示例#1
0
    def _set_params(self, *args, **kwargs):
        """
        Issue commands to the instrument to set various parameters.  If
        startup is set to true that means we are setting startup values
        and immutable parameters can be set.  Otherwise only READ_WRITE
        parameters can be set.

        must be overloaded in derived classes

        @param params dictionary containing parameter name and value pairs
        @param startup flag - true indicates initializing, false otherwise
        """

        params = args[0]

        # check for attempt to set readonly parameters (read-only or immutable set outside startup)
        self._verify_not_readonly(*args, **kwargs)
        old_config = self._param_dict.get_config()

        for (key, val) in params.iteritems():
            log.debug("KEY = " + str(key) + " VALUE = " + str(val))
            self._param_dict.set_value(key, val)

        new_config = self._param_dict.get_config()
        log.debug('new config: %s\nold config: %s', new_config, old_config)
        # check for parameter change
        if not dict_equal(old_config, new_config):
            self._driver_event(DriverAsyncEvent.CONFIG_CHANGE)
示例#2
0
    def _update_params(self, *args, **kwargs):
        """
        Update the parameter dictionary.
        """
        # see if we passed in a list of parameters to query
        # if not, use the whole parameter list
        parameters = kwargs.get('params')
        if parameters is None or WorkhorseParameter.ALL in parameters:
            parameters = self._param_dict.get_keys()
        # filter out the engineering parameters and ALL
        parameters = [p for p in parameters if not WorkhorseEngineeringParameter.has(p) and p != WorkhorseParameter.ALL]

        # Get old param dict config.
        old_config = self._param_dict.get_config()

        if parameters:
            # MASTER
            master_params = [p for p in parameters if '_5th' not in p]
            if master_params:
                resp = self._get_params(master_params, SlaveProtocol.FOURBEAM)
                self._param_dict.update_many(resp)

            # SLAVE
            slave_params = [p.replace('_5th', '') for p in parameters if '_5th' in p]
            if slave_params:
                resp = self._get_params(slave_params, SlaveProtocol.FIFTHBEAM)
                self._param_dict2.update_many(resp)
                for key, value in self._param_dict2.get_all().iteritems():
                    self._param_dict.set_value(key, value)

        new_config = self._param_dict.get_config()

        # Check if there is any changes. Ignore TT
        if not dict_equal(new_config, old_config, ['TT']) or kwargs.get('force'):
            self._driver_event(DriverAsyncEvent.CONFIG_CHANGE)
示例#3
0
 def test_dict_equal(self):
     """
     Test the diff_equal function
     """
     a='a'
     b='b'
     self.assertTrue(dict_equal({}, {}))
     self.assertTrue(dict_equal({a:1}, {a:1}))
     self.assertTrue(dict_equal({a:1, b:2}, {a:1, b:2}))
     self.assertTrue(dict_equal({b:2, a:1}, {a:1, b:2}))
     self.assertFalse(dict_equal({a:1}, {}))
     self.assertFalse(dict_equal({}, {a:1}))
     self.assertFalse(dict_equal({a:1}, {a:2}))
     self.assertFalse(dict_equal({a:1, b:2}, {a:1, b:1}))
     self.assertFalse(dict_equal({a:1, b:{b}}, {a:1, b:1}))
     self.assertFalse(dict_equal({a:1, b:b}, {a:1, b:1}))
示例#4
0
 def test_dict_equal(self):
     """
     Test the diff_equal function
     """
     a = 'a'
     b = 'b'
     self.assertTrue(dict_equal({}, {}))
     self.assertTrue(dict_equal({a: 1}, {a: 1}))
     self.assertTrue(dict_equal({a: 1, b: 2}, {a: 1, b: 2}))
     self.assertTrue(dict_equal({b: 2, a: 1}, {a: 1, b: 2}))
     self.assertFalse(dict_equal({a: 1}, {}))
     self.assertFalse(dict_equal({}, {a: 1}))
     self.assertFalse(dict_equal({a: 1}, {a: 2}))
     self.assertFalse(dict_equal({a: 1, b: 2}, {a: 1, b: 1}))
     self.assertFalse(dict_equal({a: 1, b: {b}}, {a: 1, b: 1}))
     self.assertFalse(dict_equal({a: 1, b: b}, {a: 1, b: 1}))
     self.assertTrue(dict_equal({a: 1, b: b}, {a: 1, b: 1}, [b]))
     self.assertTrue(dict_equal({a: 1, b: b}, {a: 1, b: 1}, b))
     self.assertFalse(dict_equal({a: 1, b: b}, {a: 1, b: 1}, 'c'))