93 self._IterDebugData.restype = ctypes.c_void_p |
93 self._IterDebugData.restype = ctypes.c_void_p |
94 self._IterDebugData.argtypes = [ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_char_p)] |
94 self._IterDebugData.argtypes = [ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_char_p)] |
95 |
95 |
96 self._FreeDebugData = self.PLClibraryHandle.FreeDebugData |
96 self._FreeDebugData = self.PLClibraryHandle.FreeDebugData |
97 self._FreeDebugData.restype = None |
97 self._FreeDebugData.restype = None |
|
98 |
|
99 self._WaitDebugData = self.PLClibraryHandle.WaitDebugData |
|
100 self._WaitDebugData.restype = ctypes.c_int |
98 return True |
101 return True |
99 except: |
102 except: |
100 print traceback.format_exc() |
103 print traceback.format_exc() |
101 return False |
104 return False |
102 |
105 |
244 # keep a copy of requested idx |
247 # keep a copy of requested idx |
245 self._Idxs = idxs[:] |
248 self._Idxs = idxs[:] |
246 self._ResetDebugVariables() |
249 self._ResetDebugVariables() |
247 for idx in idxs: |
250 for idx in idxs: |
248 self._RegisterDebugVariable(idx) |
251 self._RegisterDebugVariable(idx) |
249 |
252 |
|
253 TypeTranslator = {"BOOL" : ctypes.c_uint8, |
|
254 "STEP" : ctypes.c_uint8, |
|
255 "TRANSITION" : ctypes.c_uint8, |
|
256 "ACTION" : ctypes.c_uint8, |
|
257 "SINT" : ctypes.c_int8, |
|
258 "USINT" : ctypes.c_uint8, |
|
259 "BYTE" : ctypes.c_uint8, |
|
260 "STRING" : None, #TODO |
|
261 "INT" : ctypes.c_int16, |
|
262 "UINT" : ctypes.c_uint16, |
|
263 "WORD" : ctypes.c_uint16, |
|
264 "WSTRING" : None, #TODO |
|
265 "DINT" : ctypes.c_int32, |
|
266 "UDINT" : ctypes.c_uint32, |
|
267 "DWORD" : ctypes.c_uint32, |
|
268 "LINT" : ctypes.c_int64, |
|
269 "ULINT" : ctypes.c_uint64, |
|
270 "LWORD" : ctypes.c_uint64, |
|
271 "REAL" : ctypes.c_float, |
|
272 "LREAL" : ctypes.c_double, |
|
273 } |
|
274 |
250 def GetTraceVariables(self): |
275 def GetTraceVariables(self): |
251 """ |
276 """ |
252 Return a list of variables, corresponding to the list of requiered idx |
277 Return a list of variables, corresponding to the list of requiered idx |
253 """ |
278 """ |
254 self._WaitDebugData() |
279 tick = self._WaitDebugData() |
|
280 idx = ctypes.c_int() |
|
281 typename = ctypes.c_char_p() |
|
282 res = [] |
255 |
283 |
256 for idx in self._Idxs: |
284 for idx in self._Idxs: |
257 buffer=self._IterDebugData() |
285 buffer=self._IterDebugData(ctypes.byref(idx), ctypes.byref(typename)) |
|
286 c_type = TypeTranslator.get(s.value, None) |
|
287 if c_type is not None: |
|
288 res += cast(buffer, POINTER(c_type)).value |
|
289 else: |
|
290 res += None |
258 self._FreeDebugData() |
291 self._FreeDebugData() |
259 |
292 return res |
260 |
293 |
261 |
294 |
262 |
295 |