add calculation time debug message for simulator

This commit is contained in:
interfisch 2018-01-13 13:11:20 +01:00
parent c065795134
commit fee8f342eb
1 changed files with 4 additions and 1 deletions

View File

@ -31,6 +31,7 @@ class FlipdotSim():
self.udpHostSocket.bind(("", self.udpPort)) self.udpHostSocket.bind(("", self.udpPort))
self.timesincelastpacket=time.time() self.timesincelastpacket=time.time()
self.timelastcalculation=0
def run(self): def run(self):
self.RunServer() self.RunServer()
@ -49,7 +50,7 @@ class FlipdotSim():
imageArray = ImageArrayAdapter().convertPacketToImageArray(rawData) imageArray = ImageArrayAdapter().convertPacketToImageArray(rawData)
if DEBUG: if DEBUG:
print("Received Data. Time since last message: "+str( round( time.time()-self.timesincelastpacket,2))+"s ("+str( round( (1/ (time.time()-self.timesincelastpacket) ) ,2) ) +" FPS)") print("Received Data. Time since last message: "+str( round( time.time()-self.timesincelastpacket,2))+"s ("+str( round( (1/ (time.time()-self.timesincelastpacket) ) ,2) ) +" FPS), last calctime="+str(round( (self.timelastcalculation) ,2)))
self.timesincelastpacket=time.time() self.timesincelastpacket=time.time()
_bitsneeded=self.imageSize[0]*self.imageSize[1]*self.bitsperpixel _bitsneeded=self.imageSize[0]*self.imageSize[1]*self.bitsperpixel
if len(imageArray) < _bitsneeded: if len(imageArray) < _bitsneeded:
@ -67,6 +68,8 @@ class FlipdotSim():
self.flipdotMatrixSimulatorWidget.show(imageArray) #send to simulator display self.flipdotMatrixSimulatorWidget.show(imageArray) #send to simulator display
self.timelastcalculation=time.time()-self.timesincelastpacket #calculate time it took for calculation and drawing
finally: finally:
self.udpHostSocket.close() self.udpHostSocket.close()