Commands¶
This module provides abstract base classes for device commands, and a ResultCode enum.
-
class
ska_tango_base.commands.
ResultCode
(value)[source]¶ Python enumerated type for command return codes.
-
OK
= 0¶ The command was executed successfully.
-
STARTED
= 1¶ The command has been accepted and will start immediately.
-
QUEUED
= 2¶ The command has been accepted and will be executed at a future time
-
FAILED
= 3¶ The command could not be executed.
-
UNKNOWN
= 4¶ The status of the command is not known.
-
-
class
ska_tango_base.commands.
BaseCommand
(target, state_model, logger=None)[source]¶ Abstract base class for Tango device server commands. Ensures the command is run, and that if the command errors, the “fatal_error” action will be called on the state model.
Creates a new BaseCommand object for a device.
- Parameters
state_model (SKABaseClassStateModel or a subclass of same) – the state model that this command uses, for example to raise a fatal error if the command errors out.
target (object) – the object that this base command acts upon. For example, the device that this BaseCommand implements the command for.
logger (a logger that implements the standard library logger interface) – the logger to be used by this Command. If not provided, then a default module logger will be used.
-
class
ska_tango_base.commands.
ResponseCommand
(target, state_model, logger=None)[source]¶ Abstract base class for a tango command handler, for commands that execute a procedure/operation and return a (ResultCode, message) tuple.
Creates a new BaseCommand object for a device.
- Parameters
state_model (SKABaseClassStateModel or a subclass of same) – the state model that this command uses, for example to raise a fatal error if the command errors out.
target (object) – the object that this base command acts upon. For example, the device that this BaseCommand implements the command for.
logger (a logger that implements the standard library logger interface) – the logger to be used by this Command. If not provided, then a default module logger will be used.
-
class
ska_tango_base.commands.
ActionCommand
(target, state_model, action_hook, start_action=False, logger=None)[source]¶ Abstract base class for a tango command, which checks a state model to find out whether the command is allowed to be run, and after running, sends an action to that state model, thus driving device state.
Create a new ActionCommand for a device.
- Parameters
target (object) – the object that this base command acts upon. For example, the device that this ActionCommand implements the command for.
action_hook (string) – 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 result in action “scan_succeeded” being sent to the state model.
start_action (boolean) – whether the state model supports a start action (i.e. to put the state model into an transient state while the command is running); default False
logger (a logger that implements the standard library logger interface) – the logger to be used by this Command. If not provided, then a default module logger will be used.
-
check_allowed
()[source]¶ Checks whether the command is allowed to be run in the current state of the state model.
- Returns
True if the command is allowed to be run
- Raises
StateModelError – if the command is not allowed to be run