diff --git a/docs/source/SKABaseDevice.rst b/docs/source/SKABaseDevice.rst index 9d41032725d5449356f3100f4035213ed5a81c07..49deb8eb9bdb6784bacef665d92e055d32bbf406 100644 --- a/docs/source/SKABaseDevice.rst +++ b/docs/source/SKABaseDevice.rst @@ -10,6 +10,11 @@ SKA BaseDevice :maxdepth: 2 .. automodule:: ska.base.base_device + +.. autoclass:: ska.base.DeviceStateModel + :members: + :undoc-members: + .. autoclass:: ska.base.SKABaseDevice :members: :undoc-members: diff --git a/docs/source/State_Machine.rst b/docs/source/State_Machine.rst index 929d3191c289a8eae7083ee5835e774fa743db59..dfb271032b77820ee02783bdee4655c38498a5c1 100644 --- a/docs/source/State_Machine.rst +++ b/docs/source/State_Machine.rst @@ -151,11 +151,15 @@ observations (currently only subarray devices). API --- -.. toctree:: - :maxdepth: 2 - - .. automodule:: ska.base.state_machine :members: :undoc-members: +.. autoclass:: OperationStateMachine + :members: + +.. autoclass:: AdminModeStateMachine + :members: + +.. autoclass:: ObservationStateMachine + :members: diff --git a/src/ska/base/base_device.py b/src/ska/base/base_device.py index f7a243544d727f8b8205a48bc1f86bb6aba037c6..2d8b824bad2e3141cd279271bcf8a9a8262668d9 100644 --- a/src/ska/base/base_device.py +++ b/src/ska/base/base_device.py @@ -308,7 +308,7 @@ class LoggingUtils: # PROTECTED REGION END # // SKABaseDevice.additionnal_import -__all__ = ["SKABaseDevice", "main"] +__all__ = ["DeviceStateModel", "SKABaseDevice", "main"] class DeviceStateModel: @@ -527,9 +527,9 @@ class DeviceStateModel: combination of admin_mode and op_state (e.g. OFFLINE and ON). :param op_state: the target operational state (optional) - :type op_state: string + :type op_state: :py:class:`tango.DevState` :param admin_mode: the target admin mode (optional) - :type admin_mode: string + :type admin_mode: :py:class:`~ska.base.control_model.AdminMode` """ if admin_mode is None: admin_mode = self._admin_mode_state_machine.state @@ -571,7 +571,7 @@ class SKABaseDevice(Device): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: DeviceStateModel + :type state_model: :py:class:`DeviceStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -804,7 +804,7 @@ class SKABaseDevice(Device): callback :param admin_mode: the new admin_mode value - :type admin_mode: AdminMode + :type admin_mode: :py:class:`~ska.base.control_model.AdminMode` """ self.push_change_event("adminMode", admin_mode) self.push_archive_event("adminMode", admin_mode) @@ -815,7 +815,7 @@ class SKABaseDevice(Device): callback :param state: the new state value - :type state: DevState + :type state: :py:class:`tango.DevState` """ if state != self.get_state(): self.logger.info(f"Device state changed from {self.get_state()} to {state}") @@ -828,7 +828,7 @@ class SKABaseDevice(Device): events are pushed. :param state: the new state - :type state: tango.DevState + :type state: :py:class:`tango.DevState` """ super().set_state(state) self.push_change_event("state") @@ -1057,7 +1057,7 @@ class SKABaseDevice(Device): Sets Admin Mode of the device. :param value: Admin Mode of the device. - :type value: AdminMode + :type value: :py:class:`~ska.base.control_model.AdminMode` :raises ValueError: for unknown adminMode """ @@ -1186,7 +1186,7 @@ class SKABaseDevice(Device): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: DeviceStateModel + :type state_model: :py:class:`DeviceStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -1262,7 +1262,7 @@ class SKABaseDevice(Device): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: DeviceStateModel + :type state_model: :py:class:`DeviceStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -1332,7 +1332,7 @@ class SKABaseDevice(Device): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: DeviceStateModel + :type state_model: :py:class:`DeviceStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -1402,7 +1402,7 @@ class SKABaseDevice(Device): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: DeviceStateModel + :type state_model: :py:class:`DeviceStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -1472,7 +1472,7 @@ class SKABaseDevice(Device): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: DeviceStateModel + :type state_model: :py:class:`DeviceStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library diff --git a/src/ska/base/commands.py b/src/ska/base/commands.py index 87b52b969b7475f64befda87fb3e9e4e53f1b6d2..e326c62c2373171c6b6b1e89b057475694e187c2 100644 --- a/src/ska/base/commands.py +++ b/src/ska/base/commands.py @@ -288,7 +288,7 @@ class ActionCommand(ResponseCommand): :param return_code: The return_code returned by the ``do()`` method - :type return_code: ResultCode + :type return_code: :py:class:`ResultCode` """ if return_code == ResultCode.OK: self.succeeded() diff --git a/src/ska/base/logger_device.py b/src/ska/base/logger_device.py index 72f03d2cf291bd62b2135e94257cbbe432d5a793..39a5704819d31f860c199204d20aeff89d6e9b86 100644 --- a/src/ska/base/logger_device.py +++ b/src/ska/base/logger_device.py @@ -139,7 +139,7 @@ class SKALogger(SKABaseDevice): * argin[0]: list of DevLong. Desired logging level. * argin[1]: list of DevString. Desired tango device. - :type argin: DevVarLongStringArray + :type argin: :py:class:`tango.DevVarLongStringArray` :returns: None. """ diff --git a/src/ska/base/master_device.py b/src/ska/base/master_device.py index bc5038198b293844d4717febb1fbd06811c91be2..a8e0c93a3c01690b7797e71c885628803fa5abd7 100644 --- a/src/ska/base/master_device.py +++ b/src/ska/base/master_device.py @@ -231,7 +231,7 @@ class SKAMaster(SKABaseDevice): * [nrInstances]: DevLong. Number of instances of the capability. * [Capability types]: DevString. Type of capability. - :type argin: DevVarLongStringArray. + :type argin: :py:class:`tango.DevVarLongStringArray`. :return: True if capability can be achieved, False if cannot :rtype: DevBoolean diff --git a/src/ska/base/obs_device.py b/src/ska/base/obs_device.py index 9119cc0aeb2ebc65546f8aa74325809a31db3795..b92b31c23329be84a30f58e85d205cb91953270c 100644 --- a/src/ska/base/obs_device.py +++ b/src/ska/base/obs_device.py @@ -102,7 +102,7 @@ class SKAObsDevice(SKABaseDevice): callback :param obs_state: the new obs_state value - :type obs_state: ObsState + :type admin_mode: :py:class:`~ska.base.control_model.ObsState` """ self._obs_state = obs_state self.push_change_event("obsState", obs_state) diff --git a/src/ska/base/state_machine.py b/src/ska/base/state_machine.py index 4096d8a1a11f3a250f3d9fa86c684af531edfde0..0dc1f325762e29d9da711c10346197263adeb73c 100644 --- a/src/ska/base/state_machine.py +++ b/src/ska/base/state_machine.py @@ -4,6 +4,9 @@ This module contains specifications of SKA state machines. from transitions import Machine, State +__all__ = ["OperationStateMachine", "AdminModeStateMachine", "ObservationStateMachine"] + + class OperationStateMachine(Machine): """ State machine for operational state ("opState"). diff --git a/src/ska/base/subarray_device.py b/src/ska/base/subarray_device.py index 949e5725714031c7cb8fa0d382adf388216e7579..b66b16c045d7e92ef7b3be2e1bc120229b488b3e 100644 --- a/src/ska/base/subarray_device.py +++ b/src/ska/base/subarray_device.py @@ -162,7 +162,7 @@ class SKASubarrayStateModel(DeviceStateModel): :returns: where the action is allowed in the current state: :rtype: bool: True if the action is allowed, False if it is - no allowed + not allowed :raises StateModelError: for an unrecognised action """ obs_allowed = self._is_obs_action_allowed(action) @@ -244,11 +244,11 @@ class SKASubarrayStateModel(DeviceStateModel): OFFLINE, opState STANDBY, and obsState SCANNING). :param op_state: the target operational state (optional) - :type op_state: string + :type op_state: :py:class:`tango.DevState` :param admin_mode: the target admin mode (optional) - :type admin_mode: string + :type admin_mode: :py:class:`~ska.base.control_model.AdminMode` :param obs_state: the target observation state (optional) - :type obs_state: string + :type obs_state: :py:class:`~ska.base.control_model.ObsState` """ if obs_state is not None: getattr(self._observation_state_machine, f"to_{obs_state.name}")() @@ -384,7 +384,7 @@ class SKASubarray(SKAObsDevice): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: SKASubarrayStateModel instance + :type state_model: :py:class:`SKASubarrayStateModel` :param action_hook: a hook for the command, used to build actions that will be sent to the state model; for example, if the hook is "scan", then success of the command will @@ -433,7 +433,7 @@ class SKASubarray(SKAObsDevice): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: SKASubarrayStateModel instance + :type state_model: :py:class:`SKASubarrayStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -476,7 +476,7 @@ class SKASubarray(SKAObsDevice): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: SKASubarrayStateModel instance + :type state_model: :py:class:`SKASubarrayStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -545,7 +545,7 @@ class SKASubarray(SKAObsDevice): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: SKASubarrayStateModel instance + :type state_model: :py:class:`SKASubarrayStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -601,7 +601,7 @@ class SKASubarray(SKAObsDevice): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: SKASubarrayStateModel + :type state_model: :py:class:`SKASubarrayStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -644,7 +644,7 @@ class SKASubarray(SKAObsDevice): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: SKASubarrayStateModel + :type state_model: :py:class:`SKASubarrayStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -681,7 +681,7 @@ class SKASubarray(SKAObsDevice): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: SKASubarrayStateModel + :type state_model: :py:class:`SKASubarrayStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -721,7 +721,7 @@ class SKASubarray(SKAObsDevice): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: SKASubarrayStateModel + :type state_model: :py:class:`SKASubarrayStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -760,7 +760,7 @@ class SKASubarray(SKAObsDevice): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: SKASubarrayStateModel + :type state_model: :py:class:`SKASubarrayStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -807,7 +807,7 @@ class SKASubarray(SKAObsDevice): :param state_model: the state model that this command uses to check that it is allowed to run, and that it drives with actions. - :type state_model: SKASubarrayStateModel + :type state_model: :py:class:`SKASubarrayStateModel` :param logger: the logger to be used by this Command. If not provided, then a default module logger will be used. :type logger: a logger that implements the standard library @@ -886,7 +886,7 @@ class SKASubarray(SKAObsDevice): :param device: the device for which this class implements the configure command - :type device: SKASubarray + :type device: :py:class:`SKASubarray` :param capability_types: a list strings representing capability types. :type capability_types: list diff --git a/tests/conftest.py b/tests/conftest.py index 6693cef8cf850173237b0948f3c2d4c80d607ef2..0c6cc46d34d701d2bbb8b68239c3356b928ad314 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -418,7 +418,7 @@ def tango_change_event_helper(tango_context): Event subscription callback :param event_data: data about the change events - :type event_data: tango.EventData + :type event_data: :py:class:`tango.EventData` """ if event_data.err: error = event_data.errors[0] diff --git a/tests/test_base_device.py b/tests/test_base_device.py index f8d522aa2916022652a9e58d31129b7106c2da14..049b61a60d4d5b69b9d27da1e807db9e6f23e4c4 100644 --- a/tests/test_base_device.py +++ b/tests/test_base_device.py @@ -358,7 +358,7 @@ class TestDeviceStateModel(StateMachineTester): :type machine: state machine object instance :param state: the state that we are asserting to be the current state of the state machine under test - :type state: str + :type state: dict """ assert machine.admin_mode == state["admin_mode"] assert machine.op_state == state["op_state"] @@ -407,7 +407,7 @@ class TestDeviceStateModel(StateMachineTester): :type machine: state machine object instance :param target_state: the state that we want to get the state machine under test into - :type target_state: str + :type target_state: dict """ machine._straight_to_state(**target_state) @@ -543,6 +543,8 @@ class TestSKABaseDevice(object): # Check that we can turn off a device that is already off tango_context.device.Off() + state_callback.assert_not_called() + status_callback.assert_not_called() # PROTECTED REGION ID(SKABaseDevice.test_buildState_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_buildState_decorators @@ -661,6 +663,10 @@ class TestSKABaseDevice(object): assert tango_context.device.adminMode == AdminMode.ONLINE admin_mode_callback.assert_call(AdminMode.ONLINE) + tango_context.device.adminMode = AdminMode.ONLINE + assert tango_context.device.adminMode == AdminMode.ONLINE + admin_mode_callback.assert_not_called() + # PROTECTED REGION END # // SKABaseDevice.test_adminMode # PROTECTED REGION ID(SKABaseDevice.test_controlMode_decorators) ENABLED START #