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