Eclipse SUMO - Simulation of Urban MObility
MSDevice_Vehroutes.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2009-2022 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21// A device which collects info on the vehicle trip
22/****************************************************************************/
23#include <config.h>
24
25#include <microsim/MSGlobals.h>
26#include <microsim/MSNet.h>
27#include <microsim/MSLane.h>
28#include <microsim/MSEdge.h>
29#include <microsim/MSRoute.h>
30#include <microsim/MSStop.h>
31#include <microsim/MSVehicle.h>
38#include "MSDevice_Vehroutes.h"
39
40
41// ===========================================================================
42// static member variables
43// ===========================================================================
57
58
59// ===========================================================================
60// method definitions
61// ===========================================================================
62// ---------------------------------------------------------------------------
63// static initialisation methods
64// ---------------------------------------------------------------------------
65void
68 if (oc.isSet("vehroute-output")) {
69 OutputDevice::createDeviceByOption("vehroute-output", "routes", "routes_file.xsd");
70 mySaveExits = oc.getBool("vehroute-output.exit-times");
71 myLastRouteOnly = oc.getBool("vehroute-output.last-route");
72 myDUAStyle = oc.getBool("vehroute-output.dua");
73 myWriteCosts = oc.getBool("vehroute-output.cost");
74 mySorted = myDUAStyle || oc.getBool("vehroute-output.sorted");
75 myIntendedDepart = oc.getBool("vehroute-output.intended-depart");
76 myRouteLength = oc.getBool("vehroute-output.route-length");
77 mySkipPTLines = oc.getBool("vehroute-output.skip-ptlines");
78 myIncludeIncomplete = oc.getBool("vehroute-output.incomplete");
79 myWriteStopPriorEdges = oc.getBool("vehroute-output.stop-edges");
80 myWriteInternal = oc.getBool("vehroute-output.internal");
83 }
84}
85
86
87void
89 oc.addOptionSubTopic("Vehroutes Device");
90 insertDefaultAssignmentOptions("vehroute", "Vehroutes Device", oc);
91}
92
93
95MSDevice_Vehroutes::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into, int maxRoutes) {
96 if (maxRoutes < std::numeric_limits<int>::max()) {
97 return new MSDevice_Vehroutes(v, "vehroute_" + v.getID(), maxRoutes);
98 }
99 if (mySkipPTLines && v.getParameter().line != "") {
100 return nullptr;
101 }
103 if (equippedByDefaultAssignmentOptions(oc, "vehroute", v, oc.isSet("vehroute-output"))) {
104 if (myLastRouteOnly) {
105 maxRoutes = 0;
106 }
107 myStateListener.myDevices[&v] = new MSDevice_Vehroutes(v, "vehroute_" + v.getID(), maxRoutes);
108 into.push_back(myStateListener.myDevices[&v]);
109 return myStateListener.myDevices[&v];
110 }
111 return nullptr;
112}
113
114
115// ---------------------------------------------------------------------------
116// MSDevice_Vehroutes::StateListener-methods
117// ---------------------------------------------------------------------------
118void
121 const auto& deviceEntry = myDevices.find(vehicle);
122 if (deviceEntry != myDevices.end()) {
123 deviceEntry->second->addRoute(info);
124 }
125 }
126}
127
128
129// ---------------------------------------------------------------------------
130// MSDevice_Vehroutes-methods
131// ---------------------------------------------------------------------------
132MSDevice_Vehroutes::MSDevice_Vehroutes(SUMOVehicle& holder, const std::string& id, int maxRoutes) :
133 MSVehicleDevice(holder, id),
134 myCurrentRoute(&holder.getRoute()),
135 myMaxRoutes(maxRoutes),
136 myLastSavedAt(nullptr),
138 myDepartLane(-1),
139 myDepartPos(-1),
140 myDepartSpeed(-1),
142 myStopOut(2) {
144}
145
146
148 for (const RouteReplaceInfo& rri : myReplacedRoutes) {
149 rri.route->release();
150 }
153}
154
155
156bool
159 if (mySorted && myStateListener.myDevices[static_cast<SUMOVehicle*>(&veh)] == this) {
161 myRouteInfos.departureCounts[departure]++;
162 }
164 const MSVehicle& vehicle = static_cast<MSVehicle&>(veh);
165 myDepartLane = vehicle.getLane()->getIndex();
167 }
168 myDepartSpeed = veh.getSpeed();
170 }
173 const MSEdge* e = veh.getEdge();
174 if (myPriorEdges.empty() || myPriorEdges.back() != e) {
175 myPriorEdges.push_back(e);
176 }
177 } else {
178 myPriorEdges.push_back(&enteredLane->getEdge());
179 }
180 }
182 return true;
183}
184
185
186bool
187MSDevice_Vehroutes::notifyLeave(SUMOTrafficObject& veh, double /*lastPos*/, MSMoveReminder::Notification reason, const MSLane* /* enteredLane */) {
188 if (mySaveExits && reason != NOTIFICATION_LANE_CHANGE && reason != NOTIFICATION_PARKING && reason != NOTIFICATION_SEGMENT) {
189 const MSEdge* edge = myWriteInternal ? dynamic_cast<MSBaseVehicle&>(veh).getCurrentEdge() : veh.getEdge();
190 if (myLastSavedAt != edge) {
191 myExits.push_back(MSNet::getInstance()->getCurrentTimeStep());
192 myLastSavedAt = edge;
193 }
194 }
195 return true;
196}
197
198
199void
201 const SUMOVehicleParameter::Stop& stop = myHolder.getStops().front().pars;
202 const bool closeLater = myWriteStopPriorEdges || mySaveExits;
203 stop.write(myStopOut, !closeLater);
205 // calculate length
206 double priorEdgesLength = 0;
207 for (int i = 0; i < (int)myPriorEdges.size(); i++) {
208 if (i == 0) {
209 priorEdgesLength += myPriorEdges.at(i)->getLength();
210 } else if (myPriorEdges.at(i)->getID() != myPriorEdges.at(i - 1)->getID()) {
211 priorEdgesLength += myPriorEdges.at(i)->getLength();
212 }
213 }
214 myStopOut.writeAttr("priorEdges", myPriorEdges);
215 myPriorEdges.clear();
216 myStopOut.writeAttr("priorEdgesLength", priorEdgesLength);
217 }
218 if (mySaveExits) {
220 myStopOut.writeAttr(SUMO_ATTR_ENDED, stop.ended < 0 ? "-1" : time2string(stop.ended));
221 }
222 if (closeLater) {
224 }
225}
226
227
228void
230 if (index == 0 && !myIncludeIncomplete && myReplacedRoutes[index].route->size() == 2 &&
231 myReplacedRoutes[index].route->getEdges().front()->isTazConnector() &&
232 myReplacedRoutes[index].route->getEdges().back()->isTazConnector()) {
233 return;
234 }
235 // check if a previous route shall be written
236 //std::cout << " writeXMLRoute index=" << index << " numReroutes=" << myHolder.getNumberReroutes() << "\n";
237 const int routesToSkip = myHolder.getParameter().wasSet(VEHPARS_FORCE_REROUTE) ? 1 : 0;
239 if (index >= 0) {
240 assert((int)myReplacedRoutes.size() > index);
241 if (myDUAStyle || myWriteCosts) {
242 os.writeAttr(SUMO_ATTR_COST, myReplacedRoutes[index].route->getCosts());
243 }
244 if (myWriteCosts) {
245 os.writeAttr(SUMO_ATTR_SAVINGS, myReplacedRoutes[index].route->getSavings());
246 }
247 // write edge on which the vehicle was when the route was valid
248 os.writeAttr("replacedOnEdge", (myReplacedRoutes[index].edge ?
249 myReplacedRoutes[index].edge->getID() : ""));
250 if (myReplacedRoutes[index].lastRouteIndex > 0) {
251 // do not write the default
252 os.writeAttr(SUMO_ATTR_REPLACED_ON_INDEX, myReplacedRoutes[index].lastRouteIndex);
253 }
254 // write the reason for replacement
255 os.writeAttr("reason", myReplacedRoutes[index].info);
256
257 // write the time at which the route was replaced
259 os.writeAttr(SUMO_ATTR_PROB, "0");
260 OutputDevice_String edgesD;
261 // always write the part that was actually driven and the rest of the current route that wasn't yet driven
262 int start = 0;
263 for (int i = routesToSkip; i < index; i++) {
264 if (myReplacedRoutes[i].edge != nullptr) {
265 int end = myReplacedRoutes[i].lastRouteIndex;
266 myReplacedRoutes[i].route->writeEdgeIDs(edgesD, start, end, myWriteInternal, myHolder.getVClass());
267 }
268 start = myReplacedRoutes[i].newRouteIndex;
269 }
270 myReplacedRoutes[index].route->writeEdgeIDs(edgesD, start, -1, myWriteInternal, myHolder.getVClass());
271 std::string edgesS = edgesD.getString();
272 edgesS.pop_back(); // remove last ' '
273 os.writeAttr(SUMO_ATTR_EDGES, edgesS);
274 if (myRouteLength) {
275 const bool includeInternalLengths = MSGlobals::gUsingInternalLanes && MSNet::getInstance()->hasInternalLinks();
276 const MSRoute* route = myReplacedRoutes[index].route;
277 const double routeLength = route->getDistanceBetween(myHolder.getDepartPos(), route->getEdges().back()->getLength(),
278 route->begin(), route->end(), includeInternalLengths);
279 os.writeAttr("routeLength", routeLength);
280 }
281 } else {
282 if (myDUAStyle || myWriteCosts) {
284 }
285 if (myWriteCosts) {
287 }
288 OutputDevice_String edgesD;
289 int numWritten = 0;
290 int start = 0;
291 if (myHolder.getNumberReroutes() > 0) {
292 assert((int)myReplacedRoutes.size() <= myHolder.getNumberReroutes());
293 for (int i = routesToSkip; i < (int)myReplacedRoutes.size(); i++) {
294 if (myReplacedRoutes[i].edge != nullptr) {
295 int end = myReplacedRoutes[i].lastRouteIndex;
296 numWritten += myReplacedRoutes[i].route->writeEdgeIDs(edgesD, start, end, myWriteInternal, myHolder.getVClass());
297 }
298 start = myReplacedRoutes[i].newRouteIndex;
299 }
300 }
301 numWritten += myCurrentRoute->writeEdgeIDs(edgesD, start, -1, myWriteInternal, myHolder.getVClass());
302 std::string edgesS = edgesD.getString();
303 edgesS.pop_back(); // remove last ' '
304 os.writeAttr(SUMO_ATTR_EDGES, edgesS);
305
306 if (mySaveExits) {
307 std::vector<std::string> exits;
308 for (SUMOTime t : myExits) {
309 exits.push_back(time2string(t));
310 }
311 assert(numWritten >= (int)myExits.size());
312 std::vector<std::string> missing(numWritten - (int)myExits.size(), "-1");
313 exits.insert(exits.end(), missing.begin(), missing.end());
315 }
316 }
317 os.closeTag();
318}
319
320
321void
323 writeOutput(true);
324}
325
326
327void
328MSDevice_Vehroutes::writeOutput(const bool hasArrived) const {
330 OutputDevice& routeOut = OutputDevice::getDeviceByOption("vehroute-output");
338 }
344 }
345 }
346 if (tmp.wasSet(VEHPARS_DEPARTPOS_SET)) {
352 }
359 }
360 if (oc.getBool("vehroute-output.speedfactor") ||
361 (oc.isDefault("vehroute-output.speedfactor") && tmp.wasSet(VEHPARS_DEPARTSPEED_SET))) {
364 }
365
366 const std::string typeID = myHolder.getVehicleType().getID() != DEFAULT_VTYPE_ID ? myHolder.getVehicleType().getID() : "";
367 tmp.write(od, oc, SUMO_TAG_VEHICLE, typeID);
368 if (hasArrived) {
370 }
371 if (myRouteLength) {
372 const bool includeInternalLengths = MSGlobals::gUsingInternalLanes && MSNet::getInstance()->hasInternalLinks();
373 const double finalPos = hasArrived ? myHolder.getArrivalPos() : myHolder.getPositionOnLane();
374 const double routeLength = myHolder.getRoute().getDistanceBetween(myHolder.getDepartPos(), finalPos,
375 myHolder.getRoute().begin(), myHolder.getCurrentRouteEdge(), includeInternalLengths);
376 od.writeAttr("routeLength", routeLength);
377 }
378 if (myDUAStyle) {
380 if (routeDist != nullptr) {
381 const std::vector<const MSRoute*>& routes = routeDist->getVals();
382 unsigned index = 0;
383 while (index < routes.size() && routes[index] != myCurrentRoute) {
384 ++index;
385 }
387 const std::vector<double>& probs = routeDist->getProbs();
388 for (int i = 0; i < (int)routes.size(); ++i) {
389 od.setPrecision();
391 od.writeAttr(SUMO_ATTR_COST, routes[i]->getCosts());
392 if (myWriteCosts) {
393 od.writeAttr(SUMO_ATTR_SAVINGS, routes[i]->getSavings());
394 }
395 od.setPrecision(8);
396 od.writeAttr(SUMO_ATTR_PROB, probs[i]);
397 od.setPrecision();
398 OutputDevice_String edgesD;
399 routes[i]->writeEdgeIDs(edgesD, 0, -1, myWriteInternal, myHolder.getVClass());
400 std::string edgesS = edgesD.getString();
401 edgesS.pop_back(); // remove last ' '
402 od.writeAttr(SUMO_ATTR_EDGES, edgesS);
403 od.closeTag();
404 }
405 od.closeTag();
406 } else {
407 writeXMLRoute(od);
408 }
409 } else {
410 const int routesToSkip = myHolder.getParameter().wasSet(VEHPARS_FORCE_REROUTE) && !myIncludeIncomplete ? 1 : 0;
411 if ((int)myReplacedRoutes.size() > routesToSkip) {
413 for (int i = routesToSkip; i < (int)myReplacedRoutes.size(); ++i) {
414 writeXMLRoute(od, i);
415 }
416 writeXMLRoute(od);
417 od.closeTag();
418 } else {
419 writeXMLRoute(od);
420 }
421 }
422 od << myStopOut.getString();
424 od.closeTag();
425 od.lf();
426 if (mySorted) {
427 // numerical id reflects loading order
429 } else {
430 routeOut << od.getString();
431 }
432}
433
434
435const MSRoute*
437 if (index < (int)myReplacedRoutes.size()) {
438 return myReplacedRoutes[index].route;
439 } else {
440 return nullptr;
441 }
442}
443
444
445void
446MSDevice_Vehroutes::addRoute(const std::string& info) {
447 if (myMaxRoutes > 0) {
448 //std::cout << SIMTIME << " " << getID() << " departed=" << myHolder.hasDeparted() << " lastIndex=" << myLastRouteIndex << " start=" << myHolder.getRoutePosition() << "\n";
450 myHolder.hasDeparted() ? myHolder.getEdge() : nullptr,
454 if ((int)myReplacedRoutes.size() > myMaxRoutes) {
455 myReplacedRoutes.front().route->release();
456 myReplacedRoutes.erase(myReplacedRoutes.begin());
457 }
458 } else {
460 }
463}
464
465
466void
468 for (const auto& it : myStateListener.myDevices) {
469 if (it.first->hasDeparted()) {
470 if (it.first->isStopped()) {
471 it.second->notifyStopEnded();
472 }
473 it.second->writeOutput(false);
474 }
475 }
476 // unfinished persons
477 MSNet* net = MSNet::getInstance();
478 if (net->hasPersons()) {
480 while (pc.loadedBegin() != pc.loadedEnd()) {
481 pc.erase(pc.loadedBegin()->second);
482 }
483 }
484}
485
486
487void
490}
491
492
493void
494MSDevice_Vehroutes::writeSortedOutput(MSDevice_Vehroutes::SortedRouteInfo* routeInfo, SUMOTime depart, const std::string& id, const std::string& xmlOutput) {
495 if (routeInfo->routeOut == myRouteInfos.routeOut) {
496 routeInfo = &myRouteInfos;
497 }
498 routeInfo->routeXML[depart][id] = xmlOutput;
499 routeInfo->departureCounts[depart]--;
500 std::map<const SUMOTime, int>::iterator it = routeInfo->departureCounts.begin();
501 while (it != routeInfo->departureCounts.end() && it->second == 0) {
502 for (const auto& rouXML : routeInfo->routeXML[it->first]) {
503 (*routeInfo->routeOut) << rouXML.second;
504 }
505 routeInfo->routeXML.erase(it->first);
506 it = routeInfo->departureCounts.erase(it);
507 }
508}
509
510
511void
515 std::vector<std::string> internals;
517 internals.push_back(toString(myDepartLane));
518 internals.push_back(toString(myDepartPosLat));
519 }
520 internals.push_back(toString(myDepartSpeed));
521 internals.push_back(toString(myDepartPos));
522 internals.push_back(toString(myReplacedRoutes.size()));
523 for (int i = 0; i < (int)myReplacedRoutes.size(); ++i) {
524 const std::string replacedOnEdge = myReplacedRoutes[i].edge == nullptr ? "!NULL" : myReplacedRoutes[i].edge->getID();
525 internals.push_back(replacedOnEdge);
526 internals.push_back(toString(myReplacedRoutes[i].time));
527 internals.push_back(myReplacedRoutes[i].route->getID());
528 internals.push_back(myReplacedRoutes[i].info);
529 internals.push_back(toString(myReplacedRoutes[i].lastRouteIndex));
530 internals.push_back(toString(myReplacedRoutes[i].newRouteIndex));
531 }
532 out.writeAttr(SUMO_ATTR_STATE, toString(internals));
533 if (mySaveExits && myExits.size() > 0) {
536 }
537 out.closeTag();
538}
539
540
541void
543 std::istringstream bis(attrs.getString(SUMO_ATTR_STATE));
545 bis >> myDepartLane;
546 bis >> myDepartPosLat;
547 }
548 bis >> myDepartSpeed;
549 bis >> myDepartPos;
550 int size;
551 bis >> size;
552 for (int i = 0; i < size; ++i) {
553 std::string edgeID;
554 SUMOTime time;
555 std::string routeID;
556 std::string info;
557 int lastIndex;
558 int newIndex;
559 bis >> edgeID;
560 bis >> time;
561 bis >> routeID;
562 bis >> info;
563 bis >> lastIndex;
564 bis >> newIndex;
565
566 const MSRoute* route = MSRoute::dictionary(routeID);
567 if (route != nullptr) {
568 route->addReference();
569 myReplacedRoutes.push_back(RouteReplaceInfo(MSEdge::dictionary(edgeID), time, route, info, lastIndex, newIndex));
570 }
571 }
573 bool ok = true;
574 for (const std::string& t : attrs.get<std::vector<std::string> >(SUMO_ATTR_EXITTIMES, nullptr, ok)) {
575 myExits.push_back(StringUtils::toLong(t));
576 }
577 if (attrs.hasAttribute(SUMO_ATTR_EDGE)) {
579 }
580 }
581}
582
583
584/****************************************************************************/
long long int SUMOTime
Definition: GUI.h:36
std::string time2string(SUMOTime t)
convert SUMOTime to string
Definition: SUMOTime.cpp:68
const std::string DEFAULT_VTYPE_ID
@ GIVEN
The lane is given.
@ RANDOM
The lateral position is chosen randomly.
@ GIVEN
The position is given.
@ GIVEN_VEHROUTE
The position is set by the vehroute device.
@ GIVEN
The position is given.
@ GIVEN_VEHROUTE
The position is given.
@ STOP
depart position is endPos of first stop
const int VEHPARS_SPEEDFACTOR_SET
const int VEHPARS_DEPARTPOS_SET
@ GIVEN
The speed is given.
@ GIVEN_VEHROUTE
The speed is set by the vehroute device.
@ LIMIT
The maximum lane speed is used (speedLimit)
const int VEHPARS_DEPARTLANE_SET
const int VEHPARS_FORCE_REROUTE
const int VEHPARS_DEPARTSPEED_SET
const int VEHPARS_DEPARTPOSLAT_SET
@ SUMO_TAG_DEVICE
@ SUMO_TAG_VEHICLE
description of a vehicle
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_TAG_ROUTE
begin/end of the description of a route
@ SUMO_ATTR_LAST
@ SUMO_ATTR_STARTED
@ SUMO_ATTR_REPLACED_AT_TIME
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_EXITTIMES
@ SUMO_ATTR_ENDED
@ SUMO_ATTR_COST
@ SUMO_ATTR_REPLACED_ON_INDEX
@ SUMO_ATTR_PROB
@ SUMO_ATTR_SAVINGS
@ SUMO_ATTR_ID
@ SUMO_ATTR_STATE
The state of a link.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:46
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:55
Information about a replaced route.
A class that is notified about reroutings.
std::map< const SUMOVehicle *, MSDevice_Vehroutes *, ComparatorNumericalIdLess > myDevices
A map for internal notification.
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
A device which collects info on the vehicle trip (mainly on departure and arrival)
static bool myWriteCosts
A shortcut for the Option "vehroute-output.costs".
static void writeSortedOutput(SortedRouteInfo *routeInfo, SUMOTime depart, const std::string &id, const std::string &xmlOutput)
static void init()
Static intialization.
std::vector< SUMOTime > myExits
The times at which the vehicle exits an edge.
static bool mySorted
A shortcut for the Option "vehroute-output.sorted".
static bool myIntendedDepart
A shortcut for the Option "vehroute-output.intended-depart".
void addRoute(const std::string &info)
Called on route change.
int myLastRouteIndex
The route index of the last edge that the vehicle left.
static bool myIncludeIncomplete
A shortcut for the Option "vehroute-output.incomplete".
MSDevice_Vehroutes(SUMOVehicle &holder, const std::string &id, int maxRoutes)
Constructor.
static bool myRouteLength
A shortcut for the Option "vehroute-output.route-length".
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_FCD-options.
void writeXMLRoute(OutputDevice &os, int index=-1) const
Called on route output.
static MSDevice_Vehroutes * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, int maxRoutes=std::numeric_limits< int >::max())
Build devices for the given vehicle, if needed.
static void generateOutputForUnfinished()
generate vehroute output for vehicles which are still in the network
std::vector< RouteReplaceInfo > myReplacedRoutes
Prior routes.
std::vector< const MSEdge * > myPriorEdges
the edges that were passed before the current stop
const int myMaxRoutes
The maximum number of routes to report.
static bool myWriteStopPriorEdges
A shortcut for the Option "vehroute-output.stop-edges".
double myDepartPosLat
The lateral depart position.
const MSEdge * myLastSavedAt
The last edge the exit time was saved for.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
OutputDevice_String myStopOut
double myDepartPos
The lane the vehicle departed at.
const MSRoute * getRoute(int index) const
Called on route retrieval.
static bool myLastRouteOnly
A shortcut for the Option "vehroute-output.last-route".
double myDepartSpeed
The speed on departure.
int myDepartLane
The lane the vehicle departed at.
static SortedRouteInfo myRouteInfos
Information needed to sort vehicles by departure time.
void writeOutput(const bool hasArrived) const
Called on writing vehroutes output.
~MSDevice_Vehroutes()
Destructor.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Saves exit times if needed.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Does nothing, returns true only if exit times should be collected.
static bool myWriteInternal
A shortcut for the Option "vehroute-output.internal".
static bool mySkipPTLines
A shortcut for the Option "vehroute-output.skip-ptlines".
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing vehroutes output.
const MSRoute * myCurrentRoute
The currently used route.
void notifyStopEnded()
called to update state for stopped vehicles
static bool myDUAStyle
A shortcut for the Option "vehroute-output.dua".
static bool mySaveExits
A shortcut for the Option "vehroute-output.exit-times".
static void registerTransportableDepart(SUMOTime depart)
void saveState(OutputDevice &out) const
Saves the state of the device.
static StateListener myStateListener
A class that is notified about reroutings.
static void insertDefaultAssignmentOptions(const std::string &deviceName, const std::string &optionsTopic, OptionsCont &oc, const bool isPerson=false)
Adds common command options that allow to assign devices to vehicles.
Definition: MSDevice.cpp:144
static bool equippedByDefaultAssignmentOptions(const OptionsCont &oc, const std::string &deviceName, DEVICEHOLDER &v, bool outputOptionSet, const bool isPerson=false)
Determines whether a vehicle should get a certain device.
Definition: MSDevice.h:202
A road/street connecting two junctions.
Definition: MSEdge.h:77
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary....
Definition: MSEdge.cpp:945
static bool gUseMesoSim
Definition: MSGlobals.h:103
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:78
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
int getIndex() const
Returns the lane's index.
Definition: MSLane.h:597
MSEdge & getEdge() const
Returns the lane's edge.
Definition: MSLane.h:713
Notification
Definition of a vehicle state.
@ NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
@ NOTIFICATION_SEGMENT
The vehicle changes the segment (meso only)
@ NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
@ NOTIFICATION_PARKING
The vehicle starts or ends parking.
The simulated network and simulation perfomer.
Definition: MSNet.h:88
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:603
@ NEWROUTE
The vehicle got a new route.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:183
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:321
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition: MSNet.cpp:1164
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:396
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:1096
bool hasInternalLinks() const
return whether the network contains internal links
Definition: MSNet.h:777
void addReference() const
increments the reference counter for the route
Definition: MSRoute.cpp:99
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:124
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:80
int writeEdgeIDs(OutputDevice &os, int firstIndex=0, int lastIndex=-1, bool withInternal=false, SUMOVehicleClass svc=SVC_IGNORING) const
Output the edge ids up to but not including the id of the given edge.
Definition: MSRoute.cpp:231
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:118
double getSavings() const
Returns the estimated savings due to using this route (compare to the route before rerouting)
Definition: MSRoute.h:176
void release() const
deletes the route if there are no further references to it
Definition: MSRoute.cpp:105
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
Definition: MSRoute.cpp:170
double getDistanceBetween(double fromPos, double toPos, const MSEdge *fromEdge, const MSEdge *toEdge, bool includeInternal=true, int routePosition=0) const
Compute the distance between 2 given edges on this route, including the length of internal lanes....
Definition: MSRoute.cpp:316
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:74
double getCosts() const
Returns the costs of the route.
Definition: MSRoute.h:168
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
virtual void erase(MSTransportable *transportable)
removes a single transportable
Abstract in-vehicle device.
SUMOVehicle & myHolder
The vehicle that stores the device.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:77
const MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:577
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition: MSVehicle.h:416
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:91
const std::string & getID() const
Returns the id.
Definition: Named.h:74
A storage for options typed value containers)
Definition: OptionsCont.h:89
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
bool isDefault(const std::string &name) const
Returns the information whether the named option has still the default value.
void addOptionSubTopic(const std::string &topic)
Adds an option subtopic.
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:59
An output device that encapsulates an ofstream.
std::string getString() const
Returns the current content as a string.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
void lf()
writes a line feed if applicable
Definition: OutputDevice.h:239
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:251
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
static bool createDeviceByOption(const std::string &optionName, const std::string &rootElement="", const std::string &schemaFile="")
Creates the device using the output definition stored in the named option.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void setPrecision(int precision=gPrecision)
Sets the precision or resets it to default.
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
const std::vector< T > & getVals() const
Returns the members of the distribution.
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
Encapsulated SAX-Attributes.
virtual std::string getString(int id, bool *isPresent=nullptr) const =0
Returns the string-value of the named (by its enum-value) attribute.
T get(int attr, const char *objectid, bool &ok, bool report=true) const
Tries to read given attribute assuming it is an int.
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list.
Representation of a vehicle, person, or container.
virtual NumericalID getNumericalID() const =0
return the numerical ID which is only for internal usage
virtual const MSVehicleType & getVehicleType() const =0
Returns the object's "vehicle" type.
virtual double getChosenSpeedFactor() const =0
virtual double getSpeed() const =0
Returns the object's current speed.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
virtual SUMOVehicleClass getVClass() const =0
Returns the object's access class.
virtual int getRoutePosition() const =0
return index of edge within route
virtual const MSEdge * getEdge() const =0
Returns the edge the object is currently at.
virtual double getPositionOnLane() const =0
Get the object's position along the lane.
Representation of a vehicle.
Definition: SUMOVehicle.h:60
virtual const std::list< MSStop > & getStops() const =0
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
virtual int getNumberReroutes() const =0
Returns the number of new routes this vehicle got.
virtual double getArrivalPos() const =0
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
virtual double getDepartPos() const =0
Returns this vehicle's real departure position.
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
virtual const MSRoute & getRoute() const =0
Returns the current route.
Definition of vehicle stop (position and duration)
SUMOTime started
the time at which this stop was reached
void write(OutputDevice &dev, const bool close=true, const bool writeTagAndParents=true) const
Writes the stop as XML.
SUMOTime ended
the time at which this stop was ended
Structure representing possible vehicle parameter.
double departPosLat
(optional) The lateral position the vehicle shall depart from
int parametersSet
Information for the router which parameter were set, TraCI may modify this (when changing color)
int departLane
(optional) The lane the vehicle shall depart from (index in edge)
double departSpeed
(optional) The initial speed of the vehicle
double speedFactor
individual speedFactor (overriding distribution from vType)
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag altTag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
DepartLaneDefinition departLaneProcedure
Information how the vehicle shall choose the lane to depart from.
DepartPosLatDefinition departPosLatProcedure
Information how the vehicle shall choose the lateral departure position.
double departPos
(optional) The position the vehicle shall depart from
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle's initial speed shall be chosen.
bool wasSet(int what) const
Returns whether the given parameter was set.
DepartPosDefinition departPosProcedure
Information how the vehicle shall choose the departure position.
std::string line
The vehicle's line (mainly for public transport)
static long long int toLong(const std::string &sData)
converts a string into the long value described by it by calling the char-type converter,...
Information needed to sort vehicle / transportable output by departure time.
std::map< const SUMOTime, int > departureCounts
Map needed to sort vehicles by departure time.
std::map< const SUMOTime, std::map< const std::string, std::string > > routeXML
pregenerated route output sorted by time
OutputDevice * routeOut
route output device