TMC Common EventManager
1. EventManager
This module contains event management functionality.
- class ska_tmc_common.v2.event_manager.EventManager(component_manager: TmcComponentManager | TmcLeafNodeComponentManager, subscription_configuration: Optional[dict[str, list]] = None, logger: logging.Logger = <Mock name='mock()' id='133592083038560'>, stateless: bool = True, event_subscription_check_period: int = 1, event_error_max_count: int = 10, status_update_callback: Optional[Callable] = None, maximum_status_queue_size: int = 50)
This class provides necessary functions to manage event subscriptions.
- property pending_configuration: dict[str, list]
This method provides the pending configuration.
- Returns:
This method returns the pending subscription configurations.
- Return type:
dict[str, list]
- property stateless_flag: bool
This method provides the stateless flag for event subscription.
- Returns:
This returns the value of stateless flag.
- Return type:
bool
- property subscription_configruation: dict[str, list]
This method provides the subscription configuration provided.
- Returns:
This method returns the subscription configuration.
- Return type:
dict[str, list]
- property device_subscriptions: dict[str, dict[int, bool]] | dict
- This method provides the instanc of device subscriptions
dictionary.
- Returns:
This method returns the value of device subscriptions variable.
- Return type:
dict[str, dict[int, bool]],dict
- property device_errors_tracker: None
This method returns dictionary with device errors.
- init_timeout(thread_id: int) None
This method initializes timeout flag for the provided thread id.
- Parameters:
thread_id (int) – thread id
- set_timeout(thread_id: int) None
Sets the timeout flag for provided the thread id.
- Parameters:
thread_id (int) – thread id
- start_timer(name: str, thread_id: int, timeout: int = 1000) None
- This method starts a timer thread which updates timeout flag
once it is completed.
- Parameters:
name (str) – The name of the the timer thread.
timeout (int) – Timeout till when the subscriptions will be retired.
thread_id (int) – thread id
- stop_timer(name: str) None
This method stops the timer thread running.
- Parameters:
name (str) – The name of the timer thread which needs to be stopped.
- start_event_subscription(subscription_configuration: dict[str, list] | None = None, timeout: int = 1000) int
This method starts a thread to subscribe events.
- Parameters:
subscription_configuration (dict[str, list], optional) – This is optional parameter, if user wants to start thread with different configuration.
timeout (int) – The duration till when it will try to subscribe, defaults to 1000 seconds.
- Returns:
Returns the thread id
- Return type:
int
- init_unsubscription_cancellation(thread_id: int) None
This method initializes the unsubscription cancellation dictionary. :param thread_id: thread id :type thread_id: int
- cancel_unsubscription_thread(thread_id: int) None
This method canceles the unsubscription thread.
- Parameters:
thread_id (int) – thread id
- unsubscribe_event_async(device_name: str, attribute_names: list | None = None) int
This method unsubcribes the events aysnchronous using threads of the specified device name or some attributes under that device name.
- Parameters:
device_name (str) – This variable consists of device name whose events needs to be unsubscribed.
attribute_names (list, optional) – This list contains names of specific attributes that needs to be unsubscribed.
- Returns:
Returns the thread id
- Return type:
int
- unsubscribe_events(device_name: str, attribute_names: list | None = None) None
This method unsubcribes the events of the specified device name or some attributes under that device name.
- Parameters:
device_name (str) – This variable consists of device name whose events needs to be unsubscribed.
attribute_names (list, optional) – This list contains names of specific attributes that needs to be unsubscribed.
- init_device_subscriptions(device_name: str) None
Initialisation of device configuration dictionary.
- Parameters:
device_name (str) – device name.
- update_device_subscriptions(device_name: str, attribute_name: str | None = None, subscription_id: int | None = None, is_subscription_completed: bool | None = None) None
This method updates device_subscriptions dictionary with the provided values.
- Parameters:
device_name (str) – tango device FQDN.
attribute_name (str, optional) – Attribute name under provided device.
subscription_id (int, optional) – Subscription ID of attribute after successful completion.
is_subscription_completed (bool, optional) – This flag is set once all the subscription is completed.
- get_device_proxy(device_name: str) tango.DeviceProxy
This method creates device proxy for the provided device name.
- Parameters:
device_name (str) – Tango device FQDN.
- Returns:
Returns device proxy
- Return type:
tango.DeviceProxy
- cancel_subscription_thread(thread_id: int)
This method provides a mechanism to cancel the event subscription thread.
- Parameters:
thread_id (int) – Thread id to be stopped
- subscribe_events(subscription_configuration: dict[str, list], timeout: int = 1000) None
This functions utilises the subscription configuration provided and subscribes to the attributes present in them. The function updates device_subscriptions dictionary with the details of sucess and failure.
- Parameters:
subscription_configuration (dict[str, list]) – The variable contains the detail of devices and their attributes to be subscribed. For Example: {“device_name”:[“attribute1”,”attribute2”]}.
timeout (int) – The duration till when it will try to subscribe, defaults to 1000 seconds
- remove_subscribed_devices(subscription_configuration: dict) None
This method removes the devices from the configuration data.
- Parameters:
subscription_configuration (dict) – This parameter contains the detail of devices and their attributes to be subscribed.
- subscribe_pending_events(device_name: str)
This method checks for pending subscriptions for the device.
- Parameters:
device_name (str) – tango device FQDN.
- device_avaiability_callback(device_name: str) None
This method is called once device is available back again to subscribe events if it that is pending.
- Parameters:
device_name (str) – tango device FQDN which is available again.
- get_device_and_attribute_name(attribute_fqdn: str) tuple[str]
This method provides device and attribute name.
- Parameters:
attribute_fqdn (str) – Full attribute FQDN from event data.
- Returns:
Returns device name and attribue name
- Return type:
tuple[str]
- handle_event_error(event: tango.EventData) None
This method handles the event error by tracking
- Parameters:
event (tango.EventData) – change event data with error.
- check_and_handle_event_error(event: tango.EventData) bool
Checks event error and handles the API timeout error if it persists.
- Parameters:
event (tango.EventData) – Change event data
- Returns:
Returns True if event data has error, else returns False.s
- Return type:
bool
- update_status_queue(status: str) None
This method updates status queue.
- Parameters:
status (str) – The status message to update.