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-2020 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
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  std::stringstream msg;
79  msg << "#Error while connecting: " << e.what();
80  errorMsg(msg);
81  return 2;
82  }
83 
84  // read definition file and trigger commands according to it
85  defFile.open(fileName.c_str());
86  if (!defFile) {
87  msg << "Can not open definition file " << fileName << std::endl;
88  errorMsg(msg);
89  return 1;
90  }
91  defFile.unsetf(std::ios::dec);
92 
93  while (defFile >> lineCommand) {
94  repNo = 1;
95  if (lineCommand.compare("%") == 0) {
96  // a comment was read
97  commentRead = !commentRead;
98  continue;
99  }
100  if (commentRead) {
101  // wait until end of comment is reached
102  continue;
103  }
104  if (lineCommand.compare("repeat") == 0) {
105  defFile >> repNo;
106  defFile >> lineCommand;
107  }
108  if (lineCommand.compare("simstep2") == 0) {
109  // read parameter for command simulation step and trigger command
110  double time;
111  defFile >> time;
112  for (int i = 0; i < repNo; i++) {
113  commandSimulationStep(time);
114  }
115  } else if (lineCommand.compare("getvariable") == 0) {
116  // trigger command GetXXXVariable
117  int domID, varID;
118  std::string objID;
119  defFile >> domID >> varID >> objID;
120  commandGetVariable(domID, varID, objID);
121  } else if (lineCommand.compare("getvariable_plus") == 0) {
122  // trigger command GetXXXVariable with one parameter
123  int domID, varID;
124  std::string objID;
125  defFile >> domID >> varID >> objID;
126  std::stringstream msg;
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";
714  std::vector<libsumo::TraCIPosition> shape = polygon.getShape("poly0");
715  std::string shapeStr;
716  for (auto pos : shape) {
717  shapeStr += pos.getString() + " ";
718  }
719  polygon.setLineWidth("poly0", 0.6);
720  answerLog << " getLineWidth: " << polygon.getLineWidth("poly0") << "\n";
721  answerLog << " getShape: " << shapeStr << "\n";
722  answerLog << " getColor: " << polygon.getColor("poly0").getString() << "\n";
723  shape[0].x = 42;
724  polygon.setShape("poly0", shape);
725  std::string shapeStr2;
726  for (auto pos : polygon.getShape("poly0")) {
727  shapeStr2 += pos.getString() + " ";
728  }
729  answerLog << " getShape after modification: " << shapeStr2 << "\n";
730 
731  // junction
732  answerLog << " junction:\n";
733  answerLog << " getIDList: " << joinToString(junction.getIDList(), " ") << "\n";
734  answerLog << " getIDCount: " << junction.getIDCount() << "\n";
735  std::vector<libsumo::TraCIPosition> junctionShape = junction.getShape("n_m4");
736  std::string junctionShapeStr;
737  for (auto pos : junctionShape) {
738  junctionShapeStr += pos.getString() + " ";
739  }
740  answerLog << " getShape: " << junctionShapeStr << "\n";
741 
742  // route
743  answerLog << " route:\n";
744  answerLog << " add:\n";
745  std::vector<std::string> edges;
746  edges.push_back("e_u1");
747  edges.push_back("e_u0");
748  route.add("e_u1", edges);
749  edges.clear();
750  edges.push_back("e_m4");
751  route.add("e_m4", edges);
752  answerLog << " getIDList: " << joinToString(route.getIDList(), " ") << "\n";
753 
754  // vehicletype
755  answerLog << " vehicleType:\n";
756  answerLog << " getIDList: " << joinToString(vehicletype.getIDList(), " ") << "\n";
757  vehicletype.setEmergencyDecel("t1", 9.9);
758  answerLog << " getEmergencyDecel: " << vehicletype.getEmergencyDecel("t1") << "\n";
759  vehicletype.setApparentDecel("t1", 99.9);
760  answerLog << " getApparentDecel: " << vehicletype.getApparentDecel("t1") << "\n";
761  vehicletype.setWidth("t1", 1.9);
762  answerLog << " getWidth: " << vehicletype.getWidth("t1") << "\n";
763  vehicletype.setHeight("t1", 1.8);
764  answerLog << " getHeight: " << vehicletype.getHeight("t1") << "\n";
765  vehicletype.setMinGapLat("t1", 1.5);
766  answerLog << " setMinGapLat: " << vehicletype.getMinGapLat("t1") << "\n";
767  vehicletype.setMaxSpeedLat("t1", 1.2);
768  answerLog << " setMaxSpeedLat: " << vehicletype.getMaxSpeedLat("t1") << "\n";
769  vehicletype.setLateralAlignment("t1", "compact");
770  answerLog << " getLateralAlignment: " << vehicletype.getLateralAlignment("t1") << "\n";
771  answerLog << " getPersonCapacity: " << vehicletype.getPersonCapacity("t1") << "\n";
772  answerLog << " copy type 't1' to 't1_copy' and set accel to 100.\n";
773  vehicletype.copy("t1", "t1_copy");
774  answerLog << " getIDList: " << joinToString(vehicletype.getIDList(), " ") << "\n";
775  vehicletype.setAccel("t1_copy", 100.);
776  answerLog << " getAccel('t1'): " << vehicletype.getAccel("t1") << "\n";
777  answerLog << " getAccel('t1_copy'): " << vehicletype.getAccel("t1_copy") << "\n";
778 
779  // vehicle
780  answerLog << " vehicle:\n";
781  vehicle.setLine("0", "S42");
782  std::vector<std::string> via;
783  via.push_back("e_shape1");
784  vehicle.setVia("0", via);
785  vehicle.setType("0", "t1_copy");
786  answerLog << " getTypeID: " << vehicle.getTypeID("0") << "\n";
787  answerLog << " getRoadID: " << vehicle.getRoadID("0") << "\n";
788  answerLog << " getRouteID: " << vehicle.getRouteID("0") << "\n";
789  answerLog << " getLaneID: " << vehicle.getLaneID("0") << "\n";
790  answerLog << " getLanePosition: " << vehicle.getLanePosition("0") << "\n";
791  answerLog << " getLateralLanePosition: " << vehicle.getLateralLanePosition("0") << "\n";
792  answerLog << " getSpeed: " << vehicle.getSpeed("0") << "\n";
793  answerLog << " getLateralSpeed: " << vehicle.getLateralSpeed("0") << "\n";
794  answerLog << " getAcceleration: " << vehicle.getAcceleration("0") << "\n";
795 
796  answerLog << " getFollowSpeed: " << vehicle.getFollowSpeed("0", 10, 20, 9, 4.5) << "\n";
797  answerLog << " getSecureGap: " << vehicle.getSecureGap("0", 10, 9, 4.5) << "\n";
798  answerLog << " getStopSpeed: " << vehicle.getStopSpeed("0", 10, 20) << "\n";
799 
800  answerLog << " getSpeedMode: " << vehicle.getSpeedMode("0") << "\n";
801  answerLog << " getSlope: " << vehicle.getSlope("0") << "\n";
802  answerLog << " getLine: " << vehicle.getLine("0") << "\n";
803  answerLog << " getVia: " << joinToString(vehicle.getVia("0"), ",") << "\n";
804  answerLog << " getPersonCapacity: " << vehicle.getPersonCapacity("0") << "\n";
805  vehicle.setMaxSpeed("0", 30);
806  answerLog << " getMaxSpeed: " << vehicle.getMaxSpeed("0") << "\n";
807  answerLog << " isRouteValid: " << vehicle.isRouteValid("0") << "\n";
808  answerLog << " getStopState: " << vehicle.getStopState("0") << "\n";
809  answerLog << " getStopDelay: " << vehicle.getStopDelay("0") << "\n";
810  vehicle.setParameter("0", "meaningOfLife", "42");
811  answerLog << " param: " << vehicle.getParameter("0", "meaningOfLife") << "\n";
812  std::pair<std::string, std::string> paramTuple = vehicle.getParameterWithKey("0", "meaningOfLife");
813  answerLog << " parameterWithKey: (" << paramTuple.first << ", " << paramTuple.second << ")\n";
814  libsumo::TraCIColor col1;
815  col1.r = 255;
816  col1.g = 255;
817  col1.b = 0;
818  col1.a = 128;
819  vehicle.setColor("0", col1);
821  answerLog << " getColor: r=" << (int)col2.r << " g=" << (int)col2.g << " b=" << (int)col2.b << " a=" << (int)col2.a << "\n";
822  int signals = vehicle.getSignals("0");
823  answerLog << " getSignals: " << signals << "\n";
826  answerLog << " getRoutingMode: " << vehicle.getRoutingMode("0") << "\n";
827  answerLog << " getNextTLS:\n";
828  std::vector<libsumo::TraCINextTLSData> result = vehicle.getNextTLS("0");
829  for (int i = 0; i < (int)result.size(); ++i) {
830  const libsumo::TraCINextTLSData& d = result[i];
831  answerLog << " tls=" << d.id << " tlIndex=" << d.tlIndex << " dist=" << d.dist << " state=" << d.state << "\n";
832  }
833  answerLog << " moveToXY, simStep:\n";
834  vehicle.moveToXY("0", "dummy", 0, 2231.61, 498.29, 90, 1);
835  simulationStep();
836  // simulationStep(1);
837  answerLog << " getRoadID: " << vehicle.getRoadID("0") << "\n";
838  answerLog << " getLaneID: " << vehicle.getLaneID("0") << "\n";
839  vehicle.changeTarget("0", "e_o0");
840  std::vector<std::string> edges2 = vehicle.getRoute("0");
841  answerLog << " edges: " << joinToString(edges2, " ") << "\n";
842  vehicle.setRouteID("0", "e_m4");
843  answerLog << " edges: " << joinToString(vehicle.getRoute("0"), " ") << "\n";
844  vehicle.setRoute("0", edges2);
845  answerLog << " edges: " << joinToString(vehicle.getRoute("0"), " ") << "\n";
846  answerLog << " add:\n";
847  vehicle.add("1", "e_u1");
848  vehicle.add("2", "e_u1");
849  vehicle.moveTo("2", "e_u0_0", 5);
850  simulationStep();
851  answerLog << " getIDList: " << joinToString(vehicle.getIDList(), " ") << "\n";
852  answerLog << " getWaitingTime: " << vehicle.getWaitingTime("0") << "\n";
853  answerLog << " getAccumulatedWaitingTime: " << vehicle.getAccumulatedWaitingTime("0") << "\n";
854  vehicle.setShapeClass("0", "bicycle");
855  answerLog << " getShapeClass: " << vehicle.getShapeClass("0") << "\n";
856  std::pair<std::string, double> leader = vehicle.getLeader("1", 1000);
857  answerLog << " getLeader: " << leader.first << ", " << leader.second << "\n";
858  std::pair<std::string, double> follower = vehicle.getFollower("1", 1000);
859  answerLog << " getFollower: " << follower.first << ", " << follower.second << "\n";
860  std::pair<int, int> state = vehicle.getLaneChangeState("1", 1);
861  answerLog << " getLaneChangeState (left): " << state.first << ", " << state.second << "\n";
862  state = vehicle.getLaneChangeState("1", -1);
863  answerLog << " getLaneChangeState (right): " << state.first << ", " << state.second << "\n";
865  vehicle.setSpeedFactor("0", 0.8);
866  vehicle.setSpeedMode("0", 0);
867  answerLog << " getSpeedMode after change: " << vehicle.getSpeedMode("0") << "\n";
868  vehicle.setLaneChangeMode("0", 0);
869  answerLog << " getLaneChangeMode after change: " << vehicle.getLaneChangeMode("0") << "\n";
870  answerLog << " remove:\n";
871  vehicle.remove("0");
872  answerLog << " getIDCount: " << vehicle.getIDCount() << "\n";
873 
874  // inductionLoop
875  answerLog << " inductionloop:\n";
876  answerLog << " getIDList: " << joinToString(inductionloop.getIDList(), " ") << "\n";
877  answerLog << " getVehicleData:\n";
878  std::vector<libsumo::TraCIVehicleData> result2 = inductionloop.getVehicleData("det1");
879  for (int i = 0; i < (int)result2.size(); ++i) {
880  const libsumo::TraCIVehicleData& vd = result2[i];
881  answerLog << " veh=" << vd.id << " length=" << vd.length << " entered=" << vd.entryTime << " left=" << vd.leaveTime << " type=" << vd.typeID << "\n";
882  }
883 
884  // simulation
885  answerLog << " simulation:\n";
886  answerLog << " convert2D: " << simulation.convert2D("e_m5", 0).getString() << "\n";
887  answerLog << " convert2DGeo: " << simulation.convert2D("e_m5", 0, 0, true).getString() << "\n";
888  answerLog << " convert3D: " << simulation.convert3D("e_m5", 0).getString() << "\n";
889  answerLog << " convert3DGeo: " << simulation.convert3D("e_m5", 0, 0, true).getString() << "\n";
890  answerLog << " convertRoad: " << simulation.convertRoad(2500, 500).getString() << "\n";
891  answerLog << " convertRoadBus: " << simulation.convertRoad(2500, 500, false, "bus").getString() << "\n";
892  answerLog << " convertGeo: " << simulation.convertGeo(2500, 500).getString() << "\n";
893  answerLog << " convertCartesian: " << simulation.convertGeo(12, 52, true).getString() << "\n";
894  answerLog << " getDistance2D_air: " << simulation.getDistance2D(2500, 500, 2000, 500, false, false) << "\n";
895  answerLog << " getDistance2D_driving: " << simulation.getDistance2D(2500, 500, 2000, 500, false, true) << "\n";
896  answerLog << " getDistanceRoad_air: " << simulation.getDistanceRoad("e_m5", 0, "e_m4", 0, false) << "\n";
897  answerLog << " getDistanceRoad_driving: " << simulation.getDistanceRoad("e_m5", 0, "e_m4", 0, true) << "\n";
898  answerLog << " getCurrentTime: " << simulation.getCurrentTime() << "\n";
899  answerLog << " getDeltaT: " << simulation.getDeltaT() << "\n";
900  answerLog << " parkingArea param: " << simulation.getParameter("park1", "parkingArea.capacity") << "\n";
901  answerLog << " busStopWaiting: " << simulation.getBusStopWaiting("bs1") << "\n";
902  answerLog << " busStopWaitingIDs: " << joinToString(simulation.getBusStopWaitingIDList("bs1"), " ") << "\n";
903  simulation.writeMessage("custom message test");
904  answerLog << " subscribe to road and pos of vehicle '1':\n";
905  answerLog << " findRoute: " << joinToString(simulation.findRoute("e_m5", "e_m4").edges, " ") << "\n";
906  std::vector<int> vars;
907  vars.push_back(libsumo::VAR_ROAD_ID);
908  vars.push_back(libsumo::VAR_LANEPOSITION);
909  vehicle.subscribe("1", vars, 0, 100);
910  simulationStep();
911  answerLog << " subscription results:\n";
913  answerLog << " roadID=" << result3[libsumo::VAR_ROAD_ID]->getString() << " pos=" << result3[libsumo::VAR_LANEPOSITION]->getString() << "\n";
914 
915  answerLog << " subscribe to vehicles around edge 'e_u1':\n";
916  std::vector<int> vars2;
917  vars2.push_back(libsumo::VAR_LANEPOSITION);
918  edge.subscribeContext("e_u1", libsumo::CMD_GET_VEHICLE_VARIABLE, 100, vars2, 0, 100);
919  simulationStep();
920  answerLog << " context subscription results:\n";
922  for (libsumo::SubscriptionResults::iterator it = result4.begin(); it != result4.end(); ++it) {
923  answerLog << " vehicle=" << it->first << " pos=" << it->second[libsumo::VAR_LANEPOSITION]->getString() << "\n";
924  }
925 
926  answerLog << " subscribe to vehicles around vehicle '1':\n";
927  std::vector<int> vars3;
928  vars3.push_back(libsumo::VAR_SPEED);
930  vehicle.addSubscriptionFilterLanes(std::vector<int>({0, 1, 2}));
935  vehicle.addSubscriptionFilterLeadFollow(std::vector<int>({0, 1, 2}));
937  vehicle.addSubscriptionFilterVClass(std::vector<std::string>({"passenger"}));
938  vehicle.addSubscriptionFilterVType(std::vector<std::string>({"passenger"}));
940 
943 
946  //
947 
948  simulationStep();
949  answerLog << " context subscription results:\n";
951  for (auto item : result5) {
952  answerLog << " vehicle=" << item.first << "\n";
953  }
954 
955  // person
956  answerLog << " person:\n";
957  person.setWidth("p0", 1);
958  person.setMinGap("p0", 2);
959  person.setLength("p0", 3);
960  person.setHeight("p0", 4);
961  person.setColor("p0", col1);
962  person.setType("p0", "stilts");
963  answerLog << " getIDList: " << joinToString(person.getIDList(), " ") << "\n";
964  answerLog << " getRoadID: " << person.getRoadID("p0") << "\n";
965  answerLog << " getLaneID: " << person.getLaneID("p0") << "\n";
966  answerLog << " getTypeID: " << person.getTypeID("p0") << "\n";
967  answerLog << " getWaitingTime: " << person.getWaitingTime("p0") << "\n";
968  answerLog << " getNextEdge: " << person.getNextEdge("p0") << "\n";
969  answerLog << " getStage: " << person.getStage("p0").description << "\n";
970  answerLog << " getRemainingStages: " << person.getRemainingStages("p0") << "\n";
971  answerLog << " getVehicle: " << person.getVehicle("p0") << "\n";
972  answerLog << " getEdges: " << joinToString(person.getEdges("p0"), " ") << "\n";
973  answerLog << " getPosition: " << person.getPosition("p0").getString() << "\n";
974  answerLog << " getPosition3D: " << person.getPosition3D("p0").getString() << "\n";
975  answerLog << " getAngle: " << person.getAngle("p0") << "\n";
976  answerLog << " getSlope: " << person.getSlope("p0") << "\n";
977  answerLog << " getLanePosition: " << person.getLanePosition("p0") << "\n";
978  answerLog << " getLength: " << person.getLength("p0") << "\n";
979  answerLog << " getColor: " << person.getColor("p0").getString() << "\n";
980  person.setParameter("p0", "foo", "bar");
981  answerLog << " param: " << person.getParameter("p0", "foo") << "\n";
982  person.setSpeed("p0", 3);
983  simulationStep();
984  answerLog << " getSpeed: " << person.getSpeed("p0") << "\n";
985  person.add("p1", "e_u1", 10);
986  std::vector<std::string> walkEdges;
987  walkEdges.push_back("e_u1");
988  walkEdges.push_back("e_shape1");
989  person.appendWalkingStage("p1", walkEdges, -20);
990  person.appendWaitingStage("p1", 5);
991  person.appendDrivingStage("p1", "e_vu2", "BusLine42");
993  stage.edges.push_back("e_vu2");
994  stage.edges.push_back("e_vo2");
995  stage.arrivalPos = -10;
996  person.appendStage("p1", stage);
997  simulationStep();
998  // expect 5 stages due to the initial waiting-for-departure stage
999  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
1000  person.removeStage("p1", 3);
1001  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
1002  person.removeStages("p1");
1003  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
1004  answerLog << " getStage: " << person.getStage("p1").description << "\n";
1005  walkEdges.push_back("e_m5");
1006  person.appendWalkingStage("p1", walkEdges, -20);
1007  simulationStep();
1008  person.rerouteTraveltime("p1");
1009  answerLog << " getEdges after rerouting: " << joinToString(person.getEdges("p1"), " ") << "\n";
1010 
1011  // trafficlights
1012  answerLog << " trafficlights:\n";
1013  trafficlights.setPhase("n_m4", 0);
1014  trafficlights.setPhaseName("n_m4", "nameSetByTraCI");
1015  answerLog << " getIDList: " << joinToString(trafficlights.getIDList(), " ") << "\n";
1016  answerLog << " getIDCount: " << trafficlights.getIDCount() << "\n";
1017  answerLog << " state: " << trafficlights.getRedYellowGreenState("n_m4") << "\n";
1018  answerLog << " program: " << trafficlights.getProgram("n_m4") << "\n";
1019  answerLog << " phase: " << trafficlights.getPhase("n_m4") << "\n";
1020  answerLog << " phaseName: " << trafficlights.getPhaseName("n_m4") << "\n";
1021  answerLog << " phaseDuration: " << trafficlights.getPhaseDuration("n_m4") << "\n";
1022  answerLog << " nextSwitch: " << trafficlights.getNextSwitch("n_m4") << "\n";
1023  answerLog << " controlledLanes: " << joinToString(trafficlights.getControlledLanes("n_m4"), " ") << "\n";
1024  std::vector<std::vector<libsumo::TraCILink> > links = trafficlights.getControlledLinks("n_m4");
1025  answerLog << " controlledLinks:\n";
1026  for (int i = 0; i < (int)links.size(); ++i) {
1027  for (int j = 0; j < (int)links[i].size(); ++j) {
1028  answerLog << " index=" << i << " link=" << j << " fromLane=" << links[i][j].fromLane << " viaLane=" << links[i][j].viaLane << " toLane=" << links[i][j].toLane << "\n";
1029  }
1030  }
1031  libsumo::TraCILogic logic("custom", 0, 3);
1032  logic.phases = std::vector<libsumo::TraCIPhase*>({ new libsumo::TraCIPhase(5, "rrrrrrr", 5, 5),
1033  new libsumo::TraCIPhase(10, "ggggggg", 5, 15),
1034  new libsumo::TraCIPhase(3, "GGGGGGG", 3, 3),
1035  new libsumo::TraCIPhase(3, "yyyyyyy", 3, 3)
1036  });
1037  trafficlights.setProgramLogic("n_m4", logic);
1038 
1039  std::vector<libsumo::TraCILogic> logics = trafficlights.getAllProgramLogics("n_m4");
1040  answerLog << " completeDefinition:\n";
1041  for (int i = 0; i < (int)logics.size(); ++i) {
1042  answerLog << " subID=" << logics[i].programID << " type=" << logics[i].type << " phase=" << logics[i].currentPhaseIndex << "\n";
1043  answerLog << " params=" << joinToString(logics[i].subParameter) << "\n";
1044  for (int j = 0; j < (int)logics[i].phases.size(); ++j) {
1045  answerLog << " phase=" << logics[i].phases[j]->state
1046  << " dur=" << logics[i].phases[j]->duration
1047  << " minDur=" << logics[i].phases[j]->minDur
1048  << " maxDur=" << logics[i].phases[j]->maxDur
1049  << "\n";
1050  }
1051  }
1052  simulationStep();
1053  answerLog << " state=" << trafficlights.getRedYellowGreenState("n_m4") << "\n";
1054  trafficlights.setRedYellowGreenState("n_m4", "gGyruoO");
1055  answerLog << " stateSet=" << trafficlights.getRedYellowGreenState("n_m4") << "\n";
1056  answerLog << " program: " << trafficlights.getProgram("n_m4") << "\n";
1057 
1058  answerLog << " load:\n";
1059  std::vector<std::string> args;
1060  args.push_back("-n");
1061  args.push_back("net.net.xml");
1062  args.push_back("-r");
1063  args.push_back("input_routes.rou.xml");
1064  args.push_back("-a");
1065  args.push_back("input_additional.add.xml");
1066  args.push_back("--no-step-log");
1067  load(args);
1068  simulationStep();
1069  answerLog << " getCurrentTime: " << simulation.getCurrentTime() << "\n";
1070  vehicle.subscribe("0", vars, 0, 100);
1071  edge.subscribeContext("e_u1", libsumo::CMD_GET_VEHICLE_VARIABLE, 100, vars2, 0, 100);
1072 
1073  answerLog << " gui:\n";
1074  try {
1075  answerLog << " setScheme: \n";
1076  gui.setSchema("View #0", "real world");
1077  answerLog << " getScheme: " << gui.getSchema("View #0") << "\n";
1078  gui.setZoom("View #0", 50);
1079  answerLog << " getZoom: " << gui.getZoom() << "\n";
1080  answerLog << " take screenshot: \n";
1081  gui.screenshot("View #0", "image.png", 500, 500);
1082  } catch (libsumo::TraCIException&) {
1083  answerLog << " no support for gui commands\n";
1084  }
1085 }
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:3189
void setLength(const std::string &personID, double length) const
Definition: TraCIAPI.cpp:3378
libsumo::TraCIColor getColor(const std::string &personID) const
Definition: TraCIAPI.cpp:3159
double getSlope(const std::string &personID) const
Definition: TraCIAPI.cpp:3149
int getRemainingStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3200
double getWaitingTime(const std::string &personID) const
Definition: TraCIAPI.cpp:3184
libsumo::TraCIStage getStage(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3205
void removeStage(const std::string &personID, int nextStageIndex) const
Definition: TraCIAPI.cpp:3349
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:3241
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:3311
void setSpeed(const std::string &personID, double speed) const
Definition: TraCIAPI.cpp:3359
double getLength(const std::string &personID) const
Definition: TraCIAPI.cpp:3164
void setHeight(const std::string &personID, double height) const
Definition: TraCIAPI.cpp:3397
void setType(const std::string &personID, const std::string &typeID) const
Definition: TraCIAPI.cpp:3369
void setMinGap(const std::string &personID, double minGap) const
Definition: TraCIAPI.cpp:3406
libsumo::TraCIPosition getPosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3134
void removeStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3221
void setColor(const std::string &personID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:3416
std::string getRoadID(const std::string &personID) const
Definition: TraCIAPI.cpp:3169
double getSpeed(const std::string &personID) const
Definition: TraCIAPI.cpp:3129
std::string getVehicle(const std::string &personID) const
Definition: TraCIAPI.cpp:3195
void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
Definition: TraCIAPI.cpp:3332
std::string getTypeID(const std::string &personID) const
Definition: TraCIAPI.cpp:3179
void appendStage(const std::string &personID, const libsumo::TraCIStage &stage)
Definition: TraCIAPI.cpp:3258
double getAngle(const std::string &personID) const
Definition: TraCIAPI.cpp:3144
std::string getLaneID(const std::string &personID) const
Definition: TraCIAPI.cpp:3174
libsumo::TraCIPosition getPosition3D(const std::string &personID) const
Definition: TraCIAPI.cpp:3139
std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3213
void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: TraCIAPI.cpp:3294
double getLanePosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3154
void setWidth(const std::string &personID, double width) const
Definition: TraCIAPI.cpp:3388
void rerouteTraveltime(const std::string &personID) const
Definition: TraCIAPI.cpp:3231
libsumo::TraCIColor getColor(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1217
libsumo::TraCIPositionVector getShape(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1212
double getLineWidth(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1202
void setLineWidth(const std::string &polygonID, const double lineWidth) const
Definition: TraCIAPI.cpp:1222
void setShape(const std::string &polygonID, const libsumo::TraCIPositionVector &shape) const
Definition: TraCIAPI.cpp:1241
void add(const std::string &routeID, const std::vector< std::string > &edges) const
Definition: TraCIAPI.cpp:1318
double getDistance2D(double x1, double y1, double x2, double y2, bool isGeo=false, bool isDriving=false)
Definition: TraCIAPI.cpp:1507
libsumo::TraCIPosition convert2D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1418
int getBusStopWaiting(const std::string &stopID) const
Definition: TraCIAPI.cpp:1407
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:1549
libsumo::TraCIRoadPosition convertRoad(double x, double y, bool isGeo=false, const std::string &vClass="ignoring") const
Definition: TraCIAPI.cpp:1463
std::vector< std::string > getBusStopWaitingIDList(const std::string &stopID) const
Definition: TraCIAPI.cpp:1412
double getDistanceRoad(const std::string &edgeID1, double pos1, const std::string &edgeID2, double pos2, bool isDriving=false)
Definition: TraCIAPI.cpp:1527
double getDeltaT() const
Definition: TraCIAPI.cpp:1391
void writeMessage(const std::string msg)
Definition: TraCIAPI.cpp:1568
libsumo::TraCIPosition convertGeo(double x, double y, bool fromGeo=false) const
Definition: TraCIAPI.cpp:1486
libsumo::TraCIPosition convert3D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1440
const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3749
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:3629
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:3608
const libsumo::TraCIResults getSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3733
void subscribeContext(const std::string &objID, int domain, double range, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3717
void setParameter(const std::string &objectID, const std::string &key, const std::string &value) const
set generic paramter
Definition: TraCIAPI.cpp:3648
std::string getParameter(const std::string &objectID, const std::string &key) const
retrieve generic parameter
Definition: TraCIAPI.cpp:3620
void subscribe(const std::string &objID, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3705
std::string getRedYellowGreenState(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1581
int getPhase(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1677
std::string getPhaseName(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1682
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
Definition: TraCIAPI.cpp:1707
std::string getProgram(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1672
void setPhase(const std::string &tlsID, int index) const
Definition: TraCIAPI.cpp:1716
void setPhaseName(const std::string &tlsID, const std::string &name) const
Definition: TraCIAPI.cpp:1725
double getNextSwitch(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1692
std::vector< std::vector< libsumo::TraCILink > > getControlledLinks(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1644
double getPhaseDuration(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1687
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1639
std::vector< libsumo::TraCILogic > getAllProgramLogics(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1586
void setProgramLogic(const std::string &tlsID, const libsumo::TraCILogic &logic) const
Definition: TraCIAPI.cpp:1752
std::vector< libsumo::TraCINextTLSData > getNextTLS(const std::string &vehID) const
Definition: TraCIAPI.cpp:2333
double getLateralSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2111
void addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3077
void setMaxSpeed(const std::string &vehicleID, double speed) const
Definition: TraCIAPI.cpp:2902
double getSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2106
int getStopState(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2455
double getWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2290
void addSubscriptionFilterCFManeuver(double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3013
void changeTarget(const std::string &vehicleID, const std::string &edgeID) const
Definition: TraCIAPI.cpp:2652
bool isRouteValid(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2561
double getSecureGap(const std::string &vehicleID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string &leaderID="") const
Definition: TraCIAPI.cpp:2140
void setSpeedFactor(const std::string &vehicleID, double factor) const
Definition: TraCIAPI.cpp:2884
void setShapeClass(const std::string &vehicleID, const std::string &clazz) const
Definition: TraCIAPI.cpp:2962
void setVia(const std::string &vehicleID, const std::vector< std::string > &via) const
Definition: TraCIAPI.cpp:2932
void remove(const std::string &vehicleID, char reason=libsumo::REMOVE_VAPORIZED) const
Definition: TraCIAPI.cpp:2641
void moveTo(const std::string &vehicleID, const std::string &laneID, double position, int reason=libsumo::MOVE_TELEPORT) const
Definition: TraCIAPI.cpp:2742
void setRouteID(const std::string &vehicleID, const std::string &routeID) const
Definition: TraCIAPI.cpp:2702
std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction) const
Definition: TraCIAPI.cpp:2437
std::string getShapeClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2328
void addSubscriptionFilterLeadFollow(const std::vector< int > &lanes) const
Definition: TraCIAPI.cpp:3042
std::string getLine(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2313
void setRoute(const std::string &vehicleID, const std::vector< std::string > &edge) const
Definition: TraCIAPI.cpp:2712
int getSignals(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2240
libsumo::TraCIColor getColor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2225
int getPersonCapacity(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2546
void setSignals(const std::string &vehicleID, int signals) const
Definition: TraCIAPI.cpp:2944
std::string getRoadID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2189
void addSubscriptionFilterVType(const std::vector< std::string > &vTypes) const
Definition: TraCIAPI.cpp:3066
void addSubscriptionFilterUpstreamDistance(double dist) const
Definition: TraCIAPI.cpp:3007
void addSubscriptionFilterLanes(const std::vector< int > &lanes, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:2981
void addSubscriptionFilterNoOpposite() const
Definition: TraCIAPI.cpp:2997
void addSubscriptionFilterLCManeuver(int direction, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3024
std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2401
double getAcceleration(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2116
std::vector< std::string > getVia(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2318
void addSubscriptionFilterVClass(const std::vector< std::string > &vClasses) const
Definition: TraCIAPI.cpp:3060
std::string getLaneID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2194
void addSubscriptionFilterDownstreamDistance(double dist) const
Definition: TraCIAPI.cpp:3002
double getStopDelay(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2465
void setLine(const std::string &vehicleID, const std::string &line) const
Definition: TraCIAPI.cpp:2923
double getSlope(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2307
void setColor(const std::string &vehicleID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:2911
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:2581
void setLaneChangeMode(const std::string &vehicleID, int mode) const
Definition: TraCIAPI.cpp:2833
void setRoutingMode(const std::string &vehicleID, int routingMode) const
Definition: TraCIAPI.cpp:2953
void addSubscriptionFilterTurn(double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3048
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:2757
std::string getRouteID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2209
double getLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2230
int getLaneChangeMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2295
int getSpeedMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2301
std::vector< std::string > getRoute(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2220
double getLateralLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2245
std::pair< std::string, double > getFollower(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2419
double getMaxSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2169
int getRoutingMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2460
double getFollowSpeed(const std::string &vehicleID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string &leaderID="") const
Definition: TraCIAPI.cpp:2121
void setType(const std::string &vehicleID, const std::string &typeID) const
Definition: TraCIAPI.cpp:2875
void addSubscriptionFilterFieldOfVision(double angle) const
Definition: TraCIAPI.cpp:3072
void setSpeedMode(const std::string &vehicleID, int mode) const
Definition: TraCIAPI.cpp:2842
std::string getTypeID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2204
double getAccumulatedWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2531
void rerouteTraveltime(const std::string &vehicleID, bool currentTravelTimes=true) const
Definition: TraCIAPI.cpp:2725
double getStopSpeed(const std::string &vehicleID, double speed, double gap) const
Definition: TraCIAPI.cpp:2156
void setApparentDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2063
void setHeight(const std::string &typeID, double height) const
Definition: TraCIAPI.cpp:1972
double getMinGapLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1871
void copy(const std::string &origTypeID, const std::string &newTypeID) const
Definition: TraCIAPI.cpp:2018
int getPersonCapacity(const std::string &typeID) const
Definition: TraCIAPI.cpp:1886
void setWidth(const std::string &typeID, double width) const
Definition: TraCIAPI.cpp:1963
double getApparentDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1836
void setLateralAlignment(const std::string &typeID, const std::string &latAlignment) const
Definition: TraCIAPI.cpp:2009
double getMaxSpeedLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1876
double getEmergencyDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1831
double getWidth(const std::string &typeID) const
Definition: TraCIAPI.cpp:1891
void setAccel(const std::string &typeID, double accel) const
Definition: TraCIAPI.cpp:2036
double getAccel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1821
double getHeight(const std::string &typeID) const
Definition: TraCIAPI.cpp:1896
void setEmergencyDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2054
void setMaxSpeedLat(const std::string &typeID, double speed) const
Definition: TraCIAPI.cpp:2000
std::string getLateralAlignment(const std::string &typeID) const
Definition: TraCIAPI.cpp:1881
void setMinGapLat(const std::string &typeID, double minGapLat) const
Definition: TraCIAPI.cpp:1991
RouteScope route
Scope for interaction with routes.
Definition: TraCIAPI.h:826
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:836
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:806
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:822
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:931
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:812
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:832
InductionLoopScope inductionloop
Scope for interaction with inductive loops.
Definition: TraCIAPI.h:808
tcpip::Storage myOutput
The reusable output storage.
Definition: TraCIAPI.h:933
POIScope poi
Scope for interaction with POIs.
Definition: TraCIAPI.h:820
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:834
JunctionScope junction
Scope for interaction with junctions.
Definition: TraCIAPI.h:810
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:804
SimulationScope simulation
Scope for interaction with the simulation.
Definition: TraCIAPI.h:830
PersonScope person
Scope for interaction with persons.
Definition: TraCIAPI.h:818
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:316
std::string approachedInternal
Definition: TraCIDefs.h:320
std::vector< TraCIPhase * > phases
Definition: TraCIDefs.h:290
std::string description
arbitrary description string
Definition: TraCIDefs.h:502
std::vector< std::string > edges
The sequence of edges to travel.
Definition: TraCIDefs.h:486
double arrivalPos
position on the lane when ending the stage
Definition: TraCIDefs.h:500
void sendExact(const Storage &)
Definition: socket.cpp:430
virtual std::string readString()
Definition: storage.cpp:175
virtual void writeString(const std::string &s)
Definition: storage.cpp:192
virtual void writeInt(int)
Definition: storage.cpp:316
virtual void writeDouble(double)
Definition: storage.cpp:349
virtual int readUnsignedByte()
Definition: storage.cpp:150
virtual void writeStringList(const std::vector< std::string > &s)
Definition: storage.cpp:242
virtual void writeUnsignedByte(int)
Definition: storage.cpp:160
virtual void writeByte(int)
Definition: storage.cpp:135
virtual int readByte()
Definition: storage.cpp:123
virtual std::vector< std::string > readStringList()
Definition: storage.cpp:206
virtual double readDouble()
Definition: storage.cpp:357
virtual int readInt()
Definition: storage.cpp:306
TRACI_CONST int RESPONSE_SUBSCRIBE_GUI_VARIABLE
TRACI_CONST int TYPE_COLOR
TRACI_CONST int POSITION_3D
TRACI_CONST int POSITION_ROADMAP
std::map< int, std::shared_ptr< TraCIResult > > TraCIResults
{variable->value}
Definition: TraCIDefs.h:248
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, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:250
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
TRACI_CONST int RESPONSE_SUBSCRIBE_GUI_CONTEXT
TRACI_CONST int TYPE_STRING
std::string getString()
Definition: TraCIDefs.h:170
double dist
The distance to the tls.
Definition: TraCIDefs.h:348
int tlIndex
The tls index of the controlled link.
Definition: TraCIDefs.h:346
std::string id
The id of the next tls.
Definition: TraCIDefs.h:344
char state
The current state of the tls.
Definition: TraCIDefs.h:350
std::string getString()
Definition: TraCIDefs.h:142
std::string getString()
Definition: TraCIDefs.h:154
mirrors MSInductLoop::VehicleData
Definition: TraCIDefs.h:328
std::string id
The id of the vehicle.
Definition: TraCIDefs.h:330
double entryTime
Entry-time of the vehicle in [s].
Definition: TraCIDefs.h:334
std::string typeID
Type of the vehicle in.
Definition: TraCIDefs.h:338
double length
Length of the vehicle.
Definition: TraCIDefs.h:332
double leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIDefs.h:336