July 2021
24
def processData(self,packetBody):
if self.dataFilename == None:
self.dataFilename = format( "DAT_S%X_%X_R%X_%X.txt" % (self.senderAddr, self.senderID, self.recipientAddr, self.recipientID) )
self.dataFile = ResFile("",self.test_directory_path, self.dataFilename)
dataBytes = bytes(packetBody[3:])
self.bodyStr = dataBytes.decode('utf-8')
self.timedate = self.bodyStr.split(',',2)
self.msg = self.timedate[2]
self.t= "Data"
self.dataFile.appendTestFileString(self.bodyStr)
self.updateData()
self.gui.mode.set("RUN")
def processEvent(self,packetBody,eventType):
if self.eventFilename == None:
self.eventFilename = format( "EVL_S%X_%X_R%X_%X.txt" % (self.senderAddr, self.senderID, self.recipientAddr, self.recipientID) )
self.eventFile = ResFile("",self.test_directory_path, self.eventFilename)
dataBytes = bytes(packetBody[3:])
self.bodyStr = dataBytes.decode('utf-8')
self.timedate = self.bodyStr.split(',',2)
self.msg = self.timedate[2]
if ',' in self.msg:
junk = self.msg.split(',',1)
self.msg = junk[0]
self.code = junk[1]
self.t= eventType
self.eventFile.appendTestFileString(self.bodyStr)
def processPacketBody(self,packetBody):
ret_ = False
self.tag = ""
self.code = ""
self.typeStr = ""
if packetBody[0] == ord('C'):
self.t= "Incubator "
if packetBody[1] == ord('L'):
self.t= "Logging "
if self.gui != None:
self.gui.powered.set("On")
if packetBody[2] == ord('D'):
self.processData(packetBody)
ret_ = True
elif packetBody[2] == ord('A'):
self.processEvent(packetBody,"Alarm")
self.tag = "alarmRow"
ret_ = True
elif packetBody[2] == ord('E'):
self.processEvent(packetBody,"Event")
self.updateStatus()
ret_ = True
elif packetBody[2] == ord('F'):
self.processEvent(packetBody,"Fault")
self.tag = "faultRow"
ret_ = True
else:
print("INVALID BODY TYPE:",packetBody[2])
ret_ = False
if ret_:
if self.gui is None:
print(self.typeStr,"= ",self.bodyStr)
else:
self.gui.displayMsg(self)
return ret_