changeset 503:d96042bce9d3

- fermentation heat prediction kind of works? - fix watch
author Matt Johnston <matt@ucc.asn.au>
date Mon, 21 Apr 2014 21:41:44 +0800
parents 95fe8c725f90
children 028cf9bc3ee8
files web/log.py web/watch.py
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/web/log.py	Sun Mar 30 20:32:19 2014 +0800
+++ b/web/log.py	Mon Apr 21 21:41:44 2014 +0800
@@ -83,6 +83,8 @@
     # (title, sensorline) pairs.
     sensor_lines = []
 
+    wort_sensor = None
+    fridge_sensor = None
     for n, (rrdfile, sensor) in enumerate(rrds):
         unit = None
         if 'avrtemp' in sensor:
@@ -118,11 +120,27 @@
         else:
             print_legend = legend
         sensor_lines.append( (legend, 'LINE%(width)f:%(vname)s#%(colour)s:%(print_legend)s' % locals()) )
+        if legend == 'Wort':
+            wort_sensor = vname
+        elif legend == 'Fridge':
+            fridge_sensor = vname
 
     sensor_lines.sort(key = lambda (legend, line): "Wort" in legend)
 
     graph_args += (line for (legend, line) in sensor_lines)
 
+    print>>sys.stderr, '\n'.join(graph_args)
+
+    # calculated bits
+    colour = '000000'
+    print_legend = 'Heat'
+    graph_args.append('CDEF:wortdel=%(wort_sensor)s,PREV(%(wort_sensor)s),-' % locals())
+    graph_args.append('CDEF:tempdel=%(wort_sensor)s,%(fridge_sensor)s,-' % locals())
+    graph_args.append('CDEF:fermheat=wortdel,80,*,tempdel,0.9,*,+' % locals())
+    graph_args.append('CDEF:trendfermheat=fermheat,10800,TRENDNAN' % locals())
+    graph_args.append('CDEF:limitfermheat=trendfermheat,5,+,11,MIN,2,MAX' % locals())
+    graph_args.append('LINE0.5:limitfermheat#%(colour)s:%(print_legend)s' % locals())
+
     end = int(start+length)
     start = int(start)
 
--- a/web/watch.py	Sun Mar 30 20:32:19 2014 +0800
+++ b/web/watch.py	Mon Apr 21 21:41:44 2014 +0800
@@ -47,7 +47,7 @@
 		patterns = watchpatterns[event.wd]
 		for p in patterns:
 			if fnmatch.fnmatch(event.name, p):
-				print("matched %s %s" % (event.name, p, event.maskname))
+				print("matched %s %s %s" % (event.name, p, event.maskname))
 				os.utime(touchf, None)
 
 	n = pyinotify.Notifier(watcher, triggered)