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.dev/sumo
3 // Copyright (C) 2008-2024 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
23 // A test execution class
24 /****************************************************************************/
25 /* =========================================================================
26  * included modules
27  * ======================================================================= */
28 #ifdef _MSC_VER
29 #define _CRT_SECURE_NO_WARNINGS
30 // Avoid some noisy warnings with Visual Studio
31 #pragma warning(disable:4820 4514 5045 4710)
32 #endif
33 #include <vector>
34 #include <iostream>
35 #include <iomanip>
36 #include <fstream>
37 #include <sstream>
38 #include <ctime>
39 #include <cstdlib>
40 
41 #define BUILD_TCPIP
42 #include <foreign/tcpip/storage.h>
43 #include <foreign/tcpip/socket.h>
44 
45 #include <libsumo/TraCIConstants.h>
46 #include <libsumo/TraCIDefs.h>
47 #include "TraCITestClient.h"
48 
49 
50 // ===========================================================================
51 // method definitions
52 // ===========================================================================
53 TraCITestClient::TraCITestClient(std::string outputFileName)
54  : outputFileName(outputFileName), answerLog("") {
55  answerLog.setf(std::ios::fixed, std::ios::floatfield); // use decimal format
56  answerLog.setf(std::ios::showpoint); // print decimal point
57  answerLog << std::setprecision(2);
58 }
59 
60 
62  writeResult();
63 }
64 
65 
66 int
67 TraCITestClient::run(std::string fileName, int port, std::string host) {
68  std::ifstream defFile;
69  std::string fileContentStr;
70  std::stringstream fileContent;
71  std::string lineCommand;
72  std::stringstream msg;
73  int repNo = 1;
74  bool commentRead = false;
75 
76  // try to connect
77  try {
78  TraCIAPI::connect(host, port);
79  } catch (tcpip::SocketException& e) {
80  msg << "#Error while connecting: " << e.what();
81  errorMsg(msg);
82  return 2;
83  }
84 
85  // read definition file and trigger commands according to it
86  defFile.open(fileName.c_str());
87  if (!defFile) {
88  msg << "Can not open definition file " << fileName << std::endl;
89  errorMsg(msg);
90  return 1;
91  }
92  defFile.unsetf(std::ios::dec);
93 
94  while (defFile >> lineCommand) {
95  repNo = 1;
96  if (lineCommand.compare("%") == 0) {
97  // a comment was read
98  commentRead = !commentRead;
99  continue;
100  }
101  if (commentRead) {
102  // wait until end of comment is reached
103  continue;
104  }
105  if (lineCommand.compare("repeat") == 0) {
106  defFile >> repNo;
107  defFile >> lineCommand;
108  }
109  if (lineCommand.compare("simstep2") == 0) {
110  // read parameter for command simulation step and trigger command
111  double time;
112  defFile >> time;
113  for (int i = 0; i < repNo; i++) {
114  commandSimulationStep(time);
115  }
116  } else if (lineCommand.compare("getvariable") == 0) {
117  // trigger command GetXXXVariable
118  int domID, varID;
119  std::string objID;
120  defFile >> domID >> varID >> objID;
121  commandGetVariable(domID, varID, objID);
122  } else if (lineCommand.compare("getvariable_plus") == 0) {
123  // trigger command GetXXXVariable with one parameter
124  int domID, varID;
125  std::string objID;
126  defFile >> domID >> varID >> objID;
127  tcpip::Storage tmp;
128  setValueTypeDependant(tmp, defFile, msg);
129  std::string msgS = msg.str();
130  if (msgS != "") {
131  errorMsg(msg);
132  }
133  commandGetVariable(domID, varID, objID, &tmp);
134  } else if (lineCommand.compare("subscribevariable") == 0) {
135  // trigger command SubscribeXXXVariable
136  int domID, varNo;
137  double beginTime, endTime;
138  std::string objID;
139  defFile >> domID >> objID >> beginTime >> endTime >> varNo;
140  commandSubscribeObjectVariable(domID, objID, beginTime, endTime, varNo, defFile);
141  } else if (lineCommand.compare("subscribecontext") == 0) {
142  // trigger command SubscribeXXXVariable
143  int domID, varNo, domain;
144  double range;
145  double beginTime, endTime;
146  std::string objID;
147  defFile >> domID >> objID >> beginTime >> endTime >> domain >> range >> varNo;
148  commandSubscribeContextVariable(domID, objID, beginTime, endTime, domain, range, varNo, defFile);
149  } else if (lineCommand.compare("setvalue") == 0) {
150  // trigger command SetXXXValue
151  int domID, varID;
152  std::string objID;
153  defFile >> domID >> varID >> objID;
154  commandSetValue(domID, varID, objID, defFile);
155  } else if (lineCommand.compare("testAPI") == 0) {
156  // call all native API methods
157  testAPI();
158  } else if (lineCommand.compare("setorder") == 0) {
159  // call setOrder
160  int order;
161  defFile >> order;
162  commandSetOrder(order);
163  } else {
164  msg << "Error in definition file: " << lineCommand << " is not a valid command";
165  errorMsg(msg);
166  commandClose();
167  closeSocket();
168  return 1;
169  }
170  }
171  defFile.close();
172  commandClose();
173  closeSocket();
174  return 0;
175 }
176 
177 
178 // ---------- Commands handling
179 void
181  try {
183  answerLog << std::endl << "-> Command sent: <SimulationStep>:" << std::endl;
184  tcpip::Storage inMsg;
185  std::string acknowledgement;
186  check_resultState(inMsg, libsumo::CMD_SIMSTEP, false, &acknowledgement);
187  answerLog << acknowledgement << std::endl;
189  } catch (libsumo::TraCIException& e) {
190  answerLog << e.what() << std::endl;
191  }
192 }
193 
194 
195 void
197  try {
199  answerLog << std::endl << "-> Command sent: <Close>:" << std::endl;
200  tcpip::Storage inMsg;
201  std::string acknowledgement;
202  check_resultState(inMsg, libsumo::CMD_CLOSE, false, &acknowledgement);
203  answerLog << acknowledgement << std::endl;
204  } catch (libsumo::TraCIException& e) {
205  answerLog << e.what() << std::endl;
206  }
207 }
208 
209 
210 void
212  try {
213  send_commandSetOrder(order);
214  answerLog << std::endl << "-> Command sent: <SetOrder>:" << std::endl;
215  tcpip::Storage inMsg;
216  std::string acknowledgement;
217  check_resultState(inMsg, libsumo::CMD_SETORDER, false, &acknowledgement);
218  answerLog << acknowledgement << std::endl;
219  } catch (libsumo::TraCIException& e) {
220  answerLog << e.what() << std::endl;
221  }
222 }
223 
224 
225 void
226 TraCITestClient::commandGetVariable(int domID, int varID, const std::string& objID, tcpip::Storage* addData) {
227  tcpip::Storage inMsg;
228  try {
229  createCommand(domID, varID, objID, addData);
231  answerLog << std::endl << "-> Command sent: <GetVariable>:" << std::endl
232  << " domID=" << domID << " varID=" << varID
233  << " objID=" << objID << std::endl;
234  std::string acknowledgement;
235  check_resultState(inMsg, domID, false, &acknowledgement);
236  answerLog << acknowledgement << std::endl;
237  } catch (libsumo::TraCIException& e) {
238  answerLog << e.what() << std::endl;
239  return;
240  }
241  check_commandGetResult(inMsg, domID, -1, false);
242  // report result state
243  try {
244  int variableID = inMsg.readUnsignedByte();
245  std::string objectID = inMsg.readString();
246  answerLog << " CommandID=" << (domID + 0x10) << " VariableID=" << variableID << " ObjectID=" << objectID;
247  int valueDataType = inMsg.readUnsignedByte();
248  answerLog << " valueDataType=" << valueDataType;
249  readAndReportTypeDependent(inMsg, valueDataType);
250  } catch (libsumo::TraCIException& e) {
251  std::stringstream msg;
252  msg << "Error while receiving command: " << e.what();
253  errorMsg(msg);
254  return;
255  }
256 }
257 
258 
259 void
260 TraCITestClient::commandSetValue(int domID, int varID, const std::string& objID, std::ifstream& defFile) {
261  std::stringstream msg;
262  tcpip::Storage inMsg, tmp;
263  setValueTypeDependant(tmp, defFile, msg);
264  std::string msgS = msg.str();
265  if (msgS != "") {
266  errorMsg(msg);
267  }
268  createCommand(domID, varID, objID, &tmp);
270  answerLog << std::endl << "-> Command sent: <SetValue>:" << std::endl
271  << " domID=" << domID << " varID=" << varID
272  << " objID=" << objID << std::endl;
273  try {
274  std::string acknowledgement;
275  check_resultState(inMsg, domID, false, &acknowledgement);
276  answerLog << acknowledgement << std::endl;
277  } catch (libsumo::TraCIException& e) {
278  answerLog << e.what() << std::endl;
279  }
280 }
281 
282 
283 void
284 TraCITestClient::commandSubscribeObjectVariable(int domID, const std::string& objID, double beginTime, double endTime, int varNo, std::ifstream& defFile) {
285  std::vector<int> vars;
286  for (int i = 0; i < varNo; ++i) {
287  int var;
288  defFile >> var;
289  // variable id
290  vars.push_back(var);
291  }
292  send_commandSubscribeObjectVariable(domID, objID, beginTime, endTime, vars);
293  answerLog << std::endl << "-> Command sent: <SubscribeVariable>:" << std::endl
294  << " domID=" << domID << " objID=" << objID << " with " << varNo << " variables" << std::endl;
295  tcpip::Storage inMsg;
296  try {
297  std::string acknowledgement;
298  check_resultState(inMsg, domID, false, &acknowledgement);
299  answerLog << acknowledgement << std::endl;
300  validateSubscription(inMsg);
301  } catch (libsumo::TraCIException& e) {
302  answerLog << e.what() << std::endl;
303  }
304 }
305 
306 
307 void
308 TraCITestClient::commandSubscribeContextVariable(int domID, const std::string& objID, double beginTime, double endTime,
309  int domain, double range, int varNo, std::ifstream& defFile) {
310  std::vector<int> vars;
311  for (int i = 0; i < varNo; ++i) {
312  int var;
313  defFile >> var;
314  // variable id
315  vars.push_back(var);
316  }
317  send_commandSubscribeObjectContext(domID, objID, beginTime, endTime, domain, range, vars);
318  answerLog << std::endl << "-> Command sent: <SubscribeContext>:" << std::endl
319  << " domID=" << domID << " objID=" << objID << " domain=" << domain << " range=" << range
320  << " with " << varNo << " variables" << std::endl;
321  tcpip::Storage inMsg;
322  try {
323  std::string acknowledgement;
324  check_resultState(inMsg, domID, false, &acknowledgement);
325  answerLog << acknowledgement << std::endl;
326  validateSubscription(inMsg);
327  } catch (libsumo::TraCIException& e) {
328  answerLog << e.what() << std::endl;
329  }
330 }
331 
332 
333 // ---------- Report helper
334 void
336  time_t seconds;
337  tm* locTime;
338  std::ofstream outFile(outputFileName.c_str());
339  if (!outFile) {
340  std::cerr << "Unable to write result file" << std::endl;
341  }
342  time(&seconds);
343  locTime = localtime(&seconds);
344  outFile << "TraCITestClient output file. Date: " << asctime(locTime) << std::endl;
345  outFile << answerLog.str();
346  outFile.close();
347 }
348 
349 
350 void
351 TraCITestClient::errorMsg(std::stringstream& msg) {
352  std::cerr << msg.str() << std::endl;
353  answerLog << "----" << std::endl << msg.str() << std::endl;
354 }
355 
356 
357 
358 
359 
360 
361 bool
363  try {
364  int noSubscriptions = inMsg.readInt();
365  for (int s = 0; s < noSubscriptions; ++s) {
366  if (!validateSubscription(inMsg)) {
367  return false;
368  }
369  }
370  } catch (std::invalid_argument& e) {
371  answerLog << "#Error while reading message:" << e.what() << std::endl;
372  return false;
373  }
374  return true;
375 }
376 
377 
378 bool
380  try {
381  int length = inMsg.readUnsignedByte();
382  if (length == 0) {
383  length = inMsg.readInt();
384  }
385  int cmdId = inMsg.readUnsignedByte();
387  answerLog << " CommandID=" << cmdId;
388  answerLog << " ObjectID=" << inMsg.readString();
389  int varNo = inMsg.readUnsignedByte();
390  answerLog << " #variables=" << varNo << std::endl;
391  for (int i = 0; i < varNo; ++i) {
392  answerLog << " VariableID=" << inMsg.readUnsignedByte();
393  bool ok = inMsg.readUnsignedByte() == libsumo::RTYPE_OK;
394  answerLog << " ok=" << ok;
395  int valueDataType = inMsg.readUnsignedByte();
396  answerLog << " valueDataType=" << valueDataType;
397  readAndReportTypeDependent(inMsg, valueDataType);
398  }
400  answerLog << " CommandID=" << cmdId;
401  answerLog << " ObjectID=" << inMsg.readString();
402  answerLog << " Domain=" << inMsg.readUnsignedByte();
403  int varNo = inMsg.readUnsignedByte();
404  answerLog << " #variables=" << varNo << std::endl;
405  int objNo = inMsg.readInt();
406  answerLog << " #objects=" << objNo << std::endl;
407  for (int j = 0; j < objNo; ++j) {
408  answerLog << " ObjectID=" << inMsg.readString() << std::endl;
409  for (int i = 0; i < varNo; ++i) {
410  answerLog << " VariableID=" << inMsg.readUnsignedByte();
411  bool ok = inMsg.readUnsignedByte() == libsumo::RTYPE_OK;
412  answerLog << " ok=" << ok;
413  int valueDataType = inMsg.readUnsignedByte();
414  answerLog << " valueDataType=" << valueDataType;
415  readAndReportTypeDependent(inMsg, valueDataType);
416  }
417  }
418  } else {
419  answerLog << "#Error: received response with command id: " << cmdId << " but expected a subscription response (0xe0-0xef / 0x90-0x9f)" << std::endl;
420  return false;
421  }
422  } catch (std::invalid_argument& e) {
423  answerLog << "#Error while reading message:" << e.what() << std::endl;
424  return false;
425  }
426  return true;
427 }
428 
429 
430 
431 
432 
433 
434 
435 // ---------- Conversion helper
436 int
437 TraCITestClient::setValueTypeDependant(tcpip::Storage& into, std::ifstream& defFile, std::stringstream& msg) {
438  std::string dataTypeS;
439  defFile >> dataTypeS;
440  if (dataTypeS == "<airDist>") {
442  return 1;
443  } else if (dataTypeS == "<drivingDist>") {
445  return 1;
446  } else if (dataTypeS == "<objSubscription>") {
447  int beginTime, endTime, numVars;
448  defFile >> beginTime >> endTime >> numVars;
449  into.writeInt(beginTime);
450  into.writeInt(endTime);
451  into.writeInt(numVars);
452  for (int i = 0; i < numVars; ++i) {
453  int var;
454  defFile >> var;
455  into.writeUnsignedByte(var);
456  }
457  return 4 + 4 + 4 + numVars;
458  }
459  int valI;
460  double valF;
461  if (dataTypeS == "<int>") {
462  defFile >> valI;
464  into.writeInt(valI);
465  return 4 + 1;
466  } else if (dataTypeS == "<byte>") {
467  defFile >> valI;
469  into.writeByte(valI);
470  return 1 + 1;
471  } else if (dataTypeS == "<ubyte>") {
472  defFile >> valI;
474  into.writeUnsignedByte(valI);
475  return 1 + 1;
476  } else if (dataTypeS == "<double>") {
477  defFile >> valF;
479  into.writeDouble(valF);
480  return 8 + 1;
481  } else if (dataTypeS == "<string>") {
482  std::string valueS;
483  defFile >> valueS;
484  if (valueS == "\"\"") {
485  valueS = "";
486  }
488  into.writeString(valueS);
489  return 4 + 1 + (int) valueS.length();
490  } else if (dataTypeS == "<string*>") {
491  std::vector<std::string> slValue;
492  defFile >> valI;
493  int length = 1 + 4;
494  for (int i = 0; i < valI; ++i) {
495  std::string tmp;
496  defFile >> tmp;
497  slValue.push_back(tmp);
498  length += 4 + int(tmp.length());
499  }
501  into.writeStringList(slValue);
502  return length;
503  } else if (dataTypeS == "<compound>") {
504  defFile >> valI;
506  into.writeInt(valI);
507  int length = 1 + 4;
508  for (int i = 0; i < valI; ++i) {
509  length += setValueTypeDependant(into, defFile, msg);
510  }
511  return length;
512  } else if (dataTypeS == "<color>") {
513  defFile >> valI;
515  into.writeUnsignedByte(valI);
516  for (int i = 0; i < 3; ++i) {
517  defFile >> valI;
518  into.writeUnsignedByte(valI);
519  }
520  return 1 + 4;
521  } else if (dataTypeS == "<position2D>") {
522  defFile >> valF;
524  into.writeDouble(valF);
525  defFile >> valF;
526  into.writeDouble(valF);
527  return 1 + 8 + 8;
528  } else if (dataTypeS == "<position3D>") {
529  defFile >> valF;
531  into.writeDouble(valF);
532  defFile >> valF;
533  into.writeDouble(valF);
534  defFile >> valF;
535  into.writeDouble(valF);
536  return 1 + 8 + 8 + 8;
537  } else if (dataTypeS == "<positionRoadmap>") {
538  std::string valueS;
539  defFile >> valueS;
541  into.writeString(valueS);
542  int length = 1 + 8 + (int) valueS.length();
543  defFile >> valF;
544  into.writeDouble(valF);
545  defFile >> valI;
546  into.writeUnsignedByte(valI);
547  return length + 4 + 1;
548  } else if (dataTypeS == "<shape>") {
549  defFile >> valI;
551  into.writeUnsignedByte(valI);
552  int length = 1 + 1;
553  for (int i = 0; i < valI; ++i) {
554  double x, y;
555  defFile >> x >> y;
556  into.writeDouble(x);
557  into.writeDouble(y);
558  length += 8 + 8;
559  }
560  return length;
561  }
562  msg << "## Unknown data type: " << dataTypeS;
563  return 0;
564 }
565 
566 
567 void
569  if (valueDataType == libsumo::TYPE_UBYTE) {
570  int ubyte = inMsg.readUnsignedByte();
571  answerLog << " Unsigned Byte Value: " << ubyte << std::endl;
572  } else if (valueDataType == libsumo::TYPE_BYTE) {
573  int byte = inMsg.readByte();
574  answerLog << " Byte value: " << byte << std::endl;
575  } else if (valueDataType == libsumo::TYPE_INTEGER) {
576  int integer = inMsg.readInt();
577  answerLog << " Int value: " << integer << std::endl;
578  } else if (valueDataType == libsumo::TYPE_DOUBLE) {
579  double doublev = inMsg.readDouble();
580  answerLog << " Double value: " << doublev << std::endl;
581  } else if (valueDataType == libsumo::TYPE_POLYGON) {
582  int size = inMsg.readUnsignedByte();
583  if (size == 0) {
584  size = inMsg.readInt();
585  }
586  answerLog << " PolygonValue: ";
587  for (int i = 0; i < size; i++) {
588  double x = inMsg.readDouble();
589  double y = inMsg.readDouble();
590  answerLog << "(" << x << "," << y << ") ";
591  }
592  answerLog << std::endl;
593  } else if (valueDataType == libsumo::POSITION_3D) {
594  double x = inMsg.readDouble();
595  double y = inMsg.readDouble();
596  double z = inMsg.readDouble();
597  answerLog << " Position3DValue: " << std::endl;
598  answerLog << " x: " << x << " y: " << y
599  << " z: " << z << std::endl;
600  } else if (valueDataType == libsumo::POSITION_ROADMAP) {
601  std::string roadId = inMsg.readString();
602  double pos = inMsg.readDouble();
603  int laneId = inMsg.readUnsignedByte();
604  answerLog << " RoadMapPositionValue: roadId=" << roadId
605  << " pos=" << pos
606  << " laneId=" << laneId << std::endl;
607  } else if (valueDataType == libsumo::TYPE_STRING) {
608  std::string s = inMsg.readString();
609  answerLog << " string value: " << s << std::endl;
610  } else if (valueDataType == libsumo::TYPE_STRINGLIST) {
611  std::vector<std::string> s = inMsg.readStringList();
612  answerLog << " string list value: [ " << std::endl;
613  for (std::vector<std::string>::iterator i = s.begin(); i != s.end(); ++i) {
614  if (i != s.begin()) {
615  answerLog << ", ";
616  }
617  answerLog << '"' << *i << '"';
618  }
619  answerLog << " ]" << std::endl;
620  } else if (valueDataType == libsumo::TYPE_COMPOUND) {
621  int no = inMsg.readInt();
622  answerLog << " compound value with " << no << " members: [ " << std::endl;
623  for (int i = 0; i < no; ++i) {
624  int currentValueDataType = inMsg.readUnsignedByte();
625  answerLog << " valueDataType=" << currentValueDataType;
626  readAndReportTypeDependent(inMsg, currentValueDataType);
627  }
628  answerLog << " ]" << std::endl;
629  } else if (valueDataType == libsumo::POSITION_2D) {
630  double xv = inMsg.readDouble();
631  double yv = inMsg.readDouble();
632  answerLog << " position value: (" << xv << "," << yv << ")" << std::endl;
633  } else if (valueDataType == libsumo::TYPE_COLOR) {
634  int r = inMsg.readUnsignedByte();
635  int g = inMsg.readUnsignedByte();
636  int b = inMsg.readUnsignedByte();
637  int a = inMsg.readUnsignedByte();
638  answerLog << " color value: (" << r << "," << g << "," << b << "," << a << ")" << std::endl;
639  } else {
640  answerLog << "#Error: unknown valueDataType!" << std::endl;
641  }
642 }
643 
644 
645 void
647  answerLog << "testAPI:\n";
648  const auto& version = getVersion();
649  answerLog << " getVersion: " << version.first << ", " << version.second << "\n";
650  answerLog << " setOrder:\n";
651  setOrder(0);
652  // edge
653  answerLog << " edge:\n";
654  answerLog << " getIDList: " << joinToString(edge.getIDList(), " ") << "\n";
655  answerLog << " getIDCount: " << edge.getIDCount() << "\n";
656  const std::string edgeID = "e_m0";
657  edge.adaptTraveltime(edgeID, 42, 0, 10);
658  edge.setEffort(edgeID, 420, 0, 10);
659  answerLog << " currentTraveltime: " << edge.getTraveltime(edgeID) << "\n";
660  answerLog << " adaptedTravelTime: " << edge.getAdaptedTraveltime(edgeID, 0) << "\n";
661  answerLog << " effort: " << edge.getEffort(edgeID, 0) << "\n";
662  answerLog << " laneNumber: " << edge.getLaneNumber(edgeID) << "\n";
663  answerLog << " streetName: " << edge.getStreetName(edgeID) << "\n";
664  edge.setMaxSpeed(edgeID, 42);
665  answerLog << " maxSpeed: " << lane.getMaxSpeed(edgeID + "_0") << "\n";
666 
667  // lane
668  answerLog << " lane:\n";
669  answerLog << " getIDList: " << joinToString(lane.getIDList(), " ") << "\n";
670  answerLog << " getIDCount: " << lane.getIDCount() << "\n";
671  const std::string laneID = "e_m6_0";
672  answerLog << " getLinkNumber: " << lane.getLinkNumber(laneID) << "\n";
673  std::vector<libsumo::TraCIConnection> connections = lane.getLinks(laneID);
674  answerLog << " getLinks:\n";
675  for (int i = 0; i < (int)connections.size(); ++i) {
676  const libsumo::TraCIConnection& c = connections[i];
677  answerLog << " approachedLane=" << c.approachedLane
678  << " hasPrio=" << c.hasPrio
679  << " isOpen=" << c.isOpen
680  << " hasFoe=" << c.hasFoe
681  << " approachedInternal=" << c.approachedInternal
682  << " state=" << c.state
683  << " direction=" << c.direction
684  << " length=" << c.length
685  << "\n";
686  }
687  answerLog << " getFoes: " << joinToString(lane.getFoes("e_vu0_0", "e_m4_0"), " ") << "\n";
688  try {
689  answerLog << " getFoes (invalid): ";
690  answerLog << joinToString(lane.getFoes("e_vu0_0", "e_m4_1"), " ") << "\n";
691  } catch (libsumo::TraCIException& e) {
692  answerLog << " caught TraCIException(" << e.what() << ")\n";
693  }
694  answerLog << " getInternalFoes: " << joinToString(lane.getInternalFoes(":n_m4_2_0"), " ") << "\n";
695  try {
696  answerLog << " getInternalFoes (invalid): ";
697  answerLog << joinToString(lane.getInternalFoes("dummy"), " ") << "\n";
698  } catch (libsumo::TraCIException& e) {
699  answerLog << " caught TraCIException(" << e.what() << ")\n";
700  }
701  lane.setMaxSpeed(laneID, 42);
702  answerLog << " maxSpeed: " << lane.getMaxSpeed(laneID) << "\n";
703  // poi
704  answerLog << " POI:\n";
705  answerLog << " getIDList: " << joinToString(poi.getIDList(), " ") << "\n";
706  answerLog << " getIDCount: " << poi.getIDCount() << "\n";
707  answerLog << " getPosition: " << poi.getPosition("poi0").getString() << "\n";
708  answerLog << " getColor: " << poi.getColor("poi0").getString() << "\n";
709 
710  // poly
711  answerLog << " polygon:\n";
712  answerLog << " getIDList: " << joinToString(polygon.getIDList(), " ") << "\n";
713  answerLog << " getIDCount: " << polygon.getIDCount() << "\n";
715  polygon.setLineWidth("poly0", 0.6);
716  answerLog << " getLineWidth: " << polygon.getLineWidth("poly0") << "\n";
717  answerLog << " getShape: " << shape.getString() << "\n";
718  answerLog << " getColor: " << polygon.getColor("poly0").getString() << "\n";
719  shape.value[0].x = 42;
720  polygon.setShape("poly0", shape);
721  answerLog << " getShape after modification: " << polygon.getShape("poly0").getString() << "\n";
722 
723  // junction
724  answerLog << " junction:\n";
725  answerLog << " getIDList: " << joinToString(junction.getIDList(), " ") << "\n";
726  answerLog << " getIDCount: " << junction.getIDCount() << "\n";
727  answerLog << " getShape: " << junction.getShape("n_m4").getString() << "\n";
728 
729  // route
730  answerLog << " route:\n";
731  answerLog << " add:\n";
732  std::vector<std::string> edges;
733  edges.push_back("e_u1");
734  edges.push_back("e_u0");
735  route.add("e_u1", edges);
736  edges.clear();
737  edges.push_back("e_m4");
738  route.add("e_m4", edges);
739  answerLog << " getIDList: " << joinToString(route.getIDList(), " ") << "\n";
740 
741  // vehicletype
742  answerLog << " vehicleType:\n";
743  answerLog << " getIDList: " << joinToString(vehicletype.getIDList(), " ") << "\n";
744  vehicletype.setEmergencyDecel("t1", 9.9);
745  answerLog << " getEmergencyDecel: " << vehicletype.getEmergencyDecel("t1") << "\n";
746  vehicletype.setApparentDecel("t1", 99.9);
747  answerLog << " getApparentDecel: " << vehicletype.getApparentDecel("t1") << "\n";
748  vehicletype.setWidth("t1", 1.9);
749  answerLog << " getWidth: " << vehicletype.getWidth("t1") << "\n";
750  vehicletype.setHeight("t1", 1.8);
751  answerLog << " getHeight: " << vehicletype.getHeight("t1") << "\n";
752  vehicletype.setMinGapLat("t1", 1.5);
753  answerLog << " setMinGapLat: " << vehicletype.getMinGapLat("t1") << "\n";
754  vehicletype.setMaxSpeedLat("t1", 1.2);
755  answerLog << " setMaxSpeedLat: " << vehicletype.getMaxSpeedLat("t1") << "\n";
756  vehicletype.setLateralAlignment("t1", "compact");
757  answerLog << " getLateralAlignment: " << vehicletype.getLateralAlignment("t1") << "\n";
758  answerLog << " getPersonCapacity: " << vehicletype.getPersonCapacity("t1") << "\n";
759  answerLog << " copy type 't1' to 't1_copy' and set accel to 100.\n";
760  vehicletype.copy("t1", "t1_copy");
761  answerLog << " getIDList: " << joinToString(vehicletype.getIDList(), " ") << "\n";
762  vehicletype.setAccel("t1_copy", 100.);
763  answerLog << " getAccel('t1'): " << vehicletype.getAccel("t1") << "\n";
764  answerLog << " getAccel('t1_copy'): " << vehicletype.getAccel("t1_copy") << "\n";
765 
766  // vehicle
767  answerLog << " vehicle:\n";
768  vehicle.setLine("0", "S42");
769  std::vector<std::string> via;
770  via.push_back("e_shape1");
771  vehicle.setVia("0", via);
772  vehicle.setType("0", "t1_copy");
773  answerLog << " getTypeID: " << vehicle.getTypeID("0") << "\n";
774  answerLog << " getRoadID: " << vehicle.getRoadID("0") << "\n";
775  answerLog << " getRouteID: " << vehicle.getRouteID("0") << "\n";
776  answerLog << " getLaneID: " << vehicle.getLaneID("0") << "\n";
777  answerLog << " getLanePosition: " << vehicle.getLanePosition("0") << "\n";
778  answerLog << " getLateralLanePosition: " << vehicle.getLateralLanePosition("0") << "\n";
779  answerLog << " getSpeed: " << vehicle.getSpeed("0") << "\n";
780  answerLog << " getLateralSpeed: " << vehicle.getLateralSpeed("0") << "\n";
781  answerLog << " getAcceleration: " << vehicle.getAcceleration("0") << "\n";
782 
783  answerLog << " getFollowSpeed: " << vehicle.getFollowSpeed("0", 10, 20, 9, 4.5) << "\n";
784  answerLog << " getSecureGap: " << vehicle.getSecureGap("0", 10, 9, 4.5) << "\n";
785  answerLog << " getStopSpeed: " << vehicle.getStopSpeed("0", 10, 20) << "\n";
786 
787  answerLog << " getSpeedMode: " << vehicle.getSpeedMode("0") << "\n";
788  answerLog << " getSlope: " << vehicle.getSlope("0") << "\n";
789  answerLog << " getLine: " << vehicle.getLine("0") << "\n";
790  answerLog << " getVia: " << joinToString(vehicle.getVia("0"), ",") << "\n";
791  answerLog << " getPersonCapacity: " << vehicle.getPersonCapacity("0") << "\n";
792  vehicle.setMaxSpeed("0", 30);
793  answerLog << " getMaxSpeed: " << vehicle.getMaxSpeed("0") << "\n";
794  answerLog << " isRouteValid: " << vehicle.isRouteValid("0") << "\n";
795  answerLog << " getStopState: " << vehicle.getStopState("0") << "\n";
796  answerLog << " getStopDelay: " << vehicle.getStopDelay("0") << "\n";
797  vehicle.setParameter("0", "meaningOfLife", "42");
798  answerLog << " param: " << vehicle.getParameter("0", "meaningOfLife") << "\n";
799  std::pair<std::string, std::string> paramTuple = vehicle.getParameterWithKey("0", "meaningOfLife");
800  answerLog << " parameterWithKey: (" << paramTuple.first << ", " << paramTuple.second << ")\n";
801  libsumo::TraCIColor col1;
802  col1.r = 255;
803  col1.g = 255;
804  col1.b = 0;
805  col1.a = 128;
806  vehicle.setColor("0", col1);
808  answerLog << " getColor: r=" << (int)col2.r << " g=" << (int)col2.g << " b=" << (int)col2.b << " a=" << (int)col2.a << "\n";
809  int signals = vehicle.getSignals("0");
810  answerLog << " getSignals: " << signals << "\n";
813  answerLog << " getRoutingMode: " << vehicle.getRoutingMode("0") << "\n";
814  answerLog << " getNextTLS:\n";
815  std::vector<libsumo::TraCINextTLSData> result = vehicle.getNextTLS("0");
816  for (int i = 0; i < (int)result.size(); ++i) {
817  const libsumo::TraCINextTLSData& d = result[i];
818  answerLog << " tls=" << d.id << " tlIndex=" << d.tlIndex << " dist=" << d.dist << " state=" << d.state << "\n";
819  }
820  answerLog << " moveToXY, simStep:\n";
821  vehicle.moveToXY("0", "dummy", 0, 2231.61, 498.29, 90, 1);
822  simulationStep();
823  // simulationStep(1);
824  answerLog << " getRoadID: " << vehicle.getRoadID("0") << "\n";
825  answerLog << " getLaneID: " << vehicle.getLaneID("0") << "\n";
826  vehicle.changeTarget("0", "e_o0");
827  std::vector<std::string> edges2 = vehicle.getRoute("0");
828  answerLog << " edges: " << joinToString(edges2, " ") << "\n";
829  vehicle.setRouteID("0", "e_m4");
830  answerLog << " edges: " << joinToString(vehicle.getRoute("0"), " ") << "\n";
831  vehicle.setRoute("0", edges2);
832  answerLog << " edges: " << joinToString(vehicle.getRoute("0"), " ") << "\n";
833  answerLog << " add:\n";
834  vehicle.add("1", "e_u1");
835  vehicle.add("2", "e_u1");
836  vehicle.moveTo("2", "e_u0_0", 5);
837  simulationStep();
838  answerLog << " getIDList: " << joinToString(vehicle.getIDList(), " ") << "\n";
839  answerLog << " getWaitingTime: " << vehicle.getWaitingTime("0") << "\n";
840  answerLog << " getAccumulatedWaitingTime: " << vehicle.getAccumulatedWaitingTime("0") << "\n";
841  vehicle.setShapeClass("0", "bicycle");
842  answerLog << " getShapeClass: " << vehicle.getShapeClass("0") << "\n";
843  std::pair<std::string, double> leader = vehicle.getLeader("1", 1000);
844  answerLog << " getLeader: " << leader.first << ", " << leader.second << "\n";
845  std::pair<std::string, double> follower = vehicle.getFollower("1", 1000);
846  answerLog << " getFollower: " << follower.first << ", " << follower.second << "\n";
847  std::pair<int, int> state = vehicle.getLaneChangeState("1", 1);
848  answerLog << " getLaneChangeState (left): " << state.first << ", " << state.second << "\n";
849  state = vehicle.getLaneChangeState("1", -1);
850  answerLog << " getLaneChangeState (right): " << state.first << ", " << state.second << "\n";
852  vehicle.setSpeedFactor("0", 0.8);
853  vehicle.setSpeedMode("0", 0);
854  answerLog << " getSpeedMode after change: " << vehicle.getSpeedMode("0") << "\n";
855  vehicle.setLaneChangeMode("0", 0);
856  answerLog << " getLaneChangeMode after change: " << vehicle.getLaneChangeMode("0") << "\n";
857  answerLog << " remove:\n";
858  vehicle.remove("0");
859  answerLog << " getIDCount: " << vehicle.getIDCount() << "\n";
860 
861  // inductionLoop
862  answerLog << " inductionloop:\n";
863  answerLog << " getIDList: " << joinToString(inductionloop.getIDList(), " ") << "\n";
864  answerLog << " getVehicleData:\n";
865  std::vector<libsumo::TraCIVehicleData> result2 = inductionloop.getVehicleData("det1");
866  for (int i = 0; i < (int)result2.size(); ++i) {
867  const libsumo::TraCIVehicleData& vd = result2[i];
868  answerLog << " veh=" << vd.id << " length=" << vd.length << " entered=" << vd.entryTime << " left=" << vd.leaveTime << " type=" << vd.typeID << "\n";
869  }
870 
871  // multi-entry/-exit detector
872  // answerLog << " multi-entry/-exit detector:\n";
873  // answerLog << " getLastStepVehicleIDs: " << joinToString(multientryexit.getLastStepVehicleIDs("det2"), " ") << "\n";
874  // answerLog << " getEntryLanes: " << joinToString(multientryexit.getEntryLanes("det2"), " ") << "\n";
875  // answerLog << " getExitLanes: " << joinToString(multientryexit.getExitLanes("det2"), " ") << "\n";
876  // answerLog << " getEntryPositions: " << joinToString(multientryexit.getEntryPositions("det2"), " ") << "\n";
877  // answerLog << " getExitPositions: " << joinToString(multientryexit.getExitPositions("det2"), " ") << "\n";
878 
879  // simulation
880  answerLog << " simulation:\n";
881  answerLog << " getOption: " << simulation.getOption("net-file") << "\n";
882  answerLog << " convert2D: " << simulation.convert2D("e_m5", 0).getString() << "\n";
883  answerLog << " convert2DGeo: " << simulation.convert2D("e_m5", 0, 0, true).getString() << "\n";
884  answerLog << " convert3D: " << simulation.convert3D("e_m5", 0).getString() << "\n";
885  answerLog << " convert3DGeo: " << simulation.convert3D("e_m5", 0, 0, true).getString() << "\n";
886  answerLog << " convertRoad: " << simulation.convertRoad(2500, 500).getString() << "\n";
887  answerLog << " convertRoadBus: " << simulation.convertRoad(2500, 500, false, "bus").getString() << "\n";
888  answerLog << " convertGeo: " << simulation.convertGeo(2500, 500).getString() << "\n";
889  answerLog << " convertCartesian: " << simulation.convertGeo(12, 52, true).getString() << "\n";
890  answerLog << " getDistance2D_air: " << simulation.getDistance2D(2500, 500, 2000, 500, false, false) << "\n";
891  answerLog << " getDistance2D_driving: " << simulation.getDistance2D(2500, 500, 2000, 500, false, true) << "\n";
892  answerLog << " getDistanceRoad_air: " << simulation.getDistanceRoad("e_m5", 0, "e_m4", 0, false) << "\n";
893  answerLog << " getDistanceRoad_driving: " << simulation.getDistanceRoad("e_m5", 0, "e_m4", 0, true) << "\n";
894  answerLog << " getCurrentTime: " << simulation.getCurrentTime() << "\n";
895  answerLog << " getDeltaT: " << simulation.getDeltaT() << "\n";
896  answerLog << " parkingArea param: " << simulation.getParameter("park1", "parkingArea.capacity") << "\n";
897  answerLog << " busStopWaiting: " << simulation.getBusStopWaiting("bs1") << "\n";
898  answerLog << " busStopWaitingIDs: " << joinToString(simulation.getBusStopWaitingIDList("bs1"), " ") << "\n";
899  simulation.writeMessage("custom message test");
900  answerLog << " subscribe to road and pos of vehicle '1':\n";
901  answerLog << " findRoute: " << joinToString(simulation.findRoute("e_m5", "e_m4").edges, " ") << "\n";
902  std::vector<int> vars;
903  vars.push_back(libsumo::VAR_ROAD_ID);
904  vars.push_back(libsumo::VAR_LANEPOSITION);
905  vehicle.subscribe("1", vars, 0, 100);
906  simulationStep();
907  answerLog << " subscription results:\n";
909  answerLog << " roadID=" << result3[libsumo::VAR_ROAD_ID]->getString() << " pos=" << result3[libsumo::VAR_LANEPOSITION]->getString() << "\n";
910 
911  answerLog << " subscribe to vehicles around edge 'e_u1':\n";
912  std::vector<int> vars2;
913  vars2.push_back(libsumo::VAR_LANEPOSITION);
914  edge.subscribeContext("e_u1", libsumo::CMD_GET_VEHICLE_VARIABLE, 100, vars2, 0, 100);
915  simulationStep();
916  answerLog << " context subscription results:\n";
918  for (libsumo::SubscriptionResults::iterator it = result4.begin(); it != result4.end(); ++it) {
919  answerLog << " vehicle=" << it->first << " pos=" << it->second[libsumo::VAR_LANEPOSITION]->getString() << "\n";
920  }
921 
922  answerLog << " subscribe to vehicles around vehicle '1':\n";
923  std::vector<int> vars3;
924  vars3.push_back(libsumo::VAR_SPEED);
926  vehicle.addSubscriptionFilterLanes(std::vector<int>({0, 1, 2}));
931  vehicle.addSubscriptionFilterLeadFollow(std::vector<int>({0, 1, 2}));
933  vehicle.addSubscriptionFilterVClass(std::vector<std::string>({"passenger"}));
934  vehicle.addSubscriptionFilterVType(std::vector<std::string>({"DEFAULT_VEHTYPE"}));
936 
939 
942  //
943 
944  simulationStep();
945  answerLog << " context subscription results:\n";
947  for (auto item : result5) {
948  answerLog << " vehicle=" << item.first << "\n";
949  }
950 
951  // person
952  answerLog << " person:\n";
953  person.setWidth("p0", 1);
954  person.setMinGap("p0", 2);
955  person.setLength("p0", 3);
956  person.setHeight("p0", 4);
957  person.setColor("p0", col1);
958  person.setType("p0", "stilts");
959  answerLog << " getIDList: " << joinToString(person.getIDList(), " ") << "\n";
960  answerLog << " getRoadID: " << person.getRoadID("p0") << "\n";
961  answerLog << " getLaneID: " << person.getLaneID("p0") << "\n";
962  answerLog << " getTypeID: " << person.getTypeID("p0") << "\n";
963  answerLog << " getWaitingTime: " << person.getWaitingTime("p0") << "\n";
964  answerLog << " getNextEdge: " << person.getNextEdge("p0") << "\n";
965  answerLog << " getStage: " << person.getStage("p0").description << "\n";
966  answerLog << " getRemainingStages: " << person.getRemainingStages("p0") << "\n";
967  answerLog << " getVehicle: " << person.getVehicle("p0") << "\n";
968  answerLog << " getEdges: " << joinToString(person.getEdges("p0"), " ") << "\n";
969  answerLog << " getPosition: " << person.getPosition("p0").getString() << "\n";
970  answerLog << " getPosition3D: " << person.getPosition3D("p0").getString() << "\n";
971  answerLog << " getAngle: " << person.getAngle("p0") << "\n";
972  answerLog << " getSlope: " << person.getSlope("p0") << "\n";
973  answerLog << " getLanePosition: " << person.getLanePosition("p0") << "\n";
974  answerLog << " getLength: " << person.getLength("p0") << "\n";
975  answerLog << " getColor: " << person.getColor("p0").getString() << "\n";
976  person.setParameter("p0", "foo", "bar");
977  answerLog << " param: " << person.getParameter("p0", "foo") << "\n";
978  person.setSpeed("p0", 3);
979  simulationStep();
980  answerLog << " getSpeed: " << person.getSpeed("p0") << "\n";
981  person.add("p1", "e_u1", 10);
982  std::vector<std::string> walkEdges;
983  walkEdges.push_back("e_u1");
984  walkEdges.push_back("e_shape1");
985  person.appendWalkingStage("p1", walkEdges, -20);
986  person.appendWaitingStage("p1", 5);
987  person.appendDrivingStage("p1", "e_vu2", "BusLine42");
989  stage.edges.push_back("e_vu2");
990  stage.edges.push_back("e_vo2");
991  stage.arrivalPos = -10;
992  person.appendStage("p1", stage);
993  simulationStep();
994  // expect 5 stages due to the initial waiting-for-departure stage
995  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
996  person.removeStage("p1", 3);
997  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
998  person.removeStages("p1");
999  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
1000  answerLog << " getStage: " << person.getStage("p1").description << "\n";
1001  walkEdges.push_back("e_m5");
1002  person.appendWalkingStage("p1", walkEdges, -20);
1003  simulationStep();
1004  person.rerouteTraveltime("p1");
1005  answerLog << " getEdges after rerouting: " << joinToString(person.getEdges("p1"), " ") << "\n";
1006 
1007  // trafficlights
1008  answerLog << " trafficlights:\n";
1009  trafficlights.setPhase("n_m4", 0);
1010  trafficlights.setPhaseName("n_m4", "nameSetByTraCI");
1011  answerLog << " getIDList: " << joinToString(trafficlights.getIDList(), " ") << "\n";
1012  answerLog << " getIDCount: " << trafficlights.getIDCount() << "\n";
1013  answerLog << " state: " << trafficlights.getRedYellowGreenState("n_m4") << "\n";
1014  answerLog << " program: " << trafficlights.getProgram("n_m4") << "\n";
1015  answerLog << " phase: " << trafficlights.getPhase("n_m4") << "\n";
1016  answerLog << " phaseName: " << trafficlights.getPhaseName("n_m4") << "\n";
1017  answerLog << " phaseDuration: " << trafficlights.getPhaseDuration("n_m4") << "\n";
1018  answerLog << " nextSwitch: " << trafficlights.getNextSwitch("n_m4") << "\n";
1019  answerLog << " controlledLanes: " << joinToString(trafficlights.getControlledLanes("n_m4"), " ") << "\n";
1020  std::vector<std::vector<libsumo::TraCILink> > links = trafficlights.getControlledLinks("n_m4");
1021  answerLog << " controlledLinks:\n";
1022  for (int i = 0; i < (int)links.size(); ++i) {
1023  for (int j = 0; j < (int)links[i].size(); ++j) {
1024  answerLog << " index=" << i << " link=" << j << " fromLane=" << links[i][j].fromLane << " viaLane=" << links[i][j].viaLane << " toLane=" << links[i][j].toLane << "\n";
1025  }
1026  }
1027  libsumo::TraCILogic logic("custom", 0, 3);
1028  logic.phases.push_back(std::make_shared<libsumo::TraCIPhase>(5, "rrrrrrr", 5, 5));
1029  logic.phases.push_back(std::make_shared<libsumo::TraCIPhase>(10, "ggggggg", 5, 15));
1030  logic.phases.push_back(std::make_shared<libsumo::TraCIPhase>(3, "GGGGGGG", 3, 3));
1031  logic.phases.push_back(std::make_shared<libsumo::TraCIPhase>(3, "yyyyyyy", 3, 3));
1032  trafficlights.setProgramLogic("n_m4", logic);
1033 
1034  std::vector<libsumo::TraCILogic> logics = trafficlights.getAllProgramLogics("n_m4");
1035  answerLog << " completeDefinition:\n";
1036  for (int i = 0; i < (int)logics.size(); ++i) {
1037  answerLog << " subID=" << logics[i].programID << " type=" << logics[i].type << " phase=" << logics[i].currentPhaseIndex << "\n";
1038  answerLog << " params=" << joinToString(logics[i].subParameter) << "\n";
1039  for (int j = 0; j < (int)logics[i].phases.size(); ++j) {
1040  answerLog << " phase=" << logics[i].phases[j]->state
1041  << " dur=" << logics[i].phases[j]->duration
1042  << " minDur=" << logics[i].phases[j]->minDur
1043  << " maxDur=" << logics[i].phases[j]->maxDur
1044  << "\n";
1045  }
1046  }
1047  simulationStep();
1048  answerLog << " state=" << trafficlights.getRedYellowGreenState("n_m4") << "\n";
1049  trafficlights.setRedYellowGreenState("n_m4", "gGyruoO");
1050  answerLog << " stateSet=" << trafficlights.getRedYellowGreenState("n_m4") << "\n";
1051  answerLog << " program: " << trafficlights.getProgram("n_m4") << "\n";
1052 
1053  answerLog << " gui:\n";
1054  try {
1055  answerLog << " setScheme: \n";
1056  gui.setSchema("View #0", "real world");
1057  answerLog << " getScheme: " << gui.getSchema("View #0") << "\n";
1058  gui.setZoom("View #0", 50);
1059  answerLog << " getZoom: " << gui.getZoom() << "\n";
1060  answerLog << " take screenshot: \n";
1061  gui.screenshot("View #0", "image.png", 500, 500);
1062  } catch (libsumo::TraCIException&) {
1063  answerLog << " no support for gui commands\n";
1064  }
1065 
1066  answerLog << " load:\n";
1067  std::vector<std::string> args;
1068  args.push_back("-n");
1069  args.push_back("net.net.xml");
1070  args.push_back("-r");
1071  args.push_back("input_routes.rou.xml");
1072  args.push_back("-a");
1073  args.push_back("input_additional.add.xml");
1074  args.push_back("--no-step-log");
1075  load(args);
1076  simulationStep();
1077  answerLog << " getCurrentTime: " << simulation.getCurrentTime() << "\n";
1078  vehicle.subscribe("0", vars, 0, 100);
1079  edge.subscribeContext("e_u1", libsumo::CMD_GET_VEHICLE_VARIABLE, 100, vars2, 0, 100);
1080 }
void adaptTraveltime(const std::string &edgeID, double time, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
Definition: TraCIAPI.cpp:602
void setMaxSpeed(const std::string &edgeID, double speed) const
Definition: TraCIAPI.cpp:641
int getLaneNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:590
void setEffort(const std::string &edgeID, double effort, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
Definition: TraCIAPI.cpp:622
double getTraveltime(const std::string &edgeID) const
Definition: TraCIAPI.cpp:569
std::string getStreetName(const std::string &id) const
Definition: TraCIAPI.cpp:596
double getAdaptedTraveltime(const std::string &edgeID, double time) const
Definition: TraCIAPI.cpp:497
double getEffort(const std::string &edgeID, double time) const
Definition: TraCIAPI.cpp:505
std::string getSchema(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:660
void setZoom(const std::string &viewID, double zoom) const
Definition: TraCIAPI.cpp:671
void setSchema(const std::string &viewID, const std::string &schemeName) const
Definition: TraCIAPI.cpp:686
double getZoom(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:650
void screenshot(const std::string &viewID, const std::string &filename, const int width=-1, const int height=-1) const
Definition: TraCIAPI.cpp:704
std::vector< libsumo::TraCIVehicleData > getVehicleData(const std::string &loopID) const
Definition: TraCIAPI.cpp:774
libsumo::TraCIPositionVector getShape(const std::string &junctionID) const
Definition: TraCIAPI.cpp:816
int getLinkNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:850
void setMaxSpeed(const std::string &laneID, double speed) const
Definition: TraCIAPI.cpp:1023
std::vector< std::string > getInternalFoes(const std::string &laneID) const
Definition: TraCIAPI.cpp:1007
std::vector< libsumo::TraCIConnection > getLinks(const std::string &laneID) const
Definition: TraCIAPI.cpp:855
double getMaxSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:830
std::vector< std::string > getFoes(const std::string &laneID, const std::string &toLaneID) const
Definition: TraCIAPI.cpp:991
libsumo::TraCIColor getColor(const std::string &poiID) const
Definition: TraCIAPI.cpp:1095
libsumo::TraCIPosition getPosition(const std::string &poiID) const
Definition: TraCIAPI.cpp:1090
std::string getNextEdge(const std::string &personID) const
Definition: TraCIAPI.cpp:3270
void setLength(const std::string &personID, double length) const
Definition: TraCIAPI.cpp:3499
libsumo::TraCIColor getColor(const std::string &personID) const
Definition: TraCIAPI.cpp:3235
double getSlope(const std::string &personID) const
Definition: TraCIAPI.cpp:3225
int getRemainingStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3281
double getWaitingTime(const std::string &personID) const
Definition: TraCIAPI.cpp:3265
libsumo::TraCIStage getStage(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3286
void removeStage(const std::string &personID, int nextStageIndex) const
Definition: TraCIAPI.cpp:3430
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:3322
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:3392
void setSpeed(const std::string &personID, double speed) const
Definition: TraCIAPI.cpp:3471
double getLength(const std::string &personID) const
Definition: TraCIAPI.cpp:3240
void setHeight(const std::string &personID, double height) const
Definition: TraCIAPI.cpp:3518
void setType(const std::string &personID, const std::string &typeID) const
Definition: TraCIAPI.cpp:3481
void setMinGap(const std::string &personID, double minGap) const
Definition: TraCIAPI.cpp:3527
libsumo::TraCIPosition getPosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3210
void removeStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3302
void setColor(const std::string &personID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:3537
std::string getRoadID(const std::string &personID) const
Definition: TraCIAPI.cpp:3245
double getSpeed(const std::string &personID) const
Definition: TraCIAPI.cpp:3205
std::string getVehicle(const std::string &personID) const
Definition: TraCIAPI.cpp:3276
void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
Definition: TraCIAPI.cpp:3413
std::string getTypeID(const std::string &personID) const
Definition: TraCIAPI.cpp:3255
void appendStage(const std::string &personID, const libsumo::TraCIStage &stage)
Definition: TraCIAPI.cpp:3339
double getAngle(const std::string &personID) const
Definition: TraCIAPI.cpp:3220
std::string getLaneID(const std::string &personID) const
Definition: TraCIAPI.cpp:3250
libsumo::TraCIPosition getPosition3D(const std::string &personID) const
Definition: TraCIAPI.cpp:3215
std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3294
void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: TraCIAPI.cpp:3375
double getLanePosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3230
void setWidth(const std::string &personID, double width) const
Definition: TraCIAPI.cpp:3509
void rerouteTraveltime(const std::string &personID) const
Definition: TraCIAPI.cpp:3312
libsumo::TraCIColor getColor(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1237
libsumo::TraCIPositionVector getShape(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1232
double getLineWidth(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1217
void setLineWidth(const std::string &polygonID, const double lineWidth) const
Definition: TraCIAPI.cpp:1242
void setShape(const std::string &polygonID, const libsumo::TraCIPositionVector &shape) const
Definition: TraCIAPI.cpp:1261
void add(const std::string &routeID, const std::vector< std::string > &edges) const
Definition: TraCIAPI.cpp:1338
double getDistance2D(double x1, double y1, double x2, double y2, bool isGeo=false, bool isDriving=false)
Definition: TraCIAPI.cpp:1552
libsumo::TraCIPosition convert2D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1463
int getBusStopWaiting(const std::string &stopID) const
Definition: TraCIAPI.cpp:1452
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:1594
libsumo::TraCIRoadPosition convertRoad(double x, double y, bool isGeo=false, const std::string &vClass="ignoring") const
Definition: TraCIAPI.cpp:1508
std::vector< std::string > getBusStopWaitingIDList(const std::string &stopID) const
Definition: TraCIAPI.cpp:1457
double getDistanceRoad(const std::string &edgeID1, double pos1, const std::string &edgeID2, double pos2, bool isDriving=false)
Definition: TraCIAPI.cpp:1572
double getDeltaT() const
Definition: TraCIAPI.cpp:1431
std::string getOption(const std::string &option) const
Definition: TraCIAPI.cpp:1447
void writeMessage(const std::string msg)
Definition: TraCIAPI.cpp:1630
libsumo::TraCIPosition convertGeo(double x, double y, bool fromGeo=false) const
Definition: TraCIAPI.cpp:1531
libsumo::TraCIPosition convert3D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1485
const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3884
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:3764
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:3743
const libsumo::TraCIResults getSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3868
void subscribeContext(const std::string &objID, int domain, double range, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3852
void setParameter(const std::string &objectID, const std::string &key, const std::string &value) const
set generic paramter
Definition: TraCIAPI.cpp:3783
std::string getParameter(const std::string &objectID, const std::string &key) const
retrieve generic parameter
Definition: TraCIAPI.cpp:3755
void subscribe(const std::string &objID, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3840
std::string getRedYellowGreenState(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1643
int getPhase(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1739
std::string getPhaseName(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1744
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
Definition: TraCIAPI.cpp:1769
std::string getProgram(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1734
void setPhase(const std::string &tlsID, int index) const
Definition: TraCIAPI.cpp:1778
void setPhaseName(const std::string &tlsID, const std::string &name) const
Definition: TraCIAPI.cpp:1787
double getNextSwitch(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1754
std::vector< std::vector< libsumo::TraCILink > > getControlledLinks(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1706
double getPhaseDuration(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1749
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1701
std::vector< libsumo::TraCILogic > getAllProgramLogics(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1648
void setProgramLogic(const std::string &tlsID, const libsumo::TraCILogic &logic) const
Definition: TraCIAPI.cpp:1814
std::vector< libsumo::TraCINextTLSData > getNextTLS(const std::string &vehID) const
Definition: TraCIAPI.cpp:2395
double getLateralSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2173
void setMaxSpeed(const std::string &vehicleID, double speed) const
Definition: TraCIAPI.cpp:2981
double getSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2168
int getStopState(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2517
double getWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2352
void addSubscriptionFilterCFManeuver(double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3092
void changeTarget(const std::string &vehicleID, const std::string &edgeID) const
Definition: TraCIAPI.cpp:2714
bool isRouteValid(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2623
double getSecureGap(const std::string &vehicleID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string &leaderID="") const
Definition: TraCIAPI.cpp:2202
void setSpeedFactor(const std::string &vehicleID, double factor) const
Definition: TraCIAPI.cpp:2963
void setShapeClass(const std::string &vehicleID, const std::string &clazz) const
Definition: TraCIAPI.cpp:3041
void addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist=-1, double foeDistToJunction=-1) const
Definition: TraCIAPI.cpp:3153
void setVia(const std::string &vehicleID, const std::vector< std::string > &via) const
Definition: TraCIAPI.cpp:3011
void remove(const std::string &vehicleID, char reason=libsumo::REMOVE_VAPORIZED) const
Definition: TraCIAPI.cpp:2703
void moveTo(const std::string &vehicleID, const std::string &laneID, double position, int reason=libsumo::MOVE_TELEPORT) const
Definition: TraCIAPI.cpp:2804
void setRouteID(const std::string &vehicleID, const std::string &routeID) const
Definition: TraCIAPI.cpp:2764
std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction) const
Definition: TraCIAPI.cpp:2499
std::string getShapeClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2390
void addSubscriptionFilterLeadFollow(const std::vector< int > &lanes) const
Definition: TraCIAPI.cpp:3121
std::string getLine(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2375
void setRoute(const std::string &vehicleID, const std::vector< std::string > &edge) const
Definition: TraCIAPI.cpp:2774
int getSignals(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2302
libsumo::TraCIColor getColor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2287
int getPersonCapacity(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2608
void setSignals(const std::string &vehicleID, int signals) const
Definition: TraCIAPI.cpp:3023
std::string getRoadID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2251
void addSubscriptionFilterVType(const std::vector< std::string > &vTypes) const
Definition: TraCIAPI.cpp:3142
void addSubscriptionFilterUpstreamDistance(double dist) const
Definition: TraCIAPI.cpp:3086
void addSubscriptionFilterLanes(const std::vector< int > &lanes, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3060
void addSubscriptionFilterNoOpposite() const
Definition: TraCIAPI.cpp:3076
void addSubscriptionFilterLCManeuver(int direction, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3103
std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2463
double getAcceleration(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2178
std::vector< std::string > getVia(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2380
void addSubscriptionFilterVClass(const std::vector< std::string > &vClasses) const
Definition: TraCIAPI.cpp:3136
std::string getLaneID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2256
void addSubscriptionFilterDownstreamDistance(double dist) const
Definition: TraCIAPI.cpp:3081
double getStopDelay(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2527
void setLine(const std::string &vehicleID, const std::string &line) const
Definition: TraCIAPI.cpp:3002
double getSlope(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2369
void setColor(const std::string &vehicleID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:2990
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:2643
void setLaneChangeMode(const std::string &vehicleID, int mode) const
Definition: TraCIAPI.cpp:2912
void setRoutingMode(const std::string &vehicleID, int routingMode) const
Definition: TraCIAPI.cpp:3032
void addSubscriptionFilterTurn(double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3127
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:2819
std::string getRouteID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2271
double getLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2292
int getLaneChangeMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2357
int getSpeedMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2363
std::vector< std::string > getRoute(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2282
double getLateralLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2307
std::pair< std::string, double > getFollower(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2481
double getMaxSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2231
int getRoutingMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2522
double getFollowSpeed(const std::string &vehicleID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string &leaderID="") const
Definition: TraCIAPI.cpp:2183
void setType(const std::string &vehicleID, const std::string &typeID) const
Definition: TraCIAPI.cpp:2954
void addSubscriptionFilterFieldOfVision(double angle) const
Definition: TraCIAPI.cpp:3148
void setSpeedMode(const std::string &vehicleID, int mode) const
Definition: TraCIAPI.cpp:2921
std::string getTypeID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2266
double getAccumulatedWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2593
void rerouteTraveltime(const std::string &vehicleID, bool currentTravelTimes=true) const
Definition: TraCIAPI.cpp:2787
double getStopSpeed(const std::string &vehicleID, double speed, double gap) const
Definition: TraCIAPI.cpp:2218
void setApparentDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2125
void setHeight(const std::string &typeID, double height) const
Definition: TraCIAPI.cpp:2034
double getMinGapLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1933
void copy(const std::string &origTypeID, const std::string &newTypeID) const
Definition: TraCIAPI.cpp:2080
int getPersonCapacity(const std::string &typeID) const
Definition: TraCIAPI.cpp:1948
void setWidth(const std::string &typeID, double width) const
Definition: TraCIAPI.cpp:2025
double getApparentDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1898
void setLateralAlignment(const std::string &typeID, const std::string &latAlignment) const
Definition: TraCIAPI.cpp:2071
double getMaxSpeedLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1938
double getEmergencyDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1893
double getWidth(const std::string &typeID) const
Definition: TraCIAPI.cpp:1953
void setAccel(const std::string &typeID, double accel) const
Definition: TraCIAPI.cpp:2098
double getAccel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1883
double getHeight(const std::string &typeID) const
Definition: TraCIAPI.cpp:1958
void setEmergencyDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2116
void setMaxSpeedLat(const std::string &typeID, double speed) const
Definition: TraCIAPI.cpp:2062
std::string getLateralAlignment(const std::string &typeID) const
Definition: TraCIAPI.cpp:1943
void setMinGapLat(const std::string &typeID, double minGapLat) const
Definition: TraCIAPI.cpp:2053
RouteScope route
Scope for interaction with routes.
Definition: TraCIAPI.h:851
std::pair< int, std::string > getVersion()
return TraCI API and SUMO version
Definition: TraCIAPI.cpp:479
void setOrder(int order)
set priority (execution order) for the client
Definition: TraCIAPI.cpp:81
VehicleTypeScope vehicletype
Scope for interaction with vehicle types.
Definition: TraCIAPI.h:861
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:201
void send_commandSimulationStep(double time) const
Sends a SimulationStep command.
Definition: TraCIAPI.cpp:117
GUIScope gui
Scope for interaction with the gui.
Definition: TraCIAPI.h:831
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:260
PolygonScope polygon
Scope for interaction with polygons.
Definition: TraCIAPI.h:847
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
Definition: TraCIAPI.cpp:68
tcpip::Socket * mySocket
The socket.
Definition: TraCIAPI.h:956
void load(const std::vector< std::string > &args)
Let sumo load a simulation using the given command line like options.
Definition: TraCIAPI.cpp:461
void simulationStep(double time=0)
Advances by one step (or up to the given time)
Definition: TraCIAPI.cpp:439
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:154
LaneScope lane
Scope for interaction with lanes.
Definition: TraCIAPI.h:837
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:229
TrafficLightScope trafficlights
Scope for interaction with traffic lights.
Definition: TraCIAPI.h:857
InductionLoopScope inductionloop
Scope for interaction with inductive loops.
Definition: TraCIAPI.h:833
tcpip::Storage myOutput
The reusable output storage.
Definition: TraCIAPI.h:958
POIScope poi
Scope for interaction with POIs.
Definition: TraCIAPI.h:845
void closeSocket()
Closes the connection.
Definition: TraCIAPI.cpp:106
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:299
VehicleScope vehicle
Scope for interaction with vehicles.
Definition: TraCIAPI.h:859
JunctionScope junction
Scope for interaction with junctions.
Definition: TraCIAPI.h:835
void send_commandClose() const
Sends a Close command.
Definition: TraCIAPI.cpp:130
void send_commandSetOrder(int order) const
Sends a SetOrder command.
Definition: TraCIAPI.cpp:141
EdgeScope edge
Scope for interaction with edges.
Definition: TraCIAPI.h:829
SimulationScope simulation
Scope for interaction with the simulation.
Definition: TraCIAPI.h:855
PersonScope person
Scope for interaction with persons.
Definition: TraCIAPI.h:843
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:404
std::string approachedInternal
Definition: TraCIDefs.h:408
An error which allows to continue.
Definition: TraCIDefs.h:144
std::vector< std::shared_ptr< libsumo::TraCIPhase > > phases
Definition: TraCIDefs.h:377
std::string description
arbitrary description string
Definition: TraCIDefs.h:590
std::vector< std::string > edges
The sequence of edges to travel.
Definition: TraCIDefs.h:574
double arrivalPos
position on the lane when ending the stage
Definition: TraCIDefs.h:588
void sendExact(const Storage &)
Definition: socket.cpp:439
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:337
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:335
TRACI_CONST int RESPONSE_SUBSCRIBE_GUI_CONTEXT
TRACI_CONST int TYPE_STRING
std::string getString() const
Definition: TraCIDefs.h:219
double dist
The distance to the tls.
Definition: TraCIDefs.h:436
int tlIndex
The tls index of the controlled link.
Definition: TraCIDefs.h:434
std::string id
The id of the next tls.
Definition: TraCIDefs.h:432
char state
The current state of the tls.
Definition: TraCIDefs.h:438
std::string getString() const
Definition: TraCIDefs.h:179
A list of positions.
Definition: TraCIDefs.h:234
std::string getString() const
Definition: TraCIDefs.h:235
std::vector< TraCIPosition > value
Definition: TraCIDefs.h:244
std::string getString() const
Definition: TraCIDefs.h:200
mirrors MSInductLoop::VehicleData
Definition: TraCIDefs.h:416
std::string id
The id of the vehicle.
Definition: TraCIDefs.h:418
double entryTime
Entry-time of the vehicle in [s].
Definition: TraCIDefs.h:422
std::string typeID
Type of the vehicle in.
Definition: TraCIDefs.h:426
double length
Length of the vehicle.
Definition: TraCIDefs.h:420
double leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIDefs.h:424