From 4413446485d65d424615116510057ff0eb219302 Mon Sep 17 00:00:00 2001 From: Thomas Klaehn Date: Fri, 23 Dec 2016 13:18:28 +0100 Subject: [PATCH] ensure wire stays not under strain --- src/close.py | 3 +++ src/gate/gate_state.py | 6 +++++- src/open.py | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/close.py b/src/close.py index 0f19fdc..421e95f 100644 --- a/src/close.py +++ b/src/close.py @@ -4,6 +4,7 @@ Created on Dec 23, 2016 @author: klaehn ''' import sys +from time import sleep from data_buffer import DataBuffer from gate.gate_handler import GateHandler @@ -28,6 +29,8 @@ def main(argv): print "average power: " + str(average) + " mW" if average != None: if average > MAX_ENGINE_POWER["down"]: + gate_handler.open() + sleep(2) gate_handler.stop() print "Gate successfully closed" return 0 diff --git a/src/gate/gate_state.py b/src/gate/gate_state.py index fc470a2..9c54634 100644 --- a/src/gate/gate_state.py +++ b/src/gate/gate_state.py @@ -3,7 +3,7 @@ Created on Dec 19, 2016 @author: klaehn ''' -from time import time +from time import time, sleep from communiate.protocol import mqtt from data_buffer import DataBuffer from light_sensor.light_sensor import light_sensor @@ -91,6 +91,8 @@ class GateState(object): def __opened_handler(self, light_avg): next_state = self.__next_state if self.__is_transition(): + self.__gate_handler.close() + sleep(2) self.__gate_handler.stop() self.__comserver.transmit(MQTT_TOPIC, str(time()) + " Opened " + \ str(self.__power_data.average()) + " mW") @@ -105,6 +107,8 @@ class GateState(object): def __closed_handler(self, light_avg): next_state = self.__next_state if self.__is_transition(): + self.__gate_handler.open() + sleep(2) self.__gate_handler.stop() self.__comserver.transmit(MQTT_TOPIC, str(time()) + " Closed " + \ str(self.__power_data.average()) + " mW") diff --git a/src/open.py b/src/open.py index a9687e3..5aa0e65 100644 --- a/src/open.py +++ b/src/open.py @@ -4,6 +4,7 @@ Created on Dec 23, 2016 @author: klaehn ''' import sys +from time import sleep from data_buffer import DataBuffer from gate.gate_handler import GateHandler @@ -28,6 +29,8 @@ def main(argv): print "average power: " + str(average) + " mW" if average != None: if average > MAX_ENGINE_POWER["up"]: + gate_handler.close() + sleep(2) gate_handler.stop() print "Gate successfully opened" return 0