def test_value_ref_enabled(self): mg_name = str(uuid.uuid1()) channel_name = "_test_2d_1_1" argin = [mg_name, channel_name] self.pool.CreateMeasurementGroup(argin) try: mg = Device(mg_name) channel = Device(channel_name) mg.setValueRefEnabled(True, channel_name) _, values = mg.count(.1) for channel_name, value in values.items(): msg = "ValueRef (%s) for %s is not string" %\ (value, channel_name) self.assertTrue(is_pure_str(value), msg) finally: channel.cleanUp() mg.cleanUp() self.pool.DeleteElement(mg_name)
def test_ValueRefEnabled(self, elements=[ "_test_2d_1_1", "_test_2d_1_2", "_test_ct_1_3", "_test_mt_1_3/position" ]): mg_name = str(uuid.uuid1()) argin = [mg_name] + elements self.pool.CreateMeasurementGroup(argin) try: mg = Device(mg_name) # Check initial state of all kind of channels, nonexistent # channels for the feature return None as result. enabled = mg.getValueRefEnabled(*elements) expected = [False, False, None, None] self._assertMultipleResults(enabled, elements, expected) # Check if the nonexistent channels raise error if trying to set with self.assertRaises(Exception): mg.setValueRefEnabled(True, *elements[-2]) with self.assertRaises(Exception): mg.setValueRefEnabled(True, *elements[-1]) # Redefine elements to ony use existing values elements = ["_test_2d_1_1", "_test_2d_1_2"] # Test every possible combination of setting values # Check that changing one channel doesn't affect the other mg.setValueRefEnabled(True, *elements) enabled = mg.getValueRefEnabled(*elements) self._assertResult(enabled, elements, True) mg.setValueRefEnabled(False, elements[0]) result = mg.getValueRefEnabled(*elements) expected = [True] * len(elements) expected[0] = False self._assertMultipleResults(result, elements, expected) mg.setValueRefEnabled(True, *elements) enabled = mg.getValueRefEnabled(*elements) self._assertResult(enabled, elements, True) # Set values using the controller instead of channels mg.setValueRefEnabled(True, "_test_2d_ctrl_1") enabled = mg.getValueRefEnabled(*elements) self._assertResult(enabled, elements, True) # Get values by controller mg.setValueRefEnabled(False, *elements) enabled = mg.getValueRefEnabled("_test_2d_ctrl_1") self._assertResult(enabled, elements, False) # Check ret_full_name v = TangoDeviceNameValidator() full_names = [v.getNames(element)[0] for element in elements] enabled = mg.getValueRefEnabled(*full_names) self._assertResult(enabled, elements, False) mg.setValueRefEnabled(True, *full_names) enabled = mg.getValueRefEnabled(*elements, ret_full_name=True) self._assertResult(enabled, full_names, True) finally: mg.cleanUp() self.pool.DeleteElement(mg_name)