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_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)
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_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)