Ejemplo n.º 1
0
    def start(self):
        self.debug_print(1, 'start()')
        if not self.running:
            self.running = 1
            self.__status = -1
            # If Config has disabled Internal Modem Server, try to get a ref to the
            # ComIfRouteNode at the given rzhost_master_path (in nodetree):
            port_node = None
            self.debug_print(1, 'rzhost_master_path = %s',
                             self.rzhost_master_path)
            if self.QA != 0:
                try:
                    com_if_node = as_internal_node(self.rzhost_master_path)
                except ENoSuchName, segment:
                    msglog.log('RznetNode', msglog.types.ERR,
                               ('Failed to find'
                                ' InterfaceRouterNode object'
                                ' at %s, at segment %s!'
                                ' Pass-through will not run.') %
                               (self.rzhost_master_path, segment))
                else:
                    port_node = com_if_node.parent
            self.debug_print(1, 'port_node = %s', str(port_node))
            # Create/init thread that runs the whole shootin' match. Pass in
            # desired rznet_addr:
            self.line_handler = RznetThread(self.parent,
                                            self.rzhost_slave_port, port_node,
                                            self.QA, self.rznet_addr, self)
            # applies to ALL devices
            self.line_handler.def_max_dev_subscrs = self.def_max_dev_subscrs
            # Discover kids in start() rather than in configure, because
            # creating nodes in configure could conceivably confuse the
            # framework (ie should it attempt to config the new nodes?).
            # discover_children() explicitly configs each child node.
            if self.parent.as_node_url() != '/services/control':  #under com
                self.discover_children()  #need to kick start old style nodes
            #next, start the line handler thread
            self.line_handler.start()
            # opens RS485 file object, and slave and
            # cmd sockets
            # @fixme HACK to wait for the line_handler thread to init.
            self.line_handler._internal_lock.acquire()
            self.line_handler._internal_lock.release()
            # @fixme END HACK to wait for the line_handler thread to init.

            self.rznet_addr = self.line_handler.get_addrs()[
                0]  # get actual addr from ldisc:
            self.debug_print(1, 'ldisc has addr %d.', self.rznet_addr)
            CompositeNode.start(self)
            self.line_handler.broadcast_update_request(
            )  #send this out AFTER all bound_proxies are started
            self.__status = 1
Ejemplo n.º 2
0
    def start(self):
        self.debug_print(1, 'start()')
        if not self.running:
            self.running = 1
            self.__status = -1
            # Discover kids in start() rather than in configure, because
            # creating nodes in configure could conceivably confuse the
            # framework (ie should it attempt to config the new nodes?).
            # discover_children() explicitly configs each child node.
            #if self.discover:
            #self.discover_children()
            # Create/init thread that runs the whole shootin' match. Pass in
            # desired rznet_addr:
            if self.com_port_path in (
                    '/interfaces/com3',
                    '/interfaces/com4',
                    '/interfaces/com5',
                    '/interfaces/com6',
            ):
                self.line_handler = RznetThread(as_node(self.com_port_path),
                                                self.rzhost_slave_port, None,
                                                0, self.rznet_addr, self)
                self.connection_type = 'rs-485'
            else:  #since it must be a rs-232 protocol, either local com port or virtual via tunnel....
                self.line_handler = RzhostThread(as_node(self.com_port_path),
                                                 self.rzhost_slave_port,
                                                 self.rznet_addr, self)
                self.connection_type = 'rs-232'
            # applies to ALL devices
            self.line_handler.def_max_dev_subscrs = self.def_max_dev_subscrs
            #next, start the line handler thread
            self.line_handler.start()
            # opens RS485 file object, and slave and
            # cmd sockets
            # @fixme HACK to wait for the line_handler thread to init.
            self.line_handler._internal_lock.acquire()
            self.line_handler._internal_lock.release()
            # @fixme END HACK to wait for the line_handler thread to init.

            self.rznet_addr = self.line_handler.get_addrs()[
                0]  # get actual addr from ldisc:
            self.debug_print(1, 'ldisc has addr %d.', self.rznet_addr)
            CompositeNode.start(self)
            self.line_handler.broadcast_update_request(
            )  #send this out AFTER all bound_proxies are started
        else:
            msglog.log('RznetNode', msglog.types.INFO,
                       'Allready started.  Attempt to start any children')
            CompositeNode.start(self)
        return