Eclipse SUMO - Simulation of Urban MObility
TraCIServerAPI_TrafficLight.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2009-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 // APIs for getting/setting traffic light values via TraCI
22 /****************************************************************************/
23 #include <config.h>
24 
25 #include <microsim/MSLane.h>
26 #include <microsim/MSEdge.h>
29 #include <libsumo/TraCIConstants.h>
30 #include <libsumo/StorageHelper.h>
31 #include <libsumo/TrafficLight.h>
33 
34 
35 // ===========================================================================
36 // method definitions
37 // ===========================================================================
38 bool
40  tcpip::Storage& outputStorage) {
41  const int variable = inputStorage.readUnsignedByte();
42  const std::string id = inputStorage.readString();
43  server.initWrapper(libsumo::RESPONSE_GET_TL_VARIABLE, variable, id);
44  try {
45  if (!libsumo::TrafficLight::handleVariable(id, variable, &server, &inputStorage)) {
46  switch (variable) {
48  std::vector<libsumo::TraCILogic> logics = libsumo::TrafficLight::getAllProgramLogics(id);
49  tcpip::Storage& storage = server.getWrapperStorage();
50  StoHelp::writeCompound(storage, (int)logics.size());
51  for (const libsumo::TraCILogic& logic : logics) {
52  StoHelp::writeCompound(storage, 5);
53  StoHelp::writeTypedString(storage, logic.programID);
54  StoHelp::writeTypedInt(storage, logic.type);
55  StoHelp::writeTypedInt(storage, logic.currentPhaseIndex);
56  StoHelp::writeCompound(storage, (int)logic.phases.size());
57  for (const std::shared_ptr<libsumo::TraCIPhase>& phase : logic.phases) {
58  StoHelp::writeCompound(storage, 6);
59  StoHelp::writeTypedDouble(storage, phase->duration);
60  StoHelp::writeTypedString(storage, phase->state);
61  StoHelp::writeTypedDouble(storage, phase->minDur);
62  StoHelp::writeTypedDouble(storage, phase->maxDur);
63  StoHelp::writeCompound(storage, (int)phase->next.size());
64  for (int n : phase->next) {
65  StoHelp::writeTypedInt(storage, n);
66  }
67  StoHelp::writeTypedString(storage, phase->name);
68  }
69  StoHelp::writeCompound(storage, (int)logic.subParameter.size());
70  for (const auto& item : logic.subParameter) {
71  StoHelp::writeTypedStringList(storage, std::vector<std::string> {item.first, item.second});
72  }
73  }
74  break;
75  }
77  const std::vector<std::vector<libsumo::TraCILink> > links = libsumo::TrafficLight::getControlledLinks(id);
79  tcpip::Storage tempContent;
81  tempContent.writeInt((int)links.size());
82  int cnt = 1;
83  for (const std::vector<libsumo::TraCILink>& sublinks : links) {
85  tempContent.writeInt((int)sublinks.size());
86  ++cnt;
87  for (const libsumo::TraCILink& link : sublinks) {
89  tempContent.writeStringList(std::vector<std::string>({ link.fromLane, link.toLane, link.viaLane }));
90  ++cnt;
91  }
92  }
93  server.getWrapperStorage().writeInt(cnt);
94  server.getWrapperStorage().writeStorage(tempContent);
95  break;
96  }
98  int index = 0;
99  if (!server.readTypeCheckingInt(inputStorage, index)) {
100  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The phase index must be given as an integer.", outputStorage);
101  }
103  server.getWrapperStorage().writeInt(libsumo::TrafficLight::getServedPersonCount(id, index));
104  break;
105  }
107  int index = 0;
108  if (!server.readTypeCheckingInt(inputStorage, index)) {
109  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The link index must be given as an integer.", outputStorage);
110  }
112  server.getWrapperStorage().writeStringList(libsumo::TrafficLight::getBlockingVehicles(id, index));
113  break;
114  }
116  int index = 0;
117  if (!server.readTypeCheckingInt(inputStorage, index)) {
118  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The link index must be given as an integer.", outputStorage);
119  }
121  server.getWrapperStorage().writeStringList(libsumo::TrafficLight::getRivalVehicles(id, index));
122  break;
123  }
125  int index = 0;
126  if (!server.readTypeCheckingInt(inputStorage, index)) {
127  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The link index must be given as an integer.", outputStorage);
128  }
130  server.getWrapperStorage().writeStringList(libsumo::TrafficLight::getPriorityVehicles(id, index));
131  break;
132  }
133  case libsumo::TL_CONSTRAINT: {
134  std::string tripId;
135  if (!server.readTypeCheckingString(inputStorage, tripId)) {
136  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The tripId must be given as a string.", outputStorage);
137  }
138  std::vector<libsumo::TraCISignalConstraint> constraints = libsumo::TrafficLight::getConstraints(id, tripId);
140  const int cnt = 1 + (int)constraints.size() * 5;
141  server.getWrapperStorage().writeInt(cnt);
143  server.getWrapperStorage().writeInt((int)constraints.size());
144  for (const auto& c : constraints) {
145  writeConstraint(server, c);
146  }
147  break;
148  }
150  std::string foeId;
151  if (!server.readTypeCheckingString(inputStorage, foeId)) {
152  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The foeId must be given as a string.", outputStorage);
153  }
154  std::vector<libsumo::TraCISignalConstraint> constraints = libsumo::TrafficLight::getConstraintsByFoe(id, foeId);
156  const int cnt = 1 + (int)constraints.size() * 5;
157  server.getWrapperStorage().writeInt(cnt);
159  server.getWrapperStorage().writeInt((int)constraints.size());
160  for (const auto& c : constraints) {
161  writeConstraint(server, c);
162  }
163  break;
164  }
166  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
167  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A compound object is needed for swapping constraints.", outputStorage);
168  }
169  //read itemNo
170  inputStorage.readInt();
171  std::string tripId;
172  if (!server.readTypeCheckingString(inputStorage, tripId)) {
173  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The tripId must be given as a string.", outputStorage);
174  }
175  std::string foeSignal;
176  if (!server.readTypeCheckingString(inputStorage, foeSignal)) {
177  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The foeSignal id must be given as a string.", outputStorage);
178  }
179  std::string foeId;
180  if (!server.readTypeCheckingString(inputStorage, foeId)) {
181  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The foe tripId must be given as a string.", outputStorage);
182  }
183  std::vector<libsumo::TraCISignalConstraint> constraints = libsumo::TrafficLight::swapConstraints(id, tripId, foeSignal, foeId);
185  const int cnt = 1 + (int)constraints.size() * 5;
186  server.getWrapperStorage().writeInt(cnt);
188  server.getWrapperStorage().writeInt((int)constraints.size());
189  for (const auto& c : constraints) {
190  writeConstraint(server, c);
191  }
192  break;
193  }
195  if (!MSNet::getInstance()->getTLSControl().knows(id)) {
196  throw libsumo::TraCIException("Traffic light '" + id + "' is not known");
197  }
199  const std::string& state = tls->getCurrentPhaseDef().getState();
200  const Parameterised::Map& params = tls->getParametersMap();
201  int num = 0;
202  for (Parameterised::Map::const_iterator i = params.begin(); i != params.end(); ++i) {
203  if ("connection:" == (*i).first.substr(0, 11)) {
204  ++num;
205  }
206  }
207 
210  server.getWrapperStorage().writeInt(num * 2);
211  for (Parameterised::Map::const_iterator i = params.begin(); i != params.end(); ++i) {
212  if ("connection:" != (*i).first.substr(0, 11)) {
213  continue;
214  }
216  server.getWrapperStorage().writeString((*i).second); // foreign id
217  std::string connection = (*i).first.substr(11);
218  std::string from, to;
219  const std::string::size_type b = connection.find("->");
220  if (b == std::string::npos) {
221  from = connection;
222  } else {
223  from = connection.substr(0, b);
224  to = connection.substr(b + 2);
225  }
226  bool denotesEdge = from.find("_") == std::string::npos;
227  MSLane* fromLane = nullptr;
229  MSTrafficLightLogic::LaneVectorVector::const_iterator j = lanes.begin();
230  for (; j != lanes.end() && fromLane == nullptr;) {
231  for (MSTrafficLightLogic::LaneVector::const_iterator k = (*j).begin(); k != (*j).end() && fromLane == nullptr;) {
232  if (denotesEdge && (*k)->getEdge().getID() == from) {
233  fromLane = *k;
234  } else if (!denotesEdge && (*k)->getID() == from) {
235  fromLane = *k;
236  }
237  if (fromLane == nullptr) {
238  ++k;
239  }
240  }
241  if (fromLane == nullptr) {
242  ++j;
243  }
244  }
245  if (fromLane == nullptr) {
246  return server.writeErrorStatusCmd(libsumo::CMD_GET_TL_VARIABLE, "Could not find edge or lane '" + from + "' in traffic light '" + id + "'.", outputStorage);
247  }
248  int pos = (int)std::distance(lanes.begin(), j);
250  server.getWrapperStorage().writeUnsignedByte(state[pos]); // state
251  }
252  break;
253  }
254  default:
255  return server.writeErrorStatusCmd(libsumo::CMD_GET_TL_VARIABLE, "Get TLS Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
256  }
257  }
258  } catch (libsumo::TraCIException& e) {
259  return server.writeErrorStatusCmd(libsumo::CMD_GET_TL_VARIABLE, e.what(), outputStorage);
260  }
262  server.writeResponseWithLength(outputStorage, server.getWrapperStorage());
263  return true;
264 }
265 
266 
267 bool
269  tcpip::Storage& outputStorage) {
270  std::string warning = ""; // additional description for response
271  // variable
272  const int variable = inputStorage.readUnsignedByte();
273  if (variable != libsumo::TL_PHASE_INDEX && variable != libsumo::TL_PROGRAM && variable != libsumo::TL_PHASE_DURATION
275  && variable != libsumo::VAR_NAME
276  && variable != libsumo::TL_CONSTRAINT_REMOVE
277  && variable != libsumo::TL_CONSTRAINT_UPDATE
278  && variable != libsumo::TL_CONSTRAINT_ADD
279  && variable != libsumo::VAR_PARAMETER) {
280  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "Change TLS State: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
281  }
282  const std::string id = inputStorage.readString();
283  try {
284  switch (variable) {
286  int index = 0;
287  if (!server.readTypeCheckingInt(inputStorage, index)) {
288  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The phase index must be given as an integer.", outputStorage);
289  }
290  libsumo::TrafficLight::setPhase(id, index);
291  }
292  break;
293  case libsumo::VAR_NAME: {
294  std::string name;
295  if (!server.readTypeCheckingString(inputStorage, name)) {
296  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The phase name must be given as a string.", outputStorage);
297  }
298  libsumo::TrafficLight::setPhaseName(id, name);
299  }
300  break;
301  case libsumo::TL_PROGRAM: {
302  std::string subID;
303  if (!server.readTypeCheckingString(inputStorage, subID)) {
304  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The program must be given as a string.", outputStorage);
305  }
306  libsumo::TrafficLight::setProgram(id, subID);
307  }
308  break;
310  double duration = 0.;
311  if (!server.readTypeCheckingDouble(inputStorage, duration)) {
312  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The phase duration must be given as a double.", outputStorage);
313  }
314  libsumo::TrafficLight::setPhaseDuration(id, duration);
315  }
316  break;
318  std::string state;
319  if (!server.readTypeCheckingString(inputStorage, state)) {
320  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The phase must be given as a string.", outputStorage);
321  }
322  libsumo::TrafficLight::setRedYellowGreenState(id, state);
323  }
324  break;
326  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
327  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A compound object is needed for setting a new program.", outputStorage);
328  }
329  //read itemNo
330  inputStorage.readInt();
331  libsumo::TraCILogic logic;
332  if (!server.readTypeCheckingString(inputStorage, logic.programID)) {
333  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 1. parameter (programID) must be a string.", outputStorage);
334  }
335  if (!server.readTypeCheckingInt(inputStorage, logic.type)) {
336  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 2. parameter (type) must be an int.", outputStorage);
337  }
338  if (!server.readTypeCheckingInt(inputStorage, logic.currentPhaseIndex)) {
339  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 3. parameter (index) must be an int.", outputStorage);
340  }
341  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
342  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A compound object is needed for the phases.", outputStorage);
343  }
344  const int numPhases = inputStorage.readInt();
345  for (int j = 0; j < numPhases; ++j) {
346  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
347  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A compound object is needed for every phase.", outputStorage);
348  }
349  const int items = inputStorage.readInt();
350  if (items != 6 && items != 5) {
351  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A phase compound object requires 5 or 6 items.", outputStorage);
352  }
353  double duration = 0., minDuration = 0., maxDuration = 0.;
354  std::vector<int> next;
355  std::string name;
356  if (!server.readTypeCheckingDouble(inputStorage, duration)) {
357  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 4.1. parameter (duration) must be a double.", outputStorage);
358  }
359  std::string state;
360  if (!server.readTypeCheckingString(inputStorage, state)) {
361  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 4.2. parameter (phase) must be a string.", outputStorage);
362  }
363  if (!server.readTypeCheckingDouble(inputStorage, minDuration)) {
364  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 4.3. parameter (min duration) must be a double.", outputStorage);
365  }
366  if (!server.readTypeCheckingDouble(inputStorage, maxDuration)) {
367  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 4.4. parameter (max duration) must be a double.", outputStorage);
368  }
369  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
370  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program 4.5 parameter (next) must be a compound (list of ints).", outputStorage);
371  }
372  const int numNext = inputStorage.readInt();
373  for (int k = 0; k < numNext; k++) {
374  int nextEntry;
375  if (!server.readTypeCheckingInt(inputStorage, nextEntry)) {
376  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 4.5. parameter (next) must be a list of int.", outputStorage);
377  }
378  next.push_back(nextEntry);
379  }
380  if (items == 6) {
381  if (!server.readTypeCheckingString(inputStorage, name)) {
382  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 4.6. parameter (name) must be a string.", outputStorage);
383  }
384  }
385  logic.phases.emplace_back(new libsumo::TraCIPhase(duration, state, minDuration, maxDuration, next, name));
386  }
387  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
388  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 5. parameter (subparams) must be a compound object.", outputStorage);
389  }
390  const int numParams = inputStorage.readInt();
391  for (int j = 0; j < numParams; j++) {
392  std::vector<std::string> par;
393  server.readTypeCheckingStringList(inputStorage, par);
394  logic.subParameter[par[0]] = par[1];
395  }
396  libsumo::TrafficLight::setCompleteRedYellowGreenDefinition(id, logic);
397  }
398  break;
400  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
401  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A compound object is needed for removing constraints.", outputStorage);
402  }
403  //read itemNo
404  inputStorage.readInt();
405  std::string tripId;
406  if (!server.readTypeCheckingString(inputStorage, tripId)) {
407  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The tripId must be given as a string.", outputStorage);
408  }
409  std::string foeSignal;
410  if (!server.readTypeCheckingString(inputStorage, foeSignal)) {
411  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The foeSignal id must be given as a string.", outputStorage);
412  }
413  std::string foeId;
414  if (!server.readTypeCheckingString(inputStorage, foeId)) {
415  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The foe tripId must be given as a string.", outputStorage);
416  }
417  libsumo::TrafficLight::removeConstraints(id, tripId, foeSignal, foeId);
418  }
419  break;
421  std::string tripId;
422  if (!server.readTypeCheckingString(inputStorage, tripId)) {
423  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The tripId index must be given as a string.", outputStorage);
424  }
425  libsumo::TrafficLight::updateConstraints(id, tripId);
426  }
427  break;
429  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
430  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A compound object is needed for adding constraints.", outputStorage);
431  }
432  //read itemNo
433  inputStorage.readInt();
434  std::string tripId;
435  if (!server.readTypeCheckingString(inputStorage, tripId)) {
436  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The tripId must be given as a string.", outputStorage);
437  }
438  std::string foeSignal;
439  if (!server.readTypeCheckingString(inputStorage, foeSignal)) {
440  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The foe signal must be given as a string.", outputStorage);
441  }
442  std::string foeId;
443  if (!server.readTypeCheckingString(inputStorage, foeId)) {
444  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The foe tripId must be given as a string.", outputStorage);
445  }
446  int type;
447  if (!server.readTypeCheckingInt(inputStorage, type)) {
448  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The type must be an int.", outputStorage);
449  }
450  int limit;
451  if (!server.readTypeCheckingInt(inputStorage, limit)) {
452  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The limit must be an int.", outputStorage);
453  }
454  libsumo::TrafficLight::addConstraint(id, tripId, foeSignal, foeId, type, limit);
455  }
456  break;
457  case libsumo::VAR_PARAMETER: {
458  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
459  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A compound object is needed for setting a parameter.", outputStorage);
460  }
461  //read itemNo
462  inputStorage.readInt();
463  std::string name;
464  if (!server.readTypeCheckingString(inputStorage, name)) {
465  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The name of the parameter must be given as a string.", outputStorage);
466  }
467  std::string value;
468  if (!server.readTypeCheckingString(inputStorage, value)) {
469  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The value of the parameter must be given as a string.", outputStorage);
470  }
471  libsumo::TrafficLight::setParameter(id, name, value);
472  }
473  break;
474  default:
475  break;
476  }
477  } catch (libsumo::TraCIException& e) {
478  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, e.what(), outputStorage);
479  }
480  server.writeStatusCmd(libsumo::CMD_SET_TL_VARIABLE, libsumo::RTYPE_OK, warning, outputStorage);
481  return true;
482 }
483 
484 
485 void
495  std::vector<std::string> paramItems;
496  for (auto item : c.param) {
497  paramItems.push_back(item.first);
498  paramItems.push_back(item.second);
499  }
500  StoHelp::writeTypedStringList(server.getWrapperStorage(), paramItems);
501 }
502 
503 
504 /****************************************************************************/
std::string toHex(const T i, std::streamsize numDigits=0)
Definition: ToString.h:56
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:182
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition: MSNet.h:451
const std::string & getState() const
Returns the state within this phase.
MSTrafficLightLogic * getActive() const
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
The parent class for traffic light logics.
virtual const MSPhaseDefinition & getCurrentPhaseDef() const =0
Returns the definition of the current phase.
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
const LaneVectorVector & getLaneVectors() const
Returns the list of lists of all lanes controlled by this tls.
std::map< std::string, std::string > Map
parameters map
Definition: Parameterised.h:45
const Parameterised::Map & getParametersMap() const
Returns the inner key/value map.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa2: Get Traffic Lights Variable)
static void writeConstraint(TraCIServer &server, const libsumo::TraCISignalConstraint &c)
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc2: Change Traffic Lights State)
TraCI server used to control sumo by a remote TraCI client.
Definition: TraCIServer.h:59
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
tcpip::Storage & getWrapperStorage()
void initWrapper(const int domainID, const int variable, const std::string &objID)
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
static void writeTypedDouble(tcpip::Storage &content, double value)
static void writeCompound(tcpip::Storage &content, int size)
static void writeTypedInt(tcpip::Storage &content, int value)
static void writeTypedStringList(tcpip::Storage &content, const std::vector< std::string > &value)
static void writeTypedByte(tcpip::Storage &content, int value)
static void writeTypedString(tcpip::Storage &content, const std::string &value)
An error which allows to continue.
Definition: TraCIDefs.h:144
std::map< std::string, std::string > subParameter
Definition: TraCIDefs.h:378
std::string programID
Definition: TraCIDefs.h:374
std::vector< std::shared_ptr< libsumo::TraCIPhase > > phases
Definition: TraCIDefs.h:377
virtual std::string readString()
Definition: storage.cpp:180
virtual void writeString(const std::string &s)
Definition: storage.cpp:197
virtual void writeInt(int)
Definition: storage.cpp:321
virtual int readUnsignedByte()
Definition: storage.cpp:155
virtual void writeStringList(const std::vector< std::string > &s)
Definition: storage.cpp:247
virtual void writeUnsignedByte(int)
Definition: storage.cpp:165
StorageType::size_type size() const
Definition: storage.h:119
virtual void writeStorage(tcpip::Storage &store)
Definition: storage.cpp:388
virtual int readInt()
Definition: storage.cpp:311
TRACI_CONST int VAR_NAME
TRACI_CONST int CMD_GET_TL_VARIABLE
TRACI_CONST int TL_CONSTRAINT_REMOVE
TRACI_CONST int TL_BLOCKING_VEHICLES
TRACI_CONST int TL_CONSTRAINT_SWAP
TRACI_CONST int TL_PRIORITY_VEHICLES
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int TL_COMPLETE_DEFINITION_RYG
TRACI_CONST int TYPE_UBYTE
TRACI_CONST int VAR_PERSON_NUMBER
TRACI_CONST int TL_CONSTRAINT_UPDATE
TRACI_CONST int TL_EXTERNAL_STATE
TRACI_CONST int TYPE_STRINGLIST
TRACI_CONST int TL_CONTROLLED_LINKS
TRACI_CONST int TYPE_INTEGER
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int TL_CONSTRAINT_BYFOE
TRACI_CONST int TL_CONSTRAINT
TRACI_CONST int TL_PROGRAM
TRACI_CONST int RESPONSE_GET_TL_VARIABLE
TRACI_CONST int TL_PHASE_DURATION
TRACI_CONST int TL_CONSTRAINT_ADD
TRACI_CONST int TL_PHASE_INDEX
TRACI_CONST int TL_COMPLETE_PROGRAM_RYG
TRACI_CONST int CMD_SET_TL_VARIABLE
TRACI_CONST int TL_RED_YELLOW_GREEN_STATE
TRACI_CONST int RTYPE_OK
TRACI_CONST int TYPE_STRING
TRACI_CONST int TL_RIVAL_VEHICLES
std::string foeId
the tripId or vehicle id of the train that must pass first
Definition: TraCIDefs.h:655
std::string tripId
the tripId or vehicle id of the train that is constrained
Definition: TraCIDefs.h:653
std::string foeSignal
the tlsID of the rail signla that the foe must pass first
Definition: TraCIDefs.h:657
std::string signalId
the idea of the rail signal where this constraint is active
Definition: TraCIDefs.h:651
std::map< std::string, std::string > param
additional parameters
Definition: TraCIDefs.h:667
bool active
whether this constraint is active
Definition: TraCIDefs.h:665
int type
the type of constraint (predecessor:0, insertionPredecessor:1)
Definition: TraCIDefs.h:661
bool mustWait
whether tripId must still wait for foeId to pass foeSignal
Definition: TraCIDefs.h:663
int limit
the number of trains that must be recorded at the foeSignal
Definition: TraCIDefs.h:659