From 708d9df3c8acd4386e03d4ca4473dcba7930171d Mon Sep 17 00:00:00 2001 From: "daniel.halling@outlook.com" Date: Sun, 8 Oct 2017 22:00:48 +0200 Subject: [PATCH] updates --- airiana-core.py | 17 +++++++++-------- grapher.py | 10 ++++++++-- watch | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/airiana-core.py b/airiana-core.py index e4aacdc..19f7402 100755 --- a/airiana-core.py +++ b/airiana-core.py @@ -267,13 +267,13 @@ def write_register(self, reg, value,functioncode=6): resp = client.write_register(reg,value,0,6) except IOError as error: #print "write, ioerror",error,os.read(bus,20),";" - os.write(ferr,"write: "+str(error)+"\n") + #os.write(ferr,"write: "+str(error)+"\n") self.write_errors += 1 #self.write_register(reg,value) pass except ValueError as error: #print "write, val error",error,os.read(bus,20),"\n--",reg," ",value,";" - os.write(ferr,"write: "+str(error)+"\n") + #os.write(ferr,"write: "+str(error)+"\n") self.write_errors += 1 #self.write_register(reg,value) pass @@ -683,8 +683,9 @@ def moisture_calcs(self):## calculate moisure/humidities # "C target:"+str(round((( low_pw+d_pw ) / max_pw ) * 100,2))+ "%\n" self.new_humidity += (((( low_pw+d_pw ) / max_pw ) * 100 )-self.new_humidity) *0.0001 - if self.iter %81 == 0: - self.msg += "Humidity target: "+str((( low_pw+d_pw ) / max_pw ) * 100 ) + if self.iter %30 == 0: + self.msg += "Humidity target: "+str((( low_pw+d_pw ) / max_pw ) * 100 )+"\n" + return (( low_pw+d_pw ) / max_pw ) * 100 #####END #calc long and short derivatives @@ -1081,10 +1082,10 @@ def get_local(self): temp = float(tmp[1]) self.local_humidity = float(tmp[0]) comp = float(os.popen("./forcast.py tomorrows-low").read().split(" ")[0]) - comp = float(comp - temp)/1000 - self.kinetic_compensation -= comp * self.avg_frame_time + comp = float(comp - temp)/2500 + self.kinetic_compensation += comp * self.avg_frame_time if "debug" in sys.argv: - self.msg += "static comp set to: " +str(round(comp,4))+"\n" + self.msg += "Comp set to: " +str(round(comp,4))+" Static offset:"+str(round(self.kinetic_compensation,2))+"\n" if temp <> self.prev_static_temp: self.prev_static_temp = temp self.kinetic_compensation = (-1+float(os.popen("./forcast.py now").read().split(" ")[-5][:-3]))/2 @@ -1158,7 +1159,7 @@ def set_monitoring(bool): device.div = device.inlet_ave starttime=time.time() if "humidity" in sys.argv: - device.moisture_calcs() + device.new_humidity = device.moisture_calcs() print "system started:",time.ctime(starttime),";" sys.stdout.flush() diff --git a/grapher.py b/grapher.py index a3064bc..703b2a2 100755 --- a/grapher.py +++ b/grapher.py @@ -9,6 +9,7 @@ ## make backup of datafile if large## rev = 1 if int(os.stat("./RAM/data.log").st_size) > 102400*5: + os.system("./humtest.py >> humtest.log") while os.path.isfile("data.log."+str(rev)): rev += 1 os.system("mv ./RAM/data.log ./data.log."+str(rev)) os.system("tail -n "+str(60*24*3)+" data.log."+str(rev)+" > ./RAM/data.log") @@ -18,8 +19,13 @@ os.system("mv tmp.log data.log."+str(rev)) ###################### -#if len(sys.argv) >=2 and "debug" not in sys.argv[1] and "humidities" not in sys.argv :day= int(sys.argv[1]) -day = int(float(3600*24)) +if len(sys.argv) >=2 : + try: + day= int(sys.argv[1]) + print "day set to" ,day + except: day= 3600*24 +else: + day = 3600*24 fil = os.popen("tail -n "+str(day/5)+" ./RAM/data.log") data = fil.readlines() #print data[-1], tm.time() diff --git a/watch b/watch index b12124f..6ce15d4 100755 --- a/watch +++ b/watch @@ -1,4 +1,4 @@ #!/bin/bash -watch -n 1 cat ./RAM/out +watch -n 0.1 cat ./RAM/out