I'm looking to stop the VEINS application i have running on a single node of the simulation, letting the remaining vehicles simulating normally (not looking to stop the entire simulation). I just want to stop the application that is running, meaning the vehicle should continue in the simulation acting as a regular SUMO vehicle - as if he is not equipped the application. Is it possible to do so? I was not able to find a solution to my problem in the documentation. Thanks in advance
1 Answers
TL;DR: it's not possible with the VEINS API only, you need to write the code for it by hand. How much work it is depends on what you want to do exactly.
Remove & re-add: Stopping it permanently through programming should be relatively easy -- if you terminate everything associated with the Car.ned
, you'd basically do exactly what you're trying to do (this action will not remove the car in the SUMO simulation). You could then, at some later time, instantiate the car again; to do that you're probably just going to need a relatively minor extension to the mobility manager that instantiates a removed vehicle again, when some condition is met.
Pause and resume: Freezing the car and being able to resume it is a bit more difficult, since you'd have to pause all the events associated with the vehicle. The conceptual problem with pausing a single vehicle is, because of the way VEINS is designed, you're going to need to postpone some events (e.g., the timer for a periodic beaconing application), and discard others (signal reception check events queued by other sending vehicles). In particular, you'll need to ask yourself whether you want to keep messages that are in the car's MAC queue. Basically you need to write this by hand, looking at all the events associated with the vehicle and deciding whether or not to postpone them for a certain time (or discard them). If you decide to simply discard all events (probably the easiest decision to implement), you're going to have to deal with the situation that the application state of the car will not make sense anymore.

- 848
- 6
- 15
-
Thanks for your answer! Still, i do not know how to terminate everything associated with the Car.ned.. Can you give me any hint? – Bruno Viana Jan 15 '18 at 15:13
-
I did some quick searching, and probably the best way to do it is to have some method similar to `finish()` that causes all submodules in the car to shut down (and canceling the associated events with `cancelAndDelete`, see e.g. [this](https://stackoverflow.com/questions/33397097/how-to-invoke-finish-individually-on-modules-in-omnet)). I'm not sure whether the omnet++ API has some generic way to terminate complex modules at runtime, including the associated events. That's something I'd recommend asking a new question for though. – Rens van der Heijden Jan 18 '18 at 11:48
-
I'm guessing that it's not actually possible to do this, due to the way events and modules are handled, but I'm not that deep into OMNeT++ internals. – Rens van der Heijden Jan 18 '18 at 11:49