diff --git a/pylintrc b/pylintrc new file mode 100644 index 0000000..1b59ef2 --- /dev/null +++ b/pylintrc @@ -0,0 +1,2 @@ +[TYPECHECK] +ignored-modules = numpy \ No newline at end of file diff --git a/src/gate/gate_handler.py b/src/gate/gate_handler.py index f72589d..caf119c 100644 --- a/src/gate/gate_handler.py +++ b/src/gate/gate_handler.py @@ -4,29 +4,37 @@ Created on Dec 19, 2016 @author: klaehn ''' -from engine.engine import engine -from power_sensor.power_sensor import power_sensor from time import time import numpy as np +from engine.engine import engine +from power_sensor.power_sensor import power_sensor -class gate_handler: +class GateHandler(object): + """Gate handler class""" def __init__(self): self.__engine = engine(13, 19) self.__power_sensor = power_sensor(1, 0x40) - self.__max_current_up = 315 - self.__max_current_down = 280 - self.__max_time_open = 250 - self.__max_time_close = 250 - self.__timeout_open = 0 - self.__timeout_close = 0 + self.__max_current = {"up":315, "down":280} + self.__max_time = {"open":250, "close":250} return def open(self): - self.__timeout_open = time() + self.__max_time_open + """Open the gate""" + timeout_open = time() + self.__max_time["open"] self.__engine.run_up() power = np.array([]) timestamps = np.array([]) - while(time() < self.__max_time_open): + while timeout_open > time(): timestamps = np.append(timestamps, time()) power = np.append(power, self.__power_sensor.power_mw()) - \ No newline at end of file + + def close(self): + """Close the gate""" + timeout_open = time() + self.__max_time["close"] + self.__engine.run_down() + power = np.array([]) + timestamps = np.array([]) + while timeout_open > time(): + timestamps = np.append(timestamps, time()) + power = np.append(power, self.__power_sensor.power_mw()) + \ No newline at end of file