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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // A device which collects info on the vehicle trip
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <microsim/MSGlobals.h>
27 #include <microsim/MSNet.h>
28 #include <microsim/MSLane.h>
29 #include <microsim/MSEdge.h>
30 #include <microsim/MSRoute.h>
31 #include <microsim/MSVehicle.h>
32 #include <microsim/MSVehicleType.h>
38 #include "MSDevice_Vehroutes.h"
39 
40 
41 // ===========================================================================
42 // static member variables
43 // ===========================================================================
48 bool MSDevice_Vehroutes::mySorted = false;
54 std::map<const SUMOTime, int> MSDevice_Vehroutes::myDepartureCounts;
55 std::map<const SUMOTime, std::map<const std::string, std::string> > MSDevice_Vehroutes::myRouteInfos;
56 
57 
58 // ===========================================================================
59 // method definitions
60 // ===========================================================================
61 // ---------------------------------------------------------------------------
62 // static initialisation methods
63 // ---------------------------------------------------------------------------
64 void
67  if (oc.isSet("vehroute-output")) {
68  OutputDevice::createDeviceByOption("vehroute-output", "routes", "routes_file.xsd");
69  mySaveExits = oc.getBool("vehroute-output.exit-times");
70  myLastRouteOnly = oc.getBool("vehroute-output.last-route");
71  myDUAStyle = oc.getBool("vehroute-output.dua");
72  myWriteCosts = oc.getBool("vehroute-output.cost");
73  mySorted = myDUAStyle || oc.getBool("vehroute-output.sorted");
74  myIntendedDepart = oc.getBool("vehroute-output.intended-depart");
75  myRouteLength = oc.getBool("vehroute-output.route-length");
76  mySkipPTLines = oc.getBool("vehroute-output.skip-ptlines");
77  myIncludeIncomplete = oc.getBool("vehroute-output.incomplete");
79  }
80 }
81 
82 
84 MSDevice_Vehroutes::buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into, int maxRoutes) {
85  if (maxRoutes < std::numeric_limits<int>::max()) {
86  return new MSDevice_Vehroutes(v, "vehroute_" + v.getID(), maxRoutes);
87  }
88  if (OptionsCont::getOptions().isSet("vehroute-output")) {
89  if (myLastRouteOnly) {
90  maxRoutes = 0;
91  }
92  myStateListener.myDevices[&v] = new MSDevice_Vehroutes(v, "vehroute_" + v.getID(), maxRoutes);
93  into.push_back(myStateListener.myDevices[&v]);
94  return myStateListener.myDevices[&v];
95  }
96  return nullptr;
97 }
98 
99 
100 // ---------------------------------------------------------------------------
101 // MSDevice_Vehroutes::StateListener-methods
102 // ---------------------------------------------------------------------------
103 void
105  if (to == MSNet::VEHICLE_STATE_NEWROUTE) {
106  myDevices[vehicle]->addRoute(info);
107  }
108 }
109 
110 
111 // ---------------------------------------------------------------------------
112 // MSDevice_Vehroutes-methods
113 // ---------------------------------------------------------------------------
114 MSDevice_Vehroutes::MSDevice_Vehroutes(SUMOVehicle& holder, const std::string& id, int maxRoutes) :
115  MSVehicleDevice(holder, id),
116  myCurrentRoute(&holder.getRoute()),
117  myMaxRoutes(maxRoutes),
118  myLastSavedAt(nullptr),
119  myDepartLane(-1),
120  myDepartPos(-1),
121  myDepartSpeed(-1),
122  myDepartPosLat(0),
123  myStopOut(false, 2) {
125 }
126 
127 
129  for (std::vector<RouteReplaceInfo>::iterator i = myReplacedRoutes.begin(); i != myReplacedRoutes.end(); ++i) {
130  (*i).route->release();
131  }
134 }
135 
136 
137 bool
139  MSVehicle& vehicle = static_cast<MSVehicle&>(veh);
141  if (mySorted && myStateListener.myDevices[&vehicle] == this) {
143  myDepartureCounts[departure]++;
144  }
145  if (!MSGlobals::gUseMesoSim) {
146  myDepartLane = vehicle.getLane()->getIndex();
148  }
149  myDepartSpeed = veh.getSpeed();
151  }
152  return mySaveExits;
153 }
154 
155 
156 bool
157 MSDevice_Vehroutes::notifyLeave(SUMOTrafficObject& veh, double /*lastPos*/, MSMoveReminder::Notification reason, const MSLane* /* enteredLane */) {
158  if (mySaveExits && reason != NOTIFICATION_LANE_CHANGE) {
159  if (reason != NOTIFICATION_TELEPORT && myLastSavedAt == veh.getEdge()) { // need to check this for internal lanes
161  } else if (myLastSavedAt != veh.getEdge()) {
162  myExits.push_back(MSNet::getInstance()->getCurrentTimeStep());
163  myLastSavedAt = veh.getEdge();
164  }
165  }
166  return mySaveExits;
167 }
168 
169 
170 void
172  stop.write(myStopOut);
173 }
174 
175 
176 void
178  if (index == 0 && !myIncludeIncomplete && myReplacedRoutes[index].route->size() == 2 &&
179  myReplacedRoutes[index].route->getEdges().front()->isTazConnector() &&
180  myReplacedRoutes[index].route->getEdges().back()->isTazConnector()) {
181  return;
182  }
183  // check if a previous route shall be written
185  if (index >= 0) {
186  assert((int)myReplacedRoutes.size() > index);
187  if (myDUAStyle || myWriteCosts) {
188  os.writeAttr(SUMO_ATTR_COST, myReplacedRoutes[index].route->getCosts());
189  }
190  if (myWriteCosts) {
191  os.writeAttr(SUMO_ATTR_SAVINGS, myReplacedRoutes[index].route->getSavings());
192  }
193  // write edge on which the vehicle was when the route was valid
194  os.writeAttr("replacedOnEdge", (myReplacedRoutes[index].edge ?
195  myReplacedRoutes[index].edge->getID() : ""));
196  // write the reason for replacement
197  os.writeAttr("reason", myReplacedRoutes[index].info);
198 
199  // write the time at which the route was replaced
200  os.writeAttr("replacedAtTime", time2string(myReplacedRoutes[index].time));
201  os.writeAttr(SUMO_ATTR_PROB, "0");
202  os << " edges=\"";
203  // get the route
204  int i = index;
205  while (i > 0 && myReplacedRoutes[i - 1].edge != nullptr && !myIncludeIncomplete) {
206  i--;
207  }
208  const MSEdge* lastEdge = nullptr;
209  for (; i < index; ++i) {
210  myReplacedRoutes[i].route->writeEdgeIDs(os, lastEdge, myReplacedRoutes[i].edge);
211  lastEdge = myReplacedRoutes[i].edge;
212  }
213  myReplacedRoutes[index].route->writeEdgeIDs(os, lastEdge);
214  } else {
215  if (myDUAStyle || myWriteCosts) {
217  }
218  if (myWriteCosts) {
220  }
221  os << " edges=\"";
222  const MSEdge* lastEdge = nullptr;
223  int numWritten = 0;
224  if (myHolder.getNumberReroutes() > 0) {
225  assert((int)myReplacedRoutes.size() <= myHolder.getNumberReroutes());
226  int i = (int)myReplacedRoutes.size();
227  while (i > 0 && myReplacedRoutes[i - 1].edge) {
228  i--;
229  }
230  for (; i < (int)myReplacedRoutes.size(); ++i) {
231  numWritten += myReplacedRoutes[i].route->writeEdgeIDs(os, lastEdge, myReplacedRoutes[i].edge);
232  lastEdge = myReplacedRoutes[i].edge;
233  }
234  }
235  const MSEdge* upTo = nullptr;
236  if (mySaveExits) {
237  int remainingWithExitTime = (int)myExits.size() - numWritten;
238  assert(remainingWithExitTime >= 0);
239  assert(remainingWithExitTime <= (int)myCurrentRoute->size());
240  if (remainingWithExitTime < (int)myCurrentRoute->size()) {
241  upTo = *(myCurrentRoute->begin() + remainingWithExitTime);
242  }
243  }
244  myCurrentRoute->writeEdgeIDs(os, lastEdge, upTo);
245  if (mySaveExits) {
246  os << "\" exitTimes=\"";
247  for (std::vector<SUMOTime>::const_iterator it = myExits.begin(); it != myExits.end(); ++it) {
248  if (it != myExits.begin()) {
249  os << " ";
250  }
251  os << time2string(*it);
252  }
253  }
254  }
255  (os << "\"").closeTag();
256 }
257 
258 
259 void
261  writeOutput(true);
262 }
263 
264 
265 void
266 MSDevice_Vehroutes::writeOutput(const bool hasArrived) const {
267  if (mySkipPTLines && myHolder.getParameter().line != "") {
268  return;
269  }
270  OutputDevice& routeOut = OutputDevice::getDeviceByOption("vehroute-output");
271  OutputDevice_String od(routeOut.isBinary(), 1);
274  if (!MSGlobals::gUseMesoSim) {
275  if (tmp.wasSet(VEHPARS_DEPARTLANE_SET)) {
276  tmp.departLaneProcedure = DEPART_LANE_GIVEN;
277  tmp.departLane = myDepartLane;
278  }
279  if (tmp.wasSet(VEHPARS_DEPARTPOSLAT_SET)) {
280  tmp.departPosLatProcedure = DEPART_POSLAT_GIVEN;
281  tmp.departPosLat = myDepartPosLat;
282  }
283  }
284  if (tmp.wasSet(VEHPARS_DEPARTPOS_SET)) {
285  tmp.departPosProcedure = DEPART_POS_GIVEN;
286  tmp.departPos = myDepartPos;
287  }
288  if (tmp.wasSet(VEHPARS_DEPARTSPEED_SET)) {
289  tmp.departSpeedProcedure = DEPART_SPEED_GIVEN;
290  tmp.departSpeed = myDepartSpeed;
291  }
292  const std::string typeID = myHolder.getVehicleType().getID() != DEFAULT_VTYPE_ID ? myHolder.getVehicleType().getID() : "";
293  tmp.write(od, OptionsCont::getOptions(), SUMO_TAG_VEHICLE, typeID);
294  if (hasArrived) {
295  od.writeAttr("arrival", time2string(MSNet::getInstance()->getCurrentTimeStep()));
296  if (myRouteLength) {
297  const bool includeInternalLengths = MSGlobals::gUsingInternalLanes && MSNet::getInstance()->hasInternalLinks();
299  myHolder.getRoute().begin(), myHolder.getCurrentRouteEdge(), includeInternalLengths);
300  od.writeAttr("routeLength", routeLength);
301  }
302  }
303  if (myDUAStyle) {
305  if (routeDist != nullptr) {
306  const std::vector<const MSRoute*>& routes = routeDist->getVals();
307  unsigned index = 0;
308  while (index < routes.size() && routes[index] != myCurrentRoute) {
309  ++index;
310  }
311  od.openTag(SUMO_TAG_ROUTE_DISTRIBUTION).writeAttr(SUMO_ATTR_LAST, index);
312  const std::vector<double>& probs = routeDist->getProbs();
313  for (int i = 0; i < (int)routes.size(); ++i) {
314  od.setPrecision();
315  od.openTag(SUMO_TAG_ROUTE);
316  od.writeAttr(SUMO_ATTR_COST, routes[i]->getCosts());
317  if (myWriteCosts) {
318  od.writeAttr(SUMO_ATTR_SAVINGS, routes[i]->getSavings());
319  }
320  od.setPrecision(8);
321  od.writeAttr(SUMO_ATTR_PROB, probs[i]);
322  od.setPrecision();
323  od << " edges=\"";
324  routes[i]->writeEdgeIDs(od, *routes[i]->begin());
325  (od << "\"").closeTag();
326  }
327  od.closeTag();
328  } else {
329  writeXMLRoute(od);
330  }
331  } else {
332  const int routesToSkip = myHolder.getParameter().wasSet(VEHPARS_FORCE_REROUTE) && !myIncludeIncomplete ? 1 : 0;
333  if ((int)myReplacedRoutes.size() > routesToSkip) {
334  od.openTag(SUMO_TAG_ROUTE_DISTRIBUTION);
335  for (int i = routesToSkip; i < (int)myReplacedRoutes.size(); ++i) {
336  writeXMLRoute(od, i);
337  }
338  writeXMLRoute(od);
339  od.closeTag();
340  } else {
341  writeXMLRoute(od);
342  }
343  }
344  od << myStopOut.getString();
346  od.closeTag();
347  od.lf();
348  if (mySorted) {
349  myRouteInfos[tmp.depart][myHolder.getID()] = od.getString();
350  myDepartureCounts[tmp.depart]--;
351  std::map<const SUMOTime, int>::iterator it = myDepartureCounts.begin();
352  while (it != myDepartureCounts.end() && it->second == 0) {
353  std::map<const std::string, std::string>& infos = myRouteInfos[it->first];
354  for (std::map<const std::string, std::string>::const_iterator it2 = infos.begin(); it2 != infos.end(); ++it2) {
355  routeOut << it2->second;
356  }
357  myRouteInfos.erase(it->first);
358  myDepartureCounts.erase(it);
359  it = myDepartureCounts.begin();
360  }
361  } else {
362  routeOut << od.getString();
363  }
364 }
365 
366 
367 const MSRoute*
369  if (index < (int)myReplacedRoutes.size()) {
370  return myReplacedRoutes[index].route;
371  } else {
372  return nullptr;
373  }
374 }
375 
376 
377 void
378 MSDevice_Vehroutes::addRoute(const std::string& info) {
379  if (myMaxRoutes > 0) {
380  if (myHolder.hasDeparted()) {
382  } else {
383  myReplacedRoutes.push_back(RouteReplaceInfo(nullptr, MSNet::getInstance()->getCurrentTimeStep(), myCurrentRoute, info));
384  }
385  if ((int)myReplacedRoutes.size() > myMaxRoutes) {
386  myReplacedRoutes.front().route->release();
387  myReplacedRoutes.erase(myReplacedRoutes.begin());
388  }
389  } else {
391  }
394 }
395 
396 
397 void
399  for (const auto& it : myStateListener.myDevices) {
400  if (it.first->hasDeparted()) {
401  it.second->writeOutput(false);
402  }
403  }
404  // unfinished persons
405  MSNet* net = MSNet::getInstance();
406  if (net->hasPersons()) {
408  while (pc.loadedBegin() != pc.loadedEnd()) {
409  pc.erase(pc.loadedBegin()->second);
410  }
411  }
412 }
413 
414 
415 void
418  out.writeAttr(SUMO_ATTR_ID, getID());
419  std::vector<std::string> internals;
420  if (!MSGlobals::gUseMesoSim) {
421  internals.push_back(toString(myDepartLane));
422  internals.push_back(toString(myDepartPosLat));
423  }
424  internals.push_back(toString(myDepartSpeed));
425  internals.push_back(toString(myDepartPos));
426  internals.push_back(toString(myReplacedRoutes.size()));
427  for (int i = 0; i < (int)myReplacedRoutes.size(); ++i) {
428  const std::string replacedOnEdge = myReplacedRoutes[i].edge == nullptr ? "!NULL" : myReplacedRoutes[i].edge->getID();
429  internals.push_back(replacedOnEdge);
430  internals.push_back(toString(myReplacedRoutes[i].time));
431  internals.push_back(myReplacedRoutes[i].route->getID());
432  internals.push_back(myReplacedRoutes[i].info);
433  }
434  out.writeAttr(SUMO_ATTR_STATE, toString(internals));
435  out.closeTag();
436 }
437 
438 
439 void
441  std::istringstream bis(attrs.getString(SUMO_ATTR_STATE));
442  if (!MSGlobals::gUseMesoSim) {
443  bis >> myDepartLane;
444  bis >> myDepartPosLat;
445  }
446  bis >> myDepartSpeed;
447  bis >> myDepartPos;
448  int size;
449  bis >> size;
450  for (int i = 0; i < size; ++i) {
451  std::string edgeID;
452  SUMOTime time;
453  std::string routeID;
454  std::string info;
455  bis >> edgeID;
456  bis >> time;
457  bis >> routeID;
458  bis >> info;
459  const MSRoute* route = MSRoute::dictionary(routeID);
460  route->addReference();
461  myReplacedRoutes.push_back(RouteReplaceInfo(MSEdge::dictionary(edgeID), time, route, info));
462  }
463 }
464 
465 
466 /****************************************************************************/
static std::map< const SUMOTime, int > myDepartureCounts
Map needed to sort vehicles by departure time.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
const int myMaxRoutes
The maximum number of routes to report.
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
The position is given.
long long int SUMOTime
Definition: SUMOTime.h:35
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
const int VEHPARS_FORCE_REROUTE
virtual double getArrivalPos() const =0
Returns this vehicle&#39;s desired arrivalPos for its current route (may change on reroute) ...
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:354
const MSRoute * myCurrentRoute
The currently used route.
static bool myWriteCosts
A shortcut for the Option "vehroute-output.costs".
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle&#39;s type.
virtual const std::string & getID() const =0
Get the vehicle&#39;s ID.
static StateListener myStateListener
A class that is notified about reroutings.
void release() const
deletes the route if there are no further references to it
Definition: MSRoute.cpp:101
virtual const MSRoute & getRoute() const =0
Returns the current route.
Represents a generic random distribution.
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:561
distribution of a route
static bool myDUAStyle
A shortcut for the Option "vehroute-output.dua".
std::string getString() const
Returns the current content as a string.
The position is given.
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
Notification
Definition of a vehicle state.
SUMOVehicle & myHolder
The vehicle that stores the device.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:65
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:168
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn&#39;t already in the dictionary...
Definition: MSEdge.cpp:804
const std::vector< T > & getVals() const
Returns the members of the distribution.
std::vector< SUMOTime > myExits
The times the vehicle exites an edge.
static bool mySorted
A shortcut for the Option "vehroute-output.sorted".
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
double getCosts() const
Returns the costs of the route.
Definition: MSRoute.h:160
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
Definition: MSRoute.cpp:157
const std::string & getID() const
Returns the id.
Definition: Named.h:77
int size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp:82
const std::string DEFAULT_VTYPE_ID
static bool mySaveExits
A shortcut for the Option "vehroute-output.exit-times".
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition: MSNet.cpp:865
void writeXMLRoute(OutputDevice &os, int index=-1) const
Called on route output.
begin/end of the description of a route
The simulated network and simulation perfomer.
Definition: MSNet.h:92
The speed is given.
static bool myIntendedDepart
A shortcut for the Option "vehroute-output.intended-depart".
virtual void erase(MSTransportable *transportable)
removes a single transportable
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
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.
The lane is given.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
The state of a link.
void generateOutput() const
Called on writing vehroutes output.
static void init()
Static intialization.
void stopEnded(const SUMOVehicleParameter::Stop &stop)
A road/street connecting two junctions.
Definition: MSEdge.h:76
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
The vehicle changes lanes (micro only)
int myDepartLane
The lane the vehicle departed at.
static bool myLastRouteOnly
A shortcut for the Option "vehroute-output.last-route".
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Saves exit times if needed.
int getIndex() const
Returns the lane&#39;s index.
Definition: MSLane.h:564
The vehicle got a new route.
Definition: MSNet.h:548
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
Representation of a vehicle.
Definition: SUMOVehicle.h:61
double getSavings() const
Returns the estimated savings due to using this route (compare to the route before rerouting) ...
Definition: MSRoute.h:168
Encapsulated SAX-Attributes.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:798
const int VEHPARS_DEPARTSPEED_SET
virtual int getNumberReroutes() const =0
Returns the number of new routes this vehicle got.
double myDepartPosLat
The lateral depart position.
void addRoute(const std::string &info)
Called on route change.
std::vector< RouteReplaceInfo > myReplacedRoutes
Prior routes.
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
const int VEHPARS_DEPARTPOSLAT_SET
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:284
bool hasInternalLinks() const
return whether the network contains internal links
Definition: MSNet.h:642
A class that is notified about reroutings.
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:69
void write(OutputDevice &dev) const
Writes the stop as XML.
int writeEdgeIDs(OutputDevice &os, const MSEdge *const from, const MSEdge *const upTo=0) const
Output the edge ids up to but not including the id of the given edge.
Definition: MSRoute.cpp:218
static void generateOutputForUnfinished()
generate vehroute output for vehicles which are still in the network
std::map< const SUMOVehicle *, MSDevice_Vehroutes *, ComparatorNumericalIdLess > myDevices
A map for internal notification.
static bool mySkipPTLines
A shortcut for the Option "vehroute-output.skip-ptlines".
void writeOutput(const bool hasArrived) const
Called on writing vehroutes output.
std::string line
The vehicle&#39;s line (mainly for public transport)
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
double getLateralPositionOnLane() const
Get the vehicle&#39;s lateral position on the lane.
Definition: MSVehicle.h:434
Definition of vehicle stop (position and duration)
static bool myRouteLength
A shortcut for the Option "vehroute-output.route-length".
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:536
void saveState(OutputDevice &out) const
Saves the state of the device.
virtual double getDepartPos() const =0
Returns this vehicle&#39;s real departure position.
The vehicle has departed (was inserted into the network)
Structure representing possible vehicle parameter.
Representation of a vehicle or person.
virtual SUMOTime getDeparture() const =0
Returns this vehicle&#39;s real departure time.
double myDepartSpeed
The speed on departure.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle&#39;s parameter (including departure definition)
MSDevice_Vehroutes(SUMOVehicle &holder, const std::string &id, int maxRoutes)
Constructor.
A storage for options typed value containers)
Definition: OptionsCont.h:90
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:94
const int VEHPARS_DEPARTLANE_SET
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
OutputDevice_String myStopOut
void addReference() const
increments the reference counter for the route
Definition: MSRoute.cpp:95
Abstract in-vehicle device.
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
bool wasSet(int what) const
Returns whether the given parameter was set.
description of a vehicle
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.
virtual double getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
const MSRoute * getRoute(int index) const
Called on route retrieval.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:70
static std::map< const SUMOTime, std::map< const std::string, std::string > > myRouteInfos
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Does nothing, returns true only if exit times should be collected.
const int VEHPARS_DEPARTPOS_SET
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
virtual double getSpeed() const =0
Returns the vehicle&#39;s current speed.
bool isBinary() const
Returns whether we have a binary output.
Definition: OutputDevice.h:244
double myDepartPos
The lane the vehicle departed at.
static bool gUseMesoSim
Definition: MSGlobals.h:91
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
static bool myIncludeIncomplete
A shortcut for the Option "vehroute-output.incomplete".
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
An output device that encapsulates an ofstream.
The vehicle is being teleported.
const MSEdge * myLastSavedAt
The last edge the exit time was saved for.
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:114
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:277
~MSDevice_Vehroutes()
Destructor.
Information about a replaced route.