SUMO - Simulation of Urban MObility
MultiEntryExit.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 "MultiEntryExit.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 MultiEntryExit::getLastStepVehicleNumber(const std::string& detID) {
61  return getDetector(detID)->getVehiclesWithin();
62 }
63 
64 
65 double
66 MultiEntryExit::getLastStepMeanSpeed(const std::string& detID) {
67  return getDetector(detID)->getCurrentMeanSpeed();
68 }
69 
70 
71 std::vector<std::string>
72 MultiEntryExit::getLastStepVehicleIDs(const std::string& detID) {
73  return getDetector(detID)->getCurrentVehicleIDs();
74 }
75 
76 
77 int
78 MultiEntryExit::getLastStepHaltingNumber(const std::string& detID) {
79  return getDetector(detID)->getCurrentHaltingNumber();
80 }
81 
82 
84 MultiEntryExit::getDetector(const std::string& id) {
86  if (e3 == 0) {
87  throw TraCIException("Multi entry exit detector '" + id + "' is not known");
88  }
89  return e3;
90 }
91 }
92 
93 
94 /****************************************************************************/
static double getLastStepMeanSpeed(const std::string &detID)
int getCurrentHaltingNumber() const
Returns the number of current haltings within the area.
int size() const
Returns the number of stored items within the container.
T get(const std::string &id) const
Retrieves an item.
static int getLastStepVehicleNumber(const std::string &detID)
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:167
static int getLastStepHaltingNumber(const std::string &detID)
static MSE3Collector * getDetector(const std::string &detID)
std::vector< std::string > getCurrentVehicleIDs() const
Returns the number of vehicles within the area.
void insertIDs(std::vector< std::string > &into) const
double getCurrentMeanSpeed() const
Returns the mean speed within the area.
static int getIDCount()
static std::vector< std::string > getIDList()
MSDetectorControl & getDetectorControl()
Returns the detector control.
Definition: MSNet.h:369
Definition: Edge.cpp:31
static std::vector< std::string > getLastStepVehicleIDs(const std::string &detID)
A detector of vehicles passing an area between entry/exit points.
Definition: MSE3Collector.h:64
int getVehiclesWithin() const
Returns the number of vehicles within the area.
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
alternative tag for e3 detector