TMC Base Command Class
1. BaseTMCCommand
- class ska_tmc_common.tmc_command.BaseTMCCommand(component_manager, logger: <Mock id='128448670695584'>, *args, **kwargs)
Base class for managing all TMC commands.
- set_command_id(command_name: str)
Sets the command id for error propagation.
- Parameters:
command_name (str) – name of the command.
- adapter_creation_retry(device_name: str, adapter_type: AdapterType, start_time: float, timeout: int) DishAdapter | DishLeafAdapter | SubarrayAdapter | CspMasterAdapter | CspSubarrayAdapter | MCCSMasterLeafNodeAdapter | BaseAdapter | SdpSubArrayAdapter | None
Method to create adapters for device.
- Parameters:
device_name (str) – name of the device.
adapter_type (AdapterType) – Type of Adapter.
start_time (float) – start time.
timeout (int) – Timeout for adapter creation.
- Returns:
adapter created
- Raises:
ConnectionFailed – Exception is raised when connection fails
DevFailed – Exception is raised when device fails
- do(argin: str | None = None) NotImplementedError
Base method for do method for different nodes
- Parameters:
argin (str) – command params.
- Raises:
NotImplementedError – Not implemented error
- update_task_status(**kwargs) NotImplementedError
Method to update the task status for command.
- Raises:
NotImplementedError – Not implemented error
- start_tracker_thread(state_function: str, expected_state: List[IntEnum], abort_event: Event, timeout_id: str | None = None, timeout_callback: TimeoutCallback | None = None, command_id: str | None = None, lrcr_callback: LRCRCallback | None = None) None
Creates and starts a thread that will keep track of the State/ obsState change to be monitored (For confirming command completion. Currently only supports obsState change.), the timeout callback to monitor the timeout and the longRunningCommandResult callback to keep track of LRCR events.
- Parameters:
state_function (str) – The function to determine the state of the device. Should be accessible in the component_manager.
expected_state – Expected state of the device in case of successful command execution.
abort_event – threading.Event class object that is used to check if the command has been aborted.
timeout_id – Id for TimeoutCallback class object.
timeout_callback – An instance of TimeoutCallback class that acts as a callable functions to call in the event of timeout.
command_id – Id for LRCRCallback class object.
lrcr_callback – An instance of LRCRCallback class that acts as a callable functions to call when longRunningCommandResult event is received.
- track_and_update_command_status(state_function: str, expected_state: List[IntEnum], abort_event: Event, timeout_id: str | None = None, timeout_callback: TimeoutCallback | None = None, command_id: str | None = None, lrcr_callback: LRCRCallback | None = None) None
Keeps track of the obsState change and the timeout callback to determine whether timeout has occurred or the command completed successfully. Logs the result for now.
- Parameters:
state_function (str) – The function to determine the state of the device. Should be accessible in the component_manager.
expected_state – Expected state of the device in case of successful command execution.
abort_event – threading.Event class object that is used to check if the command has been aborted.
timeout_id – Id for TimeoutCallback class object.
timeout_callback – An instance of TimeoutCallback class that acts as a callable function to call in the event of timeout.
command_id – Id for LRCRCallback class object.
lrcr_callback – An instance of LRCRCallback class that acts as a callable function to call when an event from the attribute longRunningCommandResult arrives.
- check_abort_event(abort_event) bool
Checks for abort event and if abort event detected, sets TaskStatus to ABORTED and stops the tracker thread
- Parameters:
abort_event (bool) – threadingEvent class object that is used to check if the command has been aborted.
- Returns:
if command is aborted or not
- Return type:
bool
- check_command_timeout(timeout_id, timeout_callback) bool
Checks for command timeout. On timeout, it sets ResultCode to FAILED and stops the tracker thread.
- Parameters:
timeout_id – Id for TimeoutCallback class object.
timeout_callback – An instance of TimeoutCallback class that acts as a callable function to call in the event of timeout.
- Returns:
boolean value if timeout occurred or not
- check_device_state(state_function: str, state_to_achieve: Any, expected_state: list, command_id: str) bool
Waits for expected state with or without transitional state. On expected state occurrence, it sets ResultCode to OK and stops the tracker thread
- Parameters:
state_function (str) – The function to determine the state of the device. Should be accessible in the component_manager.
state_to_achieve – A particular state to needs to be achieved for command completion.
expected_state – Expected state of the device in case of successful command execution. It’s a list contains transitional obsState if exists for a command.
- Returns:
boolean value if state change occurred or not
- check_command_exception(command_id, lrcr_callback) bool
Checks if command has been failed with an exception. On exception, it sets ResultCode to FAILED and stops the tracker thread.
- Parameters:
command_id – Id for LRCRCallback class object.
lrcr_callback – An instance of LRCRCallback class that acts as a callable function to call when an event from the attribute longRunningCommandResult arrives.
- Returns:
boolean value if exception has occurred or not
- stop_tracker_thread(timeout_id: str | None) None
External stop method for stopping the timer thread as well as the tracker thread.
- Parameters:
timeout_id (str) – Timeout id
2. TMCCommand
- class ska_tmc_common.tmc_command.TMCCommand(component_manager, logger: <Mock id='128448670695584'>, *args, **kwargs)
Class to add device adapters
- init_adapters()
Base method for init_adapters method for different nodes
- Raises:
NotImplementedError – Not implemented error
- init_adapters_mid()
Base method for init_adapters_mid method for different nodes
- Raises:
NotImplementedError – Not implemented error
- init_adapters_low()
Base method for init_adapters_low method for different nodes
- Raises:
NotImplementedError – Not implemented error
- do_mid(argin: str | None = None)
Base method for do_mid method for different nodes
- Parameters:
argin (str) – Command params
- Raises:
NotImplementedError – Not implemented error
- do_low(argin=None)
Base method for do_low method for different nodes
- Parameters:
argin (str) – Command params
- Raises:
NotImplementedError – Not implemented error
3. TmcLeafNodeCommand
- class ska_tmc_common.tmc_command.TmcLeafNodeCommand(component_manager, logger: <Mock id='128448670695584'>, *args, **kwargs)
Class to add adapters for LeafNode devices
- init_adapter()
Base method for init_adapter method for different nodes
- Raises:
NotImplementedError – Not implemented error
- do_mid(argin: str | None = None)
Base method for do_mid method for different nodes
- Parameters:
argin (str) – Command params
- Raises:
NotImplementedError – Not implemented error
- do_low(argin: str | None = None)
Base method for do_low method for different nodes
- Parameters:
argin (str) – Command params
- Raises:
NotImplementedError – Not implemented error
- init_adapter_mid()
Base method for init_adapter_mid method for different nodes
- Raises:
NotImplementedError – Not implemented error
- init_adapter_low()
Base method for init_adapter_low method for different nodes
- Raises:
NotImplementedError – Not implemented error
- invoke_command_lrc_cb(device_name: str, update_event_callback: Callable | None = None) Callable
LRC callback for command result tracking.
- invoke_command_and_track(adapter, command_name: str, command_input=None, update_event_callback: Callable | None = None) Tuple[ska_tango_base.commands.ResultCode, str]
Invoke command using LRC and track execution.
- call_adapter_method(device: str, adapter, command_name: str, argin=None) Tuple[List[ska_tango_base.commands.ResultCode], List[str]]
Method to invoke commands on device adapters.
- Parameters:
device (str) – Device name
adapter (Adapter) – Adapter to use
command_name (str) – Command name
argin (str) – Command params
- Returns:
ResultCode and message
- call_update_task_status(result, message) None
Call update task status and provide result, message attributes.
- Parameters:
result (ResultCode) – Result code.
message (str) – Result message.
- set_abort_flag() None
Set abort flag to stop command completion tracker.
- is_aborted() bool
Check if command is aborted.