TMC Base Command Class
1. BaseTMCCommand
- class ska_tmc_common.tmc_command.BaseTMCCommand(component_manager: ~ska_tmc_common.tmc_component_manager.BaseTmcComponentManager, logger: <Mock id='139954894400688'>, *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) Optional[Union[DishAdapter, DishLeafAdapter, SubarrayAdapter, CspMasterAdapter, CspSubarrayAdapter, MCCSMasterLeafNodeAdapter, BaseAdapter, SdpSubArrayAdapter]]
Method to create adapters for device. :param device_name: name of the device. :type device_name: str :param adapter_type: Type of Adapter. :type adapter_type: AdapterType :param start_time: start time. :type start_time: float :param timeout: Timeout for adapter creation. :type timeout: int :return: adapter created :raises ConnectionFailed: Exception is raised when connection fails :raises DevFailed: Exception is raised when device fails
- do(argin: Optional[str] = None) NotImplementedError
Base method for do method for different nodes :param argin: command params. :type argin: str :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: Optional[str] = None, timeout_callback: Optional[TimeoutCallback] = None, command_id: Optional[str] = None, lrcr_callback: Optional[LRCRCallback] = 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: Optional[str] = None, timeout_callback: Optional[TimeoutCallback] = None, command_id: Optional[str] = None, lrcr_callback: Optional[LRCRCallback] = 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 – threadingEvent class object that is used to check if the command has been aborted.
- Dtype abort_event:
bool
- 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) 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
External stop method for stopping the timer thread as well as the tracker thread. :param timeout_id: Timeout id :type timeout_id: str
2. TMCCommand
- class ska_tmc_common.tmc_command.TMCCommand(component_manager: ~ska_tmc_common.tmc_component_manager.BaseTmcComponentManager, logger: <Mock id='139954894400688'>, *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: Optional[str] = None)
Base method for do_mid method for different nodes :param argin: Command params :type argin: str :raises NotImplementedError: Not implemented error
- do_low(argin=None)
Base method for do_low method for different nodes :param argin: Command params :type argin: str :raises NotImplementedError: Not implemented error
3. TmcLeafNodeCommand
- class ska_tmc_common.tmc_command.TmcLeafNodeCommand(component_manager: ~ska_tmc_common.tmc_component_manager.BaseTmcComponentManager, logger: <Mock id='139954894400688'>, *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: Optional[str] = None)
Base method for do_mid method for different nodes :param argin: Command params :type argin: str :raises NotImplementedError: Not implemented error
- do_low(argin: Optional[str] = None)
Base method for do_low method for different nodes :param argin: Command params :type argin: str :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
- 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. :param device: Device name :type device: str :param adapter: Adapter to use :type adapter: Adapter :param command_name: Command name :type command_name: str :param argin: Command params :type argin: str :return: ResultCode and message