class Task_flow(Thread): def __init__(self): Thread.__init__(self) self.ey = Eyeo() def run(self): while True: # detect input changes and inc count state = self.ey.read_flow_meter() self.st = bool(data['lastflowpinstate']) self.tm = int(data['lastflowratetimer']) self.ct = int(data['pulse_count']) if (state == self.st): self.tm += 1 data['lastflowratetimer'] = self.tm return if (state == HIGH): # low to high transition! self.ct += 1 data['pulse_count'] = self.ct data['lastflowpinstate'] = state data['lastflowratetimer'] = 0 time.sleep(.01) return
class Task_second(Thread): def __init__(self): Thread.__init__(self) print "Task_second init" self.ey = Eyeo() def run(self): while (True): # calc flow CalcFlow() # do valve control if (bool(data['valve_open']) == True): if (float(data['flow_delivered']) >= float(data['water_required'])): # close valve self.ey.control_valve(CLOSE) time.sleep(1) return
def __init__(self): Thread.__init__(self) self.ey = Eyeo()
def __init__(self): Thread.__init__(self) print "Task_second init" self.ey = Eyeo()