Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
libtraci/InductionLoop.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2012-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21// C++ TraCI client API implementation
22/****************************************************************************/
23#include <config.h>
24
25#define LIBTRACI 1
27#include "Domain.h"
28
29
30namespace libtraci {
31
32typedef Domain<libsumo::CMD_GET_INDUCTIONLOOP_VARIABLE, libsumo::CMD_SET_INDUCTIONLOOP_VARIABLE> Dom;
33
34
35// ===========================================================================
36// member definitions
37// ===========================================================================
38std::vector<std::string>
39InductionLoop::getIDList() {
41}
42
43
44int
45InductionLoop::getIDCount() {
47}
48
49
50double
51InductionLoop::getPosition(const std::string& loopID) {
53}
54
55
56std::string
57InductionLoop::getLaneID(const std::string& loopID) {
59}
60
61
62int
63InductionLoop::getLastStepVehicleNumber(const std::string& loopID) {
65}
66
67
68double
69InductionLoop::getLastStepMeanSpeed(const std::string& loopID) {
71}
72
73
74std::vector<std::string>
75InductionLoop::getLastStepVehicleIDs(const std::string& loopID) {
77}
78
79
80double
81InductionLoop::getLastStepOccupancy(const std::string& loopID) {
83}
84
85
86double
87InductionLoop::getLastStepMeanLength(const std::string& loopID) {
89}
90
91
92double
93InductionLoop::getTimeSinceDetection(const std::string& loopID) {
95}
96
97
98std::vector<libsumo::TraCIVehicleData>
99InductionLoop::getVehicleData(const std::string& loopID) {
100 std::unique_lock<std::mutex> lock{ libtraci::Connection::getActive().getMutex() };
101 std::vector<libsumo::TraCIVehicleData> result;
103 ret.readInt(); // components
104 // number of items
105 ret.readUnsignedByte();
106 const int n = ret.readInt();
107 for (int i = 0; i < n; ++i) {
109
110 ret.readUnsignedByte();
111 vd.id = ret.readString();
112
113 ret.readUnsignedByte();
114 vd.length = ret.readDouble();
115
116 ret.readUnsignedByte();
117 vd.entryTime = ret.readDouble();
118
119 ret.readUnsignedByte();
120 vd.leaveTime = ret.readDouble();
121
122 ret.readUnsignedByte();
123 vd.typeID = ret.readString();
124
125 result.push_back(vd);
126 }
127 return result;
128}
129
130
131double
132InductionLoop::getIntervalOccupancy(const std::string& loopID) {
134}
135
136
137double
138InductionLoop::getIntervalMeanSpeed(const std::string& loopID) {
140}
141
142
143int
144InductionLoop::getIntervalVehicleNumber(const std::string& loopID) {
146}
147
148
149std::vector<std::string>
150InductionLoop::getIntervalVehicleIDs(const std::string& loopID) {
152}
153
154
155double
156InductionLoop::getLastIntervalOccupancy(const std::string& loopID) {
158}
159
160
161double
162InductionLoop::getLastIntervalMeanSpeed(const std::string& loopID) {
164}
165
166
167int
168InductionLoop::getLastIntervalVehicleNumber(const std::string& loopID) {
170}
171
172
173std::vector<std::string>
174InductionLoop::getLastIntervalVehicleIDs(const std::string& loopID) {
176}
177
178
179void
180InductionLoop::overrideTimeSinceDetection(const std::string& loopID, double time) {
182}
183
184
187
188
189} // namespace libtraci
190
191/****************************************************************************/
#define LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition Domain.h:38
#define LIBTRACI_PARAMETER_IMPLEMENTATION(CLASS, DOMAIN)
Definition Domain.h:77
C++ TraCI client API implementation.
static Connection & getActive()
Definition Connection.h:57
std::mutex & getMutex() const
Definition Connection.h:76
static void setDouble(int var, const std::string &id, double value)
Definition Domain.h:231
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:177
static std::string getString(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:172
static int getInt(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:125
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:130
static tcpip::Storage & get(int var, const std::string &id, tcpip::Storage *add=nullptr, int expectedType=libsumo::TYPE_COMPOUND)
Definition Domain.h:111
virtual std::string readString()
Definition storage.cpp:180
virtual int readUnsignedByte()
Definition storage.cpp:155
virtual double readDouble()
Definition storage.cpp:362
virtual int readInt()
Definition storage.cpp:311
TRACI_CONST int LAST_STEP_VEHICLE_ID_LIST
TRACI_CONST int VAR_INTERVAL_NUMBER
TRACI_CONST int LAST_STEP_VEHICLE_NUMBER
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int LAST_STEP_VEHICLE_DATA
TRACI_CONST int VAR_LAST_INTERVAL_IDS
TRACI_CONST int VAR_LAST_INTERVAL_NUMBER
TRACI_CONST int LAST_STEP_LENGTH
TRACI_CONST int VAR_POSITION
TRACI_CONST int LAST_STEP_MEAN_SPEED
TRACI_CONST int VAR_LAST_INTERVAL_OCCUPANCY
TRACI_CONST int VAR_INTERVAL_IDS
TRACI_CONST int ID_COUNT
TRACI_CONST int VAR_LANE_ID
TRACI_CONST int LAST_STEP_OCCUPANCY
TRACI_CONST int VAR_INTERVAL_SPEED
TRACI_CONST int VAR_LAST_INTERVAL_SPEED
TRACI_CONST int VAR_INTERVAL_OCCUPANCY
TRACI_CONST int VAR_VIRTUAL_DETECTION
TRACI_CONST int LAST_STEP_TIME_SINCE_DETECTION
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom
mirrors MSInductLoop::VehicleData
Definition TraCIDefs.h:416
std::string id
The id of the vehicle.
Definition TraCIDefs.h:418
double entryTime
Entry-time of the vehicle in [s].
Definition TraCIDefs.h:422
std::string typeID
Type of the vehicle in.
Definition TraCIDefs.h:426
double length
Length of the vehicle.
Definition TraCIDefs.h:420
double leaveTime
Leave-time of the vehicle in [s].
Definition TraCIDefs.h:424