Custom data¶
If trajectory data and detector data, even with ExtendedDataType
for trajectories or custom LoopDetectorMeasurment
for detectors, is not sufficient, a custom form of data collection should be created. A likely design for this revolves around the internal OTS events. As an example, suppose information on each lane change is required. Then a custom data utility should be set as a listener for Network.GTU_ADD_EVENT
and Network.GTU_REMOVE_EVENT
. As a response to these events, the utility can be added or removed as a listener to LaneBasedGTU.LANE_CHANGE_EVENT
on individual GTUs. As a response to that event, the data utility can store some data for each lane change. Finally, the data utility should also be set up as a listener to SimulatorInterface.END_OF_REPLICATION_EVENT
, and as a response to this event the data can be saved. A useful tool to do this is CompressedFileWriter
, which is an implementation of a buffered writer from java. It has methods write(…)
to add text, newLine()
to create a new line, and close()
to finalize the writing.