def test_StructureArray(self): STRUCTURE = { 's': STRING, 'i': INT, 'ru': ({ 'i': INT, 'd': DOUBLE, 's': STRING }, ), 'vu': (), 'st': { 'i': INT, 'd': DOUBLE, 's': STRING }, } size = TestUtility.getRandomListSize() pv = PvObject({'v': [STRUCTURE]}) structureList = [] for i in range(0, size): pv2 = PvObject(STRUCTURE) value = TestUtility.getRandomString() pv2['s'] = value value = TestUtility.getRandomInt() pv2['i'] = value value = TestUtility.getRandomInt() unionPv = PvObject({'i': INT}, {'i': value}) pv2['ru'] = unionPv value = TestUtility.getRandomString() pv2['vu'] = PvString(value) value = TestUtility.getRandomInt() pv2['st.i'] = value value = TestUtility.getRandomString() pv2['st.s'] = value value = TestUtility.getRandomDouble() pv2['st.d'] = value structureList.append(pv2) pv['v'] = structureList sa = pv['v'] for i in range(0, size): pv2 = sa[i] assert (pv2['s'] == structureList[i]['s']) assert (pv2['i'] == structureList[i]['i']) ru = pv2['ru'][0] assert (ru['i'] == structureList[i]['ru'][0]['i']) vu = pv2['vu'][0] assert (vu['value'] == structureList[i]['vu'][0]['value']) assert (pv2['st']['i'] == structureList[i]['st.i']) assert (pv2['st']['s'] == structureList[i]['st.s']) assert (pv2['st']['d'] == structureList[i]['st.d'])
def test_VariantUnion(self): value = TestUtility.getRandomInt() pv = PvObject({'v': ()}, {'v': PvInt(value)}) u = pv['v'][0] assert (u['value'] == value) value = TestUtility.getRandomString() pv['v'] = PvString(value) u = pv['v'][0] assert (u['value'] == value) value = TestUtility.getRandomFloat() pv.setUnion(PvFloat(value)) u = pv['v'][0] TestUtility.assertFloatEquality(u['value'], value)
def test_Structure(self): pv = PvObject({ 's': STRING, 'i': INT, 'ru': ({ 'i': INT, 'd': DOUBLE, 's': STRING }, ), 'vu': (), 'st': { 'i': INT, 'd': DOUBLE, 's': STRING }, }) value = TestUtility.getRandomString() pv['s'] = value assert (pv['s'] == value) value = TestUtility.getRandomInt() pv['i'] = value assert (pv['i'] == value) value = TestUtility.getRandomInt() unionPv = PvObject({'i': INT}, {'i': value}) pv['ru'] = unionPv u = pv['ru'][0] assert (u['i'] == value) value = TestUtility.getRandomString() pv['vu'] = PvString(value) u = pv['vu'][0] assert (u['value'] == value) value = TestUtility.getRandomInt() pv['st.i'] = value assert (pv['st.i'] == value)
def testPut_PvString(self): value = TestUtility.getRandomString() c = TestUtility.getStringChannel() c.put(PvString(value)) value2 = c.get().getPyObject() assert (value == value2)
for id in value['id']: value['title'].append(titles[id - 1]) else: value['id'] = [0] value['name'] = [None] value['title'] = [None] #print("value = %s" % str(value)) newPV['value'] = value server.update('table', newPV) # create PVs tableStructDict = { 'labels': [STRING], 'value': dict(OrderedDict([('id', [UINT]), ('name', [STRING]), ('title', [STRING])])) } tablePV = PvObject(tableStructDict, "epics:nt/NTTable:1.0") tablePV['labels'] = ['ID', 'Name', 'Title'] namePV = PvString('') # create server server = PvaServer('table', tablePV) server.addRecord('name', namePV, updateValue) try: raw_input("\nEnter anything to quit\n") except NameError as ex: input("\nEnter anything to quit\n")