From c8f59f4706d2f294894b637d9e20efd8801123cf Mon Sep 17 00:00:00 2001
From: Philipp Schmidt <philipp.schmidt@xfel.eu>
Date: Fri, 8 Oct 2021 14:45:10 +0200
Subject: [PATCH] manager: Move properties for pipeline instantation to their
 own node

---
 src/calng/CalibrationManager.py | 58 ++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 27 deletions(-)

diff --git a/src/calng/CalibrationManager.py b/src/calng/CalibrationManager.py
index 820c44a1..fe2442c7 100644
--- a/src/calng/CalibrationManager.py
+++ b/src/calng/CalibrationManager.py
@@ -226,8 +226,29 @@ class WebserverApiNode(Configurable):
         accessMode=AccessMode.RECONFIGURABLE)
 
 
-class RuntimeParametersNode(Configurable):
-    # Queried from CorrectionsDevices via slot?
+class InstantiationOptionsNode(Configurable):
+    restoreMatcherSources = Bool(
+        displayedName='Restore matcher sources',
+        description='Attempt to retrieve and restore the last known '
+                    'configuration for slow and fast sources of matcher '
+                    'devices when the pipeline is instantiated.',
+        defaultValue=False,
+        accessMode=AccessMode.RECONFIGURABLE)
+
+    autoActivateGroupBridges = Bool(
+        displayedName='Activate bridges automatically',
+        description='Whether to activate all group bridges immediately after '
+                    'instantation.',
+        defaultValue=False,
+        accessMode=AccessMode.RECONFIGURABLE)
+
+    autoActivateGroupMatchers = Bool(
+        displayedName='Activate group matchers automatically',
+        description='Whether to activate all group matchers immediately after '
+                    'instantation.',
+        defaultValue=False,
+        accessMode=AccessMode.RECONFIGURABLE)
+
 
     def _device(self):
         # Pretty sure this is not supposed to work like this.
@@ -403,6 +424,11 @@ class CalibrationManager(DeviceClientBase, Device):
         description='Configurations for the webserver API to control device '
                     'servers.')
 
+    instantiationOptions = Node(
+        InstantiationOptionsNode,
+        displayedName='Instantiation options',
+        description='Optional flags controlling the pipeline instantiation.')
+
     doNotCompressEvents = Bool(
         requiredAccessLevel=AccessLevel.GOD,
         accessMode=AccessMode.READONLY,
@@ -424,28 +450,6 @@ class CalibrationManager(DeviceClientBase, Device):
         self.state = State.CHANGING
         background(self._instantiate_pipeline())
 
-    restoreMatcherSources = Bool(
-        displayedName='Restore matcher sources',
-        description='Attempt to retrieve and restore the last known '
-                    'configuration for slow and fast sources of matcher '
-                    'devices when the pipeline is instantiated.',
-        defaultValue=False,
-        accessMode=AccessMode.RECONFIGURABLE)
-
-    autoActivateBridges = Bool(
-        displayedName='Activate bridges automatically',
-        description='Whether to activate all group bridges immediately '
-                    'after instantation',
-        defaultValue=True,
-        accessMode=AccessMode.RECONFIGURABLE)
-
-    autoActivateGroupMatchers = Bool(
-        displayedName='Activate group matchers automatically',
-        description='Whether to activate all group matchers (feeding group bridges) '
-                    'immediately after instantation',
-        defaultValue=True,
-        accessMode=AccessMode.RECONFIGURABLE)
-
     outputAxisOrder = String(
         displayedName='Output axis order',
         description='Axes of main data output can be reordered after correction. '
@@ -954,7 +958,7 @@ class CalibrationManager(DeviceClientBase, Device):
                          'fsSource', input_source_by_module[vname])
                     for vname in modules_by_group[group]]
 
-                if self.restoreMatcherSources:
+                if self.instantiationOptions.restoreMatcherSources:
                     try:
                         old_config = await getConfigurationFromPast(
                             matcher_device_id, datetime.now().isoformat())
@@ -970,7 +974,7 @@ class CalibrationManager(DeviceClientBase, Device):
                     matcher_device_id, config
                 ):
                     return
-                elif self.autoActivateGroupMatchers:
+                elif self.instantiationOptions.autoActivateGroupMatchers:
                     async def _activate_matcher(device_id):
                         with await getDevice(device_id) as device:
                             await sleep(3)
@@ -995,7 +999,7 @@ class CalibrationManager(DeviceClientBase, Device):
                     server, class_ids['bridge'], bridge_device_id, config
                 ):
                     return
-                elif self.autoActivateBridges:
+                elif self.instantiationOptions.autoActivateGroupBridges:
                     # Delay the slot a bit since it will get lost during
                     # instantation.
 
-- 
GitLab