diff --git a/src/calng/DetectorAssembler.py b/src/calng/DetectorAssembler.py index 562a8c0414585083979756be1502a5397bcf9ce0..d94a6be961587bf35a34595a7858fdbdc3ae5b7b 100644 --- a/src/calng/DetectorAssembler.py +++ b/src/calng/DetectorAssembler.py @@ -233,7 +233,7 @@ class DetectorAssembler(TrainMatcher.TrainMatcher): lambda match: int(match.group(1)), ), ( - r".(\/CORRECT(\d+)_Q(\d)M(\d)", # typical for big detectors + r".*\/CORRECT(\d+)_Q(\d)M(\d)", # typical QxMy for big detectors lambda match: (int(match.group(2)) - 1) * 4 + (int(match.group(3)) - 1), ), diff --git a/src/calng/base_condition.py b/src/calng/base_condition.py index 673fa1156f93cf33a384f1c3c6b7728bdb80fe8e..57e42b4d69bb095f40af17781ae1ec409a7d2607 100644 --- a/src/calng/base_condition.py +++ b/src/calng/base_condition.py @@ -110,7 +110,7 @@ class ConditionBase(Device): ) @Slot( - allowedStates=[State.ON], + allowedStates=[State.ON, State.ERROR], displayedName="Start monitoring", description="Will keep settings on manager in sync with control device(s) " "automagically by monitoring for updates.", @@ -156,7 +156,7 @@ class ConditionBase(Device): ) @Slot( - allowedStates=[State.MONITORING], + allowedStates=[State.MONITORING, State.ERROR], displayedName="Stop monitoring", ) async def stopMonitoring(self): @@ -292,7 +292,7 @@ class ConditionBase(Device): return (control_value, ideal_value, manager_value), could_look_up @Slot( - allowedStates=[State.ON], + allowedStates=[State.ON, State.ERROR], displayedName="Check conditions", description="Compares current settings on manager to control device(s), but " "does not change anything on manager.", @@ -305,7 +305,7 @@ class ConditionBase(Device): ) @Slot( - allowedStates=[State.ON], + allowedStates=[State.ON, State.ERROR], displayedName="Copy conditions", description="Copies current settings from control device(s) to manager. See " "also 'Start monitoring' for automatic version of this.", @@ -330,12 +330,21 @@ class ConditionBase(Device): @slot def requestScene(self, params): - name = params.get("name", default="overview") - if name == "overview": - scene_data = scenes.condition_checker_overview( - self.deviceId, - self.getDeviceSchema(), - ) - payload = Hash("success", True, "name", name, "data", scene_data) - - return Hash("type", "deviceScene", "origin", self.deviceId, "payload", payload) + return Hash( + "type", + "deviceScene", + "origin", + self.deviceId, + "payload", + Hash( + "success", + True, + "name", + "overview", + "data", + scenes.condition_checker_overview( + self.deviceId, + self.getDeviceSchema(), + ), + ), + ) diff --git a/src/calng/base_correction.py b/src/calng/base_correction.py index 80abb0fb5c3c2e3b1116c4c6deb70a792f16cce1..7394e78c7bada37c680cbfdadc9a92142752cb0e 100644 --- a/src/calng/base_correction.py +++ b/src/calng/base_correction.py @@ -878,7 +878,7 @@ class BaseCorrection(PythonDevice): for future in concurrent.futures.as_completed(future_to_constant): constant = future_to_constant[future] with self.warning_context( - f"foundConstants.{constant.name}.state", on_success="ON" + f"foundConstants.{constant.name}.state" ) as warn: try: constant_data = future.result() @@ -929,14 +929,8 @@ class BaseCorrection(PythonDevice): def requestScene(self, params): payload = Hash() name = params.get("name", default="") - payload["name"] = name payload["success"] = True - if name == "overview": - payload["data"] = scenes.correction_device_overview( - device_id=self.getInstanceId(), - schema=self.getFullSchema(), - ) - elif name == "constant_overrides": + if name == "constant_overrides": payload["data"] = scenes.correction_device_constant_overrides( device_id=self.getInstanceId(), schema=self.getFullSchema(), @@ -959,7 +953,13 @@ class BaseCorrection(PythonDevice): prefix, ) else: - payload["success"] = False + # overview by default + name = "overview" + payload["data"] = scenes.correction_device_overview( + device_id=self.getInstanceId(), + schema=self.getFullSchema(), + ) + payload["name"] = name response = Hash() response["type"] = "deviceScene" response["origin"] = self.getInstanceId() @@ -1092,7 +1092,7 @@ class BaseCorrection(PythonDevice): if constant not in constants: continue with self.warning_context( - f"foundConstants.{constant.name}.state", on_success="ON" + f"foundConstants.{constant.name}.state" ) as warn: try: self.log_status_info(f"Reload constant {constant.name}") diff --git a/src/calng/base_geometry.py b/src/calng/base_geometry.py index f7c70e387e2f3f3a4c8bd5ba74bdbbc5d0e0e807..01ae9b2c9064bd0b9e0d3e18ea0c368c8a555d9f 100644 --- a/src/calng/base_geometry.py +++ b/src/calng/base_geometry.py @@ -272,7 +272,7 @@ class ManualGeometryBase(Device): description="Will send 'signalNewGeometry' to connected slots. These will for " "example be DetectorAssembler. Note that signal is sent automatically when new " "geometry is set - this slot is mostly to be called by manager after " - "(re)starting assemblers while geometry device is still up." + "(re)starting assemblers while geometry device is still up.", ) async def sendGeometry(self): self.signalNewGeometry( @@ -418,15 +418,24 @@ class ManualOriginGeometryBase(ManualGeometryBase): @slot def requestScene(self, params): - name = params.get("name", default="overview") - if name == "overview": - scene_data = scenes.origin_geometry_overview( - self.deviceId, - self.getDeviceSchema(), - ) - payload = Hash("success", True, "name", name, "data", scene_data) - - return Hash("type", "deviceScene", "origin", self.deviceId, "payload", payload) + return Hash( + "type", + "deviceScene", + "origin", + self.deviceId, + "payload", + Hash( + "success", + True, + "name", + "overview", + "data", + scenes.origin_geometry_overview( + self.deviceId, + self.getDeviceSchema(), + ), + ), + ) async def _update_manual_from_current(self): raise NotImplementedError() @@ -472,15 +481,24 @@ class ManualRelativePositionsGeometryBase(ManualGeometryBase): @slot def requestScene(self, params): - name = params.get("name", default="overview") - if name == "overview": - scene_data = scenes.relative_geometry_overview( - self.deviceId, - self.getDeviceSchema(), - ) - payload = Hash("success", True, "name", name, "data", scene_data) - - return Hash("type", "deviceScene", "origin", self.deviceId, "payload", payload) + return Hash( + "type", + "deviceScene", + "origin", + self.deviceId, + "payload", + Hash( + "success", + True, + "name", + "overview", + "data", + scenes.relative_geometry_overview( + self.deviceId, + self.getDeviceSchema(), + ), + ), + ) async def _update_manual_from_current(self): raise NotImplementedError() @@ -513,15 +531,24 @@ class ManualQuadrantsGeometryBase(ManualGeometryBase): @slot def requestScene(self, params): - name = params.get("name", default="overview") - if name == "overview": - scene_data = scenes.quadrant_geometry_overview( - self.deviceId, - self.getDeviceSchema(), - ) - payload = Hash("success", True, "name", name, "data", scene_data) - - return Hash("type", "deviceScene", "origin", self.deviceId, "payload", payload) + return Hash( + "type", + "deviceScene", + "origin", + self.deviceId, + "payload", + Hash( + "success", + True, + "name", + "overview", + "data", + scenes.quadrant_geometry_overview( + self.deviceId, + self.getDeviceSchema(), + ), + ), + ) async def _set_from_manual_config(self): self._set_status("Updating geometry from manual configuration") @@ -591,16 +618,24 @@ class ManualOrientableModuleListGeometryBase(ManualGeometryBase): @slot def requestScene(self, params): - name = params.get("name", default="overview") - if name == "overview": - # Assumes there are correction devices known to manager - scene_data = scenes.modules_geometry_overview( - self.deviceId, - self.getDeviceSchema(), - ) - payload = Hash("success", True, "name", name, "data", scene_data) - - return Hash("type", "deviceScene", "origin", self.deviceId, "payload", payload) + return Hash( + "type", + "deviceScene", + "origin", + self.deviceId, + "payload", + Hash( + "success", + True, + "name", + "overview", + "data", + scenes.modules_geometry_overview( + self.deviceId, + self.getDeviceSchema(), + ), + ), + ) async def _set_from_manual_config(self): self._set_status("Updating geometry from manual configuration") @@ -634,26 +669,31 @@ class ManualRotatableModuleListGeometryBase(ManualGeometryBase): @slot def requestScene(self, params): - name = params.get("name", default="overview") - if name == "overview": - # Assumes there are correction devices known to manager - scene_data = scenes.modules_geometry_overview( - self.deviceId, - self.getDeviceSchema(), - ) - payload = Hash("success", True, "name", name, "data", scene_data) - - return Hash("type", "deviceScene", "origin", self.deviceId, "payload", payload) + return Hash( + "type", + "deviceScene", + "origin", + self.deviceId, + "payload", + Hash( + "success", + True, + "name", + "overview", + "data", + scenes.modules_geometry_overview( + self.deviceId, + self.getDeviceSchema(), + ), + ), + ) async def _set_from_manual_config(self): self._set_status("Updating geometry from manual configuration") with self.push_state(State.CHANGING): geometry = self.geometry_class.from_module_positions( [(x, y) for (x, y, _) in self.moduleList.modules.value], - [ - rotation - for (_, _, rotation) in self.moduleList.modules.value - ], + [rotation for (_, _, rotation) in self.moduleList.modules.value], ).offset((self.moduleList.offset.x.value, self.moduleList.offset.y.value)) await self._set_geometry(geometry) self.tweakGeometry._reset() diff --git a/src/calng/corrections/Gotthard2Correction.py b/src/calng/corrections/Gotthard2Correction.py index c2f0eff3e53ad868cf84c7d53bffff4049ba387d..2b11db97e4f5d83e2d65d6b5be04d1ea9eb39188 100644 --- a/src/calng/corrections/Gotthard2Correction.py +++ b/src/calng/corrections/Gotthard2Correction.py @@ -453,7 +453,6 @@ class Gotthard2Correction(base_correction.BaseCorrection): (~np.isfinite(data)).astype(np.uint8), ), timestamp=timestamp, - safeNDArray=True, ) self._preview_friend.write_outputs(metadata, buffer_array) diff --git a/src/calng/utils.py b/src/calng/utils.py index 7b800f1672202b685f787478837d6de458645836..1fa1b1a058e4a2b7f2bcbd504c44efbf26459dcf 100644 --- a/src/calng/utils.py +++ b/src/calng/utils.py @@ -42,7 +42,7 @@ class WarningContextSystem: # (for colors per lamp depending on state signifier on active set) @contextlib.contextmanager - def __call__(self, key, warn_type): + def __call__(self, key, warn_type=None): """Will return a context handler object for tkey specified schema key and warning type. It is your responsibility to ensure that the key is valid. Using __call__ on the returned context handler will issue a warning and add the