SUMO - Simulation of Urban MObility
MSE3Collector.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2003-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // A detector of vehicles passing an area between entry/exit points
21 /****************************************************************************/
22 #ifndef MSE3Collector_h
23 #define MSE3Collector_h
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include <string>
36 #include <vector>
37 #include <limits>
40 #include <utils/common/Named.h>
43 
44 
45 // ===========================================================================
46 // class declarations
47 // ===========================================================================
48 class SUMOVehicle;
49 class OutputDevice;
50 
51 
52 // ===========================================================================
53 // class definitions
54 // ===========================================================================
65 public:
71  public:
77  MSE3EntryReminder(const MSCrossSection& crossSection, MSE3Collector& collector);
78 
79 
82 
98  bool notifyMove(SUMOVehicle& veh, double , double newPos, double);
99 
100 
111  bool notifyLeave(SUMOVehicle& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
113 
114 
115  private:
118 
120  double myPosition;
121 
122  private:
125 
128 
129  };
130 
131 
132 
138  public:
144  MSE3LeaveReminder(const MSCrossSection& crossSection, MSE3Collector& collector);
145 
146 
148 
149 
165  bool notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double);
166 
176  bool notifyLeave(SUMOVehicle& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
178 
179 
180  private:
183 
185  double myPosition;
186 
187  private:
190 
193 
194  };
195 
196 
207  MSE3Collector(const std::string& id,
208  const CrossSectionVector& entries, const CrossSectionVector& exits,
209  double haltingSpeedThreshold,
210  SUMOTime haltingTimeThreshold,
211  const std::string& vTypes);
212 
213 
215  virtual ~MSE3Collector();
216 
217 
220  void reset();
221 
222 
231  void enter(const SUMOVehicle& veh, const double entryTimestep, const double fractionTimeOnDet);
232 
233 
239  void leaveFront(const SUMOVehicle& veh, const double leaveTimestep);
240 
241 
250  void leave(const SUMOVehicle& veh, const double leaveTimestep, const double fractionTimeOnDet);
251 
252 
255 
262  double getCurrentMeanSpeed() const;
263 
264 
271  int getCurrentHaltingNumber() const;
272 
273 
277  int getVehiclesWithin() const;
278 
279 
284  std::vector<std::string> getCurrentVehicleIDs() const;
286 
287 
290 
299  void writeXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime);
300 
301 
310  void writeXMLDetectorProlog(OutputDevice& dev) const;
312 
313 
314 
323  void detectorUpdate(const SUMOTime step);
324 
325 
326 protected:
329 
332 
334  std::vector<MSE3EntryReminder*> myEntryReminders;
335 
337  std::vector<MSE3LeaveReminder*> myLeaveReminders;
338 
339 
340  // @brief Time-threshold to determine if a vehicle is halting.
342 
345 
354  struct E3Values {
356  double entryTime;
362  double speedSum;
364  int haltings;
366  double haltingBegin;
376  bool hadUpdate;
377  };
378 
380  std::map<const SUMOVehicle*, E3Values> myEnteredContainer;
381 
383  std::map<const SUMOVehicle*, E3Values> myLeftContainer;
384 
385 
388 
391 
395 
396 
399 
400 
401 private:
404 
407 
408 
409 };
410 
411 
412 #endif
413 
414 /****************************************************************************/
415 
double intervalSpeedSum
The sum of registered speeds the vehicle has/had inside the area during the current interval...
bool notifyMove(SUMOVehicle &veh, double, double newPos, double)
Checks whether the vehicle enters.
int haltings
The sum of haltings the vehicle has/had within the area.
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
void enter(const SUMOVehicle &veh, const double entryTimestep, const double fractionTimeOnDet)
Called if a vehicle touches an entry-cross-section.
virtual ~MSE3Collector()
Destructor.
A simple description of a position on a lane (crossing of a lane)
std::vector< MSE3EntryReminder * > myEntryReminders
The detector&#39;s built entry reminder.
bool hadUpdate
An internal information whether the update step was performed.
A place on the road net (at a certain lane and position on it) where the E3 area ends.
MSE3EntryReminder(const MSCrossSection &crossSection, MSE3Collector &collector)
Constructor.
A place on the road net (at a certain lane and position on it) where the E3 area begins.
Definition: MSE3Collector.h:70
double myHaltingSpeedThreshold
Speed-threshold to determine if a vehicle is halting.
Notification
Definition of a vehicle state.
std::vector< MSCrossSection > CrossSectionVector
double frontLeaveTime
The time the vehicle&#39;s front was crossing the leave line.
double myCurrentMeanSpeed
The current mean speed of known vehicles (inside)
SUMOTime myLastResetTime
Information when the last reset has been done.
std::vector< std::string > getCurrentVehicleIDs() const
Returns the number of vehicles within the area.
MSE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes)
Constructor.
std::vector< MSE3LeaveReminder * > myLeaveReminders
The detector&#39;s built exit reminder.
bool notifyLeave(SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Processes state changes of a vehicle.
double backLeaveTime
The time the vehicle&#39;s back was crossing the leave line.
MSE3EntryReminder & operator=(const MSE3EntryReminder &)
Invalidated assignment operator.
int myCurrentHaltingsNumber
The current number of haltings (inside)
Representation of a vehicle.
Definition: SUMOVehicle.h:66
std::map< const SUMOVehicle *, E3Values > myEnteredContainer
Container for vehicles that have entered the area.
Internal storage for values from a vehicle.
double entryTime
The vehicle&#39;s entry time.
double getCurrentMeanSpeed() const
Returns the mean speed within the area.
SUMOTime myHaltingTimeThreshold
MSE3Collector & myCollector
The parent collector.
Something on a lane to be noticed about vehicle movement.
void leaveFront(const SUMOVehicle &veh, const double leaveTimestep)
Called if a vehicle front passes a leave-cross-section.
void leave(const SUMOVehicle &veh, const double leaveTimestep, const double fractionTimeOnDet)
Called if a vehicle back passes a leave-cross-section.
SUMOTime intervalTimeLoss
The timeLoss of the vehicle when entering. Updated to the current timeLoss at interval write...
CrossSectionVector myEntries
The detector&#39;s entries.
double myPosition
The position on the lane.
double speedSum
The sum of registered speeds the vehicle has/had inside the area.
void reset()
Resets all generated values to allow computation of next interval.
A detector of vehicles passing an area between entry/exit points.
Definition: MSE3Collector.h:64
int intervalHaltings
The sum of haltings the vehicle has/had within the area during the current interval.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
long long int SUMOTime
Definition: TraCIDefs.h:51
int getVehiclesWithin() const
Returns the number of vehicles within the area.
void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
Representation of a lane in the micro simulation.
Definition: MSLane.h:77
double haltingBegin
Begin time of last halt begin.
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
MSE3Collector & myCollector
The parent collector.
SUMOTime timeLoss
The timeLoss of the vehicle when entering. Updated to the actual time loss within the area when leavi...
Base of value-generating classes (detectors)
double myPosition
The position on the lane.
CrossSectionVector myExits
The detector&#39;s exits.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "e3Detector" as root element.
std::map< const SUMOVehicle *, E3Values > myLeftContainer
Container for vehicles that have left the area.