elkpy.NotificationController#
- class elkpy.notificationcontroller.NotificationController(address='localhost:51051', sushi_proto_def='/usr/share/sushi/sushi_rpc.proto')[source]#
Bases:
object
Class to manage subscriptions to Sushi notifications (changes, updates, …) It allows the User, through simple API calls, to subscribe to any notification stream implemented in Sushi, and to attach call-back functions to each subscribed stream.
(See the API section at the bottom of this class.)
- Attributes:
address: gRPC server IP (str: ip:port) loop: an asynchronous event loop
- Notes:
close() should ALWAYS be called as part of an application housekeeping/cleanup-before-shutdown routine as it ensure proper releasing of resources and clean joining of concurrent threads.
- subscribe_to_parameter_updates(cb, param_blocklist=None)[source]#
Subscribes to Parameter update notification stream from Sushi User needs to implement their own logic to process these notification in the placeholder methods below
- Parameters:
cb: a callable that will be called for each notification received from the stream. param_blocklist: a list of parameter identifiers for which to block update notifications. A parameter identifier is itself a list of [processor_id: int, parameter_id: int] If no param_blocklist is passed, all parameter notifications will be subscribed to.
- Notes to write useful callbacks:
Notification objects have 2 attributes: parameter and value; Parameter itself has 2 attributes: processor_id and _parameter_id; ex: notification.parameter.parameter_id (gets the parameter ID) ex: notification.parameter.processor_id (gets the processor ID) ex: notification.normalized_value (gets the value normalized between 0 and 1) ex: notification.domain_value (gets the domain value) ex: notification.formatted_value (gets the value formatted as a string)
- subscribe_to_processor_changes(cb)[source]#
Subscribes to Processor change notification stream from Sushi. User needs to implement their own stream consumer logic and pass it as cb.
- Parameters:
cb: a callable that will be called for each notification received from the stream.
- subscribe_to_property_updates(cb, property_blocklist=None)[source]#
Subscribes to Property update notification stream from Sushi User needs to implement their own logic to process these notification in the placeholder methods below
- Parameters:
cb: a callable that will be called for each notification received from the stream.
- Notes to write useful callbacks:
Notification objects have 2 attributes: property and value; Property itself has 2 attributes: processor_id and property_id; ex: notification.parameter.property_id (gets the property ID) ex: notification.parameter.processor_id (gets the processor ID) ex: notification.value (gets the value)
- subscribe_to_timing_updates(cb)[source]#
Subscribes to Timing update notification stream from Sushi User needs to implement their own stream consumer logic and pass it as cb.
- Parameters:
cb: a callable that will be called for each notification received from the stream.