예제 #1
0
파일: Task_flow.py 프로젝트: KenHopwood/MAD
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
예제 #2
0
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
예제 #3
0
파일: Task_flow.py 프로젝트: KenHopwood/MAD
 def __init__(self):
     Thread.__init__(self)
     self.ey = Eyeo()
예제 #4
0
 def __init__(self):
     Thread.__init__(self)
     print "Task_second init"
     self.ey = Eyeo()