heros.event¶
Classes¶
Represent a callback function. |
|
Store all callbacks. |
|
Base class for event handlers. |
|
Handles event connections for a specific instance. |
|
Handles remote events for a specific instance. |
|
A descriptor to handle instance-specific event connections. |
|
Descriptor of @event decorated methods of a LocalHERO. |
|
Descriptor of remote representations of events in a RemoteHERO. |
Functions¶
|
|
|
Decorator to make an event reliable. |
|
Decorator for events. |
Module Contents¶
- class heros.event.Callback(func: collections.abc.Callable, origin: str = None)[source]¶
Represent a callback function.
- func¶
- origin = None¶
- __eq__(other) bool[source]¶
Check for equality with other Callback.
- Parameters:
other – other callback instance.
- Returns:
equality result.
- Return type:
bool
- class heros.event.CallbackStorage[source]¶
Store all callbacks.
- _callbacks¶
- __contains__(func: collections.abc.Callable) bool[source]¶
Implements the in operation for this class.
- append(func: collections.abc.Callable, origin: str = None) str[source]¶
Append a given callable to the storage.
- Parameters:
func – callable to append.
origin – str (default: None) indicating the origin of the callback.
- Returns:
name of the callback.
- Return type:
str
- remove(func: callable) bool[source]¶
Remove a callable from storage.
- Parameters:
func – callable to remove.
- Returns:
truth value indicating if the callable was a callback.
- Return type:
bool
- class heros.event.EventHandler[source]¶
Base class for event handlers.
- abstractmethod disconnect(callback: collections.abc.Callable)[source]¶
Disconnect a callback function.
- class heros.event.LocalEventHandler(instance, func, reliability: zenoh.Reliability, congestion_control: zenoh.CongestionControl)[source]¶
Bases:
EventHandlerHandles event connections for a specific instance.
- instance¶
- func¶
- callbacks¶
- publisher¶
- connect(callback: collections.abc.Callable, origin: str | None = None) str[source]¶
Connect a callback function to be triggered when the method is called.
- Parameters:
callback – callable to connect.
origin – (optional) str indicting origin of this callback.
- Returns:
name of the callback.
- Return type:
str
- disconnect(callback: collections.abc.Callable) bool[source]¶
Disconnect a callback function.
- Parameters:
callback – callable to disconnect.
- Returns:
truth value indicating if the callable was a callback.
- Return type:
bool
- class heros.event.RemoteEventHandler(instance, func: collections.abc.Callable | None = None)[source]¶
Bases:
EventHandlerHandles remote events for a specific instance.
- instance¶
- callbacks¶
- connect(callback: collections.abc.Callable) str[source]¶
Connect a callback function to be triggered when the method is called.
- Parameters:
callback – callable to connect.
origin – (optional) str indicting origin of this callback.
- Returns:
name of the callback.
- Return type:
str
- disconnect(callback: collections.abc.Callable) None[source]¶
Disconnect a callback function.
- Parameters:
callback – callable to disconnect.
- Returns:
truth value indicating if the callable was a callback.
- Return type:
bool
- class heros.event.EventDescriptor(func: collections.abc.Callable | None = None, handler_config: dict | None = None)[source]¶
A descriptor to handle instance-specific event connections.
- func = None¶
- handler_config¶
- _instances¶
- class heros.event.LocalEventDescriptor(func: collections.abc.Callable | None = None, handler_config: dict | None = None)[source]¶
Bases:
EventDescriptorDescriptor of @event decorated methods of a LocalHERO.
- class heros.event.RemoteEventDescriptor(func: collections.abc.Callable | None = None, handler_config: dict | None = None)[source]¶
Bases:
EventDescriptorDescriptor of remote representations of events in a RemoteHERO.
- heros.event.reliable(func: collections.abc.Callable | LocalEventDescriptor)[source]¶
Decorator to make an event reliable.
This decorator can be used in addition to the @event decorator to make an event use the zenoh RELIABLE reliability and BLOCK congestion. This guarantees that the message is received at all subscribers. Using the default can lead to lost messages under high load or changing network topologies. Use this if you observe missing data from e.g. cameras.
Note
Can be used on arbitrary events with the BOSS decorator injector mechanism. The following example makes the emitted images from a camera reliable.
{ "_id": "my_camera", "classname": "herosdevices.hardware.ids.PeakCompatibleCamera", "arguments": { "cam_id": "1409f4e7c3b1" } "extra_decorators": [ ["acquisition_data", "heros.event.reliable"] ] }