Coverage for janitoo.thread : 89%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*-
A thread that handle a bus, ... ie i2e, onewire,
It also handle the controller for the janitoo protocol
How do what :
The tread : - hold the mqttc - ask the nodeman to boot : - get an HADD for the controller - get configuration for the controller and start the i2c bus, the onewire bus, ..... - get an HADD for each nodes - get configuration of the node and start it : ie the lcd03 of i2c, the cpu of the rapsy, ...
Reloading configration: - inside the run loop of the thread so need to kill it and re-create a new one : only possible in the server. The server (=the rapsy server) can do it but it should be accessible on mqtt. """
This file is part of Janitoo.
Janitoo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Janitoo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Janitoo. If not, see <http://www.gnu.org/licenses/>.
"""
# Set default logging handler to avoid "No handler found" warnings.
"""Initialise the worker
:param options: The options used to start the worker. :type clientid: str """ self.options = JNTOptions(options) self.section = None self.init_section()
""" """ self.stop()
"""Init the bus. Must be overloaded """
"""Called when configuration is finished. """
"""Trigger the config_timeout_callback to reload config. """ try: self.config_timeout_delay = int(timeout) self.config_timeout_timer = None
"""Stop the thread """
"""Launch before entering the run loop. The node manager is available. """
"""Launch after finishing the run loop. The node manager is still available. """ pass
"""Needed to publish static files """ return resource_filename(Requirement.parse(self.get_package_name().split('.')[0]), path)
"""Return the name of the package. Needed to publish static files
**MUST** be copy paste in every extension that publish statics files """ return __package__
"""Initialise the worker
:param options: The options used to start the worker. :type clientid: str """
def state(self): """Return the nodeman state """ return self.nodeman.state
#~ def boot(self): #~ """configure the HADD address. The node manager is not available. #~ """ #~ raise NotImplementedError()
""" """
"""Run the loop """ #~ self.boot() except: #~ self.mqtt_nodes.stop() #~ self.mqtt_nodes.unsubscribe(topic='/nodes/%s'%(HADD %(self.add_ctrl,0))) #~ self.mqtt_nodes.unsubscribe(topic='/nodes/#') #self.mqtt_nodes = None
"""On generic message
:param client: the Client instance that is calling the callback. :type client: paho.mqtt.client.Client :param userdata: user data of any type and can be set when creating a new client instance or with user_data_set(userdata). :type userdata: all :param message: The message variable is a MQTTMessage that describes all of the message parameters. :type message: paho.mqtt.client.MQTTMessage """ logger.debug("[%s] - mqtt_on_message %s", self.__class__.__name__, message) #~ print "mqtt_on_message Ok : %s" % message
"""On generic message
:param client: the Client instance that is calling the callback. :type client: paho.mqtt.client.Client :param userdata: user data of any type and can be set when creating a new client instance or with user_data_set(userdata). :type userdata: all :param message: The message variable is a MQTTMessage that describes all of the message parameters. :type message: paho.mqtt.client.MQTTMessage """ #~ print "mqtt_on_message2 Ok : %s" % message logger.debug("[%s] - mqtt_on_message2 %s", self.__class__.__name__, message)
"""Initialise the worker
:param options: The options used to start the worker. :type clientid: str """
""" """
"""Init the bus. Must be overloaded """
"""Stop the bus """ |