Example #1
0
def send_read_CMD(parameterGroup=None, parameterNumber=None):
    """
    Send Read CMD
    """
    sendReadCMD = calculate_send_read_CMD(parameterGroup, parameterNumber)
    ca.put(chSendRead, sendReadCMD)
    return None
Example #2
0
def send_write_CMD(parameterGroup=None, parameterNumber=None, value=None):
    """
    Send Write CMD
    """
    sendWriteCMD = calculate_send_write_CMD(parameterGroup, parameterNumber,
                                            value)
    ca.put(chSendWrite, sendWriteCMD)
    return None
Example #3
0
def get_unit_CMD():
    """
    Get Pressure Unit
    """
    getUnitCMD = calculate_send_read_CMD(5, 4)
    ca.put(chGetUnit, getUnitCMD)
    time.sleep(0.1)
    unitArr = ca.get(chGetUnit)
    unitGotten = convert_receive_read_value(unitArr)
    return unitGotten
Example #4
0
def get_pn_CMD():
    """
    Get Part Number
    """
    getPNCMD = calculate_send_read_CMD(5, 3)
    ca.put(chGetPN, getPNCMD)
    time.sleep(0.1)
    pnArr = ca.get(chGetPN)
    pnGotten = convert_receive_read_value(pnArr)
    return pnGotten
Example #5
0
def get_sn_CMD():
    """
    Get Serial Number
    """
    getSNCMD = calculate_send_read_CMD(5, 2)
    ca.put(chGetSN, getSNCMD)
    time.sleep(0.1)
    snArr = ca.get(chGetSN)
    snGotten = convert_receive_read_value(snArr)
    return snGotten
Example #6
0
def get_version_CMD():
    """
    Get Hardware and Software Version
    """
    getVersionCMD = calculate_send_read_CMD(5, 1)
    ca.put(chGetVersion, getVersionCMD)
    time.sleep(0.1)
    versionArr = ca.get(chGetVersion)
    versionGotten = convert_receive_read_value(versionArr)
    return versionGotten
Example #7
0
def test_putwait():
    'test put with wait'
    pvn = pvnames.non_updating_pv
    chid = ca.create_channel(pvn, connect=True)
    o = ca.put(chid, -1, wait=True)
    time.sleep(0.01)
    assert ca.get(chid) == -1

    ca.put(chid, 2, wait=True)
    assert ca.get(chid) == 2
Example #8
0
 def test_putwait(self):
     'test put with wait'
     pvn = pvnames.non_updating_pv
     chid = ca.create_channel(pvn, connect=True)
     o  = ca.put(chid, -1, wait=True)
     val = ca.get(chid)
     self.assertEqual(val, -1)
     o  = ca.put(chid, 2, wait=True)
     val = ca.get(chid)
     self.assertEqual(val, 2)
Example #9
0
 def test_putwait(self):
     'test put with wait'
     pvn = pvnames.non_updating_pv
     chid = ca.create_channel(pvn, connect=True)
     o  = ca.put(chid, -1, wait=True)
     val = ca.get(chid)
     self.assertEqual(val, -1)
     o  = ca.put(chid, 2, wait=True)
     val = ca.get(chid)
     self.assertEqual(val, 2)
Example #10
0
def get_press2_CMD():
    """
    Get Pressure Data in CH.2
    """
    getPressCMD2 = calculate_send_read_CMD(2, 29)
    ca.put(chGetPress2, getPressCMD2)
    time.sleep(0.1)
    pressArr2 = ca.get(chGetPress2)
    pressGotten2 = convert_receive_read_value(pressArr2)
    return pressGotten2
Example #11
0
def get_press1_CMD():
    """
    Get Pressure Data in CH.1
    """
    getPressCMD1 = calculate_send_read_CMD(1, 29)
    ca.put(chGetPress1, getPressCMD1)
    time.sleep(0.1)
    pressArr1 = ca.get(chGetPress1)
    pressGotten1 = convert_receive_read_value(pressArr1)
    return pressGotten1
Example #12
0
    def test_xArray2(self):
        write('Array Test: get fewer than max vals with ca.get(count=0)')
        chid = ca.create_channel(pvnames.double_arrays[0])
        maxpts = ca.element_count(chid)
        npts = max(2, maxpts/2 - 1)
        dat = numpy.random.normal(size=npts)
        ca.put(chid, dat)

        out = ca.get(chid, count=0)
        self.assertTrue(isinstance(out, numpy.ndarray))
        self.assertEqual(len(out), npts)
Example #13
0
    def test_xArray2(self):
        write('Array Test: get fewer than max vals with ca.get(count=0)')
        chid = ca.create_channel(pvnames.double_arrays[0])
        maxpts = ca.element_count(chid)
        npts = max(2, maxpts/2 - 1)
        dat = numpy.random.normal(size=npts)
        ca.put(chid, dat)

        out = ca.get(chid, count=0)
        self.assertTrue(isinstance(out, numpy.ndarray))
        self.assertTrue(len(out) == npts)
    def testEnumPropCache_ValueMonitorCTRLget(self):
        '''Monitor PV (value events) through GW - change ENUM string directly - get the DBR_CTRL of the PV through GW'''
        # gateway should show no VC (client side connection) and no PV (IOC side connection)
        self.updateGwStats()
        self.assertTrue(self.vctotal == 0, "Expected GW VC total count: 0, actual: " + str(self.vctotal))
        self.assertTrue(self.pvtotal == 0, "Expected GW PV total count: 0, actual: " + str(self.pvtotal))
        self.assertTrue(self.connected == 0, "Expected GW connected PV count: 0, actual: " + str(self.connected))
        self.assertTrue(self.active == 0, "Expected GW active PV count: 0, actual: " + str(self.active))
        self.assertTrue(self.inactive == 0, "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # enumtest is an mbbi record with three strings defined: zero one two
        gw = ca.create_channel("gateway:enumtest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected, "Could not connect to gateway channel " + ca.name(gw))
        (gw_cbref, gw_uaref, gw_eventid) = ca.create_subscription(gw, mask=dbr.DBE_VALUE, callback=self.onChange)
        ioc = ca.create_channel("ioc:enumtest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected, "Could not connect to ioc channel " + ca.name(gw))
        (ioc_cbref, ioc_uaref, ioc_eventid) = ca.create_subscription(ioc, mask=dbr.DBE_VALUE, callback=self.onChange)

        # gateway should show one VC and one connected active PV
        self.updateGwStats()
        self.assertTrue(self.vctotal == 1, "Expected GW VC total count: 1, actual: " + str(self.vctotal))
        self.assertTrue(self.pvtotal == 1, "Expected GW PV total count: 1, actual: " + str(self.pvtotal))
        self.assertTrue(self.connected == 1, "Expected GW connected PV count: 1, actual: " + str(self.connected))
        self.assertTrue(self.active == 1, "Expected GW active PV count: 1, actual: " + str(self.active))
        self.assertTrue(self.inactive == 0, "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # enum string should not have been updated
        ioc_ctrl = ca.get_ctrlvars(ioc)
        oneStr = ioc_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'one', "Expected IOC enum[1]: one; actual enum[1]: "+ oneStr)
        gw_ctrl = ca.get_ctrlvars(gw)
        oneStr = gw_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'one', "Expected GW enum[1]: one; actual enum[1]: "+ oneStr)

        # set enum string on IOC
        ioc_enum1 = ca.create_channel("ioc:enumtest.ONST")
        ca.put(ioc_enum1, 'uno', wait=True)
        time.sleep(.1)

        # Now the enum string should have been updated (if IOC supports DBE_PROPERTY)
        ioc_ctrl = ca.get_ctrlvars(ioc)
        oneStr = ioc_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'uno', "Expected IOC enum[1]: uno; actual enum[1]: "+ oneStr)
        if self.propSupported:
            gw_expected = 'uno'
        else:
            gw_expected = 'one'
        gw_ctrl = ca.get_ctrlvars(gw)
        oneStr = gw_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == gw_expected, "Expected GW enum[1]: {0}; actual enum[1]: {1}".format(gw_expected, oneStr))
