From 92080d650f0d18123ccb2a9816719c920fa91faf Mon Sep 17 00:00:00 2001 From: tkl Date: Tue, 27 Dec 2016 19:53:58 +0100 Subject: [PATCH] error handler expanded --- src/gate/gate_state.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gate/gate_state.py b/src/gate/gate_state.py index 627f516..1872bf4 100644 --- a/src/gate/gate_state.py +++ b/src/gate/gate_state.py @@ -56,6 +56,7 @@ class GateState(object): self.__power_data = DataBuffer(POWER_CONSECUTIVE_READS) self.__gate_move_timeout = 0 self.__light_read_timeout = 0 + self.__error_count = 0 def poll(self): current_time = time() @@ -165,4 +166,10 @@ class GateState(object): self.__gate_handler.stop() self.__comserver.transmit(MQTT_TOPIC, str(time()) + \ " Error handler!!!") - self.__update_state(STATE_INIT) + if self.__error_count >= 5: + self.__update_state(STATE_INIT) + self.__error_count += 1 + else: + self.__comserver.transmit(MQTT_TOPIC, str(time()) + \ + "Error Handler - couldn't reinitiate " + \ + "system. Bye bye...")