equal
deleted
inserted
replaced
250 self._FreePLC() |
250 self._FreePLC() |
251 PLCprint("PythonThreadProc interrupted") |
251 PLCprint("PythonThreadProc interrupted") |
252 |
252 |
253 def StartPLC(self): |
253 def StartPLC(self): |
254 PLCprint("StartPLC") |
254 PLCprint("StartPLC") |
255 if self.CurrentPLCFilename is not None: |
255 if self.CurrentPLCFilename is not None and self.PLCStatus == "Stopped": |
256 self.PLCStatus = "Started" |
256 self.PLCStatus = "Started" |
257 self.PythonThread = Thread(target=self.PythonThreadProc) |
257 self.PythonThread = Thread(target=self.PythonThreadProc) |
258 self.PythonThread.start() |
258 self.PythonThread.start() |
259 |
259 |
260 def StopPLC(self): |
260 def StopPLC(self): |
382 res=[] |
382 res=[] |
383 self.PLClibraryLock.acquire() |
383 self.PLClibraryLock.acquire() |
384 tick = ctypes.c_uint32() |
384 tick = ctypes.c_uint32() |
385 size = ctypes.c_uint32() |
385 size = ctypes.c_uint32() |
386 buffer = ctypes.c_void_p() |
386 buffer = ctypes.c_void_p() |
|
387 offset = 0 |
387 if self._GetDebugData(ctypes.byref(tick),ctypes.byref(size),ctypes.byref(buffer)) == 0 : |
388 if self._GetDebugData(ctypes.byref(tick),ctypes.byref(size),ctypes.byref(buffer)) == 0 : |
388 offset = 0 |
|
389 for idx, iectype in self._Idxs: |
389 for idx, iectype in self._Idxs: |
390 cursor = ctypes.c_void_p(buffer.value + offset) |
390 cursor = ctypes.c_void_p(buffer.value + offset) |
391 c_type,unpack_func = self.TypeTranslator.get(iectype, (None,None)) |
391 c_type,unpack_func = self.TypeTranslator.get(iectype, (None,None)) |
392 if c_type is not None and offset < size: |
392 if c_type is not None and offset < size: |
393 res.append(unpack_func(ctypes.cast(cursor, |
393 res.append(unpack_func(ctypes.cast(cursor, |
399 if offset >= size: |
399 if offset >= size: |
400 PLCprint("Debug error - buffer too small !") |
400 PLCprint("Debug error - buffer too small !") |
401 break |
401 break |
402 self._FreeDebugData() |
402 self._FreeDebugData() |
403 self.PLClibraryLock.release() |
403 self.PLClibraryLock.release() |
404 if offset == size.value: |
404 if offset and offset == size.value: |
405 return self.PLCStatus, tick.value, res |
405 return self.PLCStatus, tick.value, res |
406 else: |
406 else: |
407 PLCprint("Debug error - bad buffer unpack !") |
407 PLCprint("Debug error - bad buffer unpack !") |
408 return self.PLCStatus, None, None |
408 return self.PLCStatus, None, None |
409 |
409 |