Event Manager
- class ska_csp_lmc_common.event.EventManager(device_type: str, task_callback: Callable, evt_registry: CspEventRegistry, max_queue_size: int | None = 100, logger: Logger | None = None)
Bases:
BaseEventManagerEvent manager implementing dispatching and device-level propagation. This class extends BaseEventManager by:
dispatching events to attribute-specific handlers via
CspEventRegistryapplying attribute name normalization where required
invoking a default handler when no specific handler is registered
It represents the coordination layer of the CSP event pipeline, bridging event transport and handling domain.
- __init__(device_type: str, task_callback: Callable, evt_registry: CspEventRegistry, max_queue_size: int | None = 100, logger: Logger | None = None)
Initialize the EventManager for a CSP device.
- Parameters:
device_type – The type of device managed.
task_callback – Callable to forward events or attribute updates.
evt_registry – Event dispatcher instance for callback registration.
max_queue_size – Maximum size of the internal event queue.
logger – Optional logger. Uses module logger if None.
- flush_event_queue(command_name, max_events: int = 10)
Process and remove up to max_events events from the internal queue.
This is a synchronous flush that locks the queue to prevent other threads from adding events during the flush.
- Parameters:
command_name – Identifier for the operation requesting the flush.
max_events – Maximum number of events to process. Defaults to 10.
- _normalize_attr_name(attr_name: str) str
Hook method to normalize or transform event data before processing.
Default implementation does nothing. Subclasses can override to apply mapping or transformations.
- _default_handler(component: Component, attr_name: str, value: Any)
Default event handling logic.
Builds a device-level attribute name from the event and forwards the value using the configured update callback. This handler is invoked when no dispatcher handler is registered or when the attribute is not configured to skip default handling.
- Parameters:
evt – The CspEvent to process.