ska_tmc_subarraynode.commands package

Link to the TMC User documentation is here.

See the TMC Commands Workflow section for details about TMC command workflows.

Subpackages

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)>, is_clear_command_failure_info=True)

Bases: TMCCommand

This code defines the SubarrayNodeCommand class, which is a subclass of TMCCommand. This class provides methods for initializing adapters and executing commands on subarray devices.

abort_dishes(tmc_leaf_dish_adapters)

Invokes Abort command on Dish Leaf Node Group

Return type

Tuple[ResultCode, str]

Returns

A tuple containing ResultCode and message

adapter_error_message_result(dev_name, exception)

Returns ResultCode.FAILED with failure message as a tuple

Parameters
  • dev_name (str) – The name of the device for which the adapter creation failed.

  • exception (Exception) – The exception raised during adapter creation.

Return type

Tuple[ResultCode, str]

Returns

A tuple containing the result code and the error message.

call_update_task_status(result, message)

Call update task status and provide result, message attribute

Parameters
  • result (ResultCode) – Result code

  • message (str) – command success/error message

Return type

None

Returns

None

clear_cm_command_failure_info(is_clear_command_failure_info)

Utility method to clear command failure info in component manager.

clear_command_in_progress_data()

This is a utility method used to clear command_in_progress.

clear_device_events()

Clears the device events dictionary

Return type

None

clear_resources()

Method for clearing resources in case of failure

Return type

None

do(argin='')

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

Tuple[ResultCode, str]

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.

Parameters

argin (Optional[Any]) – Accepts argument if required. Defaults to None.

Return type

Tuple[ResultCode, str]

Returns

A tuple containing the result code and a message.

do_mid(argin=None)

Abstract method from TMCCommand is defined here but not utilized by this Class.

Parameters

argin (Optional[Any]) – Accepts argument if required. Defaults to None.

Return type

Tuple[ResultCode, str]

Returns

A tuple containing the result code and a message.

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.

Parameters

device_name_list (list) – A list of device names to search for.

Return type

List

Returns

A list of adapter objects that match the device names in the input list. If no matching adapter object is found, an empty list is returned.

init_adapters()

Initializes the adapters for the subarray node command.

Return type

Tuple[ResultCode, str]

Returns

A tuple containing the result code and a message.

init_adapters_low()

Initializes the low adapters for the subarray node command.

Return type

Tuple[ResultCode, str]

Returns

A tuple containing the result code and a message.

init_adapters_mid()

Initializes the mid adapters for the subarray node command.

Return type

Tuple[ResultCode, str]

Returns

A tuple containing the result code and a message.

invoke_command_and_add_tracking_data(adapter, command_name, command_input=None)

Update command tracking data

invoke_command_lrc_cb(device_name)

Invoke LRC callback. Provide this callback whenever command is invoked using invoke_lrc api

Parameters

device_name (str) – Name Of Device

Returns

function object to provided to invoke_lrc

Return type

callback

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

Tuple[TaskStatus, str]

Returns

A tuple containing the task status and the error message.

set_abort_flag()

This set abort flag to stop command completion tracker

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.

set_subarrays_to_be_configured(subarrays)

This method updates the subarrays_to_config in component manager.

Parameters

subarrays (list) – list of the subsystem names

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

None

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.

Parameters

command_name (str) – The name of the command being updated.

Return type

None

update_event_data_storage(device_name, unique_command_id)

This method populates the command_id in eventdatastorage.

Parameters
  • device_name (str) – device name

  • unique_command_id (str) – command id

Return type

None

update_event_data_storage_kvalue(device_name='leaf-node-dish', kvalue_validation_status=False)

This method populates the kvalue_validation_status in eventdatastorage.

Parameters
  • device_name (str) – device name

  • kvalue_validation_status (bool) – status of kvalue_validation

Return type

None

update_task_status(**kwargs)

Abstract method from TMCCommand is defined here but not utilized by this Class.

Parameters

kwargs – keyword arguments

Return type

None

wait_for_command_completion(desired_obs_state, device_length, check_abort=True)

This Method wait for desired obs state

wait_for_obs_states(desired_obsstate, failure_obsstate, command_result_data)

Waits for devices to reach final or previous observation state based on the command results. If command result is failed it would wait for previous observation state else it will wait for final observation state.

Example: * AssignResources:

  • ResultCode.OK -> ObsState.IDLE

  • ResultCode.FAILED -> ObsState.EMPTY

  • Configure:

    • ResultCode.OK -> ObsState.READY

    • ResultCode.FAILED -> ObsState.IDLE

