def setup_device(self):
     config = self.config
     driver_config = config["driver_config"]
     driver_type = config["driver_type"]
     registry_config = config.get("registry_config")
     self.heart_beat_point = config.get("heart_beat_point")
     _log.info("Registry config of {} is {}".format(driver_type, registry_config))
     _log.info("Driver config of {} is {}".format(driver_type, driver_config))
     self.interface = self.get_interface(driver_type, driver_config, registry_config)
     self.meta_data = {}
     for point in self.interface.get_register_names():
         register = self.interface.get_register_by_name(point)
         self.meta_data[point] = {'units': register.get_units(),
                                  'type': self.register_data_type(register),
                                  'tz': config.get('timezone', '')}
     self.base_topic = DEVICES_VALUE(campus='',
                                     building='',
                                     unit='',
                                     path=self.device_path,
                                     point=None)
     self.device_name = DEVICES_PATH(base='',
                                     node='',
                                     campus='',
                                     building='',
                                     unit='',
                                     path=self.device_path,
                                     point='')
Exemple #2
0
        def setup_device(self):
            #First call to setup_device won't have anything to unsubscribe to.
            #         try:
            #             self.vip.pubsub.unsubscribe('pubsub', None, None)
            #         except KeyError:
            #             pass

            #config = self.get_config(self.core.identity)
            #self.config = jsonapi.loads(utils.strip_comments(config))
            driver_config = config["driver_config"]
            driver_type = config["driver_type"]
            registry_config = self.get_config(config["registry_config"])

            self.heart_beat_point = config.get("heart_beat_point")

            self.interface = self.get_interface(driver_type, driver_config,
                                                registry_config)
            self.meta_data = {}

            for point in self.interface.get_register_names():
                register = self.interface.get_register_by_name(point)
                if register.register_type == 'bit':
                    ts_type = 'boolean'
                else:
                    if register.python_type is int:
                        ts_type = 'integer'
                    elif register.python_type is float:
                        ts_type = 'float'
                    elif register.python_type is str:
                        ts_type = 'string'

                self.meta_data[point] = {
                    'units': register.get_units(),
                    'type': ts_type,
                    'tz': config['timezone']
                }

            self.base_topic = DEVICES_VALUE(campus=config.get('campus', ''),
                                            building=config.get(
                                                'building', ''),
                                            unit=config.get('unit', ''),
                                            path=config.get('path', ''),
                                            point=None)

            self.device_name = DEVICES_PATH(base='',
                                            node='',
                                            campus=config.get('campus', ''),
                                            building=config.get(
                                                'building', ''),
                                            unit=config.get('unit', ''),
                                            path=config.get('path', ''),
                                            point='')

            #self.parent.device_startup_callback(self.device_name, self.core.identity)
            self.vip.rpc.call('platform.driver', 'device_startup_callback',
                              self.device_name)
Exemple #3
0
    def setup_device(self):

        config = self.config
        driver_config = config["driver_config"]
        driver_type = config["driver_type"]
        registry_config = config.get("registry_config")

        self.heart_beat_point = config.get("heart_beat_point")

        self.publish_depth_first_all = bool(
            config.get("publish_depth_first_all", True))
        self.publish_breadth_first_all = bool(
            config.get("publish_breadth_first_all", True))
        self.publish_depth_first = bool(config.get("publish_depth_first",
                                                   True))
        self.publish_breadth_first = bool(
            config.get("publish_breadth_first", True))

        self.interface = self.get_interface(driver_type, driver_config,
                                            registry_config)
        self.meta_data = {}

        for point in self.interface.get_register_names():
            register = self.interface.get_register_by_name(point)
            if register.register_type == 'bit':
                ts_type = 'boolean'
            else:
                if register.python_type is int:
                    ts_type = 'integer'
                elif register.python_type is float:
                    ts_type = 'float'
                elif register.python_type is str:
                    ts_type = 'string'

            self.meta_data[point] = {
                'units': register.get_units(),
                'type': ts_type,
                'tz': config['timezone']
            }

        self.base_topic = DEVICES_VALUE(campus='',
                                        building='',
                                        unit='',
                                        path=self.device_path,
                                        point=None)

        self.device_name = DEVICES_PATH(base='',
                                        node='',
                                        campus='',
                                        building='',
                                        unit='',
                                        path=self.device_path,
                                        point='')