diff --git a/src/ska_tango_base/subarray_device.py b/src/ska_tango_base/subarray_device.py index 1108c65370c0fa6ba6f6c472d5cd1d8b556ccab8..044bdd1d4022fcb0ddc02f46eb7ca3c24ef868ac 100644 --- a/src/ska_tango_base/subarray_device.py +++ b/src/ska_tango_base/subarray_device.py @@ -114,11 +114,14 @@ class SKASubarrayResourceManager: A simple class for managing subarray resources """ - def __init__(self): + def __init__(self, key: str = "example"): """ Constructor for SKASubarrayResourceManager + + :param key: Key used to select from JSON input to assign/release methods. """ self._resources = set() + self._key = key def __len__(self): """ @@ -136,15 +139,15 @@ class SKASubarrayResourceManager: Assign some resources :todo: Currently implemented for testing purposes to take a JSON - string encoding a dictionary with key 'example'. In future this + string encoding a dictionary. In future this will take a collection of resources. :param resources: JSON-encoding of a dictionary, with resources to - assign under key 'example' + assign under the configured key (default 'example') :type resources: JSON string """ resources_dict = json.loads(resources) - add_resources = resources_dict['example'] + add_resources = resources_dict[self._key] self._resources |= set(add_resources) def release(self, resources): @@ -152,15 +155,15 @@ class SKASubarrayResourceManager: Release some resources :todo: Currently implemented for testing purposes to take a JSON - string encoding a dictionary with key 'example'. In future this + string encoding a dictionary. In future this will take a collection of resources. :param resources: JSON-encoding of a dictionary, with resources to - assign under key 'example' + assign under the configured key (default 'example') :type resources: JSON string """ resources_dict = json.loads(resources) - drop_resources = resources_dict['example'] + drop_resources = resources_dict[self._key] self._resources -= set(drop_resources) def release_all(self):