Resource Summary ================ This guide explains the resource management functionality in the SKA Low MCCS system, focusing on the ``MccsController.resourceSummary`` attribute and the ``MccsController.GetAssignedResources`` command. These tools provide visibility into system resource allocation and usage. Overview -------- The SKA Low MCCS system manages three primary types of resources: 1. **Channel Blocks**: Frequency channels allocated to stations for signal processing 2. **Station Beams**: Beamforming resources that process signals from multiple tiles within a station 3. **Subarray Beams**: Higher-level beams that combine data from station beams for scientific observations A view on resource management is useful for: - Monitoring system capacity and utilization - Diagnosing resource allocation issues - Planning observations based on available resources - Verifying the success of allocation/release operations MccsController.resourceSummary ------------------------------ The ``resourceSummary`` attribute provides an overview of all resources in the system. It returns a JSON-formatted string containing detailed information about resource allocation and availability. Structure ~~~~~~~~~ The resource summary has the following structure: .. code-block:: json { "resources": { "channel_blocks": { "available": { "count": 64 }, "allocated": { "count": 32, "usage": { "low-mccs/subarray/01": 16, "low-mccs/subarray/02": 16 } }, "by_station": { "ci-1": { "total": 48, "available": 16, "allocated": 32 }, "ci-2": { "total": 48, "available": 48, "allocated": 0 } } }, "station_beams": { "total": { "count": 8 }, "available": { "count": 4 }, "allocated": { "count": 4, "usage": { "low-mccs/beam/ci-1-01": "low-mccs/subarray/01", "low-mccs/beam/ci-1-02": "low-mccs/subarray/01", "low-mccs/beam/ci-2-01": "low-mccs/subarray/02", "low-mccs/beam/ci-2-02": "low-mccs/subarray/02" } } }, "subarray_beams": { "total": { "count": 4 }, "available": { "count": 2 }, "allocated": { "count": 2, "usage": { "low-mccs/subarraybeam/01": "low-mccs/subarray/01", "low-mccs/subarraybeam/02": "low-mccs/subarray/02" } } } } } Usage Example ~~~~~~~~~~~~~ To access the resource summary: .. code-block:: python import json import tango # Connect to the MccsController device controller = tango.DeviceProxy("low-mccs/control/control") # Get the resource summary summary_json = controller.resourceSummary summary = json.loads(summary_json) # Access specific resource information resources = summary["resources"] # Check channel blocks channel_blocks = resources["channel_blocks"] print(f"Available channel blocks: {channel_blocks['available']['count']}") print(f"Allocated channel blocks: {channel_blocks['allocated']['count']}") # Check station beams station_beams = resources["station_beams"] print(f"Total station beams: {station_beams['total']['count']}") print(f"Available station beams: {station_beams['available']['count']}") # Check subarray beams subarray_beams = resources["subarray_beams"] print(f"Total subarray beams: {subarray_beams['total']['count']}") print(f"Allocated subarray beams: {subarray_beams['allocated']['count']}") Resource Details ~~~~~~~~~~~~~~~~ **Channel Blocks** - Shows total, available, and allocated counts - Provides breakdown by station - Includes usage information showing which subarrays are using specific channel blocks **Station Beams** - Shows total count of station beams in the system - Tracks available (unallocated) station beams - Lists allocated station beams with their assigned subarrays **Subarray Beams** - Shows total count of subarray beams in the system - Tracks available (unallocated) subarray beams - Lists allocated subarray beams with their assigned subarrays MccsController.GetAssignedResources ----------------------------------- The ``GetAssignedResources`` command returns the specific resources allocated to a given subarray. This command takes a subarray ID as input and returns a JSON string containing the allocated resources. Command Signature ~~~~~~~~~~~~~~~~~~ .. code-block:: python @command(dtype_in="DevLong", dtype_out="DevString") def GetAssignedResources(self, subarray_id: int) -> str: """ Return a dictionary of the resources assigned to a given subarray. :param subarray_id: The subarray ID of the resources (1-indexed) :return: JSON formatted dictionary of allocated resources """ Usage Example ~~~~~~~~~~~~~ To get resources assigned to a specific subarray: .. code-block:: python import json import tango # Connect to the MccsController device controller = tango.DeviceProxy("low-mccs/control/control") # Get resources assigned to subarray 1 subarray_id = 1 resources_json = controller.GetAssignedResources(subarray_id) resources = json.loads(resources_json) # Check what resources are allocated if resources: print(f"Resources allocated to subarray {subarray_id}:") # Check for subarray beams if "subarray_beams" in resources: subarray_beams = resources["subarray_beams"] print(f" Subarray beams: {subarray_beams}") # Check for station beams if "station_beams" in resources: station_beams = resources["station_beams"] print(f" Station beams: {station_beams}") # Check for other resource types for resource_type, resource_data in resources.items(): if resource_type not in ["subarray_beams", "station_beams"]: print(f" {resource_type}: {resource_data}") else: print(f"No resources allocated to subarray {subarray_id}") Return Format ~~~~~~~~~~~~~ The command returns a JSON string containing the allocated resources. When no resources are allocated, it returns an empty JSON object ``"{}"``. Example return values: **No resources allocated:** .. code-block:: json {} **Resources allocated:** .. code-block:: json { "subarray_beams": ["low-mccs/subarraybeam/01", "low-mccs/subarraybeam/02"], "station_beams": ["low-mccs/beam/ci-1-01", "low-mccs/beam/ci-1-02", "low-mccs/beam/ci-2-01", "low-mccs/beam/ci-2-02"] } Error Handling ~~~~~~~~~~~~~~ The command validates the subarray ID and raises an error if an invalid ID is provided: .. code-block:: python try: resources = controller.GetAssignedResources(invalid_subarray_id) except tango.DevFailed as e: # Handle Tango device error (which wraps the ValueError) print(f"Error: {e.args[0].desc}") Practical Usage Scenarios -------------------------- Verifying Resource Allocation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To validate that resources have been properly allocated after an allocation operation, use the ``GetAssignedResources`` command to check the current allocation status: .. code-block:: python import json import tango # Connect to the MccsController device controller = tango.DeviceProxy("low-mccs/control/control") # Check allocation for subarray 1 subarray_id = 1 resources = json.loads(controller.GetAssignedResources(subarray_id)) # Verify allocation succeeded if resources: allocated_beams = resources.get("subarray_beams", []) print(f"Subarray {subarray_id} has {len(allocated_beams)} subarray beams allocated") # Check specific beam allocations expected_beams = ["low-mccs/subarraybeam/01", "low-mccs/subarraybeam/02"] if all(beam in allocated_beams for beam in expected_beams): print("All expected beams are allocated") else: print("Some expected beams are missing") else: print(f"No resources allocated to subarray {subarray_id}")