runtime/PLCObject.py
changeset 851 666f5bdad301
parent 798 0d2423f283a6
child 867 06495975e8a4
equal deleted inserted replaced
850:072188d4d812 851:666f5bdad301
   103             self._stopPLC_real.restype = None
   103             self._stopPLC_real.restype = None
   104             
   104             
   105             self._PythonIterator = getattr(self.PLClibraryHandle, "PythonIterator", None)
   105             self._PythonIterator = getattr(self.PLClibraryHandle, "PythonIterator", None)
   106             if self._PythonIterator is not None:
   106             if self._PythonIterator is not None:
   107                 self._PythonIterator.restype = ctypes.c_char_p
   107                 self._PythonIterator.restype = ctypes.c_char_p
   108                 self._PythonIterator.argtypes = [ctypes.c_char_p]
   108                 self._PythonIterator.argtypes = [ctypes.c_char_p, ctypes.POINTER(ctypes.c_void_p)]
   109                 
   109                 
   110                 self._stopPLC = self._stopPLC_real
   110                 self._stopPLC = self._stopPLC_real
   111             else:
   111             else:
   112                 # If python confnode is not enabled, we reuse _PythonIterator
   112                 # If python confnode is not enabled, we reuse _PythonIterator
   113                 # as a call that block pythonthread until StopPLC 
   113                 # as a call that block pythonthread until StopPLC 
   219     def PythonThreadProc(self):
   219     def PythonThreadProc(self):
   220         self.PLCStatus = "Started"
   220         self.PLCStatus = "Started"
   221         self.StatusChange()
   221         self.StatusChange()
   222         self.StartSem.release()
   222         self.StartSem.release()
   223         self.evaluator(self.PrepareRuntimePy)
   223         self.evaluator(self.PrepareRuntimePy)
   224         res,cmd = "None","None"
   224         res,cmd,blkid = "None","None",ctypes.c_void_p()
   225         while True:
   225         while True:
   226             #print "_PythonIterator(", res, ")",
   226             # print "_PythonIterator(", res, ")",
   227             cmd = self._PythonIterator(res)
   227             cmd = self._PythonIterator(res,blkid)
   228             #print " -> ", cmd
   228             # print " -> ", cmd, blkid
   229             if cmd is None:
   229             if cmd is None:
   230                 break
   230                 break
   231             try :
   231             try :
       
   232                 self.python_threads_vars["FBID"]=blkid.value
   232                 res = str(self.evaluator(eval,cmd,self.python_threads_vars))
   233                 res = str(self.evaluator(eval,cmd,self.python_threads_vars))
   233             except Exception,e:
   234             except Exception,e:
   234                 res = "#EXCEPTION : "+str(e)
   235                 res = "#EXCEPTION : "+str(e)
   235                 PLCprint(res)
   236                 PLCprint(res)
   236         self.PLCStatus = "Stopped"
   237         self.PLCStatus = "Stopped"