SUMO - Simulation of Urban MObility
MSBaseVehicle.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A base class for vehicle implementations
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <iostream>
34 #include <cassert>
35 #include <utils/common/StdDefs.h>
39 #include "MSGlobals.h"
40 #include "MSVehicleType.h"
41 #include "MSEdge.h"
42 #include "MSLane.h"
43 #include "MSMoveReminder.h"
44 #include "MSBaseVehicle.h"
45 #include "MSNet.h"
46 #include "devices/MSDevice.h"
48 #include "MSInsertionControl.h"
49 
50 // ===========================================================================
51 // static members
52 // ===========================================================================
54 #ifdef _DEBUG
55 std::set<std::string> MSBaseVehicle::myShallTraceMoveReminders;
56 #endif
57 
58 // ===========================================================================
59 // method definitions
60 // ===========================================================================
61 
62 double
64  throw ProcessError("getPreviousSpeed() is not available for non-MSVehicles.");
65 }
66 
67 
69  const MSVehicleType* type, const double speedFactor) :
70  myParameter(pars),
71  myRoute(route),
72  myType(type),
73  myCurrEdge(route->begin()),
74  myChosenSpeedFactor(speedFactor),
75  myMoveReminders(0),
77  myDepartPos(-1),
78  myArrivalPos(-1),
79  myArrivalLane(-1),
81 #ifdef _DEBUG
82  , myTraceMoveReminders(myShallTraceMoveReminders.count(pars->id) > 0)
83 #endif
84 {
85  if ((*myRoute->begin())->isTaz() || myRoute->getLastEdge()->isTaz()) {
87  }
88  // init devices
90  //
91  for (std::vector< MSDevice* >::iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
92  myMoveReminders.push_back(std::make_pair(*dev, 0.));
93  }
95  if (!pars->wasSet(VEHPARS_FORCE_REROUTE)) {
98  std::string msg;
99  if (!hasValidRoute(msg)) {
100  throw ProcessError("Vehicle '" + pars->id + "' has no valid route. " + msg);
101  }
102  }
103  }
104 }
105 
106 
108  myRoute->release();
109  if (myParameter->repetitionNumber == 0) {
111  }
112  for (std::vector< MSDevice* >::iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
113  delete *dev;
114  }
115  delete myParameter;
116 }
117 
118 
119 const std::string&
121  return myParameter->id;
122 }
123 
124 
127  return *myParameter;
128 }
129 
130 
131 double
133  return myType->getMaxSpeed();
134 }
135 
136 
137 const MSEdge*
138 MSBaseVehicle::succEdge(int nSuccs) const {
139  if (myCurrEdge + nSuccs < myRoute->end() && std::distance(myCurrEdge, myRoute->begin()) <= nSuccs) {
140  return *(myCurrEdge + nSuccs);
141  } else {
142  return 0;
143  }
144 }
145 
146 
147 const MSEdge*
149  return *myCurrEdge;
150 }
151 
152 
153 void
154 MSBaseVehicle::reroute(SUMOTime t, SUMOAbstractRouter<MSEdge, SUMOVehicle>& router, const bool onInit, const bool withTaz) {
155  // check whether to reroute
156  const MSEdge* source = withTaz && onInit ? MSEdge::dictionary(myParameter->fromTaz + "-source") : getRerouteOrigin();
157  if (source == 0) {
158  source = getRerouteOrigin();
159  }
160  const MSEdge* sink = withTaz ? MSEdge::dictionary(myParameter->toTaz + "-sink") : myRoute->getLastEdge();
161  if (sink == 0) {
162  sink = myRoute->getLastEdge();
163  }
164  ConstMSEdgeVector edges;
165  ConstMSEdgeVector stops;
166  if (myParameter->via.size() == 0) {
167  stops = getStopEdges();
168  } else {
169  // via takes precedence over stop edges
170  // XXX check for inconsistencies #2275
171  for (std::vector<std::string>::const_iterator it = myParameter->via.begin(); it != myParameter->via.end(); ++it) {
172  MSEdge* viaEdge = MSEdge::dictionary(*it);
173  assert(viaEdge != 0);
174  if (viaEdge->allowedLanes(getVClass()) == 0) {
175  throw ProcessError("Vehicle '" + getID() + "' is not allowed on any lane of via edge '" + viaEdge->getID() + "'.");
176  }
177  stops.push_back(viaEdge);
178  }
179  }
180 
181  for (MSRouteIterator s = stops.begin(); s != stops.end(); ++s) {
182  if (*s != source) {
183  // !!! need to adapt t here
184  router.compute(source, *s, this, t, edges);
185  source = *s;
186  edges.pop_back();
187  }
188  }
189  router.compute(source, sink, this, t, edges);
190  if (!edges.empty() && edges.front()->isTaz()) {
191  edges.erase(edges.begin());
192  }
193  if (!edges.empty() && edges.back()->isTaz()) {
194  edges.pop_back();
195  }
196  replaceRouteEdges(edges, onInit);
197  // this must be called even if the route could not be replaced
198  if (onInit) {
199  if (edges.empty()) {
201  throw ProcessError("Vehicle '" + getID() + "' has no valid route.");
202  } else if (source->isTaz()) {
203  WRITE_WARNING("Removing vehicle '" + getID() + "' which has no valid route.");
205  return;
206  }
207  }
209  }
210 }
211 
212 
213 bool
214 MSBaseVehicle::replaceRouteEdges(ConstMSEdgeVector& edges, bool onInit, bool check, bool addStops) {
215  if (edges.empty()) {
216  WRITE_WARNING("No route for vehicle '" + getID() + "' found.");
217  return false;
218  }
219  // build a new id, first
220  std::string id = getID();
221  if (id[0] != '!') {
222  id = "!" + id;
223  }
224  if (myRoute->getID().find("!var#") != std::string::npos) {
225  id = myRoute->getID().substr(0, myRoute->getID().rfind("!var#") + 5) + toString(getNumberReroutes() + 1);
226  } else {
227  id = id + "!var#1";
228  }
229  int oldSize = (int)edges.size();
230  if (!onInit) {
231  const MSEdge* const origin = getRerouteOrigin();
232  if (origin != *myCurrEdge && edges.front() == origin) {
233  edges.insert(edges.begin(), *myCurrEdge);
234  oldSize = (int)edges.size();
235  }
236  edges.insert(edges.begin(), myRoute->begin(), myCurrEdge);
237  }
238  if (edges == myRoute->getEdges()) {
239  return true;
240  }
241  const RGBColor& c = myRoute->getColor();
242  MSRoute* newRoute = new MSRoute(id, edges, false, &c == &RGBColor::DEFAULT_COLOR ? 0 : new RGBColor(c), myRoute->getStops());
243  if (!MSRoute::dictionary(id, newRoute)) {
244  delete newRoute;
245  return false;
246  }
247 
248  std::string msg;
249  if (check && !hasValidRoute(msg, newRoute)) {
250  WRITE_WARNING("Invalid route replacement for vehicle '" + getID() + "'. " + msg);
252  newRoute->addReference();
253  newRoute->release();
254  return false;
255  }
256  }
257  if (!replaceRoute(newRoute, onInit, (int)edges.size() - oldSize, addStops)) {
258  newRoute->addReference();
259  newRoute->release();
260  return false;
261  }
262  return true;
263 }
264 
265 
266 double
268  return 0;
269 }
270 
271 
272 double
274  return 0;
275 }
276 
277 
278 void
283 }
284 
285 
286 bool
288  return myDeparture != NOT_YET_DEPARTED;
289 }
290 
291 
292 bool
294  return succEdge(1) == 0;
295 }
296 
297 void
299 }
300 
301 void
303 }
304 
305 bool
306 MSBaseVehicle::hasValidRoute(std::string& msg, const MSRoute* route) const {
307  MSRouteIterator start = myCurrEdge;
308  if (route == 0) {
309  route = myRoute;
310  } else {
311  start = route->begin();
312  }
313  MSRouteIterator last = route->end() - 1;
314  // check connectivity, first
315  for (MSRouteIterator e = start; e != last; ++e) {
316  if ((*e)->allowedLanes(**(e + 1), myType->getVehicleClass()) == 0) {
317  msg = "No connection between edge '" + (*e)->getID() + "' and edge '" + (*(e + 1))->getID() + "'.";
318  return false;
319  }
320  }
321  last = route->end();
322  // check usable lanes, then
323  for (MSRouteIterator e = start; e != last; ++e) {
324  if ((*e)->prohibits(this)) {
325  msg = "Edge '" + (*e)->getID() + "' prohibits.";
326  return false;
327  }
328  }
329  return true;
330 }
331 
332 
333 void
335 #ifdef _DEBUG
336  if (myTraceMoveReminders) {
337  traceMoveReminder("add", rem, 0, true);
338  }
339 #endif
340  myMoveReminders.push_back(std::make_pair(rem, 0.));
341 }
342 
343 
344 void
346  for (MoveReminderCont::iterator r = myMoveReminders.begin(); r != myMoveReminders.end(); ++r) {
347  if (r->first == rem) {
348 #ifdef _DEBUG
349  if (myTraceMoveReminders) {
350  traceMoveReminder("remove", rem, 0, false);
351  }
352 #endif
353  myMoveReminders.erase(r);
354  return;
355  }
356  }
357 }
358 
359 
360 void
362  for (MoveReminderCont::iterator rem = myMoveReminders.begin(); rem != myMoveReminders.end();) {
363  if (rem->first->notifyEnter(*this, reason, enteredLane)) {
364 #ifdef _DEBUG
365  if (myTraceMoveReminders) {
366  traceMoveReminder("notifyEnter", rem->first, rem->second, true);
367  }
368 #endif
369  ++rem;
370  } else {
371 #ifdef _DEBUG
372  if (myTraceMoveReminders) {
373  traceMoveReminder("notifyEnter", rem->first, rem->second, false);
374  }
375 #endif
376  rem = myMoveReminders.erase(rem);
377  }
378  }
379 }
380 
381 
382 void
384  if (myRoute->getLastEdge()->isTaz()) {
385  return;
386  }
387  const std::vector<MSLane*>& lanes = myRoute->getLastEdge()->getLanes();
388  const double lastLaneLength = lanes[0]->getLength();
389  switch (myParameter->arrivalPosProcedure) {
390  case ARRIVAL_POS_GIVEN:
391  if (fabs(myParameter->arrivalPos) > lastLaneLength) {
392  WRITE_WARNING("Vehicle '" + getID() + "' will not be able to arrive at the given position!");
393  }
394  // Maybe we should warn the user about invalid inputs!
395  myArrivalPos = MIN2(myParameter->arrivalPos, lastLaneLength);
396  if (myArrivalPos < 0) {
397  myArrivalPos = MAX2(myArrivalPos + lastLaneLength, 0.);
398  }
399  break;
400  case ARRIVAL_POS_RANDOM:
401  myArrivalPos = RandHelper::rand(0., lastLaneLength);
402  break;
403  default:
404  myArrivalPos = lastLaneLength;
405  break;
406  }
408  if (myParameter->arrivalLane >= (int)lanes.size() || !lanes[myParameter->arrivalLane]->allowsVehicleClass(myType->getVehicleClass())) {
409  WRITE_WARNING("Vehicle '" + getID() + "' will not be able to arrive at the given lane '" + myRoute->getLastEdge()->getID() + "_" + toString(myParameter->arrivalLane) + "'!");
410  }
411  myArrivalLane = MIN2(myParameter->arrivalLane, (int)(lanes.size() - 1));
412  }
414  for (std::vector<MSLane*>::const_iterator l = lanes.begin(); l != lanes.end(); ++l) {
415  if (myParameter->arrivalSpeed <= (*l)->getVehicleMaxSpeed(this)) {
416  return;
417  }
418  }
419  WRITE_WARNING("Vehicle '" + getID() + "' will not be able to arrive with the given speed!");
420  }
421 }
422 
423 
424 double
426  return MAX2(0., MIN2(1., getVehicleType().getImpatience() +
428 }
429 
430 
431 MSDevice*
432 MSBaseVehicle::getDevice(const std::type_info& type) const {
433  for (std::vector<MSDevice*>::const_iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
434  if (typeid(**dev) == type) {
435  return *dev;
436  }
437  }
438  return 0;
439 }
440 
441 
442 void
444  // this saves lots of departParameters which are only needed for vehicles that did not yet depart
445  // the parameters may hold the name of a vTypeDistribution but we are interested in the actual type
447  // params and stops must be written in child classes since they may wish to add additional attributes first
449  // here starts the vehicle internal part (see loading)
450  // @note: remember to close the vehicle tag when calling this in a subclass!
451 }
452 
453 
454 void
455 MSBaseVehicle::addStops(const bool ignoreStopErrors) {
456  for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = myParameter->stops.begin(); i != myParameter->stops.end(); ++i) {
457  std::string errorMsg;
458  if (!addStop(*i, errorMsg) && !ignoreStopErrors) {
459  throw ProcessError(errorMsg);
460  }
461  if (errorMsg != "") {
462  WRITE_WARNING(errorMsg);
463  }
464  }
465  for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = myRoute->getStops().begin(); i != myRoute->getStops().end(); ++i) {
466  std::string errorMsg;
467  if (!addStop(*i, errorMsg) && !ignoreStopErrors) {
468  throw ProcessError(errorMsg);
469  }
470  if (errorMsg != "") {
471  WRITE_WARNING(errorMsg);
472  }
473  }
474 }
475 
476 
477 bool
478 MSBaseVehicle::hasDevice(const std::string& deviceName) const {
479  for (std::vector<MSDevice* >::const_iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
480  if ((*dev)->deviceName() == deviceName) {
481  return true;
482  }
483  }
484  return false;
485 }
486 
487 
488 void
489 MSBaseVehicle::createDevice(const std::string& deviceName) {
490  if (!hasDevice(deviceName)) {
491  if (deviceName == "rerouting") {
492  ((SUMOVehicleParameter*)myParameter)->addParameter("has." + deviceName + ".device", "true");
494  if (hasDeparted()) {
495  // vehicle already departed: disable pre-insertion rerouting and enable regular routing behavior
496  MSDevice_Routing* routingDevice = static_cast<MSDevice_Routing*>(getDevice(typeid(MSDevice_Routing)));
497  assert(routingDevice != 0);
498  routingDevice->notifyEnter(*this, MSMoveReminder::NOTIFICATION_DEPARTED);
499  }
500  } else {
501  throw InvalidArgument("Creating device of type '" + deviceName + "' is not supported");
502  }
503  }
504 }
505 
506 
507 std::string
508 MSBaseVehicle::getDeviceParameter(const std::string& deviceName, const std::string& key) const {
509  for (std::vector<MSDevice* >::const_iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
510  if ((*dev)->deviceName() == deviceName) {
511  return (*dev)->getParameter(key);
512  }
513  }
514  throw InvalidArgument("No device off type '" + deviceName + "' exists");
515 }
516 
517 
518 void
519 MSBaseVehicle::setDeviceParameter(const std::string& deviceName, const std::string& key, const std::string& value) {
520  for (std::vector<MSDevice* >::iterator dev = myDevices.begin(); dev != myDevices.end(); ++dev) {
521  if ((*dev)->deviceName() == deviceName) {
522  (*dev)->setParameter(key, value);
523  return;
524  }
525  }
526  throw InvalidArgument("No device off type '" + deviceName + "' exists");
527 }
528 
529 #ifdef _DEBUG
530 void
531 MSBaseVehicle::initMoveReminderOutput(const OptionsCont& oc) {
532  if (oc.isSet("movereminder-output.vehicles")) {
533  const std::vector<std::string> vehicles = oc.getStringVector("movereminder-output.vehicles");
534  myShallTraceMoveReminders.insert(vehicles.begin(), vehicles.end());
535  }
536 }
537 
538 
539 void
540 MSBaseVehicle::traceMoveReminder(const std::string& type, MSMoveReminder* rem, double pos, bool keep) const {
541  OutputDevice& od = OutputDevice::getDeviceByOption("movereminder-output");
542  od.openTag("movereminder");
543  od.writeAttr(SUMO_ATTR_TIME, STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep()));
544  od.writeAttr("veh", getID());
546  od.writeAttr("type", type);
547  od.writeAttr("pos", toString(pos));
548  od.writeAttr("keep", toString(keep));
549  od.closeTag();
550 }
551 #endif
552 
553 /****************************************************************************/
554 
void removeReminder(MSMoveReminder *rem)
Removes a MoveReminder dynamically.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
const MSVehicleType * myType
This Vehicle&#39;s type.
virtual bool replaceRoute(const MSRoute *route, bool onInit=false, int offset=0, bool addStops=true)=0
Replaces the current route by the given one.
const int VEHPARS_FORCE_REROUTE
bool hasValidRoute(std::string &msg, const MSRoute *route=0) const
Validates the current or given route.
void descheduleDeparture(SUMOVehicle *veh)
stops trying to emit the given vehicle (and delete it)
MoveReminderCont myMoveReminders
Currently relevant move reminders.
MSBaseVehicle(SUMOVehicleParameter *pars, const MSRoute *route, const MSVehicleType *type, const double speedFactor)
Constructor.
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:128
int repetitionNumber
The number of times the vehicle shall be repeatedly inserted.
bool hasDeparted() const
Returns whether this vehicle has already departed.
void release() const
deletes the route if there are no further references to it
Definition: MSRoute.cpp:105
void setDeviceParameter(const std::string &deviceName, const std::string &key, const std::string &value)
try to set the given parameter from any of the vehicles devices, raise InvalidArgument if no device p...
ArrivalLaneDefinition arrivalLaneProcedure
Information how the vehicle shall choose the lane to arrive on.
The speed is given.
const SUMOVehicleParameter & getParameter() const
Returns the vehicle&#39;s parameter (including departure definition)
double myArrivalPos
The position on the destination lane where the vehicle stops.
Notification
Definition of a vehicle state.
A device that performs vehicle rerouting based on current edge speeds.
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
const RGBColor & getColor() const
Returns the color.
Definition: MSRoute.cpp:341
const std::vector< MSLane * > * allowedLanes(const MSEdge &destination, SUMOVehicleClass vclass=SVC_IGNORING) const
Get the allowed lanes to reach the destination-edge.
Definition: MSEdge.cpp:292
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:192
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:158
T MAX2(T a, T b)
Definition: StdDefs.h:70
virtual ~MSBaseVehicle()
Destructor.
const MSRoute * myRoute
This Vehicle&#39;s route.
virtual bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false)=0
Adds a stop.
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:728
const MSEdge * getLastEdge() const
returns the destination edge
Definition: MSRoute.cpp:92
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:78
ArrivalSpeedDefinition arrivalSpeedProcedure
Information how the vehicle&#39;s end speed shall be chosen.
int myArrivalLane
The destination lane where the vehicle stops.
const SUMOVehicleParameter * myParameter
This Vehicle&#39;s parameter.
const std::string & getID() const
Returns the id.
Definition: Named.h:66
The arrival position is given.
int size() const
Returns the number of edges to pass.
Definition: MSRoute.cpp:86
int getNumberReroutes() const
Returns the number of new routes this vehicle got.
#define WRITE_WARNING(msg)
Definition: MsgHandler.h:200
bool replaceRouteEdges(ConstMSEdgeVector &edges, bool onInit=false, bool check=false, bool addStops=true)
Replaces the current route by the given edges.
The car-following model and parameter.
Definition: MSVehicleType.h:74
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:65
std::string toTaz
The vehicle&#39;s destination zone (district)
std::string getDeviceParameter(const std::string &deviceName, const std::string &key) const
try to retrieve the given parameter from any of the vehicles devices, raise InvalidArgument if no dev...
std::vector< Stop > stops
List of the stops the vehicle will make, TraCI may add entries here.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
Definition: MSDevice.cpp:79
double getMaxSpeed() const
Returns the maximum speed.
void calculateArrivalParams()
(Re-)Calculates the arrival position and lane from the vehicle parameters
A road/street connecting two junctions.
Definition: MSEdge.h:80
bool isSet(const std::string &name, bool failOnNonExistant=true) const
Returns the information whether the named option is set.
static SUMOTime gTimeToImpatience
Definition: MSGlobals.h:73
virtual void addPerson(MSTransportable *person)
Adds a person to this vehicle.
virtual const MSEdge * getRerouteOrigin() const
Returns the starting point for reroutes (usually the current edge)
double myDepartPos
The real depart position.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
void createDevice(const std::string &deviceName)
create device of the given type
std::string routeid
The vehicle&#39;s route id.
static bool gCheckRoutes
Definition: MSGlobals.h:86
#define SUMOTime_MAX
Definition: TraCIDefs.h:53
static const RGBColor DEFAULT_COLOR
The default color (for vehicle types and vehicles)
Definition: RGBColor.h:200
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:310
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:65
int arrivalLane
(optional) The lane the vehicle shall arrive on (not used yet)
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
Definition: MSNet.h:257
static double rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:62
void write(OutputDevice &dev, const OptionsCont &oc, const SumoXMLTag tag=SUMO_TAG_VEHICLE, const std::string &typeID="") const
Writes the parameters as a beginning element.
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
std::vector< std::string > getStringVector(const std::string &name) const
Returns the list of string-vector-value of the named option (only for Option_String) ...
T MIN2(T a, T b)
Definition: StdDefs.h:64
std::string fromTaz
The vehicle&#39;s origin zone (district)
double getImpatience() const
Returns this vehicles impatience.
virtual const ConstMSEdgeVector getStopEdges() const =0
Returns the list of still pending stop edges.
Something on a lane to be noticed about vehicle movement.
double arrivalPos
(optional) The position the vehicle shall arrive on
std::vector< std::string > via
List of the via-edges the vehicle must visit.
Abstract in-vehicle device.
Definition: MSDevice.h:71
trigger: the time of the step
SUMOVehicleClass getVClass() const
Returns the vehicle&#39;s access class.
The vehicle has departed (was inserted into the network)
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
Structure representing possible vehicle parameter.
MSDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
virtual bool hasArrived() const
Returns whether this vehicle has already arived (by default this is true if the vehicle has reached i...
virtual double getAcceleration() const
Returns the vehicle&#39;s acceleration.
const std::string & getDescription() const
MSInsertionControl & getInsertionControl()
Returns the insertion control.
Definition: MSNet.h:363
int setParameter
Information for the router which parameter were set, TraCI may modify this (whe changing color) ...
virtual double getPositionOnLane() const =0
Get the vehicle&#39;s position along the lane.
static OutputDevice & getDeviceByOption(const std::string &name)
Returns the device described by the option.
void onDepart()
Called when the vehicle is inserted into the network.
virtual double getSlope() const
Returns the slope of the road at vehicle&#39;s position.
A storage for options typed value containers)
Definition: OptionsCont.h:99
virtual void activateReminders(const MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
"Activates" all current move reminder
The arrival lane is given.
void addReference() const
increments the reference counter for the route
Definition: MSRoute.cpp:99
bool isTaz() const
Definition: MSEdge.h:268
int myNumberReroutes
The number of reroutings.
virtual SUMOTime getWaitingTime() const =0
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into)
Build devices for the given vehicle, if needed.
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes a new route on vehicle insertion.
const MSEdge * succEdge(int nSuccs) const
Returns the nSuccs&#39;th successor of edge the vehicle is currently at.
bool wasSet(int what) const
Returns whether the given parameter was set.
description of a vehicle
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
bool closeTag()
Closes the most recently opened tag.
bool hasDevice(const std::string &deviceName) const
check whether the vehicle is equiped with a device of the given type
long long int SUMOTime
Definition: TraCIDefs.h:52
MSRouteIterator myCurrEdge
Iterator to current route-edge.
double arrivalSpeed
(optional) The final speed of the vehicle (not used yet)
void reroute(SUMOTime t, SUMOAbstractRouter< MSEdge, SUMOVehicle > &router, const bool onInit=false, const bool withTaz=false)
Performs a rerouting using the given router.
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:74
void vehicleDeparted(const SUMOVehicle &v)
Informs this control about a vehicle&#39;s departure.
const std::string & getID() const
Returns the name of the vehicle.
void addReminder(MSMoveReminder *rem)
Adds a MoveReminder dynamically.
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
std::vector< MSDevice * > myDevices
The devices this vehicle has.
virtual void addContainer(MSTransportable *container)
Adds a container to this vehicle.
static void checkDist(const std::string &id)
Checks the distribution whether it is permanent and deletes it if not.
Definition: MSRoute.cpp:190
const std::vector< SUMOVehicleParameter::Stop > & getStops() const
Returns the stops.
Definition: MSRoute.cpp:350
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:80
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
double getPreviousSpeed() const
Returns the vehicle&#39;s previous speed.
SUMOTime myDeparture
The real departure time.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type&#39;s vehicle class.
ArrivalPosDefinition arrivalPosProcedure
Information how the vehicle shall choose the arrival position.
static const SUMOTime NOT_YET_DEPARTED
std::string id
The vehicle&#39;s id.
double myChosenSpeedFactor
A precomputed factor by which the driver wants to be faster than the speed limit. ...
static bool dictionary(const std::string &id, const MSRoute *route)
Adds a route to the dictionary.
Definition: MSRoute.cpp:118
The arrival position is chosen randomly.