def __init__(self, parent = None, widgetName = ''):       
        """
        Descript. :
        """
        Connectable.Connectable.__init__(self)
        QtGui.QFrame.__init__(self, parent)
        self.setObjectName(widgetName)
        self.propertyBag = PropertyBag.PropertyBag()
                
        self.__enabledState = True #saved enabled state
        self.__loadedHardwareObjects = []
        self._signalSlotFilters = {}
        self._widgetEvents = []
 
        #
        # add what's this help
        #
        self.setWhatsThis("%s (%s)\n" % (widgetName, self.__class__.__name__))
        #WhatsThis.add(self, "%s (%s)\n" % (widgetName, self.__class__.__name__))
        
        #
        # add properties shared by all BlissWidgets
        #
        self.addProperty('fontSize', 'string', str(self.font().pointSize()))
        self.addProperty('frame', 'boolean', False)
        self.addProperty('instanceAllowAlways', 'boolean', False)#, hidden=True)
        self.addProperty('instanceAllowConnected', 'boolean', False)#, hidden=True)
        #
        # connect signals / slots
        #
        dispatcher.connect(self.__hardwareObjectDiscarded, 
                           'hardwareObjectDiscarded', 
                           HardwareRepository.HardwareRepository())
        self.defineSlot('enable_widget', ())
 def _connect_louie_node_and_value(self):
     #pass
     dispatcher.connect(self._louie_group, ZWaveNetwork.SIGNAL_GROUP)
     dispatcher.connect(self._louie_node_update, ZWaveNetwork.SIGNAL_NODE)
     dispatcher.connect(self._louie_value_update, ZWaveNetwork.SIGNAL_VALUE)
     dispatcher.connect(self._louie_ctrl_message, ZWaveNetwork.SIGNAL_CONTROLLER_COMMAND)
     dispatcher.connect(self._louie_ctrl_message_waiting, ZWaveController.SIGNAL_CTRL_WAITING)
Exemple #3
0
def main(cmd):
    """
        Accept command to either read or actuate (not implemented) the nodes in zwave network.

        Args:
            [-r/w]: -r indicates read from all sensors, while -w indicates write to sensor;
    
        Returns:
            1. If the args is to read
                {
                    "success": "True" 
                    "HTTP Error 400": "Bad Request"
                } 
    """
    if cmd == '-r':
        # parse input args
        network = ZwaveNetwork()
        network.network_init()
        network.config_all_nodes()
        dispatcher.connect(louie_network_ready,
                           ZWaveNetwork.SIGNAL_NETWORK_READY)
        network.network_awake()

        while True:
            time.sleep(1000)

        network.network_stop()
    else:
        sys.exit("Not implemented")
Exemple #4
0
 def test_000_network_start_stop(self):
     self.driver_ready = False
     self.driver_removed = False
     self.options = ZWaveOption(device=self.device, user_path=self.userpath)
     self.options.set_log_file("OZW_Log.log")
     self.options.set_append_log_file(False)
     self.options.set_console_output(False)
     self.options.set_save_log_level("Debug")
     self.options.set_logging(True)
     self.options.lock()
     dispatcher.connect(self.driver_ready_message, ZWaveNetwork.SIGNAL_DRIVER_READY)
     dispatcher.connect(self.driver_removed_message, ZWaveNetwork.SIGNAL_DRIVER_REMOVED)
     self.network = ZWaveNetwork(self.options)
     for i in range(0, SLEEP):
         if self.network.state>=self.network.STATE_AWAKED:
             break
         else:
             time.sleep(1.0)
     self.assertTrue(self.driver_ready)
     self.network.stop()
     for i in range(0, SLEEP):
         if self.network.state==self.network.STATE_STOPPED:
             break
         else:
             time.sleep(1.0)
     self.assertEqual(self.network.state, self.network.STATE_STOPPED)
     #self.assertTrue(self.driver_removed)
     self.network = None
def louie_network_ready(network):
    print("Hello from network : I'm ready : %d nodes were found." % network.nodes_count)
    print("Hello from network : my controller is : %s" % network.controller)

    dispatcher.connect(louie_node_update, ZWaveNetwork.SIGNAL_NODE)

    dispatcher.connect(louie_value_update, ZWaveNetwork.SIGNAL_VALUE)
    def __init__(self, parent = None, widgetName = ''):       
        Connectable.Connectable.__init__(self)
        QWidget.__init__(self, parent, widgetName)

        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
        self.propertyBag = PropertyBag.PropertyBag()
                
        self.__enabledState = True #saved enabled state
        self.__loadedHardwareObjects = []
        self._signalSlotFilters = {}
        self._widgetEvents = []
 
        #
        # add what's this help
        #
        QWhatsThis.add(self, "%s (%s)\n" % (widgetName, self.__class__.__name__))
        
        #
        # add properties shared by all BlissWidgets
        #
        self.addProperty('fontSize', 'string', str(self.font().pointSize()))
        #self.addProperty("alignment", "combo", ("none", "top center", "top left", "top right", "bottom center", "bottom left", "bottom right", "center", "left", "right"), "none")
        self.addProperty('instanceAllowAlways', 'boolean', False)#, hidden=True)
        self.addProperty('instanceAllowConnected', 'boolean', False)#, hidden=True)

        #
        # connect signals / slots
        #
        dispatcher.connect(self.__hardwareObjectDiscarded, 'hardwareObjectDiscarded', HardwareRepository.HardwareRepository())
 
        self.defineSlot('enable_widget', ())
Exemple #7
0
    def __init__(self, name, location, nodefilename="/opt/seciot/nodenames.json"):
        IOTDeviceController.__init__(self, name)

        # Restore node stuff
        nodefile = open(nodefilename, "r")
        nodejson = nodefile.read()
        self.node_dict = json.loads(nodejson)

        # Init options
        device = "/dev/ttyACM0"
        sniff = 300.0
        options = ZWaveOption(device, config_path="/opt/openzwave/config", user_path=".", cmd_line="")
        options.set_logging(False)
        options.set_console_output(False)
        options.lock()
        # Create a network object
        self.network = ZWaveNetwork(options, autostart=False)
        self.network.set_poll_interval(10, True)
        # We connect to the louie dispatcher
        dispatcher.connect(self.louie_network_started, ZWaveNetwork.SIGNAL_NETWORK_STARTED)
        dispatcher.connect(self.louie_network_failed, ZWaveNetwork.SIGNAL_NETWORK_FAILED)
        self.network.start()
        # We wait for the network.
        print "***** Waiting for network to become ready : "
        for i in range(0, 300):
            if self.network.state >= self.network.STATE_READY:
                print "***** Network is ready"
                break
            else:
                sys.stdout.write(".")
                sys.stdout.flush()
            time.sleep(1.0)
            # We update the name of the controller
        self.network.controller.node.name = name
        self.network.controller.node.location = location
