remotivelabs.topology.namespaces.generic
GenericNamespace provides access to frames and signals in a specific namespace using a broker client.
This class also manages restbus configurations which enable frame publishing based on filters. To load restbus configuration and activate the restbus, use this class as an async context manager.
Initialize the generic namespace client.
Arguments:
- name: The namespace name to operate in.
- broker_client: The client used to communicate with the broker.
- restbus_configs: Optional list of configurations with filters for the restbus. Applied in order; if multiple filters match the same frame, the last matching configuration takes precedence.
- decode_named_values: True will decode named values to str.
Note:
Use together with a
BehavioralModel
or start the instance using a context manager:async with GenericNamespace(...) as broker_client: ...
Property to interact with the restbus. The restbus manages periodic publishing of frames and signals.
Activate the restbus and load frame configurations using filters. This is an idempotent operation - calling it multiple times has no additional effect.
Returns:
The namespace
Will close the restbus, all frames are removed from the restbus in the namespace. This is an idempotent operation - calling it multiple times has no additional effect.
Set a SecOC property in the namespace.
Publish one or more signals to the broker.
Arguments:
- *signals: One or more WriteSignal instances to publish.
Subscribe to a list of signals.
Arguments:
- *signals: One or more signals to subscribe to.
- on_change: Whether to receive updates only on change.
Note: does not support decoding enums
Returns:
An asynchronous iterator of lists of Signal objects.
Subscribe to a Frames.
Arguments:
- *frames: One or more frames to subscribe to.
- on_change: Whether to receive updates only on change.
- initial_empty: True will wait until the broker has sent an initial message
- decode_named_values: True will decode named values to str.
Returns:
An asynchronous iterator with Frames.
Creates a list of input handlers for the given namespace to be used with a BehavioralModel
.
Each handler defines a filter and a corresponding async callback for processing matching frames.
Arguments:
- - filters: A sequence of filter objects to select relevant frames or signals.
- - callback: An async callback function that receives and processes a Frame.
Inherited Members
Configuration for the Restbus
Attributes:
- restbus_filters: List of filters used to select frames; matching frames will be configured and managed by the restbus.
- delay_multiplier: Multiplier for applying artificial delays; default is 1 (no delay).
- cycle_time_millis: Optional fixed cycle time in milliseconds for publishing. By default the cycle time from the signal database is used.
Restbus provides a way to publish frames according to their cycle time. Sending recurring frames is common with for example CAN or LIN. Notice that each Namespace has its own Restbus. It allows configuring frame publishing behavior, applying filters, and controlling the restbus lifecycle.
Also notice that new frames can be added or removed in order to emulate how different frames are sent depending on the state of the model.
Usage:
Should be used with through a
Namespace
implementation such asGenericNamespace
, but can be used standalone.async with Restbus(namespace, broker_client, restbus_configs) as restbus: await restbus.start()
Arguments:
- namespace: The namespace to operate in.
- broker_client: The broker client to communicate with.
- restbus_configs: Optional list of configurations with filters for the restbus. Applied in order; if multiple filters match the same frame, the last matching configuration takes precedence.
Open the restbus and initialize it with configured frames. This is an idempotent operation - calling it multiple times has no additional effect.
Close the restbus for this namespace, this will remove all configuration and put the restbus in idle state. This is an idempotent operation - calling it multiple times has no additional effect.
Add frames by configuration to the restbus.
Arguments:
- *frame_configs: One or more frame configurations
- start: Whether to start the restbus publishing immediately. Note: this flag controls a global state for the entire restbus, not individual frames.
Remove frames from the restbus.
Arguments:
- *frames: One or more frame names to remove
Update signal configurations for the restbus.
Arguments:
- *signal_configs: Signal configurations to update.
Reset specified signals in the restbus to their original values.
Arguments:
- *signals: Signal names to reset.