SKA BaseDevice¶
This module implements a generic base model and device for SKA. It exposes the generic attributes, properties and commands of an SKA device.
-
class
ska_tango_base.
DeviceStateModel
(logger, op_state_callback=None, admin_mode_callback=None)¶ Implements the state model for the SKABaseDevice.
This implementation contains separate state machines for adminMode and opState. Since the two are slightly but inextricably coupled, the opState machine includes “ADMIN” flavours for the “INIT”, “FAULT” and “DISABLED” states, to represent states where the device has been administratively disabled via the adminModes “RESERVED”, “NOT_FITTED” and “OFFLINE”. This model drives the two state machines to ensure they remain coherent.
-
is_action_allowed
(action)¶ Whether a given action is allowed in the current state.
Parameters: action (str) – an action, as given in the transitions table Raises: StateModelError – if the action is unknown to the state machine Returns: whether the action is allowed in the current state Return type: bool
-
op_state
¶ Returns the op_state of this state model
Returns: op_state of this state model Return type: tango.DevState
-
perform_action
(action)¶ Performs an action on the state model
Parameters: action (ANY) – an action, as given in the transitions table Raises: StateModelError – if the action is not allowed in the current state
-
try_action
(action)¶ Checks whether a given action is allowed in the current state, and raises a StateModelError if it is not.
Parameters: action (str) – an action, as given in the transitions table Raises: StateModelError – if the action is not allowed in the current state Returns: True if the action is allowed Return type: boolean
-
-
class
ska_tango_base.
SKABaseDevice
(*args, **kwargs)¶ A generic base device for SKA.
-
Disable
()¶ Put the device into disabled mode
To modify behaviour for this command, modify the do() method of the command class.
Returns: A tuple containing a return code and a string message indicating status. The message is for information purpose only. Return type: (ResultCode, str)
-
class
DisableCommand
(target, state_model, logger=None)¶ A class for the SKABaseDevice’s Disable() command.
-
do
()¶ Stateless hook for Disable() command functionality.
Returns: A tuple containing a return code and a string message indicating status. The message is for information purpose only. Return type: (ResultCode, str)
-
-
GetVersionInfo
()¶ Returns the version information of the device.
To modify behaviour for this command, modify the do() method of the command class.
Returns: Version details of the device.
-
class
GetVersionInfoCommand
(target, state_model, logger=None)¶ A class for the SKABaseDevice’s Reset() command.
-
do
()¶ Stateless hook for device GetVersionInfo() command.
Returns: A tuple containing a return code and a string message indicating status. The message is for information purpose only. Return type: (ResultCode, str)
-
-
GroupDefinitions
¶ Used by autodoc_mock_imports.
-
class
InitCommand
(target, state_model, logger=None)¶ A class for the SKABaseDevice’s init_device() “command”.
-
do
()¶ Stateless hook for device initialisation.
Returns: A tuple containing a return code and a string message indicating status. The message is for information purpose only. Return type: (ResultCode, str)
-
succeeded
()¶ Callback for the successful completion of the command.
-
-
LoggingLevelDefault
¶ Used by autodoc_mock_imports.
-
LoggingTargetsDefault
¶ Used by autodoc_mock_imports.
-
Off
()¶ Turn the device off
To modify behaviour for this command, modify the do() method of the command class.
Returns: A tuple containing a return code and a string message indicating status. The message is for information purpose only. Return type: (ResultCode, str)
-
class
OffCommand
(target, state_model, logger=None)¶ A class for the SKABaseDevice’s Off() command.
-
do
()¶ Stateless hook for Off() command functionality.
Returns: A tuple containing a return code and a string message indicating status. The message is for information purpose only. Return type: (ResultCode, str)
-
-
On
()¶ Turn device on
To modify behaviour for this command, modify the do() method of the command class.
Returns: A tuple containing a return code and a string message indicating status. The message is for information purpose only. Return type: (ResultCode, str)
-
class
OnCommand
(target, state_model, logger=None)¶ A class for the SKABaseDevice’s On() command.
-
do
()¶ Stateless hook for On() command functionality.
Returns: A tuple containing a return code and a string message indicating status. The message is for information purpose only. Return type: (ResultCode, str)
-
-
Reset
()¶ Reset the device from the FAULT state.
To modify behaviour for this command, modify the do() method of the command class.
Returns: A tuple containing a return code and a string message indicating status. The message is for information purpose only. Return type: (ResultCode, str)
-
class
ResetCommand
(target, state_model, logger=None)¶ A class for the SKABaseDevice’s Reset() command.
-
check_allowed
()¶ 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
-
do
()¶ Stateless hook for device reset.
Returns: A tuple containing a return code and a string message indicating status. The message is for information purpose only. Return type: (ResultCode, str)
-
is_allowed
()¶ Whether this command is allowed to run in the current state of the state model.
Returns: whether this command is allowed to run Return type: boolean
-
succeeded
()¶ Action to take on successful completion of a reset
-
-
SkaLevel
¶ Used by autodoc_mock_imports.
-
Standby
()¶ Put the device into standby mode
To modify behaviour for this command, modify the do() method of the command class.
Returns: A tuple containing a return code and a string message indicating status. The message is for information purpose only. Return type: (ResultCode, str)
-
class
StandbyCommand
(target, state_model, logger=None)¶ A class for the SKABaseDevice’s Standby() command.
-
do
()¶ Stateless hook for Standby() command functionality.
Returns: A tuple containing a return code and a string message indicating status. The message is for information purpose only. Return type: (ResultCode, str)
-
-
adminMode
¶ Used by autodoc_mock_imports.
-
always_executed_hook
()¶ Method that is always executed before any device command gets executed.
-
buildState
¶ Used by autodoc_mock_imports.
-
controlMode
¶ Used by autodoc_mock_imports.
-
delete_device
()¶ Method to cleanup when device is stopped.
-
get_command_object
(command_name)¶ Returns the command object (handler) for a given command.
Parameters: command_name (str) – name of the command for which a command object (handler) is sought Returns: the registered command object (handler) for the command Return type: Command instance
-
healthState
¶ Used by autodoc_mock_imports.
-
init_command_objects
()¶ Creates and registers command objects (handlers) for the commands supported by this device.
-
init_device
()¶ Initializes the tango device after startup.
Subclasses that have no need to override the default default implementation of state management may leave
init_device()
alone. Override thedo()
method on the nested classInitCommand
instead.
-
is_Disable_allowed
()¶ Check if command Disable is allowed in the current device state.
Raises: tango.DevFailed – if the command is not allowed Returns: True
if the command is allowedReturn type: boolean
-
is_Off_allowed
()¶ Check if command Off is allowed in the current device state.
Raises: tango.DevFailed – if the command is not allowed Returns: True
if the command is allowedReturn type: boolean
-
is_On_allowed
()¶ Check if command On is allowed in the current device state.
Raises: tango.DevFailed – if the command is not allowed Returns: True
if the command is allowedReturn type: boolean
-
is_Reset_allowed
()¶ Whether the
Reset()
command is allowed to be run in the current stateReturns: whether the Reset()
command is allowed to be run in the current stateReturn type: boolean
-
is_Standby_allowed
()¶ Check if command Standby is allowed in the current device state.
Raises: tango.DevFailed – if the command is not allowed Returns: True
if the command is allowedReturn type: boolean
-
loggingLevel
¶ Used by autodoc_mock_imports.
-
loggingTargets
¶ Used by autodoc_mock_imports.
-
read_adminMode
()¶ Reads Admin Mode of the device.
Returns: Admin Mode of the device Return type: AdminMode
-
read_buildState
()¶ Reads the Build State of the device.
Returns: the build state of the device
-
read_controlMode
()¶ Reads Control Mode of the device.
Returns: Control Mode of the device
-
read_healthState
()¶ Reads Health State of the device.
Returns: Health State of the device
-
read_loggingLevel
()¶ Reads logging level of the device.
Returns: Logging level of the device.
-
read_loggingTargets
()¶ Reads the additional logging targets of the device.
Note that this excludes the handlers provided by the ska_ser_logging library defaults.
Returns: Logging level of the device.
-
read_simulationMode
()¶ Reads Simulation Mode of the device.
Returns: Simulation Mode of the device.
-
read_testMode
()¶ Reads Test Mode of the device.
Returns: Test Mode of the device
-
read_versionId
()¶ Reads the Version Id of the device.
Returns: the version id of the device
-
register_command_object
(command_name, command_object)¶ Registers a command object as the object to handle invocations of a given command
Parameters: - command_name (str) – name of the command for which the object is being registered
- command_object (Command instance) – the object that will handle invocations of the given command
-
set_state
(state)¶ Helper method for setting device state, ensuring that change events are pushed.
Parameters: state ( tango.DevState
) – the new state
-
set_status
(status)¶ Helper method for setting device status, ensuring that change events are pushed.
Parameters: status (str) – the new status
-
simulationMode
¶ Used by autodoc_mock_imports.
-
testMode
¶ Used by autodoc_mock_imports.
-
versionId
¶ Used by autodoc_mock_imports.
-
write_adminMode
(value)¶ Sets Admin Mode of the device.
Parameters: value ( AdminMode
) – Admin Mode of the device.Raises: ValueError – for unknown adminMode
-
write_controlMode
(value)¶ Sets Control Mode of the device.
Parameters: value – Control mode value
-
write_loggingLevel
(value)¶ Sets logging level for the device. Both the Python logger and the Tango logger are updated.
Parameters: value – Logging level for logger Raises: LoggingLevelError – for invalid value
-
write_loggingTargets
(value)¶ Sets the additional logging targets for the device.
Note that this excludes the handlers provided by the ska_ser_logging library defaults.
Parameters: value – Logging targets for logger
-
write_simulationMode
(value)¶ Sets Simulation Mode of the device
Parameters: value – SimulationMode
-
write_testMode
(value)¶ Sets Test Mode of the device.
Parameters: value – Test Mode
-