Developer/How To/Device

From Sumo
Revision as of 14:19, 19 June 2017 by Namdre (talk | contribs) (Steps for implementing a new device)
Jump to navigation Jump to search

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 --tripinfo-output <FILE> 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 --vehroute-output <FILE> and is then active for all vehicles.

MSDevice_Routing

Triggers periodic rerouting of equipped vehicles. This devices is activated using the options --vehroute-output.* 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#Vehicle_Emission_Classes. This devices is activated using the options --device.hbefa.* and is then active for selected vehicles. It is possible to equip specific vehicles or a fraction of the vehicle fleet.

MSDevice_Battery

This device is used for modelling energy use and battery capacity of electric vehicles.

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}.

In ordert to compile the new class it must be added to src/microsim/devices/Makefile.am (on Linux) or added to project z_libmicrosim_devices (on Windows).

In order to be available for use, the device must also be added in src/microsim/devices/MSDevice.cpp to the functions insertOptions and buildVehicleDevices.

Note:
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.