Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
BeamCtrl committed Oct 8, 2017
1 parent 6457770 commit 708d9df
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
17 changes: 9 additions & 8 deletions airiana-core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 8 additions & 2 deletions grapher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion watch
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

watch -n 1 cat ./RAM/out
watch -n 0.1 cat ./RAM/out

0 comments on commit 708d9df

Please sign in to comment.