Eclipse 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-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 /****************************************************************************/
18 // A detector of vehicles passing an area between entry/exit points
19 /****************************************************************************/
20 #ifndef MSE3Collector_h
21 #define MSE3Collector_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <string>
30 #include <vector>
31 #include <limits>
34 #include <utils/common/Named.h>
37 
38 
39 // ===========================================================================
40 // class declarations
41 // ===========================================================================
42 class SUMOTrafficObject;
43 class OutputDevice;
44 
45 
46 // ===========================================================================
47 // class definitions
48 // ===========================================================================
59 public:
65  public:
71  MSE3EntryReminder(const MSCrossSection& crossSection, MSE3Collector& collector);
72 
73 
76 
86  bool notifyEnter(SUMOTrafficObject& veh, Notification reason, const MSLane* enteredLane);
87 
103  bool notifyMove(SUMOTrafficObject& veh, double, double newPos, double);
104 
105 
116  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
118 
119 
120  private:
123 
125  double myPosition;
126 
127  private:
130 
133 
134  };
135 
136 
137 
143  public:
149  MSE3LeaveReminder(const MSCrossSection& crossSection, MSE3Collector& collector);
150 
151 
153 
154 
164  bool notifyEnter(SUMOTrafficObject& veh, Notification reason, const MSLane* enteredLane);
165 
181  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double);
182 
192  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
194 
195 
196  private:
199 
201  double myPosition;
202 
203  private:
206 
209 
210  };
211 
212 
223  MSE3Collector(const std::string& id,
224  const CrossSectionVector& entries, const CrossSectionVector& exits,
225  double haltingSpeedThreshold,
226  SUMOTime haltingTimeThreshold,
227  const std::string& vTypes, bool openEntry);
228 
229 
231  virtual ~MSE3Collector();
232 
233 
236  void reset();
237 
238 
247  void enter(const SUMOTrafficObject& veh, const double entryTimestep, const double fractionTimeOnDet, MSE3EntryReminder* entryReminder);
248 
249 
255  void leaveFront(const SUMOTrafficObject& veh, const double leaveTimestep);
256 
257 
266  void leave(const SUMOTrafficObject& veh, const double leaveTimestep, const double fractionTimeOnDet);
267 
268 
271 
278  double getCurrentMeanSpeed() const;
279 
280 
287  int getCurrentHaltingNumber() const;
288 
289 
293  int getVehiclesWithin() const;
294 
295 
300  std::vector<std::string> getCurrentVehicleIDs() const;
302 
303 
306 
315  void writeXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime);
316 
317 
326  void writeXMLDetectorProlog(OutputDevice& dev) const;
328 
329 
330 
339  void detectorUpdate(const SUMOTime step);
340 
341 
342 protected:
345 
348 
350  std::vector<MSE3EntryReminder*> myEntryReminders;
351 
353  std::vector<MSE3LeaveReminder*> myLeaveReminders;
354 
355 
356  // @brief Time-threshold to determine if a vehicle is halting.
358 
361 
370  struct E3Values {
372  double entryTime;
378  double speedSum;
380  int haltings;
392  bool hadUpdate;
395  };
396 
398  std::map<const SUMOTrafficObject*, E3Values> myEnteredContainer;
399 
401  std::vector<E3Values> myLeftContainer;
402 
403 
406 
409 
413 
414 
417 
419  const bool myOpenEntry;
420 
421 private:
424 
427 
428 
429 };
430 
431 
432 #endif
433 
434 /****************************************************************************/
435 
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:48
MSE3Collector::getCurrentHaltingNumber
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
Definition: MSE3Collector.cpp:536
MSE3Collector::getVehiclesWithin
int getVehiclesWithin() const
Returns the number of vehicles within the area.
Definition: MSE3Collector.cpp:542
MSE3Collector::myExits
CrossSectionVector myExits
The detector's exits.
Definition: MSE3Collector.h:347
MSE3Collector::writeXMLDetectorProlog
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "e3Detector" as root element.
Definition: MSE3Collector.cpp:483
MSE3Collector::MSE3LeaveReminder::notifyMove
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double)
Checks whether the vehicle leaves.
Definition: MSE3Collector.cpp:191
MSE3Collector::E3Values::entryTime
double entryTime
The vehicle's entry time.
Definition: MSE3Collector.h:372
MSE3Collector::myCurrentMeanSpeed
double myCurrentMeanSpeed
The current mean speed of known vehicles (inside)
Definition: MSE3Collector.h:408
MSE3Collector::MSE3EntryReminder::notifyEnter
bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane)
Checks whether the reminder is activated by a vehicle entering the lane.
Definition: MSE3Collector.cpp:59
MSDetectorFileOutput
Base of value-generating classes (detectors)
Definition: MSDetectorFileOutput.h:64
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:83
MSE3Collector
A detector of vehicles passing an area between entry/exit points.
Definition: MSE3Collector.h:58
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:64
MSE3Collector::writeXMLOutput
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
Definition: MSE3Collector.cpp:395
MSE3Collector::MSE3LeaveReminder::MSE3LeaveReminder
MSE3LeaveReminder(const MSCrossSection &crossSection, MSE3Collector &collector)
Constructor.
Definition: MSE3Collector.cpp:155
MSE3Collector::~MSE3Collector
virtual ~MSE3Collector()
Destructor.
Definition: MSE3Collector.cpp:299
MSE3Collector::enter
void enter(const SUMOTrafficObject &veh, const double entryTimestep, const double fractionTimeOnDet, MSE3EntryReminder *entryReminder)
Called if a vehicle touches an entry-cross-section.
Definition: MSE3Collector.cpp:317
MSE3Collector::E3Values::hadUpdate
bool hadUpdate
An internal information whether the update step was performed.
Definition: MSE3Collector.h:392
MSE3Collector::MSE3LeaveReminder::notifyEnter
bool notifyEnter(SUMOTrafficObject &veh, Notification reason, const MSLane *enteredLane)
Checks whether the reminder is activated by a vehicle entering the lane.
Definition: MSE3Collector.cpp:162
MSE3Collector::E3Values::intervalSpeedSum
double intervalSpeedSum
The sum of registered speeds the vehicle has/had inside the area during the current interval.
Definition: MSE3Collector.h:384
MSE3Collector::leaveFront
void leaveFront(const SUMOTrafficObject &veh, const double leaveTimestep)
Called if a vehicle front passes a leave-cross-section.
Definition: MSE3Collector.cpp:352
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:35
MSE3Collector::E3Values::entryReminder
MSE3EntryReminder * entryReminder
the reminder on which the vehicle entered the detector
Definition: MSE3Collector.h:394
MSE3Collector::myLastResetTime
SUMOTime myLastResetTime
Information when the last reset has been done.
Definition: MSE3Collector.h:416
MSE3Collector::myLeaveReminders
std::vector< MSE3LeaveReminder * > myLeaveReminders
The detector's built exit reminder.
Definition: MSE3Collector.h:353
MSCrossSection
A simple description of a position on a lane (crossing of a lane)
Definition: MSCrossSection.h:44
MSE3Collector::myEntryReminders
std::vector< MSE3EntryReminder * > myEntryReminders
The detector's built entry reminder.
Definition: MSE3Collector.h:350
MSE3Collector::E3Values::frontLeaveTime
double frontLeaveTime
The time the vehicle's front was crossing the leave line.
Definition: MSE3Collector.h:374
MSE3Collector::E3Values::intervalHaltings
int intervalHaltings
The sum of haltings the vehicle has/had within the area during the current interval.
Definition: MSE3Collector.h:386
MSDetectorFileOutput.h
MSE3Collector::E3Values::backLeaveTime
double backLeaveTime
The time the vehicle's back was crossing the leave line.
Definition: MSE3Collector.h:376
MSE3Collector::getCurrentVehicleIDs
std::vector< std::string > getCurrentVehicleIDs() const
Returns the number of vehicles within the area.
Definition: MSE3Collector.cpp:548
MSE3Collector::myCurrentHaltingsNumber
int myCurrentHaltingsNumber
The current number of haltings (inside)
Definition: MSE3Collector.h:411
MSMoveReminder
Something on a lane to be noticed about vehicle movement.
Definition: MSMoveReminder.h:64
MSE3Collector::myHaltingSpeedThreshold
double myHaltingSpeedThreshold
Speed-threshold to determine if a vehicle is halting.
Definition: MSE3Collector.h:360
MSE3Collector::MSE3EntryReminder::notifyMove
bool notifyMove(SUMOTrafficObject &veh, double, double newPos, double)
Checks whether the vehicle enters.
Definition: MSE3Collector.cpp:91
MSE3Collector::MSE3LeaveReminder::notifyLeave
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Processes state changes of a vehicle.
Definition: MSE3Collector.cpp:241
MSE3Collector::MSE3Collector
MSE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes, bool openEntry)
Constructor.
Definition: MSE3Collector.cpp:277
MSMoveReminder.h
MSE3Collector::E3Values::speedSum
double speedSum
The sum of registered speeds the vehicle has/had inside the area.
Definition: MSE3Collector.h:378
MSE3Collector::MSE3LeaveReminder::myCollector
MSE3Collector & myCollector
The parent collector.
Definition: MSE3Collector.h:198
Named.h
MSE3Collector::MSE3EntryReminder::myPosition
double myPosition
The position on the lane.
Definition: MSE3Collector.h:125
MSE3Collector::MSE3EntryReminder::operator=
MSE3EntryReminder & operator=(const MSE3EntryReminder &)
Invalidated assignment operator.
MSE3Collector::MSE3LeaveReminder::operator=
MSE3LeaveReminder & operator=(const MSE3LeaveReminder &)
Invalidated assignment operator.
UtilExceptions.h
MSE3Collector::getCurrentMeanSpeed
double getCurrentMeanSpeed() const
Returns the mean speed within the area.
Definition: MSE3Collector.cpp:530
MSE3Collector::myHaltingTimeThreshold
SUMOTime myHaltingTimeThreshold
Definition: MSE3Collector.h:357
MSE3Collector::myEnteredContainer
std::map< const SUMOTrafficObject *, E3Values > myEnteredContainer
Container for vehicles that have entered the area.
Definition: MSE3Collector.h:398
MSE3Collector::myOpenEntry
const bool myOpenEntry
whether this dector is declared as having incomplete entry detectors
Definition: MSE3Collector.h:419
MSE3Collector::E3Values::haltingBegin
SUMOTime haltingBegin
Begin time of last halt begin.
Definition: MSE3Collector.h:382
MSE3Collector::leave
void leave(const SUMOTrafficObject &veh, const double leaveTimestep, const double fractionTimeOnDet)
Called if a vehicle back passes a leave-cross-section.
Definition: MSE3Collector.cpp:367
MSE3Collector::MSE3EntryReminder::MSE3EntryReminder
MSE3EntryReminder(const MSCrossSection &crossSection, MSE3Collector &collector)
Constructor.
Definition: MSE3Collector.cpp:51
MSE3Collector::MSE3LeaveReminder
A place on the road net (at a certain lane and position on it) where the E3 area ends.
Definition: MSE3Collector.h:142
MSE3Collector::MSE3EntryReminder
A place on the road net (at a certain lane and position on it) where the E3 area begins.
Definition: MSE3Collector.h:64
MSE3Collector::MSE3EntryReminder::myCollector
MSE3Collector & myCollector
The parent collector.
Definition: MSE3Collector.h:122
MSE3Collector::myLeftContainer
std::vector< E3Values > myLeftContainer
Container for vehicles that have left the area.
Definition: MSE3Collector.h:401
MSE3Collector::E3Values::haltings
int haltings
The sum of haltings the vehicle has/had within the area.
Definition: MSE3Collector.h:380
MSE3Collector::E3Values::intervalTimeLoss
SUMOTime intervalTimeLoss
The timeLoss of the vehicle when entering. Updated to the current timeLoss at interval write.
Definition: MSE3Collector.h:390
MSE3Collector::operator=
MSE3Collector & operator=(const MSE3Collector &)
Invalidated assignment operator.
MSE3Collector::myEntries
CrossSectionVector myEntries
The detector's entries.
Definition: MSE3Collector.h:344
MSE3Collector::E3Values
Internal storage for values from a vehicle.
Definition: MSE3Collector.h:370
MSE3Collector::E3Values::timeLoss
SUMOTime timeLoss
The timeLoss of the vehicle when entering. Updated to the actual time loss within the area when leavi...
Definition: MSE3Collector.h:388
MSE3Collector::MSE3LeaveReminder::myPosition
double myPosition
The position on the lane.
Definition: MSE3Collector.h:201
MSCrossSection.h
config.h
MSE3Collector::detectorUpdate
void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
Definition: MSE3Collector.cpp:489
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:89
CrossSectionVector
std::vector< MSCrossSection > CrossSectionVector
Definition: MSCrossSection.h:64
MSE3Collector::reset
void reset()
Resets all generated values to allow computation of next interval.
Definition: MSE3Collector.cpp:310
MSE3Collector::MSE3EntryReminder::notifyLeave
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Processes state changes of a vehicle.
Definition: MSE3Collector.cpp:132