SUMO - Simulation of Urban MObility
MEVehicle.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // A vehicle from the mesoscopic point of view
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef MEVehicle_h
21 #define MEVehicle_h
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 <map>
36 #include <vector>
37 #include <microsim/MSBaseVehicle.h>
38 #include <microsim/MSEdge.h>
39 #include <utils/common/StdDefs.h>
40 #include "MESegment.h"
41 
42 class MSLane;
43 class MSLink;
44 
45 // ===========================================================================
46 // class definitions
47 // ===========================================================================
52 class MEVehicle : public MSBaseVehicle {
53 public:
61  MEVehicle(SUMOVehicleParameter* pars, const MSRoute* route,
62  MSVehicleType* type, const double speedFactor);
63 
64 
68  double getPositionOnLane() const;
69 
70 
74  double getBackPositionOnLane(const MSLane* lane) const;
75 
76 
80  double getAngle() const;
81 
82 
86  double getSlope() const;
87 
91  MSLane* getLane() const {
92  return 0;
93  }
94 
102  Position getPosition(const double offset = 0) const;
103 
104 
109  double getSpeed() const;
110 
115  double getAverageSpeed() const;
116 
118  double estimateLeaveSpeed(const MSLink* link) const;
119 
120 
126  double getConservativeSpeed(SUMOTime& earliestArrival) const;
127 
128 
132  bool moveRoutePointer();
133 
137  bool hasArrived() const;
138 
142  bool isOnRoad() const;
143 
147  bool isParking() const;
148 
155  bool addStop(const SUMOVehicleParameter::Stop& stopPar, std::string& errorMsg, SUMOTime untilOffset = 0, bool collision = false,
156  MSRouteIterator* searchStart = 0);
157 
158 
162  bool isStopped() const;
163 
164 
168  bool isStoppedTriggered() const;
169 
172  bool isStoppedInRange(double pos) const;
173 
178  SUMOTime getStoptime(const MESegment* const seg) const;
179 
180 
183  const ConstMSEdgeVector getStopEdges() const;
184 
187  bool replaceParkingArea(MSParkingArea* /* parkingArea = 0 */, std::string& /*errorMsg*/) {
188  throw ProcessError("parkingZoneReroute not implemented for meso");
189  }
190 
194  throw ProcessError("parkingZoneReroute not implemented for meso");
195  }
196 
200  inline void setEventTime(SUMOTime t, bool hasDelay = true) {
201  assert(t > myLastEntryTime);
202  if (hasDelay && mySegment != 0) {
204  }
205  myEventTime = t;
206  }
207 
208 
212  inline SUMOTime getEventTime() const {
213  return myEventTime;
214  }
215 
216 
221  inline virtual void setSegment(MESegment* s, int idx = 0) {
222  mySegment = s;
223  myQueIndex = idx;
224  }
225 
226 
230  inline MESegment* getSegment() const {
231  return mySegment;
232  }
233 
234 
238  inline int getQueIndex() const {
239  return myQueIndex;
240  }
241 
242 
246  inline void setLastEntryTime(SUMOTime t) {
247  myLastEntryTime = t;
248  }
249 
250 
255  return myLastEntryTime;
256  }
257 
258 
262  inline void setBlockTime(const SUMOTime t) {
263  assert(t > myLastEntryTime);
264  myBlockTime = t;
265  }
266 
267 
271  inline SUMOTime getBlockTime() const {
272  return myBlockTime;
273  }
274 
275 
277  inline SUMOTime getWaitingTime() const {
278  return MAX2(SUMOTime(0), myEventTime - myBlockTime);
279  }
280 
281 
288  double getWaitingSeconds() const {
289  return STEPS2TIME(getWaitingTime());
290  }
291 
292 
294  double getEventTimeSeconds() const {
295  return STEPS2TIME(getEventTime());
296  }
297 
299  double getLastEntryTimeSeconds() const {
300  return STEPS2TIME(getLastEntryTime());
301  }
302 
304  double getBlockTimeSeconds() const {
305  return STEPS2TIME(getBlockTime());
306  }
307 
309  double getCurrentLinkPenaltySeconds() const;
310 
311 
313  bool replaceRoute(const MSRoute* route, bool onInit = false, int offset = 0, bool addStops = true);
314 
318  bool mayProceed() const;
319 
322  void updateDetectorForWriting(MSMoveReminder* rem, SUMOTime currentTime, SUMOTime exitTime);
323 
326  void updateDetectors(SUMOTime currentTime, const bool isLeave,
328 
330 
331 
333  void saveState(OutputDevice& out);
334 
337  void loadState(const SUMOSAXAttributes& attrs, const SUMOTime offset);
339 
340 
341 protected:
344 
347 
350 
353 
356 
358  std::map<const MESegment* const, SUMOTime> myStops;
359 
360 };
361 
362 #endif
363 
364 /****************************************************************************/
void updateDetectorForWriting(MSMoveReminder *rem, SUMOTime currentTime, SUMOTime exitTime)
Updates a single vehicle detector if present.
Definition: MEVehicle.cpp:288
A lane area vehicles can halt at.
Definition: MSParkingArea.h:66
void loadState(const SUMOSAXAttributes &attrs, const SUMOTime offset)
Loads the state of this vehicle from the given description.
Definition: MEVehicle.cpp:369
bool isParking() const
Returns whether the vehicle is parking.
Definition: MEVehicle.cpp:175
virtual void setSegment(MESegment *s, int idx=0)
Sets the current segment the vehicle is at together with its que.
Definition: MEVehicle.h:221
double estimateLeaveSpeed(const MSLink *link) const
Returns the vehicle&#39;s estimated speed after driving accross the link.
Definition: MEVehicle.cpp:126
bool hasArrived() const
Returns whether this vehicle has already arived (reached the arrivalPosition on its final edge) ...
Definition: MEVehicle.cpp:160
SUMOTime getBlockTime() const
Returns the time at which the vehicle was blocked.
Definition: MEVehicle.h:271
A vehicle from the mesoscopic point of view.
Definition: MEVehicle.h:52
MSLane * getLane() const
Returns the lane the vehicle is on.
Definition: MEVehicle.h:91
bool replaceRoute(const MSRoute *route, bool onInit=false, int offset=0, bool addStops=true)
Replaces the current route by the given one.
Definition: MEVehicle.cpp:181
The vehicle arrived at a junction.
SUMOTime getStoptime(const MESegment *const seg) const
Returns how long to stop at the given segment.
Definition: MEVehicle.cpp:253
bool isStoppedTriggered() const
Returns whether the vehicle is on a triggered stop.
Definition: MEVehicle.cpp:240
SUMOTime getWaitingTime() const
Returns the duration for which the vehicle was blocked.
Definition: MEVehicle.h:277
double getSlope() const
Returns the slope of the road at vehicle&#39;s position.
Definition: MEVehicle.cpp:96
Notification
Definition of a vehicle state.
T MAX2(T a, T b)
Definition: StdDefs.h:74
SUMOTime getEventTime() const
Returns the (planned) time at which the vehicle leaves his current cell.
Definition: MEVehicle.h:212
double getPositionOnLane() const
Get the vehicle&#39;s position along the lane.
Definition: MEVehicle.cpp:81
std::vector< const MSEdge * > ConstMSEdgeVector
Definition: MSEdge.h:79
int myQueIndex
Index of the que the vehicle is in (important for multiqueue extension)
Definition: MEVehicle.h:346
double getSpeed() const
Returns the vehicle&#39;s estimated speed assuming no delays.
Definition: MEVehicle.cpp:110
The base class for microscopic and mesoscopic vehicles.
Definition: MSBaseVehicle.h:56
SUMOTime getLastEntryTime() const
Returns the time the vehicle entered the current segment.
Definition: MEVehicle.h:254
double getLastEntryTimeSeconds() const
Returns the entry time for the current segment.
Definition: MEVehicle.h:299
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition: MESegment.h:271
double getWaitingSeconds() const
Returns the number of seconds waited (speed was lesser than 0.1m/s)
Definition: MEVehicle.h:288
void setBlockTime(const SUMOTime t)
Sets the time at which the vehicle was blocked.
Definition: MEVehicle.h:262
The car-following model and parameter.
Definition: MSVehicleType.h:73
MSParkingArea * getNextParkingArea()
get the current parking area stop
Definition: MEVehicle.h:193
double getBlockTimeSeconds() const
Returns the time at which the vehicle was blocked on the current segment.
Definition: MEVehicle.h:304
bool isStopped() const
Returns whether the vehicle is at a stop.
Definition: MEVehicle.cpp:234
bool isOnRoad() const
Returns the information whether the vehicle is on a road (is simulated)
Definition: MEVehicle.cpp:169
Encapsulated SAX-Attributes.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:46
bool addStop(const SUMOVehicleParameter::Stop &stopPar, std::string &errorMsg, SUMOTime untilOffset=0, bool collision=false, MSRouteIterator *searchStart=0)
Adds a stop.
Definition: MEVehicle.cpp:223
ConstMSEdgeVector::const_iterator MSRouteIterator
Definition: MSRoute.h:65
void setLastEntryTime(SUMOTime t)
Sets the entry time for the current segment.
Definition: MEVehicle.h:246
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
void markDelayed() const
Definition: MSEdge.h:628
double getAngle() const
Returns the vehicle&#39;s direction in degrees.
Definition: MEVehicle.cpp:89
SUMOTime myLastEntryTime
The time the vehicle entered its current segment.
Definition: MEVehicle.h:352
Position getPosition(const double offset=0) const
Return current position (x/y, cartesian)
Definition: MEVehicle.cpp:103
Something on a lane to be noticed about vehicle movement.
bool isStoppedInRange(double pos) const
return whether the given position is within range of the current stop
Definition: MEVehicle.cpp:246
void saveState(OutputDevice &out)
Saves the states of a vehicle.
Definition: MEVehicle.cpp:340
double getConservativeSpeed(SUMOTime &earliestArrival) const
Returns the vehicle&#39;s estimated speed taking into account delays.
Definition: MEVehicle.cpp:135
MESegment * mySegment
The segment the vehicle is at.
Definition: MEVehicle.h:343
bool moveRoutePointer()
Update when the vehicle enters a new edge in the move step.
Definition: MEVehicle.cpp:142
double getEventTimeSeconds() const
Returns the earliest leave time for the current segment.
Definition: MEVehicle.h:294
void addStops(const bool ignoreStopErrors)
Adds stops to the built vehicle.
double getBackPositionOnLane(const MSLane *lane) const
Get the vehicle&#39;s position relative to the given lane.
Definition: MEVehicle.cpp:75
Structure representing possible vehicle parameter.
double getAverageSpeed() const
Returns the vehicle&#39;s estimated average speed on the segment assuming no further delays.
Definition: MEVehicle.cpp:120
bool replaceParkingArea(MSParkingArea *, std::string &)
replace the current parking area stop with a new stop with merge duration
Definition: MEVehicle.h:187
A single mesoscopic segment (cell)
Definition: MESegment.h:57
Definition of vehicle stop (position and duration)
MEVehicle(SUMOVehicleParameter *pars, const MSRoute *route, MSVehicleType *type, const double speedFactor)
Constructor.
Definition: MEVehicle.cpp:54
void updateDetectors(SUMOTime currentTime, const bool isLeave, const MSMoveReminder::Notification reason=MSMoveReminder::NOTIFICATION_JUNCTION)
Updates all vehicle detectors.
Definition: MEVehicle.cpp:306
int getQueIndex() const
Returns the index of the que the vehicle is in.
Definition: MEVehicle.h:238
std::map< const MESegment *const, SUMOTime > myStops
where to stop
Definition: MEVehicle.h:358
void setEventTime(SUMOTime t, bool hasDelay=true)
Sets the (planned) time at which the vehicle leaves his current cell.
Definition: MEVehicle.h:200
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
SUMOTime myEventTime
The (planned) time of leaving the segment (cell)
Definition: MEVehicle.h:349
const ConstMSEdgeVector getStopEdges() const
Returns the list of still pending stop edges.
Definition: MEVehicle.cpp:262
long long int SUMOTime
Definition: TraCIDefs.h:52
double getCurrentLinkPenaltySeconds() const
Returns the delay that is accrued due to option –meso-tls-penalty or –meso-minor-penalty.
Definition: MEVehicle.cpp:278
bool mayProceed() const
Returns whether the vehicle is allowed to pass the next junction.
Definition: MEVehicle.cpp:272
SUMOTime myBlockTime
The time at which the vehicle was blocked on its current segment.
Definition: MEVehicle.h:355
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
MESegment * getSegment() const
Returns the current segment the vehicle is on.
Definition: MEVehicle.h:230