SUMO - Simulation of Urban MObility
TraCI_LaneArea.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // C++ TraCI client API implementation
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2012-2017 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 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
36 #include <microsim/MSNet.h>
37 #include <traci-server/TraCIDefs.h>
38 #include "TraCI_LaneArea.h"
39 
40 
41 // ===========================================================================
42 // member definitions
43 // ===========================================================================
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 TraCI_LaneArea::getJamLengthVehicle(const std::string& detID) {
62 }
63 
64 
65 double
66 TraCI_LaneArea::getJamLengthMeters(const std::string& detID) {
68 }
69 
70 
71 double
72 TraCI_LaneArea::getLastStepMeanSpeed(const std::string& detID) {
73  return getDetector(detID)->getCurrentMeanSpeed();
74 }
75 
76 
77 std::vector<std::string>
78 TraCI_LaneArea::getLastStepVehicleIDs(const std::string& detID) {
79  return getDetector(detID)->getCurrentVehicleIDs();
80 }
81 
82 
83 double
84 TraCI_LaneArea::getLastStepOccupancy(const std::string& detID) {
85  return getDetector(detID)->getCurrentOccupancy();
86 }
87 
88 
89 double
90 TraCI_LaneArea::getPosition(const std::string& detID) {
91  return getDetector(detID)->getStartPos();
92 }
93 
94 
95 std::string
96 TraCI_LaneArea::getLaneID(const std::string& detID) {
97  return getDetector(detID)->getLane()->getID();
98 }
99 
100 
101 double
102 TraCI_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 TraCI_LaneArea::getLastStepVehicleNumber(const std::string& detID) {
110  return getDetector(detID)->getCurrentVehicleNumber();
111 }
112 
113 
114 int
115 TraCI_LaneArea::getLastStepHaltingNumber(const std::string& detID) {
116  return getDetector(detID)->getCurrentHaltingNumber();
117 }
118 
119 
121 TraCI_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 /****************************************************************************/
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:87
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:158
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:66
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:373
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 items within the container.