Parameters
  • desired_obsstate (ObsState) – Observation state in case of success.

  • failure_obsstate (ObsState) – Observation state in case of failure.

  • command_result_data (dict) – Data of command results for each subsystem.

assign_resources_command

Path: src/ska_tmc_subarraynode/commands/assign_resources_command.py

Abstract base class for AssignResources Command for SubarrayNode.

class ska_tmc_subarraynode.commands.assign_resources_command.AssignResources(component_manager, obs_state_model, logger, adapter_factory=ska_tmc_common.AdapterFactory, is_auto_recovery_enabled=False)

Bases: SubarrayNodeCommand

A 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.

Parameters

argin (dict) – JSON string containing only SDP resources.

Return type

Tuple[ResultCode, str]

Returns

A tuple containing a return code and a string message.

abstract do(argin='')

Abstract method to invoke the AssignResources command.

Parameters

argin (str) – Optional argument

Return type

Tuple[ResultCode, str]

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_assign_resources(argin, task_callback, task_abort_event)

This is a long running method for AssignResources command, it executes do hook, invoking AssignResources command.

Parameters

argin (str) – Input argument for the command

Return type

Tuple[ResultCode, str]

Returns

Result code and message

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.

Parameters

argin (str) – configure json in string format

Raises

Exception – Raises exception if json is not valid.

Returns

configuration json in dictionary data structure.

Return type

dict

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

None

configure_command

Path: src/ska_tmc_subarraynode/commands/configure_command.py

Abstract base class for Configure Command for SubarrayNode.

class ska_tmc_subarraynode.commands.configure_command.Configure(*args, **kwargs)

Bases: SubarrayNodeCommand

A 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='')

Abstract method to invoke the AssignResources command.

Parameters

argin (str) – Optional argument

Return type

Tuple[ResultCode, str]

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_configure(argin, task_callback, task_abort_event)

This is a long running method for Configure command, it executes do hook, invoking Configure command.

Parameters

argin (str) – Input argument for the command

Return type

Tuple[ResultCode, str]

Returns

A tuple containing a return code and a string message.

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

bool

load_json(argin)
This methods helps loading the string configuration into

dictionary.

Parameters

argin (str) – configure json in string format

Raises

Exception – Raises exception if json is not valid.

Returns

configuration json in dictionary data structure.

Return type

dict

property receive_addresses

Dynamically retrieves the receive addresses with a retry mechanism.

This property tries up to self.retry_attempts times to:

  1. Retrieve the device name via component_manager.

  2. Get the adapter using get_adapter_by_device_name(dev_name).

  3. Parse its receive_addresses JSON.

Returns

The parsed receive addresses if successful, otherwise None.

Return type

dict | list | None

set_scan_duration(scan_duration)

Method to set the scan duration in component manager

Parameters

scan_duration (int) – scan duration in seconds.

Raises

Exception – Raises exception if the scan duration is not set 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

None

end_command

Path: src/ska_tmc_subarraynode/commands/end_command.py

Abstract base class for End Command for SubarrayNode.

class ska_tmc_subarraynode.commands.end_command.End(component_manager, obs_state_model, adapter_factory=ska_tmc_common.adapters.AdapterFactory, logger=None, is_clear_command_failure_info=True)

Bases: SubarrayNodeCommand

A 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='')

Abstract method to invoke End command.

Parameters

argin (str) – Optional argument

Return type

Tuple[ResultCode, str]

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

Tuple[ResultCode, str]

Returns

A tuple containing ResultCode and message.

end_sdp()

End command on SDP Subarray Leaf Node

Return type

Tuple[ResultCode, str]

Returns

A tuple containing ResultCode and message.

invoke_end(task_callback, task_abort_event)

This is a long running method for End command, it executes do hook, invokes End Command SdpSubarrayleafnode.

Return type

Tuple[ResultCode, str]

Returns

A tuple of ResultCode and message.

reset_scan_duration()

Helper method to reset the scan duration and handle errors.

Return type

Tuple[ResultCode, str]

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

None

end_scan_command

Path: src/ska_tmc_subarraynode/commands/end_scan_command.py

Abstract base class for EndScan Command for SubarrayNode.

class ska_tmc_subarraynode.commands.end_scan_command.EndScan(*args, **kwargs)

Bases: SubarrayNodeCommand

A 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='')

