def test_setData_dev_prop(self): device = 'stestp09/testss/s1r228' proxy = PyTango.DeviceProxy(device) self.assertTrue(ProxyHelper.wait(proxy, 10000)) fun = sys._getframe().f_code.co_name print("Run: %s.%s() " % (self.__class__.__name__, fun)) arr = { "DeviceBoolean": ["ScalarBoolean", "bool", "DevBoolean", True], # "DeviceUChar":["ScalarUChar", "uint8", "DevUChar", 23], "DeviceShort": ["ScalarShort", "int16", "DevShort", -123], "DeviceUShort": ["ScalarUShort", "uint16", "DevUShort", 1234], "DeviceLong": ["ScalarLong", "int64", "DevLong", -124], "DeviceULong": ["ScalarULong", "uint64", "DevULong", 234], # "DeviceLong64":["ScalarLong64", "int64", "DevLong64", 234], # "DeviceULong64":["ScalarULong64", "uint64", "DevULong64", 23], "DeviceFloat": ["ScalarFloat", "float32", "DevFloat", 12.234], "DeviceDouble": ["ScalarDouble", "float64", "DevDouble", -2.456673e+02], "DeviceString": ["ScalarString", "string", "DevString", "MyTrue"], } prop = self._simps.dp.get_property(list(arr.keys())) for k in prop.keys(): prop[k] = [arr[k][3]] self._simps.dp.put_property(prop) for k in arr: mb = TgMember(k, "property") da = proxy.get_property(k)[k] mb.setData(da) dt = mb.getValue() self.checkData(dt, "SCALAR", str(arr[k][3]), 'DevString', [1, 0], None, None, arr[k][4] if len(arr[k]) > 4 else 0)
def test_setData_command(self): fun = sys._getframe().f_code.co_name print("Run: %s.%s() " % (self.__class__.__name__, fun)) device = 'stestp09/testss/s1r228' proxy = PyTango.DeviceProxy(device) self.assertTrue(ProxyHelper.wait(proxy, 10000)) arr = { "GetBoolean": ["ScalarBoolean", "bool", "DevBoolean", True], # "GetUChar":["ScalarUChar", "uint8", "DevUChar", 23], "GetShort": ["ScalarShort", "int16", "DevShort", -123], "GetUShort": ["ScalarUShort", "uint16", "DevUShort", 1234], "GetLong": ["ScalarLong", "int64", "DevLong", -124], "GetULong": ["ScalarULong", "uint64", "DevULong", 234], "GetLong64": ["ScalarLong64", "int64", "DevLong64", 234], "GetULong64": ["ScalarULong64", "uint64", "DevULong64", 23], "GetFloat": ["ScalarFloat", "float32", "DevFloat", 12.234, 1e-5], "GetDouble": ["ScalarDouble", "float64", "DevDouble", -2.456673e+02, 1e-14], "GetString": ["ScalarString", "string", "DevString", "MyTrue"], } for k in arr: self._simps.dp.write_attribute(arr[k][0], arr[k][3]) for k in arr: mb = TgMember(k, "command") cd = proxy.command_query(k) da = proxy.command_inout(k) mb.setData(da, cd) dt = mb.getValue() self.checkData(dt, "SCALAR", arr[k][3], arr[k][2], [1, 0], None, None, arr[k][4] if len(arr[k]) > 4 else 0)
def test_setData_scalar(self): fun = sys._getframe().f_code.co_name print("Run: %s.%s() " % (self.__class__.__name__, fun)) device = 'stestp09/testss/s1r228' proxy = PyTango.DeviceProxy(device) self.assertTrue(ProxyHelper.wait(proxy, 10000)) arr1 = { "ScalarBoolean": ["bool", "DevBoolean", True], "ScalarUChar": ["uint8", "DevUChar", 23], "ScalarShort": ["int16", "DevShort", -123], "ScalarUShort": ["uint16", "DevUShort", 1234], "ScalarLong": ["int64", "DevLong", -124], "ScalarULong": ["uint64", "DevULong", 234], "ScalarLong64": ["int64", "DevLong64", 234], "ScalarULong64": ["uint64", "DevULong64", 23], "ScalarFloat": ["float32", "DevFloat", 12.234, 1e-5], "ScalarDouble": ["float64", "DevDouble", -2.456673e+02, 1e-14], "ScalarString": ["string", "DevString", "MyTrue"], } arr2 = { "State": ["string", "DevState", PyTango._PyTango.DevState.ON], } arr3 = { "ScalarEncoded": [ "string", "DevEncoded", ("UTF8", b"Hello UTF8! Pr\xc3\xb3ba \xe6\xb5\x8b") ], "SpectrumEncoded": [ "string", "DevEncoded", ('INT32', b'\xd2\x04\x00\x00.\x16\x00\x00-' b'\x00\x00\x00Y\x01\x00\x00') ], } for k in arr1: self._simps.dp.write_attribute(k, arr1[k][2]) arr = dict(arr1, **(arr2)) for k in arr: mb = TgMember(k) da = proxy.read_attribute(k) mb.setData(da) dt = mb.getValue() self.checkData(dt, "SCALAR", arr[k][2], arr[k][1], [1, 0], None, None, arr[k][3] if len(arr[k]) > 3 else 0) if not PYTG_BUG_213: for k in arr3: mb = TgMember(k, encoding=arr3[k][2][0]) da = proxy.read_attribute(k) mb.setData(da) dp = DecoderPool() dt = mb.getValue(dp) self.checkData(dt, "SCALAR", arr3[k][2], arr3[k][1], [1, 0], arr3[k][2][0], dp)
def test_setData_image(self): fun = sys._getframe().f_code.co_name print("Run: %s.%s() " % (self.__class__.__name__, fun)) device = 'stestp09/testss/s1r228' proxy = PyTango.DeviceProxy(device) self.assertTrue(ProxyHelper.wait(proxy, 10000)) arr = { "ImageBoolean": ["bool", "DevBoolean", True, [1, 0]], "ImageUChar": ["uint8", "DevUChar", 23, [1, 0]], "ImageShort": ["int16", "DevShort", -123, [1, 0]], "ImageUShort": ["uint16", "DevUShort", 1234, [1, 0]], "ImageLong": ["int64", "DevLong", -124, [1, 0]], "ImageULong": ["uint64", "DevULong", 234, [1, 0]], "ImageLong64": ["int64", "DevLong64", 234, [1, 0]], "ImageULong64": ["uint64", "DevULong64", 23, [1, 0]], "ImageFloat": ["float32", "DevFloat", 12.234, [1, 0], 1e-5], "ImageDouble": ["float64", "DevDouble", -2.456673e+02, [1, 0], 1e-14], "ImageString": ["string", "DevString", "MyTrue", [1, 0]], } for k in arr: mlen = [ self.__rnd.randint(1, 10), self.__rnd.randint(1, 10), self.__rnd.randint(0, 3) ] if arr[k][1] != "DevBoolean": arr[k][2] = [[ arr[k][2] * self.__rnd.randint(0, 3) for r in range(mlen[1]) ] for c in range(mlen[0])] else: mlen = [self.__rnd.randint(1, 10), self.__rnd.randint(1, 10)] if arr[k][1] == 'DevBoolean': arr[k][2] = [[(True if self.__rnd.randint(0, 1) else False) for c in range(mlen[1])] for r in range(mlen[0])] arr[k][3] = [mlen[0], mlen[1]] self._simps.dp.write_attribute(k, arr[k][2]) for k in arr: mb = TgMember(k) da = proxy.read_attribute(k) mb.setData(da) dt = mb.getValue() self.checkData(dt, "IMAGE", arr[k][2], arr[k][1], arr[k][3], None, None, arr[k][4] if len(arr[k]) > 4 else 0)
def test_constructor_default(self): fun = sys._getframe().f_code.co_name print("Run: %s.%s() " % (self.__class__.__name__, fun)) name = "myname%s" % self.__rnd.randint(0, 9) memberType = self.__rnd.choice(["attribute", "command", "property"]) encoding = "encoding%s" % self.__rnd.randint(0, 9) mb = TgMember(name) self.assertEqual(mb.name, name) self.assertEqual(mb.memberType, 'attribute') self.assertEqual(mb.encoding, None) mb = TgMember(name, memberType) self.assertEqual(mb.name, name) self.assertEqual(mb.memberType, memberType) self.assertEqual(mb.encoding, None) mb = TgMember(name, memberType, encoding) self.assertEqual(mb.name, name) self.assertEqual(mb.memberType, memberType) self.assertEqual(mb.encoding, encoding)
def test_getData_dev_prop(self): fun = sys._getframe().f_code.co_name print("Run: %s.%s() " % (self.__class__.__name__, fun)) arr = { "DeviceBoolean": ["ScalarBoolean", "bool", "DevBoolean", True], # "DeviceUChar":["ScalarUChar", "uint8", "DevUChar", 23], "DeviceShort": ["ScalarShort", "int16", "DevShort", -123], "DeviceUShort": ["ScalarUShort", "uint16", "DevUShort", 1234], "DeviceLong": ["ScalarLong", "int64", "DevLong", -124], "DeviceULong": ["ScalarULong", "uint64", "DevULong", 234], # "DeviceLong64":["ScalarLong64", "int64", "DevLong64", 234], # "DeviceULong64":["ScalarULong64", "uint64", "DevULong64", 23], "DeviceFloat": ["ScalarFloat", "float32", "DevFloat", 12.234], "DeviceDouble": ["ScalarDouble", "float64", "DevDouble", -2.456673e+02], "DeviceString": ["ScalarString", "string", "DevString", "MyTrue"], } arrb = { "DeviceBoolean": ["ScalarBoolean", "bool", "DevBoolean", False], # "DeviceUChar":["ScalarUChar", "uint8", "DevUChar", 21], "DeviceShort": ["ScalarShort", "int16", "DevShort", -113], "DeviceUShort": ["ScalarUShort", "uint16", "DevUShort", 1232], "DeviceLong": ["ScalarLong", "int64", "DevLong", -112], "DeviceULong": ["ScalarULong", "uint64", "DevULong", 221], # "DeviceLong64":["ScalarLong64", "int64", "DevLong64", 414], # "DeviceULong64":["ScalarULong64", "uint64", "DevULong64", 12], "DeviceFloat": ["ScalarFloat", "float32", "DevFloat", 11.111], "DeviceDouble": ["ScalarDouble", "float64", "DevDouble", -1.111673e+02], "DeviceString": ["ScalarString", "string", "DevString", "Mywrew"], } counter = self.__rnd.randint(-2, 10) for k in arr: self._simps.dp.write_attribute(arr[k][0], arr[k][3]) for k in arrb: self._simps2.dp.write_attribute(arrb[k][0], arrb[k][3]) dvn = 'stestp09/testss/s1r228' dvn2 = 'stestp09/testss/s2r228' gr = TgGroup(-100) dv = gr.getDevice(dvn) dv2 = gr.getDevice(dvn2) flip = True for k in arr: mb = TgMember(k, "property") if flip: dv.setMember(mb) else: dv2.setMember(mb) flip = not flip gr.getData(counter) for k in arr: self._simps.dp.write_attribute(arrb[k][0], arrb[k][3]) for k in arrb: self._simps2.dp.write_attribute(arr[k][0], arr[k][3]) flip = True for k in arr: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "SCALAR", str(self._simps.device_prop[k]), 'DevString', [1, 0], None, None, arr[k][4] if len(arr[k]) > 4 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "SCALAR", str(self._simps.device_prop[k]), 'DevString', [1, 0], None, None, arrb[k][4] if len(arrb[k]) > 4 else 0) flip = not flip gr.getData(counter) flip = True for k in arr: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "SCALAR", str(self._simps.device_prop[k]), 'DevString', [1, 0], None, None, arr[k][4] if len(arrb[k]) > 4 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "SCALAR", str(self._simps.device_prop[k]), 'DevString', [1, 0], None, None, arrb[k][4] if len(arr[k]) > 4 else 0) flip = not flip gr.getData(counter + 1) flip = True for k in arrb: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "SCALAR", str(self._simps.device_prop[k]), 'DevString', [1, 0], None, None, arrb[k][4] if len(arrb[k]) > 4 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "SCALAR", str(self._simps.device_prop[k]), 'DevString', [1, 0], None, None, arr[k][4] if len(arr[k]) > 4 else 0) flip = not flip
def test_getData_command(self): fun = sys._getframe().f_code.co_name print("Run: %s.%s() " % (self.__class__.__name__, fun)) arr = { "GetBoolean": ["ScalarBoolean", "bool", "DevBoolean", True], # "GetUChar":["ScalarUChar", "uint8", "DevUChar", 23], "GetShort": ["ScalarShort", "int16", "DevShort", -123], "GetUShort": ["ScalarUShort", "uint16", "DevUShort", 1234], "GetLong": ["ScalarLong", "int64", "DevLong", -124], "GetULong": ["ScalarULong", "uint64", "DevULong", 234], "GetLong64": ["ScalarLong64", "int64", "DevLong64", 234], "GetULong64": ["ScalarULong64", "uint64", "DevULong64", 23], "GetFloat": ["ScalarFloat", "float32", "DevFloat", 12.234, 1e-5], "GetDouble": ["ScalarDouble", "float64", "DevDouble", -2.456673e+02, 1e-14], "GetString": ["ScalarString", "string", "DevString", "MyTrue"], } arrb = { "GetBoolean": ["ScalarBoolean", "bool", "DevBoolean", True], # "GetUChar":["ScalarUChar", "uint8", "DevUChar", 23], "GetShort": ["ScalarShort", "int16", "DevShort", -121], "GetUShort": ["ScalarUShort", "uint16", "DevUShort", 1223], "GetLong": ["ScalarLong", "int64", "DevLong", -344], "GetULong": ["ScalarULong", "uint64", "DevULong", 124], "GetLong64": ["ScalarLong64", "int64", "DevLong64", 234], "GetULong64": ["ScalarULong64", "uint64", "DevULong64", 1345], "GetFloat": ["ScalarFloat", "float32", "DevFloat", 2.123, 1e-5], "GetDouble": ["ScalarDouble", "float64", "DevDouble", -1.1233213e+02, 1e-14], "GetString": ["ScalarString", "string", "DevString", "MyFAADSD"], } counter = self.__rnd.randint(-2, 10) for k in arr: self._simps.dp.write_attribute(arr[k][0], arr[k][3]) for k in arrb: self._simps2.dp.write_attribute(arrb[k][0], arrb[k][3]) dvn = 'stestp09/testss/s1r228' dvn2 = 'stestp09/testss/s2r228' gr = TgGroup(-100) dv = gr.getDevice(dvn) dv2 = gr.getDevice(dvn2) flip = True for k in arr: mb = TgMember(k, "command") if flip: dv.setMember(mb) else: dv2.setMember(mb) flip = not flip gr.getData(counter) for k in arr: self._simps.dp.write_attribute(arrb[k][0], arrb[k][3]) for k in arrb: self._simps2.dp.write_attribute(arr[k][0], arr[k][3]) flip = True for k in arr: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "SCALAR", arr[k][3], arr[k][2], [1, 0], None, None, arr[k][4] if len(arr[k]) > 4 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "SCALAR", arrb[k][3], arrb[k][2], [1, 0], None, None, arrb[k][4] if len(arrb[k]) > 4 else 0) flip = not flip gr.getData(counter) flip = True for k in arr: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "SCALAR", arr[k][3], arr[k][2], [1, 0], None, None, arr[k][4] if len(arr[k]) > 4 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "SCALAR", arrb[k][3], arrb[k][2], [1, 0], None, None, arrb[k][4] if len(arrb[k]) > 4 else 0) flip = not flip gr.getData(counter + 1) flip = True for k in arrb: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "SCALAR", arrb[k][3], arrb[k][2], [1, 0], None, None, arrb[k][4] if len(arrb[k]) > 4 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "SCALAR", arr[k][3], arr[k][2], [1, 0], None, None, arr[k][4] if len(arr[k]) > 4 else 0) flip = not flip
def test_getData_image(self): fun = sys._getframe().f_code.co_name print("Run: %s.%s() " % (self.__class__.__name__, fun)) arr = { "ImageBoolean": ["bool", "DevBoolean", True, [1, 0]], "ImageUChar": ["uint8", "DevUChar", 23, [1, 0]], "ImageShort": ["int16", "DevShort", -123, [1, 0]], "ImageUShort": ["uint16", "DevUShort", 1234, [1, 0]], "ImageLong": ["int64", "DevLong", -124, [1, 0]], "ImageULong": ["uint64", "DevULong", 234, [1, 0]], "ImageLong64": ["int64", "DevLong64", 234, [1, 0]], "ImageULong64": ["uint64", "DevULong64", 23, [1, 0]], "ImageFloat": ["float32", "DevFloat", 12.234, [1, 0], 1e-5], "ImageDouble": ["float64", "DevDouble", -2.456673e+02, [1, 0], 1e-14], "ImageString": ["string", "DevString", "MyTrue", [1, 0]], } arrb = { "ImageBoolean": ["bool", "DevBoolean", False, [1, 0]], "ImageUChar": ["uint8", "DevUChar", 12, [1, 0]], "ImageShort": ["int16", "DevShort", -245, [1, 0]], "ImageUShort": ["uint16", "DevUShort", 1452, [1, 0]], "ImageLong": ["int64", "DevLong", -235, [1, 0]], "ImageULong": ["uint64", "DevULong", 123, [1, 0]], "ImageLong64": ["int64", "DevLong64", 123, [1, 0]], "ImageULong64": ["uint64", "DevULong64", 19, [1, 0]], "ImageFloat": ["float32", "DevFloat", 1.2324, [1, 0], 1e-5], "ImageDouble": ["float64", "DevDouble", -1.423473e+02, [1, 0], 1e-14], "ImageString": ["string", "DevString", "MyTFAL", [1, 0]], } counter = self.__rnd.randint(-2, 10) for k in arr: mlen = [ self.__rnd.randint(1, 10), self.__rnd.randint(1, 10), self.__rnd.randint(0, 3) ] if arr[k][1] != "DevBoolean": arr[k][2] = [[ arr[k][2] * self.__rnd.randint(0, 3) for r in range(mlen[1]) ] for c in range(mlen[0])] else: mlen = [self.__rnd.randint(1, 10), self.__rnd.randint(1, 10)] if arr[k][1] == 'DevBoolean': arr[k][2] = [[(True if self.__rnd.randint(0, 1) else False) for c in range(mlen[1])] for r in range(mlen[0])] arr[k][3] = [mlen[0], mlen[1]] self._simps.dp.write_attribute(k, arr[k][2]) for k in arrb: mlen = [ self.__rnd.randint(1, 10), self.__rnd.randint(1, 10), self.__rnd.randint(0, 3) ] if arrb[k][1] != "DevBoolean": arrb[k][2] = [[ arrb[k][2] * self.__rnd.randint(0, 3) for r in range(mlen[1]) ] for c in range(mlen[0])] else: mlen = [self.__rnd.randint(1, 10), self.__rnd.randint(1, 10)] if arrb[k][1] == 'DevBoolean': arrb[k][2] = [[ (True if self.__rnd.randint(0, 1) else False) for c in range(mlen[1]) ] for r in range(mlen[0])] arrb[k][3] = [mlen[0], mlen[1]] self._simps2.dp.write_attribute(k, arrb[k][2]) dvn = 'stestp09/testss/s1r228' dvn2 = 'stestp09/testss/s2r228' gr = TgGroup(-10) dv = gr.getDevice(dvn) dv2 = gr.getDevice(dvn2) flip = True for k in arr: mb = TgMember(k) if flip: dv.setMember(mb) else: dv2.setMember(mb) flip = not flip gr.getData(counter) for k in arrb: self._simps.dp.write_attribute(k, arrb[k][2]) for k in arr: self._simps2.dp.write_attribute(k, arr[k][2]) flip = True for k in arr: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "IMAGE", arr[k][2], arr[k][1], arr[k][3], None, None, arr[k][4] if len(arr[k]) > 4 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "IMAGE", arrb[k][2], arrb[k][1], arrb[k][3], None, None, arrb[k][4] if len(arrb[k]) > 4 else 0) flip = not flip gr.getData(counter) flip = True for k in arrb: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "IMAGE", arr[k][2], arr[k][1], arr[k][3], None, None, arr[k][4] if len(arr[k]) > 4 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "IMAGE", arrb[k][2], arrb[k][1], arrb[k][3], None, None, arrb[k][4] if len(arrb[k]) > 4 else 0) flip = not flip gr.getData(counter + 1) flip = True for k in arrb: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "IMAGE", arrb[k][2], arrb[k][1], arrb[k][3], None, None, arrb[k][4] if len(arrb[k]) > 4 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "IMAGE", arr[k][2], arr[k][1], arr[k][3], None, None, arr[k][4] if len(arr[k]) > 4 else 0) flip = not flip
def test_getData_spectrum(self): fun = sys._getframe().f_code.co_name print("Run: %s.%s() " % (self.__class__.__name__, fun)) arr = { "SpectrumBoolean": ["bool", "DevBoolean", True, [1, 0]], "SpectrumUChar": ["uint8", "DevUChar", 23, [1, 0]], "SpectrumShort": ["int16", "DevShort", -123, [1, 0]], "SpectrumUShort": ["uint16", "DevUShort", 1234, [1, 0]], "SpectrumLong": ["int64", "DevLong", -124, [1, 0]], "SpectrumULong": ["uint64", "DevULong", 234, [1, 0]], "SpectrumLong64": ["int64", "DevLong64", 234, [1, 0]], "SpectrumULong64": ["uint64", "DevULong64", 23, [1, 0]], "SpectrumFloat": ["float32", "DevFloat", 12.234, [1, 0], 1e-5], "SpectrumDouble": ["float64", "DevDouble", -2.456673e+02, [1, 0], 1e-14], "SpectrumString": ["string", "DevString", "MyTrue", [1, 0]], } arrb = { "SpectrumBoolean": ["bool", "DevBoolean", False, [1, 0]], "SpectrumUChar": ["uint8", "DevUChar", 22, [1, 0]], "SpectrumShort": ["int16", "DevShort", 13, [1, 0]], "SpectrumUShort": ["uint16", "DevUShort", 2434, [1, 0]], "SpectrumLong": ["int64", "DevLong", -112, [1, 0]], "SpectrumULong": ["uint64", "DevULong", 123, [1, 0]], "SpectrumLong64": ["int64", "DevLong64", 114, [1, 0]], "SpectrumULong64": ["uint64", "DevULong64", 11, [1, 0]], "SpectrumFloat": ["float32", "DevFloat", 10.124, [1, 0], 1e-5], "SpectrumDouble": ["float64", "DevDouble", -1.133173e+02, [1, 0], 1e-14], "SpectrumString": ["string", "DevString", "MyFalse", [1, 0]], } counter = self.__rnd.randint(-2, 10) for k in arr: if arr[k][1] != "DevBoolean": mlen = [self.__rnd.randint(1, 10), self.__rnd.randint(0, 3)] arr[k][2] = [ arr[k][2] * self.__rnd.randint(0, 3) for c in range(mlen[0]) ] else: mlen = [self.__rnd.randint(1, 10)] arr[k][2] = [(True if self.__rnd.randint(0, 1) else False) for c in range(mlen[0])] arr[k][3] = [mlen[0], 0] self._simps.dp.write_attribute(k, arr[k][2]) for k in arrb: if arrb[k][1] != "DevBoolean": mlen = [self.__rnd.randint(1, 10), self.__rnd.randint(0, 3)] arrb[k][2] = [ arrb[k][2] * self.__rnd.randint(0, 3) for c in range(mlen[0]) ] else: mlen = [self.__rnd.randint(1, 10)] arrb[k][2] = [(True if self.__rnd.randint(0, 1) else False) for c in range(mlen[0])] arrb[k][3] = [mlen[0], 0] self._simps2.dp.write_attribute(k, arrb[k][2]) dvn = 'stestp09/testss/s1r228' dvn2 = 'stestp09/testss/s2r228' gr = TgGroup(-100) dv = gr.getDevice(dvn) dv2 = gr.getDevice(dvn2) flip = True for k in arr: mb = TgMember(k) if flip: dv.setMember(mb) else: dv2.setMember(mb) flip = not flip gr.getData(counter) for k in arrb: self._simps.dp.write_attribute(k, arrb[k][2]) for k in arr: self._simps2.dp.write_attribute(k, arr[k][2]) flip = True for k in arr: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "SPECTRUM", arr[k][2], arr[k][1], arr[k][3], None, None, arr[k][4] if len(arr[k]) > 4 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "SPECTRUM", arrb[k][2], arrb[k][1], arrb[k][3], None, None, arrb[k][4] if len(arrb[k]) > 4 else 0) flip = not flip gr.getData(counter) flip = True for k in arr: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "SPECTRUM", arr[k][2], arr[k][1], arr[k][3], None, None, arr[k][4] if len(arr[k]) > 4 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "SPECTRUM", arrb[k][2], arrb[k][1], arrb[k][3], None, None, arrb[k][4] if len(arrb[k]) > 4 else 0) flip = not flip gr.getData(counter + 1) flip = True for k in arrb: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "SPECTRUM", arrb[k][2], arrb[k][1], arrb[k][3], None, None, arrb[k][4] if len(arrb[k]) > 4 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "SPECTRUM", arr[k][2], arr[k][1], arr[k][3], None, None, arr[k][4] if len(arr[k]) > 4 else 0) flip = not flip
def test_getData_scalar(self): fun = sys._getframe().f_code.co_name print("Run: %s.%s() " % (self.__class__.__name__, fun)) arr1 = { "ScalarBoolean": ["bool", "DevBoolean", True], "ScalarUChar": ["uint8", "DevUChar", 23], "ScalarShort": ["int16", "DevShort", -123], "ScalarUShort": ["uint16", "DevUShort", 1234], "ScalarLong": ["int64", "DevLong", -124], "ScalarULong": ["uint64", "DevULong", 234], "ScalarLong64": ["int64", "DevLong64", 234], "ScalarULong64": ["uint64", "DevULong64", 23], "ScalarFloat": ["float32", "DevFloat", 12.234, 1e-5], "ScalarDouble": ["float64", "DevDouble", -2.456673e+02, 1e-14], "ScalarString": ["string", "DevString", "MyTrue"], } arr1b = { "ScalarBoolean": ["bool", "DevBoolean", False], "ScalarUChar": ["uint8", "DevUChar", 13], "ScalarShort": ["int16", "DevShort", -112], "ScalarUShort": ["uint16", "DevUShort", 2345], "ScalarLong": ["int64", "DevLong", -255], "ScalarULong": ["uint64", "DevULong", 123], "ScalarLong64": ["int64", "DevLong64", 214], "ScalarULong64": ["uint64", "DevULong64", 244465], "ScalarFloat": ["float32", "DevFloat", 11.123, 1e-5], "ScalarDouble": ["float64", "DevDouble", -1.414532e+02, 1e-14], "ScalarString": ["string", "DevString", "MyFalse"], } arr2 = { "State": ["string", "DevState", PyTango._PyTango.DevState.ON], } arr3 = { "ScalarEncoded": [ "string", "DevEncoded", ("UTF8", b"Hello UTF8! Pr\xc3\xb3ba \xe6\xb5\x8b") ], "SpectrumEncoded": [ "string", "DevEncoded", ('INT32', b'\xd2\x04\x00\x00.\x16\x00\x00-\x00\x00\x00Y\x01\x00\x00') ], } counter = self.__rnd.randint(-2, 10) for k in arr1: self._simps.dp.write_attribute(k, arr1[k][2]) for k in arr1b: self._simps2.dp.write_attribute(k, arr1b[k][2]) arr = dict(arr1, **(arr2)) arrb = dict(arr1b, **(arr2)) dvn = 'stestp09/testss/s1r228' dvn2 = 'stestp09/testss/s2r228' gr = TgGroup(-100) dv = gr.getDevice(dvn) dv2 = gr.getDevice(dvn2) flip = True for k in arr: mb = TgMember(k) if flip: dv.setMember(mb) else: dv2.setMember(mb) flip = not flip if not PYTG_BUG_213: flip = True for k in arr3: mb = TgMember(k, encoding=arr3[k][2][0]) if flip: dv.setMember(mb) else: dv2.setMember(mb) flip = not flip print("FETCH %s" % counter) gr.getData(counter) print("FETCH END") for k in arr1: self._simps.dp.write_attribute(k, arr1b[k][2]) for k in arr1b: self._simps2.dp.write_attribute(k, arr1[k][2]) flip = True for k in arr: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "SCALAR", arr[k][2], arr[k][1], [1, 0], None, None, arr[k][3] if len(arr[k]) > 3 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "SCALAR", arrb[k][2], arrb[k][1], [1, 0], None, None, arrb[k][3] if len(arr[k]) > 3 else 0) flip = not flip gr.getData(counter) flip = True for k in arr: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "SCALAR", arr[k][2], arr[k][1], [1, 0], None, None, arr[k][3] if len(arr[k]) > 3 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "SCALAR", arrb[k][2], arrb[k][1], [1, 0], None, None, arrb[k][3] if len(arr[k]) > 3 else 0) flip = not flip gr.getData(counter + 1) flip = True for k in arr: if flip: dt = (gr.getDevice(dvn).members[k]).getValue() self.checkData(dt, "SCALAR", arrb[k][2], arrb[k][1], [1, 0], None, None, arrb[k][3] if len(arr[k]) > 3 else 0) else: dt = (gr.getDevice(dvn2).members[k]).getValue() self.checkData(dt, "SCALAR", arr[k][2], arr[k][1], [1, 0], None, None, arr[k][3] if len(arr[k]) > 3 else 0) flip = not flip if not PYTG_BUG_213: dp = DecoderPool() flip = True for k in arr3: print(k) if flip: print(gr.getDevice(dvn).members[k]) dt = (gr.getDevice(dvn).members[k]).getValue(dp) else: print(gr.getDevice(dvn2).members[k]) dt = (gr.getDevice(dvn2).members[k]).getValue(dp) self.checkData(dt, "SCALAR", arr3[k][2], arr3[k][1], [1, 0], arr3[k][2][0], dp) flip = not flip
def test_setMember(self): fun = sys._getframe().f_code.co_name print("Run: %s.%s() " % (self.__class__.__name__, fun)) device = "device/%s" % self.__rnd.randint(0, 9) # proxy = "proxy%s" % self.__rnd.randint(0, 9) dv = TgDevice(device) self.assertEqual(dv.device, device) self.assertEqual(dv.members, {}) self.assertEqual(dv.attributes, []) self.assertEqual(dv.properties, []) self.assertEqual(dv.commands, []) self.assertEqual(dv.proxy, None) name1 = "myname%s" % self.__rnd.randint(0, 9) mb1 = TgMember(name1) self.assertEqual(dv.setMember(mb1), mb1) self.assertEqual(dv.device, device) self.assertEqual(dv.members, {name1: mb1}) self.assertEqual(dv.attributes, [name1]) self.assertEqual(dv.properties, []) self.assertEqual(dv.commands, []) self.assertEqual(dv.proxy, None) name2 = "wmyname%s" % self.__rnd.randint(0, 9) mb2 = TgMember(name2) self.assertEqual(dv.setMember(mb2), mb2) self.assertEqual(dv.device, device) self.assertEqual(dv.members, {name1: mb1, name2: mb2}) self.assertEqual(dv.attributes, [name1, name2]) self.assertEqual(dv.properties, []) self.assertEqual(dv.commands, []) self.assertEqual(dv.proxy, None) name3 = "cmyname%s" % self.__rnd.randint(0, 9) mb3 = TgMember(name3, "command") self.assertEqual(dv.setMember(mb3), mb3) self.assertEqual(dv.device, device) self.assertEqual(dv.members, {name1: mb1, name2: mb2, name3: mb3}) self.assertEqual(dv.attributes, [name1, name2]) self.assertEqual(dv.properties, []) self.assertEqual(dv.commands, [name3]) self.assertEqual(dv.proxy, None) name4 = "c2myname%s" % self.__rnd.randint(0, 9) mb4 = TgMember(name4, "command") self.assertEqual(dv.setMember(mb4), mb4) self.assertEqual(dv.device, device) self.assertEqual( dv.members, {name1: mb1, name2: mb2, name3: mb3, name4: mb4}) self.assertEqual(dv.attributes, [name1, name2]) self.assertEqual(dv.properties, []) self.assertEqual(dv.commands, [name3, name4]) self.assertEqual(dv.proxy, None) name5 = "pmyname%s" % self.__rnd.randint(0, 9) mb5 = TgMember(name5, "property") self.assertEqual(dv.setMember(mb5), mb5) self.assertEqual(dv.device, device) self.assertEqual( dv.members, {name1: mb1, name2: mb2, name3: mb3, name4: mb4, name5: mb5}) self.assertEqual(dv.attributes, [name1, name2]) self.assertEqual(dv.properties, [name5]) self.assertEqual(dv.commands, [name3, name4]) self.assertEqual(dv.proxy, None) name6 = "ppmyname%s" % self.__rnd.randint(0, 9) mb6 = TgMember(name6, "property") self.assertEqual(dv.setMember(mb6), mb6) self.assertEqual(dv.device, device) self.assertEqual( dv.members, {name1: mb1, name2: mb2, name3: mb3, name4: mb4, name5: mb5, name6: mb6}) self.assertEqual(dv.attributes, [name1, name2]) self.assertEqual(dv.properties, [name5, name6]) self.assertEqual(dv.commands, [name3, name4]) self.assertEqual(dv.proxy, None) name7 = "aamyname%s" % self.__rnd.randint(0, 9) mb7 = TgMember(name7, "attribute") self.assertEqual(dv.setMember(mb7), mb7) self.assertEqual(dv.device, device) self.assertEqual( dv.members, {name1: mb1, name2: mb2, name3: mb3, name4: mb4, name5: mb5, name6: mb6, name7: mb7}) self.assertEqual(dv.attributes, [name1, name2, name7]) self.assertEqual(dv.properties, [name5, name6]) self.assertEqual(dv.commands, [name3, name4]) self.assertEqual(dv.proxy, None) mb8 = TgMember(name1, "attribute") self.assertEqual(dv.setMember(mb8), mb1) self.assertEqual(dv.device, device) self.assertEqual( dv.members, {name1: mb1, name2: mb2, name3: mb3, name4: mb4, name5: mb5, name6: mb6, name7: mb7}) self.assertEqual(dv.attributes, [name1, name2, name7]) self.assertEqual(dv.properties, [name5, name6]) self.assertEqual(dv.commands, [name3, name4]) self.assertEqual(dv.proxy, None) mb9 = TgMember(name2, "attribute") self.assertEqual(dv.setMember(mb9), mb2) self.assertEqual(dv.device, device) self.assertEqual( dv.members, {name1: mb1, name2: mb2, name3: mb3, name4: mb4, name5: mb5, name6: mb6, name7: mb7}) self.assertEqual(dv.attributes, [name1, name2, name7]) self.assertEqual(dv.properties, [name5, name6]) self.assertEqual(dv.commands, [name3, name4]) self.assertEqual(dv.proxy, None) mb10 = TgMember(name3, "attribute") self.assertEqual(dv.setMember(mb10), mb3) self.assertEqual(dv.device, device) self.assertEqual( dv.members, {name1: mb1, name2: mb2, name3: mb3, name4: mb4, name5: mb5, name6: mb6, name7: mb7}) self.assertEqual(dv.attributes, [name1, name2, name7]) self.assertEqual(dv.properties, [name5, name6]) self.assertEqual(dv.commands, [name3, name4]) self.assertEqual(dv.proxy, None) mb11 = TgMember(name4, "attribute") self.assertEqual(dv.setMember(mb11), mb4) self.assertEqual(dv.device, device) self.assertEqual( dv.members, {name1: mb1, name2: mb2, name3: mb3, name4: mb4, name5: mb5, name6: mb6, name7: mb7}) self.assertEqual(dv.attributes, [name1, name2, name7]) self.assertEqual(dv.properties, [name5, name6]) self.assertEqual(dv.commands, [name3, name4]) self.assertEqual(dv.proxy, None) mb12 = TgMember(name5, "attribute") self.assertEqual(dv.setMember(mb12), mb5) self.assertEqual(dv.device, device) self.assertEqual( dv.members, {name1: mb1, name2: mb2, name3: mb3, name4: mb4, name5: mb5, name6: mb6, name7: mb7}) self.assertEqual(dv.attributes, [name1, name2, name7]) self.assertEqual(dv.properties, [name5, name6]) self.assertEqual(dv.commands, [name3, name4]) self.assertEqual(dv.proxy, None) mb13 = TgMember(name6, "attribute") self.assertEqual(dv.setMember(mb13), mb6) self.assertEqual(dv.device, device) self.assertEqual( dv.members, {name1: mb1, name2: mb2, name3: mb3, name4: mb4, name5: mb5, name6: mb6, name7: mb7}) self.assertEqual(dv.attributes, [name1, name2, name7]) self.assertEqual(dv.properties, [name5, name6]) self.assertEqual(dv.commands, [name3, name4]) self.assertEqual(dv.proxy, None) mb14 = TgMember(name7, "attribute") self.assertEqual(dv.setMember(mb14), mb7) self.assertEqual(dv.device, device) self.assertEqual( dv.members, {name1: mb1, name2: mb2, name3: mb3, name4: mb4, name5: mb5, name6: mb6, name7: mb7}) self.assertEqual(dv.attributes, [name1, name2, name7]) self.assertEqual(dv.properties, [name5, name6]) self.assertEqual(dv.commands, [name3, name4]) self.assertEqual(dv.proxy, None)
def test_getData_default(self): fun = sys._getframe().f_code.co_name print("Run: %s.%s() " % (self.__class__.__name__, fun)) dname = 'writer' device = 'stestp09/testss/s1r228' # ctype = 'command' # atype = 'attribute' # host = self._dbhost # port = '10000' # encoding = 'UTF8' # group = 'common_motors' proxy = PyTango.DeviceProxy(device) self.assertTrue(ProxyHelper.wait(proxy, 10000)) mb = TgMember(dname) mb.getData(proxy) self.myAssertRaise(DataSourceSetupError, mb.getValue) mb = TgMember('ScalarString') mb.getData(proxy) dt = mb.getValue() self.checkData(dt, "SCALAR", "Hello!", "DevString", [1, 0], None, None) mb = TgMember('ScalarString') mb.getData(proxy) dt = mb.getValue() self.checkData(dt, "SCALAR", "Hello!", "DevString", [1, 0], None, None) dt = mb.getValue() self.checkData(dt, "SCALAR", "Hello!", "DevString", [1, 0], None, None) mb.reset() self.myAssertRaise(DataSourceSetupError, mb.getValue)