Пример #1
0
 def __exit__(self, *args):
     Spadic.__exit__(self)
     if not self._stop.is_set():
         self._stop.set()
     for s in [self._rf_server, self._sr_server, self._dlm_server,
               self._dataA_server, self._dataB_server]:
         s.join()
Пример #2
0
 def __exit__(self, *args):
     Spadic.__exit__(self)
     if not self._stop.is_set():
         self._stop.set()
     for s in [
             self._rf_server, self._sr_server, self._dlm_server,
             self._dataA_server, self._dataB_server
     ]:
         s.join()
Пример #3
0
    def __init__(self, reset=False, load=None, port_base=None, **kwargs):
        Spadic.__init__(self, reset, load, **kwargs)

        def _run_gen(cls, *args, **kwargs):
            with cls(*args, **kwargs) as serv:
                serv._stop = self._stop
                serv.run()

        try:
            debug = self._debug if kwargs['_debug_server'] else None
        except KeyError:
            debug = None

        def _run_rf_server():
            _run_gen(SpadicRFServer, self._registerfile, port_base, debug)

        def _run_sr_server():
            _run_gen(SpadicSRServer, self._shiftregister, port_base, debug)

        def _run_dlm_server():
            _run_gen(SpadicDLMServer, self.send_dlm, port_base, debug)

        def _run_dataA_server():
            _run_gen(SpadicDataServer, "A", self.read_groupA, port_base, debug)

        def _run_dataB_server():
            _run_gen(SpadicDataServer, "B", self.read_groupB, port_base, debug)

        self._rf_server = threading.Thread(name="RF server")
        self._rf_server.run = _run_rf_server
        self._rf_server.daemon = True
        self._rf_server.start()

        self._sr_server = threading.Thread(name="SR server")
        self._sr_server.run = _run_sr_server
        self._sr_server.daemon = True
        self._sr_server.start()

        self._dlm_server = threading.Thread(name="DLM server")
        self._dlm_server.run = _run_dlm_server
        self._dlm_server.daemon = True
        self._dlm_server.start()

        self._dataA_server = threading.Thread(name="DataA server")
        self._dataA_server.run = _run_dataA_server
        self._dataA_server.daemon = True
        self._dataA_server.start()

        self._dataB_server = threading.Thread(name="DataB server")
        self._dataB_server.run = _run_dataB_server
        self._dataB_server.daemon = True
        self._dataB_server.start()
Пример #4
0
    def __init__(self, reset=False, load=None, port_base=None, **kwargs):
        Spadic.__init__(self, reset, load, **kwargs)

        def _run_gen(cls, *args, **kwargs):
            with cls(*args, **kwargs) as serv:
                serv._stop = self._stop
                serv.run()

        try:
            debug = self._debug if kwargs['_debug_server'] else None
        except KeyError:
            debug = None

        def _run_rf_server():
            _run_gen(SpadicRFServer, self._registerfile, port_base, debug)

        def _run_sr_server():
            _run_gen(SpadicSRServer, self._shiftregister, port_base, debug)

        def _run_dlm_server():
            _run_gen(SpadicDLMServer, self.send_dlm, port_base, debug)

        def _run_dataA_server():
            _run_gen(SpadicDataServer, "A", self.read_groupA, port_base, debug)

        def _run_dataB_server():
            _run_gen(SpadicDataServer, "B", self.read_groupB, port_base, debug)

        self._rf_server = threading.Thread(name="RF server")
        self._rf_server.run = _run_rf_server
        self._rf_server.daemon = True
        self._rf_server.start()

        self._sr_server = threading.Thread(name="SR server")
        self._sr_server.run = _run_sr_server
        self._sr_server.daemon = True
        self._sr_server.start()

        self._dlm_server = threading.Thread(name="DLM server")
        self._dlm_server.run = _run_dlm_server
        self._dlm_server.daemon = True
        self._dlm_server.start()

        self._dataA_server = threading.Thread(name="DataA server")
        self._dataA_server.run = _run_dataA_server
        self._dataA_server.daemon = True
        self._dataA_server.start()

        self._dataB_server = threading.Thread(name="DataB server")
        self._dataB_server.run = _run_dataB_server
        self._dataB_server.daemon = True
        self._dataB_server.start()