Exemple #8
0
    def __init__(self, parent = None, widgetName = ''):       
        Connectable.Connectable.__init__(self)
        QWidget.__init__(self, parent, widgetName)

        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding)
        self.propertyBag = PropertyBag.PropertyBag()
                
        self.__enabledState = True #saved enabled state
        self.__loadedHardwareObjects = []
        self._signalSlotFilters = {}
        self._widgetEvents = []
 
        #
        # add what's this help
        #
        QWhatsThis.add(self, "%s (%s)\n" % (widgetName, self.__class__.__name__))
        
        #
        # add properties shared by all BlissWidgets
        #
        self.addProperty('fontSize', 'string', str(self.font().pointSize()))
        #self.addProperty("alignment", "combo", ("none", "top center", "top left", "top right", "bottom center", "bottom left", "bottom right", "center", "left", "right"), "none")
        self.addProperty('instanceAllowAlways', 'boolean', False)#, hidden=True)
        self.addProperty('instanceAllowConnected', 'boolean', False)#, hidden=True)

        #
        # connect signals / slots
        #
        dispatcher.connect(self.__hardwareObjectDiscarded, 'hardwareObjectDiscarded', HardwareRepository.HardwareRepository())
 
        self.defineSlot('enable_widget', ())
Exemple #9
0
    def __init__(self,
                 source,
                 log_function=default_logfunction,
                 sessionid=None,
                 default_datamodel="python",
                 setup_session=True):
        '''
        @param source: the scxml document to parse. source may be either:
        
            uri : similar to what you'd write to the open() function. The 
            difference is, StateMachine looks in the PYSCXMLPATH environment variable 
            for documents if none can be found at ".". As such, it's similar to the PYTHONPATH
            environment variable. Set the PYSCXMLPATH variable to exert more fine-grained control
            over the src attribute of <invoke>. self.filename and self.filedir are set as a result.
            
            xml string: if source is an xml string, it's executed as is. 
            self.filedir and self.filename aren't filled. 
            
            file-like object: if source has the .read() method, 
            the result of that method will be executed.
            
        @param log_function: the function to execute on a <log /> element. 
        signature is f(label, msg), where label is a string and msg a string.
        @param sessionid: is stored in the _session variable. Will be automatically
        generated if not provided.
        @param default_datamodel: if omitted, any document started by this instance will have 
        its datamodel expressions evaluated as Python expressions. Set to 'ecmascript' to assume 
        EMCAScript expressions.
        @param setup_session: for internal use.
        @raise IOError 
        @raise xml.parsers.expat.ExpatError 
        '''

        self.is_finished = False
        self.filedir = None
        self.filename = None
        self.compiler = compiler.Compiler()
        self.compiler.default_datamodel = default_datamodel
        self.compiler.log_function = log_function

        self.sessionid = sessionid or "pyscxml_session_" + str(id(self))
        self.interpreter = Interpreter()
        dispatcher.connect(self.on_exit, "signal_exit", self.interpreter)
        self.logger = logging.getLogger("pyscxml.%s" % self.sessionid)
        self.interpreter.logger = logging.getLogger("pyscxml.%s.interpreter" %
                                                    self.sessionid)
        self.compiler.logger = logging.getLogger("pyscxml.%s.compiler" %
                                                 self.sessionid)
        self.doc = self.compiler.parseXML(self._open_document(source),
                                          self.interpreter)
        self.interpreter.dm = self.doc.datamodel
        self.datamodel = self.doc.datamodel
        self.doc.datamodel["_x"] = {"self": self}
        self.doc.datamodel.self = self
        self.doc.datamodel["_sessionid"] = self.sessionid
        self.doc.datamodel.sessionid = self.sessionid
        self.name = self.doc.name
        self.is_response = self.compiler.is_response
        if setup_session:
            MultiSession().make_session(self.sessionid, self)
Exemple #10
0
 def networkReady(self, network):
     self.logger.info("Network %0.8x is ready - %d nodes were found." % (self.network.home_id, self.network.nodes_count))
     self.logger.info("Network controller %s is connected to %s" % (self.network.controller.node.product_name, self.device))
     self.logger.info("\nNodes List:")
     self.logger.info("===========")
     configChanged = False
     for node in network.nodes:
         self.logger.info("Node %s: %s (battery: %s)" % (node, network.nodes[node].product_name, network.nodes[node].get_battery_level()))
         self.logger.info("Available Command Classes: %s" % network.nodes[node].command_classes)
         modelString = network.nodes[node].manufacturer_name + " " + network.nodes[node].product_name
         if node != self.network.controller.node_id: # not for controller node
             # Should usually only be necessary once in a lifetime for a given network, but repeating it on every startup doesn't ha$
             self.configureNode(network, node)
         for sensor in network.nodes[node].get_sensors():
             if ((not self.sensorConfigured(sensor)) and (self.inDiscoveryMode)):
                 # we are in discovery mode and sensor is not configured yet, add default
                 self.addDefaultSensor(sensor, network.nodes[node].get_sensors()[sensor].label, network.nodes[node].get_sensors()[sensor].units, {"sensorModel":modelString})
                 configChanged = True
             self.logger.debug("Sensor %s has %s of %s (Unit: %s)" % (sensor, network.nodes[node].get_sensors()[sensor].label, \
                                                           network.nodes[node].get_sensor_value(sensor), network.nodes[node].get_sensors()[sensor].units))
     if self.inDiscoveryMode:
         # as discovery is more complicated for Zwave, we have to do it this way.
         # in discovery Mode, the config including new default configurations is serialized, then the agent Is stopped.
         if configChanged:
             # serialize for having all new sensors in config
             self.serializeConfig()
         self.isRunning = False # this ensures that runner stops this agent after discovery is completed
     else:
         dispatcher.connect(self.nodeUpdate, ZWaveNetwork.SIGNAL_NODE)
         dispatcher.connect(self.valueUpdate, ZWaveNetwork.SIGNAL_VALUE)
Exemple #11
0
    def _network_ready(self, network):

        # executed once the software representation is ready

        print("network : ready : %d nodes were found." % network.nodes_count)
        print("network : controller is : %s" % network.controller)
        dispatcher.connect(self._value_update, ZWaveNetwork.SIGNAL_VALUE)
 def setupConnections(self):
     self.addedConnections = True
     dispatcher.connect(self.onNodeUpdate, ZWaveNetwork.SIGNAL_NODE)
     dispatcher.connect(self.onNodeUpdateValue, ZWaveNetwork.SIGNAL_VALUE)
     dispatcher.connect(self.onNodeUpdateValue, ZWaveNetwork.SIGNAL_NODE_EVENT)
     dispatcher.connect(self.onNodeUpdateValue, ZWaveNetwork.SIGNAL_VALUE_CHANGED)
     dispatcher.connect(self.onNodeUpdateValue, ZWaveNetwork.SIGNAL_VALUE_REFRESHED)
