SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MSE3Collector.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // A detector of vehicles passing an area between entry/exit points
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2003-2016 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSE3Collector_h
24 #define MSE3Collector_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <vector>
38 #include <limits>
41 #include <utils/common/Named.h>
44 
45 
46 // ===========================================================================
47 // class declarations
48 // ===========================================================================
49 class SUMOVehicle;
50 class OutputDevice;
51 
52 
53 // ===========================================================================
54 // class definitions
55 // ===========================================================================
66 public:
72  public:
78  MSE3EntryReminder(const MSCrossSection& crossSection, MSE3Collector& collector);
79 
80 
83 
99  bool notifyMove(SUMOVehicle& veh, SUMOReal , SUMOReal newPos, SUMOReal);
100 
101 
112  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, MSMoveReminder::Notification reason);
114 
115 
116  private:
119 
122 
123  private:
126 
129 
130  };
131 
132 
133 
139  public:
145  MSE3LeaveReminder(const MSCrossSection& crossSection, MSE3Collector& collector);
146 
147 
149 
150 
166  bool notifyMove(SUMOVehicle& veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal);
167 
177  bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, MSMoveReminder::Notification reason);
179 
180 
181  private:
184 
187 
188  private:
191 
194 
195  };
196 
197 
208  MSE3Collector(const std::string& id,
209  const CrossSectionVector& entries, const CrossSectionVector& exits,
210  SUMOReal haltingSpeedThreshold,
211  SUMOTime haltingTimeThreshold,
212  const std::string& vTypes);
213 
214 
216  virtual ~MSE3Collector();
217 
218 
221  void reset();
222 
223 
232  void enter(const SUMOVehicle& veh, const SUMOReal entryTimestep, const SUMOReal fractionTimeOnDet);
233 
234 
240  void leaveFront(const SUMOVehicle& veh, const SUMOReal leaveTimestep);
241 
242 
251  void leave(const SUMOVehicle& veh, const SUMOReal leaveTimestep, const SUMOReal fractionTimeOnDet);
252 
253 
256 
264 
265 
272  int getCurrentHaltingNumber() const;
273 
274 
278  int getVehiclesWithin() const;
279 
280 
285  std::vector<std::string> getCurrentVehicleIDs() const;
287 
288 
291 
300  void writeXMLOutput(OutputDevice& dev, SUMOTime startTime, SUMOTime stopTime);
301 
302 
311  void writeXMLDetectorProlog(OutputDevice& dev) const;
313 
314 
315 
324  void detectorUpdate(const SUMOTime step);
325 
326 
327 protected:
330 
333 
335  std::vector<MSE3EntryReminder*> myEntryReminders;
336 
338  std::vector<MSE3LeaveReminder*> myLeaveReminders;
339 
340 
341  // @brief Time-threshold to determine if a vehicle is halting.
343 
346 
355  struct E3Values {
365  int haltings;
373  bool hadUpdate;
374  };
375 
377  std::map<const SUMOVehicle*, E3Values> myEnteredContainer;
378 
380  std::map<const SUMOVehicle*, E3Values> myLeftContainer;
381 
382 
385 
388 
392 
393 
396 
397 
398 private:
401 
404 
405 
406 };
407 
408 
409 #endif
410 
411 /****************************************************************************/
412 
MSE3LeaveReminder & operator=(const MSE3LeaveReminder &)
Invalidated assignment operator.
long long int SUMOTime
Definition: SUMOTime.h:43
int haltings
The sum of haltings the vehicle has/had within the area.
virtual ~MSE3Collector()
Destructor.
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Processes state changes of a vehicle.
A simple description of a position on a lane (crossing of a lane)
std::vector< MSE3EntryReminder * > myEntryReminders
The detector's built entry reminder.
SUMOReal entryTime
The vehicle's entry time.
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:71
SUMOReal myPosition
The position on the lane.
Notification
Definition of a vehicle state.
void enter(const SUMOVehicle &veh, const SUMOReal entryTimestep, const SUMOReal fractionTimeOnDet)
Called if a vehicle touches an entry-cross-section.
std::vector< MSCrossSection > CrossSectionVector
SUMOReal backLeaveTime
The time the vehicle's back was crossing the leave line.
SUMOTime myLastResetTime
Information when the last reset has been done.
std::vector< MSE3LeaveReminder * > myLeaveReminders
The detector's built exit reminder.
SUMOReal haltingBegin
Begin time of last halt begin.
SUMOReal myPosition
The position on the lane.
MSE3EntryReminder & operator=(const MSE3EntryReminder &)
Invalidated assignment operator.
int myCurrentHaltingsNumber
The current number of haltings (inside)
SUMOReal frontLeaveTime
The time the vehicle's front was crossing the leave line.
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.
void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "e3Detector" as root element.
SUMOTime myHaltingTimeThreshold
MSE3Collector & operator=(const MSE3Collector &)
Invalidated assignment operator.
MSE3Collector & myCollector
The parent collector.
SUMOReal myHaltingSpeedThreshold
Speed-threshold to determine if a vehicle is halting.
Something on a lane to be noticed about vehicle movement.
int getVehiclesWithin() const
Returns the number of vehicles within the area.
MSE3LeaveReminder(const MSCrossSection &crossSection, MSE3Collector &collector)
Constructor.
CrossSectionVector myEntries
The detector's entries.
void leaveFront(const SUMOVehicle &veh, const SUMOReal leaveTimestep)
Called if a vehicle front passes a leave-cross-section.
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:65
bool notifyMove(SUMOVehicle &veh, SUMOReal, SUMOReal newPos, SUMOReal)
Checks whether the vehicle enters.
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:71
#define SUMOReal
Definition: config.h:214
bool notifyLeave(SUMOVehicle &veh, SUMOReal lastPos, MSMoveReminder::Notification reason)
Processes state changes of a vehicle.
SUMOReal speedSum
The sum of registered speeds the vehicle has/had inside the area.
SUMOReal getCurrentMeanSpeed() const
Returns the mean speed within the area.
bool notifyMove(SUMOVehicle &veh, SUMOReal oldPos, SUMOReal newPos, SUMOReal)
Checks whether the vehicle leaves.
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
void detectorUpdate(const SUMOTime step)
Computes the detector values in each time step.
void leave(const SUMOVehicle &veh, const SUMOReal leaveTimestep, const SUMOReal fractionTimeOnDet)
Called if a vehicle back passes a leave-cross-section.
MSE3Collector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, SUMOReal haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes)
Constructor.
SUMOReal intervalSpeedSum
The sum of registered speeds the vehicle has/had inside the area during the current interval...
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Writes collected values into the given stream.
MSE3Collector & myCollector
The parent collector.
Base of value-generating classes (detectors)
std::vector< std::string > getCurrentVehicleIDs() const
Returns the number of vehicles within the area.
CrossSectionVector myExits
The detector's exits.
std::map< const SUMOVehicle *, E3Values > myLeftContainer
Container for vehicles that have left the area.
SUMOReal myCurrentMeanSpeed
The current mean speed of known vehicles (inside)