Example #15
0
 def test_xArray2(self):
     write('Array Test: get fewer than max vals using ca.get(count=0)')
     chid = ca.create_channel(pvnames.double_arrays[0])
     maxpts = ca.element_count(chid)
     npts = int(max(2, maxpts/2.3 - 1))
     dat = numpy.random.normal(size=npts)
     ca.put(chid, dat)
     out1 = ca.get(chid)
     self.assertTrue(isinstance(out1, numpy.ndarray))
     self.assertEqual(len(out1), maxpts)
     out2 = ca.get(chid, count=0)
     self.assertTrue(isinstance(out2, numpy.ndarray))
     self.assertEqual(len(out2), npts)
Example #16
0
def test_subscription_str():
    pvn = pvnames.updating_str1
    write(" Subscription on string: %s " % pvn)
    chid = ca.create_channel(pvn, connect=True)
    cb, uarg, eventID = ca.create_subscription(chid, callback=onChanges)

    start_time = time.time()
    global CHANGE_DAT
    while time.time() - start_time < 3.0:
        time.sleep(0.01)
        ca.put(chid, "%.1f" % (time.time() - start_time))
        if CHANGE_DAT.get(pvn, None) is not None:
            break
    assert CHANGE_DAT.get(pvn, None) is not None
Example #17
0
 def test_xArray2(self):
     write('Array Test: get fewer than max vals using ca.get(count=0)')
     chid = ca.create_channel(pvnames.double_arrays[0])
     maxpts = ca.element_count(chid)
     npts = int(max(2, maxpts/2.3 - 1))
     write('max points is %s' % (maxpts, ))
     dat = numpy.random.normal(size=npts)
     write('setting array to a length of npts=%s' % (npts, ))
     ca.put(chid, dat)
     out1 = ca.get(chid)
     self.assertTrue(isinstance(out1, numpy.ndarray))
     self.assertEqual(len(out1), npts)
     out2 = ca.get(chid, count=0)
     self.assertTrue(isinstance(out2, numpy.ndarray))
     self.assertEqual(len(out2), npts)
Example #18
0
    def test_subscription_str(self):

        pvn = pvnames.updating_str1
        write(" Subscription on string: %s " % pvn)
        chid = ca.create_channel(pvn,connect=True)
        cb, uarg, eventID = ca.create_subscription(chid, callback=onChanges)

        start_time = time.time()
        global CHANGE_DAT
        while time.time()-start_time < 3.0:
            time.sleep(0.01)
            ca.put(chid, "%.1f" % (time.time()-start_time) )
            if CHANGE_DAT.get(pvn, None) is not None:
                break
        val = CHANGE_DAT.get(pvn, None)
        # ca.clear_subscription(eventID)
        self.assertNotEqual(val, None)
        time.sleep(0.2)
Example #19
0
 def test_ProcPut(self):
     pvn  = pvnames.enum_pv
     chid = ca.create_channel(pvn, connect=True)
     write( 'CA test put to PROC Field (%s)' % (pvn))
     for input in (1, '1', 2, '2', 0, '0', 50, 1):
         ret = None
         try:
             ret = ca.put(chid, 1)
         except:
             pass
         self.assertIsNot(ret, None)
Example #20
0
 def test_ProcPut(self):
     pvn  = pvnames.enum_pv
     chid = ca.create_channel(pvn, connect=True)
     write( 'CA test put to PROC Field (%s)' % (pvn))
     for input in (1, '1', 2, '2', 0, '0', 50, 1):
         ret = None
         try:
             ret = ca.put(chid, 1)
         except:
             pass
         self.assertIsNot(ret, None)
Example #21
0
 def test_ProcPut(self):
     pvn = pvnames.enum_pv
     chid = ca.create_channel(pvn, connect=True)
     write("CA test put to PROC Field (%s)" % (pvn))
     for input in (1, "1", 2, "2", 0, "0", 50, 1):
         ret = None
         try:
             ret = ca.put(chid, 1)
         except:
             pass
         self.assertNotEqual(ret, None)
