LPCconnector/LPCAppObject.py
changeset 29 86fb7dc2b54e
parent 0 51f5a3138405
child 30 9cd6bc93ed89
equal deleted inserted replaced
28:79ee4178006c 29:86fb7dc2b54e
    43     def ResetPLC(self):
    43     def ResetPLC(self):
    44         self.HandleSerialTransaction(RESETTransaction())
    44         self.HandleSerialTransaction(RESETTransaction())
    45         return self.PLCStatus
    45         return self.PLCStatus
    46 
    46 
    47     def GetPLCstatus(self):
    47     def GetPLCstatus(self):
    48         self.HandleSerialTransaction(GET_PLCIDTransaction())
    48         strcounts = self.HandleSerialTransaction(GET_LOGCOUNTSTransaction())
    49         return self.PLCStatus
    49         ccounts = ctypes.cast(
       
    50                       ctypes.c_char_p(strcounts),
       
    51                       ctypes.POINTER(ctypes.c_uint32))
       
    52         return (self.PLCStatus,)+tuple(int(ccounts[idx]) for idx in range(4))
    50 
    53 
    51     def MatchMD5(self, MD5):
    54     def MatchMD5(self, MD5):
    52         data = self.HandleSerialTransaction(GET_PLCIDTransaction())
    55         data = self.HandleSerialTransaction(GET_PLCIDTransaction())
    53         if data is not None:
    56         if data is not None:
    54             return data[:32] == MD5[:32]
    57             return data[:32] == MD5[:32]
   116             if offset and offset == size:
   119             if offset and offset == size:
   117                 return self.PLCStatus, tick.value, res
   120                 return self.PLCStatus, tick.value, res
   118             #PLCprint("Debug error - wrong buffer unpack !")
   121             #PLCprint("Debug error - wrong buffer unpack !")
   119         return self.PLCStatus, None, [] 
   122         return self.PLCStatus, None, [] 
   120 
   123 
       
   124     def GetLogMessage(self, level, msgid):
       
   125         strbuf = self.HandleSerialTransaction(GET_LOGMSGTransaction(level, msgid))
       
   126         if len(strbuf) > 12:
       
   127             cbuf = ctypes.cast(
       
   128                           ctypes.c_char_p(strbuf[:12]),
       
   129                           ctypes.POINTER(ctypes.c_uint32))
       
   130             return (strbuf[12:],)+tuple(int(cbuf[idx]) for idx in range(3))
       
   131         return None