diff --git a/src/close.py b/src/close.py index 806c4f0..d4050a6 100644 --- a/src/close.py +++ b/src/close.py @@ -4,7 +4,7 @@ Created on Dec 23, 2016 @author: klaehn ''' import sys -from time import sleep +import time from datetime import datetime as dt from data_buffer import DataBuffer @@ -16,7 +16,7 @@ POWER_SENSOR_I2C_ADDRESS = 0x40 CONSECUTIVE_POWER_READS = 1000 -MAX_ENGINE_POWER = {"up":330, "down":290} +MAX_ENGINE_POWER = {"up":330, "down":280} def main(argv): gate_handler = GateHandler() @@ -25,20 +25,19 @@ def main(argv): gate_handler.close() try: while True: - power_data.push(power_sensor.power_mw()) + rd = power_sensor.power_mw() + power_data.push(rd) average = power_data.average() - print str(dt.now()) + " avg pwr: " + str(average) + " mW" + print str(time.time()) + " " + str(rd) if average != None: if average > MAX_ENGINE_POWER["down"]: - gate_handler.open() - sleep(5) gate_handler.stop() - print "Gate successfully closed" +# print "Gate successfully closed" return 0 except KeyboardInterrupt: gate_handler.stop() - print "Closing procedure interrupted." +# print "Closing procedure interrupted." return 1 diff --git a/src/open.py b/src/open.py index 269d258..a6a6c6a 100644 --- a/src/open.py +++ b/src/open.py @@ -4,7 +4,7 @@ Created on Dec 23, 2016 @author: klaehn ''' import sys -from time import sleep +import time from datetime import datetime as dt from data_buffer import DataBuffer @@ -25,15 +25,14 @@ def main(argv): gate_handler.open() try: while True: - power_data.push(power_sensor.power_mw()) + rd = power_sensor.power_mw() + power_data.push(rd) average = power_data.average() - print str(dt.now()) + " avg pwr: " + str(average) + " mW" + print str(time.time()) + " " + str(rd) if average != None: if average > MAX_ENGINE_POWER["up"]: - gate_handler.close() - sleep(5) gate_handler.stop() - print "Gate successfully opened" +# print "Gate successfully opened" return 0 except KeyboardInterrupt: