コード例 #1
0
ファイル: ca_unittest.py プロジェクト: thzfelcg/pyepics
    def test_type_converions_2(self):
        write("CA type conversions arrays")
        pvlist = (pvnames.char_arr_pv,
                  pvnames.long_arr_pv,
                  pvnames.double_arr_pv)
        with no_simulator_updates():
            chids = []
            for name in pvlist:
                chid = ca.create_channel(name)
                ca.connect_channel(chid)
                chids.append((chid, name))
                ca.poll(evt=0.025, iot=5.0)
            ca.poll(evt=0.05, iot=10.0)

            values = {}
            for chid, name in chids:
                values[name] = ca.get(chid)
            for promotion in ('ctrl', 'time'):
                for chid, pvname in chids:
                    write('=== %s  chid=%s as %s' % (ca.name(chid), repr(chid),
                                                     promotion))
                    time.sleep(0.01)
                    if promotion == 'ctrl':
                        ntype = ca.promote_type(chid, use_ctrl=True)
                    else:
                        ntype = ca.promote_type(chid, use_time=True)

                    val  = ca.get(chid, ftype=ntype)
                    cval = ca.get(chid, as_string=True)
                    for a, b in zip(val, values[pvname]):
                        self.assertEqual(a, b)
コード例 #2
0
ファイル: pv_unittest.py プロジェクト: danielballan/pyepics
    def test_type_converions_2(self):
        write("CA type conversions arrays\n")
        pvlist = (pvnames.char_arr_pv,
                  pvnames.long_arr_pv,
                  pvnames.double_arr_pv)
        with no_simulator_updates():
            chids = []
            for name in pvlist:
                chid = ca.create_channel(name)
                ca.connect_channel(chid)
                chids.append((chid, name))
                ca.poll(evt=0.025, iot=5.0)
            ca.poll(evt=0.05, iot=10.0)

            values = {}
            for chid, name in chids:
                values[name] = ca.get(chid)
            for promotion in ('ctrl', 'time'):
                for chid, pvname in chids:
                    write('=== %s  chid=%s as %s\n' % (ca.name(chid),
                                                       repr(chid), promotion))
                    time.sleep(0.01)
                    if promotion == 'ctrl':
                        ntype = ca.promote_type(chid, use_ctrl=True)
                    else:
                        ntype = ca.promote_type(chid, use_time=True)

                    val  = ca.get(chid, ftype=ntype)
                    cval = ca.get(chid, as_string=True)
                    for a, b in zip(val, values[pvname]):
                        self.assertEqual(a, b)
コード例 #3
0
ファイル: ca_unittest.py プロジェクト: thzfelcg/pyepics
    def test_type_converions_1(self):
        write("CA type conversions scalars")
        pvlist = (pvnames.str_pv, pvnames.int_pv, pvnames.float_pv,
                  pvnames.enum_pv,  pvnames.long_pv,  pvnames.double_pv2)
        chids = []
        with no_simulator_updates():
            for name in pvlist:
                chid = ca.create_channel(name)
                ca.connect_channel(chid)
                chids.append((chid, name))
                ca.poll(evt=0.025, iot=5.0)
            ca.poll(evt=0.05, iot=10.0)

            values = {}
            for chid, name in chids:
                values[name] = ca.get(chid, as_string=True)

            for promotion in ('ctrl', 'time'):
                for chid, pvname in chids:
                    write('=== %s  chid=%s as %s' % (ca.name(chid), repr(chid),
                                                     promotion))
                    time.sleep(0.01)
                    if promotion == 'ctrl':
                        ntype = ca.promote_type(chid, use_ctrl=True)
                    else:
                        ntype = ca.promote_type(chid, use_time=True)

                    val  = ca.get(chid, ftype=ntype)
                    cval = ca.get(chid, as_string=True)
                    if ca.element_count(chid) > 1:
                        val = val[:12]
                    self.assertEqual(cval, values[pvname])
コード例 #4
0
ファイル: ca_unittest.py プロジェクト: peteut/pyepics
    def test_type_converions_1(self):
        write("CA type conversions scalars")
        pvlist = (pvnames.str_pv, pvnames.int_pv, pvnames.float_pv,
                  pvnames.enum_pv,  pvnames.long_pv,  pvnames.double_pv2)
        chids = []
        pause_updating()
        for name in pvlist:
            chid = ca.create_channel(name)
            ca.connect_channel(chid)
            chids.append((chid, name))
            ca.poll(evt=0.025, iot=5.0)
        ca.poll(evt=0.05, iot=10.0)

        values = {}
        for chid, name in chids:
            values[name] = ca.get(chid, as_string=True)

        for promotion in ('ctrl', 'time'):
            for chid, pvname in chids:
                write('=== %s  chid=%s as %s' % (ca.name(chid),
                                                   repr(chid), promotion))
                time.sleep(0.01)
                if promotion == 'ctrl':
                    ntype = ca.promote_type(chid, use_ctrl=True)
                else:
                    ntype = ca.promote_type(chid, use_time=True)

                val  = ca.get(chid, ftype=ntype)
                cval = ca.get(chid, as_string=True)
                if ca.element_count(chid) > 1:
                    val = val[:12]
                self.assertEqual(cval, values[pvname])
        resume_updating()
コード例 #5
0
ファイル: ca_unittest.py プロジェクト: thzfelcg/pyepics
 def test_promote_type(self):
     pvn = pvnames.double_pv
     chid = ca.create_channel(pvn,connect=True)
     write( 'CA promote type (%s)' % (pvn))
     f_t  = ca.promote_type(chid,use_time=True)
     f_c  = ca.promote_type(chid,use_ctrl=True)
     self.assertEqual(f_t, ca.dbr.TIME_DOUBLE)
     self.assertEqual(f_c, ca.dbr.CTRL_DOUBLE)
コード例 #6
0
ファイル: ca_unittest.py プロジェクト: peteut/pyepics
 def test_promote_type(self):
     pvn = pvnames.double_pv
     chid = ca.create_channel(pvn,connect=True)
     write( 'CA promote type (%s)' % (pvn))
     f_t  = ca.promote_type(chid,use_time=True)
     f_c  = ca.promote_type(chid,use_ctrl=True)
     self.assertEqual(f_t, ca.dbr.TIME_DOUBLE)
     self.assertEqual(f_c, ca.dbr.CTRL_DOUBLE)
コード例 #7
0
    def run_subprocess(pvs, pipe):
        pvschid = []
        for pv in pvs:
            chid = ca.create_channel(pv, connect=False, auto_cb=False)
            pvschid.append(chid)

        for chid in pvschid:
            ca.connect_channel(chid)
        time.sleep(5)
        for chid in pvschid:
            ftype = ca.promote_type(chid, use_time=True, use_ctrl=False)

        ca.poll()
        while pipe.recv():
            for chid in pvschid:
                ca.get_with_metadata(chid, ftype=ftype, wait=False)
            out = []
            for chid in pvschid:
                data = ca.get_complete_with_metadata(chid, ftype=ftype)
                out.append(data['timestamp'])
            pipe.send(out)
コード例 #8
0
def test_promote_type():
    pvn = pvnames.double_pv
    chid = ca.create_channel(pvn, connect=True)
    write('CA promote type (%s)' % (pvn))
    assert ca.promote_type(chid, use_time=True) == ca.dbr.TIME_DOUBLE
    assert ca.promote_type(chid, use_ctrl=True) == ca.dbr.CTRL_DOUBLE