def activate(self, conf, glob): protocols.activate(self, conf, glob) self.logger = logging.getLogger('pellMon') self.dbvalues = {} # Initialize protocol and setup the database according to version_string try: try: self.protocol = Protocol(self.conf['serialport'], self.conf['chipversion']) except: # Create testprotocol if conf is missing self.protocol = Protocol(None, '') self.allparameters = self.protocol.getDataBase() # Create and start settings_pollthread to log settings changed locally settings = menus.getDbWithTags(('Settings', )) ht = threading.Timer(3, self.settings_pollthread, args=(settings, )) ht.setDaemon(True) ht.start() # Create and start alarm_pollthread to log settings changed locally ht = threading.Timer(5, self.alarm_pollthread, args=(('mode', 'alarm'), )) ht.setDaemon(True) ht.start() self.dataDescriptions = dataDescriptions except: self.logger.info('scottecom protocol setup failed')
def activate(self, conf, glob, db, *args, **kwargs): protocols.activate(self, conf, glob, db, *args, **kwargs) self.logger = logging.getLogger('pellMon') self.dbvalues = {} self.itemrefs = [] # Initialize protocol and setup the database according to version_string try: try: self.protocol = Protocol(self.conf['serialport'], self.conf['chipversion']) except: # Create testprotocol if conf is missing self.protocol = Protocol(None, '') self.allparameters = self.protocol.getDataBase() """Get list of all data/parameter/command items""" params = self.protocol.getDataBase() for item in params: dbitem = Getsetitem(item, None, lambda i: self.getItem(i), lambda i, v: self.setItem(i, v)) if hasattr(params[item], 'max'): dbitem.max = str(params[item].max) if hasattr(params[item], 'min'): dbitem.min = str(params[item].min) if hasattr(params[item], 'frame'): if hasattr(params[item], 'address'): dbitem.type = 'R/W' else: dbitem.type = 'R' else: dbitem.type = 'W' dbitem.longname = dataDescriptions[item][0] dbitem.unit = dataDescriptions[item][1] dbitem.description = dataDescriptions[item][2] dbitem.tags = menus.itemtags(item) self.db.insert(dbitem) self.itemrefs.append(dbitem) # Create and start settings_pollthread to log settings changed locally settings = [ item for item in params if 'Settings' in menus.itemtags(item) ] ht = threading.Timer(3, self.settings_pollthread, args=(settings, )) ht.setDaemon(True) ht.start() # Create and start alarm_pollthread to log settings changed locally ht = threading.Timer(5, self.alarm_pollthread, args=(('mode', 'alarm'), )) ht.setDaemon(True) ht.start() self.dataDescriptions = dataDescriptions except: self.logger.info('scottecom protocol setup failed')