Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
libtraci/Edge.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2017-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/****************************************************************************/
18// C++ TraCI client API implementation
19/****************************************************************************/
20#include <config.h>
21
22#define LIBTRACI 1
23#include <iterator>
24#include <libsumo/Edge.h>
25#include "Connection.h"
26#include "Domain.h"
27
28
29namespace libtraci {
30
31typedef Domain<libsumo::CMD_GET_EDGE_VARIABLE, libsumo::CMD_SET_EDGE_VARIABLE> Dom;
32
33
34// ===========================================================================
35// static member definitions
36// ===========================================================================
37std::vector<std::string>
38Edge::getIDList() {
40}
41
42
43int
44Edge::getIDCount() {
46}
47
48
49double
50Edge::getAdaptedTraveltime(const std::string& edgeID, double time) {
51 tcpip::Storage content;
53 content.writeDouble(time);
54 return Dom::getDouble(libsumo::VAR_EDGE_TRAVELTIME, edgeID, &content);
55}
56
57
58double
59Edge::getEffort(const std::string& edgeID, double time) {
60 tcpip::Storage content;
62 content.writeDouble(time);
63 return Dom::getDouble(libsumo::VAR_EDGE_EFFORT, edgeID, &content);
64}
65
66
67double
68Edge::getTraveltime(const std::string& edgeID) {
70}
71
72
73double
74Edge::getWaitingTime(const std::string& edgeID) {
76}
77
78
79const std::vector<std::string>
80Edge::getLastStepPersonIDs(const std::string& edgeID) {
82}
83
84
85const std::vector<std::string>
86Edge::getLastStepVehicleIDs(const std::string& edgeID) {
88}
89
90
91double
92Edge::getCO2Emission(const std::string& edgeID) {
94}
95
96
97double
98Edge::getCOEmission(const std::string& edgeID) {
100}
101
102
103double
104Edge::getHCEmission(const std::string& edgeID) {
106}
107
108
109double
110Edge::getPMxEmission(const std::string& edgeID) {
112}
113
114
115double
116Edge::getNOxEmission(const std::string& edgeID) {
118}
119
120
121double
122Edge::getFuelConsumption(const std::string& edgeID) {
124}
125
126
127double
128Edge::getNoiseEmission(const std::string& edgeID) {
130}
131
132
133double
134Edge::getElectricityConsumption(const std::string& edgeID) {
136}
137
138
139int
140Edge::getLastStepVehicleNumber(const std::string& edgeID) {
142}
143
144
145double
146Edge::getLastStepMeanSpeed(const std::string& edgeID) {
148}
149
150
151double
152Edge::getMeanFriction(const std::string& edgeID) {
154}
155
156
157double
158Edge::getLastStepOccupancy(const std::string& edgeID) {
160}
161
162
163int
164Edge::getLastStepHaltingNumber(const std::string& edgeID) {
166}
167
168
169double
170Edge::getLastStepLength(const std::string& edgeID) {
172}
173
174
175int
176Edge::getLaneNumber(const std::string& edgeID) {
177 return Dom::getInt(libsumo::VAR_LANE_INDEX, edgeID);
178}
179
180
181std::string
182Edge::getStreetName(const std::string& edgeID) {
183 return Dom::getString(libsumo::VAR_NAME, edgeID);
184}
185
186
187const std::vector<std::string>
188Edge::getPendingVehicles(const std::string& edgeID) {
190}
191
192
193double
194Edge::getAngle(const std::string& edgeID, double relativePosition) {
195 tcpip::Storage content;
197 content.writeDouble(relativePosition);
198 return Dom::getDouble(libsumo::VAR_ANGLE, edgeID, &content);
199}
200
201
202std::string
203Edge::getFromJunction(const std::string& edgeID) {
205}
206
207
208std::string
209Edge::getToJunction(const std::string& edgeID) {
210 return Dom::getString(libsumo::TO_JUNCTION, edgeID);
211}
212
213std::string
214Edge::getBidiEdge(const std::string& edgeID) {
215 return Dom::getString(libsumo::VAR_BIDI, edgeID);
216}
217
220
221
222void
223Edge::setAllowed(const std::string& edgeID, std::string allowedClasses) {
224 setAllowed(edgeID, std::vector<std::string>({allowedClasses}));
225}
226
227
228void
229Edge::setAllowed(const std::string& edgeID, std::vector<std::string> allowedClasses) {
230 Dom::setStringVector(libsumo::LANE_ALLOWED, edgeID, allowedClasses);
231}
232
233
234void
235Edge::setDisallowed(const std::string& edgeID, std::string disallowedClasses) {
236 setDisallowed(edgeID, std::vector<std::string>({disallowedClasses}));
237}
238
239
240void
241Edge::setDisallowed(const std::string& edgeID, std::vector<std::string> disallowedClasses) {
242 Dom::setStringVector(libsumo::LANE_DISALLOWED, edgeID, disallowedClasses);
243}
244
245
246void
247Edge::adaptTraveltime(const std::string& edgeID, double time, double beginSeconds, double endSeconds) {
248 tcpip::Storage content;
250 if (endSeconds != std::numeric_limits<double>::max()) {
251 content.writeInt(3);
253 content.writeDouble(beginSeconds);
255 content.writeDouble(endSeconds);
256 } else {
257 content.writeInt(1);
258 }
260 content.writeDouble(time);
261 Dom::set(libsumo::VAR_EDGE_TRAVELTIME, edgeID, &content);
262}
263
264
265void
266Edge::setEffort(const std::string& edgeID, double effort, double beginSeconds, double endSeconds) {
267 tcpip::Storage content;
269 if (endSeconds != std::numeric_limits<double>::max()) {
270 content.writeInt(3);
272 content.writeDouble(beginSeconds);
274 content.writeDouble(endSeconds);
275 } else {
276 content.writeInt(1);
277 }
279 content.writeDouble(effort);
280 Dom::set(libsumo::VAR_EDGE_EFFORT, edgeID, &content);
281}
282
283
284void
285Edge::setMaxSpeed(const std::string& edgeID, double speed) {
287}
288
289
290void
291Edge::setFriction(const std::string& edgeID, double friction) {
292 Dom::setDouble(libsumo::VAR_MAXSPEED, edgeID, friction);
293}
294
295}
296
297
298/****************************************************************************/
#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 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 void setStringVector(int var, const std::string &id, const std::vector< std::string > &value)
Definition Domain.h:245
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 void set(int var, const std::string &id, tcpip::Storage *add)
Definition Domain.h:219
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition Domain.h:130
virtual void writeInt(int)
Definition storage.cpp:321
virtual void writeDouble(double)
Definition storage.cpp:354
virtual void writeUnsignedByte(int)
Definition storage.cpp:165
virtual void writeByte(int)
Definition storage.cpp:140
TRACI_CONST int LAST_STEP_VEHICLE_ID_LIST
TRACI_CONST int LAST_STEP_VEHICLE_NUMBER
TRACI_CONST int VAR_NOXEMISSION
TRACI_CONST int VAR_NAME
TRACI_CONST int LAST_STEP_PERSON_ID_LIST
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_WAITING_TIME
TRACI_CONST int VAR_EDGE_TRAVELTIME
TRACI_CONST int LAST_STEP_LENGTH
TRACI_CONST int VAR_ANGLE
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int VAR_EDGE_EFFORT
TRACI_CONST int VAR_LANE_INDEX
TRACI_CONST int VAR_PMXEMISSION
TRACI_CONST int VAR_COEMISSION
TRACI_CONST int VAR_MAXSPEED
TRACI_CONST int LAST_STEP_MEAN_SPEED
TRACI_CONST int VAR_CO2EMISSION
TRACI_CONST int VAR_PENDING_VEHICLES
TRACI_CONST int VAR_FUELCONSUMPTION
TRACI_CONST int LAST_STEP_VEHICLE_HALTING_NUMBER
TRACI_CONST int VAR_HCEMISSION
TRACI_CONST int ID_COUNT
TRACI_CONST int LAST_STEP_OCCUPANCY
TRACI_CONST int VAR_BIDI
TRACI_CONST int VAR_NOISEEMISSION
TRACI_CONST int LANE_DISALLOWED
TRACI_CONST int VAR_FRICTION
TRACI_CONST int FROM_JUNCTION
TRACI_CONST int TYPE_DOUBLE
TRACI_CONST int VAR_CURRENT_TRAVELTIME
TRACI_CONST int LANE_ALLOWED
TRACI_CONST int VAR_ELECTRICITYCONSUMPTION
TRACI_CONST int TO_JUNCTION
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom