remotivelabs.topology.behavioral_model
A BehavioralModel is used to emulate some behavior instead of a real ECU.
It manages lifecycle operations for namespaces (e.g., CanNamespace
, SomeIPNamespace
), handles inputs,
routes control requests, and provides a unified interface for testing setups.
Initialize the BehavioralModel instance.
Arguments:
- name: Identifier for the ECU stub instance, then name which receives control messages.
- broker_client: The client used for communication with the broker.
- namespaces: list of Namespace instances (
CanNamespace
,SomeIPNamespace
, etc.). - input_handlers: Optional list of (namespace, handler list) pairs to receive
callbacks on inputs.
It is advised to create these using the namespace's
create_input_handler
method. - control_handlers: Optional list of (command, handler) pairs for routing control messages.
Note:
Start the instance using a context manager:
async with BehavioralModel(...) as bm: ... await bm.run_forever()
Or use the start/stop methods directly:
bm = BehavioralModel(...) await bm.start() # ... await bm.stop()
Start the behavioral model, open all namespaces, and initialize input handlers. This is an idempotent operation - calling it multiple times has no additional effect.
Control request to check if the BehavioralModel
is alive and responsive.
Use remotivelabs.topology.control.ControlClient
to send control requests.
Control request to reset all namespace restbus to default values.
Use remotivelabs.topology.control.ControlClient
to send control requests.