event_monitoring module
Monitor events from devices
- class aiv_utils.event_monitoring.EventMonitor(devices)
Monitors events from a list of devices and manages subscriptions.
This class allows for subscribing to and unsubscribing from event changes for specified attributes of devices. It handles the registration of event handlers and maintains a mapping of active subscriptions.
- Args:
devices (list): A list of device objects to monitor for events.
- change_handler(event)
Handles the event when a subscribed attribute changes.
- Args:
event: The event object containing information about the change.
- subscribe(attribute)
Subscribes to change events for a specified attribute on all devices.
- Args:
- attribute (str):
The name of the attribute to subscribe to for change events.
- unsubscribe_all()
Unsubscribes from all events for all devices.
- class aiv_utils.event_monitoring.HealthStateMonitor(devices)
Listen to devices
- change_handler(event)
Handles change events for device attributes.
- Args:
event: The event object containing details about the attribute change.
- print_timeline(cutoff=None)
Prints a timeline of unhealthy events for devices.
- Args:
cutoff (datetime, optional): The minimum timestamp for events to be printed.
- raised_unhealthy_event(device_name)
Checks if an unhealthy event has been raised for a specific device.
- Args:
device_name (str): The name of the device to check for unhealthy events.
- Returns:
bool: True if an unhealthy event is raised for the device, False otherwise.
- property unhealthy_devices
Retrieves a list of devices that are currently unhealthy.
- Returns:
list: A list of device names that are considered unhealthy.
- class aiv_utils.event_monitoring.ObsStateMonitor(devices, raise_error_on_scan=False)
Monitors observation state changes for a set of devices.
This class extends the EventMonitor to specifically handle changes in observation states. It allows for the subscription to observation state events and can raise errors based on specific conditions.
- Args:
- devices (list): A list of device objects to monitor for observation state
changes.
- raise_error_on_scan (bool, optional): A flag indicating whether to raise an
error when scanning starts.
- Methods:
- change_handler(event): Handles change events for device attributes
and processes errors.
- _get_human_value(value): Retrieves the human-readable name for a given
observation state value.
- change_handler(event)
Handles change events for device attributes and processes errors.
- Args:
event: The event object containing details about the attribute change.
- Raises:
ScanStarted: If the event indicates that scanning has started and the flag is set.
- class aiv_utils.event_monitoring.SDPSubarrayObsState(devices, raise_error_on_scan=False)
Monitors the observation state of SDP subarrays.
This class extends the EventMonitor to specifically handle changes in the observation state of SDP subarrays. It allows for the subscription to these state events and can raise errors based on specific conditions.
- Args:
- devices (list): A list of device objects to monitor for observation state
changes.
- raise_error_on_scan (bool, optional): A flag indicating whether to raise
an error when scanning starts.
- Methods:
- change_handler(event): Handles change events for device attributes and
processes errors.
- _get_human_value(value): Retrieves the human-readable name for a given
observation state value.
- change_handler(event)
Handles change events for device attributes and processes errors.
- Args:
event: The event object containing details about the attribute change.
- Raises:
- ScanStarted:
If the event indicates that scanning has started and the flag is set.
- exception aiv_utils.event_monitoring.ScanStarted
Exception raised when a scanning process is initiated.