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