Exemple #13
0
    def __init__(self, port=9000):
        self.tello_addr = ('192.168.10.1', 8889)
        self.debug = False
        self.pkt_seq_num = 0x01e4
        self.port = port
        self.udpsize = 2000
        self.left_x = 0.0
        self.left_y = 0.0
        self.right_x = 0.0
        self.right_y = 0.0
        self.sock = None
        self.state = self.STATE_DISCONNECTED
        self.lock = threading.Lock()
        self.connected = threading.Event()
        self.video_enabled = False
        self.prev_video_data_time = None
        self.video_data_size = 0
        self.log = log
        self.exposure = 0
        self.video_encoder_rate = 4
        self.video_stream = None

        # Create a UDP socket
        self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.sock.bind(('', self.port))
        self.sock.settimeout(2.0)

        dispatcher.connect(self.__state_machine, louie.signal.All, sender=self)
        threading.Thread(target=self.__recv_thread).start()
        threading.Thread(target=self.__video_thread).start()
Exemple #14
0
def louie_network_ready(network):
    print("Hello from network : I'm ready : {0:d} nodes were found.".format(
        network.nodes_count))
    print("Hello from network : my controller is : {}".format(
        network.controller))
    dispatcher.connect(louie_node_update, ZWaveNetwork.SIGNAL_NODE)
    dispatcher.connect(louie_value_update, ZWaveNetwork.SIGNAL_VALUE)
Exemple #15
0
 def setUp(self):
     self.max_delay = 30
     self.ctrl_command_result = None
     dispatcher.connect(self.ctrl_message,
                        ZWaveController.SIGNAL_CONTROLLER)
     self.node_result = None
     dispatcher.connect(self.node_update, ZWaveNetwork.SIGNAL_NODE)
Exemple #16
0
def main():
    """
        Main of the zwave network engine.

        Node: 
        $ Idealy, the program should be ran forever, as long as there are no 
        nodes being added or removed.
    
        $ No arguments are required for the program, however, the program need 
        be ran under usdo permission.
    """ 
    global threads
    network = ZwaveNetwork()
    network.network_init()
    dispatcher.connect(louie_network_ready, ZWaveNetwork.SIGNAL_NETWORK_READY)
    network.config_all_nodes()
    network.network_awake()
    sock = socket_init()

    try:
        while True:
            (conn, (ip, port)) = sock.accept()
            if len(threads) >= MAX_THREAD:
                conn.close()
            else:
                newthread = task_thread(conn, sock, network)
                threads.append(newthread)
                newthread.start()
    except Exception as e:         # if socket is closed by quit thread
        print("Socket Closed, Program Exited")
        sock.close()               # close socket
        network.network_stop()
        sys.exit("Bye")            # terminated program
Exemple #17
0
 def make_session(self, sessionid, source):
     '''initalizes and starts a new StateMachine session at the provided sessionid. 
     
     @param source: A string. if None or empty, the statemachine at this 
     sesssionid will run the document specified as default_scxml_doc 
     in the constructor. Otherwise, the source will be run. 
     @return: the resulting scxml.pyscxml.StateMachine instance. It has 
     not been started, only initialized.
      '''
     assert source or self.default_scxml_source
     if isinstance(source, basestring):
         sm = StateMachine(source or self.default_scxml_source,
                           sessionid=sessionid,
                           default_datamodel=self.default_datamodel,
                           setup_session=False,
                           log_function=self.log_function)
     else:
         sm = source  # source is assumed to be a StateMachine instance
     self.sm_mapping[sessionid] = sm
     #TODO: fix this.
     #        if not isinstance(sm.datamodel, XPathDatamodel):
     sm.datamodel.sessions = self
     self.set_processors(sm)
     dispatcher.connect(self.on_sm_exit, "signal_exit", sm)
     return sm
Exemple #18
0
    def make_session(self, sessionid, source):
        '''initalizes and starts a new StateMachine session at the provided sessionid. 
        
        @param source: A string. if None or empty, the statemachine at this 
        sesssionid will run the document specified as default_scxml_doc 
        in the constructor. Otherwise, the source will be run. 
        @return: the resulting scxml.pyscxml.StateMachine instance. It has 
        not been started, only initialized.
         '''
        assert source or self.default_scxml_source
        if isinstance(source, basestring):
            sm = StateMachine(source or self.default_scxml_source,
                                sessionid=sessionid,
                                default_datamodel=self.default_datamodel,
                                setup_session=False,
                                log_function=self.log_function)
        else:
            sm = source # source is assumed to be a StateMachine instance
        self.sm_mapping[sessionid] = sm
        #TODO: fix this.
#        if not isinstance(sm.datamodel, XPathDatamodel):
        sm.datamodel.sessions = self
        self.set_processors(sm)
        dispatcher.connect(self.on_sm_exit, "signal_exit", sm)
        return sm
