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