diff --git a/tangostationcontrol/tangostationcontrol/devices/device_decorators.py b/tangostationcontrol/tangostationcontrol/devices/device_decorators.py index 5300ba2a06380599a3457c1624344243b7f5db60..c4f333eb6e9dff5d2e5cf6f0b52129b2915e0cac 100644 --- a/tangostationcontrol/tangostationcontrol/devices/device_decorators.py +++ b/tangostationcontrol/tangostationcontrol/devices/device_decorators.py @@ -51,7 +51,7 @@ def fault_on_error(): return func(self, *args, **kwargs) except Exception as e: self.error_stream("Function failed. Trace: %s", traceback.format_exc()) - self.Fault() + self.Fault(f"FAULT in {func.__name__}: {e.__class__.__name__}: {e}") return None return error_wrapper diff --git a/tangostationcontrol/tangostationcontrol/devices/lofar_device.py b/tangostationcontrol/tangostationcontrol/devices/lofar_device.py index 5a2cc74136514d0aa4a2f2ce16fb1609d9a219ec..87a78c05c22928b48da42dd060e8f7e38b24d8f3 100644 --- a/tangostationcontrol/tangostationcontrol/devices/lofar_device.py +++ b/tangostationcontrol/tangostationcontrol/devices/lofar_device.py @@ -85,6 +85,7 @@ class lofar_device(Device, metaclass=AbstractDeviceMetas): Device.init_device(self) self.set_state(DevState.OFF) + self.set_status("Device is in the OFF state.") @log_exceptions() def delete_device(self): @@ -115,6 +116,8 @@ class lofar_device(Device, metaclass=AbstractDeviceMetas): :return:None """ self.set_state(DevState.INIT) + self.set_status("Device is in the INIT state.") + self.setup_value_dict() # reload our class & device properties from the Tango database @@ -123,6 +126,7 @@ class lofar_device(Device, metaclass=AbstractDeviceMetas): self.configure_for_initialise() self.set_state(DevState.STANDBY) + self.set_status("Device is in the STANDBY state.") @command() @only_in_states([DevState.STANDBY, DevState.ON]) @@ -141,7 +145,9 @@ class lofar_device(Device, metaclass=AbstractDeviceMetas): return self.configure_for_on() + self.set_state(DevState.ON) + self.set_status("Device is in the ON state.") @command() @DebugIt() @@ -158,23 +164,25 @@ class lofar_device(Device, metaclass=AbstractDeviceMetas): # Turn off self.set_state(DevState.OFF) + self.set_status("Device is in the OFF state.") self.configure_for_off() # Turn off again, in case of race conditions through reconnecting self.set_state(DevState.OFF) + self.set_status("Device is in the OFF state.") + @command() @only_in_states([DevState.ON, DevState.INIT, DevState.STANDBY, DevState.FAULT]) @DebugIt() @log_exceptions() - def Fault(self): + def Fault(self, new_status="Device is in the FAULT state."): """ - FAULT state is used to indicate our connection with the OPC-UA server is down. - - This device will try to reconnect once, and transition to the ON state on success. + FAULT state is used to indicate the device broke down, and partially or fully + stopped functioning. Remaining functionality is undefined. - If reconnecting fails, the user needs to call Initialise() to retry to restart this device. + new_status: The status to set when going to FAULT. :return:None """ @@ -183,8 +191,10 @@ class lofar_device(Device, metaclass=AbstractDeviceMetas): logger.warning("Requested to go to FAULT state, but am already in FAULT state.") return - self.configure_for_fault() self.set_state(DevState.FAULT) + self.set_status(new_status) + + self.configure_for_fault() # functions that can or must be overloaded def configure_for_fault(self):