Eclipse SUMO - Simulation of Urban MObility
libtraci/TrafficLight.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-2020 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 <libsumo/TraCIConstants.h>
28 #include <libsumo/TrafficLight.h>
29 #include "Domain.h"
30 
31 // TODO remove the following line once the implementation is mature
32 #ifdef _MSC_VER
33 #pragma warning(disable: 4100)
34 #else
35 #pragma GCC diagnostic ignored "-Wunused-parameter"
36 #endif
37 
38 namespace libtraci {
39 
40 typedef Domain<libsumo::CMD_GET_TL_VARIABLE, libsumo::CMD_SET_TL_VARIABLE> Dom;
41 
42 // ===========================================================================
43 // static member definitions
44 // ===========================================================================
45 std::vector<std::string>
46 TrafficLight::getIDList() {
48 }
49 
50 
51 int
52 TrafficLight::getIDCount() {
53  return Dom::getInt(libsumo::ID_COUNT, "");
54 }
55 
56 
57 std::string
58 TrafficLight::getRedYellowGreenState(const std::string& tlsID) {
60 }
61 
62 
63 std::vector<libsumo::TraCILogic>
64 TrafficLight::getAllProgramLogics(const std::string& tlsID) {
65  return std::vector<libsumo::TraCILogic>(); // Dom::getStringVector(libsumo::TL_COMPLETE_DEFINITION_RYG, tlsID); TODO
66 }
67 
68 
69 std::vector<std::string>
70 TrafficLight::getControlledJunctions(const std::string& tlsID) {
72 }
73 
74 
75 std::vector<std::string>
76 TrafficLight::getControlledLanes(const std::string& tlsID) {
78 }
79 
80 
81 std::vector<std::vector<libsumo::TraCILink> >
82 TrafficLight::getControlledLinks(const std::string& tlsID) {
83  return std::vector < std::vector<libsumo::TraCILink> >(); //Dom::getStringVector(libsumo::TL_CONTROLLED_LINKS, tlsID); TODO
84 }
85 
86 
87 std::string
88 TrafficLight::getProgram(const std::string& tlsID) {
90 }
91 
92 
93 int
94 TrafficLight::getPhase(const std::string& tlsID) {
96 }
97 
98 
99 std::string
100 TrafficLight::getPhaseName(const std::string& tlsID) {
101  return Dom::getString(libsumo::VAR_NAME, tlsID);
102 }
103 
104 
105 double
106 TrafficLight::getPhaseDuration(const std::string& tlsID) {
108 }
109 
110 
111 double
112 TrafficLight::getNextSwitch(const std::string& tlsID) {
114 }
115 
116 int
117 TrafficLight::getServedPersonCount(const std::string& tlsID, int index) {
118  return Dom::getInt(libsumo::VAR_PERSON_NUMBER, tlsID); // TODO, index);
119 }
120 
121 std::vector<std::string>
122 TrafficLight::getBlockingVehicles(const std::string& tlsID, int linkIndex) {
123  return Dom::getStringVector(libsumo::TL_BLOCKING_VEHICLES, tlsID); // TODO linkIndex);
124 }
125 
126 std::vector<std::string>
127 TrafficLight::getRivalVehicles(const std::string& tlsID, int linkIndex) {
128  return Dom::getStringVector(libsumo::TL_RIVAL_VEHICLES, tlsID); // TODO linkIndex);
129 }
130 
131 std::vector<std::string>
132 TrafficLight::getPriorityVehicles(const std::string& tlsID, int linkIndex) {
133  return Dom::getStringVector(libsumo::TL_PRIORITY_VEHICLES, tlsID); // TODO linkIndex);
134 }
135 
137 
138 void
139 TrafficLight::setRedYellowGreenState(const std::string& tlsID, const std::string& state) {
141 }
142 
143 
144 void
145 TrafficLight::setPhase(const std::string& tlsID, const int index) {
146  Dom::setInt(libsumo::TL_PHASE_INDEX, tlsID, index);
147 }
148 
149 
150 void
151 TrafficLight::setPhaseName(const std::string& tlsID, const std::string& name) {
152  Dom::setString(libsumo::VAR_NAME, tlsID, name);
153 }
154 
155 
156 void
157 TrafficLight::setProgram(const std::string& tlsID, const std::string& programID) {
158  Dom::setString(libsumo::TL_PROGRAM, tlsID, programID);
159 }
160 
161 
162 void
163 TrafficLight::setPhaseDuration(const std::string& tlsID, const double phaseDuration) {
164  Dom::setDouble(libsumo::TL_PHASE_DURATION, tlsID, phaseDuration);
165 }
166 
167 
168 void
169 TrafficLight::setProgramLogic(const std::string& tlsID, const libsumo::TraCILogic& logic) {
170 // Dom::setDouble(libsumo::TL_COMPLETE_PROGRAM_RYG, tlsID, logic); todo
171 }
172 
173 
175 
176 }
177 
178 
179 /****************************************************************************/
#define LIBTRACI_SUBSCRIPTION_IMPLEMENTATION(CLASS, DOMAIN)
Definition: Domain.h:36
#define LIBTRACI_PARAMETER_IMPLEMENTATION(CLASS, DOMAIN)
Definition: Domain.h:74
C++ TraCI client API implementation.
static void setDouble(int var, const std::string &id, double value)
Definition: Domain.h:156
static std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:140
static std::string getString(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:136
static int getInt(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:116
static double getDouble(int var, const std::string &id, tcpip::Storage *add=nullptr)
Definition: Domain.h:120
static void setInt(int var, const std::string &id, int value)
Definition: Domain.h:152
static void setString(int var, const std::string &id, const std::string &value)
Definition: Domain.h:160
TRACI_CONST int VAR_NAME
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int TL_BLOCKING_VEHICLES
TRACI_CONST int TL_PRIORITY_VEHICLES
TRACI_CONST int TL_CONTROLLED_LANES
TRACI_CONST int VAR_PERSON_NUMBER
TRACI_CONST int TL_CONTROLLED_JUNCTIONS
TRACI_CONST int ID_COUNT
TRACI_CONST int TL_NEXT_SWITCH
TRACI_CONST int TL_PROGRAM
TRACI_CONST int TL_PHASE_DURATION
TRACI_CONST int TL_PHASE_INDEX
TRACI_CONST int TL_CURRENT_PHASE
TRACI_CONST int TL_RED_YELLOW_GREEN_STATE
TRACI_CONST int TL_CURRENT_PROGRAM
TRACI_CONST int TL_RIVAL_VEHICLES
Domain< libsumo::CMD_GET_BUSSTOP_VARIABLE, libsumo::CMD_SET_BUSSTOP_VARIABLE > Dom