Eclipse SUMO - Simulation of Urban MObility
libtraci/Edge.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2017-2022 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
150double
151Edge::getMeanFriction(const std::string& edgeID) {
153}
154
155double
156Edge::getLastStepOccupancy(const std::string& edgeID) {
158}
159
160
161int
162Edge::getLastStepHaltingNumber(const std::string& edgeID) {
164}
165
166
167double
168Edge::getLastStepLength(const std::string& edgeID) {
170}
171
172
173int
174Edge::getLaneNumber(const std::string& edgeID) {
175 return Dom::getInt(libsumo::VAR_LANE_INDEX, edgeID);
176}
177
178
179std::string
180Edge::getStreetName(const std::string& edgeID) {
181 return Dom::getString(libsumo::VAR_NAME, edgeID);
182}
183
184const std::vector<std::string>
185Edge::getPendingVehicles(const std::string& edgeID) {
187}
188
191
192
193void
194Edge::setAllowedVehicleClasses(const std::string& edgeID, std::vector<std::string> classes) {
196}
197
198
199void
200Edge::setDisallowedVehicleClasses(const std::string& edgeID, std::vector<std::string> classes) {
202}
203
204
205void
206Edge::adaptTraveltime(const std::string& edgeID, double time, double beginSeconds, double endSeconds) {
207 tcpip::Storage content;
209 if (endSeconds != std::numeric_limits<double>::max()) {
210 content.writeInt(3);
212 content.writeDouble(beginSeconds);
214 content.writeDouble(endSeconds);
215 } else {
216 content.writeInt(1);
217 }
219 content.writeDouble(time);
221}
222
223
224void
225Edge::setEffort(const std::string& edgeID, double effort, double beginSeconds, double endSeconds) {
226 tcpip::Storage content;
228 if (endSeconds != std::numeric_limits<double>::max()) {
229 content.writeInt(3);
231 content.writeDouble(beginSeconds);
233 content.writeDouble(endSeconds);
234 } else {
235 content.writeInt(1);
236 }
238 content.writeDouble(effort);
240}
241
242
243void
244Edge::setMaxSpeed(const std::string& edgeID, double speed) {
246}
247
248void
249Edge::setFriction(const std::string& edgeID, double friction) {
250 Dom::setDouble(libsumo::VAR_MAXSPEED, edgeID, friction);
251}
252
253}
254
255
256/****************************************************************************/
#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:55
tcpip::Storage & doCommand(int command, int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Connection.cpp:328
static void setDouble(int var, const std::string &id, double value)
Definition: Domain.h:220
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:171
static void setStringVector(int var, const std::string &id, const std::vector< std::string > &value)
Definition: Domain.h:234
static std::string getString(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:167
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:129
virtual void writeInt(int)
Definition: storage.cpp:321
virtual void writeDouble(double)
Definition: storage.cpp:354
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 CMD_SET_EDGE_VARIABLE
TRACI_CONST int VAR_WAITING_TIME
TRACI_CONST int VAR_EDGE_TRAVELTIME
TRACI_CONST int LAST_STEP_LENGTH
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_NOISEEMISSION
TRACI_CONST int LANE_DISALLOWED
TRACI_CONST int VAR_FRICTION
TRACI_CONST int TYPE_DOUBLE
TRACI_CONST int VAR_CURRENT_TRAVELTIME
TRACI_CONST int LANE_ALLOWED
TRACI_CONST int VAR_ELECTRICITYCONSUMPTION
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom