Ejemplo n.º 1
0
    def __init__(self, options, label):

        self.options   = options
        self.label     = label
        self.namespace = self.label.upper()
        setLogLevel(namespace=self.namespace,  levelStr=options['log_messages'])
        setLogLevel(namespace=self.label,      levelStr=options['log_level'])
        self.log       = Logger(namespace=self.label)
        self.factory   = self.buildFactory()
        self.protocol  = None
        self.serport   = None
        self.buffer    = CircularBuffer(self.BUFFER_SIZE, self.log)
        self.counter   = 0
        # Handling of Asynchronous getInfo()
        self.info = None
        self.info_deferred = None
        if options['old_firmware']:
            self.info = {
                'name'  : self.options['name'],
                'mac'   : self.options['mac_address'],
                'calib' : self.options['zp'],
                'rev'   : 2,
                }
        
        # Serial port Handling
        parts = chop(self.options['endpoint'], sep=':')
        if parts[0] != 'serial':
            self.log.critical("Incorrect endpoint type {ep}, should be 'serial'", ep=parts[0])
            raise NotImplementedError
Ejemplo n.º 2
0
 def __init__(self, options, **kargs):
     MultiService.__init__(self)
     setLogLevel(namespace=NAMESPACE, levelStr=options['log_level'])
     self.options = options
     self.photometers = []  # Array of photometers
     self.task = None  # Periodic task to poll Photometers
     self.i = 0  # current photometer being sampled
     self._registryDone = {}
     self._errorCount = {}
Ejemplo n.º 3
0
 def reloadService(self, new_options):
     '''
     Reload configuration.
     Returns a Deferred
     '''
     options = options[self.label]
     setLogLevel(namespace=self.label,     levelStr=options['log_level'])
     setLogLevel(namespace=self.namespace, levelStr=options['log_messages'])
     self.options = options
     return defer.succeed(None)
Ejemplo n.º 4
0
 def reloadService(self, options):
     '''
     Reload service parameters
     '''
     log.warn("{version} reloading config", version=VERSION_STRING)
     try:
         options, cmdline_opts = yield deferToThread(read_options)
     except Exception as e:
         log.error("Error trying to reload: {excp!s}", excp=e)
     else:
         log.warn("{version} config reloaded ok.", version=VERSION_STRING)
         self.options = options['global']
         setLogLevel(namespace=self.label,
                     levelStr=self.options['log_level'])
         setLogLevel(namespace=self.namespace,
                     levelStr=self.options['log_messages'])
         yield super().reloadService(options=options)
Ejemplo n.º 5
0
 def __init__(self, options, **kargs):
     self.options = options
     setLogLevel(namespace=NAMESPACE, levelStr=options['log_level'])
     setLogLevel(namespace=PROTOCOL_NAMESPACE,
                 levelStr=options['log_messages'])
     self.factory = MQTTFactory(profile=MQTTFactory.PUBLISHER)
     self.endpoint = clientFromString(reactor, self.options['broker'])
     self.task = None
     if self.options['username'] == "":
         self.options['username'] = None
         self.options['password'] = None
     ClientService.__init__(self,
                            self.endpoint,
                            self.factory,
                            retryPolicy=backoffPolicy(
                                initialDelay=INITIAL_DELAY,
                                factor=FACTOR,
                                maxDelay=MAX_DELAY))
     self.queue = DeferredQueue()
Ejemplo n.º 6
0
 def reloadService(self, options):
     setLogLevel(namespace=NAMESPACE, levelStr=options['log_level'])
     setLogLevel(namespace=PROTOCOL_NAMESPACE,
                 levelStr=options['log_messages'])
     log.info("new log level is {lvl}", lvl=options['log_level'])
     self.options = options