Exemple #19
0
    def __init__(self):
        ###### options needed for python openzwave library like config files path, logging,
        device = configpi.interface
        options = ZWaveOption(
            device,
            config_path="/home/pi/IoTLab/python-openzwave/openzwave/config",
            user_path=".",
            cmd_line="")
        options.set_log_file("OZW.log")
        options.set_append_log_file(False)
        options.set_console_output(False)
        options.set_save_log_level('Warning')
        options.set_logging(True)
        options.lock()

        # creation of the object network using the options entity already created
        self.network = ZWaveNetwork(options, autostart=False)

        ###### 	 These dispatchers associate a method to a signal. the signals are generated by the library python-openzwave.
        ######   Once the signal is received. It's associated method is executed (see "_node_added" example below in "_network_started" method)
        dispatcher.connect(self._network_started,
                           ZWaveNetwork.SIGNAL_NETWORK_STARTED)
        dispatcher.connect(self._network_ready,
                           ZWaveNetwork.SIGNAL_NETWORK_READY)

        ###### backend object attributes
        #        self.devices = OrderedDict()  ### will contain the list of nodes in the network
        #        self.sensors = OrderedDict()  ### will contain the list of sensors (only) in the network
        self.node_added = False
        self.node_removed = False
        self.timestamps = {
        }  ### will contain the time of the last values' update for each sensor
        self.queryStages = {  ### the diffrent stages that a node object gets through before being ready
            "None": 1,  # Query process hasn't started for this node
            "ProtocolInfo": 2,  # Retrieve protocol information
            "Probe": 3,  # Ping device to see if alive
            "WakeUp": 4,  # Start wake up process if a sleeping node
            "ManufacturerSpecific1":
            5,  # Retrieve manufacturer name and product ids if ProtocolInfo lets us
            "NodeInfo":
            6,  # Retrieve info about supported, controlled command classes
            "SecurityReport":
            7,  # Retrieve a list of Command Classes that require Security
            "ManufacturerSpecific2":
            8,  # Retrieve manufacturer name and product ids
            "Versions": 9,  # Retrieve version information
            "Instances":
            10,  # Retrieve information about multiple command class instances
            "Static": 11,  # Retrieve static information (doesn't change)
            "Probe1": 12,  # Ping a device upon starting with configuration
            "Associations": 13,  # Retrieve information about associations
            "Neighbors": 14,  # Retrieve node neighbor list
            "Session":
            15,  # Retrieve session information (changes infrequently)
            "Dynamic": 16,  # Retrieve dynamic information (changes frequently)
            "Configuration":
            17,  # Retrieve configurable parameter information (only done on request)
            "Complete": 18  # Query process is completed for this node
        }
 def _connect_louie_node_and_value(self):
     #pass
     dispatcher.connect(self._louie_group, ZWaveNetwork.SIGNAL_GROUP)
     dispatcher.connect(self._louie_node_update, ZWaveNetwork.SIGNAL_NODE)
     dispatcher.connect(self._louie_value_update, ZWaveNetwork.SIGNAL_VALUE)
     dispatcher.connect(self._louie_ctrl_message,
                        ZWaveNetwork.SIGNAL_CONTROLLER_COMMAND)
     dispatcher.connect(self._louie_ctrl_message_waiting,
                        ZWaveController.SIGNAL_CTRL_WAITING)
    def _network_ready(self, network):

	# executed once the software representation is ready

        print("network : ready : %d nodes were found." % network.nodes_count)
        print("network : controller is : %s" % network.controller)
#        dispatcher.connect(self._node_update, ZWaveNetwork.SIGNAL_NODE)
        dispatcher.connect(self._node_event, ZWaveNetwork.SIGNAL_NODE_EVENT)
        dispatcher.connect(self._value_update, ZWaveNetwork.SIGNAL_VALUE)
Exemple #22
0
    def __init__(self, parent=None, widget_name=''):
        """
        Descript. :
        """
        Connectable.Connectable.__init__(self)
        QFrame.__init__(self, parent)
        self.setObjectName(widget_name)
        self.property_bag = PropertyBag.PropertyBag()

        self.__enabledState = True
        self.__loaded_hardware_objects = []
        self.__failed_to_load_hwobj = False
        self.__use_progress_dialog = False
        self._signal_slot_filters = {}
        self._widget_events = []

        self.setWhatsThis("%s (%s)\n" % (widget_name, self.__class__.__name__))

        self.addProperty('fontSize',
                         'string',
                         str(self.font().pointSize()))
        self.addProperty('frame',
                         'boolean',
                         False,
                         comment="Draw a frame around the widget")
        self.addProperty('instanceAllowAlways',
                         'boolean',
                         False,
                         comment="Allow to control brick in all modes")
        self.addProperty('instanceAllowConnected',
                         'boolean',
                         False,
                         comment="Allow to control brick in slave mode")
        self.addProperty('fixedWidth',
                         'integer',
                         '-1',
                         comment="Set fixed width in pixels")
        self.addProperty('fixedHeight',
                         'integer',
                         '-1',
                         comment="Set fixed height in pixels")
        self.addProperty('hide',
                         'boolean',
                         False,
                         comment="Hide widget")

        dispatcher.connect(self.__hardwareObjectDiscarded,
                           'hardwareObjectDiscarded',
                           HardwareRepository.HardwareRepository())
        self.defineSlot('enable_widget', ())
        self.defineSlot('disable_widget', ())

        #If PySide used then connect method was not overriden
        #This solution of redirecting methods works...

        self.connect = self.connect_hwobj
        self.diconnect = self.disconnect_hwobj
Exemple #23
0
 def louie_network_ready(self, network):
     self._logger.info(
         ">>>>>>> Hello from network : I'm ready : %d nodes were found.".
         format(self._network.nodes_count))
     self._logger.info(
         ">>>>>>> Hello from network : my controller is : {}".format(
             self._network.controller))
     dispatcher.connect(self.louie_node_update, ZWaveNetwork.SIGNAL_NODE)
     dispatcher.connect(self.louie_value_update, ZWaveNetwork.SIGNAL_VALUE)
Exemple #24
0
    def __init__(self, parent=None, widget_name=''):
        """
        Descript. :
        """
        Connectable.Connectable.__init__(self)
        QFrame.__init__(self, parent)
        self.setObjectName(widget_name)
        self.property_bag = PropertyBag.PropertyBag()

        self.__enabledState = True
        self.__loaded_hardware_objects = []
        self.__failed_to_load_hwobj = False
        self.__use_progress_dialog = False
        self._signal_slot_filters = {}
        self._widget_events = []

        self.setWhatsThis("%s (%s)\n" % (widget_name, self.__class__.__name__))

        self.addProperty('fontSize',
                         'string',
                         str(self.font().pointSize()))
        self.addProperty('frame',
                         'boolean',
                         False,
                         comment="Draw a frame around the widget")
        self.addProperty('instanceAllowAlways',
                         'boolean',
                         False,
                         comment="Allow to control brick in all modes")
        self.addProperty('instanceAllowConnected',
                         'boolean',
                         False,
                         comment="Allow to control brick in slave mode")
        self.addProperty('fixedWidth',
                         'integer',
                         '-1',
                         comment="Set fixed width in pixels")
        self.addProperty('fixedHeight',
                         'integer',
                         '-1',
                         comment="Set fixed height in pixels")
        self.addProperty('hide',
                         'boolean',
                         False,
                         comment="Hide widget")

        dispatcher.connect(self.__hardwareObjectDiscarded,
                           'hardwareObjectDiscarded',
                           HardwareRepository.getHardwareRepository())
        self.defineSlot('enable_widget', ())
        self.defineSlot('disable_widget', ())

        #If PySide used then connect method was not overriden
        #This solution of redirecting methods works...

        self.connect = self.connect_hwobj
        self.diconnect = self.disconnect_hwobj
