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.org/sumo
3 // Copyright (C) 2009-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 /****************************************************************************/
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  StoHelp::writeTypedString(server.getWrapperStorage(), c.signalId);
146  StoHelp::writeTypedString(server.getWrapperStorage(), c.tripId);
147  StoHelp::writeTypedString(server.getWrapperStorage(), c.foeId);
148  StoHelp::writeTypedString(server.getWrapperStorage(), c.foeSignal);
149  StoHelp::writeTypedInt(server.getWrapperStorage(), c.limit);
150  StoHelp::writeTypedInt(server.getWrapperStorage(), c.type);
151  StoHelp::writeTypedByte(server.getWrapperStorage(), c.mustWait);
152  }
153  break;
154  }
156  std::string foeId;
157  if (!server.readTypeCheckingString(inputStorage, foeId)) {
158  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The foeId must be given as a string.", outputStorage);
159  }
160  std::vector<libsumo::TraCISignalConstraint> constraints = libsumo::TrafficLight::getConstraintsByFoe(id, foeId);
162  const int cnt = 1 + (int)constraints.size() * 5;
163  server.getWrapperStorage().writeInt(cnt);
165  server.getWrapperStorage().writeInt((int)constraints.size());
166  for (const auto& c : constraints) {
167  StoHelp::writeTypedString(server.getWrapperStorage(), c.signalId);
168  StoHelp::writeTypedString(server.getWrapperStorage(), c.tripId);
169  StoHelp::writeTypedString(server.getWrapperStorage(), c.foeId);
170  StoHelp::writeTypedString(server.getWrapperStorage(), c.foeSignal);
171  StoHelp::writeTypedInt(server.getWrapperStorage(), c.limit);
172  StoHelp::writeTypedInt(server.getWrapperStorage(), c.type);
173  StoHelp::writeTypedByte(server.getWrapperStorage(), c.mustWait);
174  }
175  break;
176  }
178  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
179  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A compound object is needed for swapping constraints.", outputStorage);
180  }
181  //read itemNo
182  inputStorage.readInt();
183  std::string tripId;
184  if (!server.readTypeCheckingString(inputStorage, tripId)) {
185  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The tripId must be given as a string.", outputStorage);
186  }
187  std::string foeSignal;
188  if (!server.readTypeCheckingString(inputStorage, foeSignal)) {
189  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The foeSignal id must be given as a string.", outputStorage);
190  }
191  std::string foeId;
192  if (!server.readTypeCheckingString(inputStorage, foeId)) {
193  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The foe tripId must be given as a string.", outputStorage);
194  }
195  std::vector<libsumo::TraCISignalConstraint> constraints = libsumo::TrafficLight::swapConstraints(id, tripId, foeSignal, foeId);
197  const int cnt = 1 + (int)constraints.size() * 5;
198  server.getWrapperStorage().writeInt(cnt);
200  server.getWrapperStorage().writeInt((int)constraints.size());
201  for (const auto& c : constraints) {
202  StoHelp::writeTypedString(server.getWrapperStorage(), c.signalId);
203  StoHelp::writeTypedString(server.getWrapperStorage(), c.tripId);
204  StoHelp::writeTypedString(server.getWrapperStorage(), c.foeId);
205  StoHelp::writeTypedString(server.getWrapperStorage(), c.foeSignal);
206  StoHelp::writeTypedInt(server.getWrapperStorage(), c.limit);
207  StoHelp::writeTypedInt(server.getWrapperStorage(), c.type);
208  StoHelp::writeTypedByte(server.getWrapperStorage(), c.mustWait);
209  }
210  break;
211  }
213  if (!MSNet::getInstance()->getTLSControl().knows(id)) {
214  throw libsumo::TraCIException("Traffic light '" + id + "' is not known");
215  }
217  const std::string& state = tls->getCurrentPhaseDef().getState();
218  const std::map<std::string, std::string>& params = tls->getParametersMap();
219  int num = 0;
220  for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
221  if ("connection:" == (*i).first.substr(0, 11)) {
222  ++num;
223  }
224  }
225 
228  server.getWrapperStorage().writeInt(num * 2);
229  for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
230  if ("connection:" != (*i).first.substr(0, 11)) {
231  continue;
232  }
234  server.getWrapperStorage().writeString((*i).second); // foreign id
235  std::string connection = (*i).first.substr(11);
236  std::string from, to;
237  const std::string::size_type b = connection.find("->");
238  if (b == std::string::npos) {
239  from = connection;
240  } else {
241  from = connection.substr(0, b);
242  to = connection.substr(b + 2);
243  }
244  bool denotesEdge = from.find("_") == std::string::npos;
245  MSLane* fromLane = nullptr;
247  MSTrafficLightLogic::LaneVectorVector::const_iterator j = lanes.begin();
248  for (; j != lanes.end() && fromLane == nullptr;) {
249  for (MSTrafficLightLogic::LaneVector::const_iterator k = (*j).begin(); k != (*j).end() && fromLane == nullptr;) {
250  if (denotesEdge && (*k)->getEdge().getID() == from) {
251  fromLane = *k;
252  } else if (!denotesEdge && (*k)->getID() == from) {
253  fromLane = *k;
254  }
255  if (fromLane == nullptr) {
256  ++k;
257  }
258  }
259  if (fromLane == nullptr) {
260  ++j;
261  }
262  }
263  if (fromLane == nullptr) {
264  return server.writeErrorStatusCmd(libsumo::CMD_GET_TL_VARIABLE, "Could not find edge or lane '" + from + "' in traffic light '" + id + "'.", outputStorage);
265  }
266  int pos = (int)std::distance(lanes.begin(), j);
268  server.getWrapperStorage().writeUnsignedByte(state[pos]); // state
269  }
270  break;
271  }
272  default:
273  return server.writeErrorStatusCmd(libsumo::CMD_GET_TL_VARIABLE, "Get TLS Variable: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
274  }
275  }
276  } catch (libsumo::TraCIException& e) {
277  return server.writeErrorStatusCmd(libsumo::CMD_GET_TL_VARIABLE, e.what(), outputStorage);
278  }
280  server.writeResponseWithLength(outputStorage, server.getWrapperStorage());
281  return true;
282 }
283 
284 
285 bool
287  tcpip::Storage& outputStorage) {
288  std::string warning = ""; // additional description for response
289  // variable
290  const int variable = inputStorage.readUnsignedByte();
291  if (variable != libsumo::TL_PHASE_INDEX && variable != libsumo::TL_PROGRAM && variable != libsumo::TL_PHASE_DURATION
293  && variable != libsumo::VAR_NAME
294  && variable != libsumo::TL_CONSTRAINT_REMOVE
295  && variable != libsumo::VAR_PARAMETER) {
296  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "Change TLS State: unsupported variable " + toHex(variable, 2) + " specified", outputStorage);
297  }
298  const std::string id = inputStorage.readString();
299  try {
300  switch (variable) {
302  int index = 0;
303  if (!server.readTypeCheckingInt(inputStorage, index)) {
304  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The phase index must be given as an integer.", outputStorage);
305  }
306  libsumo::TrafficLight::setPhase(id, index);
307  }
308  break;
309  case libsumo::VAR_NAME: {
310  std::string name;
311  if (!server.readTypeCheckingString(inputStorage, name)) {
312  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The phase name must be given as a string.", outputStorage);
313  }
314  libsumo::TrafficLight::setPhaseName(id, name);
315  }
316  break;
317  case libsumo::TL_PROGRAM: {
318  std::string subID;
319  if (!server.readTypeCheckingString(inputStorage, subID)) {
320  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The program must be given as a string.", outputStorage);
321  }
322  libsumo::TrafficLight::setProgram(id, subID);
323  }
324  break;
326  double duration = 0.;
327  if (!server.readTypeCheckingDouble(inputStorage, duration)) {
328  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The phase duration must be given as a double.", outputStorage);
329  }
330  libsumo::TrafficLight::setPhaseDuration(id, duration);
331  }
332  break;
334  std::string state;
335  if (!server.readTypeCheckingString(inputStorage, state)) {
336  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The phase must be given as a string.", outputStorage);
337  }
338  libsumo::TrafficLight::setRedYellowGreenState(id, state);
339  }
340  break;
342  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
343  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A compound object is needed for setting a new program.", outputStorage);
344  }
345  //read itemNo
346  inputStorage.readInt();
347  libsumo::TraCILogic logic;
348  if (!server.readTypeCheckingString(inputStorage, logic.programID)) {
349  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 1. parameter (programID) must be a string.", outputStorage);
350  }
351  if (!server.readTypeCheckingInt(inputStorage, logic.type)) {
352  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 2. parameter (type) must be an int.", outputStorage);
353  }
354  if (!server.readTypeCheckingInt(inputStorage, logic.currentPhaseIndex)) {
355  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 3. parameter (index) must be an int.", outputStorage);
356  }
357  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
358  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A compound object is needed for the phases.", outputStorage);
359  }
360  const int numPhases = inputStorage.readInt();
361  for (int j = 0; j < numPhases; ++j) {
362  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
363  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A compound object is needed for every phase.", outputStorage);
364  }
365  const int items = inputStorage.readInt();
366  if (items != 6 && items != 5) {
367  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A phase compound object requires 5 or 6 items.", outputStorage);
368  }
369  double duration = 0., minDuration = 0., maxDuration = 0.;
370  std::vector<int> next;
371  std::string name;
372  if (!server.readTypeCheckingDouble(inputStorage, duration)) {
373  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 4.1. parameter (duration) must be a double.", outputStorage);
374  }
375  std::string state;
376  if (!server.readTypeCheckingString(inputStorage, state)) {
377  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 4.2. parameter (phase) must be a string.", outputStorage);
378  }
379  if (!server.readTypeCheckingDouble(inputStorage, minDuration)) {
380  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 4.3. parameter (min duration) must be a double.", outputStorage);
381  }
382  if (!server.readTypeCheckingDouble(inputStorage, maxDuration)) {
383  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 4.4. parameter (max duration) must be a double.", outputStorage);
384  }
385  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
386  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program 4.5 parameter (next) must be a compound (list of ints).", outputStorage);
387  }
388  const int numNext = inputStorage.readInt();
389  for (int k = 0; k < numNext; k++) {
390  int nextEntry;
391  if (!server.readTypeCheckingInt(inputStorage, nextEntry)) {
392  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 4.5. parameter (next) must be a list of int.", outputStorage);
393  }
394  next.push_back(nextEntry);
395  }
396  if (items == 6) {
397  if (!server.readTypeCheckingString(inputStorage, name)) {
398  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 4.6. parameter (name) must be a string.", outputStorage);
399  }
400  }
401  logic.phases.emplace_back(new libsumo::TraCIPhase(duration, state, minDuration, maxDuration, next, name));
402  }
403  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
404  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "set program: 5. parameter (subparams) must be a compound object.", outputStorage);
405  }
406  const int numParams = inputStorage.readInt();
407  for (int j = 0; j < numParams; j++) {
408  std::vector<std::string> par;
409  server.readTypeCheckingStringList(inputStorage, par);
410  logic.subParameter[par[0]] = par[1];
411  }
412  libsumo::TrafficLight::setCompleteRedYellowGreenDefinition(id, logic);
413  }
414  break;
416  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
417  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A compound object is needed for removing constraints.", outputStorage);
418  }
419  //read itemNo
420  inputStorage.readInt();
421  std::string tripId;
422  if (!server.readTypeCheckingString(inputStorage, tripId)) {
423  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The tripId must be given as a string.", outputStorage);
424  }
425  std::string foeSignal;
426  if (!server.readTypeCheckingString(inputStorage, foeSignal)) {
427  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The foeSignal id must be given as a string.", outputStorage);
428  }
429  std::string foeId;
430  if (!server.readTypeCheckingString(inputStorage, foeId)) {
431  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The foe tripId must be given as a string.", outputStorage);
432  }
433  libsumo::TrafficLight::removeConstraints(id, tripId, foeSignal, foeId);
434  }
435  break;
436  case libsumo::VAR_PARAMETER: {
437  if (inputStorage.readUnsignedByte() != libsumo::TYPE_COMPOUND) {
438  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "A compound object is needed for setting a parameter.", outputStorage);
439  }
440  //read itemNo
441  inputStorage.readInt();
442  std::string name;
443  if (!server.readTypeCheckingString(inputStorage, name)) {
444  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The name of the parameter must be given as a string.", outputStorage);
445  }
446  std::string value;
447  if (!server.readTypeCheckingString(inputStorage, value)) {
448  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, "The value of the parameter must be given as a string.", outputStorage);
449  }
450  libsumo::TrafficLight::setParameter(id, name, value);
451  }
452  break;
453  default:
454  break;
455  }
456  } catch (libsumo::TraCIException& e) {
457  return server.writeErrorStatusCmd(libsumo::CMD_SET_TL_VARIABLE, e.what(), outputStorage);
458  }
459  server.writeStatusCmd(libsumo::CMD_SET_TL_VARIABLE, libsumo::RTYPE_OK, warning, outputStorage);
460  return true;
461 }
462 
463 
464 /****************************************************************************/
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:82
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
Definition: MSNet.cpp:174
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
Definition: MSNet.h:449
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.
const std::map< std::string, std::string > & 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 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)
Definition: StorageHelper.h:97
static void writeTypedString(tcpip::Storage &content, const std::string &value)
An error which allows to continue.
Definition: TraCIDefs.h:130
std::map< std::string, std::string > subParameter
Definition: TraCIDefs.h:319
std::string programID
Definition: TraCIDefs.h:315
std::vector< std::shared_ptr< libsumo::TraCIPhase > > phases
Definition: TraCIDefs.h:318
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_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_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