runtime/PLCObject.py
branchwxPython4
changeset 3580 0c96269bf63b
parent 3578 d74eb1be6abe
child 3642 cd3d15e8ef42
child 3861 7e17f7e02a2b
equal deleted inserted replaced
3575:cbf99c4122bd 3580:0c96269bf63b
   464             elif cmd == "Start":
   464             elif cmd == "Start":
   465                 # Ack Immediately, for responsiveness
   465                 # Ack Immediately, for responsiveness
   466                 self.PythonThreadAcknowledge(cmd)
   466                 self.PythonThreadAcknowledge(cmd)
   467                 self.PythonRuntimeCall("start")
   467                 self.PythonRuntimeCall("start")
   468                 self.LogMessage("Python extensions started")
   468                 self.LogMessage("Python extensions started")
   469                 self.PostStartPLC()
   469                 self._PostStartPLC()
   470                 self.PythonThreadLoop()
   470                 self.PythonThreadLoop()
   471                 self.PythonRuntimeCall("stop", reverse_order=True)
   471                 self.PythonRuntimeCall("stop", reverse_order=True)
   472             elif cmd == "Finish":
   472             elif cmd == "Finish":
   473                 self.PythonThreadAcknowledge(cmd)
   473                 self.PythonThreadAcknowledge(cmd)
   474                 break
   474                 break
   501         Here goes actions to be taken just before PLC starts, 
   501         Here goes actions to be taken just before PLC starts, 
   502         with all libraries and python object already created.
   502         with all libraries and python object already created.
   503         For example : restore saved proprietary parameters
   503         For example : restore saved proprietary parameters
   504         """
   504         """
   505         pass
   505         pass
       
   506 
       
   507     def _PostStartPLC(self):
       
   508         try:
       
   509             self.PostStartPLC()
       
   510         except Exception:
       
   511             self.LogMessage(0, 'Post Start Exception'+'\n'.join(
       
   512                 traceback.format_exception(*sys.exc_info())))
   506 
   513 
   507     def PostStartPLC(self):
   514     def PostStartPLC(self):
   508         """ 
   515         """ 
   509         Here goes actions to be taken after PLC is started, 
   516         Here goes actions to be taken after PLC is started, 
   510         with all libraries and python object already created,
   517         with all libraries and python object already created,
   728                 self._TracesSwap()
   735                 self._TracesSwap()
   729                 self._resumeDebug()
   736                 self._resumeDebug()
   730                 return self.DebugToken
   737                 return self.DebugToken
   731         else:
   738         else:
   732             self._suspendDebug(True)
   739             self._suspendDebug(True)
   733         return None
   740         return 4 # DEBUG_SUSPENDED
   734 
   741 
   735     def _TracesSwap(self):
   742     def _TracesSwap(self):
   736         self.LastSwapTrace = time()
   743         self.LastSwapTrace = time()
   737         if self.TraceThread is None and self.PLCStatus == PlcStatus.Started:
   744         if self.TraceThread is None and self.PLCStatus == PlcStatus.Started:
   738             self.TraceThread = Thread(target=self.TraceThreadProc, name="PLCTrace")
   745             self.TraceThread = Thread(target=self.TraceThreadProc, name="PLCTrace")