From bc2b860f310da8ee2444f02e7e02b44729af5eef Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Mon, 8 May 2023 14:11:43 +0200 Subject: [PATCH] mixins should not inherit Module else conflicts building MRO may arise Change-Id: Ifdfc5000884d5d815a55eca6dbb5198b19410890 Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/31046 Tested-by: Jenkins Automated Tests Reviewed-by: Markus Zolliker --- frappy/mixins.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/frappy/mixins.py b/frappy/mixins.py index c353ad40..8bfad2c0 100644 --- a/frappy/mixins.py +++ b/frappy/mixins.py @@ -21,16 +21,17 @@ # ***************************************************************************** from frappy.datatypes import BoolType, EnumType, Enum -from frappy.core import Parameter, Writable, Attached +from frappy.core import Parameter, Attached -class HasControlledBy(Writable): +class HasControlledBy: """mixin for modules with controlled_by in the :meth:`write_target` the hardware action to switch to own control should be done and in addition self.self_controlled() should be called """ controlled_by = Parameter('source of target value', EnumType(members={'self': 0}), default=0) + target = Parameter() # make sure target is a parameter inputCallbacks = () def register_input(self, name, deactivate_control): @@ -57,7 +58,7 @@ class HasControlledBy(Writable): deactivate_control(self.name) -class HasOutputModule(Writable): +class HasOutputModule: """mixin for modules having an output module in the :meth:`write_target` the hardware action to switch to own control should be done @@ -66,6 +67,7 @@ class HasOutputModule(Writable): # mandatory=False: it should be possible to configure a module with fixed control output_module = Attached(HasControlledBy, mandatory=False) control_active = Parameter('control mode', BoolType(), default=False) + target = Parameter() # make sure target is a parameter def initModule(self): super().initModule() @@ -85,8 +87,8 @@ class HasOutputModule(Writable): out.controlled_by = self.name self.control_active = True - def deactivate_control(self, switched_by): + def deactivate_control(self, source): """called when an other module takes over control""" if self.control_active: self.control_active = False - self.log.warning(f'switched to manual mode by {switched_by}') + self.log.warning(f'switched to manual mode by {source}')