From f216ebd6db422bf7a0c9b848cfbf7be326ab1056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Balzarotti?= Date: Sat, 19 Nov 2022 19:20:04 +0100 Subject: [PATCH] make slightly resilient to missing sensors --- control/fixed_duty.py | 2 +- phasectrl.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/control/fixed_duty.py b/control/fixed_duty.py index 1eefbee..b6e1d17 100644 --- a/control/fixed_duty.py +++ b/control/fixed_duty.py @@ -39,7 +39,7 @@ class FixedDutyCycle(controllers.Controller): def fixed_duty_wrapper(args): name, duty, period = stringify(args.car, quote=False), args.cdr.car, args.cdr.cdr.car - print('name, duty, period', name, duty, period) + print('name, duty, period', name, duty*100, period) return (name, FixedDutyCycle( target=None, # reach_period_s=60*60, duty_perc=duty*100, period=period, diff --git a/phasectrl.py b/phasectrl.py index 8089cf4..50a7792 100644 --- a/phasectrl.py +++ b/phasectrl.py @@ -126,9 +126,13 @@ 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] + if ctrl.input_label not in self.envdata['sensors'].keys(): + print(f'Missing sensor {ctrl.input_label}') + continue response = ctrl.apply(self.envdata['sensors'][ctrl.input_label][0]) if self.check(): if self.next() is None: