Eclipse SUMO - Simulation of Urban MObility
TraCITestClient.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2008-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 /****************************************************************************/
23 // A test execution class
24 /****************************************************************************/
25 /* =========================================================================
26  * included modules
27  * ======================================================================= */
28 #ifdef _MSC_VER
29 #define _CRT_SECURE_NO_WARNINGS
30 #endif
31 #include <vector>
32 #include <iostream>
33 #include <iomanip>
34 #include <fstream>
35 #include <sstream>
36 #include <ctime>
37 #include <cstdlib>
38 
39 #define BUILD_TCPIP
40 #include <foreign/tcpip/storage.h>
41 #include <foreign/tcpip/socket.h>
42 
43 #include <libsumo/TraCIConstants.h>
44 #include <libsumo/TraCIDefs.h>
45 #include "TraCITestClient.h"
46 
47 
48 // ===========================================================================
49 // method definitions
50 // ===========================================================================
51 TraCITestClient::TraCITestClient(std::string outputFileName)
52  : outputFileName(outputFileName), answerLog("") {
53  answerLog.setf(std::ios::fixed, std::ios::floatfield); // use decimal format
54  answerLog.setf(std::ios::showpoint); // print decimal point
55  answerLog << std::setprecision(2);
56 }
57 
58 
60  writeResult();
61 }
62 
63 
64 int
65 TraCITestClient::run(std::string fileName, int port, std::string host) {
66  std::ifstream defFile;
67  std::string fileContentStr;
68  std::stringstream fileContent;
69  std::string lineCommand;
70  std::stringstream msg;
71  int repNo = 1;
72  bool commentRead = false;
73 
74  // try to connect
75  try {
76  TraCIAPI::connect(host, port);
77  } catch (tcpip::SocketException& e) {
78  msg << "#Error while connecting: " << e.what();
79  errorMsg(msg);
80  return 2;
81  }
82 
83  // read definition file and trigger commands according to it
84  defFile.open(fileName.c_str());
85  if (!defFile) {
86  msg << "Can not open definition file " << fileName << std::endl;
87  errorMsg(msg);
88  return 1;
89  }
90  defFile.unsetf(std::ios::dec);
91 
92  while (defFile >> lineCommand) {
93  repNo = 1;
94  if (lineCommand.compare("%") == 0) {
95  // a comment was read
96  commentRead = !commentRead;
97  continue;
98  }
99  if (commentRead) {
100  // wait until end of comment is reached
101  continue;
102  }
103  if (lineCommand.compare("repeat") == 0) {
104  defFile >> repNo;
105  defFile >> lineCommand;
106  }
107  if (lineCommand.compare("simstep2") == 0) {
108  // read parameter for command simulation step and trigger command
109  double time;
110  defFile >> time;
111  for (int i = 0; i < repNo; i++) {
112  commandSimulationStep(time);
113  }
114  } else if (lineCommand.compare("getvariable") == 0) {
115  // trigger command GetXXXVariable
116  int domID, varID;
117  std::string objID;
118  defFile >> domID >> varID >> objID;
119  commandGetVariable(domID, varID, objID);
120  } else if (lineCommand.compare("getvariable_plus") == 0) {
121  // trigger command GetXXXVariable with one parameter
122  int domID, varID;
123  std::string objID;
124  defFile >> domID >> varID >> objID;
125  tcpip::Storage tmp;
126  setValueTypeDependant(tmp, defFile, msg);
127  std::string msgS = msg.str();
128  if (msgS != "") {
129  errorMsg(msg);
130  }
131  commandGetVariable(domID, varID, objID, &tmp);
132  } else if (lineCommand.compare("subscribevariable") == 0) {
133  // trigger command SubscribeXXXVariable
134  int domID, varNo;
135  double beginTime, endTime;
136  std::string objID;
137  defFile >> domID >> objID >> beginTime >> endTime >> varNo;
138  commandSubscribeObjectVariable(domID, objID, beginTime, endTime, varNo, defFile);
139  } else if (lineCommand.compare("subscribecontext") == 0) {
140  // trigger command SubscribeXXXVariable
141  int domID, varNo, domain;
142  double range;
143  double beginTime, endTime;
144  std::string objID;
145  defFile >> domID >> objID >> beginTime >> endTime >> domain >> range >> varNo;
146  commandSubscribeContextVariable(domID, objID, beginTime, endTime, domain, range, varNo, defFile);
147  } else if (lineCommand.compare("setvalue") == 0) {
148  // trigger command SetXXXValue
149  int domID, varID;
150  std::string objID;
151  defFile >> domID >> varID >> objID;
152  commandSetValue(domID, varID, objID, defFile);
153  } else if (lineCommand.compare("testAPI") == 0) {
154  // call all native API methods
155  testAPI();
156  } else if (lineCommand.compare("setorder") == 0) {
157  // call setOrder
158  int order;
159  defFile >> order;
160  commandSetOrder(order);
161  } else {
162  msg << "Error in definition file: " << lineCommand << " is not a valid command";
163  errorMsg(msg);
164  commandClose();
165  closeSocket();
166  return 1;
167  }
168  }
169  defFile.close();
170  commandClose();
171  closeSocket();
172  return 0;
173 }
174 
175 
176 // ---------- Commands handling
177 void
179  try {
181  answerLog << std::endl << "-> Command sent: <SimulationStep>:" << std::endl;
182  tcpip::Storage inMsg;
183  std::string acknowledgement;
184  check_resultState(inMsg, libsumo::CMD_SIMSTEP, false, &acknowledgement);
185  answerLog << acknowledgement << std::endl;
187  } catch (libsumo::TraCIException& e) {
188  answerLog << e.what() << std::endl;
189  }
190 }
191 
192 
193 void
195  try {
197  answerLog << std::endl << "-> Command sent: <Close>:" << std::endl;
198  tcpip::Storage inMsg;
199  std::string acknowledgement;
200  check_resultState(inMsg, libsumo::CMD_CLOSE, false, &acknowledgement);
201  answerLog << acknowledgement << std::endl;
202  } catch (libsumo::TraCIException& e) {
203  answerLog << e.what() << std::endl;
204  }
205 }
206 
207 
208 void
210  try {
211  send_commandSetOrder(order);
212  answerLog << std::endl << "-> Command sent: <SetOrder>:" << std::endl;
213  tcpip::Storage inMsg;
214  std::string acknowledgement;
215  check_resultState(inMsg, libsumo::CMD_SETORDER, false, &acknowledgement);
216  answerLog << acknowledgement << std::endl;
217  } catch (libsumo::TraCIException& e) {
218  answerLog << e.what() << std::endl;
219  }
220 }
221 
222 
223 void
224 TraCITestClient::commandGetVariable(int domID, int varID, const std::string& objID, tcpip::Storage* addData) {
225  tcpip::Storage inMsg;
226  try {
227  createCommand(domID, varID, objID, addData);
229  answerLog << std::endl << "-> Command sent: <GetVariable>:" << std::endl
230  << " domID=" << domID << " varID=" << varID
231  << " objID=" << objID << std::endl;
232  std::string acknowledgement;
233  check_resultState(inMsg, domID, false, &acknowledgement);
234  answerLog << acknowledgement << std::endl;
235  } catch (libsumo::TraCIException& e) {
236  answerLog << e.what() << std::endl;
237  return;
238  }
239  check_commandGetResult(inMsg, domID, -1, false);
240  // report result state
241  try {
242  int variableID = inMsg.readUnsignedByte();
243  std::string objectID = inMsg.readString();
244  answerLog << " CommandID=" << (domID + 0x10) << " VariableID=" << variableID << " ObjectID=" << objectID;
245  int valueDataType = inMsg.readUnsignedByte();
246  answerLog << " valueDataType=" << valueDataType;
247  readAndReportTypeDependent(inMsg, valueDataType);
248  } catch (libsumo::TraCIException& e) {
249  std::stringstream msg;
250  msg << "Error while receiving command: " << e.what();
251  errorMsg(msg);
252  return;
253  }
254 }
255 
256 
257 void
258 TraCITestClient::commandSetValue(int domID, int varID, const std::string& objID, std::ifstream& defFile) {
259  std::stringstream msg;
260  tcpip::Storage inMsg, tmp;
261  setValueTypeDependant(tmp, defFile, msg);
262  std::string msgS = msg.str();
263  if (msgS != "") {
264  errorMsg(msg);
265  }
266  createCommand(domID, varID, objID, &tmp);
268  answerLog << std::endl << "-> Command sent: <SetValue>:" << std::endl
269  << " domID=" << domID << " varID=" << varID
270  << " objID=" << objID << std::endl;
271  try {
272  std::string acknowledgement;
273  check_resultState(inMsg, domID, false, &acknowledgement);
274  answerLog << acknowledgement << std::endl;
275  } catch (libsumo::TraCIException& e) {
276  answerLog << e.what() << std::endl;
277  }
278 }
279 
280 
281 void
282 TraCITestClient::commandSubscribeObjectVariable(int domID, const std::string& objID, double beginTime, double endTime, int varNo, std::ifstream& defFile) {
283  std::vector<int> vars;
284  for (int i = 0; i < varNo; ++i) {
285  int var;
286  defFile >> var;
287  // variable id
288  vars.push_back(var);
289  }
290  send_commandSubscribeObjectVariable(domID, objID, beginTime, endTime, vars);
291  answerLog << std::endl << "-> Command sent: <SubscribeVariable>:" << std::endl
292  << " domID=" << domID << " objID=" << objID << " with " << varNo << " variables" << std::endl;
293  tcpip::Storage inMsg;
294  try {
295  std::string acknowledgement;
296  check_resultState(inMsg, domID, false, &acknowledgement);
297  answerLog << acknowledgement << std::endl;
298  validateSubscription(inMsg);
299  } catch (libsumo::TraCIException& e) {
300  answerLog << e.what() << std::endl;
301  }
302 }
303 
304 
305 void
306 TraCITestClient::commandSubscribeContextVariable(int domID, const std::string& objID, double beginTime, double endTime,
307  int domain, double range, int varNo, std::ifstream& defFile) {
308  std::vector<int> vars;
309  for (int i = 0; i < varNo; ++i) {
310  int var;
311  defFile >> var;
312  // variable id
313  vars.push_back(var);
314  }
315  send_commandSubscribeObjectContext(domID, objID, beginTime, endTime, domain, range, vars);
316  answerLog << std::endl << "-> Command sent: <SubscribeContext>:" << std::endl
317  << " domID=" << domID << " objID=" << objID << " domain=" << domain << " range=" << range
318  << " with " << varNo << " variables" << std::endl;
319  tcpip::Storage inMsg;
320  try {
321  std::string acknowledgement;
322  check_resultState(inMsg, domID, false, &acknowledgement);
323  answerLog << acknowledgement << std::endl;
324  validateSubscription(inMsg);
325  } catch (libsumo::TraCIException& e) {
326  answerLog << e.what() << std::endl;
327  }
328 }
329 
330 
331 // ---------- Report helper
332 void
334  time_t seconds;
335  tm* locTime;
336  std::ofstream outFile(outputFileName.c_str());
337  if (!outFile) {
338  std::cerr << "Unable to write result file" << std::endl;
339  }
340  time(&seconds);
341  locTime = localtime(&seconds);
342  outFile << "TraCITestClient output file. Date: " << asctime(locTime) << std::endl;
343  outFile << answerLog.str();
344  outFile.close();
345 }
346 
347 
348 void
349 TraCITestClient::errorMsg(std::stringstream& msg) {
350  std::cerr << msg.str() << std::endl;
351  answerLog << "----" << std::endl << msg.str() << std::endl;
352 }
353 
354 
355 
356 
357 
358 
359 bool
361  try {
362  int noSubscriptions = inMsg.readInt();
363  for (int s = 0; s < noSubscriptions; ++s) {
364  if (!validateSubscription(inMsg)) {
365  return false;
366  }
367  }
368  } catch (std::invalid_argument& e) {
369  answerLog << "#Error while reading message:" << e.what() << std::endl;
370  return false;
371  }
372  return true;
373 }
374 
375 
376 bool
378  try {
379  int length = inMsg.readUnsignedByte();
380  if (length == 0) {
381  length = inMsg.readInt();
382  }
383  int cmdId = inMsg.readUnsignedByte();
385  answerLog << " CommandID=" << cmdId;
386  answerLog << " ObjectID=" << inMsg.readString();
387  int varNo = inMsg.readUnsignedByte();
388  answerLog << " #variables=" << varNo << std::endl;
389  for (int i = 0; i < varNo; ++i) {
390  answerLog << " VariableID=" << inMsg.readUnsignedByte();
391  bool ok = inMsg.readUnsignedByte() == libsumo::RTYPE_OK;
392  answerLog << " ok=" << ok;
393  int valueDataType = inMsg.readUnsignedByte();
394  answerLog << " valueDataType=" << valueDataType;
395  readAndReportTypeDependent(inMsg, valueDataType);
396  }
398  answerLog << " CommandID=" << cmdId;
399  answerLog << " ObjectID=" << inMsg.readString();
400  answerLog << " Domain=" << inMsg.readUnsignedByte();
401  int varNo = inMsg.readUnsignedByte();
402  answerLog << " #variables=" << varNo << std::endl;
403  int objNo = inMsg.readInt();
404  answerLog << " #objects=" << objNo << std::endl;
405  for (int j = 0; j < objNo; ++j) {
406  answerLog << " ObjectID=" << inMsg.readString() << std::endl;
407  for (int i = 0; i < varNo; ++i) {
408  answerLog << " VariableID=" << inMsg.readUnsignedByte();
409  bool ok = inMsg.readUnsignedByte() == libsumo::RTYPE_OK;
410  answerLog << " ok=" << ok;
411  int valueDataType = inMsg.readUnsignedByte();
412  answerLog << " valueDataType=" << valueDataType;
413  readAndReportTypeDependent(inMsg, valueDataType);
414  }
415  }
416  } else {
417  answerLog << "#Error: received response with command id: " << cmdId << " but expected a subscription response (0xe0-0xef / 0x90-0x9f)" << std::endl;
418  return false;
419  }
420  } catch (std::invalid_argument& e) {
421  answerLog << "#Error while reading message:" << e.what() << std::endl;
422  return false;
423  }
424  return true;
425 }
426 
427 
428 
429 
430 
431 
432 
433 // ---------- Conversion helper
434 int
435 TraCITestClient::setValueTypeDependant(tcpip::Storage& into, std::ifstream& defFile, std::stringstream& msg) {
436  std::string dataTypeS;
437  defFile >> dataTypeS;
438  if (dataTypeS == "<airDist>") {
440  return 1;
441  } else if (dataTypeS == "<drivingDist>") {
443  return 1;
444  } else if (dataTypeS == "<objSubscription>") {
445  int beginTime, endTime, numVars;
446  defFile >> beginTime >> endTime >> numVars;
447  into.writeInt(beginTime);
448  into.writeInt(endTime);
449  into.writeInt(numVars);
450  for (int i = 0; i < numVars; ++i) {
451  int var;
452  defFile >> var;
453  into.writeUnsignedByte(var);
454  }
455  return 4 + 4 + 4 + numVars;
456  }
457  int valI;
458  double valF;
459  if (dataTypeS == "<int>") {
460  defFile >> valI;
462  into.writeInt(valI);
463  return 4 + 1;
464  } else if (dataTypeS == "<byte>") {
465  defFile >> valI;
467  into.writeByte(valI);
468  return 1 + 1;
469  } else if (dataTypeS == "<ubyte>") {
470  defFile >> valI;
472  into.writeUnsignedByte(valI);
473  return 1 + 1;
474  } else if (dataTypeS == "<double>") {
475  defFile >> valF;
477  into.writeDouble(valF);
478  return 8 + 1;
479  } else if (dataTypeS == "<string>") {
480  std::string valueS;
481  defFile >> valueS;
482  if (valueS == "\"\"") {
483  valueS = "";
484  }
486  into.writeString(valueS);
487  return 4 + 1 + (int) valueS.length();
488  } else if (dataTypeS == "<string*>") {
489  std::vector<std::string> slValue;
490  defFile >> valI;
491  int length = 1 + 4;
492  for (int i = 0; i < valI; ++i) {
493  std::string tmp;
494  defFile >> tmp;
495  slValue.push_back(tmp);
496  length += 4 + int(tmp.length());
497  }
499  into.writeStringList(slValue);
500  return length;
501  } else if (dataTypeS == "<compound>") {
502  defFile >> valI;
504  into.writeInt(valI);
505  int length = 1 + 4;
506  for (int i = 0; i < valI; ++i) {
507  length += setValueTypeDependant(into, defFile, msg);
508  }
509  return length;
510  } else if (dataTypeS == "<color>") {
511  defFile >> valI;
513  into.writeUnsignedByte(valI);
514  for (int i = 0; i < 3; ++i) {
515  defFile >> valI;
516  into.writeUnsignedByte(valI);
517  }
518  return 1 + 4;
519  } else if (dataTypeS == "<position2D>") {
520  defFile >> valF;
522  into.writeDouble(valF);
523  defFile >> valF;
524  into.writeDouble(valF);
525  return 1 + 8 + 8;
526  } else if (dataTypeS == "<position3D>") {
527  defFile >> valF;
529  into.writeDouble(valF);
530  defFile >> valF;
531  into.writeDouble(valF);
532  defFile >> valF;
533  into.writeDouble(valF);
534  return 1 + 8 + 8 + 8;
535  } else if (dataTypeS == "<positionRoadmap>") {
536  std::string valueS;
537  defFile >> valueS;
539  into.writeString(valueS);
540  int length = 1 + 8 + (int) valueS.length();
541  defFile >> valF;
542  into.writeDouble(valF);
543  defFile >> valI;
544  into.writeUnsignedByte(valI);
545  return length + 4 + 1;
546  } else if (dataTypeS == "<shape>") {
547  defFile >> valI;
549  into.writeUnsignedByte(valI);
550  int length = 1 + 1;
551  for (int i = 0; i < valI; ++i) {
552  double x, y;
553  defFile >> x >> y;
554  into.writeDouble(x);
555  into.writeDouble(y);
556  length += 8 + 8;
557  }
558  return length;
559  }
560  msg << "## Unknown data type: " << dataTypeS;
561  return 0;
562 }
563 
564 
565 void
567  if (valueDataType == libsumo::TYPE_UBYTE) {
568  int ubyte = inMsg.readUnsignedByte();
569  answerLog << " Unsigned Byte Value: " << ubyte << std::endl;
570  } else if (valueDataType == libsumo::TYPE_BYTE) {
571  int byte = inMsg.readByte();
572  answerLog << " Byte value: " << byte << std::endl;
573  } else if (valueDataType == libsumo::TYPE_INTEGER) {
574  int integer = inMsg.readInt();
575  answerLog << " Int value: " << integer << std::endl;
576  } else if (valueDataType == libsumo::TYPE_DOUBLE) {
577  double doublev = inMsg.readDouble();
578  answerLog << " Double value: " << doublev << std::endl;
579  } else if (valueDataType == libsumo::TYPE_POLYGON) {
580  int size = inMsg.readUnsignedByte();
581  if (size == 0) {
582  size = inMsg.readInt();
583  }
584  answerLog << " PolygonValue: ";
585  for (int i = 0; i < size; i++) {
586  double x = inMsg.readDouble();
587  double y = inMsg.readDouble();
588  answerLog << "(" << x << "," << y << ") ";
589  }
590  answerLog << std::endl;
591  } else if (valueDataType == libsumo::POSITION_3D) {
592  double x = inMsg.readDouble();
593  double y = inMsg.readDouble();
594  double z = inMsg.readDouble();
595  answerLog << " Position3DValue: " << std::endl;
596  answerLog << " x: " << x << " y: " << y
597  << " z: " << z << std::endl;
598  } else if (valueDataType == libsumo::POSITION_ROADMAP) {
599  std::string roadId = inMsg.readString();
600  double pos = inMsg.readDouble();
601  int laneId = inMsg.readUnsignedByte();
602  answerLog << " RoadMapPositionValue: roadId=" << roadId
603  << " pos=" << pos
604  << " laneId=" << laneId << std::endl;
605  } else if (valueDataType == libsumo::TYPE_STRING) {
606  std::string s = inMsg.readString();
607  answerLog << " string value: " << s << std::endl;
608  } else if (valueDataType == libsumo::TYPE_STRINGLIST) {
609  std::vector<std::string> s = inMsg.readStringList();
610  answerLog << " string list value: [ " << std::endl;
611  for (std::vector<std::string>::iterator i = s.begin(); i != s.end(); ++i) {
612  if (i != s.begin()) {
613  answerLog << ", ";
614  }
615  answerLog << '"' << *i << '"';
616  }
617  answerLog << " ]" << std::endl;
618  } else if (valueDataType == libsumo::TYPE_COMPOUND) {
619  int no = inMsg.readInt();
620  answerLog << " compound value with " << no << " members: [ " << std::endl;
621  for (int i = 0; i < no; ++i) {
622  int currentValueDataType = inMsg.readUnsignedByte();
623  answerLog << " valueDataType=" << currentValueDataType;
624  readAndReportTypeDependent(inMsg, currentValueDataType);
625  }
626  answerLog << " ]" << std::endl;
627  } else if (valueDataType == libsumo::POSITION_2D) {
628  double xv = inMsg.readDouble();
629  double yv = inMsg.readDouble();
630  answerLog << " position value: (" << xv << "," << yv << ")" << std::endl;
631  } else if (valueDataType == libsumo::TYPE_COLOR) {
632  int r = inMsg.readUnsignedByte();
633  int g = inMsg.readUnsignedByte();
634  int b = inMsg.readUnsignedByte();
635  int a = inMsg.readUnsignedByte();
636  answerLog << " color value: (" << r << "," << g << "," << b << "," << a << ")" << std::endl;
637  } else {
638  answerLog << "#Error: unknown valueDataType!" << std::endl;
639  }
640 }
641 
642 
643 void
645  answerLog << "testAPI:\n";
646  const auto& version = getVersion();
647  answerLog << " getVersion: " << version.first << ", " << version.second << "\n";
648  answerLog << " setOrder:\n";
649  setOrder(0);
650  // edge
651  answerLog << " edge:\n";
652  answerLog << " getIDList: " << joinToString(edge.getIDList(), " ") << "\n";
653  answerLog << " getIDCount: " << edge.getIDCount() << "\n";
654  const std::string edgeID = "e_m0";
655  edge.adaptTraveltime(edgeID, 42, 0, 10);
656  edge.setEffort(edgeID, 420, 0, 10);
657  answerLog << " currentTraveltime: " << edge.getTraveltime(edgeID) << "\n";
658  answerLog << " adaptedTravelTime: " << edge.getAdaptedTraveltime(edgeID, 0) << "\n";
659  answerLog << " effort: " << edge.getEffort(edgeID, 0) << "\n";
660  answerLog << " laneNumber: " << edge.getLaneNumber(edgeID) << "\n";
661  answerLog << " streetName: " << edge.getStreetName(edgeID) << "\n";
662  edge.setMaxSpeed(edgeID, 42);
663  answerLog << " maxSpeed: " << lane.getMaxSpeed(edgeID + "_0") << "\n";
664 
665  // lane
666  answerLog << " lane:\n";
667  answerLog << " getIDList: " << joinToString(lane.getIDList(), " ") << "\n";
668  answerLog << " getIDCount: " << lane.getIDCount() << "\n";
669  const std::string laneID = "e_m6_0";
670  answerLog << " getLinkNumber: " << lane.getLinkNumber(laneID) << "\n";
671  std::vector<libsumo::TraCIConnection> connections = lane.getLinks(laneID);
672  answerLog << " getLinks:\n";
673  for (int i = 0; i < (int)connections.size(); ++i) {
674  const libsumo::TraCIConnection& c = connections[i];
675  answerLog << " approachedLane=" << c.approachedLane
676  << " hasPrio=" << c.hasPrio
677  << " isOpen=" << c.isOpen
678  << " hasFoe=" << c.hasFoe
679  << " approachedInternal=" << c.approachedInternal
680  << " state=" << c.state
681  << " direction=" << c.direction
682  << " length=" << c.length
683  << "\n";
684  }
685  answerLog << " getFoes: " << joinToString(lane.getFoes("e_vu0_0", "e_m4_0"), " ") << "\n";
686  try {
687  answerLog << " getFoes (invalid): ";
688  answerLog << joinToString(lane.getFoes("e_vu0_0", "e_m4_1"), " ") << "\n";
689  } catch (libsumo::TraCIException& e) {
690  answerLog << " caught TraCIException(" << e.what() << ")\n";
691  }
692  answerLog << " getInternalFoes: " << joinToString(lane.getInternalFoes(":n_m4_2_0"), " ") << "\n";
693  try {
694  answerLog << " getInternalFoes (invalid): ";
695  answerLog << joinToString(lane.getInternalFoes("dummy"), " ") << "\n";
696  } catch (libsumo::TraCIException& e) {
697  answerLog << " caught TraCIException(" << e.what() << ")\n";
698  }
699  lane.setMaxSpeed(laneID, 42);
700  answerLog << " maxSpeed: " << lane.getMaxSpeed(laneID) << "\n";
701  // poi
702  answerLog << " POI:\n";
703  answerLog << " getIDList: " << joinToString(poi.getIDList(), " ") << "\n";
704  answerLog << " getIDCount: " << poi.getIDCount() << "\n";
705  answerLog << " getPosition: " << poi.getPosition("poi0").getString() << "\n";
706  answerLog << " getColor: " << poi.getColor("poi0").getString() << "\n";
707 
708  // poly
709  answerLog << " polygon:\n";
710  answerLog << " getIDList: " << joinToString(polygon.getIDList(), " ") << "\n";
711  answerLog << " getIDCount: " << polygon.getIDCount() << "\n";
713  polygon.setLineWidth("poly0", 0.6);
714  answerLog << " getLineWidth: " << polygon.getLineWidth("poly0") << "\n";
715  answerLog << " getShape: " << shape.getString() << "\n";
716  answerLog << " getColor: " << polygon.getColor("poly0").getString() << "\n";
717  shape.value[0].x = 42;
718  polygon.setShape("poly0", shape);
719  answerLog << " getShape after modification: " << polygon.getShape("poly0").getString() << "\n";
720 
721  // junction
722  answerLog << " junction:\n";
723  answerLog << " getIDList: " << joinToString(junction.getIDList(), " ") << "\n";
724  answerLog << " getIDCount: " << junction.getIDCount() << "\n";
725  answerLog << " getShape: " << junction.getShape("n_m4").getString() << "\n";
726 
727  // route
728  answerLog << " route:\n";
729  answerLog << " add:\n";
730  std::vector<std::string> edges;
731  edges.push_back("e_u1");
732  edges.push_back("e_u0");
733  route.add("e_u1", edges);
734  edges.clear();
735  edges.push_back("e_m4");
736  route.add("e_m4", edges);
737  answerLog << " getIDList: " << joinToString(route.getIDList(), " ") << "\n";
738 
739  // vehicletype
740  answerLog << " vehicleType:\n";
741  answerLog << " getIDList: " << joinToString(vehicletype.getIDList(), " ") << "\n";
742  vehicletype.setEmergencyDecel("t1", 9.9);
743  answerLog << " getEmergencyDecel: " << vehicletype.getEmergencyDecel("t1") << "\n";
744  vehicletype.setApparentDecel("t1", 99.9);
745  answerLog << " getApparentDecel: " << vehicletype.getApparentDecel("t1") << "\n";
746  vehicletype.setWidth("t1", 1.9);
747  answerLog << " getWidth: " << vehicletype.getWidth("t1") << "\n";
748  vehicletype.setHeight("t1", 1.8);
749  answerLog << " getHeight: " << vehicletype.getHeight("t1") << "\n";
750  vehicletype.setMinGapLat("t1", 1.5);
751  answerLog << " setMinGapLat: " << vehicletype.getMinGapLat("t1") << "\n";
752  vehicletype.setMaxSpeedLat("t1", 1.2);
753  answerLog << " setMaxSpeedLat: " << vehicletype.getMaxSpeedLat("t1") << "\n";
754  vehicletype.setLateralAlignment("t1", "compact");
755  answerLog << " getLateralAlignment: " << vehicletype.getLateralAlignment("t1") << "\n";
756  answerLog << " getPersonCapacity: " << vehicletype.getPersonCapacity("t1") << "\n";
757  answerLog << " copy type 't1' to 't1_copy' and set accel to 100.\n";
758  vehicletype.copy("t1", "t1_copy");
759  answerLog << " getIDList: " << joinToString(vehicletype.getIDList(), " ") << "\n";
760  vehicletype.setAccel("t1_copy", 100.);
761  answerLog << " getAccel('t1'): " << vehicletype.getAccel("t1") << "\n";
762  answerLog << " getAccel('t1_copy'): " << vehicletype.getAccel("t1_copy") << "\n";
763 
764  // vehicle
765  answerLog << " vehicle:\n";
766  vehicle.setLine("0", "S42");
767  std::vector<std::string> via;
768  via.push_back("e_shape1");
769  vehicle.setVia("0", via);
770  vehicle.setType("0", "t1_copy");
771  answerLog << " getTypeID: " << vehicle.getTypeID("0") << "\n";
772  answerLog << " getRoadID: " << vehicle.getRoadID("0") << "\n";
773  answerLog << " getRouteID: " << vehicle.getRouteID("0") << "\n";
774  answerLog << " getLaneID: " << vehicle.getLaneID("0") << "\n";
775  answerLog << " getLanePosition: " << vehicle.getLanePosition("0") << "\n";
776  answerLog << " getLateralLanePosition: " << vehicle.getLateralLanePosition("0") << "\n";
777  answerLog << " getSpeed: " << vehicle.getSpeed("0") << "\n";
778  answerLog << " getLateralSpeed: " << vehicle.getLateralSpeed("0") << "\n";
779  answerLog << " getAcceleration: " << vehicle.getAcceleration("0") << "\n";
780 
781  answerLog << " getFollowSpeed: " << vehicle.getFollowSpeed("0", 10, 20, 9, 4.5) << "\n";
782  answerLog << " getSecureGap: " << vehicle.getSecureGap("0", 10, 9, 4.5) << "\n";
783  answerLog << " getStopSpeed: " << vehicle.getStopSpeed("0", 10, 20) << "\n";
784 
785  answerLog << " getSpeedMode: " << vehicle.getSpeedMode("0") << "\n";
786  answerLog << " getSlope: " << vehicle.getSlope("0") << "\n";
787  answerLog << " getLine: " << vehicle.getLine("0") << "\n";
788  answerLog << " getVia: " << joinToString(vehicle.getVia("0"), ",") << "\n";
789  answerLog << " getPersonCapacity: " << vehicle.getPersonCapacity("0") << "\n";
790  vehicle.setMaxSpeed("0", 30);
791  answerLog << " getMaxSpeed: " << vehicle.getMaxSpeed("0") << "\n";
792  answerLog << " isRouteValid: " << vehicle.isRouteValid("0") << "\n";
793  answerLog << " getStopState: " << vehicle.getStopState("0") << "\n";
794  answerLog << " getStopDelay: " << vehicle.getStopDelay("0") << "\n";
795  vehicle.setParameter("0", "meaningOfLife", "42");
796  answerLog << " param: " << vehicle.getParameter("0", "meaningOfLife") << "\n";
797  std::pair<std::string, std::string> paramTuple = vehicle.getParameterWithKey("0", "meaningOfLife");
798  answerLog << " parameterWithKey: (" << paramTuple.first << ", " << paramTuple.second << ")\n";
799  libsumo::TraCIColor col1;
800  col1.r = 255;
801  col1.g = 255;
802  col1.b = 0;
803  col1.a = 128;
804  vehicle.setColor("0", col1);
806  answerLog << " getColor: r=" << (int)col2.r << " g=" << (int)col2.g << " b=" << (int)col2.b << " a=" << (int)col2.a << "\n";
807  int signals = vehicle.getSignals("0");
808  answerLog << " getSignals: " << signals << "\n";
811  answerLog << " getRoutingMode: " << vehicle.getRoutingMode("0") << "\n";
812  answerLog << " getNextTLS:\n";
813  std::vector<libsumo::TraCINextTLSData> result = vehicle.getNextTLS("0");
814  for (int i = 0; i < (int)result.size(); ++i) {
815  const libsumo::TraCINextTLSData& d = result[i];
816  answerLog << " tls=" << d.id << " tlIndex=" << d.tlIndex << " dist=" << d.dist << " state=" << d.state << "\n";
817  }
818  answerLog << " moveToXY, simStep:\n";
819  vehicle.moveToXY("0", "dummy", 0, 2231.61, 498.29, 90, 1);
820  simulationStep();
821  // simulationStep(1);
822  answerLog << " getRoadID: " << vehicle.getRoadID("0") << "\n";
823  answerLog << " getLaneID: " << vehicle.getLaneID("0") << "\n";
824  vehicle.changeTarget("0", "e_o0");
825  std::vector<std::string> edges2 = vehicle.getRoute("0");
826  answerLog << " edges: " << joinToString(edges2, " ") << "\n";
827  vehicle.setRouteID("0", "e_m4");
828  answerLog << " edges: " << joinToString(vehicle.getRoute("0"), " ") << "\n";
829  vehicle.setRoute("0", edges2);
830  answerLog << " edges: " << joinToString(vehicle.getRoute("0"), " ") << "\n";
831  answerLog << " add:\n";
832  vehicle.add("1", "e_u1");
833  vehicle.add("2", "e_u1");
834  vehicle.moveTo("2", "e_u0_0", 5);
835  simulationStep();
836  answerLog << " getIDList: " << joinToString(vehicle.getIDList(), " ") << "\n";
837  answerLog << " getWaitingTime: " << vehicle.getWaitingTime("0") << "\n";
838  answerLog << " getAccumulatedWaitingTime: " << vehicle.getAccumulatedWaitingTime("0") << "\n";
839  vehicle.setShapeClass("0", "bicycle");
840  answerLog << " getShapeClass: " << vehicle.getShapeClass("0") << "\n";
841  std::pair<std::string, double> leader = vehicle.getLeader("1", 1000);
842  answerLog << " getLeader: " << leader.first << ", " << leader.second << "\n";
843  std::pair<std::string, double> follower = vehicle.getFollower("1", 1000);
844  answerLog << " getFollower: " << follower.first << ", " << follower.second << "\n";
845  std::pair<int, int> state = vehicle.getLaneChangeState("1", 1);
846  answerLog << " getLaneChangeState (left): " << state.first << ", " << state.second << "\n";
847  state = vehicle.getLaneChangeState("1", -1);
848  answerLog << " getLaneChangeState (right): " << state.first << ", " << state.second << "\n";
850  vehicle.setSpeedFactor("0", 0.8);
851  vehicle.setSpeedMode("0", 0);
852  answerLog << " getSpeedMode after change: " << vehicle.getSpeedMode("0") << "\n";
853  vehicle.setLaneChangeMode("0", 0);
854  answerLog << " getLaneChangeMode after change: " << vehicle.getLaneChangeMode("0") << "\n";
855  answerLog << " remove:\n";
856  vehicle.remove("0");
857  answerLog << " getIDCount: " << vehicle.getIDCount() << "\n";
858 
859  // inductionLoop
860  answerLog << " inductionloop:\n";
861  answerLog << " getIDList: " << joinToString(inductionloop.getIDList(), " ") << "\n";
862  answerLog << " getVehicleData:\n";
863  std::vector<libsumo::TraCIVehicleData> result2 = inductionloop.getVehicleData("det1");
864  for (int i = 0; i < (int)result2.size(); ++i) {
865  const libsumo::TraCIVehicleData& vd = result2[i];
866  answerLog << " veh=" << vd.id << " length=" << vd.length << " entered=" << vd.entryTime << " left=" << vd.leaveTime << " type=" << vd.typeID << "\n";
867  }
868 
869  // simulation
870  answerLog << " simulation:\n";
871  answerLog << " convert2D: " << simulation.convert2D("e_m5", 0).getString() << "\n";
872  answerLog << " convert2DGeo: " << simulation.convert2D("e_m5", 0, 0, true).getString() << "\n";
873  answerLog << " convert3D: " << simulation.convert3D("e_m5", 0).getString() << "\n";
874  answerLog << " convert3DGeo: " << simulation.convert3D("e_m5", 0, 0, true).getString() << "\n";
875  answerLog << " convertRoad: " << simulation.convertRoad(2500, 500).getString() << "\n";
876  answerLog << " convertRoadBus: " << simulation.convertRoad(2500, 500, false, "bus").getString() << "\n";
877  answerLog << " convertGeo: " << simulation.convertGeo(2500, 500).getString() << "\n";
878  answerLog << " convertCartesian: " << simulation.convertGeo(12, 52, true).getString() << "\n";
879  answerLog << " getDistance2D_air: " << simulation.getDistance2D(2500, 500, 2000, 500, false, false) << "\n";
880  answerLog << " getDistance2D_driving: " << simulation.getDistance2D(2500, 500, 2000, 500, false, true) << "\n";
881  answerLog << " getDistanceRoad_air: " << simulation.getDistanceRoad("e_m5", 0, "e_m4", 0, false) << "\n";
882  answerLog << " getDistanceRoad_driving: " << simulation.getDistanceRoad("e_m5", 0, "e_m4", 0, true) << "\n";
883  answerLog << " getCurrentTime: " << simulation.getCurrentTime() << "\n";
884  answerLog << " getDeltaT: " << simulation.getDeltaT() << "\n";
885  answerLog << " parkingArea param: " << simulation.getParameter("park1", "parkingArea.capacity") << "\n";
886  answerLog << " busStopWaiting: " << simulation.getBusStopWaiting("bs1") << "\n";
887  answerLog << " busStopWaitingIDs: " << joinToString(simulation.getBusStopWaitingIDList("bs1"), " ") << "\n";
888  simulation.writeMessage("custom message test");
889  answerLog << " subscribe to road and pos of vehicle '1':\n";
890  answerLog << " findRoute: " << joinToString(simulation.findRoute("e_m5", "e_m4").edges, " ") << "\n";
891  std::vector<int> vars;
892  vars.push_back(libsumo::VAR_ROAD_ID);
893  vars.push_back(libsumo::VAR_LANEPOSITION);
894  vehicle.subscribe("1", vars, 0, 100);
895  simulationStep();
896  answerLog << " subscription results:\n";
898  answerLog << " roadID=" << result3[libsumo::VAR_ROAD_ID]->getString() << " pos=" << result3[libsumo::VAR_LANEPOSITION]->getString() << "\n";
899 
900  answerLog << " subscribe to vehicles around edge 'e_u1':\n";
901  std::vector<int> vars2;
902  vars2.push_back(libsumo::VAR_LANEPOSITION);
903  edge.subscribeContext("e_u1", libsumo::CMD_GET_VEHICLE_VARIABLE, 100, vars2, 0, 100);
904  simulationStep();
905  answerLog << " context subscription results:\n";
907  for (libsumo::SubscriptionResults::iterator it = result4.begin(); it != result4.end(); ++it) {
908  answerLog << " vehicle=" << it->first << " pos=" << it->second[libsumo::VAR_LANEPOSITION]->getString() << "\n";
909  }
910 
911  answerLog << " subscribe to vehicles around vehicle '1':\n";
912  std::vector<int> vars3;
913  vars3.push_back(libsumo::VAR_SPEED);
915  vehicle.addSubscriptionFilterLanes(std::vector<int>({0, 1, 2}));
920  vehicle.addSubscriptionFilterLeadFollow(std::vector<int>({0, 1, 2}));
922  vehicle.addSubscriptionFilterVClass(std::vector<std::string>({"passenger"}));
923  vehicle.addSubscriptionFilterVType(std::vector<std::string>({"passenger"}));
925 
928 
931  //
932 
933  simulationStep();
934  answerLog << " context subscription results:\n";
936  for (auto item : result5) {
937  answerLog << " vehicle=" << item.first << "\n";
938  }
939 
940  // person
941  answerLog << " person:\n";
942  person.setWidth("p0", 1);
943  person.setMinGap("p0", 2);
944  person.setLength("p0", 3);
945  person.setHeight("p0", 4);
946  person.setColor("p0", col1);
947  person.setType("p0", "stilts");
948  answerLog << " getIDList: " << joinToString(person.getIDList(), " ") << "\n";
949  answerLog << " getRoadID: " << person.getRoadID("p0") << "\n";
950  answerLog << " getLaneID: " << person.getLaneID("p0") << "\n";
951  answerLog << " getTypeID: " << person.getTypeID("p0") << "\n";
952  answerLog << " getWaitingTime: " << person.getWaitingTime("p0") << "\n";
953  answerLog << " getNextEdge: " << person.getNextEdge("p0") << "\n";
954  answerLog << " getStage: " << person.getStage("p0").description << "\n";
955  answerLog << " getRemainingStages: " << person.getRemainingStages("p0") << "\n";
956  answerLog << " getVehicle: " << person.getVehicle("p0") << "\n";
957  answerLog << " getEdges: " << joinToString(person.getEdges("p0"), " ") << "\n";
958  answerLog << " getPosition: " << person.getPosition("p0").getString() << "\n";
959  answerLog << " getPosition3D: " << person.getPosition3D("p0").getString() << "\n";
960  answerLog << " getAngle: " << person.getAngle("p0") << "\n";
961  answerLog << " getSlope: " << person.getSlope("p0") << "\n";
962  answerLog << " getLanePosition: " << person.getLanePosition("p0") << "\n";
963  answerLog << " getLength: " << person.getLength("p0") << "\n";
964  answerLog << " getColor: " << person.getColor("p0").getString() << "\n";
965  person.setParameter("p0", "foo", "bar");
966  answerLog << " param: " << person.getParameter("p0", "foo") << "\n";
967  person.setSpeed("p0", 3);
968  simulationStep();
969  answerLog << " getSpeed: " << person.getSpeed("p0") << "\n";
970  person.add("p1", "e_u1", 10);
971  std::vector<std::string> walkEdges;
972  walkEdges.push_back("e_u1");
973  walkEdges.push_back("e_shape1");
974  person.appendWalkingStage("p1", walkEdges, -20);
975  person.appendWaitingStage("p1", 5);
976  person.appendDrivingStage("p1", "e_vu2", "BusLine42");
978  stage.edges.push_back("e_vu2");
979  stage.edges.push_back("e_vo2");
980  stage.arrivalPos = -10;
981  person.appendStage("p1", stage);
982  simulationStep();
983  // expect 5 stages due to the initial waiting-for-departure stage
984  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
985  person.removeStage("p1", 3);
986  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
987  person.removeStages("p1");
988  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
989  answerLog << " getStage: " << person.getStage("p1").description << "\n";
990  walkEdges.push_back("e_m5");
991  person.appendWalkingStage("p1", walkEdges, -20);
992  simulationStep();
994  answerLog << " getEdges after rerouting: " << joinToString(person.getEdges("p1"), " ") << "\n";
995 
996  // trafficlights
997  answerLog << " trafficlights:\n";
998  trafficlights.setPhase("n_m4", 0);
999  trafficlights.setPhaseName("n_m4", "nameSetByTraCI");
1000  answerLog << " getIDList: " << joinToString(trafficlights.getIDList(), " ") << "\n";
1001  answerLog << " getIDCount: " << trafficlights.getIDCount() << "\n";
1002  answerLog << " state: " << trafficlights.getRedYellowGreenState("n_m4") << "\n";
1003  answerLog << " program: " << trafficlights.getProgram("n_m4") << "\n";
1004  answerLog << " phase: " << trafficlights.getPhase("n_m4") << "\n";
1005  answerLog << " phaseName: " << trafficlights.getPhaseName("n_m4") << "\n";
1006  answerLog << " phaseDuration: " << trafficlights.getPhaseDuration("n_m4") << "\n";
1007  answerLog << " nextSwitch: " << trafficlights.getNextSwitch("n_m4") << "\n";
1008  answerLog << " controlledLanes: " << joinToString(trafficlights.getControlledLanes("n_m4"), " ") << "\n";
1009  std::vector<std::vector<libsumo::TraCILink> > links = trafficlights.getControlledLinks("n_m4");
1010  answerLog << " controlledLinks:\n";
1011  for (int i = 0; i < (int)links.size(); ++i) {
1012  for (int j = 0; j < (int)links[i].size(); ++j) {
1013  answerLog << " index=" << i << " link=" << j << " fromLane=" << links[i][j].fromLane << " viaLane=" << links[i][j].viaLane << " toLane=" << links[i][j].toLane << "\n";
1014  }
1015  }
1016  libsumo::TraCILogic logic("custom", 0, 3);
1017  logic.phases.push_back(std::make_shared<libsumo::TraCIPhase>(5, "rrrrrrr", 5, 5));
1018  logic.phases.push_back(std::make_shared<libsumo::TraCIPhase>(10, "ggggggg", 5, 15));
1019  logic.phases.push_back(std::make_shared<libsumo::TraCIPhase>(3, "GGGGGGG", 3, 3));
1020  logic.phases.push_back(std::make_shared<libsumo::TraCIPhase>(3, "yyyyyyy", 3, 3));
1021  trafficlights.setProgramLogic("n_m4", logic);
1022 
1023  std::vector<libsumo::TraCILogic> logics = trafficlights.getAllProgramLogics("n_m4");
1024  answerLog << " completeDefinition:\n";
1025  for (int i = 0; i < (int)logics.size(); ++i) {
1026  answerLog << " subID=" << logics[i].programID << " type=" << logics[i].type << " phase=" << logics[i].currentPhaseIndex << "\n";
1027  answerLog << " params=" << joinToString(logics[i].subParameter) << "\n";
1028  for (int j = 0; j < (int)logics[i].phases.size(); ++j) {
1029  answerLog << " phase=" << logics[i].phases[j]->state
1030  << " dur=" << logics[i].phases[j]->duration
1031  << " minDur=" << logics[i].phases[j]->minDur
1032  << " maxDur=" << logics[i].phases[j]->maxDur
1033  << "\n";
1034  }
1035  }
1036  simulationStep();
1037  answerLog << " state=" << trafficlights.getRedYellowGreenState("n_m4") << "\n";
1038  trafficlights.setRedYellowGreenState("n_m4", "gGyruoO");
1039  answerLog << " stateSet=" << trafficlights.getRedYellowGreenState("n_m4") << "\n";
1040  answerLog << " program: " << trafficlights.getProgram("n_m4") << "\n";
1041 
1042  answerLog << " load:\n";
1043  std::vector<std::string> args;
1044  args.push_back("-n");
1045  args.push_back("net.net.xml");
1046  args.push_back("-r");
1047  args.push_back("input_routes.rou.xml");
1048  args.push_back("-a");
1049  args.push_back("input_additional.add.xml");
1050  args.push_back("--no-step-log");
1051  load(args);
1052  simulationStep();
1053  answerLog << " getCurrentTime: " << simulation.getCurrentTime() << "\n";
1054  vehicle.subscribe("0", vars, 0, 100);
1055  edge.subscribeContext("e_u1", libsumo::CMD_GET_VEHICLE_VARIABLE, 100, vars2, 0, 100);
1056 
1057  answerLog << " gui:\n";
1058  try {
1059  answerLog << " setScheme: \n";
1060  gui.setSchema("View #0", "real world");
1061  answerLog << " getScheme: " << gui.getSchema("View #0") << "\n";
1062  gui.setZoom("View #0", 50);
1063  answerLog << " getZoom: " << gui.getZoom() << "\n";
1064  answerLog << " take screenshot: \n";
1065  gui.screenshot("View #0", "image.png", 500, 500);
1066  } catch (libsumo::TraCIException&) {
1067  answerLog << " no support for gui commands\n";
1068  }
1069 }
void adaptTraveltime(const std::string &edgeID, double time, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
Definition: TraCIAPI.cpp:610
void setMaxSpeed(const std::string &edgeID, double speed) const
Definition: TraCIAPI.cpp:649
int getLaneNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:598
void setEffort(const std::string &edgeID, double effort, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
Definition: TraCIAPI.cpp:630
double getTraveltime(const std::string &edgeID) const
Definition: TraCIAPI.cpp:577
std::string getStreetName(const std::string &id) const
Definition: TraCIAPI.cpp:604
double getAdaptedTraveltime(const std::string &edgeID, double time) const
Definition: TraCIAPI.cpp:505
double getEffort(const std::string &edgeID, double time) const
Definition: TraCIAPI.cpp:513
std::string getSchema(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:668
void setZoom(const std::string &viewID, double zoom) const
Definition: TraCIAPI.cpp:679
void setSchema(const std::string &viewID, const std::string &schemeName) const
Definition: TraCIAPI.cpp:694
double getZoom(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:658
void screenshot(const std::string &viewID, const std::string &filename, const int width=-1, const int height=-1) const
Definition: TraCIAPI.cpp:712
std::vector< libsumo::TraCIVehicleData > getVehicleData(const std::string &loopID) const
Definition: TraCIAPI.cpp:777
libsumo::TraCIPositionVector getShape(const std::string &junctionID) const
Definition: TraCIAPI.cpp:819
int getLinkNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:853
void setMaxSpeed(const std::string &laneID, double speed) const
Definition: TraCIAPI.cpp:1026
std::vector< std::string > getInternalFoes(const std::string &laneID) const
Definition: TraCIAPI.cpp:1010
std::vector< libsumo::TraCIConnection > getLinks(const std::string &laneID) const
Definition: TraCIAPI.cpp:858
double getMaxSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:833
std::vector< std::string > getFoes(const std::string &laneID, const std::string &toLaneID) const
Definition: TraCIAPI.cpp:994
libsumo::TraCIColor getColor(const std::string &poiID) const
Definition: TraCIAPI.cpp:1080
libsumo::TraCIPosition getPosition(const std::string &poiID) const
Definition: TraCIAPI.cpp:1075
std::string getNextEdge(const std::string &personID) const
Definition: TraCIAPI.cpp:3233
void setLength(const std::string &personID, double length) const
Definition: TraCIAPI.cpp:3462
libsumo::TraCIColor getColor(const std::string &personID) const
Definition: TraCIAPI.cpp:3198
double getSlope(const std::string &personID) const
Definition: TraCIAPI.cpp:3188
int getRemainingStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3244
double getWaitingTime(const std::string &personID) const
Definition: TraCIAPI.cpp:3228
libsumo::TraCIStage getStage(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3249
void removeStage(const std::string &personID, int nextStageIndex) const
Definition: TraCIAPI.cpp:3393
void add(const std::string &personID, const std::string &edgeID, double pos, double depart=libsumo::DEPARTFLAG_NOW, const std::string typeID="DEFAULT_PEDTYPE")
Definition: TraCIAPI.cpp:3285
void appendWalkingStage(const std::string &personID, const std::vector< std::string > &edges, double arrivalPos, double duration=-1, double speed=-1, const std::string &stopID="")
Definition: TraCIAPI.cpp:3355
void setSpeed(const std::string &personID, double speed) const
Definition: TraCIAPI.cpp:3434
double getLength(const std::string &personID) const
Definition: TraCIAPI.cpp:3203
void setHeight(const std::string &personID, double height) const
Definition: TraCIAPI.cpp:3481
void setType(const std::string &personID, const std::string &typeID) const
Definition: TraCIAPI.cpp:3444
void setMinGap(const std::string &personID, double minGap) const
Definition: TraCIAPI.cpp:3490
libsumo::TraCIPosition getPosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3173
void removeStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3265
void setColor(const std::string &personID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:3500
std::string getRoadID(const std::string &personID) const
Definition: TraCIAPI.cpp:3208
double getSpeed(const std::string &personID) const
Definition: TraCIAPI.cpp:3168
std::string getVehicle(const std::string &personID) const
Definition: TraCIAPI.cpp:3239
void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
Definition: TraCIAPI.cpp:3376
std::string getTypeID(const std::string &personID) const
Definition: TraCIAPI.cpp:3218
void appendStage(const std::string &personID, const libsumo::TraCIStage &stage)
Definition: TraCIAPI.cpp:3302
double getAngle(const std::string &personID) const
Definition: TraCIAPI.cpp:3183
std::string getLaneID(const std::string &personID) const
Definition: TraCIAPI.cpp:3213
libsumo::TraCIPosition getPosition3D(const std::string &personID) const
Definition: TraCIAPI.cpp:3178
std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3257
void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: TraCIAPI.cpp:3338
double getLanePosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3193
void setWidth(const std::string &personID, double width) const
Definition: TraCIAPI.cpp:3472
void rerouteTraveltime(const std::string &personID) const
Definition: TraCIAPI.cpp:3275
libsumo::TraCIColor getColor(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1222
libsumo::TraCIPositionVector getShape(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1217
double getLineWidth(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1202
void setLineWidth(const std::string &polygonID, const double lineWidth) const
Definition: TraCIAPI.cpp:1227
void setShape(const std::string &polygonID, const libsumo::TraCIPositionVector &shape) const
Definition: TraCIAPI.cpp:1246
void add(const std::string &routeID, const std::vector< std::string > &edges) const
Definition: TraCIAPI.cpp:1323
double getDistance2D(double x1, double y1, double x2, double y2, bool isGeo=false, bool isDriving=false)
Definition: TraCIAPI.cpp:1532
libsumo::TraCIPosition convert2D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1443
int getBusStopWaiting(const std::string &stopID) const
Definition: TraCIAPI.cpp:1432
libsumo::TraCIStage findRoute(const std::string &fromEdge, const std::string &toEdge, const std::string &vType="", double pos=-1., int routingMode=0) const
Definition: TraCIAPI.cpp:1574
libsumo::TraCIRoadPosition convertRoad(double x, double y, bool isGeo=false, const std::string &vClass="ignoring") const
Definition: TraCIAPI.cpp:1488
std::vector< std::string > getBusStopWaitingIDList(const std::string &stopID) const
Definition: TraCIAPI.cpp:1437
double getDistanceRoad(const std::string &edgeID1, double pos1, const std::string &edgeID2, double pos2, bool isDriving=false)
Definition: TraCIAPI.cpp:1552
double getDeltaT() const
Definition: TraCIAPI.cpp:1416
void writeMessage(const std::string msg)
Definition: TraCIAPI.cpp:1610
libsumo::TraCIPosition convertGeo(double x, double y, bool fromGeo=false) const
Definition: TraCIAPI.cpp:1511
libsumo::TraCIPosition convert3D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1465
const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3833
std::pair< std::string, std::string > getParameterWithKey(const std::string &objectID, const std::string &key) const
retrieve generic parameter and return (key, value) tuple
Definition: TraCIAPI.cpp:3713
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:3692
const libsumo::TraCIResults getSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3817
void subscribeContext(const std::string &objID, int domain, double range, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3801
void setParameter(const std::string &objectID, const std::string &key, const std::string &value) const
set generic paramter
Definition: TraCIAPI.cpp:3732
std::string getParameter(const std::string &objectID, const std::string &key) const
retrieve generic parameter
Definition: TraCIAPI.cpp:3704
void subscribe(const std::string &objID, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3789
std::string getRedYellowGreenState(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1623
int getPhase(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1719
std::string getPhaseName(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1724
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
Definition: TraCIAPI.cpp:1749
std::string getProgram(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1714
void setPhase(const std::string &tlsID, int index) const
Definition: TraCIAPI.cpp:1758
void setPhaseName(const std::string &tlsID, const std::string &name) const
Definition: TraCIAPI.cpp:1767
double getNextSwitch(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1734
std::vector< std::vector< libsumo::TraCILink > > getControlledLinks(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1686
double getPhaseDuration(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1729
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1681
std::vector< libsumo::TraCILogic > getAllProgramLogics(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1628
void setProgramLogic(const std::string &tlsID, const libsumo::TraCILogic &logic) const
Definition: TraCIAPI.cpp:1794
std::vector< libsumo::TraCINextTLSData > getNextTLS(const std::string &vehID) const
Definition: TraCIAPI.cpp:2375
double getLateralSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2153
void setMaxSpeed(const std::string &vehicleID, double speed) const
Definition: TraCIAPI.cpp:2944
double getSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2148
int getStopState(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2497
double getWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2332
void addSubscriptionFilterCFManeuver(double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3055
void changeTarget(const std::string &vehicleID, const std::string &edgeID) const
Definition: TraCIAPI.cpp:2694
bool isRouteValid(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2603
double getSecureGap(const std::string &vehicleID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string &leaderID="") const
Definition: TraCIAPI.cpp:2182
void setSpeedFactor(const std::string &vehicleID, double factor) const
Definition: TraCIAPI.cpp:2926
void setShapeClass(const std::string &vehicleID, const std::string &clazz) const
Definition: TraCIAPI.cpp:3004
void addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist=-1, double foeDistToJunction=-1) const
Definition: TraCIAPI.cpp:3116
void setVia(const std::string &vehicleID, const std::vector< std::string > &via) const
Definition: TraCIAPI.cpp:2974
void remove(const std::string &vehicleID, char reason=libsumo::REMOVE_VAPORIZED) const
Definition: TraCIAPI.cpp:2683
void moveTo(const std::string &vehicleID, const std::string &laneID, double position, int reason=libsumo::MOVE_TELEPORT) const
Definition: TraCIAPI.cpp:2784
void setRouteID(const std::string &vehicleID, const std::string &routeID) const
Definition: TraCIAPI.cpp:2744
std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction) const
Definition: TraCIAPI.cpp:2479
std::string getShapeClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2370
void addSubscriptionFilterLeadFollow(const std::vector< int > &lanes) const
Definition: TraCIAPI.cpp:3084
std::string getLine(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2355
void setRoute(const std::string &vehicleID, const std::vector< std::string > &edge) const
Definition: TraCIAPI.cpp:2754
int getSignals(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2282
libsumo::TraCIColor getColor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2267
int getPersonCapacity(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2588
void setSignals(const std::string &vehicleID, int signals) const
Definition: TraCIAPI.cpp:2986
std::string getRoadID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2231
void addSubscriptionFilterVType(const std::vector< std::string > &vTypes) const
Definition: TraCIAPI.cpp:3105
void addSubscriptionFilterUpstreamDistance(double dist) const
Definition: TraCIAPI.cpp:3049
void addSubscriptionFilterLanes(const std::vector< int > &lanes, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3023
void addSubscriptionFilterNoOpposite() const
Definition: TraCIAPI.cpp:3039
void addSubscriptionFilterLCManeuver(int direction, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3066
std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2443
double getAcceleration(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2158
std::vector< std::string > getVia(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2360
void addSubscriptionFilterVClass(const std::vector< std::string > &vClasses) const
Definition: TraCIAPI.cpp:3099
std::string getLaneID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2236
void addSubscriptionFilterDownstreamDistance(double dist) const
Definition: TraCIAPI.cpp:3044
double getStopDelay(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2507
void setLine(const std::string &vehicleID, const std::string &line) const
Definition: TraCIAPI.cpp:2965
double getSlope(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2349
void setColor(const std::string &vehicleID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:2953
void add(const std::string &vehicleID, const std::string &routeID, const std::string &typeID="DEFAULT_VEHTYPE", std::string depart="-1", const std::string &departLane="first", const std::string &departPos="base", const std::string &departSpeed="0", const std::string &arrivalLane="current", const std::string &arrivalPos="max", const std::string &arrivalSpeed="current", const std::string &fromTaz="", const std::string &toTaz="", const std::string &line="", int personCapacity=0, int personNumber=0) const
Definition: TraCIAPI.cpp:2623
void setLaneChangeMode(const std::string &vehicleID, int mode) const
Definition: TraCIAPI.cpp:2875
void setRoutingMode(const std::string &vehicleID, int routingMode) const
Definition: TraCIAPI.cpp:2995
void addSubscriptionFilterTurn(double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3090
void moveToXY(const std::string &vehicleID, const std::string &edgeID, const int lane, const double x, const double y, const double angle, const int keepRoute) const
Definition: TraCIAPI.cpp:2799
std::string getRouteID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2251
double getLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2272
int getLaneChangeMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2337
int getSpeedMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2343
std::vector< std::string > getRoute(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2262
double getLateralLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2287
std::pair< std::string, double > getFollower(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2461
double getMaxSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2211
int getRoutingMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2502
double getFollowSpeed(const std::string &vehicleID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string &leaderID="") const
Definition: TraCIAPI.cpp:2163
void setType(const std::string &vehicleID, const std::string &typeID) const
Definition: TraCIAPI.cpp:2917
void addSubscriptionFilterFieldOfVision(double angle) const
Definition: TraCIAPI.cpp:3111
void setSpeedMode(const std::string &vehicleID, int mode) const
Definition: TraCIAPI.cpp:2884
std::string getTypeID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2246
double getAccumulatedWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2573
void rerouteTraveltime(const std::string &vehicleID, bool currentTravelTimes=true) const
Definition: TraCIAPI.cpp:2767
double getStopSpeed(const std::string &vehicleID, double speed, double gap) const
Definition: TraCIAPI.cpp:2198
void setApparentDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2105
void setHeight(const std::string &typeID, double height) const
Definition: TraCIAPI.cpp:2014
double getMinGapLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1913
void copy(const std::string &origTypeID, const std::string &newTypeID) const
Definition: TraCIAPI.cpp:2060
int getPersonCapacity(const std::string &typeID) const
Definition: TraCIAPI.cpp:1928
void setWidth(const std::string &typeID, double width) const
Definition: TraCIAPI.cpp:2005
double getApparentDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1878
void setLateralAlignment(const std::string &typeID, const std::string &latAlignment) const
Definition: TraCIAPI.cpp:2051
double getMaxSpeedLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1918
double getEmergencyDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1873
double getWidth(const std::string &typeID) const
Definition: TraCIAPI.cpp:1933
void setAccel(const std::string &typeID, double accel) const
Definition: TraCIAPI.cpp:2078
double getAccel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1863
double getHeight(const std::string &typeID) const
Definition: TraCIAPI.cpp:1938
void setEmergencyDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2096
void setMaxSpeedLat(const std::string &typeID, double speed) const
Definition: TraCIAPI.cpp:2042
std::string getLateralAlignment(const std::string &typeID) const
Definition: TraCIAPI.cpp:1923
void setMinGapLat(const std::string &typeID, double minGapLat) const
Definition: TraCIAPI.cpp:2033
RouteScope route
Scope for interaction with routes.
Definition: TraCIAPI.h:839
std::pair< int, std::string > getVersion()
return TraCI API and SUMO version
Definition: TraCIAPI.cpp:487
void setOrder(int order)
set priority (execution order) for the client
Definition: TraCIAPI.cpp:89
VehicleTypeScope vehicletype
Scope for interaction with vehicle types.
Definition: TraCIAPI.h:849
void send_commandSubscribeObjectVariable(int domID, const std::string &objID, double beginTime, double endTime, const std::vector< int > &vars) const
Sends a SubscribeVariable request.
Definition: TraCIAPI.cpp:209
void send_commandSimulationStep(double time) const
Sends a SimulationStep command.
Definition: TraCIAPI.cpp:125
GUIScope gui
Scope for interaction with the gui.
Definition: TraCIAPI.h:819
void check_resultState(tcpip::Storage &inMsg, int command, bool ignoreCommandId=false, std::string *acknowledgement=0) const
Validates the result state of a command.
Definition: TraCIAPI.cpp:268
PolygonScope polygon
Scope for interaction with polygons.
Definition: TraCIAPI.h:835
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
Definition: TraCIAPI.cpp:76
tcpip::Socket * mySocket
The socket.
Definition: TraCIAPI.h:944
void load(const std::vector< std::string > &args)
Let sumo load a simulation using the given command line like options.
Definition: TraCIAPI.cpp:469
void simulationStep(double time=0)
Advances by one step (or up to the given time)
Definition: TraCIAPI.cpp:447
void createCommand(int cmdID, int varID, const std::string &objID, tcpip::Storage *add=nullptr) const
Sends a GetVariable / SetVariable request if mySocket is connected. Otherwise writes to myOutput only...
Definition: TraCIAPI.cpp:162
LaneScope lane
Scope for interaction with lanes.
Definition: TraCIAPI.h:825
void send_commandSubscribeObjectContext(int domID, const std::string &objID, double beginTime, double endTime, int domain, double range, const std::vector< int > &vars) const
Sends a SubscribeContext request.
Definition: TraCIAPI.cpp:237
TrafficLightScope trafficlights
Scope for interaction with traffic lights.
Definition: TraCIAPI.h:845
InductionLoopScope inductionloop
Scope for interaction with inductive loops.
Definition: TraCIAPI.h:821
tcpip::Storage myOutput
The reusable output storage.
Definition: TraCIAPI.h:946
POIScope poi
Scope for interaction with POIs.
Definition: TraCIAPI.h:833
void closeSocket()
Closes the connection.
Definition: TraCIAPI.cpp:114
int check_commandGetResult(tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const
Validates the result state of a command.
Definition: TraCIAPI.cpp:307
VehicleScope vehicle
Scope for interaction with vehicles.
Definition: TraCIAPI.h:847
JunctionScope junction
Scope for interaction with junctions.
Definition: TraCIAPI.h:823
void send_commandClose() const
Sends a Close command.
Definition: TraCIAPI.cpp:138
void send_commandSetOrder(int order) const
Sends a SetOrder command.
Definition: TraCIAPI.cpp:149
EdgeScope edge
Scope for interaction with edges.
Definition: TraCIAPI.h:817
SimulationScope simulation
Scope for interaction with the simulation.
Definition: TraCIAPI.h:843
PersonScope person
Scope for interaction with persons.
Definition: TraCIAPI.h:831
void readAndReportTypeDependent(tcpip::Storage &inMsg, int valueDataType)
Reads a value of the given type from the given storage and reports it.
std::string joinToString(const std::vector< std::string > &s, const std::string &between)
void commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *addData=0)
Sends and validates a GetVariable command.
void testAPI()
call all API methods once
~TraCITestClient()
Destructor.
void commandSetValue(int domID, int varID, const std::string &objID, std::ifstream &defFile)
Sends and validates a SetVariable command.
int run(std::string fileName, int port, std::string host="localhost")
Runs a test.
std::string outputFileName
The name of the file to write the results log into.
void writeResult()
Writes the results file.
int setValueTypeDependant(tcpip::Storage &into, std::ifstream &defFile, std::stringstream &msg)
Parses the next value type / value pair from the stream and inserts it into the storage.
bool validateSubscription(tcpip::Storage &inMsg)
Validates whether the given message is a valid subscription return message.
void errorMsg(std::stringstream &msg)
Writes an error message.
bool validateSimulationStep2(tcpip::Storage &inMsg)
Validates whether the given message is a valid answer to CMD_SIMSTEP.
TraCITestClient(std::string outputFileName="testclient_result.out")
Constructor.
void commandSetOrder(int order)
Sends and validates a SetOrder command.
std::stringstream answerLog
Stream containing the log.
void commandSubscribeContextVariable(int domID, const std::string &objID, double beginTime, double endTime, int domain, double range, int varNo, std::ifstream &defFile)
Sends and validates a SubscribeContext command.
void commandSubscribeObjectVariable(int domID, const std::string &objID, double beginTime, double endTime, int varNo, std::ifstream &defFile)
Sends and validates a SubscribeVariable command.
void commandClose()
Sends and validates a Close command.
void commandSimulationStep(double time)
Sends and validates a simulation step command.
std::string approachedLane
Definition: TraCIDefs.h:345
std::string approachedInternal
Definition: TraCIDefs.h:349
An error which allows to continue.
Definition: TraCIDefs.h:130
std::vector< std::shared_ptr< libsumo::TraCIPhase > > phases
Definition: TraCIDefs.h:318
std::string description
arbitrary description string
Definition: TraCIDefs.h:531
std::vector< std::string > edges
The sequence of edges to travel.
Definition: TraCIDefs.h:515
double arrivalPos
position on the lane when ending the stage
Definition: TraCIDefs.h:529
void sendExact(const Storage &)
Definition: socket.cpp:431
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 void writeDouble(double)
Definition: storage.cpp:354
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
virtual void writeByte(int)
Definition: storage.cpp:140
virtual int readByte()
Definition: storage.cpp:128
virtual std::vector< std::string > readStringList()
Definition: storage.cpp:211
virtual double readDouble()
Definition: storage.cpp:362
virtual int readInt()
Definition: storage.cpp:311
TRACI_CONST int RESPONSE_SUBSCRIBE_GUI_VARIABLE
TRACI_CONST int TYPE_COLOR
TRACI_CONST int POSITION_3D
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int TYPE_UBYTE
TRACI_CONST int RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
TRACI_CONST int POSITION_2D
TRACI_CONST int ROUTING_MODE_AGGREGATED
TRACI_CONST int CMD_CLOSE
TRACI_CONST int TYPE_POLYGON
TRACI_CONST int CMD_SETORDER
TRACI_CONST int TYPE_STRINGLIST
TRACI_CONST int TYPE_INTEGER
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:278
TRACI_CONST int VAR_LANEPOSITION
TRACI_CONST int REQUEST_DRIVINGDIST
TRACI_CONST int STAGE_WALKING
TRACI_CONST int VAR_SPEED
TRACI_CONST int TYPE_DOUBLE
TRACI_CONST int TYPE_BYTE
TRACI_CONST int REQUEST_AIRDIST
TRACI_CONST int CMD_SIMSTEP
TRACI_CONST int RTYPE_OK
TRACI_CONST int RESPONSE_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
Definition: TraCIDefs.h:276
TRACI_CONST int RESPONSE_SUBSCRIBE_GUI_CONTEXT
TRACI_CONST int TYPE_STRING
std::string getString() const
Definition: TraCIDefs.h:195
double dist
The distance to the tls.
Definition: TraCIDefs.h:377
int tlIndex
The tls index of the controlled link.
Definition: TraCIDefs.h:375
std::string id
The id of the next tls.
Definition: TraCIDefs.h:373
char state
The current state of the tls.
Definition: TraCIDefs.h:379
std::string getString() const
Definition: TraCIDefs.h:165
A list of positions.
Definition: TraCIDefs.h:207
std::string getString() const
Definition: TraCIDefs.h:208
std::vector< TraCIPosition > value
Definition: TraCIDefs.h:217
std::string getString() const
Definition: TraCIDefs.h:179
mirrors MSInductLoop::VehicleData
Definition: TraCIDefs.h:357
std::string id
The id of the vehicle.
Definition: TraCIDefs.h:359
double entryTime
Entry-time of the vehicle in [s].
Definition: TraCIDefs.h:363
std::string typeID
Type of the vehicle in.
Definition: TraCIDefs.h:367
double length
Length of the vehicle.
Definition: TraCIDefs.h:361
double leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIDefs.h:365