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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
20 // A test execution class
21 /****************************************************************************/
22 /* =========================================================================
23  * included modules
24  * ======================================================================= */
25 #include <config.h>
26 
27 #include <vector>
28 #include <iostream>
29 #include <iomanip>
30 #include <fstream>
31 #include <sstream>
32 #include <ctime>
33 #include <cstdlib>
34 
35 #define BUILD_TCPIP
36 #include <foreign/tcpip/storage.h>
37 #include <foreign/tcpip/socket.h>
38 
39 #include <libsumo/TraCIConstants.h>
40 #include <libsumo/TraCIDefs.h>
41 #include <utils/common/SUMOTime.h>
42 #include <utils/common/ToString.h>
43 #include "TraCITestClient.h"
44 
45 
46 // ===========================================================================
47 // method definitions
48 // ===========================================================================
49 TraCITestClient::TraCITestClient(std::string outputFileName)
50  : outputFileName(outputFileName), answerLog("") {
51  answerLog.setf(std::ios::fixed, std::ios::floatfield); // use decimal format
52  answerLog.setf(std::ios::showpoint); // print decimal point
53  answerLog << std::setprecision(2);
54 }
55 
56 
58  writeResult();
59 }
60 
61 
62 int
63 TraCITestClient::run(std::string fileName, int port, std::string host) {
64  std::ifstream defFile;
65  std::string fileContentStr;
66  std::stringstream fileContent;
67  std::string lineCommand;
68  std::stringstream msg;
69  int repNo = 1;
70  bool commentRead = false;
71 
72  // try to connect
73  try {
74  TraCIAPI::connect(host, port);
75  } catch (tcpip::SocketException& e) {
76  std::stringstream msg;
77  msg << "#Error while connecting: " << e.what();
78  errorMsg(msg);
79  return 2;
80  }
81 
82  // read definition file and trigger commands according to it
83  defFile.open(fileName.c_str());
84  if (!defFile) {
85  msg << "Can not open definition file " << fileName << std::endl;
86  errorMsg(msg);
87  return 1;
88  }
89  defFile.unsetf(std::ios::dec);
90 
91  while (defFile >> lineCommand) {
92  repNo = 1;
93  if (lineCommand.compare("%") == 0) {
94  // a comment was read
95  commentRead = !commentRead;
96  continue;
97  }
98  if (commentRead) {
99  // wait until end of comment is reached
100  continue;
101  }
102  if (lineCommand.compare("repeat") == 0) {
103  defFile >> repNo;
104  defFile >> lineCommand;
105  }
106  if (lineCommand.compare("simstep2") == 0) {
107  // read parameter for command simulation step and trigger command
108  double time;
109  defFile >> time;
110  for (int i = 0; i < repNo; i++) {
111  commandSimulationStep(time);
112  }
113  } else if (lineCommand.compare("getvariable") == 0) {
114  // trigger command GetXXXVariable
115  int domID, varID;
116  std::string objID;
117  defFile >> domID >> varID >> objID;
118  commandGetVariable(domID, varID, objID);
119  } else if (lineCommand.compare("getvariable_plus") == 0) {
120  // trigger command GetXXXVariable with one parameter
121  int domID, varID;
122  std::string objID;
123  defFile >> domID >> varID >> objID;
124  std::stringstream msg;
125  tcpip::Storage tmp;
126  setValueTypeDependant(tmp, defFile, msg);
127  std::string msgS = msg.str();
128  if (msgS != "") {
129  errorMsg(msg);
130  }
131  commandGetVariable(domID, varID, objID, &tmp);
132  } else if (lineCommand.compare("subscribevariable") == 0) {
133  // trigger command SubscribeXXXVariable
134  int domID, varNo;
135  double beginTime, endTime;
136  std::string objID;
137  defFile >> domID >> objID >> beginTime >> endTime >> varNo;
138  commandSubscribeObjectVariable(domID, objID, beginTime, endTime, varNo, defFile);
139  } else if (lineCommand.compare("subscribecontext") == 0) {
140  // trigger command SubscribeXXXVariable
141  int domID, varNo, domain;
142  double range;
143  double beginTime, endTime;
144  std::string objID;
145  defFile >> domID >> objID >> beginTime >> endTime >> domain >> range >> varNo;
146  commandSubscribeContextVariable(domID, objID, beginTime, endTime, domain, range, varNo, defFile);
147  } else if (lineCommand.compare("setvalue") == 0) {
148  // trigger command SetXXXValue
149  int domID, varID;
150  std::string objID;
151  defFile >> domID >> varID >> objID;
152  commandSetValue(domID, varID, objID, defFile);
153  } else if (lineCommand.compare("testAPI") == 0) {
154  // call all native API methods
155  testAPI();
156  } else if (lineCommand.compare("setorder") == 0) {
157  // call setOrder
158  int order;
159  defFile >> order;
160  commandSetOrder(order);
161  } else {
162  msg << "Error in definition file: " << lineCommand << " is not a valid command";
163  errorMsg(msg);
164  commandClose();
165  closeSocket();
166  return 1;
167  }
168  }
169  defFile.close();
170  commandClose();
171  closeSocket();
172  return 0;
173 }
174 
175 
176 // ---------- Commands handling
177 void
179  try {
181  answerLog << std::endl << "-> Command sent: <SimulationStep>:" << std::endl;
182  tcpip::Storage inMsg;
183  std::string acknowledgement;
184  check_resultState(inMsg, libsumo::CMD_SIMSTEP, false, &acknowledgement);
185  answerLog << acknowledgement << std::endl;
187  } catch (libsumo::TraCIException& e) {
188  answerLog << e.what() << std::endl;
189  }
190 }
191 
192 
193 void
195  try {
197  answerLog << std::endl << "-> Command sent: <Close>:" << std::endl;
198  tcpip::Storage inMsg;
199  std::string acknowledgement;
200  check_resultState(inMsg, libsumo::CMD_CLOSE, false, &acknowledgement);
201  answerLog << acknowledgement << std::endl;
202  } catch (libsumo::TraCIException& e) {
203  answerLog << e.what() << std::endl;
204  }
205 }
206 
207 
208 void
210  try {
211  send_commandSetOrder(order);
212  answerLog << std::endl << "-> Command sent: <SetOrder>:" << std::endl;
213  tcpip::Storage inMsg;
214  std::string acknowledgement;
215  check_resultState(inMsg, libsumo::CMD_SETORDER, false, &acknowledgement);
216  answerLog << acknowledgement << std::endl;
217  } catch (libsumo::TraCIException& e) {
218  answerLog << e.what() << std::endl;
219  }
220 }
221 
222 
223 void
224 TraCITestClient::commandGetVariable(int domID, int varID, const std::string& objID, tcpip::Storage* addData) {
225  tcpip::Storage inMsg;
226  try {
227  createCommand(domID, varID, objID, addData);
229  answerLog << std::endl << "-> Command sent: <GetVariable>:" << std::endl
230  << " domID=" << domID << " varID=" << varID
231  << " objID=" << objID << std::endl;
232  std::string acknowledgement;
233  check_resultState(inMsg, domID, false, &acknowledgement);
234  answerLog << acknowledgement << std::endl;
235  } catch (libsumo::TraCIException& e) {
236  answerLog << e.what() << std::endl;
237  return;
238  }
239  check_commandGetResult(inMsg, domID, -1, false);
240  // report result state
241  try {
242  int variableID = inMsg.readUnsignedByte();
243  std::string objectID = inMsg.readString();
244  answerLog << " CommandID=" << (domID + 0x10) << " VariableID=" << variableID << " ObjectID=" << objectID;
245  int valueDataType = inMsg.readUnsignedByte();
246  answerLog << " valueDataType=" << valueDataType;
247  readAndReportTypeDependent(inMsg, valueDataType);
248  } catch (libsumo::TraCIException& e) {
249  std::stringstream msg;
250  msg << "Error while receiving command: " << e.what();
251  errorMsg(msg);
252  return;
253  }
254 }
255 
256 
257 void
258 TraCITestClient::commandSetValue(int domID, int varID, const std::string& objID, std::ifstream& defFile) {
259  std::stringstream msg;
260  tcpip::Storage inMsg, tmp;
261  setValueTypeDependant(tmp, defFile, msg);
262  std::string msgS = msg.str();
263  if (msgS != "") {
264  errorMsg(msg);
265  }
266  createCommand(domID, varID, objID, &tmp);
268  answerLog << std::endl << "-> Command sent: <SetValue>:" << std::endl
269  << " domID=" << domID << " varID=" << varID
270  << " objID=" << objID << std::endl;
271  try {
272  std::string acknowledgement;
273  check_resultState(inMsg, domID, false, &acknowledgement);
274  answerLog << acknowledgement << std::endl;
275  } catch (libsumo::TraCIException& e) {
276  answerLog << e.what() << std::endl;
277  }
278 }
279 
280 
281 void
282 TraCITestClient::commandSubscribeObjectVariable(int domID, const std::string& objID, double beginTime, double endTime, int varNo, std::ifstream& defFile) {
283  std::vector<int> vars;
284  for (int i = 0; i < varNo; ++i) {
285  int var;
286  defFile >> var;
287  // variable id
288  vars.push_back(var);
289  }
290  send_commandSubscribeObjectVariable(domID, objID, beginTime, endTime, vars);
291  answerLog << std::endl << "-> Command sent: <SubscribeVariable>:" << std::endl
292  << " domID=" << domID << " objID=" << objID << " with " << varNo << " variables" << std::endl;
293  tcpip::Storage inMsg;
294  try {
295  std::string acknowledgement;
296  check_resultState(inMsg, domID, false, &acknowledgement);
297  answerLog << acknowledgement << std::endl;
298  validateSubscription(inMsg);
299  } catch (libsumo::TraCIException& e) {
300  answerLog << e.what() << std::endl;
301  }
302 }
303 
304 
305 void
306 TraCITestClient::commandSubscribeContextVariable(int domID, const std::string& objID, double beginTime, double endTime,
307  int domain, double range, int varNo, std::ifstream& defFile) {
308  std::vector<int> vars;
309  for (int i = 0; i < varNo; ++i) {
310  int var;
311  defFile >> var;
312  // variable id
313  vars.push_back(var);
314  }
315  send_commandSubscribeObjectContext(domID, objID, beginTime, endTime, domain, range, vars);
316  answerLog << std::endl << "-> Command sent: <SubscribeContext>:" << std::endl
317  << " domID=" << domID << " objID=" << objID << " domain=" << domain << " range=" << range
318  << " with " << varNo << " variables" << std::endl;
319  tcpip::Storage inMsg;
320  try {
321  std::string acknowledgement;
322  check_resultState(inMsg, domID, false, &acknowledgement);
323  answerLog << acknowledgement << std::endl;
324  validateSubscription(inMsg);
325  } catch (libsumo::TraCIException& e) {
326  answerLog << e.what() << std::endl;
327  }
328 }
329 
330 
331 // ---------- Report helper
332 void
334  time_t seconds;
335  tm* locTime;
336  std::ofstream outFile(outputFileName.c_str());
337  if (!outFile) {
338  std::cerr << "Unable to write result file" << std::endl;
339  }
340  time(&seconds);
341  locTime = localtime(&seconds);
342  outFile << "TraCITestClient output file. Date: " << asctime(locTime) << std::endl;
343  outFile << answerLog.str();
344  outFile.close();
345 }
346 
347 
348 void
349 TraCITestClient::errorMsg(std::stringstream& msg) {
350  std::cerr << msg.str() << std::endl;
351  answerLog << "----" << std::endl << msg.str() << std::endl;
352 }
353 
354 
355 
356 
357 
358 
359 bool
361  try {
362  int noSubscriptions = inMsg.readInt();
363  for (int s = 0; s < noSubscriptions; ++s) {
364  if (!validateSubscription(inMsg)) {
365  return false;
366  }
367  }
368  } catch (std::invalid_argument& e) {
369  answerLog << "#Error while reading message:" << e.what() << std::endl;
370  return false;
371  }
372  return true;
373 }
374 
375 
376 bool
378  try {
379  int length = inMsg.readUnsignedByte();
380  if (length == 0) {
381  length = inMsg.readInt();
382  }
383  int cmdId = inMsg.readUnsignedByte();
385  answerLog << " CommandID=" << cmdId;
386  answerLog << " ObjectID=" << inMsg.readString();
387  int varNo = inMsg.readUnsignedByte();
388  answerLog << " #variables=" << varNo << std::endl;
389  for (int i = 0; i < varNo; ++i) {
390  answerLog << " VariableID=" << inMsg.readUnsignedByte();
391  bool ok = inMsg.readUnsignedByte() == libsumo::RTYPE_OK;
392  answerLog << " ok=" << ok;
393  int valueDataType = inMsg.readUnsignedByte();
394  answerLog << " valueDataType=" << valueDataType;
395  readAndReportTypeDependent(inMsg, valueDataType);
396  }
398  answerLog << " CommandID=" << cmdId;
399  answerLog << " ObjectID=" << inMsg.readString();
400  answerLog << " Domain=" << inMsg.readUnsignedByte();
401  int varNo = inMsg.readUnsignedByte();
402  answerLog << " #variables=" << varNo << std::endl;
403  int objNo = inMsg.readInt();
404  answerLog << " #objects=" << objNo << std::endl;
405  for (int j = 0; j < objNo; ++j) {
406  answerLog << " ObjectID=" << inMsg.readString() << std::endl;
407  for (int i = 0; i < varNo; ++i) {
408  answerLog << " VariableID=" << inMsg.readUnsignedByte();
409  bool ok = inMsg.readUnsignedByte() == libsumo::RTYPE_OK;
410  answerLog << " ok=" << ok;
411  int valueDataType = inMsg.readUnsignedByte();
412  answerLog << " valueDataType=" << valueDataType;
413  readAndReportTypeDependent(inMsg, valueDataType);
414  }
415  }
416  } else {
417  answerLog << "#Error: received response with command id: " << cmdId << " but expected a subscription response (0xe0-0xef / 0x90-0x9f)" << std::endl;
418  return false;
419  }
420  } catch (std::invalid_argument& e) {
421  answerLog << "#Error while reading message:" << e.what() << std::endl;
422  return false;
423  }
424  return true;
425 }
426 
427 
428 
429 
430 
431 
432 
433 // ---------- Conversion helper
434 int
435 TraCITestClient::setValueTypeDependant(tcpip::Storage& into, std::ifstream& defFile, std::stringstream& msg) {
436  std::string dataTypeS;
437  defFile >> dataTypeS;
438  if (dataTypeS == "<airDist>") {
440  return 1;
441  } else if (dataTypeS == "<drivingDist>") {
443  return 1;
444  } else if (dataTypeS == "<objSubscription>") {
445  int beginTime, endTime, numVars;
446  defFile >> beginTime >> endTime >> numVars;
447  into.writeInt(beginTime);
448  into.writeInt(endTime);
449  into.writeInt(numVars);
450  for (int i = 0; i < numVars; ++i) {
451  int var;
452  defFile >> var;
453  into.writeUnsignedByte(var);
454  }
455  return 4 + 4 + 4 + numVars;
456  }
457  int valI;
458  double valF;
459  if (dataTypeS == "<int>") {
460  defFile >> valI;
462  into.writeInt(valI);
463  return 4 + 1;
464  } else if (dataTypeS == "<byte>") {
465  defFile >> valI;
467  into.writeByte(valI);
468  return 1 + 1;
469  } else if (dataTypeS == "<ubyte>") {
470  defFile >> valI;
472  into.writeUnsignedByte(valI);
473  return 1 + 1;
474  } else if (dataTypeS == "<double>") {
475  defFile >> valF;
477  into.writeDouble(valF);
478  return 8 + 1;
479  } else if (dataTypeS == "<string>") {
480  std::string valueS;
481  defFile >> valueS;
482  if (valueS == "\"\"") {
483  valueS = "";
484  }
486  into.writeString(valueS);
487  return 4 + 1 + (int) valueS.length();
488  } else if (dataTypeS == "<string*>") {
489  std::vector<std::string> slValue;
490  defFile >> valI;
491  int length = 1 + 4;
492  for (int i = 0; i < valI; ++i) {
493  std::string tmp;
494  defFile >> tmp;
495  slValue.push_back(tmp);
496  length += 4 + int(tmp.length());
497  }
499  into.writeStringList(slValue);
500  return length;
501  } else if (dataTypeS == "<compound>") {
502  defFile >> valI;
504  into.writeInt(valI);
505  int length = 1 + 4;
506  for (int i = 0; i < valI; ++i) {
507  length += setValueTypeDependant(into, defFile, msg);
508  }
509  return length;
510  } else if (dataTypeS == "<color>") {
511  defFile >> valI;
513  into.writeUnsignedByte(valI);
514  for (int i = 0; i < 3; ++i) {
515  defFile >> valI;
516  into.writeUnsignedByte(valI);
517  }
518  return 1 + 4;
519  } else if (dataTypeS == "<position2D>") {
520  defFile >> valF;
522  into.writeDouble(valF);
523  defFile >> valF;
524  into.writeDouble(valF);
525  return 1 + 8 + 8;
526  } else if (dataTypeS == "<position3D>") {
527  defFile >> valF;
529  into.writeDouble(valF);
530  defFile >> valF;
531  into.writeDouble(valF);
532  defFile >> valF;
533  into.writeDouble(valF);
534  return 1 + 8 + 8 + 8;
535  } else if (dataTypeS == "<positionRoadmap>") {
536  std::string valueS;
537  defFile >> valueS;
539  into.writeString(valueS);
540  int length = 1 + 8 + (int) valueS.length();
541  defFile >> valF;
542  into.writeDouble(valF);
543  defFile >> valI;
544  into.writeUnsignedByte(valI);
545  return length + 4 + 1;
546  } else if (dataTypeS == "<shape>") {
547  defFile >> valI;
549  into.writeUnsignedByte(valI);
550  int length = 1 + 1;
551  for (int i = 0; i < valI; ++i) {
552  double x, y;
553  defFile >> x >> y;
554  into.writeDouble(x);
555  into.writeDouble(y);
556  length += 8 + 8;
557  }
558  return length;
559  }
560  msg << "## Unknown data type: " << dataTypeS;
561  return 0;
562 }
563 
564 
565 void
567  if (valueDataType == libsumo::TYPE_UBYTE) {
568  int ubyte = inMsg.readUnsignedByte();
569  answerLog << " Unsigned Byte Value: " << ubyte << std::endl;
570  } else if (valueDataType == libsumo::TYPE_BYTE) {
571  int byte = inMsg.readByte();
572  answerLog << " Byte value: " << byte << std::endl;
573  } else if (valueDataType == libsumo::TYPE_INTEGER) {
574  int integer = inMsg.readInt();
575  answerLog << " Int value: " << integer << std::endl;
576  } else if (valueDataType == libsumo::TYPE_DOUBLE) {
577  double doublev = inMsg.readDouble();
578  answerLog << " Double value: " << doublev << std::endl;
579  } else if (valueDataType == libsumo::TYPE_POLYGON) {
580  int size = inMsg.readUnsignedByte();
581  if (size == 0) {
582  size = inMsg.readInt();
583  }
584  answerLog << " PolygonValue: ";
585  for (int i = 0; i < size; i++) {
586  double x = inMsg.readDouble();
587  double y = inMsg.readDouble();
588  answerLog << "(" << x << "," << y << ") ";
589  }
590  answerLog << std::endl;
591  } else if (valueDataType == libsumo::POSITION_3D) {
592  double x = inMsg.readDouble();
593  double y = inMsg.readDouble();
594  double z = inMsg.readDouble();
595  answerLog << " Position3DValue: " << std::endl;
596  answerLog << " x: " << x << " y: " << y
597  << " z: " << z << std::endl;
598  } else if (valueDataType == libsumo::POSITION_ROADMAP) {
599  std::string roadId = inMsg.readString();
600  double pos = inMsg.readDouble();
601  int laneId = inMsg.readUnsignedByte();
602  answerLog << " RoadMapPositionValue: roadId=" << roadId
603  << " pos=" << pos
604  << " laneId=" << laneId << std::endl;
605  } else if (valueDataType == libsumo::TYPE_STRING) {
606  std::string s = inMsg.readString();
607  answerLog << " string value: " << s << std::endl;
608  } else if (valueDataType == libsumo::TYPE_STRINGLIST) {
609  std::vector<std::string> s = inMsg.readStringList();
610  answerLog << " string list value: [ " << std::endl;
611  for (std::vector<std::string>::iterator i = s.begin(); i != s.end(); ++i) {
612  if (i != s.begin()) {
613  answerLog << ", ";
614  }
615  answerLog << '"' << *i << '"';
616  }
617  answerLog << " ]" << std::endl;
618  } else if (valueDataType == libsumo::TYPE_COMPOUND) {
619  int no = inMsg.readInt();
620  answerLog << " compound value with " << no << " members: [ " << std::endl;
621  for (int i = 0; i < no; ++i) {
622  int currentValueDataType = inMsg.readUnsignedByte();
623  answerLog << " valueDataType=" << currentValueDataType;
624  readAndReportTypeDependent(inMsg, currentValueDataType);
625  }
626  answerLog << " ]" << std::endl;
627  } else if (valueDataType == libsumo::POSITION_2D) {
628  double xv = inMsg.readDouble();
629  double yv = inMsg.readDouble();
630  answerLog << " position value: (" << xv << "," << yv << ")" << std::endl;
631  } else if (valueDataType == libsumo::TYPE_COLOR) {
632  int r = inMsg.readUnsignedByte();
633  int g = inMsg.readUnsignedByte();
634  int b = inMsg.readUnsignedByte();
635  int a = inMsg.readUnsignedByte();
636  answerLog << " color value: (" << r << "," << g << "," << b << "," << a << ")" << std::endl;
637  } else {
638  answerLog << "#Error: unknown valueDataType!" << std::endl;
639  }
640 }
641 
642 
643 void
645  answerLog << "testAPI:\n";
646  answerLog << " setOrder:\n";
647  setOrder(0);
648  // edge
649  answerLog << " edge:\n";
650  answerLog << " getIDList: " << joinToString(edge.getIDList(), " ") << "\n";
651  answerLog << " getIDCount: " << edge.getIDCount() << "\n";
652  const std::string edgeID = "e_m0";
653  edge.adaptTraveltime(edgeID, 42, 0, 10);
654  edge.setEffort(edgeID, 420, 0, 10);
655  answerLog << " currentTraveltime: " << edge.getTraveltime(edgeID) << "\n";
656  answerLog << " adaptedTravelTime: " << edge.getAdaptedTraveltime(edgeID, 0) << "\n";
657  answerLog << " effort: " << edge.getEffort(edgeID, 0) << "\n";
658  answerLog << " laneNumber: " << edge.getLaneNumber(edgeID) << "\n";
659  answerLog << " streetName: " << edge.getStreetName(edgeID) << "\n";
660 
661  // lane
662  answerLog << " lane:\n";
663  answerLog << " getIDList: " << joinToString(lane.getIDList(), " ") << "\n";
664  answerLog << " getIDCount: " << lane.getIDCount() << "\n";
665  const std::string laneID = "e_m6_0";
666  answerLog << " getLinkNumber: " << lane.getLinkNumber(laneID) << "\n";
667  std::vector<libsumo::TraCIConnection> connections = lane.getLinks(laneID);
668  answerLog << " getLinks:\n";
669  for (int i = 0; i < (int)connections.size(); ++i) {
670  const libsumo::TraCIConnection& c = connections[i];
671  answerLog << " approachedLane=" << c.approachedLane
672  << " hasPrio=" << c.hasPrio
673  << " isOpen=" << c.isOpen
674  << " hasFoe=" << c.hasFoe
675  << " approachedInternal=" << c.approachedInternal
676  << " state=" << c.state
677  << " direction=" << c.direction
678  << " length=" << c.length
679  << "\n";
680  }
681  answerLog << " getFoes: " << joinToString(lane.getFoes("e_vu0_0", "e_m4_0"), " ") << "\n";
682  try {
683  answerLog << " getFoes (invalid): ";
684  answerLog << joinToString(lane.getFoes("e_vu0_0", "e_m4_1"), " ") << "\n";
685  } catch (libsumo::TraCIException& e) {
686  answerLog << " caught TraCIException(" << e.what() << ")\n";
687  }
688  answerLog << " getInternalFoes: " << joinToString(lane.getInternalFoes(":n_m4_2_0"), " ") << "\n";
689  try {
690  answerLog << " getInternalFoes (invalid): ";
691  answerLog << joinToString(lane.getInternalFoes("dummy"), " ") << "\n";
692  } catch (libsumo::TraCIException& e) {
693  answerLog << " caught TraCIException(" << e.what() << ")\n";
694  }
695  // poi
696  answerLog << " POI:\n";
697  answerLog << " getIDList: " << joinToString(poi.getIDList(), " ") << "\n";
698  answerLog << " getIDCount: " << poi.getIDCount() << "\n";
699  answerLog << " getPosition: " << poi.getPosition("poi0").getString() << "\n";
700  answerLog << " getColor: " << poi.getColor("poi0").getString() << "\n";
701 
702  // poly
703  answerLog << " polygon:\n";
704  answerLog << " getIDList: " << joinToString(polygon.getIDList(), " ") << "\n";
705  answerLog << " getIDCount: " << polygon.getIDCount() << "\n";
706  std::vector<libsumo::TraCIPosition> shape = polygon.getShape("poly0");
707  std::string shapeStr;
708  for (auto pos : shape) {
709  shapeStr += pos.getString() + " ";
710  }
711  polygon.setLineWidth("poly0", 0.6);
712  answerLog << " getLineWidth: " << polygon.getLineWidth("poly0") << "\n";
713  answerLog << " getShape: " << shapeStr << "\n";
714  answerLog << " getColor: " << polygon.getColor("poly0").getString() << "\n";
715  shape[0].x = 42;
716  polygon.setShape("poly0", shape);
717  std::string shapeStr2;
718  for (auto pos : polygon.getShape("poly0")) {
719  shapeStr2 += pos.getString() + " ";
720  }
721  answerLog << " getShape after modification: " << shapeStr2 << "\n";
722 
723  // junction
724  answerLog << " junction:\n";
725  answerLog << " getIDList: " << joinToString(junction.getIDList(), " ") << "\n";
726  answerLog << " getIDCount: " << junction.getIDCount() << "\n";
727  std::vector<libsumo::TraCIPosition> junctionShape = junction.getShape("n_m4");
728  std::string junctionShapeStr;
729  for (auto pos : junctionShape) {
730  junctionShapeStr += pos.getString() + " ";
731  }
732  answerLog << " getShape: " << junctionShapeStr << "\n";
733 
734  // route
735  answerLog << " route:\n";
736  answerLog << " add:\n";
737  std::vector<std::string> edges;
738  edges.push_back("e_u1");
739  edges.push_back("e_u0");
740  route.add("e_u1", edges);
741  edges.clear();
742  edges.push_back("e_m4");
743  route.add("e_m4", edges);
744  answerLog << " getIDList: " << joinToString(route.getIDList(), " ") << "\n";
745 
746  // vehicletype
747  answerLog << " vehicleType:\n";
748  answerLog << " getIDList: " << joinToString(vehicletype.getIDList(), " ") << "\n";
749  vehicletype.setEmergencyDecel("t1", 9.9);
750  answerLog << " getEmergencyDecel: " << vehicletype.getEmergencyDecel("t1") << "\n";
751  vehicletype.setApparentDecel("t1", 99.9);
752  answerLog << " getApparentDecel: " << vehicletype.getApparentDecel("t1") << "\n";
753  vehicletype.setWidth("t1", 1.9);
754  answerLog << " getWidth: " << vehicletype.getWidth("t1") << "\n";
755  vehicletype.setHeight("t1", 1.8);
756  answerLog << " getHeight: " << vehicletype.getHeight("t1") << "\n";
757  vehicletype.setMinGapLat("t1", 1.5);
758  answerLog << " setMinGapLat: " << vehicletype.getMinGapLat("t1") << "\n";
759  vehicletype.setMaxSpeedLat("t1", 1.2);
760  answerLog << " setMaxSpeedLat: " << vehicletype.getMaxSpeedLat("t1") << "\n";
761  vehicletype.setLateralAlignment("t1", "compact");
762  answerLog << " getLateralAlignment: " << vehicletype.getLateralAlignment("t1") << "\n";
763  answerLog << " getPersonCapacity: " << vehicletype.getPersonCapacity("t1") << "\n";
764  answerLog << " copy type 't1' to 't1_copy' and set accel to 100.\n";
765  vehicletype.copy("t1", "t1_copy");
766  answerLog << " getIDList: " << joinToString(vehicletype.getIDList(), " ") << "\n";
767  vehicletype.setAccel("t1_copy", 100.);
768  answerLog << " getAccel('t1'): " << vehicletype.getAccel("t1") << "\n";
769  answerLog << " getAccel('t1_copy'): " << vehicletype.getAccel("t1_copy") << "\n";
770 
771  // vehicle
772  answerLog << " vehicle:\n";
773  vehicle.setLine("0", "S42");
774  std::vector<std::string> via;
775  via.push_back("e_shape1");
776  vehicle.setVia("0", via);
777  vehicle.setType("0", "t1_copy");
778  answerLog << " getTypeID: " << vehicle.getTypeID("0") << "\n";
779  answerLog << " getRoadID: " << vehicle.getRoadID("0") << "\n";
780  answerLog << " getRouteID: " << vehicle.getRouteID("0") << "\n";
781  answerLog << " getLaneID: " << vehicle.getLaneID("0") << "\n";
782  answerLog << " getLanePosition: " << vehicle.getLanePosition("0") << "\n";
783  answerLog << " getLateralLanePosition: " << vehicle.getLateralLanePosition("0") << "\n";
784  answerLog << " getSpeed: " << vehicle.getSpeed("0") << "\n";
785  answerLog << " getLateralSpeed: " << vehicle.getLateralSpeed("0") << "\n";
786  answerLog << " getAcceleration: " << vehicle.getAcceleration("0") << "\n";
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  vehicle.setParameter("0", "meaningOfLife", "42");
797  answerLog << " param: " << vehicle.getParameter("0", "meaningOfLife") << "\n";
798  libsumo::TraCIColor col1;
799  col1.r = 255;
800  col1.g = 255;
801  col1.b = 0;
802  col1.a = 128;
803  vehicle.setColor("0", col1);
805  answerLog << " getColor: r=" << (int)col2.r << " g=" << (int)col2.g << " b=" << (int)col2.b << " a=" << (int)col2.a << "\n";
806  int signals = vehicle.getSignals("0");
807  answerLog << " getSignals: " << signals << "\n";
810  answerLog << " getRoutingMode: " << vehicle.getRoutingMode("0") << "\n";
811  answerLog << " getNextTLS:\n";
812  std::vector<libsumo::TraCINextTLSData> result = vehicle.getNextTLS("0");
813  for (int i = 0; i < (int)result.size(); ++i) {
814  const libsumo::TraCINextTLSData& d = result[i];
815  answerLog << " tls=" << d.id << " tlIndex=" << d.tlIndex << " dist=" << d.dist << " state=" << d.state << "\n";
816  }
817  answerLog << " moveToXY, simStep:\n";
818  vehicle.moveToXY("0", "dummy", 0, 2231.61, 498.29, 90, 1);
819  simulationStep();
820  answerLog << " getRoadID: " << vehicle.getRoadID("0") << "\n";
821  answerLog << " getLaneID: " << vehicle.getLaneID("0") << "\n";
822  vehicle.changeTarget("0", "e_o0");
823  std::vector<std::string> edges2 = vehicle.getRoute("0");
824  answerLog << " edges: " << joinToString(edges2, " ") << "\n";
825  vehicle.setRouteID("0", "e_m4");
826  answerLog << " edges: " << joinToString(vehicle.getRoute("0"), " ") << "\n";
827  vehicle.setRoute("0", edges2);
828  answerLog << " edges: " << joinToString(vehicle.getRoute("0"), " ") << "\n";
829  answerLog << " add:\n";
830  vehicle.add("1", "e_u1");
831  vehicle.add("2", "e_u1");
832  vehicle.moveTo("2", "e_u0_0", 5);
833  simulationStep();
834  answerLog << " getIDList: " << joinToString(vehicle.getIDList(), " ") << "\n";
835  answerLog << " getWaitingTime: " << vehicle.getWaitingTime("0") << "\n";
836  answerLog << " getAccumulatedWaitingTime: " << vehicle.getAccumulatedWaitingTime("0") << "\n";
837  vehicle.setShapeClass("0", "bicycle");
838  answerLog << " getShapeClass: " << vehicle.getShapeClass("0") << "\n";
839  std::pair<std::string, double> leader = vehicle.getLeader("1", 1000);
840  answerLog << " getLeader: " << leader.first << ", " << leader.second << "\n";
841  std::pair<int, int> state = vehicle.getLaneChangeState("1", 1);
842  answerLog << " getLaneChangeState (left): " << state.first << ", " << state.second << "\n";
843  state = vehicle.getLaneChangeState("1", -1);
844  answerLog << " getLaneChangeState (right): " << state.first << ", " << state.second << "\n";
846  vehicle.setSpeedFactor("0", 0.8);
847  answerLog << " remove:\n";
848  vehicle.remove("0");
849  answerLog << " getIDCount: " << vehicle.getIDCount() << "\n";
850 
851  // inductionLoop
852  answerLog << " inductionloop:\n";
853  answerLog << " getIDList: " << joinToString(inductionloop.getIDList(), " ") << "\n";
854  answerLog << " getVehicleData:\n";
855  std::vector<libsumo::TraCIVehicleData> result2 = inductionloop.getVehicleData("det1");
856  for (int i = 0; i < (int)result2.size(); ++i) {
857  const libsumo::TraCIVehicleData& vd = result2[i];
858  answerLog << " veh=" << vd.id << " length=" << vd.length << " entered=" << vd.entryTime << " left=" << vd.leaveTime << " type=" << vd.typeID << "\n";
859  }
860 
861  // simulation
862  answerLog << " simulation:\n";
863  answerLog << " convert2D: " << simulation.convert2D("e_m5", 0).getString() << "\n";
864  answerLog << " convert2DGeo: " << simulation.convert2D("e_m5", 0, 0, true).getString() << "\n";
865  answerLog << " convert3D: " << simulation.convert3D("e_m5", 0).getString() << "\n";
866  answerLog << " convert3DGeo: " << simulation.convert3D("e_m5", 0, 0, true).getString() << "\n";
867  answerLog << " convertRoad: " << simulation.convertRoad(2500, 500).getString() << "\n";
868  answerLog << " convertRoadBus: " << simulation.convertRoad(2500, 500, false, "bus").getString() << "\n";
869  answerLog << " convertGeo: " << simulation.convertGeo(2500, 500).getString() << "\n";
870  answerLog << " convertCartesian: " << simulation.convertGeo(12, 52, true).getString() << "\n";
871  answerLog << " getDistance2D_air: " << simulation.getDistance2D(2500, 500, 2000, 500, false, false) << "\n";
872  answerLog << " getDistance2D_driving: " << simulation.getDistance2D(2500, 500, 2000, 500, false, true) << "\n";
873  answerLog << " getDistanceRoad_air: " << simulation.getDistanceRoad("e_m5", 0, "e_m4", 0, false) << "\n";
874  answerLog << " getDistanceRoad_driving: " << simulation.getDistanceRoad("e_m5", 0, "e_m4", 0, true) << "\n";
875  answerLog << " getCurrentTime: " << simulation.getCurrentTime() << "\n";
876  answerLog << " getDeltaT: " << simulation.getDeltaT() << "\n";
877  answerLog << " parkingArea param: " << simulation.getParameter("park1", "parkingArea.capacity") << "\n";
878  answerLog << " busStopWaiting: " << simulation.getBusStopWaiting("bs1") << "\n";
879  answerLog << " busStopWaitingIDs: " << joinToString(simulation.getBusStopWaitingIDList("bs1"), " ") << "\n";
880  answerLog << " subscribe to road and pos of vehicle '1':\n";
881  std::vector<int> vars;
882  vars.push_back(libsumo::VAR_ROAD_ID);
883  vars.push_back(libsumo::VAR_LANEPOSITION);
884  vehicle.subscribe("1", vars, 0, 100);
885  simulationStep();
886  answerLog << " subscription results:\n";
888  answerLog << " roadID=" << result3[libsumo::VAR_ROAD_ID]->getString() << " pos=" << result3[libsumo::VAR_LANEPOSITION]->getString() << "\n";
889 
890  answerLog << " subscribe to vehicles around edge 'e_u1':\n";
891  std::vector<int> vars2;
892  vars2.push_back(libsumo::VAR_LANEPOSITION);
893  edge.subscribeContext("e_u1", libsumo::CMD_GET_VEHICLE_VARIABLE, 100, vars2, 0, 100);
894  simulationStep();
895  answerLog << " context subscription results:\n";
897  for (libsumo::SubscriptionResults::iterator it = result4.begin(); it != result4.end(); ++it) {
898  answerLog << " vehicle=" << it->first << " pos=" << it->second[libsumo::VAR_LANEPOSITION]->getString() << "\n";
899  }
900 
901  answerLog << " subscribe to vehicles around vehicle '1':\n";
902  std::vector<int> vars3;
903  vars3.push_back(libsumo::VAR_SPEED);
905  //vehicle.addSubscriptionFilterTurn();
906  //vehicle.addSubscriptionFilterDownstreamDistance(1000);
907  //vehicle.addSubscriptionFilterUpstreamDistance(1000);
908  //vehicle.addSubscriptionFilterVClass(std::vector<std::string>({"passenger"}));
909  //vehicle.addSubscriptionFilterLanes(std::vector<int>({0, 1, 2}));
910  //vehicle.addSubscriptionFilterLeadFollow(std::vector<int>({0, 1, 2}));
911  //vehicle.addSubscriptionFilterLanes(std::vector<int>({0}));
912  //vehicle.addSubscriptionFilterLeadFollow(std::vector<int>({0}));
913  //vehicle.addSubscriptionFilterCFManeuver();
915 
916  simulationStep();
917  answerLog << " context subscription results:\n";
919  for (auto item : result5) {
920  answerLog << " vehicle=" << item.first << "\n";
921  }
922 
923  // person
924  answerLog << " person:\n";
925  person.setWidth("p0", 1);
926  person.setMinGap("p0", 2);
927  person.setLength("p0", 3);
928  person.setHeight("p0", 4);
929  person.setColor("p0", col1);
930  person.setType("p0", "stilts");
931  answerLog << " getIDList: " << joinToString(person.getIDList(), " ") << "\n";
932  answerLog << " getRoadID: " << person.getRoadID("p0") << "\n";
933  answerLog << " getTypeID: " << person.getTypeID("p0") << "\n";
934  answerLog << " getWaitingTime: " << person.getWaitingTime("p0") << "\n";
935  answerLog << " getNextEdge: " << person.getNextEdge("p0") << "\n";
936  answerLog << " getStage: " << person.getStage("p0").description << "\n";
937  answerLog << " getRemainingStages: " << person.getRemainingStages("p0") << "\n";
938  answerLog << " getVehicle: " << person.getVehicle("p0") << "\n";
939  answerLog << " getEdges: " << joinToString(person.getEdges("p0"), " ") << "\n";
940  answerLog << " getPosition: " << person.getPosition("p0").getString() << "\n";
941  answerLog << " getPosition3D: " << person.getPosition3D("p0").getString() << "\n";
942  answerLog << " getAngle: " << person.getAngle("p0") << "\n";
943  answerLog << " getSlope: " << person.getSlope("p0") << "\n";
944  answerLog << " getLanePosition: " << person.getLanePosition("p0") << "\n";
945  answerLog << " getLength: " << person.getLength("p0") << "\n";
946  answerLog << " getColor: " << person.getColor("p0").getString() << "\n";
947  person.setParameter("p0", "foo", "bar");
948  answerLog << " param: " << person.getParameter("p0", "foo") << "\n";
949  person.setSpeed("p0", 3);
950  simulationStep();
951  answerLog << " getSpeed: " << person.getSpeed("p0") << "\n";
952  person.add("p1", "e_u1", 10);
953  std::vector<std::string> walkEdges;
954  walkEdges.push_back("e_u1");
955  walkEdges.push_back("e_shape1");
956  person.appendWalkingStage("p1", walkEdges, -20);
957  person.appendWaitingStage("p1", 5);
958  person.appendDrivingStage("p1", "e_vu2", "BusLine42");
960  stage.edges.push_back("e_vu2");
961  stage.edges.push_back("e_vo2");
962  stage.arrivalPos = -10;
963  person.appendStage("p1", stage);
964  simulationStep();
965  // expect 5 stages due to the initial waiting-for-departure stage
966  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
967  person.removeStage("p1", 3);
968  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
969  person.removeStages("p1");
970  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
971  answerLog << " getStage: " << person.getStage("p1").description << "\n";
972  walkEdges.push_back("e_m5");
973  person.appendWalkingStage("p1", walkEdges, -20);
974  simulationStep();
976  answerLog << " getEdges after rerouting: " << joinToString(person.getEdges("p1"), " ") << "\n";
977 
978  // trafficlights
979  answerLog << " trafficlights:\n";
980  trafficlights.setPhase("n_m4", 0);
981  trafficlights.setPhaseName("n_m4", "nameSetByTraCI");
982  answerLog << " getIDList: " << joinToString(trafficlights.getIDList(), " ") << "\n";
983  answerLog << " getIDCount: " << trafficlights.getIDCount() << "\n";
984  answerLog << " state: " << trafficlights.getRedYellowGreenState("n_m4") << "\n";
985  answerLog << " program: " << trafficlights.getProgram("n_m4") << "\n";
986  answerLog << " phase: " << trafficlights.getPhase("n_m4") << "\n";
987  answerLog << " phaseName: " << trafficlights.getPhaseName("n_m4") << "\n";
988  answerLog << " phaseDuration: " << trafficlights.getPhaseDuration("n_m4") << "\n";
989  answerLog << " nextSwitch: " << trafficlights.getNextSwitch("n_m4") << "\n";
990  answerLog << " controlledLanes: " << joinToString(trafficlights.getControlledLanes("n_m4"), " ") << "\n";
991  std::vector<std::vector<libsumo::TraCILink> > links = trafficlights.getControlledLinks("n_m4");
992  answerLog << " controlledLinks:\n";
993  for (int i = 0; i < (int)links.size(); ++i) {
994  for (int j = 0; j < (int)links[i].size(); ++j) {
995  answerLog << " index=" << i << " link=" << j << " fromLane=" << links[i][j].fromLane << " viaLane=" << links[i][j].viaLane << " toLane=" << links[i][j].toLane << "\n";
996  }
997  }
998  libsumo::TraCILogic logic("custom", 0, 3);
999  logic.phases = std::vector<libsumo::TraCIPhase>({ libsumo::TraCIPhase(5, "rrrrrrr", 5, 5), libsumo::TraCIPhase(10, "ggggggg", 5, 15),
1000  libsumo::TraCIPhase(3, "GGGGGGG", 3, 3), libsumo::TraCIPhase(3, "yyyyyyy", 3, 3)
1001  });
1003 
1004  std::vector<libsumo::TraCILogic> logics = trafficlights.getCompleteRedYellowGreenDefinition("n_m4");
1005  answerLog << " completeDefinition:\n";
1006  for (int i = 0; i < (int)logics.size(); ++i) {
1007  answerLog << " subID=" << logics[i].programID << " type=" << logics[i].type << " phase=" << logics[i].currentPhaseIndex << "\n";
1008  answerLog << " params=" << joinToString(logics[i].subParameter, " ", ":") << "\n";
1009  for (int j = 0; j < (int)logics[i].phases.size(); ++j) {
1010  answerLog << " phase=" << logics[i].phases[j].state
1011  << " dur=" << logics[i].phases[j].duration
1012  << " minDur=" << logics[i].phases[j].minDur
1013  << " maxDur=" << logics[i].phases[j].maxDur
1014  << "\n";
1015  }
1016  }
1017  simulationStep();
1018  answerLog << " state=" << trafficlights.getRedYellowGreenState("n_m4") << "\n";
1019  trafficlights.setRedYellowGreenState("n_m4", "gGyruoO");
1020  answerLog << " stateSet=" << trafficlights.getRedYellowGreenState("n_m4") << "\n";
1021  answerLog << " program: " << trafficlights.getProgram("n_m4") << "\n";
1022 
1023  answerLog << " load:\n";
1024  std::vector<std::string> args;
1025  args.push_back("-n");
1026  args.push_back("net.net.xml");
1027  args.push_back("-r");
1028  args.push_back("input_routes.rou.xml");
1029  args.push_back("-a");
1030  args.push_back("input_additional.add.xml");
1031  args.push_back("--no-step-log");
1032  load(args);
1033  simulationStep();
1034  answerLog << " getCurrentTime: " << simulation.getCurrentTime() << "\n";
1035  vehicle.subscribe("0", vars, 0, TIME2STEPS(100));
1036  edge.subscribeContext("e_u1", libsumo::CMD_GET_VEHICLE_VARIABLE, 100, vars2, 0, TIME2STEPS(100));
1037 
1038  answerLog << " gui:\n";
1039  try {
1040  answerLog << " setScheme: \n";
1041  gui.setSchema("View #0", "real world");
1042  answerLog << " getScheme: " << gui.getSchema("View #0") << "\n";
1043  gui.setZoom("View #0", 50);
1044  answerLog << " getZoom: " << gui.getZoom() << "\n";
1045  answerLog << " take screenshot: \n";
1046  gui.screenshot("View #0", "image.png", 500, 500);
1047  } catch (libsumo::TraCIException&) {
1048  answerLog << " no support for gui commands\n";
1049  }
1050 }
TraCIAPI::VehicleScope::getLeader
std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2630
TraCIAPI::PersonScope::setLength
void setLength(const std::string &personID, double length) const
Definition: TraCIAPI.cpp:3539
TraCIAPI::TrafficLightScope::getProgram
std::string getProgram(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1949
libsumo::RTYPE_OK
TRACI_CONST int RTYPE_OK
Definition: TraCIConstants.h:353
TraCIAPI::POIScope::getIDCount
int getIDCount() const
Definition: TraCIAPI.cpp:1325
tcpip::Storage::readDouble
virtual double readDouble()
TraCIAPI::VehicleTypeScope::getHeight
double getHeight(const std::string &typeID) const
Definition: TraCIAPI.cpp:2169
TraCIAPI::TrafficLightScope::getIDList
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1848
TraCIAPI::VehicleScope::getRoute
std::vector< std::string > getRoute(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2455
ToString.h
TraCIAPI::PersonScope::setType
void setType(const std::string &personID, const std::string &typeID) const
Definition: TraCIAPI.cpp:3530
TraCIAPI::VehicleScope::changeTarget
void changeTarget(const std::string &vehicleID, const std::string &edgeID) const
Definition: TraCIAPI.cpp:2852
TraCIAPI::VehicleScope::setMaxSpeed
void setMaxSpeed(const std::string &vehicleID, double speed) const
Definition: TraCIAPI.cpp:3073
TraCIAPI::GUIScope::getSchema
std::string getSchema(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:847
TraCIAPI::VehicleScope::getRoadID
std::string getRoadID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2424
libsumo::TYPE_COLOR
TRACI_CONST int TYPE_COLOR
Definition: TraCIConstants.h:346
TraCIAPI::VehicleScope::moveToXY
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:2955
TraCIAPI::VehicleTypeScope::getMinGapLat
double getMinGapLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:2144
TraCIAPI::PersonScope::getAngle
double getAngle(const std::string &personID) const
Definition: TraCIAPI.cpp:3310
TraCIAPI::VehicleTypeScope::getMaxSpeedLat
double getMaxSpeedLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:2149
TraCIAPI::lane
LaneScope lane
Scope for interaction with lanes.
Definition: TraCIAPI.h:938
TraCIAPI::InductionLoopScope::getIDList
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:927
SUMOTime.h
TraCIAPI::LaneScope::getInternalFoes
std::vector< std::string > getInternalFoes(const std::string &laneID) const
Definition: TraCIAPI.cpp:1227
TraCIAPI::JunctionScope::getIDCount
int getIDCount() const
Definition: TraCIAPI.cpp:1015
TraCIAPI::LaneScope::getFoes
std::vector< std::string > getFoes(const std::string &laneID, const std::string &toLaneID) const
Definition: TraCIAPI.cpp:1211
TraCIAPI::POIScope::getPosition
libsumo::TraCIPosition getPosition(const std::string &poiID) const
Definition: TraCIAPI.cpp:1335
TraCIAPI::PersonScope::getIDList
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:3285
libsumo::POSITION_3D
TRACI_CONST int POSITION_3D
Definition: TraCIConstants.h:319
TraCIAPI::VehicleScope::moveTo
void moveTo(const std::string &vehicleID, const std::string &laneID, double position) const
Definition: TraCIAPI.cpp:2942
libsumo::VAR_ROAD_ID
TRACI_CONST int VAR_ROAD_ID
Definition: TraCIConstants.h:673
libsumo::TraCIResults
std::map< int, std::shared_ptr< TraCIResult > > TraCIResults
{variable->value}
Definition: TraCIDefs.h:202
TraCIAPI::PersonScope::getPosition
libsumo::TraCIPosition getPosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3300
TraCIAPI::VehicleScope::setSpeedFactor
void setSpeedFactor(const std::string &vehicleID, double factor) const
Definition: TraCIAPI.cpp:3064
libsumo::TraCIConnection::approachedInternal
std::string approachedInternal
Definition: TraCIDefs.h:279
TraCIAPI::TraCIScopeWrapper::getContextSubscriptionResults
const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3657
TraCIAPI::VehicleScope::setRoutingMode
void setRoutingMode(const std::string &vehicleID, int routingMode) const
Definition: TraCIAPI.cpp:3124
libsumo::CMD_CLOSE
TRACI_CONST int CMD_CLOSE
Definition: TraCIConstants.h:83
tcpip::Storage::writeUnsignedByte
virtual void writeUnsignedByte(int)
TraCIAPI::junction
JunctionScope junction
Scope for interaction with junctions.
Definition: TraCIAPI.h:936
TraCIAPI::send_commandSetOrder
void send_commandSetOrder(int order) const
Sends a SetOrder command.
Definition: TraCIAPI.cpp:148
TraCIAPI::TrafficLightScope::setPhase
void setPhase(const std::string &tlsID, int index) const
Definition: TraCIAPI.cpp:1984
TraCIAPI::PersonScope::getVehicle
std::string getVehicle(const std::string &personID) const
Definition: TraCIAPI.cpp:3356
TraCIAPI::VehicleScope::SIGNAL_FOGLIGHT
Definition: TraCIAPI.h:673
libsumo::TraCIColor::a
int a
Definition: TraCIDefs.h:144
tcpip::Storage::readStringList
virtual std::vector< std::string > readStringList()
libsumo::RESPONSE_SUBSCRIBE_GUI_VARIABLE
TRACI_CONST int RESPONSE_SUBSCRIBE_GUI_VARIABLE
Definition: TraCIConstants.h:278
TraCIAPI::SimulationScope::getDistanceRoad
double getDistanceRoad(const std::string &edgeID1, double pos1, const std::string &edgeID2, double pos2, bool isDriving=false)
Definition: TraCIAPI.cpp:1823
TraCITestClient::commandSimulationStep
void commandSimulationStep(double time)
Sends and validates a simulation step command.
Definition: TraCITestClient.cpp:178
TraCIAPI::TrafficLightScope::getRedYellowGreenState
std::string getRedYellowGreenState(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1858
TraCIAPI::TraCIScopeWrapper::subscribe
void subscribe(const std::string &objID, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3613
TraCIAPI::person
PersonScope person
Scope for interaction with persons.
Definition: TraCIAPI.h:944
libsumo::TraCIColor::g
int g
Definition: TraCIDefs.h:144
TraCIAPI::VehicleScope::getIDList
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:2379
TraCIAPI::LaneScope::getLinks
std::vector< libsumo::TraCIConnection > getLinks(const std::string &laneID) const
Definition: TraCIAPI.cpp:1075
TraCIAPI::setOrder
void setOrder(int order)
set priority (execution order) for the client
Definition: TraCIAPI.cpp:88
TraCIAPI::VehicleScope::getSlope
double getSlope(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2536
TraCITestClient::outputFileName
std::string outputFileName
The name of the file to write the results log into.
Definition: TraCITestClient.h:191
TraCIAPI::inductionloop
InductionLoopScope inductionloop
Scope for interaction with inductive loops.
Definition: TraCIAPI.h:934
libsumo::TraCIVehicleData::leaveTime
double leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIDefs.h:295
TraCIAPI::VehicleScope::remove
void remove(const std::string &vehicleID, char reason=libsumo::REMOVE_VAPORIZED) const
Definition: TraCIAPI.cpp:2841
TraCIAPI::TrafficLightScope::setPhaseName
void setPhaseName(const std::string &tlsID, const std::string &name) const
Definition: TraCIAPI.cpp:1993
TraCIAPI::RouteScope::getIDList
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1603
TraCIAPI::VehicleScope::getLanePosition
double getLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2465
TraCIAPI::TrafficLightScope::getControlledLinks
std::vector< std::vector< libsumo::TraCILink > > getControlledLinks(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1921
TraCIAPI::PolygonScope::getIDList
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1483
libsumo::TYPE_BYTE
TRACI_CONST int TYPE_BYTE
Definition: TraCIConstants.h:332
TraCIAPI::PersonScope::getWaitingTime
double getWaitingTime(const std::string &personID) const
Definition: TraCIAPI.cpp:3345
libsumo::TraCINextTLSData::tlIndex
int tlIndex
The tls index of the controlled link.
Definition: TraCIDefs.h:305
TraCIAPI::VehicleScope::setSignals
void setSignals(const std::string &vehicleID, int signals) const
Definition: TraCIAPI.cpp:3115
TraCIAPI::PersonScope::getStage
libsumo::TraCIStage getStage(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3366
libsumo::TraCIColor
A color.
Definition: TraCIDefs.h:136
TraCIAPI::VehicleScope::rerouteTraveltime
void rerouteTraveltime(const std::string &vehicleID, bool currentTravelTimes=true) const
Definition: TraCIAPI.cpp:2925
libsumo::TraCIVehicleData
mirrors MSInductLoop::VehicleData
Definition: TraCIDefs.h:287
TraCIAPI::VehicleScope::getMaxSpeed
double getMaxSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2404
TraCIAPI::VehicleScope::setLine
void setLine(const std::string &vehicleID, const std::string &line) const
Definition: TraCIAPI.cpp:3094
TraCIAPI::SimulationScope::getBusStopWaitingIDList
std::vector< std::string > getBusStopWaitingIDList(const std::string &stopID) const
Definition: TraCIAPI.cpp:1708
libsumo::TraCINextTLSData::dist
double dist
The distance to the tls.
Definition: TraCIDefs.h:307
libsumo::TraCIConnection::state
std::string state
Definition: TraCIDefs.h:280
TraCITestClient::~TraCITestClient
~TraCITestClient()
Destructor.
Definition: TraCITestClient.cpp:57
libsumo::TraCIColor::b
int b
Definition: TraCIDefs.h:144
TraCIAPI::PersonScope::setWidth
void setWidth(const std::string &personID, double width) const
Definition: TraCIAPI.cpp:3549
TraCIAPI::PersonScope::rerouteTraveltime
void rerouteTraveltime(const std::string &personID) const
Definition: TraCIAPI.cpp:3392
libsumo::TraCIConnection::direction
std::string direction
Definition: TraCIDefs.h:281
libsumo::CMD_GET_VEHICLE_VARIABLE
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
Definition: TraCIConstants.h:150
libsumo::TraCIConnection::hasFoe
bool hasFoe
Definition: TraCIDefs.h:278
libsumo::TraCIStage::arrivalPos
double arrivalPos
position on the lane when ending the stage
Definition: TraCIDefs.h:372
TraCIAPI::TrafficLightScope::setRedYellowGreenState
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
Definition: TraCIAPI.cpp:1975
TraCIAPI::createCommand
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:161
tcpip::Storage::writeByte
virtual void writeByte(int)
TraCITestClient::commandSubscribeObjectVariable
void commandSubscribeObjectVariable(int domID, const std::string &objID, double beginTime, double endTime, int varNo, std::ifstream &defFile)
Sends and validates a SubscribeVariable command.
Definition: TraCITestClient.cpp:282
TraCIAPI::VehicleScope::addSubscriptionFilterLCManeuver
void addSubscriptionFilterLCManeuver(int direction, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3195
TraCIAPI::GUIScope::screenshot
void screenshot(const std::string &viewID, const std::string &filename, const int width=-1, const int height=-1) const
Definition: TraCIAPI.cpp:899
TraCIAPI::PersonScope::appendDrivingStage
void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
Definition: TraCIAPI.cpp:3493
TraCIAPI::TraCIScopeWrapper::getParameter
std::string getParameter(const std::string &objectID, const std::string &key) const
retrieve generic paramter
Definition: TraCIAPI.cpp:3590
TraCIAPI::VehicleScope::getLateralSpeed
double getLateralSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2394
TraCIAPI::load
void load(const std::vector< std::string > &args)
Let sumo load a simulation using the given command line like options.
Definition: TraCIAPI.cpp:643
libsumo::CMD_SETORDER
TRACI_CONST int CMD_SETORDER
Definition: TraCIConstants.h:56
TraCITestClient::run
int run(std::string fileName, int port, std::string host="localhost")
Runs a test.
Definition: TraCITestClient.cpp:63
TraCIAPI::EdgeScope::getStreetName
std::string getStreetName(const std::string &id) const
Definition: TraCIAPI.cpp:773
TraCIAPI::VehicleScope::getStopState
int getStopState(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2666
TraCIAPI::PersonScope::setHeight
void setHeight(const std::string &personID, double height) const
Definition: TraCIAPI.cpp:3558
TraCITestClient::writeResult
void writeResult()
Writes the results file.
Definition: TraCITestClient.cpp:333
libsumo::TraCILogic
Definition: TraCIDefs.h:233
TraCIAPI::closeSocket
void closeSocket()
Closes the connection.
Definition: TraCIAPI.cpp:113
libsumo::TraCINextTLSData::state
char state
The current state of the tls.
Definition: TraCIDefs.h:309
TraCITestClient::commandSetValue
void commandSetValue(int domID, int varID, const std::string &objID, std::ifstream &defFile)
Sends and validates a SetVariable command.
Definition: TraCITestClient.cpp:258
tcpip::Storage::readUnsignedByte
virtual int readUnsignedByte()
libsumo::RESPONSE_SUBSCRIBE_GUI_CONTEXT
TRACI_CONST int RESPONSE_SUBSCRIBE_GUI_CONTEXT
Definition: TraCIConstants.h:268
tcpip::Storage::writeInt
virtual void writeInt(int)
TraCIAPI::simulationStep
void simulationStep(double time=0)
Advances by one step (or up to the given time)
Definition: TraCIAPI.cpp:621
libsumo::TYPE_DOUBLE
TRACI_CONST int TYPE_DOUBLE
Definition: TraCIConstants.h:336
TraCIAPI::VehicleScope::setColor
void setColor(const std::string &vehicleID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:3082
libsumo::TYPE_POLYGON
TRACI_CONST int TYPE_POLYGON
Definition: TraCIConstants.h:328
TraCIAPI::send_commandSubscribeObjectVariable
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:208
tcpip::Storage::readString
virtual std::string readString()
TraCIAPI::SimulationScope::convert2D
libsumo::TraCIPosition convert2D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1714
TraCIConstants.h
TraCIAPI::VehicleScope::setType
void setType(const std::string &vehicleID, const std::string &typeID) const
Definition: TraCIAPI.cpp:3055
TraCITestClient::commandSubscribeContextVariable
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.
Definition: TraCITestClient.cpp:306
TraCIAPI::trafficlights
TrafficLightScope trafficlights
Scope for interaction with traffic lights.
Definition: TraCIAPI.h:954
TraCIAPI::TrafficLightScope::getNextSwitch
double getNextSwitch(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1969
libsumo::TraCIStage::description
std::string description
arbitrary description string
Definition: TraCIDefs.h:374
TraCIAPI::GUIScope::setSchema
void setSchema(const std::string &viewID, const std::string &schemeName) const
Definition: TraCIAPI.cpp:877
tcpip::Storage::readInt
virtual int readInt()
libsumo::TYPE_INTEGER
TRACI_CONST int TYPE_INTEGER
Definition: TraCIConstants.h:334
TIME2STEPS
#define TIME2STEPS(x)
Definition: SUMOTime.h:59
libsumo::TraCIVehicleData::typeID
std::string typeID
Type of the vehicle in.
Definition: TraCIDefs.h:297
TraCIAPI::VehicleTypeScope::getWidth
double getWidth(const std::string &typeID) const
Definition: TraCIAPI.cpp:2164
TraCIAPI::InductionLoopScope::getVehicleData
std::vector< libsumo::TraCIVehicleData > getVehicleData(const std::string &loopID) const
Definition: TraCIAPI.cpp:973
TraCIAPI::PersonScope::getLanePosition
double getLanePosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3320
tcpip::Storage::writeStringList
virtual void writeStringList(const std::vector< std::string > &s)
libsumo::TraCIConnection
Definition: TraCIDefs.h:266
libsumo::STAGE_WALKING
TRACI_CONST int STAGE_WALKING
Definition: TraCIConstants.h:401
TraCIAPI::SimulationScope::convert3D
libsumo::TraCIPosition convert3D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1736
TraCIAPI::TraCIScopeWrapper::setParameter
void setParameter(const std::string &objectID, const std::string &key, const std::string &value) const
set generic paramter
Definition: TraCIAPI.cpp:3599
TraCIAPI::VehicleScope::getVia
std::vector< std::string > getVia(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2547
TraCIAPI::EdgeScope::getIDCount
int getIDCount() const
Definition: TraCIAPI.cpp:669
TraCITestClient.h
libsumo::TraCIStage
Definition: TraCIDefs.h:345
TraCIAPI::VehicleTypeScope::getLateralAlignment
std::string getLateralAlignment(const std::string &typeID) const
Definition: TraCIAPI.cpp:2154
TraCIAPI::VehicleTypeScope::getPersonCapacity
int getPersonCapacity(const std::string &typeID) const
Definition: TraCIAPI.cpp:2159
TraCIAPI::PersonScope::setMinGap
void setMinGap(const std::string &personID, double minGap) const
Definition: TraCIAPI.cpp:3567
TraCIAPI::VehicleScope::getSpeed
double getSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2389
TraCIAPI::send_commandSubscribeObjectContext
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:236
TraCIAPI::PolygonScope::getIDCount
int getIDCount() const
Definition: TraCIAPI.cpp:1488
libsumo::TraCIColor::getString
std::string getString()
Definition: TraCIDefs.h:139
TraCIAPI::VehicleTypeScope::setMinGapLat
void setMinGapLat(const std::string &typeID, double minGapLat) const
Definition: TraCIAPI.cpp:2264
TraCIAPI::TrafficLightScope::getPhase
int getPhase(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1954
TraCIAPI::VehicleTypeScope::setWidth
void setWidth(const std::string &typeID, double width) const
Definition: TraCIAPI.cpp:2236
TraCIAPI::route
RouteScope route
Scope for interaction with routes.
Definition: TraCIAPI.h:950
TraCIAPI::GUIScope::setZoom
void setZoom(const std::string &viewID, double zoom) const
Definition: TraCIAPI.cpp:858
TraCIAPI::VehicleTypeScope::setHeight
void setHeight(const std::string &typeID, double height) const
Definition: TraCIAPI.cpp:2245
TraCIAPI::PersonScope::appendWalkingStage
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:3472
libsumo::TraCIVehicleData::id
std::string id
The id of the vehicle.
Definition: TraCIDefs.h:289
TraCIAPI::JunctionScope::getShape
libsumo::TraCIPositionVector getShape(const std::string &junctionID) const
Definition: TraCIAPI.cpp:1026
libsumo::TraCIColor::r
int r
Definition: TraCIDefs.h:144
TraCIAPI::TrafficLightScope::getCompleteRedYellowGreenDefinition
std::vector< libsumo::TraCILogic > getCompleteRedYellowGreenDefinition(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1863
libsumo::TraCIConnection::approachedLane
std::string approachedLane
Definition: TraCIDefs.h:275
libsumo::POSITION_ROADMAP
TRACI_CONST int POSITION_ROADMAP
Definition: TraCIConstants.h:321
TraCIAPI::VehicleScope::setVia
void setVia(const std::string &vehicleID, const std::vector< std::string > &via) const
Definition: TraCIAPI.cpp:3103
TraCIAPI::VehicleScope::getSignals
int getSignals(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2475
TraCIAPI::simulation
SimulationScope simulation
Scope for interaction with the simulation.
Definition: TraCIAPI.h:952
TraCIAPI::VehicleScope::setShapeClass
void setShapeClass(const std::string &vehicleID, const std::string &clazz) const
Definition: TraCIAPI.cpp:3133
TraCIAPI::TrafficLightScope::getPhaseDuration
double getPhaseDuration(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1964
TraCIAPI::PersonScope::getNextEdge
std::string getNextEdge(const std::string &personID) const
Definition: TraCIAPI.cpp:3350
TraCIAPI::VehicleScope::getLateralLanePosition
double getLateralLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2480
TraCIAPI::SimulationScope::getCurrentTime
int getCurrentTime() const
Definition: TraCIAPI.cpp:1627
libsumo::TraCIConnection::length
double length
Definition: TraCIDefs.h:282
TraCIAPI::PolygonScope::getColor
libsumo::TraCIColor getColor(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1508
TraCIAPI::PersonScope::getColor
libsumo::TraCIColor getColor(const std::string &personID) const
Definition: TraCIAPI.cpp:3325
libsumo::TraCIException
Definition: TraCIDefs.h:90
libsumo::RESPONSE_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
TRACI_CONST int RESPONSE_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
Definition: TraCIConstants.h:92
TraCIAPI::PolygonScope::setLineWidth
void setLineWidth(const std::string &polygonID, const double lineWidth) const
Definition: TraCIAPI.cpp:1513
TraCIAPI::VehicleScope::getWaitingTime
double getWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2525
TraCIAPI::EdgeScope::adaptTraveltime
void adaptTraveltime(const std::string &edgeID, double time, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
Definition: TraCIAPI.cpp:779
TraCIAPI::TrafficLightScope::getControlledLanes
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1916
TraCIAPI::myOutput
tcpip::Storage myOutput
The reusable output storage.
Definition: TraCIAPI.h:1055
libsumo::TYPE_STRINGLIST
TRACI_CONST int TYPE_STRINGLIST
Definition: TraCIConstants.h:340
tcpip::SocketException
Definition: socket.h:53
TraCIAPI::TrafficLightScope::getPhaseName
std::string getPhaseName(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1959
TraCIAPI::PersonScope::removeStage
void removeStage(const std::string &personID, int nextStageIndex) const
Definition: TraCIAPI.cpp:3510
TraCIAPI::SimulationScope::convertRoad
libsumo::TraCIRoadPosition convertRoad(double x, double y, bool isGeo=false, const std::string &vClass="ignoring") const
Definition: TraCIAPI.cpp:1759
libsumo::TraCIVehicleData::length
double length
Length of the vehicle.
Definition: TraCIDefs.h:291
tcpip::Storage::writeString
virtual void writeString(const std::string &s)
TraCIAPI::VehicleScope::getShapeClass
std::string getShapeClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2557
libsumo::TraCINextTLSData::id
std::string id
The id of the next tls.
Definition: TraCIDefs.h:303
TraCIAPI::VehicleScope::getRouteID
std::string getRouteID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2444
libsumo::TraCILogic::phases
std::vector< TraCIPhase > phases
Definition: TraCIDefs.h:249
libsumo::ROUTING_MODE_AGGREGATED
TRACI_CONST int ROUTING_MODE_AGGREGATED
Definition: TraCIConstants.h:455
TraCIAPI::check_commandGetResult
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:306
libsumo::TraCIPhase
Definition: TraCIDefs.h:208
TraCIAPI::VehicleScope::getLine
std::string getLine(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2542
TraCITestClient::validateSimulationStep2
bool validateSimulationStep2(tcpip::Storage &inMsg)
Validates whether the given message is a valid answer to CMD_SIMSTEP.
Definition: TraCITestClient.cpp:360
TraCIAPI::EdgeScope::getIDList
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:664
TraCIAPI::POIScope::getColor
libsumo::TraCIColor getColor(const std::string &poiID) const
Definition: TraCIAPI.cpp:1340
libsumo::TraCIConnection::hasPrio
bool hasPrio
Definition: TraCIDefs.h:276
TraCIAPI::PersonScope::getRoadID
std::string getRoadID(const std::string &personID) const
Definition: TraCIAPI.cpp:3335
TraCITestClient::setValueTypeDependant
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.
Definition: TraCITestClient.cpp:435
TraCITestClient::readAndReportTypeDependent
void readAndReportTypeDependent(tcpip::Storage &inMsg, int valueDataType)
Reads a value of the given type from the given storage and reports it.
Definition: TraCITestClient.cpp:566
storage.h
TraCIAPI::SimulationScope::getDistance2D
double getDistance2D(double x1, double y1, double x2, double y2, bool isGeo=false, bool isDriving=false)
Definition: TraCIAPI.cpp:1803
TraCIAPI::vehicle
VehicleScope vehicle
Scope for interaction with vehicles.
Definition: TraCIAPI.h:956
TraCIAPI::EdgeScope::setEffort
void setEffort(const std::string &edgeID, double effort, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
Definition: TraCIAPI.cpp:799
libsumo::POSITION_2D
TRACI_CONST int POSITION_2D
Definition: TraCIConstants.h:315
TraCIAPI::VehicleTypeScope::setMaxSpeedLat
void setMaxSpeedLat(const std::string &typeID, double speed) const
Definition: TraCIAPI.cpp:2273
TraCIAPI::VehicleTypeScope::getApparentDecel
double getApparentDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:2109
TraCIAPI::VehicleScope::getAccumulatedWaitingTime
double getAccumulatedWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2731
TraCIAPI::VehicleTypeScope::setAccel
void setAccel(const std::string &typeID, double accel) const
Definition: TraCIAPI.cpp:2309
libsumo::TYPE_STRING
TRACI_CONST int TYPE_STRING
Definition: TraCIConstants.h:338
TraCIAPI::VehicleTypeScope::copy
void copy(const std::string &origTypeID, const std::string &newTypeID) const
Definition: TraCIAPI.cpp:2291
libsumo::TraCIStage::edges
std::vector< std::string > edges
The sequence of edges to travel.
Definition: TraCIDefs.h:358
TraCIAPI::VehicleScope::getLaneChangeState
std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction) const
Definition: TraCIAPI.cpp:2648
TraCIAPI::TrafficLightScope::setCompleteRedYellowGreenDefinition
void setCompleteRedYellowGreenDefinition(const std::string &tlsID, const libsumo::TraCILogic &logic) const
Definition: TraCIAPI.cpp:2020
TraCIAPI::EdgeScope::getLaneNumber
int getLaneNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:767
TraCIAPI::VehicleScope::isRouteValid
bool isRouteValid(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2761
TraCITestClient::commandSetOrder
void commandSetOrder(int order)
Sends and validates a SetOrder command.
Definition: TraCITestClient.cpp:209
TraCIAPI::EdgeScope::getAdaptedTraveltime
double getAdaptedTraveltime(const std::string &edgeID, double time) const
Definition: TraCIAPI.cpp:674
TraCIAPI::polygon
PolygonScope polygon
Scope for interaction with polygons.
Definition: TraCIAPI.h:948
TraCIAPI::VehicleScope::getIDCount
int getIDCount() const
Definition: TraCIAPI.cpp:2384
TraCIAPI::LaneScope::getIDCount
int getIDCount() const
Definition: TraCIAPI.cpp:1040
libsumo::VAR_LANEPOSITION
TRACI_CONST int VAR_LANEPOSITION
Definition: TraCIConstants.h:697
TraCITestClient::commandClose
void commandClose()
Sends and validates a Close command.
Definition: TraCITestClient.cpp:194
TraCIAPI::send_commandSimulationStep
void send_commandSimulationStep(double time) const
Sends a SimulationStep command.
Definition: TraCIAPI.cpp:124
TraCIAPI::send_commandClose
void send_commandClose() const
Sends a Close command.
Definition: TraCIAPI.cpp:137
TraCIAPI::VehicleScope::getLaneID
std::string getLaneID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2429
joinToString
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:247
TraCIAPI::VehicleScope::setRouteID
void setRouteID(const std::string &vehicleID, const std::string &routeID) const
Definition: TraCIAPI.cpp:2902
libsumo::TYPE_UBYTE
TRACI_CONST int TYPE_UBYTE
Definition: TraCIConstants.h:330
TraCIAPI::PolygonScope::getShape
libsumo::TraCIPositionVector getShape(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1503
TraCIAPI::poi
POIScope poi
Scope for interaction with POIs.
Definition: TraCIAPI.h:946
TraCIAPI::PersonScope::getLength
double getLength(const std::string &personID) const
Definition: TraCIAPI.cpp:3330
socket.h
TraCITestClient::validateSubscription
bool validateSubscription(tcpip::Storage &inMsg)
Validates whether the given message is a valid subscription return message.
Definition: TraCITestClient.cpp:377
TraCIAPI::VehicleScope::getPersonCapacity
int getPersonCapacity(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2746
libsumo::TraCIConnection::isOpen
bool isOpen
Definition: TraCIDefs.h:277
TraCIAPI::PolygonScope::setShape
void setShape(const std::string &polygonID, const libsumo::TraCIPositionVector &shape) const
Definition: TraCIAPI.cpp:1532
libsumo::REQUEST_AIRDIST
TRACI_CONST int REQUEST_AIRDIST
Definition: TraCIConstants.h:374
TraCIAPI::GUIScope::getZoom
double getZoom(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:837
tcpip::Storage::readByte
virtual int readByte()
TraCIAPI::VehicleScope::setRoute
void setRoute(const std::string &vehicleID, const std::vector< std::string > &edge) const
Definition: TraCIAPI.cpp:2912
TraCIAPI::VehicleScope::getAcceleration
double getAcceleration(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2399
libsumo::TraCINextTLSData
Definition: TraCIDefs.h:301
config.h
TraCIAPI::PersonScope::removeStages
void removeStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3382
TraCIAPI::VehicleTypeScope::setLateralAlignment
void setLateralAlignment(const std::string &typeID, const std::string &latAlignment) const
Definition: TraCIAPI.cpp:2282
TraCIAPI::PersonScope::setColor
void setColor(const std::string &personID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:3577
TraCIAPI::VehicleScope::add
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:2781
TraCIAPI::gui
GUIScope gui
Scope for interaction with the gui.
Definition: TraCIAPI.h:932
TraCIAPI::VehicleScope::getSpeedMode
int getSpeedMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2530
TraCIAPI::RouteScope::add
void add(const std::string &routeID, const std::vector< std::string > &edges) const
Definition: TraCIAPI.cpp:1614
TraCIAPI::VehicleTypeScope::setEmergencyDecel
void setEmergencyDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2327
TraCIAPI::JunctionScope::getIDList
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1010
libsumo::VAR_SPEED
TRACI_CONST int VAR_SPEED
Definition: TraCIConstants.h:607
TraCITestClient::answerLog
std::stringstream answerLog
Stream containing the log.
Definition: TraCITestClient.h:194
tcpip::Storage::writeDouble
virtual void writeDouble(double)
TraCIAPI::SimulationScope::convertGeo
libsumo::TraCIPosition convertGeo(double x, double y, bool fromGeo=false) const
Definition: TraCIAPI.cpp:1782
TraCITestClient::testAPI
void testAPI()
call all API methods once
Definition: TraCITestClient.cpp:644
TraCIAPI::EdgeScope::getTraveltime
double getTraveltime(const std::string &edgeID) const
Definition: TraCIAPI.cpp:746
TraCIAPI::VehicleScope::getTypeID
std::string getTypeID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2439
TraCIAPI::VehicleTypeScope::getIDList
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:2069
libsumo::REQUEST_DRIVINGDIST
TRACI_CONST int REQUEST_DRIVINGDIST
Definition: TraCIConstants.h:376
TraCIAPI::TraCIScopeWrapper::getSubscriptionResults
const libsumo::TraCIResults getSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3641
TraCIAPI::VehicleTypeScope::getEmergencyDecel
double getEmergencyDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:2104
TraCIAPI::LaneScope::getLinkNumber
int getLinkNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:1070
libsumo::TraCIPosition::getString
std::string getString()
Definition: TraCIDefs.h:111
tcpip::Socket::sendExact
void sendExact(const Storage &)
Definition: socket.cpp:435
TraCIAPI::PersonScope::appendWaitingStage
void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: TraCIAPI.cpp:3455
libsumo::RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
TRACI_CONST int RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
Definition: TraCIConstants.h:100
TraCIAPI::LaneScope::getIDList
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1035
TraCIAPI::PersonScope::getSlope
double getSlope(const std::string &personID) const
Definition: TraCIAPI.cpp:3315
TraCIDefs.h
TraCIAPI::PolygonScope::getLineWidth
double getLineWidth(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1493
TraCIAPI::VehicleTypeScope::setApparentDecel
void setApparentDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2336
TraCIAPI::SimulationScope::getBusStopWaiting
int getBusStopWaiting(const std::string &stopID) const
Definition: TraCIAPI.cpp:1703
TraCIAPI::PersonScope::setSpeed
void setSpeed(const std::string &personID, double speed) const
Definition: TraCIAPI.cpp:3520
TraCIAPI::POIScope::getIDList
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1320
TraCIAPI::PersonScope::add
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:3402
TraCIAPI::mySocket
tcpip::Socket * mySocket
The socket.
Definition: TraCIAPI.h:1053
TraCIAPI::TraCIScopeWrapper::subscribeContext
void subscribeContext(const std::string &objID, int domain, double range, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3625
TraCIAPI::VehicleScope::getNextTLS
std::vector< libsumo::TraCINextTLSData > getNextTLS(const std::string &vehID) const
Definition: TraCIAPI.cpp:2562
TraCIAPI::check_resultState
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:267
TraCIAPI::connect
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
Definition: TraCIAPI.cpp:75
TraCIAPI::PersonScope::appendStage
void appendStage(const std::string &personID, const libsumo::TraCIStage &stage)
Definition: TraCIAPI.cpp:3419
TraCITestClient::commandGetVariable
void commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *addData=0)
Sends and validates a GetVariable command.
Definition: TraCITestClient.cpp:224
tcpip::Storage
Definition: storage.h:36
TraCIAPI::PersonScope::getRemainingStages
int getRemainingStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3361
TraCITestClient::TraCITestClient
TraCITestClient(std::string outputFileName="testclient_result.out")
Constructor.
Definition: TraCITestClient.cpp:49
libsumo::SubscriptionResults
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:204
TraCIAPI::PersonScope::getTypeID
std::string getTypeID(const std::string &personID) const
Definition: TraCIAPI.cpp:3340
TraCIAPI::SimulationScope::getDeltaT
double getDeltaT() const
Definition: TraCIAPI.cpp:1687
TraCITestClient::errorMsg
void errorMsg(std::stringstream &msg)
Writes an error message.
Definition: TraCITestClient.cpp:349
TraCIAPI::PersonScope::getPosition3D
libsumo::TraCIPosition getPosition3D(const std::string &personID) const
Definition: TraCIAPI.cpp:3305
TraCIAPI::VehicleTypeScope::getAccel
double getAccel(const std::string &typeID) const
Definition: TraCIAPI.cpp:2094
TraCIAPI::PersonScope::getSpeed
double getSpeed(const std::string &personID) const
Definition: TraCIAPI.cpp:3295
TraCIAPI::EdgeScope::getEffort
double getEffort(const std::string &edgeID, double time) const
Definition: TraCIAPI.cpp:682
libsumo::CMD_SIMSTEP
TRACI_CONST int CMD_SIMSTEP
Definition: TraCIConstants.h:53
libsumo::TraCIVehicleData::entryTime
double entryTime
Entry-time of the vehicle in [s].
Definition: TraCIDefs.h:293
TraCIAPI::vehicletype
VehicleTypeScope vehicletype
Scope for interaction with vehicle types.
Definition: TraCIAPI.h:958
libsumo::TraCIRoadPosition::getString
std::string getString()
Definition: TraCIDefs.h:123
TraCIAPI::edge
EdgeScope edge
Scope for interaction with edges.
Definition: TraCIAPI.h:930
TraCIAPI::VehicleScope::getRoutingMode
int getRoutingMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2671
TraCIAPI::TrafficLightScope::getIDCount
int getIDCount() const
Definition: TraCIAPI.cpp:1853
libsumo::TYPE_COMPOUND
TRACI_CONST int TYPE_COMPOUND
Definition: TraCIConstants.h:342
TraCIAPI::VehicleScope::getColor
libsumo::TraCIColor getColor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2460
TraCIAPI::PersonScope::getEdges
std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3374