SUMO - Simulation of Urban MObility
LaneArea.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2012-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 // C++ TraCI client API implementation
21 /****************************************************************************/
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 
35 #include <microsim/MSNet.h>
36 #include <libsumo/TraCIDefs.h>
37 #include "LaneArea.h"
38 
39 
40 // ===========================================================================
41 // member definitions
42 // ===========================================================================
43 namespace libsumo {
44 std::vector<std::string>
46  std::vector<std::string> ids;
48  return ids;
49 }
50 
51 
52 int
54  std::vector<std::string> ids;
56 }
57 
58 
59 int
60 LaneArea::getJamLengthVehicle(const std::string& detID) {
62 }
63 
64 
65 double
66 LaneArea::getJamLengthMeters(const std::string& detID) {
68 }
69 
70 
71 double
72 LaneArea::getLastStepMeanSpeed(const std::string& detID) {
73  return getDetector(detID)->getCurrentMeanSpeed();
74 }
75 
76 
77 std::vector<std::string>
78 LaneArea::getLastStepVehicleIDs(const std::string& detID) {
79  return getDetector(detID)->getCurrentVehicleIDs();
80 }
81 
82 
83 double
84 LaneArea::getLastStepOccupancy(const std::string& detID) {
85  return getDetector(detID)->getCurrentOccupancy();
86 }
87 
88 
89 double
90 LaneArea::getPosition(const std::string& detID) {
91  return getDetector(detID)->getStartPos();
92 }
93 
94 
95 std::string
96 LaneArea::getLaneID(const std::string& detID) {
97  return getDetector(detID)->getLane()->getID();
98 }
99 
100 
101 double
102 LaneArea::getLength(const std::string& detID) {
103  const MSE2Collector* const e2 = getDetector(detID);
104  return e2->getEndPos() - e2->getStartPos();
105 }
106 
107 
108 int
109 LaneArea::getLastStepVehicleNumber(const std::string& detID) {
110  return getDetector(detID)->getCurrentVehicleNumber();
111 }
112 
113 
114 int
115 LaneArea::getLastStepHaltingNumber(const std::string& detID) {
116  return getDetector(detID)->getCurrentHaltingNumber();
117 }
118 
119 
121 LaneArea::getDetector(const std::string& id) {
123  if (e2 == 0) {
124  throw TraCIException("Lane area detector '" + id + "' is not known");
125  }
126  return e2;
127 }
128 }
129 
130 
131 /****************************************************************************/
const MSLane * getLane() const
Returns the lane the reminder works on.
std::vector< std::string > getCurrentVehicleIDs() const
Returns the IDs of the vehicles within the area.
static std::string getLaneID(const std::string &detID)
Definition: LaneArea.cpp:96
int getCurrentJamLengthInVehicles() const
Returns the length of all jams in vehicles.
static double getPosition(const std::string &detID)
Definition: LaneArea.cpp:90
An areal detector corresponding to a sequence of consecutive lanes.
Definition: MSE2Collector.h:86
int size() const
Returns the number of stored items within the container.
double getEndPos() const
Returns the end position of the detector.
T get(const std::string &id) const
Retrieves an item.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
double getStartPos() const
Returns the begin position of the detector.
const std::string & getID() const
Returns the id.
Definition: Named.h:65
void insertIDs(std::vector< std::string > &into) const
static int getLastStepVehicleNumber(const std::string &detID)
Definition: LaneArea.cpp:109
static double getJamLengthMeters(const std::string &detID)
Definition: LaneArea.cpp:66
static double getLength(const std::string &detID)
Definition: LaneArea.cpp:102
double getCurrentMeanSpeed() const
Returns the mean vehicle speed of vehicles currently on the detector.
static int getIDCount()
Definition: LaneArea.cpp:53
static double getLastStepMeanSpeed(const std::string &detID)
Definition: LaneArea.cpp:72
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
static int getJamLengthVehicle(const std::string &detID)
Definition: LaneArea.cpp:60
MSDetectorControl & getDetectorControl()
Returns the detector control.
Definition: MSNet.h:369
Definition: Edge.cpp:31
static std::vector< std::string > getIDList()
Definition: LaneArea.cpp:45
double getCurrentJamLengthInMeters() const
Returns the length of all jams in meters.
static int getLastStepHaltingNumber(const std::string &detID)
Definition: LaneArea.cpp:115
static double getLastStepOccupancy(const std::string &detID)
Definition: LaneArea.cpp:84
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
double getCurrentOccupancy() const
Returns the current detector occupancy.
static std::vector< std::string > getLastStepVehicleIDs(const std::string &detID)
Definition: LaneArea.cpp:78
alternative tag for e2 detector
static MSE2Collector * getDetector(const std::string &detID)
Definition: LaneArea.cpp:121
int getCurrentVehicleNumber() const
Returns the number of vehicles currently on the detector.