ska_tmc_subarraynode.commands package
Link to the TMC User documentation is here.
Submodules
subarray_node_command
Path: src/ska_tmc_subarraynode/commands/subarray_node_command.py
SubarrayNode command class for SubarrayNode, a subclass of TMCCommand. This class provides methods to initialize adapters and executing commands on subarray devices.
- class ska_tmc_subarraynode.commands.subarray_node_command.SubarrayNodeCommand(component_manager, adapter_factory=ska_tmc_common.AdapterFactory, logger=<Logger ska_tmc_subarraynode.commands.subarray_node_command (WARNING)>)
Bases:
TMCCommandThis code defines the SubarrayNodeCommand class, which is a subclass of TMCCommand. This class provides methods for initializing adapters and executing commands on subarray devices.
- adapter_error_message_result(dev_name, exception)
Returns ResultCode.FAILED with failure message as a tuple
- Parameters
- Return type
- Returns
A tuple containing the result code and the error message.
- clear_command_in_progress_data()
This is a utility method used to clear command_in_progress.
- do(argin=None)
This method is called to execute the command. It sets the command timestamp and calls either do_mid or do_low based on the input parameter type. It returns the result of the command execution.
- Parameters
argin (str) – The input argument for the command. Defaults to None.
- Return type
- Returns
A tuple containing the result code and a message.
- do_low(argin=None)
Abstract method from TMCCommand is defined here but not utilized by this Class.
- do_mid(argin=None)
Abstract method from TMCCommand is defined here but not utilized by this Class.
- get_adapter_by_device_name(device_name)
The get_adapter_by_device_name method takes a device_name as input and searches for an adapter object in the adapter_factory object’s adapters attribute that matches the input device_name. If a matching adapter object is found, it is returned. If no matching adapter object is found, first adapter is returned.
- Parameters
device_name (str) – The name of the device to search for.
- Return type
BaseAdapter- Returns
An adapter object if a matching device is found, otherwise first adapter object is returned.
- get_dish_adapter_by_device_name(device_name_list)
The get_dish_adapter_by_device_name method takes a list of device_name_list as input and searches for adapter objects in the adapter_factory object’s adapters attribute that match any of the device names in the input list. It returns a list of matching adapter objects.
- init_adapters()
Initializes the adapters for the subarray node command.
- Return type
- Returns
A tuple containing the result code and a message.
- init_adapters_low()
Initializes the low adapters for the subarray node command.
- Return type
- Returns
A tuple containing the result code and a message.
- init_adapters_mid()
Initializes the mid adapters for the subarray node command.
- Return type
- Returns
A tuple containing the result code and a message.
- reject_command(message)
Method to return task status as TaskStatus.REJECTED along with the error message
- Parameters
message (str) – The error message to be logged.
- Return type
- Returns
A tuple containing the task status and the error message.
- set_subarray_obs_state_to_fault_on_command_timeout()
Method to set Subarray Node ObsState to FAULT when timeout occurs on one of the leaf node.
- task_callback_default(**kwargs)
Default method if the taskcallback is not passed
- Parameters
kwargs – keyword arguments such as :-
status (-) – status of the task.
progress (-) – progress of the task.
result (-) – result of the task.
exception (-) – an exception raised from the task.
- Return type
- update_command_in_progress_id(command_name)
The update_command_in_progress_id method updates command_in_progress_id attributes of the component_manager object with the given command_name. It also logs information about the updated command.
- update_event_data_storage(device_name, unique_command_id)
This method populates the command_id in eventdatastorage.
- update_event_data_storage_kvalue(device_name='leaf-node-dish', kvalue_validation_status=False)
This method populates the kvalue_validation_status in eventdatastorage.
assign_resources_command
Path: src/ska_tmc_subarraynode/commands/assign_resources_command.py
AssignResourcesCommand class for SubarrayNode.
- class ska_tmc_subarraynode.commands.assign_resources_command.AssignResources(*args, **kwargs)
Bases:
SubarrayNodeCommandA class for SubarrayNode’s AssignResources() command.
Assigns resources to CSP, SDP via respective subarray leaf nodes. It also sets AssignedResources attribute on SubarrayNode.
- assign_sdp_resources(argin)
This function accepts SDP block from input AssignResources JSON and assigns SDP resources to SDP Subarray through SDP Subarray Leaf Node.
- abstract do(argin=None)
Abstract method to invoke the AssignResources command.
- Parameters
- Return type
- Returns
A tuple containing a return code and a string message indicating execution status of command.
- Raises
NotImplementedError – If not implemented in derived classes.
- invoke_command(method, resources)
This method assign resources command. :type method:
Callable[[dict],Tuple] :param method: method for assigning resources :type method: dict :type resources:dict:param resources: resource configuration :type resources: dict
- load_json(argin)
- This methods helps loading the string configuration into
dictionary.
- update_task_status(**kwargs)
Method to update task status with result code and exception message if any.
- Parameters
kwargs – keyword arguments such as :-
result (-) – Tuple containing ResultCode and unique id
status (-) – Current Task Status
message (-) – Any Failure/Exception message
- Return type
configure_command
Path: src/ska_tmc_subarraynode/commands/configure_command.py
Configure Command class for SubarrayNode.
- class ska_tmc_subarraynode.commands.configure_command.Configure(*args, **kwargs)
Bases:
SubarrayNodeCommandA class for SubarrayNode’s Configure() command.
Configures the resources assigned to the Subarray. The configuration data for SDP, CSP and Dish for mid telescope and MCCS for low telescope is extracted out of the input configuration string and relayed to the respective underlying devices (SDP Subarray Leaf Node, CSP Subarray Leaf Node and Dish Leaf Node for mid telescope and MCCS Leaf Node for low telescope ).
- abstract do(argin=None)
Abstract method to invoke the AssignResources command.
- Parameters
- Return type
- Returns
A tuple containing a return code and a string message indicating execution status of command.
- Raises
NotImplementedError – If not implemented in derived classes.
- property is_wrap_sector_key_present
Returns True if the wrap sector key present in the configure.
- Returns
True if wrap sector key present
- Return type
- load_json(argin)
- This methods helps loading the string configuration into
dictionary.
- property receive_addresses
Dynamically retrieves the receive addresses with a retry mechanism.
This property tries up to self.retry_attempts times to:
Retrieve the device name via component_manager.
Get the adapter using get_adapter_by_device_name(dev_name).
Parse its receive_addresses JSON.
- set_scan_duration(scan_duration)
Method to set the scan duration in component manager
- update_task_status(**kwargs)
Method to update task status with result code and exception message if any.
- Parameters
kwargs – keyword arguments such as :-
result (-) – Tuple containing ResultCode and unique id
status (-) – Current Task Status
message (-) – Any Failure/Exception message
- Return type
end_command
Path: src/ska_tmc_subarraynode/commands/end_command.py
A class for TMC SubarrayNode’s End() command (Abstract Base Class)
- class ska_tmc_subarraynode.commands.end_command.End(*args, **kwargs)
Bases:
SubarrayNodeCommandA class for SubarrayNode’s End() command. This command on Subarray Node invokes End command on CSP Subarray Leaf Node and SDP Subarray Leaf Node, MCCS LeafNodes for Low and stops tracking of all the assigned dishes on Mid.
- abstract do(argin=None)
Abstract method to invoke End command.
- Parameters
argin – Optional argument
- Return type
- Returns
A tuple containing a return code and a string message indicating execution status of command.
- Raises
NotImplementedError – If not implemented in derived classes.
- end_csp()
End command on CSP Subarray Leaf Node
- Return type
- Returns
A tuple containing ResultCode and message.
- end_sdp()
End command on SDP Subarray Leaf Node
- Return type
- Returns
A tuple containing ResultCode and message.
- reset_scan_duration()
Helper method to reset the scan duration and handle errors.
- Return type
- Returns
A tuple containing ResultCode and message.
- update_task_status(**kwargs)
Method to update task status with result code and exception message if any.
- Parameters
kwargs – Keyword arguments such as :-
result (-) – Tuple containing ResultCode and unique id
status (-) – Current Task Status
message (-) – Any Failure/Exception message
- Return type
end_scan_command
Path: src/ska_tmc_subarraynode/commands/end_scan_command.py
A class for TMC SubarrayNode’s EndScan() command (Abstract Base Class).
- class ska_tmc_subarraynode.commands.end_scan_command.EndScan(*args, **kwargs)
Bases:
SubarrayNodeCommandA class for SubarrayNode’s EndScan() command.
Ends the scan. It is invoked on subarray after completion of the scan duration. It can also be invoked by an external client while a scan is in progress, Which stops the scan immediately irrespective of the provided scan duration.
- abstract do(argin=None)
Abstract method to invoke EndScan command.
- Parameters
- Return type
- Returns
Tuple of ResultCode and message
- Raises
NotImplementedError – If not implemented in derived classes.
- endscan_csp()
Method to invoke EndScan command on CSP Subarray Leaf Node.
- Return type
- Returns
(ResultCode, message)
- endscan_sdp()
Method to invoke EndScan command on SDP Subarray Leaf Node.
- Return type
- Returns
(ResultCode, message)
- update_task_status(**kwargs)
Method to update task status with result code and exception message if any.
- Parameters
kwargs – Keyword arguments such as :-
result (-) – Tuple containing ResultCode and unique id
status (-) – Current Task Status
message (-) – Any Failure/Exception message
- Return type
release_all_resources_command
Path: src/ska_tmc_subarraynode/commands/release_all_resources_command.py
ReleaseAllResources Command for SubarrayNode
- class ska_tmc_subarraynode.commands.release_all_resources_command.ReleaseAllResources(*args, **kwargs)
Bases:
SubarrayNodeCommandA class for TMC SubarrayNode’s ReleaseAllResources() command.
It checks whether all resources are already released. If yes then it returns code FAILED. If not it Releases all the resources from the subarray i.e. Releases resources from TMC Subarray Node, CSP Subarray and SDP Subarray. Upon successful execution, all the resources of a given subarray get released and empty array is returned. Selective release is not yet supported.
- abstract clean_up_resources()
Clears the assignedResources attribute.
Cleans dictionaries of the resources across the subarraynode.
Note
Currently there are only receptors allocated so only the receptor ids details are stored.
- Return type
- Returns
Tuple of Resultcode and message
- abstract do(argin=None)
Method to invoke ReleaseAllResources command.
- Parameters
argin – Optional argument
- Return type
- Returns
A tuple containing a return code and “” as a string on successful release all resources.
- Raises
NotImplementedError if not implemented in derived classes –
- release_csp_resources()
This function invokes releaseAllResources command on CSP Subarray via CSP Subarray Leaf Node.
- Return type
- Returns
Tuple of Resultcode and message
- release_sdp_resources()
This function invokes releaseAllResources command on SDP Subarray via SDP Subarray Leaf Node.
- Return type
- Returns
Tuple of Resultcode and message
- update_task_status(**kwargs)
Method to update task status with result code and exception message if any.
- Parameters
kwargs – Keyword arguments such as :-
result (-) – Tuple containing ResultCode and unique id
status (-) – Current Task Status
message (-) – Any Failure/Exception message
- Return type
restart_command
Path: src/ska_tmc_subarraynode/commands/restart_command.py
Restart Command for SubarrayNode.
- class ska_tmc_subarraynode.commands.restart_command.Restart(*args, **kwargs)
Bases:
SubarrayNodeCommandA class representing the Restart command for SubarrayNode.
This command restarts various leaf nodes of the Subarray, including CSP Subarray Leaf Node, SDP Subarray Leaf Node, and Mccs Subarray Leaf Node in Low and Dish Leaf Nodes in Mid, to reset ongoing activities and configurations.
- Parameters
component_manager – The component manager instance.
obs_state_model – The observational state model of the Subarray.
adapter_factory – An optional adapter factory instance.
logger – An optional logger instance for logging. Default is None.
- clean_up_configuration()
Cleans up the configuration and resources of the Subarray.
- Return type
- Returns
A tuple containing the result code and an empty string.
- abstract do(argin=None)
Invokes the Restart command on subarray leaf nodes.
- Parameters
- Return type
- Returns
A tuple containing the result code and a message indicating the execution status.
- Raises
NotImplementedError if not implemented in derived classes –
- restart_csp()
Send Restart command to CSP devices
- Return type
- Returns
A tuple containing ResultCode and message
- restart_sdp()
Send Restart command to SDP devices
- Return type
- Returns
A tuple containing ResultCode and message
- update_task_status(**kwargs)
Method to update task status with result code and exception message if any.
- Parameters
kwargs – Keyword Arguments such as :-
result (-) – Tuple containing ResultCode and unique id
status (-) – Current Task Status
message (-) – Any Failure/Exception message
- Return type
scan_command
Path: src/ska_tmc_subarraynode/commands/scan_command.py
A class for TMC SubarrayNode’s Scan() command (Abstract Base Class)
- class ska_tmc_subarraynode.commands.scan_command.Scan(*args, **kwargs)
Bases:
SubarrayNodeCommandA class for SubarrayNode’s Scan() command. The command accepts Scan id as an input and executes a scan on the subarray. Scan command is invoked on respective CSP and SDP subarray node for the provided interval of time. It checks whether the scan is already in progress. If yes it throws error showing duplication of command.
- abstract do(argin)
Abstract method to invoke Scan command.
- Parameters
argin (str) – JSON string containing id.
- Return type
- Returns
A tuple containing a return code and a string message indicating status. The message is for information purpose only.
- Raises
NotImplementedError – If not implemented in derived classes.
- parse_json_input(argin)
Helper method to parse JSON input string and handle errors.
- Parameters
argin (str) – JSON string to parse
- Return type
- Returns
Tuple of ResultCode and either the parsed JSON dictionary or an error message
- abstract scan_csp(argin)
Abstract method to invoke Scan command on CSP Subarray Leaf Node.
- Parameters
argin (str) – Additional argument
- Return type
- Returns
(ResultCode, message)
- Raises
NotImplementedError – If not implemented in derived classes.
- scan_sdp(argin)
Method to invoke Scan command on SDP Subarray Leaf Node.
- Parameters
argin (str) – json input
- Return type
- Returns
(ResultCode, message)
- start_scan_timer(scan_duration)
Method for starting scan timer
- update_task_status(**kwargs)
Method to update task status with result code and exception message if any.
- Parameters
kwargs – Keyword arguments such as :-
result (-) – Tuple containing ResultCode and unique id
status (-) – Current Task Status
message (-) – Any Failure/Exception message
- Return type
off_command
Path: src/ska_tmc_subarraynode/commands/off_command.py
Off Command for SubarrayNode
- class ska_tmc_subarraynode.commands.off_command.Off(*args, **kwargs)
Bases:
SubarrayNodeCommandA class for SubarrayNode’s Off() command.
- abstract do(argin=None)
Invokes the Off command on subarray leaf nodes.
- Parameters
- Return type
- Returns
A tuple containing the result code and a message indicating the execution status.
- Raises
NotImplementedError if not implemented in derived classes –
- get_csp_subarray_obstate()
Return obstate of csp subarray obstate
- Return type
ObsState- Returns
ObsState of the csp subarray
- get_sdp_subarray_obstate()
Return obstate of sdp subarray obstate
- Return type
ObsState- Returns
ObsState of the sdp subarray
- get_subarray_obstate(dev_name)
Return obstate of subarray device
- Parameters
dev_name (str) – Name of the subarray device
- Return type
ObsState- Returns
ObsState of the subarray
- invoke_sdp_off()
Invokes the Off command on the SDP Subarray Leaf Node.
- Return type
- Returns
A tuple containing a return code and a string message indicating execution status of command.
- subarray_off(logger, task_callback, task_abort_event=None)
This is a long running method for Off command, it executes do hook, invokes Off command on SdpSubarrayleafnode.
on_command
Path: src/ska_tmc_subarraynode/commands/on_command.py
On Command for SubarrayNode
- class ska_tmc_subarraynode.commands.on_command.On(*args, **kwargs)
Bases:
SubarrayNodeCommandA class for the SubarrayNode’s On() command.
- abstract do(argin=None)
Method to invoke On command on subarray leaf nodes.
- Parameters
argin – Input json for Command, defaults to None
- Return type
- Returns
A tuple containing a return code and a string message indicating execution status of command.
- Raises
NotImplementedError if not implemented in derived classes –
- invoke_sdp_on()
Method to invoke On command on SdpSubarrayLeafNode.
- Parameters
None –
- Return type
- Returns
A tuple containing a return code and a string message indicating execution status of command.
- Raises
Exception if the command execution is not successful –
- on_leaf_nodes(logger, task_callback, task_abort_event=None)
This is a long running method for On command, it executes do hook, invokes On command on CspSubarrayleafnode and SdpSubarrayleafnode.
set_admin_mode_command
Path: src/ska_tmc_subarraynode/commands/set_admin_mode_command.py
Class for setting the adminMode of lower level devices
- class ska_tmc_subarraynode.commands.set_admin_mode_command.SetAdminMode(*args, **kwargs)
Bases:
SubarrayNodeCommandA class for SubarrayNode’s SetAdminMode command.
- do_low(argin)
Method to invoke SetAdminMode command on the Subarray Leaf Nodes.
- Parameters
argin (str) – Input JSON for the command, containing the admin mode to be set.
- Return type
- Returns
A tuple containing a return code and a string message indicating the execution status of the command.
- invoke_setadminmode(argin, task_callback, task_abort_event=None)
This is a long-running method for the SetAdminMode command. It executes the do hook and invokes SetAdminMode on Subarray Leaf Nodes.
- set_admin_mode_csp(admin_mode)
SetAdminMode command on CSP Subarray Leaf Node.
- Parameters
admin_mode (int) – The admin mode to be set.
- Return type
- Returns
A tuple containing the result code and a message.
- set_admin_mode_mccs(admin_mode)
SetAdminMode command on MCCS Subarray Leaf Node.
- Parameters
admin_mode (int) – The admin mode to be set.
- Return type
- Returns
A tuple containing the result code and a message.
abort_command
Path: src/ska_tmc_subarraynode/commands/abort_command.py
Abstract base class for TMC SubarrayNode’s Abort() command.
- class ska_tmc_subarraynode.commands.abort_command.Abort(*args, **kwargs)
Bases:
SubarrayNodeCommandA class for SubarrayNode Abort() command. It aborts the ongoing operation on subarray node.
- abort_csp()
Send abort command to CSP devices
- Return type
- Returns
A tuple containing ResultCode and message
- abort_sdp()
Send abort command to SDP devices
- Return type
- Returns
A tuple containing ResultCode and message
- abstract do(argin=None)
Abstract method to invoke the Abort command.
- Parameters
- Return type
- Returns
A tuple containing a return code and a string message indicating execution status of command.
- Raises
NotImplementedError – If not implemented
in derived classes. –
- update_task_status(**kwargs)
Method to update task status with result code and exception message if any.
- Parameters
kwargs – Keyword arguments such as :-
result (-) – Tuple containing ResultCode and unique id
status (-) – Current Task Status
message (-) – Any Failure/Exception message
- Return type
build_up_data
Path: src/ska_tmc_subarraynode/commands/build_up_data.py
Class to generate schema.
- class ska_tmc_subarraynode.commands.build_up_data.ElementDeviceData(scan_config, component_manager)
Bases:
objectA class representing data for an element device.
- build_up_csp_cmd_data(receive_addresses_map)
Builds the input data for CSP configuration.
- Parameters
receive_addresses_map (str) – Map of receive addresses
- Return type
- Returns
Returns Resultcode and message
- build_up_sdp_cmd_data()
Method to build up sdp command data
- Return type
- Returns
Returns ResultCode and sdp configuration schema
- class ska_tmc_subarraynode.commands.build_up_data.ElementDeviceDataLow(scan_config, component_manager)
Bases:
ElementDeviceDataA class representing data for an Low element device.
- class ska_tmc_subarraynode.commands.build_up_data.ElementDeviceDataMid(scan_config, component_manager)
Bases:
ElementDeviceDataA class representing data for an Mid element device.
- build_up_csp_cmd_data(receive_addresses_map)
Builds the input data for CSP configuration.
- Parameters
receive_addresses_map (str) – Map of receive addresses
- Return type
- Returns
Result code and CSP configuration schema
- build_up_dish_cmd_data()
Method to build up dish command data
- Return type
- Returns
Result code and dish configuration schema