SUMO - Simulation of Urban MObility
MEVehicle.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 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 /****************************************************************************/
15 // A vehicle from the mesoscopic point of view
16 /****************************************************************************/
17 
18 
19 // ===========================================================================
20 // included modules
21 // ===========================================================================
22 #include <config.h>
23 
24 #include <iostream>
25 #include <cassert>
26 #include <utils/common/StdDefs.h>
34 #include <microsim/MSGlobals.h>
35 #include <microsim/MSEdge.h>
36 #include <microsim/MSLane.h>
37 #include <microsim/MSNet.h>
38 #include <microsim/MSVehicleType.h>
39 #include <microsim/MSLink.h>
43 #include "MELoop.h"
44 #include "MEVehicle.h"
45 #include "MESegment.h"
46 
47 
48 // ===========================================================================
49 // method definitions
50 // ===========================================================================
52  MSVehicleType* type, const double speedFactor) :
53  MSBaseVehicle(pars, route, type, speedFactor),
54  mySegment(nullptr),
55  myQueIndex(0),
56  myEventTime(SUMOTime_MIN),
57  myLastEntryTime(SUMOTime_MIN),
58  myBlockTime(SUMOTime_MAX) {
59  if (!(*myCurrEdge)->isTazConnector()) {
60  if ((*myCurrEdge)->allowedLanes(type->getVehicleClass()) == nullptr) {
61  throw ProcessError("Vehicle '" + pars->id + "' is not allowed to depart on any lane of its first edge.");
62  }
63  if (pars->departSpeedProcedure == DEPART_SPEED_GIVEN && pars->departSpeed > type->getMaxSpeed()) {
64  throw ProcessError("Departure speed for vehicle '" + pars->id +
65  "' is too high for the vehicle type '" + type->getID() + "'.");
66  }
67  }
68 }
69 
70 
71 double
72 MEVehicle::getBackPositionOnLane(const MSLane* /* lane */) const {
74 }
75 
76 
77 double
79 // the following interpolation causes problems with arrivals and calibrators
80 // const double fracOnSegment = MIN2(double(1), STEPS2TIME(MSNet::getInstance()->getCurrentTimeStep() - myLastEntryTime) / STEPS2TIME(myEventTime - myLastEntryTime));
81  return mySegment == nullptr ? 0 : (double(mySegment->getIndex()) /* + fracOnSegment */) * mySegment->getLength();
82 }
83 
84 
85 double
87  const MSLane* const lane = getEdge()->getLanes()[0];
89 }
90 
91 
92 double
94  const MSLane* const lane = getEdge()->getLanes()[0];
96 }
97 
98 
100 MEVehicle::getPosition(const double offset) const {
101  const MSLane* const lane = getEdge()->getLanes()[0];
102  return lane->geometryPositionAtOffset(getPositionOnLane() + offset);
103 }
104 
105 
106 double
108  if (getWaitingTime() > 0) {
109  return 0;
110  } else {
111  return getAverageSpeed();
112  }
113 }
114 
115 
116 double
119 }
120 
121 
122 double
125  const double v = getSpeed();
126  return MIN2(link->getViaLaneOrLane()->getVehicleMaxSpeed(this),
127  (double)sqrt(2 * link->getLength() * getVehicleType().getCarFollowModel().getMaxAccel() + v * v));
128 }
129 
130 
131 double
132 MEVehicle::getConservativeSpeed(SUMOTime& earliestArrival) const {
133  earliestArrival = MAX2(myEventTime, earliestArrival - DELTA_T); // event times have subsecond resolution
134  return mySegment->getLength() / STEPS2TIME(earliestArrival - myLastEntryTime);
135 }
136 
137 
138 bool
140  // vehicle has just entered a new edge. Position is 0
141  if (myCurrEdge == myRoute->end() - 1) { // may happen during teleport
142  return true;
143  }
144  ++myCurrEdge;
145  if ((*myCurrEdge)->isVaporizing()) {
146  return true;
147  }
148  // update via
149  if (myParameter->via.size() > 0 && (*myCurrEdge)->getID() == myParameter->via.front()) {
150  myParameter->via.erase(myParameter->via.begin());
151  }
152  return hasArrived();
153 }
154 
155 
156 bool
158  // mySegment may be 0 due to teleporting or arrival
159  return myCurrEdge == myRoute->end() - 1 && (
160  (mySegment == nullptr)
163 }
164 
165 bool
167  return getSegment() != nullptr;
168 }
169 
170 
171 bool
173  return false; // parking attribute of a stop is not yet evaluated /implemented
174 }
175 
176 
177 bool
178 MEVehicle::replaceRoute(const MSRoute* newRoute, const std::string& info, bool onInit, int offset, bool addStops, bool removeStops) {
179  UNUSED_PARAMETER(addStops); // @todo recheck!
180  UNUSED_PARAMETER(removeStops); // @todo recheck!
181  const ConstMSEdgeVector& edges = newRoute->getEdges();
182  // assert the vehicle may continue (must not be "teleported" or whatever to another position)
183  if (!onInit && !newRoute->contains(*myCurrEdge)) {
184  return false;
185  }
186  MSLink* oldLink = nullptr;
187  MSLink* newLink = nullptr;
188  if (mySegment != nullptr) {
189  oldLink = mySegment->getLink(this);
190  }
191  // rebuild in-vehicle route information
192  if (onInit) {
193  myCurrEdge = newRoute->begin();
194  } else {
195  myCurrEdge = find(edges.begin() + offset, edges.end(), *myCurrEdge);
196  }
197  // check whether the old route may be deleted (is not used by anyone else)
198  newRoute->addReference();
199  myRoute->release();
200  // assign new route
201  myRoute = newRoute;
202  if (mySegment != nullptr) {
203  newLink = mySegment->getLink(this);
204  }
205  // update approaching vehicle information
206  if (oldLink != nullptr && oldLink != newLink) {
207  oldLink->removeApproaching(this);
208  MELoop::setApproaching(this, newLink);
209  }
210  // update arrival definition
212  // save information that the vehicle was rerouted
216  return true;
217 }
218 
219 
220 bool
221 MEVehicle::addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& /*errorMsg*/, SUMOTime untilOffset, bool /*collision*/,
222  MSRouteIterator* /* searchStart */) {
223  const MSEdge* const edge = MSEdge::dictionary(stopPar.lane.substr(0, stopPar.lane.rfind('_')));
224  assert(edge != 0);
225  MESegment* stopSeg = MSGlobals::gMesoNet->getSegmentForEdge(*edge, stopPar.endPos);
226  myStops[stopSeg].push_back(stopPar);
227  if (myStops[stopSeg].back().until >= 0) {
228  myStops[stopSeg].back().until += untilOffset;
229  }
230  myStopEdges.push_back(edge);
231  return true;
232 }
233 
234 
235 bool
237  return myStops.find(mySegment) != myStops.end();
238 }
239 
240 
241 bool
243  return false;
244 }
245 
246 
247 bool
248 MEVehicle::isStoppedInRange(double pos) const {
249  UNUSED_PARAMETER(pos);
250  return isStopped();
251 }
252 
253 
254 SUMOTime
255 MEVehicle::getStoptime(const MESegment* const seg, SUMOTime time) const {
256  if (myStops.find(seg) != myStops.end()) {
257  for (const SUMOVehicleParameter::Stop& stop : myStops.find(seg)->second) {
258  time += stop.duration;
259  if (stop.until > time) {
260  // @note: this assumes the stop is reached at time. With the way this is called in MESegment (time == entryTime),
261  // travel time is overestimated of the stop is not at the start of the segment
262  time = stop.until;
263  }
264  }
265  }
266  return time;
267 }
268 
269 
270 double
273 }
274 
275 
276 const ConstMSEdgeVector
278 // TODO: myStopEdges still needs to be updated when leaving a stop
279  return myStopEdges;
280 }
281 
282 
283 void
285  assert(isStopped());
286  MSEdge* edge = const_cast<MSEdge*>(getEdge());
287  for (const SUMOVehicleParameter::Stop& stop : myStops.find(mySegment)->second) {
288  //SUMOTime started = MSNet::getInstance()->getCurrentTimeStep() - TIME2STEPS(getCurrentStoppingTimeSeconds());
289  SUMOTime started = myLastEntryTime;
290  //std::cout << SIMTIME << " veh=" << getID() << " lastEntry=" << STEPS2TIME(myLastEntryTime) << " stopStarted=" << STEPS2TIME(started) << "\n";
291  if (MSStopOut::active()) {
293  }
294  MSNet* const net = MSNet::getInstance();
295  SUMOTime dummyDuration; // boarding- and loading-time are not considered
296  if (net->hasPersons()) {
297  net->getPersonControl().boardAnyWaiting(edge, this, stop, started, dummyDuration);
298  }
299  if (net->hasContainers()) {
300  net->getContainerControl().loadAnyWaiting(edge, this, stop, started, dummyDuration);
301  }
302  MSDevice_Vehroutes* vehroutes = static_cast<MSDevice_Vehroutes*>(getDevice(typeid(MSDevice_Vehroutes)));
303  if (vehroutes != nullptr) {
304  vehroutes->stopEnded(stop);
305  }
306  if (MSStopOut::active()) {
308  }
309  }
311 }
312 
313 
314 bool
316  return mySegment == nullptr || mySegment->isOpen(this);
317 }
318 
319 
320 double
322  if (mySegment == nullptr) {
323  return 0;
324  } else {
325  return STEPS2TIME(mySegment->getLinkPenalty(this));
326  }
327 }
328 
329 
330 void
332  for (MoveReminderCont::iterator i = myMoveReminders.begin(); i != myMoveReminders.end(); ++i) {
333  if (i->first == rem) {
335  (mySegment->getIndex() + 1) * mySegment->getLength(),
336  getLastEntryTime(), currentTime, exitTime, false);
337 #ifdef _DEBUG
338  if (myTraceMoveReminders) {
339  traceMoveReminder("notifyMove", i->first, i->second, true);
340  }
341 #endif
342  return;
343  }
344  }
345 }
346 
347 
348 void
349 MEVehicle::updateDetectors(SUMOTime currentTime, const bool isLeave, const MSMoveReminder::Notification reason) {
350  // segments of the same edge have the same reminder so no cleaning up must take place
351  const bool cleanUp = isLeave && (reason != MSMoveReminder::NOTIFICATION_SEGMENT);
352  for (MoveReminderCont::iterator rem = myMoveReminders.begin(); rem != myMoveReminders.end();) {
353  if (currentTime != getLastEntryTime()) {
354  rem->first->updateDetector(*this, mySegment->getIndex() * mySegment->getLength(),
355  (mySegment->getIndex() + 1) * mySegment->getLength(),
356  getLastEntryTime(), currentTime, getEventTime(), cleanUp);
357 #ifdef _DEBUG
358  if (myTraceMoveReminders) {
359  traceMoveReminder("notifyMove", rem->first, rem->second, true);
360  }
361 #endif
362  }
363  if (!isLeave || rem->first->notifyLeave(*this, mySegment->getLength(), reason)) {
364 #ifdef _DEBUG
365  if (isLeave && myTraceMoveReminders) {
366  traceMoveReminder("notifyLeave", rem->first, rem->second, true);
367  }
368 #endif
369  ++rem;
370  } else {
371 #ifdef _DEBUG
372  if (myTraceMoveReminders) {
373  traceMoveReminder("remove", rem->first, rem->second, false);
374  }
375 #endif
376  rem = myMoveReminders.erase(rem);
377  }
378  }
379 }
380 
381 
382 void
385  assert(mySegment == 0 || *myCurrEdge == &mySegment->getEdge());
386  std::vector<SUMOTime> internals;
387  internals.push_back(myDeparture);
388  internals.push_back((SUMOTime)distance(myRoute->begin(), myCurrEdge));
389  internals.push_back(mySegment == nullptr ? (SUMOTime) - 1 : (SUMOTime)mySegment->getIndex());
390  internals.push_back((SUMOTime)getQueIndex());
391  internals.push_back(myEventTime);
392  internals.push_back(myLastEntryTime);
393  internals.push_back(myBlockTime);
394  out.writeAttr(SUMO_ATTR_STATE, toString(internals));
395  // save stops and parameters
396  for (const auto& it : myStops) {
397  for (const SUMOVehicleParameter::Stop& stop : it.second) {
398  stop.write(out);
399  }
400  }
401  myParameter->writeParams(out);
402  for (MSDevice* dev : myDevices) {
403  dev->saveState(out);
404  }
405  out.closeTag();
406 }
407 
408 
409 void
410 MEVehicle::loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset) {
411  if (attrs.hasAttribute(SUMO_ATTR_POSITION)) {
412  throw ProcessError("Error: Invalid vehicles in state (may be a micro state)!");
413  }
414  int routeOffset;
415  int segIndex;
416  int queIndex;
417  std::istringstream bis(attrs.getString(SUMO_ATTR_STATE));
418  bis >> myDeparture;
419  bis >> routeOffset;
420  bis >> segIndex;
421  bis >> queIndex;
422  bis >> myEventTime;
423  bis >> myLastEntryTime;
424  bis >> myBlockTime;
425  if (hasDeparted()) {
426  myDeparture -= offset;
427  myEventTime -= offset;
428  myLastEntryTime -= offset;
429  myCurrEdge += routeOffset;
430  if (segIndex >= 0) {
432  while (seg->getIndex() != (int)segIndex) {
433  seg = seg->getNextSegment();
434  assert(seg != 0);
435  }
436  setSegment(seg, queIndex);
437  } else {
438  // on teleport
439  setSegment(nullptr, 0);
440  assert(myEventTime != SUMOTime_MIN);
441  MSGlobals::gMesoNet->addLeaderCar(this, nullptr);
442  }
443  }
444  if (myBlockTime != SUMOTime_MAX) {
445  myBlockTime -= offset;
446  }
447 }
448 
449 
450 /****************************************************************************/
451 
std::vector< MSVehicleDevice * > myDevices
The devices this vehicle has.
void updateDetectorForWriting(MSMoveReminder *rem, SUMOTime currentTime, SUMOTime exitTime)
Updates a single vehicle detector if present.
Definition: MEVehicle.cpp:331
void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)
Loads the state of this vehicle from the given description.
Definition: MEVehicle.cpp:410
MESegment * getNextSegment() const
Returns the following segment on the same edge (0 if it is the last).
Definition: MESegment.h:152
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
int getContainerNumber() const
Returns the number of containers.
static bool active()
Definition: MSStopOut.h:57
void updateDetector(SUMOVehicle &veh, double entryPos, double leavePos, SUMOTime entryTime, SUMOTime currentTime, SUMOTime leaveTime, bool cleanUp)
double getVehicleMaxSpeed(const SUMOVehicle *const veh) const
Returns the lane&#39;s maximum speed, given a vehicle&#39;s speed limit adaptation.
Definition: MSLane.h:492
virtual void setSegment(MESegment *s, int idx=0)
Sets the current segment the vehicle is at together with its que.
Definition: MEVehicle.h:228
double getAngle() const
Returns the vehicle&#39;s direction in degrees.
Definition: MEVehicle.cpp:86
long long int SUMOTime
Definition: SUMOTime.h:36
bool isOpen(const MEVehicle *veh) const
Returns whether the vehicle may use the next link.
Definition: MESegment.cpp:408
bool hasPersons() const
Returns whether persons are simulated.
Definition: MSNet.h:333
void informVehicleStateListener(const SUMOVehicle *const vehicle, VehicleState to, const std::string &info="")
Informs all added listeners about a vehicle&#39;s state change.
Definition: MSNet.cpp:855
double getLength() const
Returns the length of the segment in meters.
Definition: MESegment.h:160
MoveReminderCont myMoveReminders
Currently relevant move reminders.
const ConstMSEdgeVector & getEdges() const
Definition: MSRoute.h:121
std::map< const MESegment *const, std::vector< SUMOVehicleParameter::Stop > > myStops
where to stop
Definition: MEVehicle.h:372
MESegment * getSegmentForEdge(const MSEdge &e, double pos=0)
Get the segment for a given edge at a given position.
Definition: MELoop.cpp:283
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:101
double estimateLeaveSpeed(const MSLink *link) const
Returns the vehicle&#39;s estimated speed after driving accross the link.
Definition: MEVehicle.cpp:123
SUMOTime getLastEntryTime() const
Returns the time the vehicle entered the current segment.
Definition: MEVehicle.h:261
bool mayProceed() const
Returns whether the vehicle is allowed to pass the next junction.
Definition: MEVehicle.cpp:315
int getIndex() const
Returns the running index of the segment in the edge (0 is the most upstream).
Definition: MESegment.h:144
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
Definition: MEVehicle.cpp:100
double getSlope() const
Returns the slope of the road at vehicle&#39;s position.
Definition: MEVehicle.cpp:93
double myArrivalPos
The position on the destination lane where the vehicle stops.
Notification
Definition of a vehicle state.
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:162
SUMOTime getWaitingTime() const
Returns the duration for which the vehicle was blocked.
Definition: MEVehicle.h:284
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:165
T MAX2(T a, T b)
Definition: StdDefs.h:76
SUMOTime DELTA_T
Definition: SUMOTime.cpp:35
const PositionVector & getShape() const
Returns this lane&#39;s shape.
Definition: MSLane.h:456
const MSRoute * myRoute
This vehicle&#39;s route.
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves his current cell.
Definition: MEVehicle.h:219
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:788
double rotationAtOffset(double pos) const
Returns the rotation at the given length.
bool isStoppedInRange(double pos) const
return whether the given position is within range of the current stop
Definition: MEVehicle.cpp:248
The vehicle changes the segment (meso only)
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:72
bool replaceRoute(const MSRoute *route, const std::string &info, bool onInit=false, int offset=0, bool addStops=true, bool removeStops=true)
Replaces the current route by the given one.
Definition: MEVehicle.cpp:178
const SUMOVehicleParameter * myParameter
This vehicle&#39;s parameter.
const std::string & getID() const
Returns the id.
Definition: Named.h:78
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:52
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MEVehicle.cpp:166
virtual bool hasAttribute(int id) const =0
Returns the information whether the named (by its enum-value) attribute is within the current list...
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:33
The simulated network and simulation perfomer.
Definition: MSNet.h:84
The speed is given.
The car-following model and parameter.
Definition: MSVehicleType.h:66
virtual void saveState(OutputDevice &out)
Saves the (common) state of a vehicle.
virtual std::string getString(int id) const =0
Returns the string-value of the named (by its enum-value) attribute.
virtual MSTransportableControl & getContainerControl()
Returns the container control.
Definition: MSNet.cpp:784
void stopEnded(const SUMOVehicle *veh, const SUMOVehicleParameter::Stop &stop, const std::string &laneOrEdgeID)
Definition: MSStopOut.cpp:99
double getMaxAccel() const
Get the vehicle type&#39;s maximum acceleration [m/s^2].
Definition: MSCFModel.h:210
void calculateArrivalParams()
(Re-)Calculates the arrival position and lane from the vehicle parameters
The state of a link.
#define SUMOTime_MIN
Definition: SUMOTime.h:38
double departSpeed
(optional) The initial speed of the vehicle
void stopEnded(const SUMOVehicleParameter::Stop &stop)
A road/street connecting two junctions.
Definition: MSEdge.h:75
double getCurrentStoppingTimeSeconds() const
Returns the delay that is accrued due to option –meso-tls-penalty or –meso-minor-penalty.
Definition: MEVehicle.cpp:271
SUMOTime getLinkPenalty(const MEVehicle *veh) const
Returns the penalty time for passing a link (if using gMesoTLSPenalty > 0 or gMesoMinorPenalty > 0) ...
Definition: MESegment.cpp:713
DepartSpeedDefinition departSpeedProcedure
Information how the vehicle&#39;s initial speed shall be chosen.
const MSCFModel & getCarFollowModel() const
Returns the vehicle type&#39;s car following model definition (const version)
The vehicle got a new route.
Definition: MSNet.h:506
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:49
void stopStarted(const SUMOVehicle *veh, int numPersons, int numContainers, SUMOTime time)
Definition: MSStopOut.cpp:64
Encapsulated SAX-Attributes.
virtual MSTransportableControl & getPersonControl()
Returns the person control.
Definition: MSNet.cpp:776
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:39
MESegment * getSegment() const
Returns the current segment the vehicle is on.
Definition: MEVehicle.h:237
const MSEdge * getEdge() const
Returns the edge the vehicle is currently at.
MSVehicleControl & getVehicleControl()
Returns the vehicle control.
Definition: MSNet.h:316
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, MSRouteIterator *searchStart=0)
Adds a stop.
Definition: MEVehicle.cpp:221
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:58
bool isStopped() const
Returns whether the vehicle is at a stop.
Definition: MEVehicle.cpp:236
bool hasContainers() const
Returns whether containers are simulated.
Definition: MSNet.h:349
#define STEPS2TIME(x)
Definition: SUMOTime.h:58
double getMaxSpeed() const
Get vehicle&#39;s maximum speed [m/s].
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge) ...
Definition: MEVehicle.cpp:157
T MIN2(T a, T b)
Definition: StdDefs.h:70
void processStop()
ends the current stop and performs loading/unloading
Definition: MEVehicle.cpp:284
#define POSITION_EPS
Definition: config.h:172
SUMOTime myLastEntryTime
The time the vehicle entered its current segment.
Definition: MEVehicle.h:366
double endPos
The stopping position end.
Something on a lane to be noticed about vehicle movement.
int getQueIndex() const
Returns the index of the que the vehicle is in.
Definition: MEVehicle.h:245
void saveState(OutputDevice &out)
Saves the states of a vehicle.
Definition: MEVehicle.cpp:383
bool loadAnyWaiting(MSEdge *edge, SUMOVehicle *vehicle, const SUMOVehicleParameter::Stop &stop, SUMOTime &timeToLoadNextContainer, SUMOTime &stopDuration)
load any applicable containers Loads any container that is waiting on that edge for the given vehicle...
double getConservativeSpeed(SUMOTime &earliestArrival) const
Returns the vehicle&#39;s estimated speed taking into account delays.
Definition: MEVehicle.cpp:132
void writeParams(OutputDevice &device) const
write Params in the given outputdevice
MESegment * mySegment
The segment the vehicle is at.
Definition: MEVehicle.h:357
static void setApproaching(MEVehicle *veh, MSLink *link)
registers vehicle with the given link
Definition: MELoop.cpp:205
std::string lane
The lane to stop at.
std::vector< std::string > via
List of the via-edges the vehicle must visit.
bool moveRoutePointer()
Update when the vehicle enters a new edge in the move step.
Definition: MEVehicle.cpp:139
double slopeDegreeAtOffset(double pos) const
Returns the slope at the given length.
Abstract in-vehicle / in-person device.
Definition: MSDevice.h:63
void write(OutputDevice &dev) const
Writes the stop as XML.
SUMOTime getStoptime(const MESegment *const seg, SUMOTime time) const
Returns until when to stop at the given segment.
Definition: MEVehicle.cpp:255
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
ConstMSEdgeVector myStopEdges
edges to stop
Definition: MEVehicle.h:375
int getPersonNumber() const
Returns the number of persons.
Structure representing possible vehicle parameter.
#define SUMOTime_MAX
Definition: SUMOTime.h:37
const MSVehicleType & getVehicleType() const
Returns the vehicle&#39;s type definition.
MSLink * getLink(const MEVehicle *veh, bool tlsPenalty=false) const
Returns the link the given car will use when passing the next junction.
Definition: MESegment.cpp:377
bool boardAnyWaiting(MSEdge *edge, SUMOVehicle *vehicle, const SUMOVehicleParameter::Stop &stop, SUMOTime &timeToBoardNextPerson, SUMOTime &stopDuration)
board any applicable persons Boards any people who wait on that edge for the given vehicle and remove...
A single mesoscopic segment (cell)
Definition: MESegment.h:50
Definition of vehicle stop (position and duration)
MSVehicleDevice * getDevice(const std::type_info &type) const
Returns a device of the given type if it exists or 0.
MEVehicle(SUMOVehicleParameter *pars, const MSRoute *route, MSVehicleType *type, const double speedFactor)
Constructor.
Definition: MEVehicle.cpp:51
void updateDetectors(SUMOTime currentTime, const bool isLeave, const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_JUNCTION)
Updates all vehicle detectors.
Definition: MEVehicle.cpp:349
double interpolateLanePosToGeometryPos(double lanePos) const
Definition: MSLane.h:472
const std::string & getID() const
Returns the name of the vehicle type.
Definition: MSVehicleType.h:94
const Position geometryPositionAtOffset(double offset, double lateralOffset=0) const
Definition: MSLane.h:478
void addReference() const
increments the reference counter for the route
Definition: MSRoute.cpp:95
static MELoop * gMesoNet
mesoscopic simulation infrastructure
Definition: MSGlobals.h:106
A device which collects info on the vehicle trip (mainly on departure and arrival) ...
int myNumberReroutes
The number of reroutings.
double getLength() const
Get vehicle&#39;s length [m].
static MSStopOut * getInstance()
Definition: MSStopOut.h:63
bool isParking() const
Returns whether the vehicle is parking.
Definition: MEVehicle.cpp:172
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
double getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MEVehicle.cpp:78
SUMOTime myEventTime
The (planned) time of leaving the segment (cell)
Definition: MEVehicle.h:363
double getAverageSpeed() const
Returns the vehicle&#39;s estimated average speed on the segment assuming no further delays.
Definition: MEVehicle.cpp:117
MSRouteIterator myCurrEdge
Iterator to current route-edge.
double getCurrentLinkPenaltySeconds() const
Returns the delay that is accrued due to option –meso-tls-penalty or –meso-minor-penalty.
Definition: MEVehicle.cpp:321
MSRouteIterator begin() const
Returns the begin of the list of edges to pass.
Definition: MSRoute.cpp:70
double getSpeed() const
Returns the vehicle&#39;s estimated speed assuming no delays.
Definition: MEVehicle.cpp:107
const ConstMSEdgeVector getStopEdges() const
Returns the list of still pending stop edges.
Definition: MEVehicle.cpp:277
bool isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
Definition: MEVehicle.cpp:242
SUMOTime myBlockTime
The time at which the vehicle was blocked on its current segment.
Definition: MEVehicle.h:369
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition: MESegment.h:266
Representation of a lane in the micro simulation.
Definition: MSLane.h:78
void addLeaderCar(MEVehicle *veh, MSLink *link)
Adds the given car to the leading vehicles.
Definition: MELoop.cpp:198
MSRouteIterator end() const
Returns the end of the list of edges to pass.
Definition: MSRoute.cpp:76
bool contains(const MSEdge *const edge) const
Definition: MSRoute.h:103
SUMOTime myDeparture
The real departure time.
SUMOVehicleClass getVehicleClass() const
Get this vehicle type&#39;s vehicle class.
std::string id
The vehicle&#39;s id.
void removeWaiting(const MSEdge *const edge, const SUMOVehicle *vehicle)
Removes a vehicle from the list of waiting vehicles to a given edge.
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle&#39;s position relative to the given lane.
Definition: MEVehicle.cpp:72