Example #22
0
    def testCtrlStruct_ValueMonitor(self):
        '''Monitor PV (value events) through GW - change value and properties directly - check CTRL structure consistency'''
        diffs = []

        # gwcachetest is an ai record with full set of alarm limits: -100 -10 10 100
        gw = ca.create_channel("gateway:gwcachetest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to gateway channel " + ca.name(gw))
        (gw_cbref, gw_uaref,
         gw_eventid) = ca.create_subscription(gw,
                                              mask=dbr.DBE_VALUE,
                                              use_ctrl=True,
                                              callback=self.onChangeGW)
        ioc = ca.create_channel("ioc:gwcachetest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to ioc channel " + ca.name(ioc))
        (ioc_cbref, ioc_uaref,
         ioc_eventid) = ca.create_subscription(ioc,
                                               mask=dbr.DBE_VALUE,
                                               use_ctrl=True,
                                               callback=self.onChangeIOC)

        # set value on IOC
        ioc_value = ca.create_channel("ioc:gwcachetest")
        ca.put(ioc_value, 10.0, wait=True)
        gwtests.wait_until(
            lambda: self.eventsReceivedIOC == self.eventsReceivedGW, 5.0)

        self.assertTrue(
            self.eventsReceivedIOC == self.eventsReceivedGW,
            "After setting value, no. of received updates differ: GW {0}, IOC {1}"
            .format(str(self.eventsReceivedGW), str(self.eventsReceivedIOC)))

        (are_diff, diffs) = self.compareStructures()
        self.assertTrue(
            are_diff == False,
            "At update {0} (change value), received structure updates differ:\n\t{1}"
            .format(str(self.eventsReceivedIOC), "\n\t".join(diffs)))

        # set property on IOC
        ioc_hihi = ca.create_channel("ioc:gwcachetest.HIHI")
        ca.put(ioc_hihi, 123.0, wait=True)
        ca.put(ioc_value, 11.0, wait=True)  # trigger update
        gwtests.wait_until(
            lambda: self.eventsReceivedIOC == self.eventsReceivedGW, 5.0)

        self.assertTrue(
            self.eventsReceivedIOC == self.eventsReceivedGW,
            "After setting property, no. of received updates differ: GW {0}, IOC {1}"
            .format(str(self.eventsReceivedGW), str(self.eventsReceivedIOC)))

        (are_diff, diffs) = self.compareStructures()
        self.assertTrue(
            are_diff == False,
            "At update {0} (change property), received structure updates differ:\n\t{1}"
            .format(str(self.eventsReceivedIOC), "\n\t".join(diffs)))
    def testCtrlStruct_ValueMonitor(self):
        '''Monitor PV (value events) through GW - change value and properties directly - check CTRL structure consistency'''
        diffs = []

        # gwcachetest is an ai record with full set of alarm limits: -100 -10 10 100
        gw = ca.create_channel("gateway:gwcachetest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected, "Could not connect to gateway channel " + ca.name(gw))
        (gw_cbref, gw_uaref, gw_eventid) = ca.create_subscription(gw, mask=dbr.DBE_VALUE, use_ctrl=True, callback=self.onChangeGW)
        ioc = ca.create_channel("ioc:gwcachetest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected, "Could not connect to ioc channel " + ca.name(ioc))
        (ioc_cbref, ioc_uaref, ioc_eventid) = ca.create_subscription(ioc, mask=dbr.DBE_VALUE, use_ctrl=True, callback=self.onChangeIOC)

        # set value on IOC
        ioc_value = ca.create_channel("ioc:gwcachetest")
        ca.put(ioc_value, 10.0, wait=True)
        time.sleep(.1)

        self.assertTrue(self.eventsReceivedIOC == self.eventsReceivedGW,
        "After setting value, no. of received updates differ: GW {0}, IOC {1}"
        .format(str(self.eventsReceivedGW), str(self.eventsReceivedIOC)))
        (are_diff, diffs) = self.compareStructures()
        self.assertTrue(are_diff == False,
        "At update {0} (change value), received structure updates differ:\n\t{1}"
        .format(str(self.eventsReceivedIOC), "\n\t".join(diffs)))

        # set property on IOC
        ioc_hihi = ca.create_channel("ioc:gwcachetest.HIHI")
        ca.put(ioc_hihi, 123.0, wait=True)
        ca.put(ioc_value, 11.0, wait=True) # trigger update
        time.sleep(.1)

        self.assertTrue(self.eventsReceivedIOC == self.eventsReceivedGW,
        "After setting property, no. of received updates differ: GW {0}, IOC {1}"
        .format(str(self.eventsReceivedGW), str(self.eventsReceivedIOC)))
        (are_diff, diffs) = self.compareStructures()
        self.assertTrue(are_diff == False,
        "At update {0} (change property), received structure updates differ:\n\t{1}"
        .format(str(self.eventsReceivedIOC), "\n\t".join(diffs)))
    def testEnumPropCache_ValueGetDisconnectCTRLGet(self):
        '''Get PV (value) through GW - disconnect client - change ENUM string directly - get the DBR_CTRL of the PV through GW'''
        # gateway should show no VC (client side connection) and no PV (IOC side connection)
        self.updateGwStats()
        self.assertTrue(self.vctotal == 0, "Expected GW VC total count: 0, actual: " + str(self.vctotal))
        self.assertTrue(self.pvtotal == 0, "Expected GW PV total count: 0, actual: " + str(self.pvtotal))
        self.assertTrue(self.connected == 0, "Expected GW connected PV count: 0, actual: " + str(self.connected))
        self.assertTrue(self.active == 0, "Expected GW active PV count: 0, actual: " + str(self.active))
        self.assertTrue(self.inactive == 0, "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # enumtest is an mbbi record with three strings defined: zero one two
        gw = ca.create_channel("gateway:enumtest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected, "Could not connect to gateway channel " + ca.name(gw))
        ioc = ca.create_channel("ioc:enumtest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected, "Could not connect to ioc channel " + ca.name(gw))

        # gateway should show one VC and one connected active PV
        self.updateGwStats()
        self.assertTrue(self.vctotal == 1, "Expected GW VC total count: 1, actual: " + str(self.vctotal))
        self.assertTrue(self.pvtotal == 1, "Expected GW PV total count: 1, actual: " + str(self.pvtotal))
        self.assertTrue(self.connected == 1, "Expected GW connected PV count: 1, actual: " + str(self.connected))
        self.assertTrue(self.active == 1, "Expected GW active PV count: 1, actual: " + str(self.active))
        self.assertTrue(self.inactive == 0, "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # enum string should not have been updated
        ioc_ctrl = ca.get_ctrlvars(ioc)
        oneStr = ioc_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'one', "Expected IOC enum[1]: one; actual enum[1]: "+ oneStr)
        gw_ctrl = ca.get_ctrlvars(gw)
        oneStr = gw_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'one', "Expected GW enum[1]: one; actual enum[1]: "+ oneStr)

        # disconnect Channel Access, reconnect Gateway stats
        ca.finalize_libca()
        ca.initialize_libca()
        self.connectGwStats()

        # gateway should show no VC and 1 connected inactive PV
        self.updateGwStats()
        self.assertTrue(self.vctotal == 0, "Expected GW VC total count: 0, actual: " + str(self.vctotal))
        self.assertTrue(self.pvtotal == 1, "Expected GW PV total count: 1, actual: " + str(self.pvtotal))
        self.assertTrue(self.connected == 1, "Expected GW connected PV count: 1, actual: " + str(self.connected))
        self.assertTrue(self.active == 0, "Expected GW active PV count: 0, actual: " + str(self.active))
        self.assertTrue(self.inactive == 1, "Expected GW inactive PV count: 1, actual: " + str(self.inactive))

        # set enum string on IOC
        ioc_enum1 = ca.create_channel("ioc:enumtest.ONST")
        ca.put(ioc_enum1, 'uno', wait=True)
        time.sleep(.1)

        # reconnect Gateway and IOC
        gw = ca.create_channel("gateway:enumtest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected, "Could not connect to gateway channel " + ca.name(gw))
        ioc = ca.create_channel("ioc:enumtest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected, "Could not connect to ioc channel " + ca.name(gw))

        # gateway should show one VC and one connected active PV
        self.updateGwStats()
        self.assertTrue(self.vctotal == 1, "Expected GW VC total count: 1, actual: " + str(self.vctotal))
        self.assertTrue(self.pvtotal == 1, "Expected GW PV total count: 1, actual: " + str(self.pvtotal))
        self.assertTrue(self.connected == 1, "Expected GW connected PV count: 1, actual: " + str(self.connected))
        self.assertTrue(self.active == 1, "Expected GW active PV count: 1, actual: " + str(self.active))
        self.assertTrue(self.inactive == 0, "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # Now the enum string should have been updated
        ioc_ctrl = ca.get_ctrlvars(ioc)
        oneStr = ioc_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'uno', "Expected IOC enum[1]: uno; actual enum[1]: "+ oneStr)
        gw_ctrl = ca.get_ctrlvars(gw)
        oneStr = gw_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'uno', "Expected GW enum[1]: uno; actual enum[1]: "+ oneStr)
Example #25
0
    def testPropCache_ValueGetDisconnectCTRLGet(self):
        '''Get PV (value) through GW - disconnect client - change HIGH directly - get the DBR_CTRL of the PV through GW'''
        gw_vctotal = ca.create_channel("gwtest:vctotal")
        gw_pvtotal = ca.create_channel("gwtest:pvtotal")
        gw_connected = ca.create_channel("gwtest:connected")
        gw_active = ca.create_channel("gwtest:active")
        gw_inactive = ca.create_channel("gwtest:inactive")

        # gateway should show no VC (client side connection) and no PV (IOC side connection)
        count = ca.get(gw_vctotal)
        self.assertTrue(count == 0, "Expected GW VC total count: 0, actual: " + str(count))
        count = ca.get(gw_pvtotal)
        self.assertTrue(count == 0, "Expected GW PV total count: 0, actual: " + str(count))
        count = ca.get(gw_connected)
        self.assertTrue(count == 0, "Expected GW connected PV count: 0, actual: " + str(count))
        count = ca.get(gw_active)
        self.assertTrue(count == 0, "Expected GW active PV count: 0, actual: " + str(count))
        count = ca.get(gw_inactive)
        self.assertTrue(count == 0, "Expected GW inactive PV count: 0, actual: " + str(count))

        # gwcachetest is an ai record with full set of alarm limits: -100 -10 10 100
        gw = ca.create_channel("gateway:gwcachetest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected, "Could not connect to gateway channel " + ca.name(gw))
        ioc = ca.create_channel("ioc:gwcachetest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected, "Could not connect to ioc channel " + ca.name(gw))

        # gateway should show one VC and one connected active PV
        count = ca.get(gw_vctotal)
        self.assertTrue(count == 1, "Expected GW VC total count: 1, actual: " + str(count))
        count = ca.get(gw_pvtotal)
        self.assertTrue(count == 1, "Expected GW PV total count: 1, actual: " + str(count))
        count = ca.get(gw_connected)
        self.assertTrue(count == 1, "Expected GW connected PV count: 1, actual: " + str(count))
        count = ca.get(gw_active)
        self.assertTrue(count == 1, "Expected GW active PV count: 1, actual: " + str(count))
        count = ca.get(gw_inactive)
        self.assertTrue(count == 0, "Expected GW inactive PV count: 0, actual: " + str(count))

        # limit should not have been updated
        ioc_ctrl = ca.get_ctrlvars(ioc)
        highVal = ioc_ctrl['upper_warning_limit']
        self.assertTrue(highVal == 10.0, "Expected IOC warning_limit: 10; actual limit: "+ str(highVal))
        gw_ctrl = ca.get_ctrlvars(gw)
        highVal = gw_ctrl['upper_warning_limit']
        self.assertTrue(highVal == 10.0, "Expected GW warning_limit: 10; actual limit: "+ str(highVal))

        # disconnect Channel Access, reconnect Gateway stats
        ca.finalize_libca()
        ca.initialize_libca()
        gw_vctotal = ca.create_channel("gwtest:vctotal")
        gw_pvtotal = ca.create_channel("gwtest:pvtotal")
        gw_connected = ca.create_channel("gwtest:connected")
        gw_active = ca.create_channel("gwtest:active")
        gw_inactive = ca.create_channel("gwtest:inactive")

        # gateway should show no VC and 1 connected inactive PV
        count = ca.get(gw_vctotal)
        self.assertTrue(count == 0, "Expected GW VC total count: 0, actual: " + str(count))
        count = ca.get(gw_pvtotal)
        self.assertTrue(count == 1, "Expected GW PV total count: 1, actual: " + str(count))
        count = ca.get(gw_connected)
        self.assertTrue(count == 1, "Expected GW connected PV count: 1, actual: " + str(count))
        count = ca.get(gw_active)
        self.assertTrue(count == 0, "Expected GW active PV count: 0, actual: " + str(count))
        count = ca.get(gw_inactive)
        self.assertTrue(count == 1, "Expected GW inactive PV count: 1, actual: " + str(count))

        # set warning limit on IOC
        ioc_high = ca.create_channel("ioc:gwcachetest.HIGH")
        ca.put(ioc_high, 20.0, wait=True)
        time.sleep(.1)

        # reconnect Gateway and IOC
        gw = ca.create_channel("gateway:gwcachetest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected, "Could not connect to gateway channel " + ca.name(gw))
        ioc = ca.create_channel("ioc:gwcachetest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected, "Could not connect to ioc channel " + ca.name(gw))

        # gateway should show one VC and one connected active PV
        count = ca.get(gw_vctotal)
        self.assertTrue(count == 1, "Expected GW VC total count: 1, actual: " + str(count))
        count = ca.get(gw_pvtotal)
        self.assertTrue(count == 1, "Expected GW PV total count: 1, actual: " + str(count))
        count = ca.get(gw_connected)
        self.assertTrue(count == 1, "Expected GW connected PV count: 1, actual: " + str(count))
        count = ca.get(gw_active)
        self.assertTrue(count == 1, "Expected GW active PV count: 1, actual: " + str(count))
        count = ca.get(gw_inactive)
        self.assertTrue(count == 0, "Expected GW inactive PV count: 0, actual: " + str(count))

        # now the limit should have been updated
        ioc_ctrl = ca.get_ctrlvars(ioc)
        highVal = ioc_ctrl['upper_warning_limit']
        self.assertTrue(highVal == 20.0, "Expected IOC warning_limit: 20; actual limit: "+ str(highVal))
        gw_ctrl = ca.get_ctrlvars(gw)
        highVal = gw_ctrl['upper_warning_limit']
        self.assertTrue(highVal == 20.0, "Expected GW warning_limit: 20; actual limit: "+ str(highVal))
Example #26
0
    def testPropCache_ValueMonitorCTRLget(self):
        '''Monitor PV (value events) through GW - change HIGH directly - get the DBR_CTRL of the PV through GW'''
        gw_vctotal = ca.create_channel("gwtest:vctotal")
        gw_pvtotal = ca.create_channel("gwtest:pvtotal")
        gw_connected = ca.create_channel("gwtest:connected")
        gw_active = ca.create_channel("gwtest:active")
        gw_inactive = ca.create_channel("gwtest:inactive")

        # gateway should show no VC (client side connection) and no PV (IOC side connection)
        count = ca.get(gw_vctotal)
        self.assertTrue(count == 0, "Expected GW VC total count: 0, actual: " + str(count))
        count = ca.get(gw_pvtotal)
        self.assertTrue(count == 0, "Expected GW PV total count: 0, actual: " + str(count))
        count = ca.get(gw_connected)
        self.assertTrue(count == 0, "Expected GW connected PV count: 0, actual: " + str(count))
        count = ca.get(gw_active)
        self.assertTrue(count == 0, "Expected GW active PV count: 0, actual: " + str(count))
        count = ca.get(gw_inactive)
        self.assertTrue(count == 0, "Expected GW inactive PV count: 0, actual: " + str(count))

        # gwcachetest is an ai record with full set of alarm limits: -100 -10 10 100
        gw = ca.create_channel("gateway:gwcachetest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected, "Could not connect to gateway channel " + ca.name(gw))
        (gw_cbref, gw_uaref, gw_eventid) = ca.create_subscription(gw, mask=dbr.DBE_VALUE, callback=self.onChange)
        ioc = ca.create_channel("ioc:gwcachetest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected, "Could not connect to ioc channel " + ca.name(gw))
        (ioc_cbref, ioc_uaref, ioc_eventid) = ca.create_subscription(ioc, mask=dbr.DBE_VALUE, callback=self.onChange)

        # gateway should show one VC and one connected active PV
        count = ca.get(gw_vctotal)
        self.assertTrue(count == 1, "Expected GW VC total count: 1, actual: " + str(count))
        count = ca.get(gw_pvtotal)
        self.assertTrue(count == 1, "Expected GW PV total count: 1, actual: " + str(count))
        count = ca.get(gw_connected)
        self.assertTrue(count == 1, "Expected GW connected PV count: 1, actual: " + str(count))
        count = ca.get(gw_active)
        self.assertTrue(count == 1, "Expected GW active PV count: 1, actual: " + str(count))
        count = ca.get(gw_inactive)
        self.assertTrue(count == 0, "Expected GW inactive PV count: 0, actual: " + str(count))

        # limit should not have been updated
        ioc_ctrl = ca.get_ctrlvars(ioc)
        highVal = ioc_ctrl['upper_warning_limit']
        self.assertTrue(highVal == 10.0, "Expected IOC warning_limit: 10; actual limit: "+ str(highVal))
        gw_ctrl = ca.get_ctrlvars(gw)
        highVal = gw_ctrl['upper_warning_limit']
        self.assertTrue(highVal == 10.0, "Expected GW warning_limit: 10; actual limit: "+ str(highVal))

        # set warning limit on IOC
        ioc_high = ca.create_channel("ioc:gwcachetest.HIGH")
        ca.put(ioc_high, 20.0, wait=True)
        time.sleep(.1)

        # Now the limit should have been updated (if IOC supports DBE_PROPERTY)
        ioc_ctrl = ca.get_ctrlvars(ioc)
        highVal = ioc_ctrl['upper_warning_limit']
        self.assertTrue(highVal == 20.0, "Expected IOC warning_limit: 20; actual limit: "+ str(highVal))
        if self.propSupported:
            gw_expected = 20.0
        else:
            gw_expected = 10.0
        gw_ctrl = ca.get_ctrlvars(gw)
        highVal = gw_ctrl['upper_warning_limit']
        self.assertTrue(highVal == gw_expected, "Expected GW warning_limit: {0}; actual limit: {1}".format(gw_expected, highVal))
    def testPropCache_ValueMonitorCTRLget(self):
        '''Monitor PV (value events) through GW - change properties (HIGH, EGU) directly - get the DBR_CTRL of the PV through GW'''
        # gateway should show no VC (client side connection) and no PV (IOC side connection)
        self.updateGwStats()
        self.assertTrue(
            self.vctotal == 0,
            "Expected GW VC total count: 0, actual: " + str(self.vctotal))
        self.assertTrue(
            self.pvtotal == 0,
            "Expected GW PV total count: 0, actual: " + str(self.pvtotal))
        self.assertTrue(
            self.connected == 0,
            "Expected GW connected PV count: 0, actual: " +
            str(self.connected))
        self.assertTrue(
            self.active == 0,
            "Expected GW active PV count: 0, actual: " + str(self.active))
        self.assertTrue(
            self.inactive == 0,
            "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # gwcachetest is an ai record with full set of alarm limits: -100 -10 10 100
        gw = ca.create_channel("gateway:gwcachetest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to gateway channel " + ca.name(gw))
        (gw_cbref, gw_uaref,
         gw_eventid) = ca.create_subscription(gw,
                                              mask=dbr.DBE_VALUE,
                                              callback=self.onChange)
        ioc = ca.create_channel("ioc:gwcachetest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to ioc channel " + ca.name(ioc))
        (ioc_cbref, ioc_uaref,
         ioc_eventid) = ca.create_subscription(ioc,
                                               mask=dbr.DBE_VALUE,
                                               callback=self.onChange)

        # gateway should show one VC and one connected active PV
        self.updateGwStats()
        self.assertTrue(
            self.vctotal == 1,
            "Expected GW VC total count: 1, actual: " + str(self.vctotal))
        self.assertTrue(
            self.pvtotal == 1,
            "Expected GW PV total count: 1, actual: " + str(self.pvtotal))
        self.assertTrue(
            self.connected == 1,
            "Expected GW connected PV count: 1, actual: " +
            str(self.connected))
        self.assertTrue(
            self.active == 1,
            "Expected GW active PV count: 1, actual: " + str(self.active))
        self.assertTrue(
            self.inactive == 0,
            "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # limit should not have been updated
        ioc_ctrl = ca.get_ctrlvars(ioc)
        highVal = ioc_ctrl['upper_warning_limit']
        self.assertTrue(
            highVal == 10.0,
            "Expected IOC warning_limit: 10; actual limit: " + str(highVal))
        gw_ctrl = ca.get_ctrlvars(gw)
        highVal = gw_ctrl['upper_warning_limit']
        self.assertTrue(
            highVal == 10.0,
            "Expected GW warning_limit: 10; actual limit: " + str(highVal))

        # set warning limit on IOC
        ioc_high = ca.create_channel("ioc:gwcachetest.HIGH")
        ca.put(ioc_high, 20.0, wait=True)
        time.sleep(.1)

        # Now the limit should have been updated (if IOC supports DBE_PROPERTY)
        ioc_ctrl = ca.get_ctrlvars(ioc)
        highVal = ioc_ctrl['upper_warning_limit']
        self.assertTrue(
            highVal == 20.0,
            "Expected IOC warning_limit: 20; actual limit: " + str(highVal))
        if self.propSupported:
            gw_expected = 20.0
        else:
            gw_expected = 10.0
        gw_ctrl = ca.get_ctrlvars(gw)
        highVal = gw_ctrl['upper_warning_limit']
        self.assertTrue(
            highVal == gw_expected,
            "Expected GW warning_limit: {0}; actual limit: {1}".format(
                gw_expected, highVal))

        # set unit string on IOC
        ioc_egu = ca.create_channel("ioc:gwcachetest.EGU")
        old_egu = ca.get(ioc_egu)
        ca.put(ioc_egu, "foo", wait=True)
        time.sleep(.1)

        # Now the unit string should have been updated (if IOC supports DBE_PROPERTY)
        ioc_ctrl = ca.get_ctrlvars(ioc)
        eguVal = ioc_ctrl['units']
        self.assertTrue(
            eguVal == "foo",
            "Expected IOC units string: foo; actual units string: " + eguVal)
        if self.propSupported:
            gw_expected = "foo"
        else:
            gw_expected = old_egu
        gw_ctrl = ca.get_ctrlvars(gw)
        eguVal = gw_ctrl['units']
        self.assertTrue(
            eguVal == gw_expected,
            "Expected GW units string: {0}; actual units string: {1}".format(
                gw_expected, eguVal))
    def testPropCache_ValueGetDisconnectCTRLGet(self):
        '''Get PV (value) through GW - disconnect client - change properties (HIGH, EGU) directly - get the DBR_CTRL of the PV through GW'''
        # gateway should show no VC (client side connection) and no PV (IOC side connection)
        self.updateGwStats()
        self.assertTrue(
            self.vctotal == 0,
            "Expected GW VC total count: 0, actual: " + str(self.vctotal))
        self.assertTrue(
            self.pvtotal == 0,
            "Expected GW PV total count: 0, actual: " + str(self.pvtotal))
        self.assertTrue(
            self.connected == 0,
            "Expected GW connected PV count: 0, actual: " +
            str(self.connected))
        self.assertTrue(
            self.active == 0,
            "Expected GW active PV count: 0, actual: " + str(self.active))
        self.assertTrue(
            self.inactive == 0,
            "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # gwcachetest is an ai record with full set of alarm limits: -100 -10 10 100
        gw = ca.create_channel("gateway:gwcachetest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to gateway channel " + ca.name(gw))
        ioc = ca.create_channel("ioc:gwcachetest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to ioc channel " + ca.name(gw))

        # gateway should show one VC and one connected active PV
        self.updateGwStats()
        self.assertTrue(
            self.vctotal == 1,
            "Expected GW VC total count: 1, actual: " + str(self.vctotal))
        self.assertTrue(
            self.pvtotal == 1,
            "Expected GW PV total count: 1, actual: " + str(self.pvtotal))
        self.assertTrue(
            self.connected == 1,
            "Expected GW connected PV count: 1, actual: " +
            str(self.connected))
        self.assertTrue(
            self.active == 1,
            "Expected GW active PV count: 1, actual: " + str(self.active))
        self.assertTrue(
            self.inactive == 0,
            "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # limit should not have been updated
        ioc_ctrl = ca.get_ctrlvars(ioc)
        highVal = ioc_ctrl['upper_warning_limit']
        self.assertTrue(
            highVal == 10.0,
            "Expected IOC warning_limit: 10; actual limit: " + str(highVal))
        eguVal = ioc_ctrl['units']
        self.assertTrue(
            eguVal == "wobbles",
            "Expected IOC units string: wobbles; actual units string: " +
            eguVal)
        gw_ctrl = ca.get_ctrlvars(gw)
        highVal = gw_ctrl['upper_warning_limit']
        self.assertTrue(
            highVal == 10.0,
            "Expected GW warning_limit: 10; actual limit: " + str(highVal))
        eguVal = gw_ctrl['units']
        self.assertTrue(
            eguVal == "wobbles",
            "Expected GW units string: wobbles; actual units string: " +
            eguVal)

        # disconnect Channel Access, reconnect Gateway stats
        ca.finalize_libca()
        ca.initialize_libca()
        self.connectGwStats()

        # gateway should show no VC and 1 connected inactive PV
        self.updateGwStats()
        self.assertTrue(
            self.vctotal == 0,
            "Expected GW VC total count: 0, actual: " + str(self.vctotal))
        self.assertTrue(
            self.pvtotal == 1,
            "Expected GW PV total count: 1, actual: " + str(self.pvtotal))
        self.assertTrue(
            self.connected == 1,
            "Expected GW connected PV count: 1, actual: " +
            str(self.connected))
        self.assertTrue(
            self.active == 0,
            "Expected GW active PV count: 0, actual: " + str(self.active))
        self.assertTrue(
            self.inactive == 1,
            "Expected GW inactive PV count: 1, actual: " + str(self.inactive))

        # set warning limit on IOC
        ioc_high = ca.create_channel("ioc:gwcachetest.HIGH")
        ca.put(ioc_high, 20.0, wait=True)
        # set unit string on IOC
        ioc_egu = ca.create_channel("ioc:gwcachetest.EGU")
        ca.put(ioc_egu, "foo", wait=True)
        time.sleep(.1)

        # reconnect Gateway and IOC
        gw = ca.create_channel("gateway:gwcachetest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to gateway channel " + ca.name(gw))
        ioc = ca.create_channel("ioc:gwcachetest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to ioc channel " + ca.name(gw))

        # gateway should show one VC and one connected active PV
        self.updateGwStats()
        self.assertTrue(
            self.vctotal == 1,
            "Expected GW VC total count: 1, actual: " + str(self.vctotal))
        self.assertTrue(
            self.pvtotal == 1,
            "Expected GW PV total count: 1, actual: " + str(self.pvtotal))
        self.assertTrue(
            self.connected == 1,
            "Expected GW connected PV count: 1, actual: " +
            str(self.connected))
        self.assertTrue(
            self.active == 1,
            "Expected GW active PV count: 1, actual: " + str(self.active))
        self.assertTrue(
            self.inactive == 0,
            "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # now the limit should have been updated
        ioc_ctrl = ca.get_ctrlvars(ioc)
        highVal = ioc_ctrl['upper_warning_limit']
        self.assertTrue(
            highVal == 20.0,
            "Expected IOC warning_limit: 20; actual limit: " + str(highVal))
        eguVal = ioc_ctrl['units']
        self.assertTrue(
            eguVal == "foo",
            "Expected IOC units string: foo; actual units string: " + eguVal)
        gw_ctrl = ca.get_ctrlvars(gw)
        highVal = gw_ctrl['upper_warning_limit']
        self.assertTrue(
            highVal == 20.0,
            "Expected GW warning_limit: 20; actual limit: " + str(highVal))
        eguVal = gw_ctrl['units']
        self.assertTrue(
            eguVal == "foo",
            "Expected GW units string: wobbles; actual units string: " +
            eguVal)
Example #29
0
    def testEnumPropCache_ValueMonitorCTRLget(self):
        '''Monitor PV (value events) through GW - change ENUM string directly - get the DBR_CTRL of the PV through GW'''
        # gateway should show no VC (client side connection) and no PV (IOC side connection)
        self.updateGwStats()
        self.assertTrue(
            self.vctotal == 0,
            "Expected GW VC total count: 0, actual: " + str(self.vctotal))
        self.assertTrue(
            self.pvtotal == 0,
            "Expected GW PV total count: 0, actual: " + str(self.pvtotal))
        self.assertTrue(
            self.connected == 0,
            "Expected GW connected PV count: 0, actual: " +
            str(self.connected))
        self.assertTrue(
            self.active == 0,
            "Expected GW active PV count: 0, actual: " + str(self.active))
        self.assertTrue(
            self.inactive == 0,
            "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # enumtest is an mbbi record with three strings defined: zero one two
        gw = ca.create_channel("gateway:enumtest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to gateway channel " + ca.name(gw))
        (gw_cbref, gw_uaref,
         gw_eventid) = ca.create_subscription(gw,
                                              mask=dbr.DBE_VALUE,
                                              callback=self.onChange)
        ioc = ca.create_channel("ioc:enumtest")
        connected = ca.connect_channel(ioc)
        self.assertTrue(connected,
                        "Could not connect to ioc channel " + ca.name(gw))
        (ioc_cbref, ioc_uaref,
         ioc_eventid) = ca.create_subscription(ioc,
                                               mask=dbr.DBE_VALUE,
                                               callback=self.onChange)

        # gateway should show one VC and one connected active PV
        self.updateGwStats()
        self.assertTrue(
            self.vctotal == 1,
            "Expected GW VC total count: 1, actual: " + str(self.vctotal))
        self.assertTrue(
            self.pvtotal == 1,
            "Expected GW PV total count: 1, actual: " + str(self.pvtotal))
        self.assertTrue(
            self.connected == 1,
            "Expected GW connected PV count: 1, actual: " +
            str(self.connected))
        self.assertTrue(
            self.active == 1,
            "Expected GW active PV count: 1, actual: " + str(self.active))
        self.assertTrue(
            self.inactive == 0,
            "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # enum string should not have been updated
        ioc_ctrl = ca.get_ctrlvars(ioc)
        oneStr = ioc_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'one',
                        "Expected IOC enum[1]: one; actual enum[1]: " + oneStr)
        gw_ctrl = ca.get_ctrlvars(gw)
        oneStr = gw_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'one',
                        "Expected GW enum[1]: one; actual enum[1]: " + oneStr)

        # set enum string on IOC
        ioc_enum1 = ca.create_channel("ioc:enumtest.ONST")
        ca.put(ioc_enum1, 'uno', wait=True)
        time.sleep(.1)

        # Now the enum string should have been updated (if IOC supports DBE_PROPERTY)
        ioc_ctrl = ca.get_ctrlvars(ioc)
        oneStr = ioc_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'uno',
                        "Expected IOC enum[1]: uno; actual enum[1]: " + oneStr)
        if self.propSupported:
            gw_expected = 'uno'
        else:
            gw_expected = 'one'
        gw_ctrl = ca.get_ctrlvars(gw)
        oneStr = gw_ctrl['enum_strs'][1]
        self.assertTrue(
            oneStr == gw_expected,
            "Expected GW enum[1]: {0}; actual enum[1]: {1}".format(
                gw_expected, oneStr))
Example #30
0
    def testEnumPropCache_ValueGetDisconnectCTRLGet(self):
        '''Get PV (value) through GW - disconnect client - change ENUM string directly - get the DBR_CTRL of the PV through GW'''
        # gateway should show no VC (client side connection) and no PV (IOC side connection)
        self.updateGwStats()
        self.assertTrue(
            self.vctotal == 0,
            "Expected GW VC total count: 0, actual: " + str(self.vctotal))
        self.assertTrue(
            self.pvtotal == 0,
            "Expected GW PV total count: 0, actual: " + str(self.pvtotal))
        self.assertTrue(
            self.connected == 0,
            "Expected GW connected PV count: 0, actual: " +
            str(self.connected))
        self.assertTrue(
            self.active == 0,
            "Expected GW active PV count: 0, actual: " + str(self.active))
        self.assertTrue(
            self.inactive == 0,
            "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # enumtest is an mbbi record with three strings defined: zero one two
        gw = ca.create_channel("gateway:enumtest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to gateway channel " + ca.name(gw))
        ioc = ca.create_channel("ioc:enumtest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to ioc channel " + ca.name(gw))

        # gateway should show one VC and one connected active PV
        self.updateGwStats()
        self.assertTrue(
            self.vctotal == 1,
            "Expected GW VC total count: 1, actual: " + str(self.vctotal))
        self.assertTrue(
            self.pvtotal == 1,
            "Expected GW PV total count: 1, actual: " + str(self.pvtotal))
        self.assertTrue(
            self.connected == 1,
            "Expected GW connected PV count: 1, actual: " +
            str(self.connected))
        self.assertTrue(
            self.active == 1,
            "Expected GW active PV count: 1, actual: " + str(self.active))
        self.assertTrue(
            self.inactive == 0,
            "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # enum string should not have been updated
        ioc_ctrl = ca.get_ctrlvars(ioc)
        oneStr = ioc_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'one',
                        "Expected IOC enum[1]: one; actual enum[1]: " + oneStr)
        gw_ctrl = ca.get_ctrlvars(gw)
        oneStr = gw_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'one',
                        "Expected GW enum[1]: one; actual enum[1]: " + oneStr)

        # disconnect Channel Access, reconnect Gateway stats
        ca.finalize_libca()
        ca.initialize_libca()
        self.connectGwStats()

        # gateway should show no VC and 1 connected inactive PV
        self.updateGwStats()
        self.assertTrue(
            self.vctotal == 0,
            "Expected GW VC total count: 0, actual: " + str(self.vctotal))
        self.assertTrue(
            self.pvtotal == 1,
            "Expected GW PV total count: 1, actual: " + str(self.pvtotal))
        self.assertTrue(
            self.connected == 1,
            "Expected GW connected PV count: 1, actual: " +
            str(self.connected))
        self.assertTrue(
            self.active == 0,
            "Expected GW active PV count: 0, actual: " + str(self.active))
        self.assertTrue(
            self.inactive == 1,
            "Expected GW inactive PV count: 1, actual: " + str(self.inactive))

        # set enum string on IOC
        ioc_enum1 = ca.create_channel("ioc:enumtest.ONST")
        ca.put(ioc_enum1, 'uno', wait=True)
        time.sleep(.1)

        # reconnect Gateway and IOC
        gw = ca.create_channel("gateway:enumtest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to gateway channel " + ca.name(gw))
        ioc = ca.create_channel("ioc:enumtest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to ioc channel " + ca.name(gw))

        # gateway should show one VC and one connected active PV
        self.updateGwStats()
        self.assertTrue(
            self.vctotal == 1,
            "Expected GW VC total count: 1, actual: " + str(self.vctotal))
        self.assertTrue(
            self.pvtotal == 1,
            "Expected GW PV total count: 1, actual: " + str(self.pvtotal))
        self.assertTrue(
            self.connected == 1,
            "Expected GW connected PV count: 1, actual: " +
            str(self.connected))
        self.assertTrue(
            self.active == 1,
            "Expected GW active PV count: 1, actual: " + str(self.active))
        self.assertTrue(
            self.inactive == 0,
            "Expected GW inactive PV count: 0, actual: " + str(self.inactive))

        # Now the enum string should have been updated
        ioc_ctrl = ca.get_ctrlvars(ioc)
        oneStr = ioc_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'uno',
                        "Expected IOC enum[1]: uno; actual enum[1]: " + oneStr)
        gw_ctrl = ca.get_ctrlvars(gw)
        oneStr = gw_ctrl['enum_strs'][1]
        self.assertTrue(oneStr == 'uno',
                        "Expected GW enum[1]: uno; actual enum[1]: " + oneStr)
Example #31
0
    def testCSStudio_ValueAndPropMonitor(self):
        '''Monitor PV (imitating CS-Studio) through GW - change value and properties directly - check CTRL structure consistency'''
        diffs = []

        if gwtests.verbose:
            print()
        # gwcachetest is an ai record with full set of alarm limits: -100 -10 10 100
        gw = ca.create_channel("gateway:gwcachetest")
        connected = ca.connect_channel(gw, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to gateway channel " + ca.name(gw))
        (gw_cbref, gw_uaref, gw_eventid) = ca.create_subscription(
            gw,
            mask=dbr.DBE_VALUE | dbr.DBE_ALARM,
            use_time=True,
            callback=self.onChangeGW)
        (gw_cbref2, gw_uaref2,
         gw_eventid2) = ca.create_subscription(gw,
                                               mask=dbr.DBE_PROPERTY,
                                               use_ctrl=True,
                                               callback=self.onChangeGW)
        ioc = ca.create_channel("ioc:gwcachetest")
        connected = ca.connect_channel(ioc, timeout=.5)
        self.assertTrue(connected,
                        "Could not connect to ioc channel " + ca.name(ioc))
        (ioc_cbref, ioc_uaref, ioc_eventid) = ca.create_subscription(
            ioc,
            mask=dbr.DBE_VALUE | dbr.DBE_ALARM,
            use_time=True,
            callback=self.onChangeIOC)
        (ioc_cbref2, ioc_uaref2,
         ioc_eventid2) = ca.create_subscription(ioc,
                                                mask=dbr.DBE_PROPERTY,
                                                use_ctrl=True,
                                                callback=self.onChangeIOC)

        time.sleep(.1)

        # set value on IOC
        ioc_value = ca.create_channel("ioc:gwcachetest")
        ca.put(ioc_value, 10.0, wait=True)
        time.sleep(.1)
        if gwtests.verbose:
            print()

        self.assertTrue(
            self.eventsReceivedIOC == self.eventsReceivedGW,
            "After setting value, no. of received updates differ: GW {0}, IOC {1}"
            .format(str(self.eventsReceivedGW), str(self.eventsReceivedIOC)))

        (are_diff, diffs) = self.compareStructures()
        self.assertTrue(
            are_diff == False,
            "At update {0} (change value), received structure updates differ:\n\t{1}"
            .format(str(self.eventsReceivedIOC), "\n\t".join(diffs)))

        # set property on IOC
        ioc_hihi = ca.create_channel("ioc:gwcachetest.HIHI")
        ca.put(ioc_hihi, 123.0, wait=True)
        time.sleep(.1)
        if gwtests.verbose:
            print()
        ca.put(ioc_value, 11.0, wait=True)
        time.sleep(.1)
        if gwtests.verbose:
            print()

        self.assertTrue(
            self.eventsReceivedIOC == self.eventsReceivedGW,
            "After setting property, no. of received updates differ: GW {0}, IOC {1}"
            .format(str(self.eventsReceivedGW), str(self.eventsReceivedIOC)))

        (are_diff, diffs) = self.compareStructures()
        self.assertTrue(
            are_diff == False,
            "At update {0} (change property), received structure updates differ:\n\t{1}"
            .format(str(self.eventsReceivedIOC), "\n\t".join(diffs)))