runtime/PLCObject.py
changeset 504 688e84df3408
parent 483 bc26c42d2eec
child 592 c6408f92da0a
equal deleted inserted replaced
503:4c0cd5e54e1b 504:688e84df3408
   360             # keep a copy of requested idx
   360             # keep a copy of requested idx
   361             self._Idxs = idxs[:]
   361             self._Idxs = idxs[:]
   362             self._ResetDebugVariables()
   362             self._ResetDebugVariables()
   363             for idx,iectype,force in idxs:
   363             for idx,iectype,force in idxs:
   364                 if force !=None:
   364                 if force !=None:
   365                     c_type,unpack_func, pack_func = self.TypeTranslator.get(iectype, (None,None,None))
   365                     c_type,unpack_func, pack_func = \
       
   366                         self.TypeTranslator.get(iectype,
       
   367                                                 (None,None,None))
   366                     force = ctypes.byref(pack_func(c_type,force)) 
   368                     force = ctypes.byref(pack_func(c_type,force)) 
   367                 self._RegisterDebugVariable(idx, force)
   369                 self._RegisterDebugVariable(idx, force)
   368             self._resumeDebug()
   370             self._resumeDebug()
   369         else:
   371         else:
   370             self._suspendDebug(True)
   372             self._suspendDebug(True)
   379             tick = ctypes.c_uint32()
   381             tick = ctypes.c_uint32()
   380             size = ctypes.c_uint32()
   382             size = ctypes.c_uint32()
   381             buffer = ctypes.c_void_p()
   383             buffer = ctypes.c_void_p()
   382             offset = 0
   384             offset = 0
   383             if self.PLClibraryLock.acquire(False) and \
   385             if self.PLClibraryLock.acquire(False) and \
   384                self._GetDebugData(ctypes.byref(tick),ctypes.byref(size),ctypes.byref(buffer)) == 0 :
   386                self._GetDebugData(ctypes.byref(tick),
       
   387                                   ctypes.byref(size),
       
   388                                   ctypes.byref(buffer)) == 0 :
   385                 if size.value:
   389                 if size.value:
   386                     for idx, iectype, forced in self._Idxs:
   390                     for idx, iectype, forced in self._Idxs:
   387                         cursor = ctypes.c_void_p(buffer.value + offset)
   391                         cursor = ctypes.c_void_p(buffer.value + offset)
   388                         c_type,unpack_func, pack_func = self.TypeTranslator.get(iectype, (None,None,None))
   392                         c_type,unpack_func, pack_func = \
       
   393                             self.TypeTranslator.get(iectype,
       
   394                                                     (None,None,None))
   389                         if c_type is not None and offset < size:
   395                         if c_type is not None and offset < size:
   390                             res.append(unpack_func(ctypes.cast(cursor,
   396                             res.append(unpack_func(
   391                                                                ctypes.POINTER(c_type)).contents))
   397                                         ctypes.cast(cursor,
       
   398                                          ctypes.POINTER(c_type)).contents))
   392                             offset += ctypes.sizeof(c_type)
   399                             offset += ctypes.sizeof(c_type)
   393                         else:
   400                         else:
   394                             if c_type is None:
   401                             if c_type is None:
   395                                 PLCprint("Debug error - " + iectype + " not supported !")
   402                                 PLCprint("Debug error - " + iectype +
       
   403                                          " not supported !")
   396                             if offset >= size:
   404                             if offset >= size:
   397                                 PLCprint("Debug error - buffer too small !")
   405                                 PLCprint("Debug error - buffer too small !")
   398                             break
   406                             break
   399                 self._FreeDebugData()
   407                 self._FreeDebugData()
   400                 self.PLClibraryLock.release()
   408                 self.PLClibraryLock.release()