Пример #1
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