Exemple #25
0
    def __init__(self, parent=None, widget_name=""):

        Connectable.Connectable.__init__(self)
        QtImport.QFrame.__init__(self, parent)
        self.setObjectName(widget_name)
        self.property_bag = PropertyBag.PropertyBag()

        self.__enabled_state = True
        self.__loaded_hardware_objects = []
        self.__failed_to_load_hwobj = False
        self.__use_progress_dialog = False
        self._signal_slot_filters = {}
        self._widget_events = []

        self.setWhatsThis("%s (%s)\n" % (widget_name, self.__class__.__name__))

        self.add_property("fontSize", "string", str(self.font().pointSize()))
        self.add_property("frame",
                          "boolean",
                          False,
                          comment="Draw a frame around the widget")
        self.add_property(
            "instanceAllowAlways",
            "boolean",
            False,
            comment="Allow to control brick in all modes",
        )
        self.add_property(
            "instanceAllowConnected",
            "boolean",
            False,
            comment="Allow to control brick in slave mode",
        )
        self.add_property("fixedWidth",
                          "integer",
                          "-1",
                          comment="Set fixed width in pixels")
        self.add_property("fixedHeight",
                          "integer",
                          "-1",
                          comment="Set fixed height in pixels")
        self.add_property("hide", "boolean", False, comment="Hide widget")

        dispatcher.connect(
            self.__hardware_object_discarded,
            "hardwareObjectDiscarded",
            HardwareRepository.getHardwareRepository(),
        )
        self.define_slot("enable_widget", ())
        self.define_slot("disable_widget", ())

        # If PySide used then connect method was not overriden
        # This solution of redirecting methods works...

        self.connect = self.connect_hwobj
        self.diconnect = self.disconnect_hwobj
Exemple #26
0
    def __init__(self, coin):
        Sprite.__init__(self)

        self.image = pygame.Surface(coin.rect.size)
        self.rect = self.image.get_rect()

        self.rect.center = coin.rect.center
        self.coin = coin
        dispatcher.connect(self.kill, signal=signals.DEL_OBJECT, sender=coin)
        self.redraw()
Exemple #27
0
    def __init__(self, identifier, nick, color, pos, vel=(0,0)):
        WorldObject.__init__(self, identifier)

        self.nick = nick
        self.color = color
        self.rect = Rect((0,0), settings.PLAYER_SIZE)
        self.vx, self.vy = vel
        self.x, self.y = pos
        self.rect.center = pos

        dispatcher.connect(self.move, signal=signals.MOVE_PLAYER, sender=self)
Exemple #28
0
 def _connect_louie(self):
     dispatcher.connect(self._louie_network_started,
                        ZWaveNetwork.SIGNAL_NETWORK_STARTED)
     dispatcher.connect(self._louie_network_resetted,
                        ZWaveNetwork.SIGNAL_NETWORK_RESETTED)
     dispatcher.connect(self._louie_network_awaked,
                        ZWaveNetwork.SIGNAL_NETWORK_AWAKED)
     dispatcher.connect(self._louie_network_ready,
                        ZWaveNetwork.SIGNAL_NETWORK_READY)
     dispatcher.connect(self._louie_network_stopped,
                        ZWaveNetwork.SIGNAL_NETWORK_STOPPED)
Exemple #29
0
 def startup(self, args={}):
   
   if self._network is None:
     self.install_zwave()
   self.get_all_node_data()
   self.refresh_scheduler()
   dispatcher.connect(self.testL, ZWaveNetwork.SIGNAL_VALUE_CHANGED)
   dispatcher.connect(self.testL, ZWaveNetwork.SIGNAL_NODE_EVENT)
   dispatcher.connect(self.testL, ZWaveNetwork.SIGNAL_SCENE_EVENT)
   dispatcher.connect(self.testL, ZWaveNetwork.SIGNAL_BUTTON_OFF)
   dispatcher.connect(self.testL, ZWaveNetwork.SIGNAL_BUTTON_ON)
Exemple #30
0
    def __init__(self, parent=None, widget_name=""):

        Connectable.Connectable.__init__(self)
        QtImport.QFrame.__init__(self, parent)
        self.setObjectName(widget_name)
        self.property_bag = PropertyBag.PropertyBag()

        self.__enabled_state = True
        self.__loaded_hardware_objects = []
        self.__failed_to_load_hwobj = False
        self.__use_progress_dialog = False
        self._signal_slot_filters = {}
        self._widget_events = []

        self.setWhatsThis("%s (%s)\n" % (widget_name, self.__class__.__name__))

        self.add_property("fontSize", "string", str(self.font().pointSize()))
        self.add_property(
            "frame", "boolean", False, comment="Draw a frame around the widget"
        )
        self.add_property(
            "instanceAllowAlways",
            "boolean",
            False,
            comment="Allow to control brick in all modes",
        )
        self.add_property(
            "instanceAllowConnected",
            "boolean",
            False,
            comment="Allow to control brick in slave mode",
        )
        self.add_property(
            "fixedWidth", "integer", "-1", comment="Set fixed width in pixels"
        )
        self.add_property(
            "fixedHeight", "integer", "-1", comment="Set fixed height in pixels"
        )
        self.add_property("hide", "boolean", False, comment="Hide widget")

        dispatcher.connect(
            self.__hardware_object_discarded,
            "hardwareObjectDiscarded",
            HardwareRepository.getHardwareRepository(),
        )
        self.define_slot("enable_widget", ())
        self.define_slot("disable_widget", ())

        # If PySide used then connect method was not overriden
        # This solution of redirecting methods works...

        self.connect = self.connect_hwobj
        self.diconnect = self.disconnect_hwobj
Exemple #31
0
    def __init__(self):
        self.blade = False
        self.xpos = 0
        self.ypos = 0

        self.offTimer = None
        self.lastPickup = None

        dispatcher.connect(self.dragTo, "dragto")
        self.path = [] # future points to walk to
        self.lastByteTime = 0
        atexit.register(lambda: self.out(0))
Exemple #32
0
    def __init__(self, identifier, nick, color, pos, vel=(0, 0)):
        WorldObject.__init__(self, identifier)

        self.nick = nick
        self.color = color
        self.rect = Rect((0, 0), settings.PLAYER_SIZE)
        self.vx, self.vy = vel
        self.x, self.y = pos
        self.rect.center = pos
        self.local = False

        dispatcher.connect(self.move, signal=signals.MOVE_PLAYER, sender=self)