Abstract method to invoke EndScan command.

Parameters

argin (str) – Optional argument

Return type

Tuple[ResultCode, str]

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

Tuple[ResultCode, str]

Returns

(ResultCode, message)

endscan_sdp()

Method to invoke EndScan command on SDP Subarray Leaf Node.

Return type

Tuple[ResultCode, str]

Returns

(ResultCode, message)

invoke_end_scan(task_callback, task_abort_event)

This is a long running method for Scan command, it executes do hook, invokes EndScan command on CspSubarrayleafnode and SdpSubarrayleafnode.

Parameters
  • logger (logging.Logger) – logger

  • task_abort_event (Event, optional) – Check for abort, defaults to None

Return type

Tuple[ResultCode, str]

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

None

release_all_resources_command

Path: src/ska_tmc_subarraynode/commands/release_all_resources_command.py

Abstract base class for ReleaseAllResources Command for SubarrayNode.

class ska_tmc_subarraynode.commands.release_all_resources_command.ReleaseAllResources(component_manager, obs_state_model, logger, adapter_factory=ska_tmc_common.AdapterFactory, is_auto_recovery_enabled=False, is_clear_command_failure_info=True)

Bases: SubarrayNodeCommand

A 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

Tuple[ResultCode, str]

Returns

Tuple of Resultcode and message

abstract do(argin=None)

Method to invoke ReleaseAllResources command.

Parameters

argin – Optional argument

Return type

Tuple[ResultCode, str]

Returns

A tuple containing a return code and “” as a string on successful release all resources.

Raises

NotImplementedError if not implemented in derived classes

invoke_release_resources(task_callback, task_abort_event)

This is a long running method for ReleaseAllResources command, it executes do hook, invoking ReleaseAllResources command.

Return type

Tuple[ResultCode, str]

Returns

Result code and message

release_csp_resources()

This function invokes releaseAllResources command on CSP Subarray via CSP Subarray Leaf Node.

Return type

Tuple[ResultCode, str]

Returns

Tuple of Resultcode and message

release_sdp_resources()

This function invokes releaseAllResources command on SDP Subarray via SDP Subarray Leaf Node.

Return type

Tuple[ResultCode, str]

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

None

restart_command

Path: src/ska_tmc_subarraynode/commands/restart_command.py

Abstract base class for Restart Command for SubarrayNode.

class ska_tmc_subarraynode.commands.restart_command.Restart(*args, **kwargs)

Bases: SubarrayNodeCommand

A 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

Tuple[ResultCode, str]

Returns

A tuple containing the result code and an empty string.

abstract do(argin='')

Invokes the Restart command on subarray leaf nodes.

Parameters

argin (str) – Optional argument. Default is None.

Return type

Tuple[ResultCode, str]

Returns

A tuple containing the result code and a message indicating the execution status.

Raises

NotImplementedError if not implemented in derived classes

invoke_restart(task_callback, task_abort_event)

Invokes the Restart command on various leaf nodes of the Subarray.

Parameters
  • logger (logging.Logger) – The logger instance for logging.

  • task_callback (TaskCallbackType, optional) – An optional callback function for task status updates. Default is None.

  • task_abort_event (threading.Event, optional) – An optional threading event for checking task abort status. Default is None.

Return type

Tuple[ResultCode, str]

Returns

Tuple of ResultCode and message

restart_csp()

Send Restart command to CSP devices

Return type

Tuple[ResultCode, str]

Returns

A tuple containing ResultCode and message

restart_sdp()

Send Restart command to SDP devices

Return type

Tuple[ResultCode, str]

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

None

scan_command

Path: src/ska_tmc_subarraynode/commands/scan_command.py

Abstract base class for Scan Command for SubarrayNode.

class ska_tmc_subarraynode.commands.scan_command.Scan(*args, **kwargs)

Bases: SubarrayNodeCommand

A 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

Tuple[ResultCode, str]

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.

inject_field_start_time(argin, offset)

Function to inject start_time in JSON if not present already

Parameters
  • argin (dict) – De-serialised input JSON

  • offset – Offset value to be added in start_time (unit seconds)

Returns: De-serialised modified JSON with additional keys if required

invoke_scan(argin, task_callback, task_abort_event)

This is a long running method for Scan command, it executes do hook, invokes Scan command on CspSubarrayleafnode and SdpSubarrayleafnode.

Parameters
  • argin (str) – JSON string consisting of the resources to be Scan

  • task_abort_event (Event) – Check for abort, defaults to None

