Restbus Simulation

The PyRbs Python class connects your application logic with timers, CAN messages, signals, state machines, and system variables. React to changes and updates without learning a proprietary programming language.

./rbs/main.py
Copy code
from pyrbs import PyRbs, CanMessage, Timerrbs = PyRbs(dashboard=True, log_all=True)timer_100ms: Timer = rbs.timer.add("timer_100ms", 0.1, active_on_start=True)msg_control_01: CanMessage = rbs.can_message.get("CAN1.Control_01")@rbs.timer.on("timer_100ms")def on_timer_100ms(self: Timer):    msg_control_01.send()

Create your event-driven restbus simulation

PyRbs decorators expose the events taking place behind the scenes: CAN message reception and transmission, signal updates, timer events, state-machine changes, and service events from diagnostic protocols such as UDS or CANopen.

Keep the code focused on the behavior of the device under test while pyCANdo handles the timing and CAN communication around it.

./rbs/main.py
Copy code
temp_avg = rbs.sysvar.add("temp_avg", 0.0)temp_1_mapped = rbs.sysvar.add("temp_1_mapped", 0.0)@rbs.can_message.on("CAN1.Measurement_01")def on_measurement_msg(self):    temp_avg.value = np.average(np.array([        self[f"Temperature_0{x}"] for x in range(1,5)    ]))@rbs.sysvar.on_change("temp_avg")def on_temp_avg(self):    if self.value > 55:        print("over temperature warning!")@rbs.can_signal.on_update("CAN1.Measurement_01.Temperature_01")def on_temp_2_update(self):    temp_1_mapped.value = self.phys

Common questions about pyCANdo

Isn't Python is a slow programming language?

PyRbs keeps the performance-critical work outside of your business logic. The heavy lifting is implemented in Rust in the background.

Is real-time behavior possible with pyCANdo?

Linux preemption, core isolation, and other system-level measures are used to make response times accurate and predictable.

Can I use any Python package?

Most packages fit naturally, including NumPy, Polars, pandas, and SciPy. Blocking requests or custom asynchronous threads should not run directly inside an @rbs event handler.

How many simulations can run in parallel?

The available CPU cores determine the number of parallel running simulations. Three cores are typically reserved for utilities and real-time services; each remaining core can run an additional simulation.

Can i use my CAN Interfaces on multiple Simulations at the same time

Yes, Interfaces can be shared as well as locked exclusivly for one Simulation.