Line data Source code
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 : /****************************************************************************/
12 : /// @file TraCI_LaneArea.cpp
13 : /// @author Daniel Krajzewicz
14 : /// @author Mario Krumnow
15 : /// @author Jakob Erdmann
16 : /// @author Michael Behrisch
17 : /// @date 30.05.2012
18 : /// @version $Id$
19 : ///
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 :
33 : #include <microsim/output/MSDetectorControl.h>
34 : #include <microsim/output/MSE2Collector.h>
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>
44 6 : TraCI_LaneArea::getIDList() {
45 6 : std::vector<std::string> ids;
46 6 : MSNet::getInstance()->getDetectorControl().getTypedDetectors(SUMO_TAG_LANE_AREA_DETECTOR).insertIDs(ids);
47 6 : return ids;
48 : }
49 :
50 :
51 : int
52 6 : TraCI_LaneArea::getIDCount() {
53 6 : std::vector<std::string> ids;
54 6 : return (int)MSNet::getInstance()->getDetectorControl().getTypedDetectors(SUMO_TAG_LANE_AREA_DETECTOR).size();
55 : }
56 :
57 :
58 : int
59 1 : TraCI_LaneArea::getJamLengthVehicle(const std::string& detID) {
60 1 : return getDetector(detID)->getCurrentJamLengthInVehicles();
61 : }
62 :
63 :
64 : double
65 0 : TraCI_LaneArea::getJamLengthMeters(const std::string& detID) {
66 0 : return getDetector(detID)->getCurrentJamLengthInMeters();
67 : }
68 :
69 :
70 : double
71 3 : TraCI_LaneArea::getLastStepMeanSpeed(const std::string& detID) {
72 3 : return getDetector(detID)->getCurrentMeanSpeed();
73 : }
74 :
75 :
76 : std::vector<std::string>
77 3 : TraCI_LaneArea::getLastStepVehicleIDs(const std::string& detID) {
78 3 : return getDetector(detID)->getCurrentVehicleIDs();
79 : }
80 :
81 :
82 : double
83 3 : TraCI_LaneArea::getLastStepOccupancy(const std::string& detID) {
84 3 : return getDetector(detID)->getCurrentOccupancy();
85 : }
86 :
87 :
88 : double
89 4 : TraCI_LaneArea::getPosition(const std::string& detID) {
90 4 : return getDetector(detID)->getStartPos();
91 : }
92 :
93 :
94 : std::string
95 4 : TraCI_LaneArea::getLaneID(const std::string& detID) {
96 4 : return getDetector(detID)->getLane()->getID();
97 : }
98 :
99 :
100 : double
101 4 : TraCI_LaneArea::getLength(const std::string& detID) {
102 4 : const MSE2Collector* const e2 = getDetector(detID);
103 4 : return e2->getEndPos() - e2->getStartPos();
104 : }
105 :
106 :
107 : int
108 15 : TraCI_LaneArea::getLastStepVehicleNumber(const std::string& detID) {
109 15 : return getDetector(detID)->getCurrentVehicleNumber();
110 : }
111 :
112 :
113 : int
114 3 : TraCI_LaneArea::getLastStepHaltingNumber(const std::string& detID) {
115 3 : return getDetector(detID)->getCurrentHaltingNumber();
116 : }
117 :
118 :
119 : MSE2Collector*
120 40 : TraCI_LaneArea::getDetector(const std::string& id) {
121 40 : MSE2Collector* e2 = dynamic_cast<MSE2Collector*>(MSNet::getInstance()->getDetectorControl().getTypedDetectors(SUMO_TAG_LANE_AREA_DETECTOR).get(id));
122 40 : if (e2 == 0) {
123 1 : throw TraCIException("Lane area detector '" + id + "' is not known");
124 : }
125 39 : return e2;
126 43554 : }
127 :
128 :
129 : /****************************************************************************/
|