SUMO - Simulation of Urban MObility
TraCITestClient.cpp
Go to the documentation of this file.
1 /****************************************************************************/
13 /****************************************************************************/
14 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
15 // Copyright (C) 2008-2017 DLR (http://www.dlr.de/) and contributors
16 /****************************************************************************/
17 //
18 // This file is part of SUMO.
19 // SUMO is free software: you can redistribute it and/or modify
20 // it under the terms of the GNU General Public License as published by
21 // the Free Software Foundation, either version 3 of the License, or
22 // (at your option) any later version.
23 //
24 /****************************************************************************/
25 /* =========================================================================
26  * included modules
27  * ======================================================================= */
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include <config.h>
32 #endif
33 
34 #include <vector>
35 #include <iostream>
36 #include <iomanip>
37 #include <fstream>
38 #include <sstream>
39 #include <ctime>
40 #include <cstdlib>
41 
42 #define BUILD_TCPIP
43 #include <foreign/tcpip/storage.h>
44 #include <foreign/tcpip/socket.h>
45 
47 #include <traci-server/TraCIDefs.h>
48 #include <utils/common/SUMOTime.h>
49 #include <utils/common/ToString.h>
50 #include "TraCITestClient.h"
51 
52 
53 // ===========================================================================
54 // method definitions
55 // ===========================================================================
56 TraCITestClient::TraCITestClient(std::string outputFileName)
57  : outputFileName(outputFileName), answerLog("") {
58  answerLog.setf(std::ios::fixed , std::ios::floatfield); // use decimal format
59  answerLog.setf(std::ios::showpoint); // print decimal point
60  answerLog << std::setprecision(2);
61 }
62 
63 
65  writeResult();
66 }
67 
68 
69 bool
70 TraCITestClient::run(std::string fileName, int port, std::string host) {
71  std::ifstream defFile;
72  std::string fileContentStr;
73  std::stringstream fileContent;
74  std::string lineCommand;
75  std::stringstream msg;
76  int repNo = 1;
77  bool commentRead = false;
78 
79  // try to connect
80  try {
81  TraCIAPI::connect(host, port);
82  } catch (tcpip::SocketException& e) {
83  std::stringstream msg;
84  msg << "#Error while connecting: " << e.what();
85  errorMsg(msg);
86  return false;
87  }
88 
89  // read definition file and trigger commands according to it
90  defFile.open(fileName.c_str());
91  if (!defFile) {
92  msg << "Can not open definition file " << fileName << std::endl;
93  errorMsg(msg);
94  return false;
95  }
96  defFile.unsetf(std::ios::dec);
97 
98  while (defFile >> lineCommand) {
99  repNo = 1;
100  if (lineCommand.compare("%") == 0) {
101  // a comment was read
102  commentRead = !commentRead;
103  continue;
104  }
105  if (commentRead) {
106  // wait until end of comment is reached
107  continue;
108  }
109  if (lineCommand.compare("repeat") == 0) {
110  defFile >> repNo;
111  defFile >> lineCommand;
112  }
113  if (lineCommand.compare("simstep2") == 0) {
114  // read parameter for command simulation step and trigger command
115  std::string time;
116  defFile >> time;
117  for (int i = 0; i < repNo; i++) {
119  }
120  } else if (lineCommand.compare("getvariable") == 0) {
121  // trigger command GetXXXVariable
122  int domID, varID;
123  std::string objID;
124  defFile >> domID >> varID >> objID;
125  commandGetVariable(domID, varID, objID);
126  } else if (lineCommand.compare("getvariable_plus") == 0) {
127  // trigger command GetXXXVariable with one parameter
128  int domID, varID;
129  std::string objID;
130  defFile >> domID >> varID >> objID;
131  std::stringstream msg;
132  tcpip::Storage tmp;
133  setValueTypeDependant(tmp, defFile, msg);
134  std::string msgS = msg.str();
135  if (msgS != "") {
136  errorMsg(msg);
137  }
138  commandGetVariable(domID, varID, objID, &tmp);
139  } else if (lineCommand.compare("subscribevariable") == 0) {
140  // trigger command SubscribeXXXVariable
141  int domID, varNo;
142  std::string beginTime, endTime;
143  std::string objID;
144  defFile >> domID >> objID >> beginTime >> endTime >> varNo;
145  commandSubscribeObjectVariable(domID, objID, string2time(beginTime), string2time(endTime), varNo, defFile);
146  } else if (lineCommand.compare("subscribecontext") == 0) {
147  // trigger command SubscribeXXXVariable
148  int domID, varNo, domain;
149  double range;
150  std::string beginTime, endTime;
151  std::string objID;
152  defFile >> domID >> objID >> beginTime >> endTime >> domain >> range >> varNo;
153  commandSubscribeContextVariable(domID, objID, string2time(beginTime), string2time(endTime), domain, range, varNo, defFile);
154  } else if (lineCommand.compare("setvalue") == 0) {
155  // trigger command SetXXXValue
156  int domID, varID;
157  std::string objID;
158  defFile >> domID >> varID >> objID;
159  commandSetValue(domID, varID, objID, defFile);
160  } else if (lineCommand.compare("testAPI") == 0) {
161  // call all native API methods
162  testAPI();
163  } else {
164  msg << "Error in definition file: " << lineCommand << " is not a valid command";
165  errorMsg(msg);
166  commandClose();
167  closeSocket();
168  return false;
169  }
170  }
171  defFile.close();
172  commandClose();
173  closeSocket();
174  return true;
175 }
176 
177 
178 // ---------- Commands handling
179 void
182  answerLog << std::endl << "-> Command sent: <SimulationStep2>:" << std::endl;
183  tcpip::Storage inMsg;
184  try {
185  std::string acknowledgement;
186  check_resultState(inMsg, CMD_SIMSTEP, false, &acknowledgement);
187  answerLog << acknowledgement << std::endl;
189  } catch (tcpip::SocketException& e) {
190  answerLog << e.what() << std::endl;
191  }
192 }
193 
194 
195 void
198  answerLog << std::endl << "-> Command sent: <Close>:" << std::endl;
199  try {
200  tcpip::Storage inMsg;
201  std::string acknowledgement;
202  check_resultState(inMsg, CMD_CLOSE, false, &acknowledgement);
203  answerLog << acknowledgement << std::endl;
204  } catch (tcpip::SocketException& e) {
205  answerLog << e.what() << std::endl;
206  }
207 }
208 
209 
210 void
211 TraCITestClient::commandGetVariable(int domID, int varID, const std::string& objID, tcpip::Storage* addData) {
212  send_commandGetVariable(domID, varID, objID, addData);
213  answerLog << std::endl << "-> Command sent: <GetVariable>:" << std::endl
214  << " domID=" << domID << " varID=" << varID
215  << " objID=" << objID << std::endl;
216  tcpip::Storage inMsg;
217  try {
218  std::string acknowledgement;
219  check_resultState(inMsg, domID, false, &acknowledgement);
220  answerLog << acknowledgement << std::endl;
221  } catch (tcpip::SocketException& e) {
222  answerLog << e.what() << std::endl;
223  return;
224  }
225  check_commandGetResult(inMsg, domID, -1, false);
226  // report result state
227  try {
228  int variableID = inMsg.readUnsignedByte();
229  std::string objectID = inMsg.readString();
230  answerLog << " CommandID=" << (domID + 0x10) << " VariableID=" << variableID << " ObjectID=" << objectID;
231  int valueDataType = inMsg.readUnsignedByte();
232  answerLog << " valueDataType=" << valueDataType;
233  readAndReportTypeDependent(inMsg, valueDataType);
234  } catch (tcpip::SocketException& e) {
235  std::stringstream msg;
236  msg << "Error while receiving command: " << e.what();
237  errorMsg(msg);
238  return;
239  }
240 }
241 
242 
243 void
244 TraCITestClient::commandSetValue(int domID, int varID, const std::string& objID, std::ifstream& defFile) {
245  std::stringstream msg;
246  tcpip::Storage inMsg, tmp;
247  setValueTypeDependant(tmp, defFile, msg);
248  std::string msgS = msg.str();
249  if (msgS != "") {
250  errorMsg(msg);
251  }
252  send_commandSetValue(domID, varID, objID, tmp);
253  answerLog << std::endl << "-> Command sent: <SetValue>:" << std::endl
254  << " domID=" << domID << " varID=" << varID
255  << " objID=" << objID << std::endl;
256  try {
257  std::string acknowledgement;
258  check_resultState(inMsg, domID, false, &acknowledgement);
259  answerLog << acknowledgement << std::endl;
260  } catch (tcpip::SocketException& e) {
261  answerLog << e.what() << std::endl;
262  }
263 }
264 
265 
266 void
267 TraCITestClient::commandSubscribeObjectVariable(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime, int varNo, std::ifstream& defFile) {
268  std::vector<int> vars;
269  for (int i = 0; i < varNo; ++i) {
270  int var;
271  defFile >> var;
272  // variable id
273  vars.push_back(var);
274  }
275  send_commandSubscribeObjectVariable(domID, objID, beginTime, endTime, vars);
276  answerLog << std::endl << "-> Command sent: <SubscribeVariable>:" << std::endl
277  << " domID=" << domID << " objID=" << objID << " with " << varNo << " variables" << std::endl;
278  tcpip::Storage inMsg;
279  try {
280  std::string acknowledgement;
281  check_resultState(inMsg, domID, false, &acknowledgement);
282  answerLog << acknowledgement << std::endl;
283  validateSubscription(inMsg);
284  } catch (tcpip::SocketException& e) {
285  answerLog << e.what() << std::endl;
286  }
287 }
288 
289 
290 void
291 TraCITestClient::commandSubscribeContextVariable(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime,
292  int domain, double range, int varNo, std::ifstream& defFile) {
293  std::vector<int> vars;
294  for (int i = 0; i < varNo; ++i) {
295  int var;
296  defFile >> var;
297  // variable id
298  vars.push_back(var);
299  }
300  send_commandSubscribeObjectContext(domID, objID, beginTime, endTime, domain, range, vars);
301  answerLog << std::endl << "-> Command sent: <SubscribeContext>:" << std::endl
302  << " domID=" << domID << " objID=" << objID << " domain=" << domain << " range=" << range
303  << " with " << varNo << " variables" << std::endl;
304  tcpip::Storage inMsg;
305  try {
306  std::string acknowledgement;
307  check_resultState(inMsg, domID, false, &acknowledgement);
308  answerLog << acknowledgement << std::endl;
309  validateSubscription(inMsg);
310  } catch (tcpip::SocketException& e) {
311  answerLog << e.what() << std::endl;
312  }
313 }
314 
315 
316 // ---------- Report helper
317 void
319  time_t seconds;
320  tm* locTime;
321  std::ofstream outFile(outputFileName.c_str());
322  if (!outFile) {
323  std::cerr << "Unable to write result file" << std::endl;
324  }
325  time(&seconds);
326  locTime = localtime(&seconds);
327  outFile << "TraCITestClient output file. Date: " << asctime(locTime) << std::endl;
328  outFile << answerLog.str();
329  outFile.close();
330 }
331 
332 
333 void
334 TraCITestClient::errorMsg(std::stringstream& msg) {
335  std::cerr << msg.str() << std::endl;
336  answerLog << "----" << std::endl << msg.str() << std::endl;
337 }
338 
339 
340 
341 
342 
343 
344 bool
346  try {
347  int noSubscriptions = inMsg.readInt();
348  for (int s = 0; s < noSubscriptions; ++s) {
349  if (!validateSubscription(inMsg)) {
350  return false;
351  }
352  }
353  } catch (std::invalid_argument& e) {
354  answerLog << "#Error while reading message:" << e.what() << std::endl;
355  return false;
356  }
357  return true;
358 }
359 
360 
361 bool
363  try {
364  int length = inMsg.readUnsignedByte();
365  if (length == 0) {
366  length = inMsg.readInt();
367  }
368  int cmdId = inMsg.readUnsignedByte();
370  answerLog << " CommandID=" << cmdId;
371  answerLog << " ObjectID=" << inMsg.readString();
372  int varNo = inMsg.readUnsignedByte();
373  answerLog << " #variables=" << varNo << std::endl;
374  for (int i = 0; i < varNo; ++i) {
375  answerLog << " VariableID=" << inMsg.readUnsignedByte();
376  bool ok = inMsg.readUnsignedByte() == RTYPE_OK;
377  answerLog << " ok=" << ok;
378  int valueDataType = inMsg.readUnsignedByte();
379  answerLog << " valueDataType=" << valueDataType;
380  readAndReportTypeDependent(inMsg, valueDataType);
381  }
383  answerLog << " CommandID=" << cmdId;
384  answerLog << " ObjectID=" << inMsg.readString();
385  answerLog << " Domain=" << inMsg.readUnsignedByte();
386  int varNo = inMsg.readUnsignedByte();
387  answerLog << " #variables=" << varNo << std::endl;
388  int objNo = inMsg.readInt();
389  answerLog << " #objects=" << objNo << std::endl;
390  for (int j = 0; j < objNo; ++j) {
391  answerLog << " ObjectID=" << inMsg.readString() << std::endl;
392  for (int i = 0; i < varNo; ++i) {
393  answerLog << " VariableID=" << inMsg.readUnsignedByte();
394  bool ok = inMsg.readUnsignedByte() == RTYPE_OK;
395  answerLog << " ok=" << ok;
396  int valueDataType = inMsg.readUnsignedByte();
397  answerLog << " valueDataType=" << valueDataType;
398  readAndReportTypeDependent(inMsg, valueDataType);
399  }
400  }
401  } else {
402  answerLog << "#Error: received response with command id: " << cmdId << " but expected a subscription response (0xe0-0xef / 0x90-0x9f)" << std::endl;
403  return false;
404  }
405  } catch (std::invalid_argument& e) {
406  answerLog << "#Error while reading message:" << e.what() << std::endl;
407  return false;
408  }
409  return true;
410 }
411 
412 
413 
414 
415 
416 
417 
418 // ---------- Conversion helper
419 int
420 TraCITestClient::setValueTypeDependant(tcpip::Storage& into, std::ifstream& defFile, std::stringstream& msg) {
421  std::string dataTypeS;
422  defFile >> dataTypeS;
423  if (dataTypeS == "<airDist>") {
425  return 1;
426  } else if (dataTypeS == "<drivingDist>") {
428  return 1;
429  } else if (dataTypeS == "<objSubscription>") {
430  int beginTime, endTime, numVars;
431  defFile >> beginTime >> endTime >> numVars;
432  into.writeInt(beginTime);
433  into.writeInt(endTime);
434  into.writeInt(numVars);
435  for (int i = 0; i < numVars; ++i) {
436  int var;
437  defFile >> var;
438  into.writeUnsignedByte(var);
439  }
440  return 4 + 4 + 4 + numVars;
441  }
442  int valI;
443  double valF;
444  if (dataTypeS == "<int>") {
445  defFile >> valI;
447  into.writeInt(valI);
448  return 4 + 1;
449  } else if (dataTypeS == "<byte>") {
450  defFile >> valI;
452  into.writeByte(valI);
453  return 1 + 1;
454  } else if (dataTypeS == "<ubyte>") {
455  defFile >> valI;
457  into.writeUnsignedByte(valI);
458  return 1 + 1;
459  } else if (dataTypeS == "<float>") {
460  defFile >> valF;
462  into.writeFloat(float(valF));
463  return 4 + 1;
464  } else if (dataTypeS == "<double>") {
465  defFile >> valF;
467  into.writeDouble(valF);
468  return 8 + 1;
469  } else if (dataTypeS == "<string>") {
470  std::string valueS;
471  defFile >> valueS;
472  if (valueS == "\"\"") {
473  valueS = "";
474  }
476  into.writeString(valueS);
477  return 4 + 1 + (int) valueS.length();
478  } else if (dataTypeS == "<string*>") {
479  std::vector<std::string> slValue;
480  defFile >> valI;
481  int length = 1 + 4;
482  for (int i = 0; i < valI; ++i) {
483  std::string tmp;
484  defFile >> tmp;
485  slValue.push_back(tmp);
486  length += 4 + int(tmp.length());
487  }
489  into.writeStringList(slValue);
490  return length;
491  } else if (dataTypeS == "<compound>") {
492  defFile >> valI;
494  into.writeInt(valI);
495  int length = 1 + 4;
496  for (int i = 0; i < valI; ++i) {
497  length += setValueTypeDependant(into, defFile, msg);
498  }
499  return length;
500  } else if (dataTypeS == "<color>") {
501  defFile >> valI;
503  into.writeUnsignedByte(valI);
504  for (int i = 0; i < 3; ++i) {
505  defFile >> valI;
506  into.writeUnsignedByte(valI);
507  }
508  return 1 + 4;
509  } else if (dataTypeS == "<position2D>") {
510  defFile >> valF;
512  into.writeDouble(valF);
513  defFile >> valF;
514  into.writeDouble(valF);
515  return 1 + 8 + 8;
516  } else if (dataTypeS == "<position3D>") {
517  defFile >> valF;
519  into.writeDouble(valF);
520  defFile >> valF;
521  into.writeDouble(valF);
522  defFile >> valF;
523  into.writeDouble(valF);
524  return 1 + 8 + 8 + 8;
525  } else if (dataTypeS == "<positionRoadmap>") {
526  std::string valueS;
527  defFile >> valueS;
529  into.writeString(valueS);
530  int length = 1 + 8 + (int) valueS.length();
531  defFile >> valF;
532  into.writeDouble(valF);
533  defFile >> valI;
534  into.writeUnsignedByte(valI);
535  return length + 4 + 1;
536  } else if (dataTypeS == "<shape>") {
537  defFile >> valI;
539  into.writeUnsignedByte(valI);
540  int length = 1 + 1;
541  for (int i = 0; i < valI; ++i) {
542  double x, y;
543  defFile >> x >> y;
544  into.writeDouble(x);
545  into.writeDouble(y);
546  length += 8 + 8;
547  }
548  return length;
549  }
550  msg << "## Unknown data type: " << dataTypeS;
551  return 0;
552 }
553 
554 
555 void
557  if (valueDataType == TYPE_UBYTE) {
558  int ubyte = inMsg.readUnsignedByte();
559  answerLog << " Unsigned Byte Value: " << ubyte << std::endl;
560  } else if (valueDataType == TYPE_BYTE) {
561  int byte = inMsg.readByte();
562  answerLog << " Byte value: " << byte << std::endl;
563  } else if (valueDataType == TYPE_INTEGER) {
564  int integer = inMsg.readInt();
565  answerLog << " Int value: " << integer << std::endl;
566  } else if (valueDataType == TYPE_FLOAT) {
567  float floatv = inMsg.readFloat();
568  if (floatv < 0.1 && floatv > 0) {
569  answerLog.setf(std::ios::scientific, std::ios::floatfield);
570  }
571  answerLog << " float value: " << floatv << std::endl;
572  answerLog.setf(std::ios::fixed , std::ios::floatfield); // use decimal format
573  answerLog.setf(std::ios::showpoint); // print decimal point
574  answerLog << std::setprecision(2);
575  } else if (valueDataType == TYPE_DOUBLE) {
576  double doublev = inMsg.readDouble();
577  answerLog << " Double value: " << doublev << std::endl;
578  } else if (valueDataType == TYPE_BOUNDINGBOX) {
579  double lowerLeftX = inMsg.readDouble();
580  double lowerLeftY = inMsg.readDouble();
581  double upperRightX = inMsg.readDouble();
582  double upperRightY = inMsg.readDouble();
583  answerLog << " BoundaryBoxValue: lowerLeft x=" << lowerLeftX
584  << " y=" << lowerLeftY << " upperRight x=" << upperRightX
585  << " y=" << upperRightY << std::endl;
586  } else if (valueDataType == TYPE_POLYGON) {
587  int length = inMsg.readUnsignedByte();
588  answerLog << " PolygonValue: ";
589  for (int i = 0; i < length; i++) {
590  double x = inMsg.readDouble();
591  double y = inMsg.readDouble();
592  answerLog << "(" << x << "," << y << ") ";
593  }
594  answerLog << std::endl;
595  } else if (valueDataType == POSITION_3D) {
596  double x = inMsg.readDouble();
597  double y = inMsg.readDouble();
598  double z = inMsg.readDouble();
599  answerLog << " Position3DValue: " << std::endl;
600  answerLog << " x: " << x << " y: " << y
601  << " z: " << z << std::endl;
602  } else if (valueDataType == POSITION_ROADMAP) {
603  std::string roadId = inMsg.readString();
604  double pos = inMsg.readDouble();
605  int laneId = inMsg.readUnsignedByte();
606  answerLog << " RoadMapPositionValue: roadId=" << roadId
607  << " pos=" << pos
608  << " laneId=" << laneId << std::endl;
609  } else if (valueDataType == TYPE_TLPHASELIST) {
610  int length = inMsg.readUnsignedByte();
611  answerLog << " TLPhaseListValue: length=" << length << std::endl;
612  for (int i = 0; i < length; i++) {
613  std::string pred = inMsg.readString();
614  std::string succ = inMsg.readString();
615  int phase = inMsg.readUnsignedByte();
616  answerLog << " precRoad=" << pred << " succRoad=" << succ
617  << " phase=";
618  switch (phase) {
619  case TLPHASE_RED:
620  answerLog << "red" << std::endl;
621  break;
622  case TLPHASE_YELLOW:
623  answerLog << "yellow" << std::endl;
624  break;
625  case TLPHASE_GREEN:
626  answerLog << "green" << std::endl;
627  break;
628  default:
629  answerLog << "#Error: unknown phase value" << (int)phase << std::endl;
630  return;
631  }
632  }
633  } else if (valueDataType == TYPE_STRING) {
634  std::string s = inMsg.readString();
635  answerLog << " string value: " << s << std::endl;
636  } else if (valueDataType == TYPE_STRINGLIST) {
637  std::vector<std::string> s = inMsg.readStringList();
638  answerLog << " string list value: [ " << std::endl;
639  for (std::vector<std::string>::iterator i = s.begin(); i != s.end(); ++i) {
640  if (i != s.begin()) {
641  answerLog << ", ";
642  }
643  answerLog << '"' << *i << '"';
644  }
645  answerLog << " ]" << std::endl;
646  } else if (valueDataType == TYPE_COMPOUND) {
647  int no = inMsg.readInt();
648  answerLog << " compound value with " << no << " members: [ " << std::endl;
649  for (int i = 0; i < no; ++i) {
650  int currentValueDataType = inMsg.readUnsignedByte();
651  answerLog << " valueDataType=" << currentValueDataType;
652  readAndReportTypeDependent(inMsg, currentValueDataType);
653  }
654  answerLog << " ]" << std::endl;
655  } else if (valueDataType == POSITION_2D) {
656  double xv = inMsg.readDouble();
657  double yv = inMsg.readDouble();
658  answerLog << " position value: (" << xv << "," << yv << ")" << std::endl;
659  } else if (valueDataType == TYPE_COLOR) {
660  int r = inMsg.readUnsignedByte();
661  int g = inMsg.readUnsignedByte();
662  int b = inMsg.readUnsignedByte();
663  int a = inMsg.readUnsignedByte();
664  answerLog << " color value: (" << r << "," << g << "," << b << "," << a << ")" << std::endl;
665  } else {
666  answerLog << "#Error: unknown valueDataType!" << std::endl;
667  }
668 }
669 
670 
671 void
673  answerLog << "testAPI:\n";
674 
675  answerLog << " edge:\n";
676  answerLog << " getIDList: " << joinToString(edge.getIDList(), " ") << "\n";
677  answerLog << " getIDCount: " << edge.getIDCount() << "\n";
678  const std::string edgeID = "e_m0";
679  edge.adaptTraveltime(edgeID, 42, 0, 10);
680  edge.setEffort(edgeID, 420, 0, 10);
681  answerLog << " currentTraveltime: " << edge.getTraveltime(edgeID) << "\n";
682  answerLog << " adaptedTravelTime: " << edge.getAdaptedTraveltime(edgeID, 0) << "\n";
683  answerLog << " effort: " << edge.getEffort(edgeID, 0) << "\n";
684  answerLog << " route:\n";
685  answerLog << " add:\n";
686  std::vector<std::string> edges;
687  edges.push_back("e_u1");
688  route.add("e_u1", edges);
689  answerLog << " getIDList: " << joinToString(route.getIDList(), " ") << "\n";
690  answerLog << " vehicleType:\n";
691  answerLog << " getIDList: " << joinToString(vehicletype.getIDList(), " ") << "\n";
692  vehicletype.setWidth("t1", 1.9);
693  answerLog << " getWidth: " << vehicletype.getWidth("t1") << "\n";
694  vehicletype.setHeight("t1", 1.8);
695  answerLog << " getHeight: " << vehicletype.getHeight("t1") << "\n";
696  vehicletype.setMinGapLat("t1", 1.5);
697  answerLog << " setMinGapLat: " << vehicletype.getMinGapLat("t1") << "\n";
698  vehicletype.setMaxSpeedLat("t1", 1.2);
699  answerLog << " setMaxSpeedLat: " << vehicletype.getMaxSpeedLat("t1") << "\n";
700  vehicletype.setLateralAlignment("t1", "compact");
701  answerLog << " getLateralAlignment: " << vehicletype.getLateralAlignment("t1") << "\n";
702 
703  answerLog << " vehicle:\n";
704  vehicle.setLine("0", "S42");
705  std::vector<std::string> via;
706  via.push_back("e_shape1");
707  vehicle.setVia("0", via);
708  answerLog << " getRoadID: " << vehicle.getRoadID("0") << "\n";
709  answerLog << " getLaneID: " << vehicle.getLaneID("0") << "\n";
710  answerLog << " getLanePosition: " << vehicle.getLanePosition("0") << "\n";
711  answerLog << " getLateralLanePosition: " << vehicle.getLateralLanePosition("0") << "\n";
712  answerLog << " getSpeedMode: " << vehicle.getSpeedMode("0") << "\n";
713  answerLog << " getSlope: " << vehicle.getSlope("0") << "\n";
714  answerLog << " getLine: " << vehicle.getLine("0") << "\n";
715  answerLog << " getVia: " << joinToString(vehicle.getVia("0"), ",") << "\n";
716  vehicle.setMaxSpeed("0", 30);
717  answerLog << " getMaxSpeed: " << vehicle.getMaxSpeed("0") << "\n";
718  TraCIColor col1;
719  col1.r = 255;
720  col1.g = 255;
721  col1.b = 0;
722  col1.a = 128;
723  vehicle.setColor("0", col1);
724  TraCIColor col2 = vehicle.getColor("0");
725  answerLog << " getColor: r=" << (int)col2.r << " g=" << (int)col2.g << " b=" << (int)col2.b << " a=" << (int)col2.a << "\n";
726  answerLog << " getNextTLS:\n";
727  std::vector<VehicleScope::NextTLSData> result = vehicle.getNextTLS("0");
728  for (int i = 0; i < (int)result.size(); ++i) {
729  const VehicleScope::NextTLSData& d = result[i];
730  answerLog << " tls=" << d.id << " tlIndex=" << d.tlIndex << " dist=" << d.dist << " state=" << d.state << "\n";
731  }
732  answerLog << " moveToXY, simStep:\n";
733  vehicle.moveToXY("0", "dummy", 0, 2231.61, 498.29, 90, 1);
734  simulationStep();
735  answerLog << " getRoadID: " << vehicle.getRoadID("0") << "\n";
736  answerLog << " getLaneID: " << vehicle.getLaneID("0") << "\n";
737  vehicle.changeTarget("0", "e_o0");
738  answerLog << " edges: " << joinToString(vehicle.getEdges("0"), " ") << "\n";
739  answerLog << " add:\n";
740  vehicle.add("1", "e_u1");
741  simulationStep();
742  answerLog << " getIDList: " << joinToString(vehicle.getIDList(), " ") << "\n";
743  answerLog << " getWaitingTime: " << vehicle.getWaitingTime("0") << "\n";
744  vehicle.setShapeClass("0", "bicycle");
745  answerLog << " getShapeClass: " << vehicle.getShapeClass("0") << "\n";
746  answerLog << " remove:\n";
747  vehicle.remove("0");
748  answerLog << " getIDCount: " << vehicle.getIDCount() << "\n";
749 
750  answerLog << " inductionloop:\n";
751  answerLog << " getIDList: " << joinToString(inductionloop.getIDList(), " ") << "\n";
752  answerLog << " getVehicleData:\n";
753  std::vector<TraCIVehicleData> result2 = inductionloop.getVehicleData("det1");
754  for (int i = 0; i < (int)result2.size(); ++i) {
755  const TraCIVehicleData& vd = result2[i];
756  answerLog << " veh=" << vd.id << " length=" << vd.length << " entered=" << vd.entryTime << " left=" << vd.leaveTime << " type=" << vd.typeID << "\n";
757  }
758 
759  answerLog << " simulation:\n";
760  answerLog << " getCurrentTime: " << simulation.getCurrentTime() << "\n";
761  answerLog << " subscribe to road and pos of vehicle '1':\n";
762  std::vector<int> vars;
763  vars.push_back(VAR_ROAD_ID);
764  vars.push_back(VAR_LANEPOSITION);
766  simulationStep();
767  answerLog << " subscription results:\n";
769  answerLog << " roadID=" << result3[VAR_ROAD_ID].string << " pos=" << result3[VAR_LANEPOSITION].scalar << "\n";
770 
771  answerLog << " subscribe to vehicles around edge 'e_u1':\n";
772  std::vector<int> vars2;
773  vars2.push_back(VAR_LANEPOSITION);
775  simulationStep();
776  answerLog << " context subscription results:\n";
778  for (SubscribedValues::iterator it = result4.begin(); it != result4.end(); ++it) {
779  answerLog << " vehicle=" << it->first << " pos=" << it->second[VAR_LANEPOSITION].scalar << "\n";
780  }
781 
782  answerLog << " person:\n";
783  person.setWidth("p0", 1);
784  person.setMinGap("p0", 2);
785  person.setLength("p0", 3);
786  person.setHeight("p0", 4);
787  person.setColor("p0", col1);
788  person.setType("p0", "stilts");
789  answerLog << " getIDList: " << joinToString(person.getIDList(), " ") << "\n";
790  answerLog << " getRoadID: " << person.getRoadID("p0") << "\n";
791  answerLog << " getTypeID: " << person.getTypeID("p0") << "\n";
792  answerLog << " getWaitingTime: " << person.getWaitingTime("p0") << "\n";
793  answerLog << " getNextEdge: " << person.getNextEdge("p0") << "\n";
794  answerLog << " getStage: " << person.getStage("p0") << "\n";
795  answerLog << " getRemainingStages: " << person.getRemainingStages("p0") << "\n";
796  answerLog << " getVehicle: " << person.getVehicle("p0") << "\n";
797  answerLog << " getEdges: " << joinToString(person.getEdges("p0"), " ") << "\n";
798  person.setSpeed("p0", 3);
799  simulationStep();
800  answerLog << " getSpeed: " << person.getSpeed("p0") << "\n";
801  person.add("p1", "e_u1", 10);
802  std::vector<std::string> walkEdges;
803  walkEdges.push_back("e_u1");
804  walkEdges.push_back("e_shape1");
805  person.appendWalkingStage("p1", walkEdges, -20);
806  person.appendWaitingStage("p1", 5);
807  person.appendDrivingStage("p1", "e_vu2", "BusLine42");
808  // expect 4 stages due to the initial waiting-for-departure stage
809  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
810  person.removeStage("p1", 3);
811  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
812  person.removeStages("p1");
813  answerLog << " getRemainingStages: " << person.getRemainingStages("p1") << "\n";
814  answerLog << " getStage: " << person.getStage("p1") << "\n";
815  simulationStep();
816  answerLog << " trafficlights:\n";
817  answerLog << " getIDList: " << joinToString(trafficlights.getIDList(), " ") << "\n";
818  answerLog << " state: " << trafficlights.getRedYellowGreenState("n_m4") << "\n";
819  answerLog << " program: " << trafficlights.getProgram("n_m4") << "\n";
820  answerLog << " phase: " << trafficlights.getPhase("n_m4") << "\n";
821  answerLog << " nextSwitch: " << trafficlights.getNextSwitch("n_m4") << "\n";
822  answerLog << " controlledLanes: " << joinToString(trafficlights.getControlledLanes("n_m4"), " ") << "\n";
823  std::vector<TraCILink> links = trafficlights.getControlledLinks("n_m4");
824  answerLog << " controlledLinks:\n";
825  for (int i = 0; i < (int)links.size(); ++i) {
826  answerLog << " index=" << i << " from=" << links[i].from << " via=" << links[i].via << " to=" << links[i].to << "\n";
827  }
828  answerLog << " load:\n";
829  std::vector<std::string> args;
830  args.push_back("-n");
831  args.push_back("net.net.xml");
832  args.push_back("-r");
833  args.push_back("input_routes.rou.xml");
834  args.push_back("--no-step-log");
835  load(args);
836  simulationStep();
837  answerLog << " getCurrentTime: " << simulation.getCurrentTime() << "\n";
840 
841  answerLog << " gui:\n";
842  try {
843  answerLog << " setScheme: \n";
844  gui.setSchema("View #0", "real world");
845  answerLog << " getScheme: " << gui.getSchema("View #0") << "\n";
846  answerLog << " take screenshot: \n";
847  gui.screenshot("View #0", "image.png");
848  } catch (tcpip::SocketException&) {
849  answerLog << " no support for gui commands\n";
850  }
851 }
EdgeScope edge
Scope for interaction with edges.
Definition: TraCIAPI.h:768
#define VAR_ROAD_ID
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1487
#define RESPONSE_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1333
void send_commandSetValue(int domID, int varID, const std::string &objID, tcpip::Storage &content) const
Sends a SetVariable request.
Definition: TraCIAPI.cpp:151
void remove(const std::string &vehicleID, char reason=REMOVE_VAPORIZED) const
Definition: TraCIAPI.cpp:2201
void setMinGapLat(const std::string &typeID, double minGapLat) const
Definition: TraCIAPI.cpp:1851
int getNextSwitch(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1579
std::vector< NextTLSData > getNextTLS(const std::string &vehID) const
Definition: TraCIAPI.cpp:2110
void readAndReportTypeDependent(tcpip::Storage &inMsg, int valueDataType)
Reads a value of the given type from the given storage and reports it.
void screenshot(const std::string &viewID, const std::string &filename) const
Definition: TraCIAPI.cpp:802
void setEffort(const std::string &edgeID, double effort, SUMOTime begin=0, SUMOTime end=SUMOTime_MAX) const
Definition: TraCIAPI.cpp:702
void setWidth(const std::string &typeID, double width) const
Definition: TraCIAPI.cpp:1820
void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
Definition: TraCIAPI.cpp:2482
#define REQUEST_DRIVINGDIST
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:250
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
Definition: TraCIAPI.cpp:66
void setLength(const std::string &personID, double length) const
Definition: TraCIAPI.cpp:2532
double length
Length of the vehicle.
Definition: TraCIDefs.h:169
void changeTarget(const std::string &vehicleID, const std::string &edgeID) const
Definition: TraCIAPI.cpp:2212
void adaptTraveltime(const std::string &edgeID, double time, double begin=0, double end=SUMOTime_MAX/1000.0) const
Definition: TraCIAPI.cpp:686
#define CMD_GET_VEHICLE_VARIABLE
#define TYPE_COMPOUND
SUMOTime getCurrentTime() const
Definition: TraCIAPI.cpp:1361
std::stringstream answerLog
Stream containing the log.
#define CMD_CLOSE
void setVia(const std::string &vehicleID, const std::vector< std::string > &via) const
Definition: TraCIAPI.cpp:2301
virtual std::vector< std::string > readStringList()
#define RESPONSE_SUBSCRIBE_GUI_VARIABLE
#define POSITION_2D
void commandSubscribeObjectVariable(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, int varNo, std::ifstream &defFile)
Sends and validates a SubscribeVariable command.
void testAPI()
call all API methods once
std::map< int, TraCIValue > TraCIValues
{object->{variable->value}}
Definition: TraCIAPI.h:465
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.
double leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIDefs.h:173
TraCIColor getColor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2017
double getWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2072
#define TYPE_UBYTE
#define RTYPE_OK
void send_commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *add=0) const
Sends a GetVariable request.
Definition: TraCIAPI.cpp:124
#define POSITION_ROADMAP
virtual double readDouble()
#define TYPE_POLYGON
PersonScope person
Scope for interaction with persons.
Definition: TraCIAPI.h:782
int getIDCount() const
Definition: TraCIAPI.cpp:1957
double getMaxSpeedLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1732
unsigned char g
Definition: TraCIDefs.h:79
void setMaxSpeedLat(const std::string &typeID, double speed) const
Definition: TraCIAPI.cpp:1861
double getMaxSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1967
void setLine(const std::string &vehicleID, const std::string &line) const
Definition: TraCIAPI.cpp:2291
bool validateSubscription(tcpip::Storage &inMsg)
Validates whether the given message is a valid subscription return message.
std::string getRoadID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1982
void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: TraCIAPI.cpp:2438
#define TYPE_COLOR
#define TYPE_STRINGLIST
void load(const std::vector< std::string > &args)
Let sumo load a simulation using the given command line like options.
Definition: TraCIAPI.cpp:562
double getSpeed(const std::string &personID) const
Definition: TraCIAPI.cpp:2351
unsigned char r
Definition: TraCIDefs.h:79
#define POSITION_3D
void closeSocket()
Closes the connection.
Definition: TraCIAPI.cpp:89
void simulationStep(SUMOTime time=0)
Advances by one step (or up to the given time)
Definition: TraCIAPI.cpp:541
std::string getNextEdge(const std::string &personID) const
Definition: TraCIAPI.cpp:2376
std::string outputFileName
The name of the file to write the results log into.
#define TIME2STEPS(x)
Definition: SUMOTime.h:66
virtual void writeUnsignedByte(int)
std::string getRedYellowGreenState(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1492
TrafficLightScope trafficlights
Scope for interaction with traffic lights.
Definition: TraCIAPI.h:792
unsigned char a
Definition: TraCIDefs.h:79
int getPhase(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1574
std::string getLine(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2090
void removeStage(const std::string &personID, int nextStageIndex) const
Definition: TraCIAPI.cpp:2500
InductionLoopScope inductionloop
Scope for interaction with inductive loops.
Definition: TraCIAPI.h:772
virtual void writeInt(int)
std::vector< std::string > getEdges(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2012
#define TLPHASE_RED
#define TYPE_STRING
virtual int readUnsignedByte()
std::vector< TraCIVehicleData > getVehicleData(const std::string &loopID) const
Definition: TraCIAPI.cpp:873
#define RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
bool validateSimulationStep2(tcpip::Storage &inMsg)
Validates whether the given message is a valid answer to CMD_SIMSTEP.
const SubscribedValues & getSubscriptionResults() const
Definition: TraCIAPI.cpp:1452
void setColor(const std::string &vehicleID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:2278
void commandSetValue(int domID, int varID, const std::string &objID, std::ifstream &defFile)
Sends and validates a SetVariable command.
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:2236
#define TLPHASE_YELLOW
#define TYPE_FLOAT
#define TYPE_TLPHASELIST
std::string id
The id of the vehicle.
Definition: TraCIDefs.h:167
std::string getShapeClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2105
std::string getTypeID(const std::string &personID) const
Definition: TraCIAPI.cpp:2366
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:828
void setHeight(const std::string &personID, double height) const
Definition: TraCIAPI.cpp:2553
std::vector< std::string > getVia(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2095
std::map< std::string, TraCIValues > SubscribedValues
Definition: TraCIAPI.h:466
virtual int readInt()
#define VAR_LANEPOSITION
void writeResult()
Writes the results file.
void send_commandSubscribeObjectVariable(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, const std::vector< int > &vars) const
Sends a SubscribeVariable request.
Definition: TraCIAPI.cpp:172
virtual void writeByte(int)
RouteScope route
Scope for interaction with routes.
Definition: TraCIAPI.h:788
#define TYPE_BOUNDINGBOX
void send_commandSimulationStep(SUMOTime time) const
Sends a SimulationStep command.
Definition: TraCIAPI.cpp:100
virtual const char * what() const
Definition: socket.h:70
double getLateralLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2027
bool run(std::string fileName, int port, std::string host="localhost")
Runs a test.
virtual void writeStringList(const std::vector< std::string > &s)
void setLateralAlignment(const std::string &typeID, const std::string &latAlignment) const
Definition: TraCIAPI.cpp:1871
int getIDCount() const
Definition: TraCIAPI.cpp:587
SUMOTime string2time(const std::string &r)
Definition: SUMOTime.cpp:47
void setColor(const std::string &personID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:2574
void add(const std::string &personID, const std::string &edgeID, double pos, double depart=DEPARTFLAG_NOW, const std::string typeID="DEFAULT_PEDTYPE")
Definition: TraCIAPI.cpp:2417
double getWaitingTime(const std::string &personID) const
Definition: TraCIAPI.cpp:2371
std::string getRoadID(const std::string &personID) const
Definition: TraCIAPI.cpp:2361
virtual std::string readString()
void add(const std::string &routeID, const std::vector< std::string > &edges) const
Definition: TraCIAPI.cpp:1344
std::string getProgram(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1569
#define CMD_SUBSCRIBE_EDGE_CONTEXT
void setWidth(const std::string &personID, double width) const
Definition: TraCIAPI.cpp:2543
void setSpeed(const std::string &personID, double speed) const
Definition: TraCIAPI.cpp:2511
void setShapeClass(const std::string &vehicleID, const std::string &clazz) const
Definition: TraCIAPI.cpp:2315
std::string getVehicle(const std::string &personID) const
Definition: TraCIAPI.cpp:2382
std::vector< TraCILink > getControlledLinks(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1541
TraCITestClient(std::string outputFileName="testclient_result.out")
Constructor.
virtual void writeFloat(float)
const SubscribedContextValues & getContextSubscriptionResults() const
Definition: TraCIAPI.cpp:1468
double getEffort(const std::string &edgeID, SUMOTime time) const
Definition: TraCIAPI.cpp:600
int getRemainingStages(const std::string &personID) const
Definition: TraCIAPI.cpp:2387
double getSlope(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2084
void errorMsg(std::stringstream &msg)
Writes an error message.
#define TLPHASE_GREEN
#define RESPONSE_SUBSCRIBE_GUI_CONTEXT
void commandSubscribeContextVariable(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, int domain, double range, int varNo, std::ifstream &defFile)
Sends and validates a SubscribeContext command.
SimulationScope simulation
Scope for interaction with the simulation.
Definition: TraCIAPI.h:790
virtual void writeString(const std::string &s)
void setMaxSpeed(const std::string &vehicleID, double speed) const
Definition: TraCIAPI.cpp:2268
#define REQUEST_AIRDIST
VehicleScope vehicle
Scope for interaction with vehicles.
Definition: TraCIAPI.h:794
#define TYPE_DOUBLE
#define CMD_SUBSCRIBE_VEHICLE_VARIABLE
std::string typeID
Type of the vehicle in.
Definition: TraCIDefs.h:175
double getHeight(const std::string &typeID) const
Definition: TraCIAPI.cpp:1747
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1536
virtual float readFloat()
#define TYPE_BYTE
void commandClose()
Sends and validates a Close command.
void send_commandClose() const
Sends a Close command.
Definition: TraCIAPI.cpp:113
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:289
int getSpeedMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2078
void setSchema(const std::string &viewID, const std::string &schemeName) const
Definition: TraCIAPI.cpp:779
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1662
virtual void writeDouble(double)
double getTraveltime(const std::string &edgeID) const
Definition: TraCIAPI.cpp:664
GUIScope gui
Scope for interaction with the gui.
Definition: TraCIAPI.h:770
void setMinGap(const std::string &personID, double minGap) const
Definition: TraCIAPI.cpp:2563
void subscribe(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, const std::vector< int > &vars) const
Definition: TraCIAPI.cpp:1431
void subscribeContext(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, int domain, double range, const std::vector< int > &vars) const
Definition: TraCIAPI.cpp:1442
std::string getLateralAlignment(const std::string &typeID) const
Definition: TraCIAPI.cpp:1737
unsigned char b
Definition: TraCIDefs.h:79
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:2457
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:582
void setHeight(const std::string &typeID, double height) const
Definition: TraCIAPI.cpp:1830
std::string getLaneID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1987
long long int SUMOTime
Definition: TraCIDefs.h:52
int getStage(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:2392
double getLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2022
void commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *addData=0)
Sends and validates a GetVariable command.
void removeStages(const std::string &personID) const
Definition: TraCIAPI.cpp:2408
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:2140
void commandSimulationStep(SUMOTime time)
Sends and validates a simulation step command.
double getAdaptedTraveltime(const std::string &edgeID, double time) const
Definition: TraCIAPI.cpp:592
double entryTime
Entry-time of the vehicle in [s].
Definition: TraCIDefs.h:171
#define TYPE_INTEGER
void setType(const std::string &personID, const std::string &typeID) const
Definition: TraCIAPI.cpp:2522
void send_commandSubscribeObjectContext(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, int domain, double range, const std::vector< int > &vars) const
Sends a SubscribeContext request.
Definition: TraCIAPI.cpp:200
std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:2400
double getWidth(const std::string &typeID) const
Definition: TraCIAPI.cpp:1742
double getMinGapLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1727
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
Definition: ToString.h:228
#define CMD_SIMSTEP
virtual int readByte()
~TraCITestClient()
Destructor.
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:2341
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1952
std::string getSchema(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:748
VehicleTypeScope vehicletype
Scope for interaction with vehicle types.
Definition: TraCIAPI.h:796