logFile = open('logFile.csv', 'a') logFile.write(firstLogString) print("logged: " + firstLogString) logFile.close() grapher4 = PeachyGrapher(numlines=3) #grapher2=PeachyGrapher(title='TITLE',xlabel='XXX',ylabel='YYY',graphsize=20,numlines=1,legend=["string legend"],padding=2) while True: ##mesageCount += 1 if heardEnter() == True: logString = str(logCount) + "," + str( graphLastMax) + "," + time.strftime("%Y:%m:%d:%H:%M:%S") + "\n" logFile = open('logFile.csv', 'a') logFile.write(logString) logFile.close() print("logged: " + logString) graphLastMax = 0 logCount += 1 mesage = int(str(ser.readline().split(',')[0])) if mesage > graphLastMax: graphLastMax = mesage grapher4.addPoint([mesage, graphLastMax, graphMin]) # for i in range(0,testLen): # rando=random.randint(0,10) # grapher4.addPoint([rando,rando+2,rando+5,rando-2,rando-5]) # grapher4.saveGraph("3_line_dynamic.png")
self.logFid.write(msg+"\n") self.logFid.flush() try: self.temps.append(float(split_msg[2])) except: print "tried to graph not an int" return split_msg def save_exit(): print "Exiting Cleanly and saving graph" grapher.saveGraph("reflow.png") if __name__=="__main__": logger=ReflowLogger() grapher=PeachyGrapher(title="Reflow Curve",xlabel="seconds (s)",ylabel="Temperature (C)") connectionStatus=logger.connect() atexit.register(save_exit) while(connectionStatus): msg=logger.readSerial() if (len(msg)==4): try: if float(msg[2])<500: grapher.addPoint(float(msg[2])) #grapher.saveGraph("reflow.png") else: print "Got Bad result, Thermal Couple Die again?" except: print "Bad Graphing Line" print msg time.sleep(0.1)