runtime/PLCObject.py
changeset 2606 9944a18cad17
parent 2602 19dc6b830e7d
child 2608 a332f989f0b8
equal deleted inserted replaced
2598:46df689dbc3b 2606:9944a18cad17
   386         self.PythonRuntimeCall("init", use_evaluator=False)
   386         self.PythonRuntimeCall("init", use_evaluator=False)
   387 
   387 
   388         self.PythonThreadCondLock = Lock()
   388         self.PythonThreadCondLock = Lock()
   389         self.PythonThreadCond = Condition(self.PythonThreadCondLock)
   389         self.PythonThreadCond = Condition(self.PythonThreadCondLock)
   390         self.PythonThreadCmd = "Wait"
   390         self.PythonThreadCmd = "Wait"
   391         self.PythonThread = Thread(target=self.PythonThreadProc)
   391         self.PythonThread = Thread(target=self.PythonThreadProc, name="PLCPythonThread")
   392         self.PythonThread.start()
   392         self.PythonThread.start()
   393 
   393 
   394     # used internaly
   394     # used internaly
   395     def PythonRuntimeCleanup(self):
   395     def PythonRuntimeCleanup(self):
   396         if self.python_runtime_vars is not None:
   396         if self.python_runtime_vars is not None:
   475                 self.TraceThread.join()
   475                 self.TraceThread.join()
   476                 self.TraceThread = None
   476                 self.TraceThread = None
   477             return True
   477             return True
   478         return False
   478         return False
   479 
   479 
   480     @RunInMain
       
   481     def GetPLCstatus(self):
   480     def GetPLCstatus(self):
       
   481         try:
       
   482             return self._GetPLCstatus()
       
   483         except EOFError:
       
   484             return (PlcStatus.Disconnected, None)
       
   485 
       
   486     @RunInMain
       
   487     def _GetPLCstatus(self):
   482         return self.PLCStatus, map(self.GetLogCount, xrange(LogLevelsCount))
   488         return self.PLCStatus, map(self.GetLogCount, xrange(LogLevelsCount))
   483 
   489 
   484     @RunInMain
   490     @RunInMain
   485     def GetPLCID(self):
   491     def GetPLCID(self):
   486         return getPSKID(partial(self.LogMessage, 0))
   492         return getPSKID(partial(self.LogMessage, 0))
   643         return None
   649         return None
   644 
   650 
   645     def _TracesSwap(self):
   651     def _TracesSwap(self):
   646         self.LastSwapTrace = time()
   652         self.LastSwapTrace = time()
   647         if self.TraceThread is None and self.PLCStatus == PlcStatus.Started:
   653         if self.TraceThread is None and self.PLCStatus == PlcStatus.Started:
   648             self.TraceThread = Thread(target=self.TraceThreadProc)
   654             self.TraceThread = Thread(target=self.TraceThreadProc, name="PLCTrace")
   649             self.TraceThread.start()
   655             self.TraceThread.start()
   650         self.TraceLock.acquire()
   656         self.TraceLock.acquire()
   651         Traces = self.Traces
   657         Traces = self.Traces
   652         self.Traces = []
   658         self.Traces = []
   653         self.TraceLock.release()
   659         self.TraceLock.release()