Return type

Tuple[ResultCode, str]

Returns

Tuple of ResultCode and message

parse_json_input(argin)

Helper method to parse JSON input string and handle errors.

Parameters

argin (str) – JSON string to parse

Return type

Tuple[ResultCode, dict]

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

Tuple[ResultCode, str]

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

Tuple[ResultCode, str]

Returns

(ResultCode, message)

start_scan_timer(scan_duration)

Method for starting scan timer

Parameters

scan_duration (int) – scan duration in second

Return type

None

submit_endscan_command()

Will submit the end scan

Return type

None

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

None

off_command

Path: src/ska_tmc_subarraynode/commands/off_command.py

Abstract base class for Off Command for SubarrayNode.

class ska_tmc_subarraynode.commands.off_command.Off(*args, **kwargs)

Bases: SubarrayNodeCommand

A class for SubarrayNode’s Off() command.

abstract do(argin='')

Invokes the Off command on subarray leaf nodes.

Parameters

argin (str) – Optional argument. Default is None.

Return type

Tuple[ResultCode, str]

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

Tuple[ResultCode, str]

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.

Parameters
  • logger (Logger) – logger

  • task_callback (TaskCallbackType) – Update task state, defaults to None

  • task_abort_event (Optional[Event]) – Check for abort, defaults to None

Return type

Tuple[ResultCode, str]

update_task_status()

Method for implementing for updating task status

Return type

None

on_command

Path: src/ska_tmc_subarraynode/commands/on_command.py

Abstract base class for Off Command for SubarrayNode.

class ska_tmc_subarraynode.commands.on_command.On(*args, **kwargs)

Bases: SubarrayNodeCommand

A class for the SubarrayNode’s On() command.

abstract do(argin='')

Method to invoke On command on subarray leaf nodes.

Parameters

argin (str) – Input json for Command, defaults to None

Return type

Tuple[ResultCode, str]

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

Tuple[ResultCode, str]

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.

Parameters
  • logger (Logger) – logger

  • task_callback (TaskCallbackType) – Update task state, defaults to None

  • task_abort_event (Optional[Event]) – Check for abort, defaults to None

Return type

Tuple[ResultCode, str]

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: SubarrayNodeCommand

A 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

Tuple[ResultCode, str]

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.

Parameters
  • argin (str) – Internal argument

  • task_callback (TaskCallbackType) – An optional callback function for task status updates. Default is None.

  • task_abort_event (Optional[Event]) – An optional threading event for checking task abort status. Default is None.

Return type

None

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

Tuple[ResultCode, str]

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

Tuple[ResultCode, str]

Returns

A tuple containing the result code and a message.

set_admin_mode_sdp(admin_mode)

SetAdminMode command on SDP Subarray Leaf Node.

Parameters

admin_mode (int) – The admin mode to be set.

Return type

Tuple[ResultCode, str]

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 Abort Command for SubarrayNode.

class ska_tmc_subarraynode.commands.abort_command.Abort(*args, **kwargs)

Bases: SubarrayNodeCommand

A class for SubarrayNode Abort() command. It aborts the ongoing operation on subarray node.

abort_csp()

Send abort command to CSP devices

Return type

Tuple[ResultCode, str]

Returns

A tuple containing ResultCode and message

abort_sdp()

Send abort command to SDP devices

Return type

Tuple[ResultCode, str]

Returns

A tuple containing ResultCode and message

abstract do(argin='')

Abstract method to invoke the Abort command.

Parameters

argin (str) – Optional argument

Return type

Tuple[ResultCode, str]

Returns

A tuple containing a return code and a string message indicating execution status of command.

Raises
invoke_abort(task_callback=<function SubarrayNodeCommand.task_callback_default>, task_abort_event=None)

This is a long running method for Abort command, it executes do hook, invoking Abort command.

Parameters
  • task_callback (TaskCallbackType) – Task Callback

  • task_abort_event (Optional[Event]) – Task Abort event

Return type

Tuple[ResultCode, str]

Returns

A tuple containing Result code and message

set_subarray_obsstate_fault()

This method sets subarray obsstate to fault.

Return type

None

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

None

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: object

A 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

Tuple[ResultCode, str]

Returns

Returns Resultcode and message

build_up_sdp_cmd_data()

Method to build up sdp command data

Return type

Tuple[ResultCode, str]

Returns

Returns ResultCode and sdp configuration schema

