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 /****************************************************************************/
MSDevice_Vehroutes::myDUAStyle
static bool myDUAStyle
A shortcut for the Option "vehroute-output.dua".
Definition: MSDevice_Vehroutes.h:185
OptionsCont::isSet
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
Definition: OptionsCont.cpp:136
MSMoveReminder::NOTIFICATION_LANE_CHANGE
The vehicle changes lanes (micro only)
Definition: MSMoveReminder.h:97
MSNet::hasInternalLinks
bool hasInternalLinks() const
return whether the network contains internal links
Definition: MSNet.h:642
MSDevice_Vehroutes::getRoute
const MSRoute * getRoute(int index) const
Called on route retrieval.
Definition: MSDevice_Vehroutes.cpp:368
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:48
OutputDevice::createDeviceByOption
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.
Definition: OutputDevice.cpp:102
MSDevice_Vehroutes::myRouteInfos
static std::map< const SUMOTime, std::map< const std::string, std::string > > myRouteInfos
Definition: MSDevice_Vehroutes.h:233
MSRoute::release
void release() const
deletes the route if there are no further references to it
Definition: MSRoute.cpp:101
MSVehicleType::getID
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:94
SUMOVehicleParameter::wasSet
bool wasSet(int what) const
Returns whether the given parameter was set.
Definition: SUMOVehicleParameter.h:306
MSNet.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
OutputDevice_String
An output device that encapsulates an ofstream.
Definition: OutputDevice_String.h:40
MSDevice_Vehroutes::myIncludeIncomplete
static bool myIncludeIncomplete
A shortcut for the Option "vehroute-output.incomplete".
Definition: MSDevice_Vehroutes.h:203
SUMOSAXAttributes::getString
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
SUMOVehicle::getParameter
virtual const SUMOVehicleParameter & getParameter() const =0
Returns the vehicle's parameter (including departure definition)
MSDevice_Vehroutes::StateListener::myDevices
std::map< const SUMOVehicle *, MSDevice_Vehroutes *, ComparatorNumericalIdLess > myDevices
A map for internal notification.
Definition: MSDevice_Vehroutes.h:221
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
MSDevice_Vehroutes::loadState
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
Definition: MSDevice_Vehroutes.cpp:440
MSDevice_Vehroutes::myExits
std::vector< SUMOTime > myExits
The times the vehicle exites an edge.
Definition: MSDevice_Vehroutes.h:279
SUMO_ATTR_LAST
Definition: SUMOXMLDefinitions.h:624
MSDevice_Vehroutes::generateOutput
void generateOutput() const
Called on writing vehroutes output.
Definition: MSDevice_Vehroutes.cpp:260
MSDevice_Vehroutes::notifyEnter
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Does nothing, returns true only if exit times should be collected.
Definition: MSDevice_Vehroutes.cpp:138
SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
Definition: SUMOXMLDefinitions.h:215
OptionsCont.h
SUMOTrafficObject::getEdge
virtual const MSEdge * getEdge() const =0
Returns the edge the vehicle is currently at.
MSDevice_Vehroutes::init
static void init()
Static intialization.
Definition: MSDevice_Vehroutes.cpp:65
SUMOTrafficObject::getVehicleType
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
SUMOTrafficObject::getID
virtual const std::string & getID() const =0
Get the vehicle's ID.
VEHPARS_FORCE_REROUTE
const int VEHPARS_FORCE_REROUTE
Definition: SUMOVehicleParameter.h:63
MSTransportableControl::erase
virtual void erase(MSTransportable *transportable)
removes a single transportable
Definition: MSTransportableControl.cpp:86
MSNet
The simulated network and simulation perfomer.
Definition: MSNet.h:92
SUMOVehicle::getCurrentRouteEdge
virtual const ConstMSEdgeVector::const_iterator & getCurrentRouteEdge() const =0
Returns an iterator pointing to the current edge in this vehicles route.
MSDevice_Vehroutes::mySaveExits
static bool mySaveExits
A shortcut for the Option "vehroute-output.exit-times".
Definition: MSDevice_Vehroutes.h:179
OutputDevice::isBinary
bool isBinary() const
Returns whether we have a binary output.
Definition: OutputDevice.h:244
MSDevice_Vehroutes::myMaxRoutes
const int myMaxRoutes
The maximum number of routes to report.
Definition: MSDevice_Vehroutes.h:282
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:61
OptionsCont::getBool
bool getBool(const std::string &name) const
Returns the boolean-value of the named option (only for Option_Bool)
Definition: OptionsCont.cpp:223
OptionsCont::getOptions
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:58
MSDevice_Vehroutes::myDepartPosLat
double myDepartPosLat
The lateral depart position.
Definition: MSDevice_Vehroutes.h:297
MSNet::hasPersons
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:354
MSGlobals::gUseMesoSim
static bool gUseMesoSim
Definition: MSGlobals.h:91
SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:379
SUMOVehicleParameter
Structure representing possible vehicle parameter.
Definition: SUMOVehicleParameter.h:291
MSEdge.h
MSDevice_Vehroutes::notifyLeave
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, Notification reason, const MSLane *enteredLane=0)
Saves exit times if needed.
Definition: MSDevice_Vehroutes.cpp:157
MSDevice_Vehroutes::myDepartureCounts
static std::map< const SUMOTime, int > myDepartureCounts
Map needed to sort vehicles by departure time.
Definition: MSDevice_Vehroutes.h:230
MSVehicleDevice::myHolder
SUMOVehicle & myHolder
The vehicle that stores the device.
Definition: MSVehicleDevice.h:85
SUMO_ATTR_COST
Definition: SUMOXMLDefinitions.h:625
MSDevice_Vehroutes::StateListener
A class that is notified about reroutings.
Definition: MSDevice_Vehroutes.h:209
MSNet::VEHICLE_STATE_NEWROUTE
The vehicle got a new route.
Definition: MSNet.h:548
MSRoute
Definition: MSRoute.h:67
SUMOVehicleParameter::depart
SUMOTime depart
Definition: SUMOVehicleParameter.h:476
MSDevice_Vehroutes::myCurrentRoute
const MSRoute * myCurrentRoute
The currently used route.
Definition: MSDevice_Vehroutes.h:273
VEHPARS_DEPARTSPEED_SET
const int VEHPARS_DEPARTSPEED_SET
Definition: SUMOVehicleParameter.h:50
OutputDevice_String::getString
std::string getString() const
Returns the current content as a string.
Definition: OutputDevice_String.cpp:44
Parameterised::writeParams
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
Definition: Parameterised.cpp:111
MSVehicle.h
OutputDevice::closeTag
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
Definition: OutputDevice.cpp:254
MSDevice_Vehroutes::myWriteCosts
static bool myWriteCosts
A shortcut for the Option "vehroute-output.costs".
Definition: MSDevice_Vehroutes.h:188
MSVehicleType.h
MSVehicle::getLateralPositionOnLane
double getLateralPositionOnLane() const
Get the vehicle's lateral position on the lane.
Definition: MSVehicle.h:434
MSRoute::getCosts
double getCosts() const
Returns the costs of the route.
Definition: MSRoute.h:160
MSTransportableControl
Definition: MSTransportableControl.h:52
SUMOVehicleParameter::line
std::string line
The vehicle's line (mainly for public transport)
Definition: SUMOVehicleParameter.h:555
MSDevice_Vehroutes::myStateListener
static StateListener myStateListener
A class that is notified about reroutings.
Definition: MSDevice_Vehroutes.h:227
SUMOVehicle::getDeparture
virtual SUMOTime getDeparture() const =0
Returns this vehicle's real departure time.
SUMOVehicle::getRoute
virtual const MSRoute & getRoute() const =0
Returns the current route.
OutputDevice::writeAttr
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
MSRoute::size
int size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp:82
SUMOVehicle.h
MSDevice_Vehroutes::myRouteLength
static bool myRouteLength
A shortcut for the Option "vehroute-output.route-length".
Definition: MSDevice_Vehroutes.h:197
MSDevice_Vehroutes::saveState
void saveState(OutputDevice &out) const
Saves the state of the device.
Definition: MSDevice_Vehroutes.cpp:416
SUMO_ATTR_PROB
Definition: SUMOXMLDefinitions.h:627
MSDevice_Vehroutes::mySorted
static bool mySorted
A shortcut for the Option "vehroute-output.sorted".
Definition: MSDevice_Vehroutes.h:191
MSTransportableControl.h
MSNet::VehicleState
VehicleState
Definition of a vehicle state.
Definition: MSNet.h:536
MSRoute::distDictionary
static RandomDistributor< const MSRoute * > * distDictionary(const std::string &id)
Returns the named route distribution.
Definition: MSRoute.cpp:157
MSDevice_Vehroutes::buildVehicleDevices
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.
Definition: MSDevice_Vehroutes.cpp:84
DEPART_SPEED_GIVEN
The speed is given.
Definition: SUMOVehicleParameter.h:190
MSNet::getCurrentTimeStep
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:284
DEFAULT_VTYPE_ID
const std::string DEFAULT_VTYPE_ID
MSEdge::dictionary
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:804
MSDevice_Vehroutes::mySkipPTLines
static bool mySkipPTLines
A shortcut for the Option "vehroute-output.skip-ptlines".
Definition: MSDevice_Vehroutes.h:200
MSDevice_Vehroutes::generateOutputForUnfinished
static void generateOutputForUnfinished()
generate vehroute output for vehicles which are still in the network
Definition: MSDevice_Vehroutes.cpp:398
MSDevice_Vehroutes::RouteReplaceInfo
Information about a replaced route.
Definition: MSDevice_Vehroutes.h:245
DEPART_LANE_GIVEN
The lane is given.
Definition: SUMOVehicleParameter.h:116
MSDevice_Vehroutes::writeXMLRoute
void writeXMLRoute(OutputDevice &os, int index=-1) const
Called on route output.
Definition: MSDevice_Vehroutes.cpp:177
MSNet::addVehicleStateListener
void addVehicleStateListener(VehicleStateListener *listener)
Adds a vehicle states listener.
Definition: MSNet.cpp:865
SUMO_TAG_DEVICE
Definition: SUMOXMLDefinitions.h:272
MSTransportableControl::loadedBegin
constVehIt loadedBegin() const
Returns the begin of the internal transportables map.
Definition: MSTransportableControl.h:150
MSRoute::getSavings
double getSavings() const
Returns the estimated savings due to using this route (compare to the route before rerouting)
Definition: MSRoute.h:168
time2string
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:65
MSGlobals.h
SUMOVehicleParameter::Stop::write
void write(OutputDevice &dev) const
Writes the stop as XML.
Definition: SUMOVehicleParameter.cpp:167
OptionsCont
A storage for options typed value containers)
Definition: OptionsCont.h:90
MSEdge
A road/street connecting two junctions.
Definition: MSEdge.h:76
MSDevice_Vehroutes::StateListener::vehicleStateChanged
void vehicleStateChanged(const SUMOVehicle *const vehicle, MSNet::VehicleState to, const std::string &info="")
Called if a vehicle changes its state.
Definition: MSDevice_Vehroutes.cpp:104
MSDevice_Vehroutes::myLastRouteOnly
static bool myLastRouteOnly
A shortcut for the Option "vehroute-output.last-route".
Definition: MSDevice_Vehroutes.h:182
MSDevice_Vehroutes::myDepartLane
int myDepartLane
The lane the vehicle departed at.
Definition: MSDevice_Vehroutes.h:288
RandomDistributor::getProbs
const std::vector< double > & getProbs() const
Returns the probabilities assigned to the members of the distribution.
Definition: RandomDistributor.h:160
MSMoveReminder::NOTIFICATION_DEPARTED
The vehicle has departed (was inserted into the network)
Definition: MSMoveReminder.h:91
SUMO_TAG_VEHICLE
description of a vehicle
Definition: SUMOXMLDefinitions.h:120
MSDevice_Vehroutes::myIntendedDepart
static bool myIntendedDepart
A shortcut for the Option "vehroute-output.intended-depart".
Definition: MSDevice_Vehroutes.h:194
MSDevice_Vehroutes::MSDevice_Vehroutes
MSDevice_Vehroutes(SUMOVehicle &holder, const std::string &id, int maxRoutes)
Constructor.
Definition: MSDevice_Vehroutes.cpp:114
RandomDistributor< const MSRoute * >
VEHPARS_DEPARTLANE_SET
const int VEHPARS_DEPARTLANE_SET
Definition: SUMOVehicleParameter.h:48
MSGlobals::gUsingInternalLanes
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
Definition: MSGlobals.h:69
MSVehicle::getLane
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MSVehicle.h:561
MSDevice_Vehroutes::stopEnded
void stopEnded(const SUMOVehicleParameter::Stop &stop)
Definition: MSDevice_Vehroutes.cpp:171
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:240
toString
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:48
MSDevice_Vehroutes::addRoute
void addRoute(const std::string &info)
Called on route change.
Definition: MSDevice_Vehroutes.cpp:378
MSDevice_Vehroutes::myDepartPos
double myDepartPos
The lane the vehicle departed at.
Definition: MSDevice_Vehroutes.h:291
SUMO_ATTR_STATE
The state of a link.
Definition: SUMOXMLDefinitions.h:705
VEHPARS_DEPARTPOSLAT_SET
const int VEHPARS_DEPARTPOSLAT_SET
Definition: SUMOVehicleParameter.h:67
MSNet::getInstance
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:168
MSTransportableControl::loadedEnd
constVehIt loadedEnd() const
Returns the end of the internal transportables map.
Definition: MSTransportableControl.h:158
MSNet::getPersonControl
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:798
MSRoute::writeEdgeIDs
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
MSDevice_Vehroutes
A device which collects info on the vehicle trip (mainly on departure and arrival)
Definition: MSDevice_Vehroutes.h:53
SUMOVehicle::hasDeparted
virtual bool hasDeparted() const =0
Returns whether this vehicle has departed.
VEHPARS_DEPARTPOS_SET
const int VEHPARS_DEPARTPOS_SET
Definition: SUMOVehicleParameter.h:49
SUMO_ATTR_SAVINGS
Definition: SUMOXMLDefinitions.h:626
MSDevice_Vehroutes::myLastSavedAt
const MSEdge * myLastSavedAt
The last edge the exit time was saved for.
Definition: MSDevice_Vehroutes.h:285
SUMOVehicle::getNumberReroutes
virtual int getNumberReroutes() const =0
Returns the number of new routes this vehicle got.
OutputDevice_String.h
MSRoute.h
SUMOSAXAttributes.h
MSDevice_Vehroutes::myReplacedRoutes
std::vector< RouteReplaceInfo > myReplacedRoutes
Prior routes.
Definition: MSDevice_Vehroutes.h:276
MSDevice_Vehroutes::writeOutput
void writeOutput(const bool hasArrived) const
Called on writing vehroutes output.
Definition: MSDevice_Vehroutes.cpp:266
MSDevice_Vehroutes.h
SUMOVehicle::getArrivalPos
virtual double getArrivalPos() const =0
Returns this vehicle's desired arrivalPos for its current route (may change on reroute)
MSRoute::begin
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:70
SUMO_TAG_ROUTE
begin/end of the description of a route
Definition: SUMOXMLDefinitions.h:126
MSRoute::dictionary
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:114
config.h
MSDevice_Vehroutes::~MSDevice_Vehroutes
~MSDevice_Vehroutes()
Destructor.
Definition: MSDevice_Vehroutes.cpp:128
DEPART_POS_GIVEN
The position is given.
Definition: SUMOVehicleParameter.h:140
MSRoute::addReference
void addReference() const
increments the reference counter for the route
Definition: MSRoute.cpp:95
MSLane.h
SUMOTrafficObject::getPositionOnLane
virtual double getPositionOnLane() const =0
Get the vehicle's position along the lane.
MSRoute::getDistanceBetween
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
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:57
Named::getID
const std::string & getID() const
Returns the id.
Definition: Named.h:77
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:89
DEPART_POSLAT_GIVEN
The position is given.
Definition: SUMOVehicleParameter.h:164
SUMOVehicle::getDepartPos
virtual double getDepartPos() const =0
Returns this vehicle's real departure position.
OutputDevice::getDeviceByOption
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
Definition: OutputDevice.cpp:117
MSLane::getIndex
int getIndex() const
Returns the lane's index.
Definition: MSLane.h:564
MSDevice_Vehroutes::myStopOut
OutputDevice_String myStopOut
Definition: MSDevice_Vehroutes.h:299
MSMoveReminder::NOTIFICATION_TELEPORT
The vehicle is being teleported.
Definition: MSMoveReminder.h:101
RandomDistributor::getVals
const std::vector< T > & getVals() const
Returns the members of the distribution.
Definition: RandomDistributor.h:149
SUMOVehicleParameter::Stop
Definition of vehicle stop (position and duration)
Definition: SUMOVehicleParameter.h:566
SUMOTrafficObject::getSpeed
virtual double getSpeed() const =0
Returns the vehicle's current speed.
MSDevice_Vehroutes::myDepartSpeed
double myDepartSpeed
The speed on departure.
Definition: MSDevice_Vehroutes.h:294
MSVehicle
Representation of a vehicle in the micro simulation.
Definition: MSVehicle.h:80
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:55