open/close: change log to raw values

Signed-off-by: Thomas Klaehn <thomas.klaehn@u-blox.com>
This commit is contained in:
Thomas Klaehn 2017-03-30 10:31:54 +02:00
parent c5eb6ffc7a
commit 28b0b82237
2 changed files with 12 additions and 14 deletions

View File

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

View File

@ -4,7 +4,7 @@ Created on Dec 23, 2016
@author: klaehn @author: klaehn
''' '''
import sys import sys
from time import sleep import time
from datetime import datetime as dt from datetime import datetime as dt
from data_buffer import DataBuffer from data_buffer import DataBuffer
@ -25,15 +25,14 @@ def main(argv):
gate_handler.open() gate_handler.open()
try: try:
while True: while True:
power_data.push(power_sensor.power_mw()) rd = power_sensor.power_mw()
power_data.push(rd)
average = power_data.average() average = power_data.average()
print str(dt.now()) + " avg pwr: " + str(average) + " mW" print str(time.time()) + " " + str(rd)
if average != None: if average != None:
if average > MAX_ENGINE_POWER["up"]: if average > MAX_ENGINE_POWER["up"]:
gate_handler.close()
sleep(5)
gate_handler.stop() gate_handler.stop()
print "Gate successfully opened" # print "Gate successfully opened"
return 0 return 0
except KeyboardInterrupt: except KeyboardInterrupt: