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 /****************************************************************************/
17 // A detector of vehicles passing an area between entry/exit points
18 /****************************************************************************/
19 #ifndef MSE3Collector_h
20 #define MSE3Collector_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #include <config.h>
27 
28 #include <string>
29 #include <vector>
30 #include <limits>
33 #include <utils/common/Named.h>
36 #ifdef HAVE_FOX
37 #include <fx.h>
38 #endif
39 
40 
41 // ===========================================================================
42 // class declarations
43 // ===========================================================================
44 class SUMOTrafficObject;
45 class OutputDevice;
46 
47 
48 // ===========================================================================
49 // class definitions
50 // ===========================================================================
61 public:
67  public:
73  MSE3EntryReminder(const MSCrossSection& crossSection, MSE3Collector& collector);
74 
75 
78 
88  bool notifyEnter(SUMOTrafficObject& veh, Notification reason, const MSLane* enteredLane);
89 
105  bool notifyMove(SUMOTrafficObject& veh, double, double newPos, double);
106 
107 
118  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
120 
121 
122  private:
125 
127  double myPosition;
128 
129  private:
132 
135 
136  };
137 
138 
139 
145  public:
151  MSE3LeaveReminder(const MSCrossSection& crossSection, MSE3Collector& collector);
152 
153 
155 
156 
166  bool notifyEnter(SUMOTrafficObject& veh, Notification reason, const MSLane* enteredLane);
167 
183  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double);
184 
194  bool notifyLeave(SUMOTrafficObject& veh, double lastPos, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
196 
197 
198  private:
201 
203  double myPosition;
204 
205  private:
208 
211 
212  };
213 
214 
225  MSE3Collector(const std::string& id,
226  const CrossSectionVector& entries, const CrossSectionVector& exits,
227  double haltingSpeedThreshold,
228  SUMOTime haltingTimeThreshold,
229  const std::string& vTypes, bool openEntry);
230 
231 
233  virtual ~MSE3Collector();
234 
235 
238  void reset();
239 
240 
249  void enter(const SUMOTrafficObject& veh, const double entryTimestep, const double fractionTimeOnDet, MSE3EntryReminder* entryReminder);
250 
251 
257  void leaveFront(const SUMOTrafficObject& veh, const double leaveTimestep);
258 
259 
268  void leave(const SUMOTrafficObject& veh, const double leaveTimestep, const double fractionTimeOnDet);
269 
270 
273 
280  double getCurrentMeanSpeed() const;
281 
282 
289  int getCurrentHaltingNumber() const;
290 
291 
295  int getVehiclesWithin() const;
296 
297 
302  std::vector<std::string> getCurrentVehicleIDs() const;
304 
305 
308 
317  void writeXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime);
318 
319 
328  void writeXMLDetectorProlog(OutputDevice& dev) const;
330 
331 
332 
341  void detectorUpdate(const SUMOTime step);
342 
343 
344 protected:
347 
350 
352  std::vector<MSE3EntryReminder*> myEntryReminders;
353 
355  std::vector<MSE3LeaveReminder*> myLeaveReminders;
356 
357 
358  // @brief Time-threshold to determine if a vehicle is halting.
360 
363 
372  struct E3Values {
374  double entryTime;
380  double speedSum;
382  int haltings;
394  bool hadUpdate;
397  };
398 
400  std::map<const SUMOTrafficObject*, E3Values> myEnteredContainer;
401 
403  std::vector<E3Values> myLeftContainer;
404 
405 #ifdef HAVE_FOX
406  FXMutex myContainerMutex;
408 #endif
409 
412 
415 
419 
420 
423 
425  const bool myOpenEntry;
426 
427 private:
430 
433 
434 
435 };
436 
437 
438 #endif
439 
440 /****************************************************************************/
441 
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:47
MSE3Collector::getCurrentHaltingNumber
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
Definition: MSE3Collector.cpp:551
MSE3Collector::getVehiclesWithin
int getVehiclesWithin() const
Returns the number of vehicles within the area.
Definition: MSE3Collector.cpp:557
MSE3Collector::myExits
CrossSectionVector myExits
The detector's exits.
Definition: MSE3Collector.h:349
MSE3Collector::writeXMLDetectorProlog
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "e3Detector" as root element.
Definition: MSE3Collector.cpp:498
MSE3Collector::MSE3LeaveReminder::notifyMove
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double)
Checks whether the vehicle leaves.
Definition: MSE3Collector.cpp:200
MSE3Collector::E3Values::entryTime
double entryTime
The vehicle's entry time.
Definition: MSE3Collector.h:374
MSE3Collector::myCurrentMeanSpeed
double myCurrentMeanSpeed
The current mean speed of known vehicles (inside)
Definition: MSE3Collector.h:414
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:58
MSDetectorFileOutput
Base of value-generating classes (detectors)
Definition: MSDetectorFileOutput.h:63
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSE3Collector
A detector of vehicles passing an area between entry/exit points.
Definition: MSE3Collector.h:60
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
MSE3Collector::writeXMLOutput
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
Definition: MSE3Collector.cpp:410
MSE3Collector::MSE3LeaveReminder::MSE3LeaveReminder
MSE3LeaveReminder(const MSCrossSection &crossSection, MSE3Collector &collector)
Constructor.
Definition: MSE3Collector.cpp:163
MSE3Collector::~MSE3Collector
virtual ~MSE3Collector()
Destructor.
Definition: MSE3Collector.cpp:314
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:332
MSE3Collector::E3Values::hadUpdate
bool hadUpdate
An internal information whether the update step was performed.
Definition: MSE3Collector.h:394
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:170
MSE3Collector::E3Values::intervalSpeedSum
double intervalSpeedSum
The sum of registered speeds the vehicle has/had inside the area during the current interval.
Definition: MSE3Collector.h:386
MSE3Collector::leaveFront
void leaveFront(const SUMOTrafficObject &veh, const double leaveTimestep)
Called if a vehicle front passes a leave-cross-section.
Definition: MSE3Collector.cpp:367
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MSE3Collector::E3Values::entryReminder
MSE3EntryReminder * entryReminder
the reminder on which the vehicle entered the detector
Definition: MSE3Collector.h:396
MSE3Collector::myLastResetTime
SUMOTime myLastResetTime
Information when the last reset has been done.
Definition: MSE3Collector.h:422
MSE3Collector::myLeaveReminders
std::vector< MSE3LeaveReminder * > myLeaveReminders
The detector's built exit reminder.
Definition: MSE3Collector.h:355
MSCrossSection
A simple description of a position on a lane (crossing of a lane)
Definition: MSCrossSection.h:43
MSE3Collector::myEntryReminders
std::vector< MSE3EntryReminder * > myEntryReminders
The detector's built entry reminder.
Definition: MSE3Collector.h:352
MSE3Collector::E3Values::frontLeaveTime
double frontLeaveTime
The time the vehicle's front was crossing the leave line.
Definition: MSE3Collector.h:376
MSE3Collector::E3Values::intervalHaltings
int intervalHaltings
The sum of haltings the vehicle has/had within the area during the current interval.
Definition: MSE3Collector.h:388
MSDetectorFileOutput.h
MSE3Collector::E3Values::backLeaveTime
double backLeaveTime
The time the vehicle's back was crossing the leave line.
Definition: MSE3Collector.h:378
MSE3Collector::getCurrentVehicleIDs
std::vector< std::string > getCurrentVehicleIDs() const
Returns the number of vehicles within the area.
Definition: MSE3Collector.cpp:563
MSE3Collector::myCurrentHaltingsNumber
int myCurrentHaltingsNumber
The current number of haltings (inside)
Definition: MSE3Collector.h:417
MSMoveReminder
Something on a lane to be noticed about vehicle movement.
Definition: MSMoveReminder.h:66
MSE3Collector::myHaltingSpeedThreshold
double myHaltingSpeedThreshold
Speed-threshold to determine if a vehicle is halting.
Definition: MSE3Collector.h:362
MSE3Collector::MSE3EntryReminder::notifyMove
bool notifyMove(SUMOTrafficObject &veh, double, double newPos, double)
Checks whether the vehicle enters.
Definition: MSE3Collector.cpp:93
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:253
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:292
MSMoveReminder.h
MSE3Collector::E3Values::speedSum
double speedSum
The sum of registered speeds the vehicle has/had inside the area.
Definition: MSE3Collector.h:380
MSE3Collector::MSE3LeaveReminder::myCollector
MSE3Collector & myCollector
The parent collector.
Definition: MSE3Collector.h:200
Named.h
MSE3Collector::MSE3EntryReminder::myPosition
double myPosition
The position on the lane.
Definition: MSE3Collector.h:127
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:545
MSE3Collector::myHaltingTimeThreshold
SUMOTime myHaltingTimeThreshold
Definition: MSE3Collector.h:359
MSE3Collector::myEnteredContainer
std::map< const SUMOTrafficObject *, E3Values > myEnteredContainer
Container for vehicles that have entered the area.
Definition: MSE3Collector.h:400
MSE3Collector::myOpenEntry
const bool myOpenEntry
whether this dector is declared as having incomplete entry detectors
Definition: MSE3Collector.h:425
MSE3Collector::E3Values::haltingBegin
SUMOTime haltingBegin
Begin time of last halt begin.
Definition: MSE3Collector.h:384
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:382
MSE3Collector::MSE3EntryReminder::MSE3EntryReminder
MSE3EntryReminder(const MSCrossSection &crossSection, MSE3Collector &collector)
Constructor.
Definition: MSE3Collector.cpp:50
MSE3Collector::MSE3LeaveReminder
A place on the road net (at a certain lane and position on it) where the E3 area ends.
Definition: MSE3Collector.h:144
MSE3Collector::MSE3EntryReminder
A place on the road net (at a certain lane and position on it) where the E3 area begins.
Definition: MSE3Collector.h:66
MSE3Collector::MSE3EntryReminder::myCollector
MSE3Collector & myCollector
The parent collector.
Definition: MSE3Collector.h:124
MSE3Collector::myLeftContainer
std::vector< E3Values > myLeftContainer
Container for vehicles that have left the area.
Definition: MSE3Collector.h:403
MSE3Collector::E3Values::haltings
int haltings
The sum of haltings the vehicle has/had within the area.
Definition: MSE3Collector.h:382
MSE3Collector::E3Values::intervalTimeLoss
SUMOTime intervalTimeLoss
The timeLoss of the vehicle when entering. Updated to the current timeLoss at interval write.
Definition: MSE3Collector.h:392
MSE3Collector::operator=
MSE3Collector & operator=(const MSE3Collector &)
Invalidated assignment operator.
MSE3Collector::myEntries
CrossSectionVector myEntries
The detector's entries.
Definition: MSE3Collector.h:346
MSE3Collector::E3Values
Internal storage for values from a vehicle.
Definition: MSE3Collector.h:372
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:390
MSE3Collector::MSE3LeaveReminder::myPosition
double myPosition
The position on the lane.
Definition: MSE3Collector.h:203
MSCrossSection.h
config.h
MSE3Collector::detectorUpdate
void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
Definition: MSE3Collector.cpp:504
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:91
CrossSectionVector
std::vector< MSCrossSection > CrossSectionVector
Definition: MSCrossSection.h:63
MSE3Collector::reset
void reset()
Resets all generated values to allow computation of next interval.
Definition: MSE3Collector.cpp:325
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:137