class ska_tmc_subarraynode.commands.build_up_data.ElementDeviceDataLow(scan_config, component_manager)

Bases: ElementDeviceData

A class representing data for an Low element device.

build_csp_layout_data()

Build antenna layout data for CSP for the given observation.

This method constructs a subset of the array layout data containing interface, telescope, and receptor information required by CSP. It gathers receptor (station) data from the downloaded layout based on the station IDs retrieved from the configuration.

Returns

A dictionary containing the CSP layout data with keys below.
  • ”interface” (dict): Interface details from the layout data.

  • ”telescope” (dict): Telescope metadata from the layout data.

  • ”receptors” (list): List of receptor dictionaries.

Return type

dict

Raises

ValueError – If no station IDs are found in the configuration JSON.

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

Tuple[ResultCode, str]

Returns

Result code and CSP configuration schema

get_pss_data()

Retrieve the PSS beams data from the CSP scan configuration.

Returns

(ResultCode, list, message) - On success: (ResultCode.OK, pss_beams, “”) - On failure: (ResultCode.FAILED, [], error_message)

Return type

tuple

get_pst_data()

Retrieve the PST beams data from the CSP scan configuration.

Returns

(ResultCode, list, message) - On success: (ResultCode.OK, pst_beams, “”) - On failure: (ResultCode.FAILED, [], error_message)

Return type

tuple

get_station_data_by_id(station_id)

Return receptor matching the given station ID, or None if not found.

Parameters

station_id (int) – Station ID as defined in the layout file.

Returns

The receptor dictionary corresponding to the given station ID, or None if no matching receptor is found.

Return type

dict or None

Raises
  • KeyError – If the “receptors” key is missing in the layout data.

  • ValueError – If the receptor’s station_id cannot be converted to int.

get_station_ids()

Get the list of station IDs from the CSP configuration.

Returns

A list of station IDs extracted from the configuration JSON under the CSP → lowcbf → stations → stns structure.

Return type

list[int]

Raises

ValueError – If there is any error while accessing or parsing the station information in the configuration JSON.

inject_beam_delay_centre(pss_beams)

Injects ‘beam_delay_centre’ into each PSS beam section if missing.

Returns

(ResultCode, message) OK and “” on success. FAILED and an error message on failure.

Return type

tuple

Notes

Any internal exception is caught and converted into (ResultCode.FAILED, <error_message>).

inject_delay_centre(pst_beams)

Injects ‘delay_centre’ into each PST beam scan section if missing.

Returns

(ResultCode, message) OK and “” on success. FAILED and an error message on failure.

Return type

tuple

Notes

Any internal exception is caught and converted into (ResultCode.FAILED, <error_message>).

inject_rfi_frequency_masks(pst_beams)

Injects ‘rfi_frequency_masks’ into each PST beam’s scan section if missing.

Returns

(ResultCode, message) OK and “” on success. FAILED and an error message on failure.

Return type

tuple

Notes

Any internal exception is caught and converted into (ResultCode.FAILED, <error_message>).

update_pss_data()

Injects beam_delay_centre to PSS beam data.

Returns

(ResultCode, message)

Return type

tuple

update_pst_data()

Injects delay_centre and rfi_frequency_masks to PST beam data.

Returns

(ResultCode, message)

Return type

tuple

class ska_tmc_subarraynode.commands.build_up_data.ElementDeviceDataMid(scan_config, component_manager)

Bases: ElementDeviceData

A class representing data for an Mid element device.

build_csp_layout_data()

Build CSP antenna layout data for the observation.

Collects interface, telescope, and receptor details from the array layout and prepares data required by CSP.

Returns

CSP layout data with keys below.
  • ”interface” (dict): Interface details.

  • ”telescope” (dict): Telescope information.

  • ”receptors” (list): Receptor entries for assigned dishes.

Return type

dict

Raises

ValueError – If layout data for any receptor is missing.

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

Tuple[ResultCode, str]

Returns

Result code and CSP configuration schema

build_up_dish_cmd_data()

Method to build up dish command data

Return type

Tuple[ResultCode, str]

Returns

Result code and dish configuration schema

get_dish_data_by_label(label)

Get receptor data for the given dish label.

Searches the layout data for a receptor matching the provided dish label and returns its details.

Parameters

label (str) – Dish ID label in the layout file.

Returns

Receptor data matching label, or None if not found.

Return type

dict or None

Raises

KeyError – If receptor data is missing in the layout.

Module contents