diff --git a/tangostationcontrol/tangostationcontrol/devices/base_device_classes/lofar_device.py b/tangostationcontrol/tangostationcontrol/devices/base_device_classes/lofar_device.py index 7930a1dc3451810f6a29c3711df9c0cc478e79dc..a43e44b13b8545b78260e80ad50749de433f7880 100644 --- a/tangostationcontrol/tangostationcontrol/devices/base_device_classes/lofar_device.py +++ b/tangostationcontrol/tangostationcontrol/devices/base_device_classes/lofar_device.py @@ -45,10 +45,7 @@ from tangostationcontrol.common.lofar_logging import ( device_logging_to_python, ) from tangostationcontrol.common.proxy import create_device_proxy -from tangostationcontrol.common.states import ( - DEFAULT_COMMAND_STATES, - INITIALISED_STATES, -) +from tangostationcontrol.common.states import DEFAULT_COMMAND_STATES from tangostationcontrol.common.type_checking import sequence_not_str from tangostationcontrol.devices.base_device_classes.control_hierarchy import ( ControlHierarchyDevice, @@ -220,7 +217,7 @@ class LOFARDevice(Device): def is_attribute_access_allowed(self, req_type: AttReqType): """Returns whether an attribute wrapped by the AttributeWrapper be accessed.""" - return self.get_state() in INITIALISED_STATES + return self.get_state() in DEFAULT_COMMAND_STATES # TODO(Corne): Actually implement locking in L2SS-940 def atomic_read_modify_write_attribute( @@ -405,6 +402,7 @@ class LOFARDevice(Device): # Commands # -------- + @only_in_states([DevState.OFF]) def _Initialise(self): """ Command to ask for initialisation of this device. Can only be called in OFF state. @@ -443,11 +441,11 @@ class LOFARDevice(Device): @command() @debugit() @log_exceptions() - @only_in_states([DevState.OFF]) @fault_on_error() def Initialise(self): self._Initialise() + @only_in_states(DEFAULT_COMMAND_STATES) def _On(self): if self.get_state() == DevState.ON: # Already on. Don't complain. @@ -462,7 +460,6 @@ class LOFARDevice(Device): @command() @debugit() @log_exceptions() - @only_in_states(INITIALISED_STATES) @fault_on_error() def On(self): """ @@ -658,7 +655,6 @@ class LOFARDevice(Device): f"Cannot assign default to attribute {attribute}" ) from _e - @only_in_states(INITIALISED_STATES) @command() @debugit() @log_exceptions() @@ -668,7 +664,6 @@ class LOFARDevice(Device): # This is just the command version of _prepare_hardware(). self._power_hardware_on() - @only_in_states(INITIALISED_STATES) @command() @debugit() @log_exceptions() @@ -698,6 +693,7 @@ class LOFARDevice(Device): restart_python() logger.error("Failed to restart Device Server") + @only_in_states([DevState.OFF]) def _boot(self): # setup connections self._Initialise() @@ -708,7 +704,6 @@ class LOFARDevice(Device): # make device available self._On() - @only_in_states([DevState.OFF]) @command() def boot(self): self._boot() @@ -720,6 +715,7 @@ class LOFARDevice(Device): before configuring the hardware.""" pass + @only_in_states(DEFAULT_COMMAND_STATES) def _power_hardware_off(self): """Override this method to disable any hardware related to the device.""" pass