From e74192d45e505ee38d4183ae2d5f28f1f3214314 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Tue, 11 Jun 2024 09:32:49 +0200 Subject: [PATCH] HasControlledBy: update target without switching to self control when a HeaterOutput module is used e.g. from a software loop, a method is needed to update the output without switching to self-controlled Change-Id: I9c83b4e172e14812a405e836757491622ff5f949 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/33903 Reviewed-by: Markus Zolliker Tested-by: Jenkins Automated Tests Reviewed-by: Enrico Faulhaber --- frappy/mixins.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/frappy/mixins.py b/frappy/mixins.py index 06418164..4fadd6a3 100644 --- a/frappy/mixins.py +++ b/frappy/mixins.py @@ -56,6 +56,20 @@ class HasControlledBy: for deactivate_control in self.inputCallbacks.values(): deactivate_control(self.name) + def update_target(self, module, value): + """update internal target value + + as write_target would switch to manual mode, the controlling module + has to use this method to update the value + + override and super call, if other actions are needed + """ + if self.controlled_by != module: + deactivate_control = self.inputCallbacks.get(self.controlled_by) + if deactivate_control: + deactivate_control(module) + self.target = value + class HasOutputModule: """mixin for modules having an output module