This commit is contained in:
Thomas Klaehn 2016-12-20 14:44:15 +01:00 committed by Thomas Klaehn
parent b0a3f6b711
commit 8730ed0913
2 changed files with 22 additions and 12 deletions

2
pylintrc Normal file
View File

@ -0,0 +1,2 @@
[TYPECHECK]
ignored-modules = numpy

View File

@ -4,29 +4,37 @@ Created on Dec 19, 2016
@author: klaehn @author: klaehn
''' '''
from engine.engine import engine
from power_sensor.power_sensor import power_sensor
from time import time from time import time
import numpy as np 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): def __init__(self):
self.__engine = engine(13, 19) self.__engine = engine(13, 19)
self.__power_sensor = power_sensor(1, 0x40) self.__power_sensor = power_sensor(1, 0x40)
self.__max_current_up = 315 self.__max_current = {"up":315, "down":280}
self.__max_current_down = 280 self.__max_time = {"open":250, "close":250}
self.__max_time_open = 250
self.__max_time_close = 250
self.__timeout_open = 0
self.__timeout_close = 0
return return
def open(self): 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() self.__engine.run_up()
power = np.array([]) power = np.array([])
timestamps = 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())
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()) timestamps = np.append(timestamps, time())
power = np.append(power, self.__power_sensor.power_mw()) power = np.append(power, self.__power_sensor.power_mw())