fix attuator
This commit is contained in:
parent
f7491bb79b
commit
ce789263f0
4
app.py
4
app.py
|
@ -97,7 +97,7 @@ def run_recipes():
|
||||||
updateState()
|
updateState()
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
def read_esnsors():
|
def read_sensors():
|
||||||
while True:
|
while True:
|
||||||
sensors.read()
|
sensors.read()
|
||||||
socketio.emit('sensors', (sensors.get(),))
|
socketio.emit('sensors', (sensors.get(),))
|
||||||
|
@ -107,7 +107,7 @@ import threading
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
thread = threading.Thread(target=run_recipes, daemon=True)
|
thread = threading.Thread(target=run_recipes, daemon=True)
|
||||||
thread.start()
|
thread.start()
|
||||||
sensors_thread = threading.Thread(target=read_esnsors, daemon=True)
|
sensors_thread = threading.Thread(target=read_sensors, daemon=True)
|
||||||
sensors_thread.start()
|
sensors_thread.start()
|
||||||
print('RUN APP')
|
print('RUN APP')
|
||||||
socketio.run(app, host='0.0.0.0')
|
socketio.run(app, host='0.0.0.0')
|
||||||
|
|
|
@ -126,7 +126,6 @@ class State():
|
||||||
for sensor in self.envdata.get('sensors', ()):
|
for sensor in self.envdata.get('sensors', ()):
|
||||||
_, ctrl, target = self.envdata['sensors'][sensor]
|
_, ctrl, target = self.envdata['sensors'][sensor]
|
||||||
self.envdata['sensors'][sensor] = (get_sensor_value(sensor), ctrl, target)
|
self.envdata['sensors'][sensor] = (get_sensor_value(sensor), ctrl, target)
|
||||||
print(self.envdata)
|
|
||||||
# Apply actuators
|
# Apply actuators
|
||||||
for controller in self.envdata.get('controllers', {}).keys():
|
for controller in self.envdata.get('controllers', {}).keys():
|
||||||
ctrl = self.envdata['controllers'][controller]
|
ctrl = self.envdata['controllers'][controller]
|
||||||
|
@ -134,6 +133,7 @@ class State():
|
||||||
print(f'Missing sensor {ctrl.input_label}')
|
print(f'Missing sensor {ctrl.input_label}')
|
||||||
continue
|
continue
|
||||||
response = ctrl.apply(self.envdata['sensors'][ctrl.input_label][0])
|
response = ctrl.apply(self.envdata['sensors'][ctrl.input_label][0])
|
||||||
|
actuators[controller].enable(response)
|
||||||
if self.check():
|
if self.check():
|
||||||
if self.next() is None:
|
if self.next() is None:
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in New Issue