Ejemplo n.º 1
0
 def __init__(self, endpoint, factory, log, connections, name):
     ClientService.__init__(self, endpoint, factory)
     self.endpoint = endpoint
     self.factory = factory
     self.log = log
     self.connections = connections
     self.name = name
Ejemplo n.º 2
0
    def __init__(self, options, **kargs):

        self.options = options
        self.topics = []
        self.regAllowed = False
        self.validate = options['validation']
        setLogLevel(namespace=NAMESPACE, levelStr=options['log_level'])
        setLogLevel(namespace=PROTOCOL_NAMESPACE,
                    levelStr=options['protocol_log_level'])

        self.tess_heads = [
            t.split('/')[0] for t in self.options['tess_topics']
        ]
        self.tess_tails = [
            t.split('/')[2] for t in self.options['tess_topics']
        ]
        self.factory = MQTTFactory(profile=MQTTFactory.SUBSCRIBER)
        self.endpoint = clientFromString(reactor, self.options['broker'])
        if self.options['username'] == "":
            self.options['username'] = None
            self.options['password'] = None
        self.resetCounters()
        ClientService.__init__(self,
                               self.endpoint,
                               self.factory,
                               retryPolicy=backoffPolicy(
                                   initialDelay=INITIAL_DELAY,
                                   factor=FACTOR,
                                   maxDelay=MAX_DELAY))
Ejemplo n.º 3
0
 def __init__(self, endpoint, factory, observersByTopic, clientId):
     self.endpoint = endpoint
     self.observersByTopic = observersByTopic
     self.clientId = clientId
     ClientService.__init__(self,
                            endpoint,
                            factory,
                            retryPolicy=lambda _: 5)
Ejemplo n.º 4
0
    def __init(self, endpoint, factory):
        """
		Create MQTT client service
		"""
        ClientService.__init__(self,
                               endpoint,
                               factory,
                               retryPolicy=backoffPolicy())
Ejemplo n.º 5
0
 def __init__(self, reactor):
     self.reactor = reactor
     factory = MQTTFactory(profile=MQTTFactory.PUBLISHER)
     endpoint = clientFromString(reactor, BROKER)
     ClientService.__init__(self,
                            endpoint,
                            factory,
                            retryPolicy=backoffPolicy())
     self.connected = False
Ejemplo n.º 6
0
    def __init__(self, endpoint, factory, config, log, connections):

        ClientService.__init__(self, endpoint, factory, retryPolicy=backoffPolicy())
        self.config = config
        self.log = log
        self.endpoint = endpoint
        self.connections = connections
        self.host = None
        self.port = None
Ejemplo n.º 7
0
 def __init__(self, host, port, topic, user, password):
     self.broker_url = "tcp:%s:%s" % (host, port)
     self.topic = topic
     self.user = user
     self.password = password
     self.connected = False
     factory = MQTTFactory(profile=MQTTFactory.PUBLISHER)
     endpoint = clientFromString(reactor, self.broker_url)
     ClientService.__init__(self, endpoint, factory, retryPolicy=backoffPolicy())
Ejemplo n.º 8
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.º 9
0
    def __init__(self, reactor, config):

        self.endpoint = clientFromString(reactor, config["endpoint"])
        self.factory = Factory.forProtocol(MQTTProtocol)
        self.version = VERSION[config["version"]]
        self.clientId = config["client_id"]
        self.username = config["username"]
        self.appKey = config["app_key"]

        self.protocol = None

        # In flight subscribe request
        self.subscribe_requests = {}

        # Map topic and related function
        self.topics = {}

        # Map of publish waiting for ack
        self.publish_requests = {}

        ClientService.__init__(self, self.endpoint, self.factory, retryPolicy=backoffPolicy())
Ejemplo n.º 10
0
    def __init__(self, options, reference):

        self.options = options
        self.namespace = 'ref.' if reference else 'test'
        self.label = self.namespace.upper()
        setLogLevel(namespace=self.label, levelStr=options['log_messages'])
        setLogLevel(namespace=self.namespace, levelStr=options['log_level'])
        self.log = Logger(namespace=self.namespace)
        self.reference = reference  # Flag, is this instance for the reference photometer
        self.factory = self.buildFactory()
        self.protocol = None
        self.serport = None
        self.info = None  # Photometer info
        self.buffer = CircularBuffer(options['size'], self.log)
        parts = chop(self.options['endpoint'], sep=':')
        if parts[0] == 'tcp':
            endpoint = clientFromString(reactor, self.options['endpoint'])
            ClientService.__init__(self,
                                   endpoint,
                                   self.factory,
                                   retryPolicy=backoffPolicy(initialDelay=0.5,
                                                             factor=3.0))
Ejemplo n.º 11
0
 def __init(self, endpoint, factory):
     ClientService.__init__(self, endpoint, factory, retryPolicy=backoffPolicy())
Ejemplo n.º 12
0
 def __init__(self, endpoint, factory, observersByTopic, clientId):
     self.endpoint = endpoint
     self.observersByTopic = observersByTopic
     self.clientId = clientId
     ClientService.__init__(self, endpoint, factory, retryPolicy=lambda _: 5)
Ejemplo n.º 13
0
 def __init(self, endpoint, factory):
     ClientService.__init__(self,
                            endpoint,
                            factory,
                            retryPolicy=backoffPolicy())
Ejemplo n.º 14
0
 def __init__(self, endpoint, factory, log, datastore):
     self.log=log
     self.datastore=datastore
     ClientService.__init__(self, endpoint, factory, retryPolicy=backoffPolicy())
Ejemplo n.º 15
0
 def __init__(self, endpoint, factory, keepalive, access_key=None, secret_key=None):
     self.keepalive = keepalive
     self.protocol = None
     self.access_key = access_key
     self.secret_key = secret_key
     ClientService.__init__(self, endpoint, factory, retryPolicy=backoffPolicy(maxDelay=keepalive))