fix attuator

This commit is contained in:
Nicolò Balzarotti 2022-11-19 19:33:19 +01:00
parent f7491bb79b
commit ce789263f0
2 changed files with 3 additions and 3 deletions

4
app.py
View File

@ -97,7 +97,7 @@ def run_recipes():
updateState()
sleep(1)
def read_esnsors():
def read_sensors():
while True:
sensors.read()
socketio.emit('sensors', (sensors.get(),))
@ -107,7 +107,7 @@ import threading
if __name__ == '__main__':
thread = threading.Thread(target=run_recipes, daemon=True)
thread.start()
sensors_thread = threading.Thread(target=read_esnsors, daemon=True)
sensors_thread = threading.Thread(target=read_sensors, daemon=True)
sensors_thread.start()
print('RUN APP')
socketio.run(app, host='0.0.0.0')

View File

@ -126,7 +126,6 @@ class State():
for sensor in self.envdata.get('sensors', ()):
_, ctrl, target = self.envdata['sensors'][sensor]
self.envdata['sensors'][sensor] = (get_sensor_value(sensor), ctrl, target)
print(self.envdata)
# Apply actuators
for controller in self.envdata.get('controllers', {}).keys():
ctrl = self.envdata['controllers'][controller]
@ -134,6 +133,7 @@ class State():
print(f'Missing sensor {ctrl.input_label}')
continue
response = ctrl.apply(self.envdata['sensors'][ctrl.input_label][0])
actuators[controller].enable(response)
if self.check():
if self.next() is None:
return True