vectorgrp / sil-kit

Vector SIL Kit – Open-Source Library for Connecting Software-in-the-Loop Environments
https://vectorgrp.github.io/sil-kit-docs
MIT License
107 stars 32 forks source link

Simulation with unknown number of participants #121

Closed kocho1984 closed 1 month ago

kocho1984 commented 1 month ago

Hi,

If sil-kit-system-controller has to know number and names of participants in advance, then how can we achieve a simulation where participiants are added and removed dynamically in the runtime?

KonradBkd commented 1 month ago

Hello,

the sil-kit-system-controller is needed if you have a set of participants that need to be available right from the start of the simulation. In SIL Kit terminology, we say that these participants are required and want to perform a coordinated simulation start. This can be achieved by creating the LifecycleService with the flag OperationMode::Coordinated on these participants. If you look at a single coordinated participant, it doesn't know the about the other participant names that are also coordinated. That's were the sil-kit-system-controller comes into play and centrally defines all participant that are required for the simulation to start.

If you want a participant to dynamically join and leave the simulation, we say it runs autonomously. In this case, you create a LifecycleService with the flag OperationMode::Autonomous on these participant, and their names no longer have to appear in the list of names passed to the sil-kit-system-controller.

These two concepts can be mixed to be able to cover all kinds of scenarios with the SIL Kit. If you end up with a setup where no participant is required any more and all are dynamic joining and leaving the simulation, just use OperationMode::Autonomous for all of them and the sil-kit-system-controller is no longer needed.

Hope this helped!

KonradBkd commented 1 month ago

Ah seems like you could resolve the issue by yourself just while I was typing, perfect :)

kocho1984 commented 1 month ago

Yes, I solved the problem just by running participants with --async flag. In this case simulation works without sil-kit-system-controller.

Thank you!

KonradBkd commented 1 month ago

You're welcome! That's right, the demos have a --async flag that instructs them to use the OperationMode::Autonomous under the hood. One more feature of the SIL Kit is that this dynamic mode also works if the simulation uses a virtual time. See https://vectorgrp.github.io/sil-kit-docs/simulation/simulation.html#joining-a-running-simulation-with-virtual-time for more info.

kocho1984 commented 1 month ago

@KonradBkd, thanks again for quick and great support!