Developer/How To/Device

This Page describes how to implement a new device.

What is a device good for?
A device is a container for data and functionality which resides in individual vehicles. Devices are notified about all vehicle movements and may interact with the vehicle or with other devices. An important aspect of devices is, that it is possible to equip only a fraction of the simulated vehicles. Usually devices support some kind of output. The following is a list of available devices and their functionality

MSDevice_Tripinfo
Records start and arrival of a vehicle as well as aggregate measures about a completed trip such as average speed and waiting time. This device is also used for expressing aggregate results from other devices such as emissions (MSDevice_HBEFA). This devices is activated using the option and is then active for all vehicles.

MSDevice_Vehroutes
Records the edges traveled by a vehicle and optionally the times at which each edge was left. It can also record dynamic route changes. This device is also used for expressing aggregate results from other devices such as emissions (MSDevice_HBEFA). This devices is activated using the option and is then active for all vehicles.

MSDevice_Routing
Triggers periodic rerouting of equipped vehicles. This devices is activated using the options and is then active for selected vehicles. It is possible to equip specific vehicles or a fraction of the vehicle fleet.

MSDevice_Person
This device is automatically created if a person rides in a vehicle. It is used when managing boarding and alighting

MSDevice_HBEFA
Computes emissions of a vehicle as described in Definition_of_Vehicles,_Vehicle_Types,_and_Routes. This devices is activated using the options and is then active for selected vehicles. It is possible to equip specific vehicles or a fraction of the vehicle fleet.

MSDevice_Energy
This device is used for modelling energy use and battery capacity of electric vehicles. It is currently under development.

MSDevice_Example
This device serves as an implementation example for custom devices.

Steps for implementing a new device
The suggested way for creating a new device is to create a new class by copying the files src/microsim/devices/MSDevice_Example.{h,cpp}. It is important to test new code and suggestions for how to do so can be found in tests/sumo/extended/device_example/.

Show your work
If you have implemented a new device and you think it may be useful to other users of SUMO, please contribute to our community and tell us about your work. We would be happy to help you in getting your device into the main development tree.