예제 #1
0
    def test_Monitor(self,
                     elements=[
                         "_test_ct_1_1", "_test_ct_1_2", "_test_ct_1_3",
                         "_test_2d_1_1", '_test_2d_1_2',
                         "_test_mt_1_3/position"
                     ]):
        mg_name = str(uuid.uuid1())
        argin = [mg_name] + elements
        self.pool.CreateMeasurementGroup(argin)
        try:
            mg = Device(mg_name)

            with self.assertRaises(Exception):
                mg.setMonitor("_test_mt_1_3/position")

            mg.setMonitor('_test_2d_1_2')
            mg.setMonitor("_test_ct_1_3")
            expected = [
                "_test_ct_1_3", "_test_ct_1_3", "_test_ct_1_3", "_test_2d_1_2",
                '_test_2d_1_2', None
            ]
            result = mg.getMonitor()
            self._assertMultipleResults(result, elements, expected)

            expected = ["_test_ct_1_3", '_test_2d_1_2', None]
            result = mg.getMonitor(ret_by_ctrl=True)
            ctrls = ['_test_ct_ctrl_1', '_test_2d_ctrl_1', '__tango__']
            self._assertMultipleResults(result, ctrls, expected)

            # Check ret_full_name
            v = TangoDeviceNameValidator()
            counters = [
                "_test_ct_1_1", "_test_ct_1_2", "_test_ct_1_3", '_test_2d_1_1',
                '_test_2d_1_2'
            ]
            full_names = [v.getNames(counter)[0] for counter in counters]
            mg.setMonitor(v.getNames('_test_ct_1_1')[0])
            mg.setMonitor(v.getNames('_test_2d_1_2')[0])

            result = mg.getMonitor(*counters, ret_full_name=True)
            expected = [
                "_test_ct_1_1", "_test_ct_1_1", "_test_ct_1_1", "_test_2d_1_2",
                '_test_2d_1_2'
            ]
            self._assertMultipleResults(result, full_names, expected)
        finally:
            mg.cleanUp()
            self.pool.DeleteElement(mg_name)