예제 #1
0
    def PyroLoop(self, when_ready):
        if self._to_be_published():
            self.Publish()

        while self.continueloop:
            Pyro.config.PYRO_MULTITHREADED = 0
            pyro.initServer()
            self.daemon = pyro.Daemon(host=self.ip_addr, port=self.port)

            # pyro never frees memory after connection close if no timeout set
            # taking too small timeout value may cause
            # unwanted diconnection when IDE is kept busy for long periods
            self.daemon.setTimeout(60)

            pyro_obj = Pyro.core.ObjBase()
            pyro_obj.delegateTo(runtime.GetPLCObjectSingleton())

            self.daemon.connect(pyro_obj, "PLCObject")

            when_ready()
            self.piper, self.pipew = os.pipe()
            self.daemon.requestLoop(others=[self.piper],
                                    callback=lambda x: None)
            self.piper, self.pipew = None, None
            if hasattr(self, 'sock'):
                self.daemon.sock.close()
        self.Unpublish()
예제 #2
0
    def PyroLoop(self, when_ready):
        if self._to_be_published():
            self.Publish()

        while self.continueloop:
            # config.PYRO_MULTITHREADED = 0
            server = runtime.GetPLCObjectSingleton()
            self.daemon = Daemon(host=self.ip_addr, port=self.port)

            # pyro never frees memory after connection close if no timeout set
            # taking too small timeout value may cause
            # unwanted diconnection when IDE is kept busy for long periods
            # self.daemon.setTimeout(60)

            # pyro_obj = core.ObjBase()
            # pyro_obj.delegateTo(runtime.GetPLCObjectSingleton())

            # self.daemon.connect(pyro_obj, "PLCObject")
            ns = Pyro4.locateNS()
            uri = self.daemon.register(server)
            ns.register("PLCObject", uri)
            print("Ready. Object uri =", uri)
            when_ready()
            self.piper, self.pipew = os.pipe()
            self.daemon.requestLoop()
            self.piper, self.pipew = None, None
            if hasattr(self, 'sock'):
                self.daemon.sock.close()
        self.Unpublish()
예제 #3
0
 def _LiveShellLocals(self):
     return {
         "locals":
         runtime.GetPLCObjectSingleton().python_runtime_vars
     }
예제 #4
0
 def OnTaskBarStopPLC(self, evt):
     runtime.GetPLCObjectSingleton().StopPLC()
예제 #5
0
        def signal_uithread_started():
            global twisted_reactor_thread_id
            twisted_reactor_thread_id = currentThread().ident
            ui_thread_started.release()

        reactor.callLater(0, signal_uithread_started)
    else:
        wx.CallAfter(ui_thread_started.release)

    # Wait for ui thread to be effective
    ui_thread_started.acquire()
    print("UI thread started successfully.")

try:
    runtime.MainWorker.runloop(runtime.GetPLCObjectSingleton().AutoLoad,
                               autostart)
except KeyboardInterrupt:
    pass

pyroserver.Quit()
pyro_thread.join()

plcobj = runtime.GetPLCObjectSingleton()
plcobj.StopPLC()
plcobj.UnLoadPLC()

if havetwisted:
    reactor.stop()
    ui_thread.join()
elif havewx: