scripts for "bypassing" open and close
This commit is contained in:
parent
d68e642f21
commit
5fe02f2ae3
41
src/close.py
Normal file
41
src/close.py
Normal file
@ -0,0 +1,41 @@
|
||||
'''
|
||||
Created on Dec 23, 2016
|
||||
|
||||
@author: klaehn
|
||||
'''
|
||||
import sys
|
||||
|
||||
from data_buffer import DataBuffer
|
||||
from gate.gate_handler import GateHandler
|
||||
from power_sensor import PowerSensor
|
||||
|
||||
POWER_SENSOR_I2C_BUS = 1
|
||||
POWER_SENSOR_I2C_ADDRESS = 0x40
|
||||
|
||||
CONSECUTIVE_POWER_READS = 1000
|
||||
|
||||
MAX_ENGINE_POWER = {"up":330, "down":290}
|
||||
|
||||
def main(argv):
|
||||
gate_handler = GateHandler()
|
||||
power_sensor = PowerSensor(POWER_SENSOR_I2C_BUS, POWER_SENSOR_I2C_ADDRESS)
|
||||
power_data = DataBuffer(CONSECUTIVE_POWER_READS)
|
||||
gate_handler.close()
|
||||
try:
|
||||
while True:
|
||||
power_data.push(power_sensor.power_mw())
|
||||
average = power_data.average()
|
||||
print "average power: " + str(average) + " mW"
|
||||
if average != None:
|
||||
if average > MAX_ENGINE_POWER["down"]:
|
||||
gate_handler.stop()
|
||||
print "Gate successfully closed"
|
||||
return 0
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print "Closing procedure interrupted."
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
41
src/open.py
Normal file
41
src/open.py
Normal file
@ -0,0 +1,41 @@
|
||||
'''
|
||||
Created on Dec 23, 2016
|
||||
|
||||
@author: klaehn
|
||||
'''
|
||||
import sys
|
||||
|
||||
from data_buffer import DataBuffer
|
||||
from gate.gate_handler import GateHandler
|
||||
from power_sensor import PowerSensor
|
||||
|
||||
POWER_SENSOR_I2C_BUS = 1
|
||||
POWER_SENSOR_I2C_ADDRESS = 0x40
|
||||
|
||||
CONSECUTIVE_POWER_READS = 1000
|
||||
|
||||
MAX_ENGINE_POWER = {"up":330, "down":290}
|
||||
|
||||
def main(argv):
|
||||
gate_handler = GateHandler()
|
||||
power_sensor = PowerSensor(POWER_SENSOR_I2C_BUS, POWER_SENSOR_I2C_ADDRESS)
|
||||
power_data = DataBuffer(CONSECUTIVE_POWER_READS)
|
||||
gate_handler.open()
|
||||
try:
|
||||
while True:
|
||||
power_data.push(power_sensor.power_mw())
|
||||
average = power_data.average()
|
||||
print "average power: " + str(average) + " mW"
|
||||
if average != None:
|
||||
if average > MAX_ENGINE_POWER["up"]:
|
||||
gate_handler.stop()
|
||||
print "Gate successfully opened"
|
||||
return 0
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print "Closing procedure interrupted."
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
Loading…
Reference in New Issue
Block a user