Exemple #33
0
    def __init__(self, source, log_function=default_logfunction, sessionid=None, default_datamodel="python", setup_session=True):
        '''
        @param source: the scxml document to parse. source may be either:
        
            uri : similar to what you'd write to the open() function. The 
            difference is, StateMachine looks in the PYSCXMLPATH environment variable 
            for documents if none can be found at ".". As such, it's similar to the PYTHONPATH
            environment variable. Set the PYSCXMLPATH variable to exert more fine-grained control
            over the src attribute of <invoke>. self.filename and self.filedir are set as a result.
            
            xml string: if source is an xml string, it's executed as is. 
            self.filedir and self.filename aren't filled. 
            
            file-like object: if source has the .read() method, 
            the result of that method will be executed.
            
        @param log_function: the function to execute on a <log /> element. 
        signature is f(label, msg), where label is a string and msg a string.
        @param sessionid: is stored in the _session variable. Will be automatically
        generated if not provided.
        @param default_datamodel: if omitted, any document started by this instance will have 
        its datamodel expressions evaluated as Python expressions. Set to 'ecmascript' to assume 
        EMCAScript expressions.
        @param setup_session: for internal use.
        @raise IOError 
        @raise xml.parsers.expat.ExpatError 
        '''

        self.is_finished = False
        self.filedir = None
        self.filename = None
        self.compiler = compiler.Compiler()
        self.compiler.default_datamodel = default_datamodel
        self.compiler.log_function = log_function
        
        
        self.sessionid = sessionid or "pyscxml_session_" + str(id(self))
        self.interpreter = Interpreter()
        dispatcher.connect(self.on_exit, "signal_exit", self.interpreter)
        self.logger = logging.getLogger("pyscxml.%s" % self.sessionid)
        self.interpreter.logger = logging.getLogger("pyscxml.%s.interpreter" % self.sessionid)
        self.compiler.logger = logging.getLogger("pyscxml.%s.compiler" % self.sessionid)
        self.doc = self.compiler.parseXML(self._open_document(source), self.interpreter)
        self.interpreter.dm = self.doc.datamodel
        self.datamodel = self.doc.datamodel
        self.doc.datamodel["_x"] = {"self" : self}
        self.doc.datamodel.self = self
        self.doc.datamodel["_sessionid"] = self.sessionid 
        self.doc.datamodel.sessionid = self.sessionid 
        self.name = self.doc.name
        self.is_response = self.compiler.is_response
        if setup_session:
            MultiSession().make_session(self.sessionid, self)
Exemple #34
0
    def _network_started(self, network):
        # executed once the software representation is started. the discovery of the network components has begun. they will be mapped into objects
        print("network started - %d nodes were found." % network.nodes_count)

        # these dispatchers associate a method to a signal. the signals are generated by the library python-openzwave.
        # a signal may contain a number of parameters that are passed to the method associated to the signal.
        # for exemple, the dispatcher below associates the signal "SIGNAL_NODE_ADDED" to the method "_node_added" that is implemented below (line 111).
        # the signal "SIGNAL_NODE_ADDED" transports two parameters which are the objects network and node.
        # once this signal is received, these two parameters will be passed to the method "_node_added" and the method will be executed.
        dispatcher.connect(self._node_added, ZWaveNetwork.SIGNAL_NODE_ADDED)
        dispatcher.connect(self._node_removed,
                           ZWaveNetwork.SIGNAL_NODE_REMOVED)
Exemple #35
0
    def __init__(self, state=None):
        SimulationClock.__init__(self, framerate=self.framerate)
        self.screen = pygame.display.get_surface()

        # initialize base state
        if state is None:
            state = Application.State

        self.set_state(state)

        # connect signals
        dispatcher.connect(self.quit, sender=self, signal=signals.QUIT)
Exemple #36
0
    def __init__(self):
        self.blade = False
        self.xpos = 0
        self.ypos = 0

        self.offTimer = None
        self.lastPickup = None

        dispatcher.connect(self.dragTo, "dragto")
        self.path = []  # future points to walk to
        self.lastByteTime = 0
        atexit.register(lambda: self.out(0))
Exemple #37
0
    def __init__(self, coin):
        Sprite.__init__(self)

        self.image = pygame.Surface(coin.rect.size)
        self.rect = self.image.get_rect()

        self.image.fill((0,0,0))
        self.image.fill((255,255,0), self.rect.inflate(-4,-4))

        self.rect.center = coin.rect.center

        self.coin = coin
        dispatcher.connect(self.kill, signal=signals.DEL_OBJECT, sender=coin)
Exemple #38
0
    def __init__(self, player):
        Sprite.__init__(self)

        self.image = pygame.Surface(player.rect.size)
        self.rect = self.image.get_rect()

        self.image.fill((0,0,0))
        self.image.fill(player.color, self.rect.inflate(-4,-4))

        self.rect.center = player.rect.center

        self.player = player
        dispatcher.connect(self.kill, signal=signals.DEL_OBJECT, sender=player)
    def _checkInterface(self):
        dispatcher.connect(self._notifyDriverReady, ZWaveWrapper.SIGNAL_DRIVER_READY)
        dispatcher.connect(self._notifySystemReady, ZWaveWrapper.SIGNAL_SYSTEM_READY)
        dispatcher.connect(self._notifyNodeReady, ZWaveWrapper.SIGNAL_NODE_READY)
        dispatcher.connect(self._notifyValueChanged, ZWaveWrapper.SIGNAL_VALUE_CHANGED)
        dispatcher.connect(self._notifyNodeAdded, ZWaveWrapper.SIGNAL_NODE_ADDED)
        self._initDialog(10,60,['Cancel'],'Progress')
        self._addDialogText(2,'Initializing OpenZWave')
        self._log.info('Initializing OpenZWave via wrapper')
        self._wrapper = ZWaveWrapper.getInstance(device=self._config['device'], config=self._config['config'], log=None)
        self._setTimer('initCheck', 3, self._checkIfInitialized)

        while not self._stop.isSet() and not self._wrapper.initialized:
            time.sleep(0.1)
Exemple #40
0
def zwave_network_ready(network):
    print("Z-wave network ready: HomeId {:08x}, {} nodes found.".format(network.home_id, network.nodes_count))
    dispatcher.connect(zwave_value_update, ZWaveNetwork.SIGNAL_VALUE)
    dispatcher.connect(zwave_read_nodes, ZWaveNetwork.SIGNAL_NODE_ADDED)
    dispatcher.connect(zwave_read_nodes, ZWaveNetwork.SIGNAL_NODE_EVENT)
    dispatcher.connect(zwave_read_nodes, ZWaveNetwork.SIGNAL_NODE_REMOVED)
    zwave_read_nodes(network)
Exemple #41
0
    def make_invoke_wrapper(self, node, parentId, n):
        
        def start_invoke(wrapper):
            try:
                inv = self.parseInvoke(node, parentId, n)
            except Exception, e:
                self.logger.exception("Line %s: Exception while parsing invoke." % (node.sourceline))
                self.raiseError("error.execution.invoke." + type(e).__name__.lower(), e)
                return
            wrapper.set_invoke(inv)
            
            dispatcher.connect(self.onInvokeSignal, "init.invoke." + inv.invokeid, inv)
            dispatcher.connect(self.onInvokeSignal, "result.invoke." + inv.invokeid, inv)
            dispatcher.connect(self.onInvokeSignal, "error.communication.invoke." + inv.invokeid, inv)
            try:
                if isinstance(inv, InvokeSCXML):
                    def onCreated(sender, sm):
                        sessionid = sm.sessionid
                        self.dm.sessions.make_session(sessionid, sm)
#                        self.dm["_x"]["sessions"][sessionid] = inv
                    dispatcher.connect(onCreated, "created", inv, weak=False)
                inv.start(self.dm.sessionid)
            except Exception, e:
#                del self.dm["_x"]["sessions"][sessionid]
                self.logger.exception("Line %s: Exception while parsing invoke xml." % (node.sourceline))
                self.raiseError("error.execution.invoke." + type(e).__name__.lower(), e)
Exemple #42
0
    def __init__(self, name, levels):
        """this sub has a name just for debugging. It doesn't get persisted.
        See PersistentSubmaster.

        levels is a dict
        """
        self.name = name
        self.levels = levels

        self.temporary = True

        if not self.temporary:
            # obsolete
            dispatcher.connect(log.error, 'reload all subs')
Exemple #43
0
 def setUpClass(self):
     super(TestApi, self).setUpClass()
     self.options = ZWaveOption(device=self.device, user_path=self.userpath)
     self.options.set_log_file("OZW_Log.log")
     self.options.set_append_log_file(False)
     self.options.set_console_output(False)
     self.options.set_save_log_level("Debug")
     self.options.set_logging(True)
     self.options.lock()
     self.network = ZWaveNetwork(self.options)
     self.ctrl_command_result = None
     dispatcher.connect(self.ctrl_message, ZWaveController.SIGNAL_CONTROLLER)
     self.node_result = None
     dispatcher.connect(self.node_update, ZWaveNetwork.SIGNAL_NODE)
Exemple #44
0
 def setUpClass(self):
     super(TestApi, self).setUpClass()
     self.options = ZWaveOption(device=self.device, user_path=self.userpath)
     self.options.set_log_file("OZW_Log.log")
     self.options.set_append_log_file(False)
     self.options.set_console_output(False)
     self.options.set_save_log_level("Debug")
     self.options.set_logging(True)
     self.options.lock()
     self.network = ZWaveNetwork(self.options)
     self.ctrl_command_result = None
     dispatcher.connect(self.ctrl_message,
                        ZWaveController.SIGNAL_CONTROLLER)
     self.node_result = None
     dispatcher.connect(self.node_update, ZWaveNetwork.SIGNAL_NODE)
Exemple #45
0
def zwave_network_ready(network):
    print("Z-wave network ready: HomeId {:08x}, {} nodes found.".format(
        network.home_id, network.nodes_count))
    dispatcher.connect(zwave_value_update, ZWaveNetwork.SIGNAL_VALUE)
    dispatcher.connect(zwave_read_nodes, ZWaveNetwork.SIGNAL_NODE_ADDED)
    dispatcher.connect(zwave_read_nodes, ZWaveNetwork.SIGNAL_NODE_EVENT)
    dispatcher.connect(zwave_read_nodes, ZWaveNetwork.SIGNAL_NODE_REMOVED)
    zwave_read_nodes(network)
    def __init__(self, world):
        self.world = world
        self.player = None

        dispatcher.connect(self.add_coin, signal=signals.NEW_OBJECT, sender=Coin)
        dispatcher.connect(self.add_player, signal=signals.NEW_OBJECT, sender=Player)
        dispatcher.connect(self.remove_object, signal=signals.DEL_OBJECT)
        dispatcher.connect(self.move_player, signal=signals.MOVE_PLAYER)
Exemple #47
0
def connect(handler, signal, sender=dispatcher.Any, priority=0):
    """
    Connects a callback to a signal, so that the callback will be automatically invoked
    when that signal is sent.

    Parameters:

        :handler: This can be any callable that that takes the right arguments for
                  the signal. For most signals this means a single argument that
                  will be an ``ExecutionContext`` instance. But please see documentation
                  for individual signals in the :ref:`signals reference <instruments_method_map>`.
        :signal: The signal to which the handler will be subscribed. Please see
                 :ref:`signals reference <instruments_method_map>` for the list of standard WA
                 signals.

                 .. note:: There is nothing that prevents instruments from sending their
                           own signals that are not part of the standard set. However the signal
                           must always be an :class:`wa.core.signal.Signal` instance.

        :sender: The handler will be invoked only for the signals emitted by this sender. By
                 default, this is set to :class:`louie.dispatcher.Any`, so the handler will
                 be invoked for signals from any sender.
        :priority: An integer (positive or negative) the specifies the priority of the handler.
                   Handlers with higher priority will be called before handlers with lower
                   priority. The  call order of handlers with the same priority is not specified.
                   Defaults to 0.

                   .. note:: Priorities for some signals are inverted (so highest priority
                             handlers get executed last). Please see :ref:`signals reference <instruments_method_map>`
                             for details.

    """
    logger.debug('Connecting {} to {}({}) with priority {}'.format(
        handler, signal, sender, priority))
    if getattr(signal, 'invert_priority', False):
        priority = -priority
    senderkey = id(sender)
    if senderkey in dispatcher.connections:
        signals = dispatcher.connections[senderkey]
    else:
        dispatcher.connections[senderkey] = signals = {}
    if signal in signals:
        receivers = signals[signal]
    else:
        receivers = signals[signal] = _prioritylist_wrapper()
    dispatcher.connect(handler, signal, sender)
    receivers.add(saferef.safe_ref(handler, on_delete=_remove_receiver),
                  priority)
