comparison service/garageArduino/garageArduino.py @ 809:bebb8f7c5a3e

move a bunch of services into this tree, give them all web status pages Ignore-this: a11e90f9d2cd9470565c743f54943c4b darcs-hash:20110808073131-312f9-a7f420d66388cedae458276d672a27a9249f1e2f.gz
author drewp <drewp@bigasterisk.com>
date Mon, 08 Aug 2011 00:31:31 -0700
parents 9e99114dde57
children 4c44c80a6a72
comparison
equal deleted inserted replaced
808:867f59c83dba 809:bebb8f7c5a3e
91 """ 91 """
92 raw data from the analog sensor, for plotting or picking a noise threshold 92 raw data from the analog sensor, for plotting or picking a noise threshold
93 """ 93 """
94 def get(self): 94 def get(self):
95 self.set_header("Content-Type", "application/javascript") 95 self.set_header("Content-Type", "application/javascript")
96 self.settings.poller.assertIsCurrent() 96 pts = []
97 self.write(json.dumps({"irLevels" : [[t1, lev1], [t2,lev2], ]})) 97 for i in range(60):
98 level = self.settings.arduino.lastLevel()
99 pts.append((round(time.time(), 3), level))
100
101 self.write(json.dumps({"irLevels" : pts}))
98 102
99 class HousePowerThreshold(PrettyErrorHandler, cyclone.web.RequestHandler): 103 class HousePowerThreshold(PrettyErrorHandler, cyclone.web.RequestHandler):
100 """ 104 """
101 the level that's between between an IR pulse and the noise 105 the level that's between between an IR pulse and the noise
102 """ 106 """
114 handlers = [ 118 handlers = [
115 (r"/", Index), 119 (r"/", Index),
116 (r"/graph", GraphPage), 120 (r"/graph", GraphPage),
117 (r"/frontDoorMotion", FrontDoorMotion), 121 (r"/frontDoorMotion", FrontDoorMotion),
118 (r'/housePower', HousePower), 122 (r'/housePower', HousePower),
119 (r'/housepower/raw', HousePowerRaw), 123 (r'/housePower/raw', HousePowerRaw),
120 (r'/housepower/threshold', HousePowerThreshold), 124 (r'/housePower/threshold', HousePowerThreshold),
121 ] 125 ]
122 settings = {"arduino" : ard, "poller" : poller} 126 settings = {"arduino" : ard, "poller" : poller}
123 cyclone.web.Application.__init__(self, handlers, **settings) 127 cyclone.web.Application.__init__(self, handlers, **settings)
124 128
125 129