diff --git a/src/calng/CalibrationManager.py b/src/calng/CalibrationManager.py index 6a05a27645432913f42cfa6b6d007a3a3bda8d7e..2c89e200362e84614508164ae31f6a61035bd373 100644 --- a/src/calng/CalibrationManager.py +++ b/src/calng/CalibrationManager.py @@ -1310,7 +1310,8 @@ class CalibrationManager(DeviceClientBase, Device): 'constantParameters.detectorName', detector_id, 'constantParameters.karaboDa', aggregator, 'dataInput.connectedOutputChannels', [input_channel], - 'fastSources', [input_source] + 'fastSources', [input_source], + 'geometryDevice', self.geometryDevice.value ) # Add managed keys. diff --git a/src/calng/base_correction.py b/src/calng/base_correction.py index 94c0d82907b2f2c883128cd06ad0955c438ce31e..b409234279910a6c0ddfa0cf3a89b47897ef4e71 100644 --- a/src/calng/base_correction.py +++ b/src/calng/base_correction.py @@ -248,6 +248,13 @@ class BaseCorrection(PythonDevice): .assignmentOptional() .defaultValue(True) .commit(), + + STRING_ELEMENT(expected) + .key("geometryDevice") + .displayedName("Geometry device") + .assignmentOptional() + .defaultValue("") + .commit(), ) ( @@ -709,6 +716,15 @@ class BaseCorrection(PythonDevice): key = f"foundConstants.{constant.name}.state" self._warning_trackers[key] = utils.ContextWarningLamp(self, key) + self._geometry = None + if self.get("geometryDevice"): + self.signalSlotable.connect( + self.get("geometryDevice"), + "signalNewGeometry", + "", # slot device ID (default: self) + "slotReceiveGeometry", + ) + with self.warning_context( "deviceInternalsState", WarningLampType.CALCAT_CONNECTION ) as warn: @@ -955,6 +971,13 @@ class BaseCorrection(PythonDevice): response["payload"] = payload self.reply(response) + def slotReceiveGeometry(self, device_id, serialized_geometry): + self.log.INFO(f"Received geometry from {device_id}") + try: + self._geometry = geom_utils.deserialize_geometry(serialized_geometry) + except Exception as e: + self.log.WARN(f"Failed to deserialize geometry; {e}") + def _write_output(self, data, old_metadata): """For dataOutput: reusing incoming data hash and setting source and timestamp to be same as input""" diff --git a/src/calng/correction_addons/base_addon.py b/src/calng/correction_addons/base_addon.py index ae03225e64bde4ce00b98642fb059d53843e0466..ef7d0deee4960f2a33c6c7d3a36eef0693a4da47 100644 --- a/src/calng/correction_addons/base_addon.py +++ b/src/calng/correction_addons/base_addon.py @@ -1,5 +1,6 @@ class BaseCorrectionAddon: _node_name = None # subclass must set (usually name of addon minus "Addon" suffix) + _device = None # will be set to host device *after* init @staticmethod def extend_device_schema(schema, prefix):