Exemple #48
0
def start_acq(dev, acq_mode, expo_time, point_period, nb_points,
              static_cb_list=[]):
    acq_end = Event()
    def acq_status_cb(status, **kws):
        if status == device.AcqStatus.Ready:
            acq_end.set()
    static_cb_list.append(acq_status_cb)
    
    dev.acq_mode = getattr(device.AcqMode, acq_mode)
    dev.acq_expo_time = expo_time
    dev.acq_point_period = point_period
    dev.acq_nb_points = nb_points
    dev.prepare_acq()
    dispatcher.connect(acq_status_cb, device.StatusSignal, dev)
    dev.start_acq()
    return acq_end
    def _network_started(self, network):

	# executed once the software representation is started. the discovery of the network components has begun. they will be mapped into objects

        print("network started - %d nodes were found." % network.nodes_count)

	# these dispatchers associate a method to a signal. the signals are generated by the library python-openzwave.
	# a signal may contain a number of parameters that are passed to the method associated to the signal.
	# for exemple, the dispatcher below associates the signal "SIGNAL_NODE_ADDED" to the method "_node_added" that is implemented below (line 111).
	# the signal "SIGNAL_NODE_ADDED" transports two parameters which are the objects network and node.
	# once this signal is received, these two parameters will be passed to the method "_node_added" and the method will be executed.

        dispatcher.connect(self._node_added, ZWaveNetwork.SIGNAL_NODE_ADDED)
        dispatcher.connect(self._node_removed, ZWaveNetwork.SIGNAL_NODE_REMOVED)
        dispatcher.connect(self._debug_node_naming, ZWaveNetwork.SIGNAL_NODE_NAMING)
        dispatcher.connect(self._debug_node_new, ZWaveNetwork.SIGNAL_NODE_NEW)
        dispatcher.connect(self._debug_node_protocol_info, ZWaveNetwork.SIGNAL_NODE_PROTOCOL_INFO)
    def __init__(self, device, isac_node):
        self.isac_node = isac_node

        self.signals = {}

        self._ozw_notif_queue = Queue()
        self._running = True
        green.spawn(self._notif_reader)

        self.options = ZWaveOption(
            device,
            config_path='/usr/share/openzwave/config',
            user_path='./user-dir',
            cmd_line=''
        )
        self.options.set_log_file("./user-dir/OZW_Log.log")
        self.options.set_append_log_file(False)
        self.options.set_console_output(False)
        self.options.set_save_log_level('Info')
        self.options.set_logging(False)
        self.options.lock()

        self.network = ZWaveNetwork(self.options, log=None)

        notif_to_func = [
            (ZWaveNetwork.SIGNAL_NETWORK_STARTED,    self.notif_network_started),
            (ZWaveNetwork.SIGNAL_NETWORK_RESETTED,   self.notif_network_resetted),
            (ZWaveNetwork.SIGNAL_NETWORK_READY,      self.notif_network_ready),
            (ZWaveNetwork.SIGNAL_NODE_ADDED,         self.notif_node_added),
            (ZWaveNetwork.SIGNAL_NODE_NAMING,        self.notif_node_named),
            (ZWaveNetwork.SIGNAL_NODE_REMOVED,       self.notif_node_removed),
            (ZWaveNetwork.SIGNAL_VALUE_ADDED,        self.notif_value_added),
            (ZWaveNetwork.SIGNAL_VALUE_CHANGED,      self.notif_value_update),
            (ZWaveNetwork.SIGNAL_VALUE_REMOVED,      self.notif_value_removed),
            (ZWaveNetwork.SIGNAL_CONTROLLER_COMMAND, self.notif_ctrl_message),
            (ZWaveNetwork.SIGNAL_CONTROLLER_WAITING, self.notif_ctrl_message),
        ]
        for notif, func in notif_to_func:
            dispatcher.connect(self._notif_wrapper(func), notif, weak=False)

        # dispatcher.connect(self._notif_wrapper_all, All)

        self.isac_node.add_rpc(self.network_heal)
        self.isac_node.add_rpc(self.controller_add_node, name='add_node')
        self.isac_node.add_rpc(self.controller_remove_node, name='remove_node')
        self.isac_node.add_rpc(self.controller_cancel_command, name='cancel_command')
Exemple #51
0
    def __init__(self, player):
        Sprite.__init__(self)

        self.image = pygame.Surface(player.rect.size)
        self.rect = self.image.get_rect()

        if player.local:
            border = 255, 255, 255
        else:
            border = 0, 0, 0
        self.image.fill(border)
        self.image.fill(player.color, self.rect.inflate(-4, -4))

        self.rect.center = player.rect.center

        self.player = player
        dispatcher.connect(self.kill, signal=signals.DEL_OBJECT, sender=player)
Exemple #52
0
def connect(handler, signal, sender=dispatcher.Any, priority=0):
    """
    Connects a callback to a signal, so that the callback will be automatically invoked
    when that signal is sent.

    Parameters:

        :handler: This can be any callable that that takes the right arguments for
                  the signal. For most signals this means a single argument that
                  will be an ``ExecutionContext`` instance. But please see documentation
                  for individual signals in the :ref:`signals reference <instruments_method_map>`.
        :signal: The signal to which the handler will be subscribed. Please see
                 :ref:`signals reference <instruments_method_map>` for the list of standard WA
                 signals.

                 .. note:: There is nothing that prevents instruments from sending their
                           own signals that are not part of the standard set. However the signal
                           must always be an :class:`wa.core.signal.Signal` instance.

        :sender: The handler will be invoked only for the signals emitted by this sender. By
                 default, this is set to :class:`louie.dispatcher.Any`, so the handler will
                 be invoked for signals from any sender.
        :priority: An integer (positive or negative) the specifies the priority of the handler.
                   Handlers with higher priority will be called before handlers with lower
                   priority. The  call order of handlers with the same priority is not specified.
                   Defaults to 0.

                   .. note:: Priorities for some signals are inverted (so highest priority
                             handlers get executed last). Please see :ref:`signals reference <instruments_method_map>`
                             for details.

    """
    logger.debug('Connecting {} to {}({}) with priority {}'.format(handler, signal, sender, priority))
    if getattr(signal, 'invert_priority', False):
        priority = -priority
    senderkey = id(sender)
    if senderkey in dispatcher.connections:
        signals = dispatcher.connections[senderkey]
    else:
        dispatcher.connections[senderkey] = signals = {}
    if signal in signals:
        receivers = signals[signal]
    else:
        receivers = signals[signal] = _prioritylist_wrapper()
    receivers.add(handler, priority)
    dispatcher.connect(handler, signal, sender)
Exemple #53
0
    def __init__(self, *args, **kwargs):
        self._serialDevicePath = kwargs.get('serialDevicePath', None)
        self._options = ZWaveOption(self._serialDevicePath, \
          config_path="/usr/local/etc/openzwave/", \
          user_path=".", cmd_line="")
        self._options.set_log_file("OZW_Log.log")
        self._options.set_append_log_file(False)
        self._options.set_console_output(False)
        #self._options.set_save_log_level(log)
        self._options.set_save_log_level('Info')
        self._options.set_logging(True)
	self._options.set_notify_transactions(True)
        self._options.lock()

        self._network = ZWaveNetwork(self._options, log=None,autostart=False)
	dispatcher.connect(self.louie_network_ready, ZWaveNetwork.SIGNAL_NETWORK_READY)
	self._network.start()
        super(Open_zwave, self).__init__(self, *args, **kwargs)