SUMO - Simulation of Urban MObility
TraCIAPI.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2012-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
20 // C++ TraCI client API implementation
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include "TraCIAPI.h"
34 
35 using namespace libsumo;
36 
37 
38 // ===========================================================================
39 // member definitions
40 // ===========================================================================
41 
42 // ---------------------------------------------------------------------------
43 // TraCIAPI-methods
44 // ---------------------------------------------------------------------------
45 #ifdef _MSC_VER
46 #pragma warning(push)
47 #pragma warning(disable: 4355)
48 #endif
50  : edge(*this), gui(*this), inductionloop(*this),
51  junction(*this), lane(*this), lanearea(*this), multientryexit(*this),
52  person(*this), poi(*this), polygon(*this), route(*this),
53  simulation(*this), trafficlights(*this),
54  vehicle(*this), vehicletype(*this),
55  mySocket(0) {}
56 #ifdef _MSC_VER
57 #pragma warning(pop)
58 #endif
59 
60 
62  delete mySocket;
63 }
64 
65 
66 void
67 TraCIAPI::connect(const std::string& host, int port) {
68  mySocket = new tcpip::Socket(host, port);
69  try {
70  mySocket->connect();
71  } catch (tcpip::SocketException&) {
72  delete mySocket;
73  mySocket = 0;
74  throw;
75  }
76 }
77 
78 
79 void
80 TraCIAPI::setOrder(int order) {
81  tcpip::Storage outMsg;
82  // command length
83  outMsg.writeUnsignedByte(1 + 1 + 4);
84  // command id
86  outMsg.writeInt(order);
87  // send request message
88  mySocket->sendExact(outMsg);
89  tcpip::Storage inMsg;
91 }
92 
93 
94 void
97  tcpip::Storage inMsg;
98  std::string acknowledgement;
99  check_resultState(inMsg, CMD_CLOSE, false, &acknowledgement);
100  closeSocket();
101 }
102 
103 
104 void
106  if (mySocket == 0) {
107  return;
108  }
109  mySocket->close();
110  delete mySocket;
111  mySocket = 0;
112 }
113 
114 
115 void
117  tcpip::Storage outMsg;
118  // command length
119  outMsg.writeUnsignedByte(1 + 1 + 4);
120  // command id
122  outMsg.writeInt((int)time);
123  // send request message
124  mySocket->sendExact(outMsg);
125 }
126 
127 
128 void
130  tcpip::Storage outMsg;
131  // command length
132  outMsg.writeUnsignedByte(1 + 1);
133  // command id
135  mySocket->sendExact(outMsg);
136 }
137 
138 
139 void
141  tcpip::Storage outMsg;
142  // command length
143  outMsg.writeUnsignedByte(1 + 1 + 4);
144  // command id
146  // client index
147  outMsg.writeInt(order);
148  mySocket->sendExact(outMsg);
149 }
150 
151 
152 void
153 TraCIAPI::send_commandGetVariable(int domID, int varID, const std::string& objID, tcpip::Storage* add) const {
154  if (mySocket == 0) {
155  throw tcpip::SocketException("Socket is not initialised");
156  }
157  tcpip::Storage outMsg;
158  // command length
159  int length = 1 + 1 + 1 + 4 + (int) objID.length();
160  if (add != 0) {
161  length += (int)add->size();
162  }
163  outMsg.writeUnsignedByte(length);
164  // command id
165  outMsg.writeUnsignedByte(domID);
166  // variable id
167  outMsg.writeUnsignedByte(varID);
168  // object id
169  outMsg.writeString(objID);
170  // additional values
171  if (add != 0) {
172  outMsg.writeStorage(*add);
173  }
174  // send request message
175  mySocket->sendExact(outMsg);
176 }
177 
178 
179 void
180 TraCIAPI::send_commandSetValue(int domID, int varID, const std::string& objID, tcpip::Storage& content) const {
181  if (mySocket == 0) {
182  throw tcpip::SocketException("Socket is not initialised");
183  }
184  tcpip::Storage outMsg;
185  // command length (domID, varID, objID, dataType, data)
186  outMsg.writeUnsignedByte(1 + 1 + 1 + 4 + (int) objID.length() + (int)content.size());
187  // command id
188  outMsg.writeUnsignedByte(domID);
189  // variable id
190  outMsg.writeUnsignedByte(varID);
191  // object id
192  outMsg.writeString(objID);
193  // data type
194  outMsg.writeStorage(content);
195  // send message
196  mySocket->sendExact(outMsg);
197 }
198 
199 
200 void
201 TraCIAPI::send_commandSubscribeObjectVariable(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime,
202  const std::vector<int>& vars) const {
203  if (mySocket == 0) {
204  throw tcpip::SocketException("Socket is not initialised");
205  }
206  tcpip::Storage outMsg;
207  // command length (domID, objID, beginTime, endTime, length, vars)
208  int varNo = (int) vars.size();
209  outMsg.writeUnsignedByte(0);
210  outMsg.writeInt(5 + 1 + 4 + 4 + 4 + (int) objID.length() + 1 + varNo);
211  // command id
212  outMsg.writeUnsignedByte(domID);
213  // time
214  outMsg.writeInt((int)beginTime);
215  outMsg.writeInt((int)endTime);
216  // object id
217  outMsg.writeString(objID);
218  // command id
219  outMsg.writeUnsignedByte((int)vars.size());
220  for (int i = 0; i < varNo; ++i) {
221  outMsg.writeUnsignedByte(vars[i]);
222  }
223  // send message
224  mySocket->sendExact(outMsg);
225 }
226 
227 
228 void
229 TraCIAPI::send_commandSubscribeObjectContext(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime,
230  int domain, double range, const std::vector<int>& vars) const {
231  if (mySocket == 0) {
232  throw tcpip::SocketException("Socket is not initialised");
233  }
234  tcpip::Storage outMsg;
235  // command length (domID, objID, beginTime, endTime, length, vars)
236  int varNo = (int) vars.size();
237  outMsg.writeUnsignedByte(0);
238  outMsg.writeInt(5 + 1 + 4 + 4 + 4 + (int) objID.length() + 1 + 8 + 1 + varNo);
239  // command id
240  outMsg.writeUnsignedByte(domID);
241  // time
242  outMsg.writeInt((int)beginTime);
243  outMsg.writeInt((int)endTime);
244  // object id
245  outMsg.writeString(objID);
246  // domain and range
247  outMsg.writeUnsignedByte(domain);
248  outMsg.writeDouble(range);
249  // command id
250  outMsg.writeUnsignedByte((int)vars.size());
251  for (int i = 0; i < varNo; ++i) {
252  outMsg.writeUnsignedByte(vars[i]);
253  }
254  // send message
255  mySocket->sendExact(outMsg);
256 }
257 
258 void
259 TraCIAPI::send_commandMoveToXY(const std::string& vehicleID, const std::string& edgeID, const int lane, const double x, const double y, const double angle, const int keepRoute) const {
260  tcpip::Storage content;
262  content.writeInt(6);
264  content.writeString(edgeID);
266  content.writeInt(lane);
268  content.writeDouble(x);
270  content.writeDouble(y);
272  content.writeDouble(angle);
273  content.writeUnsignedByte(TYPE_BYTE);
274  content.writeByte(keepRoute);
276 }
277 
278 void
279 TraCIAPI::check_resultState(tcpip::Storage& inMsg, int command, bool ignoreCommandId, std::string* acknowledgement) const {
280  mySocket->receiveExact(inMsg);
281  int cmdLength;
282  int cmdId;
283  int resultType;
284  int cmdStart;
285  std::string msg;
286  try {
287  cmdStart = inMsg.position();
288  cmdLength = inMsg.readUnsignedByte();
289  cmdId = inMsg.readUnsignedByte();
290  if (command != cmdId && !ignoreCommandId) {
291  throw tcpip::SocketException("#Error: received status response to command: " + toString(cmdId) + " but expected: " + toString(command));
292  }
293  resultType = inMsg.readUnsignedByte();
294  msg = inMsg.readString();
295  } catch (std::invalid_argument&) {
296  throw tcpip::SocketException("#Error: an exception was thrown while reading result state message");
297  }
298  switch (resultType) {
299  case RTYPE_ERR:
300  throw tcpip::SocketException(".. Answered with error to command (" + toString(command) + "), [description: " + msg + "]");
302  throw tcpip::SocketException(".. Sent command is not implemented (" + toString(command) + "), [description: " + msg + "]");
303  case RTYPE_OK:
304  if (acknowledgement != 0) {
305  (*acknowledgement) = ".. Command acknowledged (" + toString(command) + "), [description: " + msg + "]";
306  }
307  break;
308  default:
309  throw tcpip::SocketException(".. Answered with unknown result code(" + toString(resultType) + ") to command(" + toString(command) + "), [description: " + msg + "]");
310  }
311  if ((cmdStart + cmdLength) != (int) inMsg.position()) {
312  throw tcpip::SocketException("#Error: command at position " + toString(cmdStart) + " has wrong length");
313  }
314 }
315 
316 
317 int
318 TraCIAPI::check_commandGetResult(tcpip::Storage& inMsg, int command, int expectedType, bool ignoreCommandId) const {
319  inMsg.position(); // respStart
320  int length = inMsg.readUnsignedByte();
321  if (length == 0) {
322  length = inMsg.readInt();
323  }
324  int cmdId = inMsg.readUnsignedByte();
325  if (!ignoreCommandId && cmdId != (command + 0x10)) {
326  throw tcpip::SocketException("#Error: received response with command id: " + toString(cmdId) + "but expected: " + toString(command + 0x10));
327  }
328  if (expectedType >= 0) {
329  // not called from the TraCITestClient but from within the TraCIAPI
330  inMsg.readUnsignedByte(); // variableID
331  inMsg.readString(); // objectID
332  int valueDataType = inMsg.readUnsignedByte();
333  if (valueDataType != expectedType) {
334  throw tcpip::SocketException("Expected " + toString(expectedType) + " but got " + toString(valueDataType));
335  }
336  }
337  return cmdId;
338 }
339 
340 
341 void
342 TraCIAPI::processGET(tcpip::Storage& inMsg, int command, int expectedType, bool ignoreCommandId) const {
343  check_resultState(inMsg, command, ignoreCommandId);
344  check_commandGetResult(inMsg, command, expectedType, ignoreCommandId);
345 }
346 
347 
348 
349 
350 SUMOTime
351 TraCIAPI::getSUMOTime(int cmd, int var, const std::string& id, tcpip::Storage* add) {
352  tcpip::Storage inMsg;
353  send_commandGetVariable(cmd, var, id, add);
354  processGET(inMsg, cmd, TYPE_INTEGER);
355  return inMsg.readInt();
356 }
357 
358 
359 int
360 TraCIAPI::getUnsignedByte(int cmd, int var, const std::string& id, tcpip::Storage* add) {
361  tcpip::Storage inMsg;
362  send_commandGetVariable(cmd, var, id, add);
363  processGET(inMsg, cmd, TYPE_UBYTE);
364  return inMsg.readUnsignedByte();
365 }
366 
367 
368 int
369 TraCIAPI::getByte(int cmd, int var, const std::string& id, tcpip::Storage* add) {
370  tcpip::Storage inMsg;
371  send_commandGetVariable(cmd, var, id, add);
372  processGET(inMsg, cmd, TYPE_BYTE);
373  return inMsg.readByte();
374 }
375 
376 
377 int
378 TraCIAPI::getInt(int cmd, int var, const std::string& id, tcpip::Storage* add) {
379  tcpip::Storage inMsg;
380  send_commandGetVariable(cmd, var, id, add);
381  processGET(inMsg, cmd, TYPE_INTEGER);
382  return inMsg.readInt();
383 }
384 
385 
386 double
387 TraCIAPI::getFloat(int cmd, int var, const std::string& id, tcpip::Storage* add) {
388  tcpip::Storage inMsg;
389  send_commandGetVariable(cmd, var, id, add);
390  processGET(inMsg, cmd, TYPE_FLOAT);
391  return inMsg.readFloat();
392 }
393 
394 
395 double
396 TraCIAPI::getDouble(int cmd, int var, const std::string& id, tcpip::Storage* add) {
397  tcpip::Storage inMsg;
398  send_commandGetVariable(cmd, var, id, add);
399  processGET(inMsg, cmd, TYPE_DOUBLE);
400  return inMsg.readDouble();
401 }
402 
403 
405 TraCIAPI::getBoundingBox(int cmd, int var, const std::string& id, tcpip::Storage* add) {
406  tcpip::Storage inMsg;
407  send_commandGetVariable(cmd, var, id, add);
408  processGET(inMsg, cmd, TYPE_BOUNDINGBOX);
409  TraCIBoundary b;
410  b.xMin = inMsg.readDouble();
411  b.yMin = inMsg.readDouble();
412  b.zMin = 0;
413  b.xMax = inMsg.readDouble();
414  b.yMax = inMsg.readDouble();
415  b.zMax = 0;
416  return b;
417 }
418 
419 
421 TraCIAPI::getPolygon(int cmd, int var, const std::string& id, tcpip::Storage* add) {
422  tcpip::Storage inMsg;
423  send_commandGetVariable(cmd, var, id, add);
424  processGET(inMsg, cmd, TYPE_POLYGON);
425  int size = inMsg.readByte();
427  for (int i = 0; i < size; ++i) {
428  TraCIPosition p;
429  p.x = inMsg.readDouble();
430  p.y = inMsg.readDouble();
431  p.z = 0;
432  ret.push_back(p);
433  }
434  return ret;
435 }
436 
437 
439 TraCIAPI::getPosition(int cmd, int var, const std::string& id, tcpip::Storage* add) {
440  tcpip::Storage inMsg;
441  send_commandGetVariable(cmd, var, id, add);
442  processGET(inMsg, cmd, POSITION_2D);
443  TraCIPosition p;
444  p.x = inMsg.readDouble();
445  p.y = inMsg.readDouble();
446  p.z = 0;
447  return p;
448 }
449 
450 
452 TraCIAPI::getPosition3D(int cmd, int var, const std::string& id, tcpip::Storage* add) {
453  tcpip::Storage inMsg;
454  send_commandGetVariable(cmd, var, id, add);
455  processGET(inMsg, cmd, POSITION_3D);
456  TraCIPosition p;
457  p.x = inMsg.readDouble();
458  p.y = inMsg.readDouble();
459  p.z = inMsg.readDouble();
460  return p;
461 }
462 
463 
464 std::string
465 TraCIAPI::getString(int cmd, int var, const std::string& id, tcpip::Storage* add) {
466  tcpip::Storage inMsg;
467  send_commandGetVariable(cmd, var, id, add);
468  processGET(inMsg, cmd, TYPE_STRING);
469  return inMsg.readString();
470 }
471 
472 
473 std::vector<std::string>
474 TraCIAPI::getStringVector(int cmd, int var, const std::string& id, tcpip::Storage* add) {
475  tcpip::Storage inMsg;
476  send_commandGetVariable(cmd, var, id, add);
477  processGET(inMsg, cmd, TYPE_STRINGLIST);
478  int size = inMsg.readInt();
479  std::vector<std::string> r;
480  for (int i = 0; i < size; ++i) {
481  r.push_back(inMsg.readString());
482  }
483  return r;
484 }
485 
486 
488 TraCIAPI::getColor(int cmd, int var, const std::string& id, tcpip::Storage* add) {
489  tcpip::Storage inMsg;
490  send_commandGetVariable(cmd, var, id, add);
491  processGET(inMsg, cmd, TYPE_COLOR);
492  TraCIColor c;
493  c.r = (unsigned char)inMsg.readUnsignedByte();
494  c.g = (unsigned char)inMsg.readUnsignedByte();
495  c.b = (unsigned char)inMsg.readUnsignedByte();
496  c.a = (unsigned char)inMsg.readUnsignedByte();
497  return c;
498 }
499 
500 void
501 TraCIAPI::readVariables(tcpip::Storage& inMsg, const std::string& objectID, int variableCount, SubscribedValues& into) {
502  while (variableCount > 0) {
503 
504  const int variableID = inMsg.readUnsignedByte();
505  const int status = inMsg.readUnsignedByte();
506  const int type = inMsg.readUnsignedByte();
507 
508  if (status == RTYPE_OK) {
509 
510  TraCIValue v;
511 
512  switch (type) {
513  case TYPE_DOUBLE:
514  v.scalar = inMsg.readDouble();
515  break;
516  case TYPE_STRING:
517  v.string = inMsg.readString();
518  break;
519  case POSITION_2D:
520  v.position.x = inMsg.readDouble();
521  v.position.y = inMsg.readDouble();
522  v.position.z = 0;
523  break;
524  case POSITION_3D:
525  v.position.x = inMsg.readDouble();
526  v.position.y = inMsg.readDouble();
527  v.position.z = inMsg.readDouble();
528  break;
529  case TYPE_COLOR:
530  v.color.r = (unsigned char)inMsg.readUnsignedByte();
531  v.color.g = (unsigned char)inMsg.readUnsignedByte();
532  v.color.b = (unsigned char)inMsg.readUnsignedByte();
533  v.color.a = (unsigned char)inMsg.readUnsignedByte();
534  break;
535  case TYPE_INTEGER:
536  v.scalar = inMsg.readInt();
537  break;
538  case TYPE_STRINGLIST: {
539  int n = inMsg.readInt();
540  for (int i = 0; i < n; ++i) {
541  v.stringList.push_back(inMsg.readString());
542  }
543  }
544  break;
545 
546  // TODO Other data types
547 
548  default:
549  throw tcpip::SocketException("Unimplemented subscription type: " + toString(type));
550  }
551 
552  into[objectID][variableID] = v;
553  } else {
554  throw tcpip::SocketException("Subscription response error: variableID=" + toString(variableID) + " status=" + toString(status));
555  }
556 
557  variableCount--;
558  }
559 }
560 
561 void
563  const std::string objectID = inMsg.readString();
564  const int variableCount = inMsg.readUnsignedByte();
565  readVariables(inMsg, objectID, variableCount, mySubscribedValues);
566 }
567 
568 void
570  const std::string contextID = inMsg.readString();
571  inMsg.readUnsignedByte(); // context domain
572  const int variableCount = inMsg.readUnsignedByte();
573  int numObjects = inMsg.readInt();
574 
575  while (numObjects > 0) {
576  std::string objectID = inMsg.readString();
577  readVariables(inMsg, objectID, variableCount, mySubscribedContextValues[contextID]);
578  numObjects--;
579  }
580 }
581 
582 void
585  tcpip::Storage inMsg;
587 
588  mySubscribedValues.clear();
590  int numSubs = inMsg.readInt();
591  while (numSubs > 0) {
592  int cmdId = check_commandGetResult(inMsg, 0, -1, true);
595  } else {
597  }
598  numSubs--;
599  }
600 }
601 
602 
603 void
604 TraCIAPI::load(const std::vector<std::string>& args) {
605  int numChars = 0;
606  for (int i = 0; i < (int)args.size(); ++i) {
607  numChars += (int)args[i].size();
608  }
609  tcpip::Storage content;
610  content.writeUnsignedByte(0);
611  content.writeInt(1 + 4 + 1 + 1 + 4 + numChars + 4 * (int)args.size());
612  content.writeUnsignedByte(CMD_LOAD);
614  content.writeStringList(args);
615  mySocket->sendExact(content);
616  tcpip::Storage inMsg;
617  check_resultState(inMsg, CMD_LOAD);
618 }
619 
620 
621 // ---------------------------------------------------------------------------
622 // TraCIAPI::EdgeScope-methods
623 // ---------------------------------------------------------------------------
624 std::vector<std::string>
626  return myParent.getStringVector(CMD_GET_EDGE_VARIABLE, ID_LIST, "");
627 }
628 
629 int
631  return myParent.getInt(CMD_GET_EDGE_VARIABLE, ID_COUNT, "");
632 }
633 
634 double
635 TraCIAPI::EdgeScope::getAdaptedTraveltime(const std::string& edgeID, double time) const {
636  tcpip::Storage content;
637  content.writeByte(TYPE_INTEGER);
638  content.writeInt((int)time);
639  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_EDGE_TRAVELTIME, edgeID, &content);
640 }
641 
642 double
643 TraCIAPI::EdgeScope::getEffort(const std::string& edgeID, SUMOTime time) const {
644  tcpip::Storage content;
645  content.writeByte(TYPE_INTEGER);
646  content.writeInt((int)time);
647  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_EDGE_EFFORT, edgeID, &content);
648 }
649 
650 double
651 TraCIAPI::EdgeScope::getCO2Emission(const std::string& edgeID) const {
652  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CO2EMISSION, edgeID);
653 }
654 
655 
656 double
657 TraCIAPI::EdgeScope::getCOEmission(const std::string& edgeID) const {
658  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_COEMISSION, edgeID);
659 }
660 
661 double
662 TraCIAPI::EdgeScope::getHCEmission(const std::string& edgeID) const {
663  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_HCEMISSION, edgeID);
664 }
665 
666 double
667 TraCIAPI::EdgeScope::getPMxEmission(const std::string& edgeID) const {
668  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_PMXEMISSION, edgeID);
669 }
670 
671 double
672 TraCIAPI::EdgeScope::getNOxEmission(const std::string& edgeID) const {
673  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_NOXEMISSION, edgeID);
674 }
675 
676 double
677 TraCIAPI::EdgeScope::getFuelConsumption(const std::string& edgeID) const {
678  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_FUELCONSUMPTION, edgeID);
679 }
680 
681 double
682 TraCIAPI::EdgeScope::getNoiseEmission(const std::string& edgeID) const {
683  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_NOISEEMISSION, edgeID);
684 }
685 
686 double
687 TraCIAPI::EdgeScope::getElectricityConsumption(const std::string& edgeID) const {
688  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_ELECTRICITYCONSUMPTION, edgeID);
689 }
690 
691 double
692 TraCIAPI::EdgeScope::getLastStepMeanSpeed(const std::string& edgeID) const {
693  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_MEAN_SPEED, edgeID);
694 }
695 
696 double
697 TraCIAPI::EdgeScope::getLastStepOccupancy(const std::string& edgeID) const {
698  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_OCCUPANCY, edgeID);
699 }
700 
701 double
702 TraCIAPI::EdgeScope::getLastStepLength(const std::string& edgeID) const {
703  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_LENGTH, edgeID);
704 }
705 
706 double
707 TraCIAPI::EdgeScope::getTraveltime(const std::string& edgeID) const {
708  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CURRENT_TRAVELTIME, edgeID);
709 }
710 
711 int
712 TraCIAPI::EdgeScope::getLastStepVehicleNumber(const std::string& edgeID) const {
713  return myParent.getInt(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_NUMBER, edgeID);
714 }
715 
716 double
717 TraCIAPI::EdgeScope::getLastStepHaltingNumber(const std::string& edgeID) const {
718  return myParent.getInt(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_HALTING_NUMBER, edgeID);
719 }
720 
721 std::vector<std::string>
722 TraCIAPI::EdgeScope::getLastStepVehicleIDs(const std::string& edgeID) const {
723  return myParent.getStringVector(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, edgeID);
724 }
725 
726 
727 
728 void
729 TraCIAPI::EdgeScope::adaptTraveltime(const std::string& edgeID, double time, int beginSeconds, int endSeconds) const {
730  tcpip::Storage content;
731  content.writeByte(TYPE_COMPOUND);
732  if (endSeconds != std::numeric_limits<double>::max()) {
733  content.writeInt(3);
734  content.writeByte(TYPE_INTEGER);
735  content.writeInt(beginSeconds);
736  content.writeByte(TYPE_INTEGER);
737  content.writeInt(endSeconds);
738  } else {
739  content.writeInt(1);
740  }
741  content.writeByte(TYPE_DOUBLE);
742  content.writeDouble(time);
743  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_EDGE_TRAVELTIME, edgeID, content);
744  tcpip::Storage inMsg;
745  myParent.check_resultState(inMsg, CMD_SET_EDGE_VARIABLE);
746 }
747 
748 void
749 TraCIAPI::EdgeScope::setEffort(const std::string& edgeID, double effort, int beginSeconds, int endSeconds) const {
750  tcpip::Storage content;
751  content.writeByte(TYPE_COMPOUND);
752  if (endSeconds != std::numeric_limits<double>::max()) {
753  content.writeInt(3);
754  content.writeByte(TYPE_INTEGER);
755  content.writeInt(beginSeconds);
756  content.writeByte(TYPE_INTEGER);
757  content.writeInt(endSeconds);
758  } else {
759  content.writeInt(1);
760  }
761  content.writeByte(TYPE_DOUBLE);
762  content.writeDouble(effort);
763  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_EDGE_EFFORT, edgeID, content);
764  tcpip::Storage inMsg;
765  myParent.check_resultState(inMsg, CMD_SET_EDGE_VARIABLE);
766 }
767 
768 void
769 TraCIAPI::EdgeScope::setMaxSpeed(const std::string& edgeID, double speed) const {
770  tcpip::Storage content;
771  content.writeDouble(speed);
772  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_MAXSPEED, edgeID, content);
773  tcpip::Storage inMsg;
774  myParent.check_resultState(inMsg, CMD_SET_EDGE_VARIABLE);
775 }
776 
777 
778 
779 
780 // ---------------------------------------------------------------------------
781 // TraCIAPI::GUIScope-methods
782 // ---------------------------------------------------------------------------
783 std::vector<std::string>
785  return myParent.getStringVector(CMD_GET_GUI_VARIABLE, ID_LIST, "");
786 }
787 
788 double
789 TraCIAPI::GUIScope::getZoom(const std::string& viewID) const {
790  return myParent.getDouble(CMD_GET_GUI_VARIABLE, VAR_VIEW_ZOOM, viewID);
791 }
792 
794 TraCIAPI::GUIScope::getOffset(const std::string& viewID) const {
795  return myParent.getPosition(CMD_GET_GUI_VARIABLE, VAR_VIEW_OFFSET, viewID);
796 }
797 
798 std::string
799 TraCIAPI::GUIScope::getSchema(const std::string& viewID) const {
800  return myParent.getString(CMD_GET_GUI_VARIABLE, VAR_VIEW_SCHEMA, viewID);
801 }
802 
804 TraCIAPI::GUIScope::getBoundary(const std::string& viewID) const {
805  return myParent.getBoundingBox(CMD_GET_GUI_VARIABLE, VAR_VIEW_BOUNDARY, viewID);
806 }
807 
808 
809 void
810 TraCIAPI::GUIScope::setZoom(const std::string& viewID, double zoom) const {
811  tcpip::Storage content;
812  content.writeDouble(zoom);
813  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_ZOOM, viewID, content);
814  tcpip::Storage inMsg;
815  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
816 }
817 
818 void
819 TraCIAPI::GUIScope::setOffset(const std::string& viewID, double x, double y) const {
820  tcpip::Storage content;
822  content.writeDouble(x);
823  content.writeDouble(y);
824  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_OFFSET, viewID, content);
825  tcpip::Storage inMsg;
826  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
827 }
828 
829 void
830 TraCIAPI::GUIScope::setSchema(const std::string& viewID, const std::string& schemeName) const {
831  tcpip::Storage content;
833  content.writeString(schemeName);
834  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_SCHEMA, viewID, content);
835  tcpip::Storage inMsg;
836  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
837 }
838 
839 void
840 TraCIAPI::GUIScope::setBoundary(const std::string& viewID, double xmin, double ymin, double xmax, double ymax) const {
841  tcpip::Storage content;
843  content.writeDouble(xmin);
844  content.writeDouble(ymin);
845  content.writeDouble(xmax);
846  content.writeDouble(ymax);
847  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_BOUNDARY, viewID, content);
848  tcpip::Storage inMsg;
849  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
850 }
851 
852 void
853 TraCIAPI::GUIScope::screenshot(const std::string& viewID, const std::string& filename) const {
854  tcpip::Storage content;
856  content.writeString(filename);
857  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_SCREENSHOT, viewID, content);
858  tcpip::Storage inMsg;
859  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
860 }
861 
862 void
863 TraCIAPI::GUIScope::trackVehicle(const std::string& viewID, const std::string& vehID) const {
864  tcpip::Storage content;
866  content.writeString(vehID);
867  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_TRACK_VEHICLE, viewID, content);
868  tcpip::Storage inMsg;
869  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
870 }
871 
872 
873 
874 
875 // ---------------------------------------------------------------------------
876 // TraCIAPI::InductionLoopScope-methods
877 // ---------------------------------------------------------------------------
878 std::vector<std::string>
880  return myParent.getStringVector(CMD_GET_INDUCTIONLOOP_VARIABLE, ID_LIST, "");
881 }
882 
883 double
884 TraCIAPI::InductionLoopScope::getPosition(const std::string& loopID) const {
885  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, VAR_POSITION, loopID);
886 }
887 
888 std::string
889 TraCIAPI::InductionLoopScope::getLaneID(const std::string& loopID) const {
890  return myParent.getString(CMD_GET_INDUCTIONLOOP_VARIABLE, VAR_LANE_ID, loopID);
891 }
892 
893 int
895  return myParent.getInt(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_NUMBER, loopID);
896 }
897 
898 double
899 TraCIAPI::InductionLoopScope::getLastStepMeanSpeed(const std::string& loopID) const {
900  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_MEAN_SPEED, loopID);
901 }
902 
903 std::vector<std::string>
904 TraCIAPI::InductionLoopScope::getLastStepVehicleIDs(const std::string& loopID) const {
905  return myParent.getStringVector(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, loopID);
906 }
907 
908 double
909 TraCIAPI::InductionLoopScope::getLastStepOccupancy(const std::string& loopID) const {
910  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_OCCUPANCY, loopID);
911 }
912 
913 double
914 TraCIAPI::InductionLoopScope::getLastStepMeanLength(const std::string& loopID) const {
915  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_LENGTH, loopID);
916 }
917 
918 double
919 TraCIAPI::InductionLoopScope::getTimeSinceDetection(const std::string& loopID) const {
920  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_TIME_SINCE_DETECTION, loopID);
921 }
922 
923 std::vector<TraCIVehicleData>
924 TraCIAPI::InductionLoopScope::getVehicleData(const std::string& loopID) const {
925  tcpip::Storage inMsg;
926  myParent.send_commandGetVariable(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_DATA, loopID);
927  myParent.processGET(inMsg, CMD_GET_INDUCTIONLOOP_VARIABLE, TYPE_COMPOUND);
928  std::vector<TraCIVehicleData> result;
929  inMsg.readInt(); // components
930  // number of items
931  inMsg.readUnsignedByte();
932  const int n = inMsg.readInt();
933  for (int i = 0; i < n; ++i) {
934  TraCIVehicleData vd;
935 
936  inMsg.readUnsignedByte();
937  vd.id = inMsg.readString();
938 
939  inMsg.readUnsignedByte();
940  vd.length = inMsg.readDouble();
941 
942  inMsg.readUnsignedByte();
943  vd.entryTime = inMsg.readDouble();
944 
945  inMsg.readUnsignedByte();
946  vd.leaveTime = inMsg.readDouble();
947 
948  inMsg.readUnsignedByte();
949  vd.typeID = inMsg.readString();
950 
951  result.push_back(vd);
952  }
953  return result;
954 }
955 
956 
957 
958 
959 // ---------------------------------------------------------------------------
960 // TraCIAPI::JunctionScope-methods
961 // ---------------------------------------------------------------------------
962 std::vector<std::string>
964  return myParent.getStringVector(CMD_GET_JUNCTION_VARIABLE, ID_LIST, "");
965 }
966 
968 TraCIAPI::JunctionScope::getPosition(const std::string& junctionID) const {
969  return myParent.getPosition(CMD_GET_JUNCTION_VARIABLE, VAR_POSITION, junctionID);
970 }
971 
972 
973 
974 
975 // ---------------------------------------------------------------------------
976 // TraCIAPI::LaneScope-methods
977 // ---------------------------------------------------------------------------
978 std::vector<std::string>
980  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, ID_LIST, "");
981 }
982 
983 int
985  return myParent.getInt(CMD_GET_LANE_VARIABLE, ID_COUNT, "");
986 }
987 
988 double
989 TraCIAPI::LaneScope::getLength(const std::string& laneID) const {
990  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_LENGTH, laneID);
991 }
992 
993 double
994 TraCIAPI::LaneScope::getMaxSpeed(const std::string& laneID) const {
995  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_MAXSPEED, laneID);
996 }
997 
998 double
999 TraCIAPI::LaneScope::getWidth(const std::string& laneID) const {
1000  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_WIDTH, laneID);
1001 }
1002 
1003 std::vector<std::string>
1004 TraCIAPI::LaneScope::getAllowed(const std::string& laneID) const {
1005  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, LANE_ALLOWED, laneID);
1006 }
1007 
1008 std::vector<std::string>
1009 TraCIAPI::LaneScope::getDisallowed(const std::string& laneID) const {
1010  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, LANE_DISALLOWED, laneID);
1011 }
1012 
1013 int
1014 TraCIAPI::LaneScope::getLinkNumber(const std::string& laneID) const {
1015  return myParent.getUnsignedByte(CMD_GET_LANE_VARIABLE, LANE_LINK_NUMBER, laneID);
1016 }
1017 
1018 std::vector<TraCIConnection>
1019 TraCIAPI::LaneScope::getLinks(const std::string& laneID) const {
1020  tcpip::Storage inMsg;
1021  myParent.send_commandGetVariable(CMD_GET_LANE_VARIABLE, LANE_LINKS, laneID);
1022  myParent.processGET(inMsg, CMD_GET_LANE_VARIABLE, TYPE_COMPOUND);
1023  std::vector<TraCIConnection> ret;
1024 
1025  inMsg.readUnsignedByte();
1026  inMsg.readInt();
1027 
1028  int linkNo = inMsg.readInt();
1029  for (int i = 0; i < linkNo; ++i) {
1030 
1031  inMsg.readUnsignedByte();
1032  std::string approachedLane = inMsg.readString();
1033 
1034  inMsg.readUnsignedByte();
1035  std::string approachedLaneInternal = inMsg.readString();
1036 
1037  inMsg.readUnsignedByte();
1038  bool hasPrio = inMsg.readUnsignedByte() != 0;
1039 
1040  inMsg.readUnsignedByte();
1041  bool isOpen = inMsg.readUnsignedByte() != 0;
1042 
1043  inMsg.readUnsignedByte();
1044  bool hasFoe = inMsg.readUnsignedByte() != 0;
1045 
1046  inMsg.readUnsignedByte();
1047  std::string state = inMsg.readString();
1048 
1049  inMsg.readUnsignedByte();
1050  std::string direction = inMsg.readString();
1051 
1052  inMsg.readUnsignedByte();
1053  double length = inMsg.readDouble();
1054 
1055  ret.push_back(TraCIConnection(approachedLane,
1056  hasPrio,
1057  isOpen,
1058  hasFoe,
1059  approachedLaneInternal,
1060  state,
1061  direction,
1062  length));
1063 
1064  }
1065  return ret;
1066 }
1067 
1069 TraCIAPI::LaneScope::getShape(const std::string& laneID) const {
1070  return myParent.getPolygon(CMD_GET_LANE_VARIABLE, VAR_SHAPE, laneID);
1071 }
1072 
1073 std::string
1074 TraCIAPI::LaneScope::getEdgeID(const std::string& laneID) const {
1075  return myParent.getString(CMD_GET_LANE_VARIABLE, LANE_EDGE_ID, laneID);
1076 }
1077 
1078 double
1079 TraCIAPI::LaneScope::getCO2Emission(const std::string& laneID) const {
1080  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_CO2EMISSION, laneID);
1081 }
1082 
1083 double
1084 TraCIAPI::LaneScope::getCOEmission(const std::string& laneID) const {
1085  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_COEMISSION, laneID);
1086 }
1087 
1088 double
1089 TraCIAPI::LaneScope::getHCEmission(const std::string& laneID) const {
1090  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_HCEMISSION, laneID);
1091 }
1092 
1093 double
1094 TraCIAPI::LaneScope::getPMxEmission(const std::string& laneID) const {
1095  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_PMXEMISSION, laneID);
1096 }
1097 
1098 double
1099 TraCIAPI::LaneScope::getNOxEmission(const std::string& laneID) const {
1100  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_NOXEMISSION, laneID);
1101 }
1102 
1103 double
1104 TraCIAPI::LaneScope::getFuelConsumption(const std::string& laneID) const {
1105  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_FUELCONSUMPTION, laneID);
1106 }
1107 
1108 double
1109 TraCIAPI::LaneScope::getNoiseEmission(const std::string& laneID) const {
1110  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_NOISEEMISSION, laneID);
1111 }
1112 
1113 double
1114 TraCIAPI::LaneScope::getElectricityConsumption(const std::string& laneID) const {
1115  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_ELECTRICITYCONSUMPTION, laneID);
1116 }
1117 
1118 double
1119 TraCIAPI::LaneScope::getLastStepMeanSpeed(const std::string& laneID) const {
1120  return myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_MEAN_SPEED, laneID);
1121 }
1122 
1123 double
1124 TraCIAPI::LaneScope::getLastStepOccupancy(const std::string& laneID) const {
1125  return myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_OCCUPANCY, laneID);
1126 }
1127 
1128 double
1129 TraCIAPI::LaneScope::getLastStepLength(const std::string& laneID) const {
1130  return myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_LENGTH, laneID);
1131 }
1132 
1133 double
1134 TraCIAPI::LaneScope::getTraveltime(const std::string& laneID) const {
1135  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_CURRENT_TRAVELTIME, laneID);
1136 }
1137 
1138 int
1139 TraCIAPI::LaneScope::getLastStepVehicleNumber(const std::string& laneID) const {
1140  return myParent.getInt(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_NUMBER, laneID);
1141 }
1142 
1143 int
1144 TraCIAPI::LaneScope::getLastStepHaltingNumber(const std::string& laneID) const {
1145  return myParent.getInt(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_HALTING_NUMBER, laneID);
1146 }
1147 
1148 std::vector<std::string>
1149 TraCIAPI::LaneScope::getLastStepVehicleIDs(const std::string& laneID) const {
1150  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, laneID);
1151 }
1152 
1153 
1154 std::vector<std::string>
1155 TraCIAPI::LaneScope::getFoes(const std::string& laneID, const std::string& toLaneID) const {
1156  tcpip::Storage content;
1157  content.writeUnsignedByte(TYPE_STRING);
1158  content.writeString(toLaneID);
1159  myParent.send_commandGetVariable(CMD_GET_LANE_VARIABLE, VAR_FOES, laneID, &content);
1160  tcpip::Storage inMsg;
1161  myParent.processGET(inMsg, CMD_GET_LANE_VARIABLE, TYPE_STRINGLIST);
1162  int size = inMsg.readInt();
1163  std::vector<std::string> r;
1164  for (int i = 0; i < size; ++i) {
1165  r.push_back(inMsg.readString());
1166  }
1167  return r;
1168 }
1169 
1170 std::vector<std::string>
1171 TraCIAPI::LaneScope::getInternalFoes(const std::string& laneID) const {
1172  return getFoes(laneID, "");
1173 }
1174 
1175 
1176 void
1177 TraCIAPI::LaneScope::setAllowed(const std::string& laneID, const std::vector<std::string>& allowedClasses) const {
1178  tcpip::Storage content;
1180  content.writeInt((int)allowedClasses.size());
1181  for (int i = 0; i < (int)allowedClasses.size(); ++i) {
1182  content.writeString(allowedClasses[i]);
1183  }
1184  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, LANE_ALLOWED, laneID, content);
1185  tcpip::Storage inMsg;
1186  myParent.check_resultState(inMsg, CMD_SET_LANE_VARIABLE);
1187 }
1188 
1189 void
1190 TraCIAPI::LaneScope::setDisallowed(const std::string& laneID, const std::vector<std::string>& disallowedClasses) const {
1191  tcpip::Storage content;
1193  content.writeInt((int)disallowedClasses.size());
1194  for (int i = 0; i < (int)disallowedClasses.size(); ++i) {
1195  content.writeString(disallowedClasses[i]);
1196  }
1197  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, LANE_DISALLOWED, laneID, content);
1198  tcpip::Storage inMsg;
1199  myParent.check_resultState(inMsg, CMD_SET_LANE_VARIABLE);
1200 }
1201 
1202 void
1203 TraCIAPI::LaneScope::setMaxSpeed(const std::string& laneID, double speed) const {
1204  tcpip::Storage content;
1205  content.writeUnsignedByte(TYPE_DOUBLE);
1206  content.writeDouble(speed);
1207  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, VAR_MAXSPEED, laneID, content);
1208  tcpip::Storage inMsg;
1209  myParent.check_resultState(inMsg, CMD_SET_LANE_VARIABLE);
1210 }
1211 
1212 void
1213 TraCIAPI::LaneScope::setLength(const std::string& laneID, double length) const {
1214  tcpip::Storage content;
1215  content.writeUnsignedByte(TYPE_DOUBLE);
1216  content.writeDouble(length);
1217  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, VAR_LENGTH, laneID, content);
1218  tcpip::Storage inMsg;
1219  myParent.check_resultState(inMsg, CMD_SET_LANE_VARIABLE);
1220 }
1221 
1222 
1223 // ---------------------------------------------------------------------------
1224 // TraCIAPI::LaneAreaDetector-methods
1225 // ---------------------------------------------------------------------------
1226 std::vector<std::string>
1228  return myParent.getStringVector(CMD_GET_LANEAREA_VARIABLE, ID_LIST, "");
1229 }
1230 
1231 
1232 
1233 
1234 // ---------------------------------------------------------------------------
1235 // TraCIAPI::MeMeScope-methods
1236 // ---------------------------------------------------------------------------
1237 std::vector<std::string>
1239  return myParent.getStringVector(CMD_GET_MULTIENTRYEXIT_VARIABLE, ID_LIST, "");
1240 }
1241 
1242 int
1243 TraCIAPI::MeMeScope::getLastStepVehicleNumber(const std::string& detID) const {
1244  return myParent.getInt(CMD_GET_MULTIENTRYEXIT_VARIABLE, LAST_STEP_VEHICLE_NUMBER, detID);
1245 }
1246 
1247 double
1248 TraCIAPI::MeMeScope::getLastStepMeanSpeed(const std::string& detID) const {
1249  return myParent.getInt(CMD_GET_MULTIENTRYEXIT_VARIABLE, LAST_STEP_MEAN_SPEED, detID);
1250 }
1251 
1252 std::vector<std::string>
1253 TraCIAPI::MeMeScope::getLastStepVehicleIDs(const std::string& detID) const {
1254  return myParent.getStringVector(CMD_GET_MULTIENTRYEXIT_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, detID);
1255 }
1256 
1257 int
1258 TraCIAPI::MeMeScope::getLastStepHaltingNumber(const std::string& detID) const {
1259  return myParent.getInt(CMD_GET_MULTIENTRYEXIT_VARIABLE, LAST_STEP_VEHICLE_HALTING_NUMBER, detID);
1260 }
1261 
1262 
1263 
1264 // ---------------------------------------------------------------------------
1265 // TraCIAPI::POIScope-methods
1266 // ---------------------------------------------------------------------------
1267 std::vector<std::string>
1269  return myParent.getStringVector(CMD_GET_POI_VARIABLE, ID_LIST, "");
1270 }
1271 
1272 std::string
1273 TraCIAPI::POIScope::getType(const std::string& poiID) const {
1274  return myParent.getString(CMD_GET_POI_VARIABLE, VAR_TYPE, poiID);
1275 }
1276 
1278 TraCIAPI::POIScope::getPosition(const std::string& poiID) const {
1279  return myParent.getPosition(CMD_GET_POI_VARIABLE, VAR_POSITION, poiID);
1280 }
1281 
1282 TraCIColor
1283 TraCIAPI::POIScope::getColor(const std::string& poiID) const {
1284  return myParent.getColor(CMD_GET_POI_VARIABLE, VAR_COLOR, poiID);
1285 }
1286 
1287 
1288 void
1289 TraCIAPI::POIScope::setType(const std::string& poiID, const std::string& setType) const {
1290  tcpip::Storage content;
1291  content.writeUnsignedByte(TYPE_STRING);
1292  content.writeString(setType);
1293  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_TYPE, poiID, content);
1294  tcpip::Storage inMsg;
1295  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1296 }
1297 
1298 void
1299 TraCIAPI::POIScope::setPosition(const std::string& poiID, double x, double y) const {
1300  tcpip::Storage content;
1301  content.writeUnsignedByte(POSITION_2D);
1302  content.writeDouble(x);
1303  content.writeDouble(y);
1304  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_POSITION, poiID, content);
1305  tcpip::Storage inMsg;
1306  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1307 }
1308 
1309 void
1310 TraCIAPI::POIScope::setColor(const std::string& poiID, const TraCIColor& c) const {
1311  tcpip::Storage content;
1312  content.writeUnsignedByte(TYPE_COLOR);
1313  content.writeUnsignedByte(c.r);
1314  content.writeUnsignedByte(c.g);
1315  content.writeUnsignedByte(c.b);
1316  content.writeUnsignedByte(c.a);
1317  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_COLOR, poiID, content);
1318  tcpip::Storage inMsg;
1319  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1320 }
1321 
1322 void
1323 TraCIAPI::POIScope::add(const std::string& poiID, double x, double y, const TraCIColor& c, const std::string& type, int layer) const {
1324  tcpip::Storage content;
1326  content.writeInt(4);
1327  content.writeUnsignedByte(TYPE_STRING);
1328  content.writeString(type);
1329  content.writeUnsignedByte(TYPE_COLOR);
1330  content.writeUnsignedByte(c.r);
1331  content.writeUnsignedByte(c.g);
1332  content.writeUnsignedByte(c.b);
1333  content.writeUnsignedByte(c.a);
1335  content.writeInt(layer);
1336  content.writeUnsignedByte(POSITION_2D);
1337  content.writeDouble(x);
1338  content.writeDouble(y);
1339  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, ADD, poiID, content);
1340  tcpip::Storage inMsg;
1341  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1342 }
1343 
1344 void
1345 TraCIAPI::POIScope::remove(const std::string& poiID, int layer) const {
1346  tcpip::Storage content;
1348  content.writeInt(layer);
1349  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, REMOVE, poiID, content);
1350  tcpip::Storage inMsg;
1351  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1352 }
1353 
1354 
1355 
1356 // ---------------------------------------------------------------------------
1357 // TraCIAPI::PolygonScope-methods
1358 // ---------------------------------------------------------------------------
1359 std::vector<std::string>
1361  return myParent.getStringVector(CMD_GET_POLYGON_VARIABLE, ID_LIST, "");
1362 }
1363 
1364 std::string
1365 TraCIAPI::PolygonScope::getType(const std::string& polygonID) const {
1366  return myParent.getString(CMD_GET_POLYGON_VARIABLE, VAR_TYPE, polygonID);
1367 }
1368 
1370 TraCIAPI::PolygonScope::getShape(const std::string& polygonID) const {
1371  return myParent.getPolygon(CMD_GET_POLYGON_VARIABLE, VAR_SHAPE, polygonID);
1372 }
1373 
1374 TraCIColor
1375 TraCIAPI::PolygonScope::getColor(const std::string& polygonID) const {
1376  return myParent.getColor(CMD_GET_POLYGON_VARIABLE, VAR_COLOR, polygonID);
1377 }
1378 
1379 
1380 void
1381 TraCIAPI::PolygonScope::setType(const std::string& polygonID, const std::string& setType) const {
1382  tcpip::Storage content;
1383  content.writeUnsignedByte(TYPE_STRING);
1384  content.writeString(setType);
1385  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_TYPE, polygonID, content);
1386  tcpip::Storage inMsg;
1387  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1388 }
1389 
1390 void
1391 TraCIAPI::PolygonScope::setShape(const std::string& polygonID, const TraCIPositionVector& shape) const {
1392  tcpip::Storage content;
1394  content.writeInt((int)shape.size());
1395  for (int i = 0; i < (int)shape.size(); ++i) {
1396  content.writeDouble(shape[i].x);
1397  content.writeDouble(shape[i].y);
1398  }
1399  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_POSITION, polygonID, content);
1400  tcpip::Storage inMsg;
1401  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1402 }
1403 
1404 void
1405 TraCIAPI::PolygonScope::setColor(const std::string& polygonID, const TraCIColor& c) const {
1406  tcpip::Storage content;
1407  content.writeUnsignedByte(TYPE_COLOR);
1408  content.writeUnsignedByte(c.r);
1409  content.writeUnsignedByte(c.g);
1410  content.writeUnsignedByte(c.b);
1411  content.writeUnsignedByte(c.a);
1412  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_COLOR, polygonID, content);
1413  tcpip::Storage inMsg;
1414  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1415 }
1416 
1417 void
1418 TraCIAPI::PolygonScope::add(const std::string& polygonID, const TraCIPositionVector& shape, const TraCIColor& c, bool fill, const std::string& type, int layer) const {
1419  tcpip::Storage content;
1421  content.writeInt(5);
1422  content.writeUnsignedByte(TYPE_STRING);
1423  content.writeString(type);
1424  content.writeUnsignedByte(TYPE_COLOR);
1425  content.writeUnsignedByte(c.r);
1426  content.writeUnsignedByte(c.g);
1427  content.writeUnsignedByte(c.b);
1428  content.writeUnsignedByte(c.a);
1429  content.writeUnsignedByte(TYPE_UBYTE);
1430  int f = fill ? 1 : 0;
1431  content.writeUnsignedByte(f);
1433  content.writeInt(layer);
1435  content.writeUnsignedByte((int)shape.size());
1436  for (int i = 0; i < (int)shape.size(); ++i) {
1437  content.writeDouble(shape[i].x);
1438  content.writeDouble(shape[i].y);
1439  }
1440  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, ADD, polygonID, content);
1441  tcpip::Storage inMsg;
1442  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1443 }
1444 
1445 void
1446 TraCIAPI::PolygonScope::remove(const std::string& polygonID, int layer) const {
1447  tcpip::Storage content;
1449  content.writeInt(layer);
1450  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, REMOVE, polygonID, content);
1451  tcpip::Storage inMsg;
1452  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1453 }
1454 
1455 
1456 
1457 // ---------------------------------------------------------------------------
1458 // TraCIAPI::RouteScope-methods
1459 // ---------------------------------------------------------------------------
1460 std::vector<std::string>
1462  return myParent.getStringVector(CMD_GET_ROUTE_VARIABLE, ID_LIST, "");
1463 }
1464 
1465 std::vector<std::string>
1466 TraCIAPI::RouteScope::getEdges(const std::string& routeID) const {
1467  return myParent.getStringVector(CMD_GET_ROUTE_VARIABLE, VAR_EDGES, routeID);
1468 }
1469 
1470 
1471 void
1472 TraCIAPI::RouteScope::add(const std::string& routeID, const std::vector<std::string>& edges) const {
1473  tcpip::Storage content;
1475  content.writeStringList(edges);
1476  myParent.send_commandSetValue(CMD_SET_ROUTE_VARIABLE, ADD, routeID, content);
1477  tcpip::Storage inMsg;
1478  myParent.check_resultState(inMsg, CMD_SET_ROUTE_VARIABLE);
1479 }
1480 
1481 
1482 
1483 
1484 
1485 // ---------------------------------------------------------------------------
1486 // TraCIAPI::SimulationScope-methods
1487 // ---------------------------------------------------------------------------
1488 SUMOTime
1490  return myParent.getSUMOTime(CMD_GET_SIM_VARIABLE, VAR_TIME_STEP, "");
1491 }
1492 
1493 int
1495  return (int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_LOADED_VEHICLES_NUMBER, "");
1496 }
1497 
1498 std::vector<std::string>
1500  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_LOADED_VEHICLES_IDS, "");
1501 }
1502 
1503 int
1505  return (int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_DEPARTED_VEHICLES_NUMBER, "");
1506 }
1507 
1508 std::vector<std::string>
1510  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_DEPARTED_VEHICLES_IDS, "");
1511 }
1512 
1513 int
1515  return (int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_ARRIVED_VEHICLES_NUMBER, "");
1516 }
1517 
1518 std::vector<std::string>
1520  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_ARRIVED_VEHICLES_IDS, "");
1521 }
1522 
1523 int
1525  return (int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_STARTING_VEHICLES_NUMBER, "");
1526 }
1527 
1528 std::vector<std::string>
1530  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_STARTING_VEHICLES_IDS, "");
1531 }
1532 
1533 int
1535  return (int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_ENDING_VEHICLES_NUMBER, "");
1536 }
1537 
1538 std::vector<std::string>
1540  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_ENDING_VEHICLES_IDS, "");
1541 }
1542 
1543 SUMOTime
1545  return myParent.getSUMOTime(CMD_GET_SIM_VARIABLE, VAR_DELTA_T, "");
1546 }
1547 
1550  return myParent.getBoundingBox(CMD_GET_SIM_VARIABLE, VAR_NET_BOUNDING_BOX, "");
1551 }
1552 
1553 int
1555  return myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_MIN_EXPECTED_VEHICLES, "");
1556 }
1557 
1558 void
1559 TraCIAPI::SimulationScope::subscribe(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime, const std::vector<int>& vars) const {
1560  myParent.send_commandSubscribeObjectVariable(domID, objID, beginTime, endTime, vars);
1561  tcpip::Storage inMsg;
1562  myParent.check_resultState(inMsg, domID);
1563  if (vars.size() > 0) {
1564  myParent.check_commandGetResult(inMsg, domID);
1565  myParent.readVariableSubscription(inMsg);
1566  }
1567 }
1568 
1569 void
1570 TraCIAPI::SimulationScope::subscribeContext(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime, int domain, double range, const std::vector<int>& vars) const {
1571 
1572  myParent.send_commandSubscribeObjectContext(domID, objID, beginTime, endTime, domain, range, vars);
1573  tcpip::Storage inMsg;
1574  myParent.check_resultState(inMsg, domID);
1575  myParent.check_commandGetResult(inMsg, domID);
1576  myParent.readContextSubscription(inMsg);
1577 }
1578 
1581  return myParent.mySubscribedValues;
1582 }
1583 
1584 
1585 const TraCIAPI::TraCIValues&
1586 TraCIAPI::SimulationScope::getSubscriptionResults(const std::string& objID) const {
1587  if (myParent.mySubscribedValues.find(objID) != myParent.mySubscribedValues.end()) {
1588  return myParent.mySubscribedValues[objID];
1589  } else {
1590  throw; // Something?
1591  }
1592 }
1593 
1594 
1597  return myParent.mySubscribedContextValues;
1598 }
1599 
1600 
1603  if (myParent.mySubscribedContextValues.find(objID) != myParent.mySubscribedContextValues.end()) {
1604  return myParent.mySubscribedContextValues[objID];
1605  } else {
1606  throw; // Something?
1607  }
1608 }
1609 
1610 
1611 // ---------------------------------------------------------------------------
1612 // TraCIAPI::TrafficLightScope-methods
1613 // ---------------------------------------------------------------------------
1614 std::vector<std::string>
1616  return myParent.getStringVector(CMD_GET_TL_VARIABLE, ID_LIST, "");
1617 }
1618 
1619 std::string
1621  return myParent.getString(CMD_GET_TL_VARIABLE, TL_RED_YELLOW_GREEN_STATE, tlsID);
1622 }
1623 
1624 std::vector<TraCILogic>
1626  tcpip::Storage inMsg;
1627  myParent.send_commandGetVariable(CMD_GET_TL_VARIABLE, TL_COMPLETE_DEFINITION_RYG, tlsID);
1628  myParent.processGET(inMsg, CMD_GET_TL_VARIABLE, TYPE_COMPOUND);
1629  std::vector<TraCILogic> ret;
1630 
1631  inMsg.readUnsignedByte();
1632  inMsg.readInt();
1633 
1634  int logicNo = inMsg.readInt();
1635  for (int i = 0; i < logicNo; ++i) {
1636  inMsg.readUnsignedByte();
1637  std::string subID = inMsg.readString();
1638  inMsg.readUnsignedByte();
1639  int type = inMsg.readInt();
1640  inMsg.readUnsignedByte();
1641  inMsg.readInt(); // add
1642  inMsg.readUnsignedByte();
1643  int phaseIndex = inMsg.readInt();
1644  inMsg.readUnsignedByte();
1645  int phaseNumber = inMsg.readInt();
1646  TraCILogic logic(subID, type, phaseIndex);
1647  for (int j = 0; j < phaseNumber; ++j) {
1648  inMsg.readUnsignedByte();
1649  int duration = inMsg.readInt();
1650  inMsg.readUnsignedByte();
1651  int duration1 = inMsg.readInt();
1652  inMsg.readUnsignedByte();
1653  int duration2 = inMsg.readInt();
1654  inMsg.readUnsignedByte();
1655  std::string phase = inMsg.readString();
1656  logic.phases.emplace_back(TraCIPhase(duration, duration1, duration2, phase));
1657  }
1658  ret.emplace_back(logic);
1659  }
1660  return ret;
1661 }
1662 
1663 std::vector<std::string>
1664 TraCIAPI::TrafficLightScope::getControlledLanes(const std::string& tlsID) const {
1665  return myParent.getStringVector(CMD_GET_TL_VARIABLE, TL_CONTROLLED_LANES, tlsID);
1666 }
1667 
1668 std::vector<std::vector<TraCILink> >
1669 TraCIAPI::TrafficLightScope::getControlledLinks(const std::string& tlsID) const {
1670  tcpip::Storage inMsg;
1671  myParent.send_commandGetVariable(CMD_GET_TL_VARIABLE, TL_CONTROLLED_LINKS, tlsID);
1672  myParent.processGET(inMsg, CMD_GET_TL_VARIABLE, TYPE_COMPOUND);
1673  std::vector<std::vector<TraCILink> > result;
1674 
1675  inMsg.readUnsignedByte();
1676  inMsg.readInt();
1677 
1678  int linkNo = inMsg.readInt();
1679  for (int i = 0; i < linkNo; ++i) {
1680  inMsg.readUnsignedByte();
1681  int no = inMsg.readInt();
1682  std::vector<TraCILink> ret;
1683  for (int i1 = 0; i1 < no; ++i1) {
1684  inMsg.readUnsignedByte();
1685  inMsg.readInt();
1686  std::string from = inMsg.readString();
1687  std::string to = inMsg.readString();
1688  std::string via = inMsg.readString();
1689  ret.emplace_back(TraCILink(from, via, to));
1690  }
1691  result.emplace_back(ret);
1692  }
1693  return result;
1694 }
1695 
1696 std::string
1697 TraCIAPI::TrafficLightScope::getProgram(const std::string& tlsID) const {
1698  return myParent.getString(CMD_GET_TL_VARIABLE, TL_CURRENT_PROGRAM, tlsID);
1699 }
1700 
1701 int
1702 TraCIAPI::TrafficLightScope::getPhase(const std::string& tlsID) const {
1703  return myParent.getInt(CMD_GET_TL_VARIABLE, TL_CURRENT_PHASE, tlsID);
1704 }
1705 
1706 int
1707 TraCIAPI::TrafficLightScope::getNextSwitch(const std::string& tlsID) const {
1708  return myParent.getInt(CMD_GET_TL_VARIABLE, TL_NEXT_SWITCH, tlsID);
1709 }
1710 
1711 
1712 void
1713 TraCIAPI::TrafficLightScope::setRedYellowGreenState(const std::string& tlsID, const std::string& state) const {
1714  tcpip::Storage content;
1715  content.writeUnsignedByte(TYPE_STRING);
1716  content.writeString(state);
1717  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_RED_YELLOW_GREEN_STATE, tlsID, content);
1718  tcpip::Storage inMsg;
1719  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1720 }
1721 
1722 void
1723 TraCIAPI::TrafficLightScope::setPhase(const std::string& tlsID, int index) const {
1724  tcpip::Storage content;
1726  content.writeInt(index);
1727  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PHASE_INDEX, tlsID, content);
1728  tcpip::Storage inMsg;
1729  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1730 }
1731 
1732 void
1733 TraCIAPI::TrafficLightScope::setProgram(const std::string& tlsID, const std::string& programID) const {
1734  tcpip::Storage content;
1735  content.writeUnsignedByte(TYPE_STRING);
1736  content.writeString(programID);
1737  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PROGRAM, tlsID, content);
1738  tcpip::Storage inMsg;
1739  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1740 }
1741 
1742 void
1743 TraCIAPI::TrafficLightScope::setPhaseDuration(const std::string& tlsID, int phaseDuration) const {
1744  tcpip::Storage content;
1746  content.writeInt(int(1000 * phaseDuration));
1747  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PHASE_DURATION, tlsID, content);
1748  tcpip::Storage inMsg;
1749  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1750 }
1751 
1752 void
1754  tcpip::Storage content;
1756  content.writeInt(5 + 4 * (int)logic.phases.size());
1757  content.writeUnsignedByte(TYPE_STRING);
1758  content.writeString(logic.subID);
1760  content.writeInt(logic.type);
1762  content.writeInt(0);
1764  content.writeInt(logic.currentPhaseIndex);
1766  content.writeInt((int)logic.phases.size());
1767  for (int i = 0; i < (int) logic.phases.size(); ++i) {
1769  content.writeInt((int)logic.phases[i].duration);
1771  content.writeInt((int)logic.phases[i].duration1);
1773  content.writeInt((int)logic.phases[i].duration2);
1774  content.writeUnsignedByte(TYPE_STRING);
1775  content.writeString(logic.phases[i].phase);
1776  }
1777  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_COMPLETE_PROGRAM_RYG, tlsID, content);
1778  tcpip::Storage inMsg;
1779  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1780 }
1781 
1782 
1783 
1784 
1785 
1786 // ---------------------------------------------------------------------------
1787 // TraCIAPI::VehicleTypeScope-methods
1788 // ---------------------------------------------------------------------------
1789 std::vector<std::string>
1791  return myParent.getStringVector(CMD_GET_VEHICLETYPE_VARIABLE, ID_LIST, "");
1792 }
1793 
1794 double
1795 TraCIAPI::VehicleTypeScope::getLength(const std::string& typeID) const {
1796  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_LENGTH, typeID);
1797 }
1798 
1799 double
1800 TraCIAPI::VehicleTypeScope::getMaxSpeed(const std::string& typeID) const {
1801  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_MAXSPEED, typeID);
1802 }
1803 
1804 double
1805 TraCIAPI::VehicleTypeScope::getSpeedFactor(const std::string& typeID) const {
1806  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_SPEED_FACTOR, typeID);
1807 }
1808 
1809 double
1810 TraCIAPI::VehicleTypeScope::getSpeedDeviation(const std::string& typeID) const {
1811  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_SPEED_DEVIATION, typeID);
1812 }
1813 
1814 double
1815 TraCIAPI::VehicleTypeScope::getAccel(const std::string& typeID) const {
1816  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_ACCEL, typeID);
1817 }
1818 
1819 double
1820 TraCIAPI::VehicleTypeScope::getDecel(const std::string& typeID) const {
1821  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_DECEL, typeID);
1822 }
1823 
1824 double
1825 TraCIAPI::VehicleTypeScope::getEmergencyDecel(const std::string& typeID) const {
1826  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_EMERGENCY_DECEL, typeID);
1827 }
1828 
1829 double
1830 TraCIAPI::VehicleTypeScope::getApparentDecel(const std::string& typeID) const {
1831  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_APPARENT_DECEL, typeID);
1832 }
1833 
1834 double
1835 TraCIAPI::VehicleTypeScope::getImperfection(const std::string& typeID) const {
1836  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_IMPERFECTION, typeID);
1837 }
1838 
1839 double
1840 TraCIAPI::VehicleTypeScope::getTau(const std::string& typeID) const {
1841  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_TAU, typeID);
1842 }
1843 
1844 std::string
1845 TraCIAPI::VehicleTypeScope::getVehicleClass(const std::string& typeID) const {
1846  return myParent.getString(CMD_GET_VEHICLETYPE_VARIABLE, VAR_VEHICLECLASS, typeID);
1847 }
1848 
1849 std::string
1850 TraCIAPI::VehicleTypeScope::getEmissionClass(const std::string& typeID) const {
1851  return myParent.getString(CMD_GET_VEHICLETYPE_VARIABLE, VAR_EMISSIONCLASS, typeID);
1852 }
1853 
1854 std::string
1855 TraCIAPI::VehicleTypeScope::getShapeClass(const std::string& typeID) const {
1856  return myParent.getString(CMD_GET_VEHICLETYPE_VARIABLE, VAR_SHAPECLASS, typeID);
1857 }
1858 
1859 double
1860 TraCIAPI::VehicleTypeScope::getMinGap(const std::string& typeID) const {
1861  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_MINGAP, typeID);
1862 }
1863 
1864 double
1865 TraCIAPI::VehicleTypeScope::getMinGapLat(const std::string& typeID) const {
1866  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_MINGAP_LAT, typeID);
1867 }
1868 
1869 double
1870 TraCIAPI::VehicleTypeScope::getMaxSpeedLat(const std::string& typeID) const {
1871  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_MAXSPEED_LAT, typeID);
1872 }
1873 
1874 std::string
1875 TraCIAPI::VehicleTypeScope::getLateralAlignment(const std::string& typeID) const {
1876  return myParent.getString(CMD_GET_VEHICLETYPE_VARIABLE, VAR_LATALIGNMENT, typeID);
1877 }
1878 
1879 double
1880 TraCIAPI::VehicleTypeScope::getWidth(const std::string& typeID) const {
1881  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_WIDTH, typeID);
1882 }
1883 
1884 double
1885 TraCIAPI::VehicleTypeScope::getHeight(const std::string& typeID) const {
1886  return myParent.getDouble(CMD_GET_VEHICLETYPE_VARIABLE, VAR_HEIGHT, typeID);
1887 }
1888 
1889 TraCIColor
1890 TraCIAPI::VehicleTypeScope::getColor(const std::string& typeID) const {
1891  return myParent.getColor(CMD_GET_VEHICLETYPE_VARIABLE, VAR_COLOR, typeID);
1892 }
1893 
1894 
1895 
1896 void
1897 TraCIAPI::VehicleTypeScope::setLength(const std::string& typeID, double length) const {
1898  tcpip::Storage content;
1899  content.writeUnsignedByte(TYPE_DOUBLE);
1900  content.writeDouble(length);
1901  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_LENGTH, typeID, content);
1902  tcpip::Storage inMsg;
1903  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1904 }
1905 
1906 void
1907 TraCIAPI::VehicleTypeScope::setMaxSpeed(const std::string& typeID, double speed) const {
1908  tcpip::Storage content;
1909  content.writeUnsignedByte(TYPE_DOUBLE);
1910  content.writeDouble(speed);
1911  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_MAXSPEED, typeID, content);
1912  tcpip::Storage inMsg;
1913  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1914 }
1915 
1916 void
1917 TraCIAPI::VehicleTypeScope::setVehicleClass(const std::string& typeID, const std::string& clazz) const {
1918  tcpip::Storage content;
1919  content.writeUnsignedByte(TYPE_STRING);
1920  content.writeString(clazz);
1921  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_VEHICLECLASS, typeID, content);
1922  tcpip::Storage inMsg;
1923  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1924 }
1925 
1926 void
1927 TraCIAPI::VehicleTypeScope::setSpeedFactor(const std::string& typeID, double factor) const {
1928  tcpip::Storage content;
1929  content.writeUnsignedByte(TYPE_DOUBLE);
1930  content.writeDouble(factor);
1931  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SPEED_FACTOR, typeID, content);
1932  tcpip::Storage inMsg;
1933  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1934 }
1935 
1936 void
1937 TraCIAPI::VehicleTypeScope::setSpeedDeviation(const std::string& typeID, double deviation) const {
1938  tcpip::Storage content;
1939  content.writeUnsignedByte(TYPE_DOUBLE);
1940  content.writeDouble(deviation);
1941  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SPEED_DEVIATION, typeID, content);
1942  tcpip::Storage inMsg;
1943  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1944 }
1945 
1946 
1947 void
1948 TraCIAPI::VehicleTypeScope::setEmissionClass(const std::string& typeID, const std::string& clazz) const {
1949  tcpip::Storage content;
1950  content.writeUnsignedByte(TYPE_STRING);
1951  content.writeString(clazz);
1952  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_EMISSIONCLASS, typeID, content);
1953  tcpip::Storage inMsg;
1954  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1955 }
1956 
1957 void
1958 TraCIAPI::VehicleTypeScope::setWidth(const std::string& typeID, double width) const {
1959  tcpip::Storage content;
1960  content.writeUnsignedByte(TYPE_DOUBLE);
1961  content.writeDouble(width);
1962  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_WIDTH, typeID, content);
1963  tcpip::Storage inMsg;
1964  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1965 }
1966 
1967 void
1968 TraCIAPI::VehicleTypeScope::setHeight(const std::string& typeID, double height) const {
1969  tcpip::Storage content;
1970  content.writeUnsignedByte(TYPE_DOUBLE);
1971  content.writeDouble(height);
1972  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_HEIGHT, typeID, content);
1973  tcpip::Storage inMsg;
1974  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1975 }
1976 
1977 void
1978 TraCIAPI::VehicleTypeScope::setMinGap(const std::string& typeID, double minGap) const {
1979  tcpip::Storage content;
1980  content.writeUnsignedByte(TYPE_DOUBLE);
1981  content.writeDouble(minGap);
1982  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_MINGAP, typeID, content);
1983  tcpip::Storage inMsg;
1984  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1985 }
1986 
1987 
1988 void
1989 TraCIAPI::VehicleTypeScope::setMinGapLat(const std::string& typeID, double minGapLat) const {
1990  tcpip::Storage content;
1991  content.writeUnsignedByte(TYPE_DOUBLE);
1992  content.writeDouble(minGapLat);
1993  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_MINGAP_LAT, typeID, content);
1994  tcpip::Storage inMsg;
1995  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1996 }
1997 
1998 void
1999 TraCIAPI::VehicleTypeScope::setMaxSpeedLat(const std::string& typeID, double speed) const {
2000  tcpip::Storage content;
2001  content.writeUnsignedByte(TYPE_DOUBLE);
2002  content.writeDouble(speed);
2003  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_MAXSPEED_LAT, typeID, content);
2004  tcpip::Storage inMsg;
2005  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
2006 }
2007 
2008 void
2009 TraCIAPI::VehicleTypeScope::setLateralAlignment(const std::string& typeID, const std::string& latAlignment) const {
2010  tcpip::Storage content;
2011  content.writeUnsignedByte(TYPE_STRING);
2012  content.writeString(latAlignment);
2013  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_LATALIGNMENT, typeID, content);
2014  tcpip::Storage inMsg;
2015  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
2016 }
2017 
2018 void
2019 TraCIAPI::VehicleTypeScope::copy(const std::string& origTypeID, const std::string& newTypeID) const {
2020  tcpip::Storage content;
2021  content.writeUnsignedByte(TYPE_STRING);
2022  content.writeString(newTypeID);
2023  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, COPY, origTypeID, content);
2024  tcpip::Storage inMsg;
2025  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
2026 }
2027 
2028 void
2029 TraCIAPI::VehicleTypeScope::setShapeClass(const std::string& typeID, const std::string& clazz) const {
2030  tcpip::Storage content;
2031  content.writeUnsignedByte(TYPE_STRING);
2032  content.writeString(clazz);
2033  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SHAPECLASS, typeID, content);
2034  tcpip::Storage inMsg;
2035  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
2036 }
2037 
2038 void
2039 TraCIAPI::VehicleTypeScope::setAccel(const std::string& typeID, double accel) const {
2040  tcpip::Storage content;
2041  content.writeUnsignedByte(TYPE_DOUBLE);
2042  content.writeDouble(accel);
2043  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_ACCEL, typeID, content);
2044  tcpip::Storage inMsg;
2045  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
2046 }
2047 
2048 void
2049 TraCIAPI::VehicleTypeScope::setDecel(const std::string& typeID, double decel) const {
2050  tcpip::Storage content;
2051  content.writeUnsignedByte(TYPE_DOUBLE);
2052  content.writeDouble(decel);
2053  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_DECEL, typeID, content);
2054  tcpip::Storage inMsg;
2055  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
2056 }
2057 
2058 void
2059 TraCIAPI::VehicleTypeScope::setEmergencyDecel(const std::string& typeID, double decel) const {
2060  tcpip::Storage content;
2061  content.writeUnsignedByte(TYPE_DOUBLE);
2062  content.writeDouble(decel);
2063  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_EMERGENCY_DECEL, typeID, content);
2064  tcpip::Storage inMsg;
2065  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
2066 }
2067 
2068 void
2069 TraCIAPI::VehicleTypeScope::setApparentDecel(const std::string& typeID, double decel) const {
2070  tcpip::Storage content;
2071  content.writeUnsignedByte(TYPE_DOUBLE);
2072  content.writeDouble(decel);
2073  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_APPARENT_DECEL, typeID, content);
2074  tcpip::Storage inMsg;
2075  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
2076 }
2077 
2078 void
2079 TraCIAPI::VehicleTypeScope::setImperfection(const std::string& typeID, double imperfection) const {
2080  tcpip::Storage content;
2081  content.writeUnsignedByte(TYPE_DOUBLE);
2082  content.writeDouble(imperfection);
2083  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_IMPERFECTION, typeID, content);
2084  tcpip::Storage inMsg;
2085  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
2086 }
2087 
2088 void
2089 TraCIAPI::VehicleTypeScope::setTau(const std::string& typeID, double tau) const {
2090  tcpip::Storage content;
2091  content.writeUnsignedByte(TYPE_DOUBLE);
2092  content.writeDouble(tau);
2093  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_TAU, typeID, content);
2094  tcpip::Storage inMsg;
2095  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
2096 }
2097 
2098 void
2099 TraCIAPI::VehicleTypeScope::setColor(const std::string& typeID, const TraCIColor& c) const {
2100  tcpip::Storage content;
2101  content.writeUnsignedByte(TYPE_COLOR);
2102  content.writeUnsignedByte(c.r);
2103  content.writeUnsignedByte(c.g);
2104  content.writeUnsignedByte(c.b);
2105  content.writeUnsignedByte(c.a);
2106  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_COLOR, typeID, content);
2107  tcpip::Storage inMsg;
2108  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
2109 }
2110 
2111 
2112 
2113 
2114 
2115 // ---------------------------------------------------------------------------
2116 // TraCIAPI::VehicleScope-methods
2117 // ---------------------------------------------------------------------------
2118 std::vector<std::string>
2120  return myParent.getStringVector(CMD_GET_VEHICLE_VARIABLE, ID_LIST, "");
2121 }
2122 
2123 int
2125  return myParent.getInt(CMD_GET_VEHICLE_VARIABLE, ID_COUNT, "");
2126 }
2127 
2128 double
2129 TraCIAPI::VehicleScope::getSpeed(const std::string& vehicleID) const {
2130  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_SPEED, vehicleID);
2131 }
2132 
2133 double
2134 TraCIAPI::VehicleScope::getMaxSpeed(const std::string& vehicleID) const {
2135  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_MAXSPEED, vehicleID);
2136 }
2137 
2139 TraCIAPI::VehicleScope::getPosition(const std::string& vehicleID) const {
2140  return myParent.getPosition(CMD_GET_VEHICLE_VARIABLE, VAR_POSITION, vehicleID);
2141 }
2142 
2144 TraCIAPI::VehicleScope::getPosition3D(const std::string& vehicleID) const {
2145  return myParent.getPosition3D(CMD_GET_VEHICLE_VARIABLE, VAR_POSITION3D, vehicleID);
2146 }
2147 
2148 double
2149 TraCIAPI::VehicleScope::getAngle(const std::string& vehicleID) const {
2150  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_ANGLE, vehicleID);
2151 }
2152 
2153 std::string
2154 TraCIAPI::VehicleScope::getRoadID(const std::string& vehicleID) const {
2155  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_ROAD_ID, vehicleID);
2156 }
2157 
2158 std::string
2159 TraCIAPI::VehicleScope::getLaneID(const std::string& vehicleID) const {
2160  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_LANE_ID, vehicleID);
2161 }
2162 
2163 int
2164 TraCIAPI::VehicleScope::getLaneIndex(const std::string& vehicleID) const {
2165  return myParent.getInt(CMD_GET_VEHICLE_VARIABLE, VAR_LANE_INDEX, vehicleID);
2166 }
2167 
2168 std::string
2169 TraCIAPI::VehicleScope::getTypeID(const std::string& vehicleID) const {
2170  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_TYPE, vehicleID);
2171 }
2172 
2173 std::string
2174 TraCIAPI::VehicleScope::getRouteID(const std::string& vehicleID) const {
2175  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_ROUTE_ID, vehicleID);
2176 }
2177 
2178 int
2179 TraCIAPI::VehicleScope::getRouteIndex(const std::string& vehicleID) const {
2180  return myParent.getInt(CMD_GET_VEHICLE_VARIABLE, VAR_ROUTE_INDEX, vehicleID);
2181 }
2182 
2183 std::vector<std::string>
2184 TraCIAPI::VehicleScope::getEdges(const std::string& vehicleID) const {
2185  return getRoute(vehicleID);
2186 }
2187 
2188 std::vector<std::string>
2189 TraCIAPI::VehicleScope::getRoute(const std::string& vehicleID) const {
2190  return myParent.getStringVector(CMD_GET_VEHICLE_VARIABLE, VAR_EDGES, vehicleID);
2191 }
2192 
2193 TraCIColor
2194 TraCIAPI::VehicleScope::getColor(const std::string& vehicleID) const {
2195  return myParent.getColor(CMD_GET_VEHICLE_VARIABLE, VAR_COLOR, vehicleID);
2196 }
2197 
2198 double
2199 TraCIAPI::VehicleScope::getLanePosition(const std::string& vehicleID) const {
2200  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_LANEPOSITION, vehicleID);
2201 }
2202 
2203 double
2204 TraCIAPI::VehicleScope::getDistance(const std::string& vehicleID) const {
2205  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_DISTANCE, vehicleID);
2206 }
2207 
2208 double
2209 TraCIAPI::VehicleScope::getLateralLanePosition(const std::string& vehicleID) const {
2210  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_LANEPOSITION_LAT, vehicleID);
2211 }
2212 
2213 double
2214 TraCIAPI::VehicleScope::getCO2Emission(const std::string& vehicleID) const {
2215  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_CO2EMISSION, vehicleID);
2216 }
2217 
2218 double
2219 TraCIAPI::VehicleScope::getCOEmission(const std::string& vehicleID) const {
2220  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_COEMISSION, vehicleID);
2221 }
2222 
2223 double
2224 TraCIAPI::VehicleScope::getHCEmission(const std::string& vehicleID) const {
2225  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_HCEMISSION, vehicleID);
2226 }
2227 
2228 double
2229 TraCIAPI::VehicleScope::getPMxEmission(const std::string& vehicleID) const {
2230  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_PMXEMISSION, vehicleID);
2231 }
2232 
2233 double
2234 TraCIAPI::VehicleScope::getNOxEmission(const std::string& vehicleID) const {
2235  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_NOXEMISSION, vehicleID);
2236 }
2237 
2238 double
2239 TraCIAPI::VehicleScope::getFuelConsumption(const std::string& vehicleID) const {
2240  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_FUELCONSUMPTION, vehicleID);
2241 }
2242 
2243 double
2244 TraCIAPI::VehicleScope::getNoiseEmission(const std::string& vehicleID) const {
2245  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_NOISEEMISSION, vehicleID);
2246 }
2247 
2248 double
2249 TraCIAPI::VehicleScope::getElectricityConsumption(const std::string& vehicleID) const {
2250  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_ELECTRICITYCONSUMPTION, vehicleID);
2251 }
2252 
2253 double
2254 TraCIAPI::VehicleScope::getWaitingTime(const std::string& vehID) const {
2255  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_WAITING_TIME, vehID);
2256 }
2257 
2258 int
2259 TraCIAPI::VehicleScope::getSpeedMode(const std::string& vehID) const {
2260  return myParent.getInt(CMD_GET_VEHICLE_VARIABLE, VAR_SPEEDSETMODE, vehID);
2261 }
2262 
2263 
2264 double
2265 TraCIAPI::VehicleScope::getSlope(const std::string& vehID) const {
2266  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_SLOPE, vehID);
2267 }
2268 
2269 
2270 std::string
2271 TraCIAPI::VehicleScope::getLine(const std::string& typeID) const {
2272  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_LINE, typeID);
2273 }
2274 
2275 std::vector<std::string>
2276 TraCIAPI::VehicleScope::getVia(const std::string& vehicleID) const {
2277  return myParent.getStringVector(CMD_GET_VEHICLE_VARIABLE, VAR_VIA, vehicleID);
2278 }
2279 
2280 std::string
2281 TraCIAPI::VehicleScope::getEmissionClass(const std::string& vehicleID) const {
2282  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_EMISSIONCLASS, vehicleID);
2283 }
2284 
2285 std::string
2286 TraCIAPI::VehicleScope::getShapeClass(const std::string& vehicleID) const {
2287  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_SHAPECLASS, vehicleID);
2288 }
2289 
2290 std::vector<TraCINextTLSData>
2291 TraCIAPI::VehicleScope::getNextTLS(const std::string& vehID) const {
2292  tcpip::Storage inMsg;
2293  myParent.send_commandGetVariable(CMD_GET_VEHICLE_VARIABLE, VAR_NEXT_TLS, vehID);
2294  myParent.processGET(inMsg, CMD_GET_VEHICLE_VARIABLE, TYPE_COMPOUND);
2295  std::vector<TraCINextTLSData> result;
2296  inMsg.readInt(); // components
2297  // number of items
2298  inMsg.readUnsignedByte();
2299  const int n = inMsg.readInt();
2300  for (int i = 0; i < n; ++i) {
2301  TraCINextTLSData d;
2302  inMsg.readUnsignedByte();
2303  d.id = inMsg.readString();
2304 
2305  inMsg.readUnsignedByte();
2306  d.tlIndex = inMsg.readInt();
2307 
2308  inMsg.readUnsignedByte();
2309  d.dist = inMsg.readDouble();
2310 
2311  inMsg.readUnsignedByte();
2312  d.state = (char)inMsg.readByte();
2313 
2314  result.push_back(d);
2315  }
2316  return result;
2317 }
2318 
2319 std::vector<TraCIBestLanesData>
2320 TraCIAPI::VehicleScope::getBestLanes(const std::string& vehicleID) const {
2321  tcpip::Storage inMsg;
2322  myParent.send_commandGetVariable(CMD_GET_VEHICLE_VARIABLE, VAR_BEST_LANES, vehicleID);
2323  myParent.processGET(inMsg, CMD_GET_VEHICLE_VARIABLE, TYPE_COMPOUND);
2324  inMsg.readInt();
2325  inMsg.readUnsignedByte();
2326 
2327  std::vector<TraCIBestLanesData> result;
2328  const int n = inMsg.readInt(); // number of following edge information
2329  for (int i = 0; i < n; ++i) {
2330  TraCIBestLanesData info;
2331  inMsg.readUnsignedByte();
2332  info.laneID = inMsg.readString();
2333 
2334  inMsg.readUnsignedByte();
2335  info.length = inMsg.readDouble();
2336 
2337  inMsg.readUnsignedByte();
2338  info.occupation = inMsg.readDouble();
2339 
2340  inMsg.readUnsignedByte();
2341  info.bestLaneOffset = inMsg.readByte();
2342 
2343  inMsg.readUnsignedByte();
2344  info.allowsContinuation = (inMsg.readUnsignedByte() == 1);
2345 
2346  inMsg.readUnsignedByte();
2347  const int m = inMsg.readInt();
2348  for (int i = 0; i < m; ++i) {
2349  info.continuationLanes.push_back(inMsg.readString());
2350  }
2351 
2352  result.push_back(info);
2353  }
2354  return result;
2355 }
2356 
2357 
2358 std::pair<std::string, double>
2359 TraCIAPI::VehicleScope::getLeader(const std::string& vehicleID, double dist) const {
2360  tcpip::Storage content;
2361  content.writeByte(TYPE_DOUBLE);
2362  content.writeDouble(dist);
2363  myParent.send_commandGetVariable(CMD_GET_VEHICLE_VARIABLE, VAR_LEADER, vehicleID, &content);
2364  tcpip::Storage inMsg;
2365  myParent.processGET(inMsg, CMD_GET_VEHICLE_VARIABLE, TYPE_COMPOUND);
2366  inMsg.readInt(); // components
2367  inMsg.readUnsignedByte();
2368  const std::string leaderID = inMsg.readString();
2369  inMsg.readUnsignedByte();
2370  const double gap = inMsg.readDouble();
2371  return make_pair(leaderID, gap);
2372 }
2373 
2374 
2375 int
2376 TraCIAPI::VehicleScope::getStopState(const std::string& vehicleID) const {
2377  return myParent.getUnsignedByte(CMD_GET_VEHICLE_VARIABLE, VAR_STOPSTATE, vehicleID);
2378 }
2379 
2380 double
2381 TraCIAPI::VehicleScope::getAccel(const std::string& vehicleID) const {
2382  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_ACCEL, vehicleID);
2383 }
2384 
2385 double
2386 TraCIAPI::VehicleScope::getDecel(const std::string& vehicleID) const {
2387  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_DECEL, vehicleID);
2388 }
2389 
2390 double
2391 TraCIAPI::VehicleScope::getTau(const std::string& vehicleID) const {
2392  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_TAU, vehicleID);
2393 }
2394 
2395 double
2396 TraCIAPI::VehicleScope::getImperfection(const std::string& vehicleID) const {
2397  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_IMPERFECTION, vehicleID);
2398 }
2399 
2400 double
2401 TraCIAPI::VehicleScope::getSpeedFactor(const std::string& vehicleID) const {
2402  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_SPEED_FACTOR, vehicleID);
2403 }
2404 
2405 double
2406 TraCIAPI::VehicleScope::getSpeedDeviation(const std::string& vehicleID) const {
2407  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_SPEED_DEVIATION, vehicleID);
2408 }
2409 
2410 std::string
2411 TraCIAPI::VehicleScope::getVehicleClass(const std::string& vehicleID) const {
2412  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_VEHICLECLASS, vehicleID);
2413 }
2414 
2415 double
2416 TraCIAPI::VehicleScope::getMinGap(const std::string& vehicleID) const {
2417  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_MINGAP, vehicleID);
2418 }
2419 
2420 double
2421 TraCIAPI::VehicleScope::getWidth(const std::string& vehicleID) const {
2422  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_WIDTH, vehicleID);
2423 }
2424 
2425 double
2426 TraCIAPI::VehicleScope::getLength(const std::string& vehicleID) const {
2427  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_LENGTH, vehicleID);
2428 }
2429 
2430 double
2431 TraCIAPI::VehicleScope::getHeight(const std::string& vehicleID) const {
2432  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_HEIGHT, vehicleID);
2433 }
2434 
2435 double
2436 TraCIAPI::VehicleScope::getAccumulatedWaitingTime(const std::string& vehicleID) const {
2437  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_ACCUMULATED_WAITING_TIME, vehicleID);
2438 }
2439 
2440 double
2441 TraCIAPI::VehicleScope::getAllowedSpeed(const std::string& vehicleID) const {
2442  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_ALLOWED_SPEED, vehicleID);
2443 }
2444 
2445 int
2446 TraCIAPI::VehicleScope::getPersonNumber(const std::string& vehicleID) const {
2447  return myParent.getInt(CMD_GET_VEHICLE_VARIABLE, VAR_PERSON_NUMBER, vehicleID);
2448 }
2449 
2450 double
2451 TraCIAPI::VehicleScope::getSpeedWithoutTraCI(const std::string& vehicleID) const {
2452  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_SPEED_WITHOUT_TRACI, vehicleID);
2453 }
2454 
2455 bool
2456 TraCIAPI::VehicleScope::isRouteValid(const std::string& vehicleID) const {
2457  return myParent.getUnsignedByte(CMD_GET_VEHICLE_VARIABLE, VAR_ROUTE_VALID, vehicleID) != 0;
2458 }
2459 
2460 double
2461 TraCIAPI::VehicleScope::getMaxSpeedLat(const std::string& vehicleID) const {
2462  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_MAXSPEED_LAT, vehicleID);
2463 }
2464 
2465 double
2466 TraCIAPI::VehicleScope::getMinGapLat(const std::string& vehicleID) const {
2467  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_MINGAP_LAT, vehicleID);
2468 }
2469 
2470 std::string
2471 TraCIAPI::VehicleScope::getLateralAlignment(const std::string& vehicleID) const {
2472  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_LATALIGNMENT, vehicleID);
2473 }
2474 
2475 void
2476 TraCIAPI::VehicleScope::add(const std::string& vehicleID,
2477  const std::string& routeID,
2478  const std::string& typeID,
2479  std::string depart,
2480  const std::string& departLane,
2481  const std::string& departPos,
2482  const std::string& departSpeed,
2483  const std::string& arrivalLane,
2484  const std::string& arrivalPos,
2485  const std::string& arrivalSpeed,
2486  const std::string& fromTaz,
2487  const std::string& toTaz,
2488  const std::string& line,
2489  int personCapacity,
2490  int personNumber) const {
2491 
2492  if (depart == "-1") {
2493  depart = toString(myParent.simulation.getCurrentTime() / 1000.0);
2494  }
2495  tcpip::Storage content;
2497  content.writeInt(14);
2498  content.writeUnsignedByte(TYPE_STRING);
2499  content.writeString(routeID);
2500  content.writeUnsignedByte(TYPE_STRING);
2501  content.writeString(typeID);
2502  content.writeUnsignedByte(TYPE_STRING);
2503  content.writeString(depart);
2504  content.writeUnsignedByte(TYPE_STRING);
2505  content.writeString(departLane);
2506  content.writeUnsignedByte(TYPE_STRING);
2507  content.writeString(departPos);
2508  content.writeUnsignedByte(TYPE_STRING);
2509  content.writeString(departSpeed);
2510 
2511  content.writeUnsignedByte(TYPE_STRING);
2512  content.writeString(arrivalLane);
2513  content.writeUnsignedByte(TYPE_STRING);
2514  content.writeString(arrivalPos);
2515  content.writeUnsignedByte(TYPE_STRING);
2516  content.writeString(arrivalSpeed);
2517 
2518  content.writeUnsignedByte(TYPE_STRING);
2519  content.writeString(fromTaz);
2520  content.writeUnsignedByte(TYPE_STRING);
2521  content.writeString(toTaz);
2522  content.writeUnsignedByte(TYPE_STRING);
2523  content.writeString(line);
2524 
2526  content.writeInt(personCapacity);
2528  content.writeInt(personNumber);
2529 
2530  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, ADD_FULL, vehicleID, content);
2531  tcpip::Storage inMsg;
2532  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2533 }
2534 
2535 
2536 void
2537 TraCIAPI::VehicleScope::remove(const std::string& vehicleID, char reason) const {
2538  tcpip::Storage content;
2539  content.writeUnsignedByte(TYPE_BYTE);
2540  content.writeUnsignedByte(reason);
2541  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, REMOVE, vehicleID, content);
2542  tcpip::Storage inMsg;
2543  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2544 
2545 }
2546 
2547 void
2548 TraCIAPI::VehicleScope::changeTarget(const std::string& vehicleID, const std::string& edgeID) const {
2549  tcpip::Storage content;
2550  content.writeUnsignedByte(TYPE_STRING);
2551  content.writeString(edgeID);
2552  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, CMD_CHANGETARGET, vehicleID, content);
2553  tcpip::Storage inMsg;
2554  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2555 }
2556 
2557 void
2558 TraCIAPI::VehicleScope::setRouteID(const std::string& vehicleID, const std::string& routeID) const {
2559  tcpip::Storage content;
2560  content.writeUnsignedByte(TYPE_STRING);
2561  content.writeString(routeID);
2562  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_ROUTE_ID, vehicleID, content);
2563  tcpip::Storage inMsg;
2564  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2565 }
2566 
2567 
2568 void
2569 TraCIAPI::VehicleScope::setRoute(const std::string& vehicleID, const std::vector<std::string>& edges) const {
2570  tcpip::Storage content;
2572  content.writeInt((int)edges.size());
2573  for (int i = 0; i < (int)edges.size(); ++i) {
2574  content.writeString(edges[i]);
2575  }
2576  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_ROUTE, vehicleID, content);
2577  tcpip::Storage inMsg;
2578  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2579 }
2580 
2581 
2582 void
2583 TraCIAPI::VehicleScope::rerouteTraveltime(const std::string& vehicleID, bool currentTravelTimes) const {
2584  if (currentTravelTimes) {
2585  // updated edge weights with current network traveltimes (at most once per simulation step)
2586  SUMOTime time = myParent.simulation.getCurrentTime();
2587  if (time != LAST_TRAVEL_TIME_UPDATE) {
2588  LAST_TRAVEL_TIME_UPDATE = time;
2589  }
2590  std::vector<std::string> edges = myParent.edge.getIDList();
2591  for (std::vector<std::string>::iterator it = edges.begin(); it != edges.end(); ++it) {
2592  myParent.edge.adaptTraveltime(*it, myParent.edge.getTraveltime(*it));
2593  }
2594  }
2595 
2596  tcpip::Storage content;
2598  content.writeInt(0);
2599  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, CMD_REROUTE_TRAVELTIME, vehicleID, content);
2600  tcpip::Storage inMsg;
2601  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2602 }
2603 
2604 void
2605 TraCIAPI::VehicleScope::moveTo(const std::string& vehicleID, const std::string& laneID, double position) const {
2606  tcpip::Storage content;
2608  content.writeInt(2);
2609  content.writeUnsignedByte(TYPE_STRING);
2610  content.writeString(laneID);
2611  content.writeUnsignedByte(TYPE_DOUBLE);
2612  content.writeDouble(position);
2613  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_MOVE_TO, vehicleID, content);
2614  tcpip::Storage inMsg;
2615  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2616 }
2617 
2618 void
2619 TraCIAPI::VehicleScope::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 {
2620  myParent.send_commandMoveToXY(vehicleID, edgeID, lane, x, y, angle, keepRoute);
2621  tcpip::Storage inMsg;
2622  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2623 }
2624 
2625 
2626 void
2627 TraCIAPI::VehicleScope::slowDown(const std::string& vehicleID, double speed, SUMOTime duration) const {
2628  tcpip::Storage content;
2630  content.writeInt(2);
2631  content.writeUnsignedByte(TYPE_DOUBLE);
2632  content.writeDouble(speed);
2634  content.writeInt((int)duration);
2635  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, CMD_SLOWDOWN, vehicleID, content);
2636  tcpip::Storage inMsg;
2637  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2638 }
2639 
2640 void
2641 TraCIAPI::VehicleScope::setSpeed(const std::string& vehicleID, double speed) const {
2642  tcpip::Storage content;
2643  content.writeUnsignedByte(TYPE_DOUBLE);
2644  content.writeDouble(speed);
2645  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_SPEED, vehicleID, content);
2646  tcpip::Storage inMsg;
2647  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2648 }
2649 
2650 void
2651 TraCIAPI::VehicleScope::setType(const std::string& vehicleID, const std::string& typeID) const {
2652  tcpip::Storage content;
2653  content.writeUnsignedByte(TYPE_STRING);
2654  content.writeString(typeID);
2655  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_TYPE, vehicleID, content);
2656  tcpip::Storage inMsg;
2657  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2658 }
2659 
2660 void
2661 TraCIAPI::VehicleScope::setMaxSpeed(const std::string& vehicleID, double speed) const {
2662  tcpip::Storage content;
2663  content.writeUnsignedByte(TYPE_DOUBLE);
2664  content.writeDouble(speed);
2665  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_MAXSPEED, vehicleID, content);
2666  tcpip::Storage inMsg;
2667  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2668 }
2669 
2670 void
2671 TraCIAPI::VehicleScope::setColor(const std::string& vehicleID, const TraCIColor& c) const {
2672  tcpip::Storage content;
2673  content.writeUnsignedByte(TYPE_COLOR);
2674  content.writeUnsignedByte(c.r);
2675  content.writeUnsignedByte(c.g);
2676  content.writeUnsignedByte(c.b);
2677  content.writeUnsignedByte(c.a);
2678  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_COLOR, vehicleID, content);
2679  tcpip::Storage inMsg;
2680  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2681 }
2682 
2683 void
2684 TraCIAPI::VehicleScope::setLine(const std::string& vehicleID, const std::string& line) const {
2685  tcpip::Storage content;
2686  content.writeUnsignedByte(TYPE_STRING);
2687  content.writeString(line);
2688  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_LINE, vehicleID, content);
2689  tcpip::Storage inMsg;
2690  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2691 }
2692 
2693 void
2694 TraCIAPI::VehicleScope::setVia(const std::string& vehicleID, const std::vector<std::string>& via) const {
2695  tcpip::Storage content;
2697  content.writeInt((int)via.size());
2698  for (int i = 0; i < (int)via.size(); ++i) {
2699  content.writeString(via[i]);
2700  }
2701  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_VIA, vehicleID, content);
2702  tcpip::Storage inMsg;
2703  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2704 }
2705 
2706 
2707 void
2708 TraCIAPI::VehicleScope::setShapeClass(const std::string& vehicleID, const std::string& clazz) const {
2709  tcpip::Storage content;
2710  content.writeUnsignedByte(TYPE_STRING);
2711  content.writeString(clazz);
2712  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_SHAPECLASS, vehicleID, content);
2713  tcpip::Storage inMsg;
2714  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2715 }
2716 
2717 
2718 void
2719 TraCIAPI::VehicleScope::setEmissionClass(const std::string& vehicleID, const std::string& clazz) const {
2720  tcpip::Storage content;
2721  content.writeUnsignedByte(TYPE_STRING);
2722  content.writeString(clazz);
2723  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_EMISSIONCLASS, vehicleID, content);
2724  tcpip::Storage inMsg;
2725  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2726 }
2727 
2728 
2729 // ---------------------------------------------------------------------------
2730 // // TraCIAPI::PersonScope-methods
2731 // ---------------------------------------------------------------------------
2732 
2733 std::vector<std::string>
2735  return myParent.getStringVector(CMD_GET_PERSON_VARIABLE, ID_LIST, "");
2736 }
2737 
2738 int
2740  return myParent.getInt(CMD_GET_PERSON_VARIABLE, ID_COUNT, "");
2741 }
2742 
2743 double
2744 TraCIAPI::PersonScope::getSpeed(const std::string& personID) const {
2745  return myParent.getDouble(CMD_GET_PERSON_VARIABLE, VAR_SPEED, personID);
2746 }
2747 
2749 TraCIAPI::PersonScope::getPosition(const std::string& personID) const {
2750  return myParent.getPosition(CMD_GET_PERSON_VARIABLE, VAR_POSITION, personID);
2751 }
2752 
2753 std::string
2754 TraCIAPI::PersonScope::getRoadID(const std::string& personID) const {
2755  return myParent.getString(CMD_GET_PERSON_VARIABLE, VAR_ROAD_ID, personID);
2756 }
2757 
2758 std::string
2759 TraCIAPI::PersonScope::getTypeID(const std::string& personID) const {
2760  return myParent.getString(CMD_GET_PERSON_VARIABLE, VAR_TYPE, personID);
2761 }
2762 
2763 double
2764 TraCIAPI::PersonScope::getWaitingTime(const std::string& personID) const {
2765  return myParent.getDouble(CMD_GET_PERSON_VARIABLE, VAR_WAITING_TIME, personID);
2766 }
2767 
2768 std::string
2769 TraCIAPI::PersonScope::getNextEdge(const std::string& personID) const {
2770  return myParent.getString(CMD_GET_PERSON_VARIABLE, VAR_NEXT_EDGE, personID);
2771 }
2772 
2773 
2774 std::string
2775 TraCIAPI::PersonScope::getVehicle(const std::string& personID) const {
2776  return myParent.getString(CMD_GET_PERSON_VARIABLE, VAR_VEHICLE, personID);
2777 }
2778 
2779 int
2780 TraCIAPI::PersonScope::getRemainingStages(const std::string& personID) const {
2781  return myParent.getInt(CMD_GET_PERSON_VARIABLE, VAR_STAGES_REMAINING, personID);
2782 }
2783 
2784 int
2785 TraCIAPI::PersonScope::getStage(const std::string& personID, int nextStageIndex) const {
2786  tcpip::Storage content;
2787  content.writeByte(TYPE_INTEGER);
2788  content.writeInt(nextStageIndex);
2789  return myParent.getInt(CMD_GET_PERSON_VARIABLE, VAR_STAGE, personID, &content);
2790 }
2791 
2792 std::vector<std::string>
2793 TraCIAPI::PersonScope::getEdges(const std::string& personID, int nextStageIndex) const {
2794  tcpip::Storage content;
2795  content.writeByte(TYPE_INTEGER);
2796  content.writeInt(nextStageIndex);
2797  return myParent.getStringVector(CMD_GET_PERSON_VARIABLE, VAR_EDGES, personID, &content);
2798 }
2799 
2800 void
2801 TraCIAPI::PersonScope::removeStages(const std::string& personID) const {
2802  // remove all stages after the current and then abort the current stage
2803  while (getRemainingStages(personID) > 1) {
2804  removeStage(personID, 1);
2805  }
2806  removeStage(personID, 0);
2807 }
2808 
2809 
2810 void
2811 TraCIAPI::PersonScope::rerouteTraveltime(const std::string& personID) const {
2812  tcpip::Storage content;
2814  content.writeInt(0);
2815  myParent.send_commandSetValue(CMD_SET_PERSON_VARIABLE, CMD_REROUTE_TRAVELTIME, personID, content);
2816  tcpip::Storage inMsg;
2817  myParent.check_resultState(inMsg, CMD_SET_PERSON_VARIABLE);
2818 }
2819 
2820 void
2821 TraCIAPI::PersonScope::add(const std::string& personID, const std::string& edgeID, double pos, double depart, const std::string typeID) {
2822  if (depart > 0) {
2823  depart *= 1000;
2824  }
2825  tcpip::Storage content;
2827  content.writeInt(4);
2828  content.writeUnsignedByte(TYPE_STRING);
2829  content.writeString(typeID);
2830  content.writeUnsignedByte(TYPE_STRING);
2831  content.writeString(edgeID);
2833  content.writeInt((int)depart);
2834  content.writeUnsignedByte(TYPE_DOUBLE);
2835  content.writeDouble(pos);
2836  myParent.send_commandSetValue(CMD_SET_PERSON_VARIABLE, ADD, personID, content);
2837  tcpip::Storage inMsg;
2838  myParent.check_resultState(inMsg, CMD_SET_PERSON_VARIABLE);
2839 }
2840 
2841 void
2842 TraCIAPI::PersonScope::appendWaitingStage(const std::string& personID, double duration, const std::string& description, const std::string& stopID) {
2843  duration *= 1000;
2844  tcpip::Storage content;
2846  content.writeInt(4);
2848  content.writeInt(STAGE_WAITING);
2850  content.writeInt((int)duration);
2851  content.writeUnsignedByte(TYPE_STRING);
2852  content.writeString(description);
2853  content.writeUnsignedByte(TYPE_STRING);
2854  content.writeString(stopID);
2855  myParent.send_commandSetValue(CMD_SET_PERSON_VARIABLE, APPEND_STAGE, personID, content);
2856  tcpip::Storage inMsg;
2857  myParent.check_resultState(inMsg, CMD_SET_PERSON_VARIABLE);
2858 }
2859 
2860 void
2861 TraCIAPI::PersonScope::appendWalkingStage(const std::string& personID, const std::vector<std::string>& edges, double arrivalPos, double duration, double speed, const std::string& stopID) {
2862  if (duration > 0) {
2863  duration *= 1000;
2864  }
2865  tcpip::Storage content;
2867  content.writeInt(6);
2869  content.writeInt(STAGE_WALKING);
2871  content.writeStringList(edges);
2872  content.writeUnsignedByte(TYPE_DOUBLE);
2873  content.writeDouble(arrivalPos);
2875  content.writeInt((int)duration);
2876  content.writeUnsignedByte(TYPE_DOUBLE);
2877  content.writeDouble(speed);
2878  content.writeUnsignedByte(TYPE_STRING);
2879  content.writeString(stopID);
2880  myParent.send_commandSetValue(CMD_SET_PERSON_VARIABLE, APPEND_STAGE, personID, content);
2881  tcpip::Storage inMsg;
2882  myParent.check_resultState(inMsg, CMD_SET_PERSON_VARIABLE);
2883 }
2884 
2885 void
2886 TraCIAPI::PersonScope::appendDrivingStage(const std::string& personID, const std::string& toEdge, const std::string& lines, const std::string& stopID) {
2887  tcpip::Storage content;
2889  content.writeInt(4);
2891  content.writeInt(STAGE_DRIVING);
2892  content.writeUnsignedByte(TYPE_STRING);
2893  content.writeString(toEdge);
2894  content.writeUnsignedByte(TYPE_STRING);
2895  content.writeString(lines);
2896  content.writeUnsignedByte(TYPE_STRING);
2897  content.writeString(stopID);
2898  myParent.send_commandSetValue(CMD_SET_PERSON_VARIABLE, APPEND_STAGE, personID, content);
2899  tcpip::Storage inMsg;
2900  myParent.check_resultState(inMsg, CMD_SET_PERSON_VARIABLE);
2901 }
2902 
2903 void
2904 TraCIAPI::PersonScope::removeStage(const std::string& personID, int nextStageIndex) const {
2905  tcpip::Storage content;
2906  content.writeByte(TYPE_INTEGER);
2907  content.writeInt(nextStageIndex);
2908  myParent.send_commandSetValue(CMD_SET_PERSON_VARIABLE, REMOVE_STAGE, personID, content);
2909  tcpip::Storage inMsg;
2910  myParent.check_resultState(inMsg, CMD_SET_PERSON_VARIABLE);
2911 }
2912 
2913 
2914 void
2915 TraCIAPI::PersonScope::setSpeed(const std::string& personID, double speed) const {
2916  tcpip::Storage content;
2917  content.writeUnsignedByte(TYPE_DOUBLE);
2918  content.writeDouble(speed);
2919  myParent.send_commandSetValue(CMD_SET_PERSON_VARIABLE, VAR_SPEED, personID, content);
2920  tcpip::Storage inMsg;
2921  myParent.check_resultState(inMsg, CMD_SET_PERSON_VARIABLE);
2922 }
2923 
2924 
2925 void
2926 TraCIAPI::PersonScope::setType(const std::string& personID, const std::string& typeID) const {
2927  tcpip::Storage content;
2928  content.writeUnsignedByte(TYPE_STRING);
2929  content.writeString(typeID);
2930  myParent.send_commandSetValue(CMD_SET_PERSON_VARIABLE, VAR_TYPE, personID, content);
2931  tcpip::Storage inMsg;
2932  myParent.check_resultState(inMsg, CMD_SET_PERSON_VARIABLE);
2933 }
2934 
2935 void
2936 TraCIAPI::PersonScope::setLength(const std::string& personID, double length) const {
2937  tcpip::Storage content;
2938  content.writeUnsignedByte(TYPE_DOUBLE);
2939  content.writeDouble(length);
2940  myParent.send_commandSetValue(CMD_SET_PERSON_VARIABLE, VAR_LENGTH, personID, content);
2941  tcpip::Storage inMsg;
2942  myParent.check_resultState(inMsg, CMD_SET_PERSON_VARIABLE);
2943 }
2944 
2945 
2946 void
2947 TraCIAPI::PersonScope::setWidth(const std::string& personID, double width) const {
2948  tcpip::Storage content;
2949  content.writeUnsignedByte(TYPE_DOUBLE);
2950  content.writeDouble(width);
2951  myParent.send_commandSetValue(CMD_SET_PERSON_VARIABLE, VAR_WIDTH, personID, content);
2952  tcpip::Storage inMsg;
2953  myParent.check_resultState(inMsg, CMD_SET_PERSON_VARIABLE);
2954 }
2955 
2956 void
2957 TraCIAPI::PersonScope::setHeight(const std::string& personID, double height) const {
2958  tcpip::Storage content;
2959  content.writeUnsignedByte(TYPE_DOUBLE);
2960  content.writeDouble(height);
2961  myParent.send_commandSetValue(CMD_SET_PERSON_VARIABLE, VAR_HEIGHT, personID, content);
2962  tcpip::Storage inMsg;
2963  myParent.check_resultState(inMsg, CMD_SET_PERSON_VARIABLE);
2964 }
2965 
2966 void
2967 TraCIAPI::PersonScope::setMinGap(const std::string& personID, double minGap) const {
2968  tcpip::Storage content;
2969  content.writeUnsignedByte(TYPE_DOUBLE);
2970  content.writeDouble(minGap);
2971  myParent.send_commandSetValue(CMD_SET_PERSON_VARIABLE, VAR_MINGAP, personID, content);
2972  tcpip::Storage inMsg;
2973  myParent.check_resultState(inMsg, CMD_SET_PERSON_VARIABLE);
2974 }
2975 
2976 
2977 void
2978 TraCIAPI::PersonScope::setColor(const std::string& personID, const TraCIColor& c) const {
2979  tcpip::Storage content;
2980  content.writeUnsignedByte(TYPE_COLOR);
2981  content.writeUnsignedByte(c.r);
2982  content.writeUnsignedByte(c.g);
2983  content.writeUnsignedByte(c.b);
2984  content.writeUnsignedByte(c.a);
2985  myParent.send_commandSetValue(CMD_SET_PERSON_VARIABLE, VAR_COLOR, personID, content);
2986  tcpip::Storage inMsg;
2987  myParent.check_resultState(inMsg, CMD_SET_PERSON_VARIABLE);
2988 }
2989 
2990 
2991 /****************************************************************************/
2992 
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1268
#define VAR_ROAD_ID
#define LAST_STEP_MEAN_SPEED
unsigned char g
Definition: TraCIDefs.h:79
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1615
TraCIColor color
Definition: TraCIDefs.h:100
double getNOxEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:1099
std::string getRouteID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2174
void setAccel(const std::string &typeID, double accel) const
Definition: TraCIAPI.cpp:2039
void setRoute(const std::string &vehicleID, const std::vector< std::string > &edge) const
Definition: TraCIAPI.cpp:2569
double getDecel(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2386
std::vector< libsumo::TraCILogic > getCompleteRedYellowGreenDefinition(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1625
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1461
int getStopState(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2376
std::string id
The id of the next tls.
Definition: TraCIDefs.h:181
double getFuelConsumption(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2239
void send_commandSetValue(int domID, int varID, const std::string &objID, tcpip::Storage &content) const
Sends a SetVariable request.
Definition: TraCIAPI.cpp:180
#define TL_NEXT_SWITCH
#define VAR_TIME_STEP
void remove(const std::string &vehicleID, char reason=REMOVE_VAPORIZED) const
Definition: TraCIAPI.cpp:2537
void setMinGapLat(const std::string &typeID, double minGapLat) const
Definition: TraCIAPI.cpp:1989
int getNextSwitch(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1707
void trackVehicle(const std::string &viewID, const std::string &vehID) const
Definition: TraCIAPI.cpp:863
double leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIDefs.h:173
void screenshot(const std::string &viewID, const std::string &filename) const
Definition: TraCIAPI.cpp:853
#define VAR_EMISSIONCLASS
void setWidth(const std::string &typeID, double width) const
Definition: TraCIAPI.cpp:1958
void setColor(const std::string &vehicleID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:2671
void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
Definition: TraCIAPI.cpp:2886
std::vector< std::string > getLastStepVehicleIDs(const std::string &laneID) const
Definition: TraCIAPI.cpp:1149
int getDepartedNumber() const
Definition: TraCIAPI.cpp:1504
#define VAR_VIA
tcpip::Socket * mySocket
The socket.
Definition: TraCIAPI.h:930
#define VAR_CO2EMISSION
void close()
ends the simulation and closes the connection
Definition: TraCIAPI.cpp:95
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:979
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:279
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
Definition: TraCIAPI.cpp:67
void setType(const std::string &poiID, const std::string &setType) const
Definition: TraCIAPI.cpp:1289
#define CMD_GET_TL_VARIABLE
double getMinGap(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2416
#define VAR_LENGTH
double dist
The distance to the tls.
Definition: TraCIDefs.h:185
void setLength(const std::string &personID, double length) const
Definition: TraCIAPI.cpp:2936
bool allowsContinuation
Whether this lane allows continuing the route.
Definition: TraCIDefs.h:201
void slowDown(const std::string &vehicleID, double speed, SUMOTime duration) const
Definition: TraCIAPI.cpp:2627
#define VAR_LATALIGNMENT
std::string typeID
Type of the vehicle in.
Definition: TraCIDefs.h:175
void changeTarget(const std::string &vehicleID, const std::string &edgeID) const
Definition: TraCIAPI.cpp:2548
void setOrder(int order)
set priority (execution order) for the client
Definition: TraCIAPI.cpp:80
void add(const std::string &polygonID, const libsumo::TraCIPositionVector &shape, const libsumo::TraCIColor &c, bool fill, const std::string &type, int layer) const
Definition: TraCIAPI.cpp:1418
#define CMD_GET_VEHICLE_VARIABLE
#define TYPE_COMPOUND
#define VAR_ACCUMULATED_WAITING_TIME
#define VAR_CURRENT_TRAVELTIME
#define LANE_LINKS
std::vector< libsumo::TraCIBestLanesData > getBestLanes(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2320
std::vector< libsumo::TraCIConnection > getLinks(const std::string &laneID) const
Definition: TraCIAPI.cpp:1019
void setZoom(const std::string &viewID, double zoom) const
Definition: TraCIAPI.cpp:810
int getLaneIndex(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2164
SUMOTime getCurrentTime() const
Definition: TraCIAPI.cpp:1489
#define CMD_CLOSE
void setVia(const std::string &vehicleID, const std::vector< std::string > &via) const
Definition: TraCIAPI.cpp:2694
double getCOEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2219
#define POSITION_2D
double getSpeedFactor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1805
#define VAR_POSITION
mirrors MSInductLoop::VehicleData
Definition: TraCIDefs.h:165
void setRouteID(const std::string &vehicleID, const std::string &routeID) const
Definition: TraCIAPI.cpp:2558
bool receiveExact(Storage &)
Receive a complete TraCI message from Socket::socket_.
Definition: socket.cpp:504
#define CMD_GET_INDUCTIONLOOP_VARIABLE
#define VAR_ROUTE
#define STAGE_WAITING
std::vector< std::string > getLastStepVehicleIDs(const std::string &detID) const
Definition: TraCIAPI.cpp:1253
#define VAR_SPEEDSETMODE
#define VAR_TAU
#define LANE_EDGE_ID
#define LANE_LINK_NUMBER
void setSpeedFactor(const std::string &typeID, double factor) const
Definition: TraCIAPI.cpp:1927
double getNoiseEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2244
#define LAST_STEP_VEHICLE_DATA
double getCO2Emission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:651
std::string getVehicleClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1845
libsumo::TraCIColor getColor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2194
double getNoiseEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:682
std::vector< libsumo::TraCINextTLSData > getNextTLS(const std::string &vehID) const
Definition: TraCIAPI.cpp:2291
std::string getLateralAlignment(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2471
double getWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2254
#define VAR_ALLOWED_SPEED
std::string getType(const std::string &poiID) const
Definition: TraCIAPI.cpp:1273
int getMinExpectedNumber() const
Definition: TraCIAPI.cpp:1554
#define TYPE_UBYTE
double getNOxEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2234
#define RTYPE_OK
std::string getTypeID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2169
int getArrivedNumber() const
Definition: TraCIAPI.cpp:1514
void send_commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *add=0) const
Sends a GetVariable request.
Definition: TraCIAPI.cpp:153
void setLength(const std::string &typeID, double length) const
Definition: TraCIAPI.cpp:1897
double getLastStepOccupancy(const std::string &edgeID) const
Definition: TraCIAPI.cpp:697
#define VAR_HEIGHT
double getTimeSinceDetection(const std::string &loopID) const
Definition: TraCIAPI.cpp:919
#define CMD_GET_LANEAREA_VARIABLE
double getEmergencyDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1825
LaneScope lane
Scope for interaction with lanes.
Definition: TraCIAPI.h:806
#define VAR_WAITING_TIME
#define CMD_GET_PERSON_VARIABLE
virtual double readDouble()
void setPhaseDuration(const std::string &tlsID, int phaseDuration) const
Definition: TraCIAPI.cpp:1743
#define VAR_TYPE
#define TYPE_POLYGON
double getPMxEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:1094
#define VAR_ROUTE_ID
int getIDCount() const
Definition: TraCIAPI.cpp:2124
double getMaxSpeedLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1870
#define VAR_VEHICLE
double getPMxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:667
#define VAR_VEHICLECLASS
void rerouteTraveltime(const std::string &vehicleID, bool currentTravelTimes=true) const
Definition: TraCIAPI.cpp:2583
A 3D-bounding box.
Definition: TraCIDefs.h:90
#define VAR_SPEED_FACTOR
#define VAR_COLOR
void setMaxSpeedLat(const std::string &typeID, double speed) const
Definition: TraCIAPI.cpp:1999
double getMaxSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2134
void setLine(const std::string &vehicleID, const std::string &line) const
Definition: TraCIAPI.cpp:2684
#define VAR_LOADED_VEHICLES_IDS
double occupation
The traffic density along length.
Definition: TraCIDefs.h:197
void setOffset(const std::string &viewID, double x, double y) const
Definition: TraCIAPI.cpp:819
int getLastStepVehicleNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:1139
std::vector< std::string > getDisallowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:1009
std::string getRoadID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2154
void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: TraCIAPI.cpp:2842
std::vector< std::string > getStartingTeleportIDList() const
Definition: TraCIAPI.cpp:1529
std::string laneID
The id of the lane.
Definition: TraCIDefs.h:193
void setImperfection(const std::string &typeID, double imperfection) const
Definition: TraCIAPI.cpp:2079
#define APPEND_STAGE
std::string getEdgeID(const std::string &laneID) const
Definition: TraCIAPI.cpp:1074
#define TYPE_COLOR
double getWidth(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2421
#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:604
void setAllowed(const std::string &laneID, const std::vector< std::string > &allowedClasses) const
Definition: TraCIAPI.cpp:1177
double getSpeed(const std::string &personID) const
Definition: TraCIAPI.cpp:2744
double getMaxSpeedLat(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2461
void send_commandSetOrder(int order) const
Sends a SetOrder command.
Definition: TraCIAPI.cpp:140
#define POSITION_3D
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1360
void setPhase(const std::string &tlsID, int index) const
Definition: TraCIAPI.cpp:1723
SubscribedContextValues mySubscribedContextValues
Definition: TraCIAPI.h:933
#define VAR_TELEPORT_STARTING_VEHICLES_IDS
void closeSocket()
Closes the connection.
Definition: TraCIAPI.cpp:105
std::string getEmissionClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1850
#define CMD_GET_POLYGON_VARIABLE
void simulationStep(SUMOTime time=0)
Advances by one step (or up to the given time)
Definition: TraCIAPI.cpp:583
std::string getNextEdge(const std::string &personID) const
Definition: TraCIAPI.cpp:2769
#define VAR_BEST_LANES
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1238
std::string getLaneID(const std::string &loopID) const
Definition: TraCIAPI.cpp:889
#define VAR_STAGE
virtual void writeUnsignedByte(int)
std::string getRedYellowGreenState(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1620
void setTau(const std::string &typeID, double tau) const
Definition: TraCIAPI.cpp:2089
#define CMD_SET_EDGE_VARIABLE
#define VAR_NEXT_TLS
#define CMD_SET_GUI_VARIABLE
#define TL_CURRENT_PHASE
void readVariableSubscription(tcpip::Storage &inMsg)
Definition: TraCIAPI.cpp:562
std::string getType(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1365
std::map< std::string, SubscribedValues > SubscribedContextValues
Definition: TraCIAPI.h:469
int getPhase(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1702
#define VAR_LOADED_VEHICLES_NUMBER
std::vector< TraCIPhase > phases
Definition: TraCIDefs.h:128
#define VAR_SHAPE
#define VAR_SPEED_DEVIATION
#define VAR_NOISEEMISSION
#define VAR_NEXT_EDGE
#define VAR_FUELCONSUMPTION
std::string getLine(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2271
double getDistance(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2204
#define CMD_GET_ROUTE_VARIABLE
#define REMOVE_STAGE
void removeStage(const std::string &personID, int nextStageIndex) const
Definition: TraCIAPI.cpp:2904
int getLastStepVehicleNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:1243
virtual void writeInt(int)
#define VAR_POSITION3D
int getLastStepHaltingNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:1144
std::vector< std::string > getEdges(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2184
std::vector< std::string > getEdges(const std::string &routeID) const
Definition: TraCIAPI.cpp:1466
libsumo::TraCIPosition getPosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2139
std::vector< std::string > getRoute(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2189
#define TYPE_STRING
virtual int readUnsignedByte()
#define TL_PHASE_DURATION
libsumo::TraCIPosition getPosition(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:439
std::string string
Definition: TraCIDefs.h:102
void connect()
Connects to host_:port_.
Definition: socket.cpp:331
double getLastStepOccupancy(const std::string &laneID) const
Definition: TraCIAPI.cpp:1124
#define LAST_STEP_LENGTH
std::vector< libsumo::TraCIVehicleData > getVehicleData(const std::string &loopID) const
Definition: TraCIAPI.cpp:924
#define VAR_NOXEMISSION
#define RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
#define TL_CURRENT_PROGRAM
double getMaxSpeed(const std::string &typeID) const
Definition: TraCIAPI.cpp:1800
#define CMD_SET_TL_VARIABLE
std::string getVehicleClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2411
libsumo::TraCIColor getColor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1890
double getImperfection(const std::string &typeID) const
Definition: TraCIAPI.cpp:1835
int getLastStepHaltingNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:1258
void setVehicleClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1917
void remove(const std::string &polygonID, int layer=0) const
Definition: TraCIAPI.cpp:1446
#define VAR_ANGLE
int bestLaneOffset
The offset of this lane from the best lane.
Definition: TraCIDefs.h:199
unsigned char b
Definition: TraCIDefs.h:79
#define CMD_GET_VEHICLETYPE_VARIABLE
const SubscribedValues & getSubscriptionResults() const
Definition: TraCIAPI.cpp:1580
double getLastStepMeanSpeed(const std::string &loopID) const
Definition: TraCIAPI.cpp:899
double getElectricityConsumption(const std::string &edgeID) const
Definition: TraCIAPI.cpp:687
double getTau(const std::string &typeID) const
Definition: TraCIAPI.cpp:1840
SubscribedValues mySubscribedValues
Definition: TraCIAPI.h:932
std::vector< std::string > getEndingTeleportIDList() const
Definition: TraCIAPI.cpp:1539
#define VAR_PERSON_NUMBER
#define LANE_ALLOWED
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:2619
void setEmissionClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1948
#define VAR_DEPARTED_VEHICLES_NUMBER
int getEndingTeleportNumber() const
Definition: TraCIAPI.cpp:1534
void rerouteTraveltime(const std::string &personID) const
Definition: TraCIAPI.cpp:2811
#define LAST_STEP_TIME_SINCE_DETECTION
#define CMD_SLOWDOWN
#define CMD_SET_ROUTE_VARIABLE
std::vector< std::string > getDepartedIDList() const
Definition: TraCIAPI.cpp:1509
#define TYPE_FLOAT
double getImperfection(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2396
double getLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:989
#define VAR_SHAPECLASS
void setCompleteRedYellowGreenDefinition(const std::string &tlsID, const libsumo::TraCILogic &logic) const
Definition: TraCIAPI.cpp:1753
#define VAR_MIN_EXPECTED_VEHICLES
libsumo::TraCIPosition getPosition(const std::string &personID) const
Definition: TraCIAPI.cpp:2749
#define VAR_SCREENSHOT
std::string getShapeClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2286
#define VAR_VIEW_BOUNDARY
std::string getTypeID(const std::string &personID) const
Definition: TraCIAPI.cpp:2759
#define CMD_LOAD
#define VAR_TRACK_VEHICLE
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:879
double getLastStepHaltingNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:717
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1227
void setHeight(const std::string &personID, double height) const
Definition: TraCIAPI.cpp:2957
std::vector< std::string > getVia(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2276
#define MOVE_TO_XY
std::map< std::string, TraCIValues > SubscribedValues
Definition: TraCIAPI.h:468
void setType(const std::string &vehicleID, const std::string &typeID) const
Definition: TraCIAPI.cpp:2651
#define STAGE_DRIVING
#define VAR_ACCEL
int getStartingTeleportNumber() const
Definition: TraCIAPI.cpp:1524
#define CMD_CHANGETARGET
void setBoundary(const std::string &viewID, double xmin, double ymin, double xmax, double ymax) const
Definition: TraCIAPI.cpp:840
virtual int readInt()
double getCO2Emission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2214
#define TL_COMPLETE_PROGRAM_RYG
std::vector< std::string > getLastStepVehicleIDs(const std::string &edgeID) const
Definition: TraCIAPI.cpp:722
double getHCEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2224
#define VAR_NET_BOUNDING_BOX
double getMinGap(const std::string &typeID) const
Definition: TraCIAPI.cpp:1860
#define CMD_GET_POI_VARIABLE
double getLastStepMeanSpeed(const std::string &edgeID) const
Definition: TraCIAPI.cpp:692
std::vector< std::string > getArrivedIDList() const
Definition: TraCIAPI.cpp:1519
double getHCEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:662
double getMaxSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:994
#define VAR_LANEPOSITION
double getFloat(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:387
~TraCIAPI()
Destructor.
Definition: TraCIAPI.cpp:61
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:201
#define TL_COMPLETE_DEFINITION_RYG
#define VAR_TELEPORT_STARTING_VEHICLES_NUMBER
double getAccumulatedWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2436
#define CMD_SET_VEHICLETYPE_VARIABLE
virtual void writeByte(int)
double getCOEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:1084
libsumo::TraCIColor getColor(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1375
std::map< int, libsumo::TraCIValue > TraCIValues
{object->{variable->value}}
Definition: TraCIAPI.h:467
double getWidth(const std::string &laneID) const
Definition: TraCIAPI.cpp:999
#define TYPE_BOUNDINGBOX
void send_commandSimulationStep(SUMOTime time) const
Sends a SimulationStep command.
Definition: TraCIAPI.cpp:116
double getLastStepMeanSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:1119
#define VAR_EMERGENCY_DECEL
double getLateralLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2209
void send_commandMoveToXY(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:259
unsigned char a
Definition: TraCIDefs.h:79
#define VAR_VIEW_SCHEMA
virtual void writeStringList(const std::vector< std::string > &s)
double getAngle(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2149
#define VAR_PMXEMISSION
void setLateralAlignment(const std::string &typeID, const std::string &latAlignment) const
Definition: TraCIAPI.cpp:2009
#define VAR_TELEPORT_ENDING_VEHICLES_IDS
#define CMD_GET_LANE_VARIABLE
int getInt(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:378
libsumo::TraCIPosition getPosition(const std::string &junctionID) const
Definition: TraCIAPI.cpp:968
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
Definition: TraCIAPI.cpp:1713
void add(const std::string &poiID, double x, double y, const libsumo::TraCIColor &c, const std::string &type, int layer) const
Definition: TraCIAPI.cpp:1323
int getIDCount() const
Definition: TraCIAPI.cpp:630
double getSpeedFactor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2401
#define CMD_SET_VEHICLE_VARIABLE
double getFuelConsumption(const std::string &laneID) const
Definition: TraCIAPI.cpp:1104
double length
Length of the vehicle.
Definition: TraCIDefs.h:169
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:2821
double getWaitingTime(const std::string &personID) const
Definition: TraCIAPI.cpp:2764
#define VAR_IMPERFECTION
std::string getRoadID(const std::string &personID) const
Definition: TraCIAPI.cpp:2754
std::string id
The id of the vehicle.
Definition: TraCIDefs.h:167
std::vector< std::string > getAllowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:1004
#define CMD_GET_SIM_VARIABLE
virtual std::string readString()
bool isRouteValid(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2456
#define CMD_GET_EDGE_VARIABLE
int getByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:369
TraCIPosition position
Definition: TraCIDefs.h:99
virtual unsigned int position() const
#define VAR_EDGES
static std::string toString(const T &t, std::streamsize accuracy=PRECISION)
Definition: TraCIAPI.h:917
#define CMD_GET_GUI_VARIABLE
std::string getEmissionClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2281
#define VAR_DEPARTED_VEHICLES_IDS
unsigned char r
Definition: TraCIDefs.h:79
#define CMD_SET_POI_VARIABLE
int getUnsignedByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:360
double getDouble(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:396
void add(const std::string &routeID, const std::vector< std::string > &edges) const
Definition: TraCIAPI.cpp:1472
#define VAR_EDGE_EFFORT
double getSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2129
double getPosition(const std::string &loopID) const
Definition: TraCIAPI.cpp:884
void setMaxSpeed(const std::string &typeID, double speed) const
Definition: TraCIAPI.cpp:1907
std::string getProgram(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1697
#define VAR_STOPSTATE
void setWidth(const std::string &personID, double width) const
Definition: TraCIAPI.cpp:2947
#define ADD
void setSpeed(const std::string &personID, double speed) const
Definition: TraCIAPI.cpp:2915
#define CMD_GET_JUNCTION_VARIABLE
#define VAR_SLOPE
#define VAR_DELTA_T
#define REMOVE
void setDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2049
virtual void writeStorage(tcpip::Storage &store)
#define VAR_LEADER
double getCO2Emission(const std::string &laneID) const
Definition: TraCIAPI.cpp:1079
#define TL_CONTROLLED_LINKS
double getElectricityConsumption(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2249
std::vector< std::string > getLastStepVehicleIDs(const std::string &loopID) const
Definition: TraCIAPI.cpp:904
void readContextSubscription(tcpip::Storage &inMsg)
Definition: TraCIAPI.cpp:569
#define COPY
libsumo::TraCIPositionVector getPolygon(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:421
void setShapeClass(const std::string &vehicleID, const std::string &clazz) const
Definition: TraCIAPI.cpp:2708
std::string getVehicle(const std::string &personID) const
Definition: TraCIAPI.cpp:2775
Definition: Edge.cpp:31
StorageType::size_type size() const
Definition: storage.h:115
void readVariables(tcpip::Storage &inMsg, const std::string &objectID, int variableCount, SubscribedValues &into)
Definition: TraCIAPI.cpp:501
void setColor(const std::string &poiID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:1310
#define VAR_SPEED
std::vector< std::string > getStringVector(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:474
void setSpeed(const std::string &vehicleID, double speed) const
Definition: TraCIAPI.cpp:2641
const SubscribedContextValues & getContextSubscriptionResults() const
Definition: TraCIAPI.cpp:1596
double getEffort(const std::string &edgeID, SUMOTime time) const
Definition: TraCIAPI.cpp:643
void setLength(const std::string &laneID, double length) const
Definition: TraCIAPI.cpp:1213
#define TL_RED_YELLOW_GREEN_STATE
#define STAGE_WALKING
int getRemainingStages(const std::string &personID) const
Definition: TraCIAPI.cpp:2780
void setProgram(const std::string &tlsID, const std::string &programID) const
Definition: TraCIAPI.cpp:1733
double getSlope(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2265
#define LAST_STEP_VEHICLE_NUMBER
void remove(const std::string &poiID, int layer=0) const
Definition: TraCIAPI.cpp:1345
#define VAR_EDGE_TRAVELTIME
#define VAR_VIEW_ZOOM
#define VAR_ARRIVED_VEHICLES_NUMBER
void setShape(const std::string &polygonID, const libsumo::TraCIPositionVector &shape) const
Definition: TraCIAPI.cpp:1391
void setSpeedDeviation(const std::string &typeID, double deviation) const
Definition: TraCIAPI.cpp:1937
double getHeight(const std::string &veihcleID) const
Definition: TraCIAPI.cpp:2431
#define CMD_SET_POLYGON_VARIABLE
double getTraveltime(const std::string &laneID) const
Definition: TraCIAPI.cpp:1134
#define VAR_COEMISSION
std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2359
virtual void writeString(const std::string &s)
#define RTYPE_NOTIMPLEMENTED
void setMinGap(const std::string &typeID, double minGap) const
Definition: TraCIAPI.cpp:1978
void setMaxSpeed(const std::string &vehicleID, double speed) const
Definition: TraCIAPI.cpp:2661
int getPersonNumber(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2446
void setColor(const std::string &personID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:2978
int getIDCount() const
Definition: TraCIAPI.cpp:2739
#define VAR_LANEPOSITION_LAT
void setPosition(const std::string &poiID, double x, double y) const
Definition: TraCIAPI.cpp:1299
#define LAST_STEP_VEHICLE_ID_LIST
void setDisallowed(const std::string &laneID, const std::vector< std::string > &disallowedClasses) const
Definition: TraCIAPI.cpp:1190
#define LANE_DISALLOWED
#define VAR_MOVE_TO
double getLastStepMeanLength(const std::string &loopID) const
Definition: TraCIAPI.cpp:914
#define TL_PROGRAM
void setColor(const std::string &typeID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:2099
void adaptTraveltime(const std::string &edgeID, double time, int beginSeconds=0, int endSeconds=std::numeric_limits< int >::max()) const
Definition: TraCIAPI.cpp:729
SUMOTime getSUMOTime(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:351
#define TYPE_DOUBLE
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:784
double getHeight(const std::string &typeID) const
Definition: TraCIAPI.cpp:1885
void processGET(tcpip::Storage &inMsg, int command, int expectedType, bool ignoreCommandId=false) const
Definition: TraCIAPI.cpp:342
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1664
libsumo::TraCIColor getColor(const std::string &poiID) const
Definition: TraCIAPI.cpp:1283
double getPMxEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2229
#define CMD_REROUTE_TRAVELTIME
int getLinkNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:1014
double getTau(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2391
void sendExact(const Storage &)
Definition: socket.cpp:405
virtual float readFloat()
char state
The current state of the tls.
Definition: TraCIDefs.h:187
#define TYPE_BYTE
#define CMD_SET_LANE_VARIABLE
#define VAR_ELECTRICITYCONSUMPTION
#define VAR_ROUTE_INDEX
void setColor(const std::string &polygonID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:1405
std::vector< std::string > getLoadedIDList() const
Definition: TraCIAPI.cpp:1499
libsumo::TraCIPosition getPosition3D(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2144
libsumo::TraCIBoundary getBoundary(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:804
#define CMD_GET_MULTIENTRYEXIT_VARIABLE
libsumo::TraCIBoundary getNetBoundary() const
Definition: TraCIAPI.cpp:1549
void setEmergencyDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2059
void send_commandClose() const
Sends a Close command.
Definition: TraCIAPI.cpp:129
libsumo::TraCIPosition getPosition3D(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:452
void setType(const std::string &polygonID, const std::string &setType) const
Definition: TraCIAPI.cpp:1381
std::string subID
Definition: TraCIDefs.h:125
void copy(const std::string &origTypeID, const std::string &newTypeID) const
Definition: TraCIAPI.cpp:2019
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:318
void setMaxSpeed(const std::string &edgeID, double speed) const
Definition: TraCIAPI.cpp:769
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:963
int getSpeedMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2259
int getIDCount() const
Definition: TraCIAPI.cpp:984
void setSchema(const std::string &viewID, const std::string &schemeName) const
Definition: TraCIAPI.cpp:830
double getSpeedDeviation(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2406
void setEffort(const std::string &edgeID, double effort, int beginSeconds=0, int endSeconds=std::numeric_limits< int >::max()) const
Definition: TraCIAPI.cpp:749
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1790
virtual void writeDouble(double)
double getTraveltime(const std::string &edgeID) const
Definition: TraCIAPI.cpp:707
libsumo::TraCIBoundary getBoundingBox(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:405
#define CMD_SETORDER
#define VAR_TELEPORT_ENDING_VEHICLES_NUMBER
void setMinGap(const std::string &personID, double minGap) const
Definition: TraCIAPI.cpp:2967
void subscribe(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, const std::vector< int > &vars) const
Definition: TraCIAPI.cpp:1559
double getLength(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2426
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:1570
std::string getLateralAlignment(const std::string &typeID) const
Definition: TraCIAPI.cpp:1875
double getLastStepOccupancy(const std::string &loopID) const
Definition: TraCIAPI.cpp:909
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:2861
double getApparentDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1830
std::string getShapeClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1855
double getMinGapLat(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2466
libsumo::TraCIColor getColor(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:488
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:625
libsumo::TraCIPositionVector getShape(const std::string &laneID) const
Definition: TraCIAPI.cpp:1069
double getSpeedDeviation(const std::string &typeID) const
Definition: TraCIAPI.cpp:1810
void setEmissionClass(const std::string &vehicleID, const std::string &clazz) const
Definition: TraCIAPI.cpp:2719
double getLastStepMeanSpeed(const std::string &detID) const
Definition: TraCIAPI.cpp:1248
void setHeight(const std::string &typeID, double height) const
Definition: TraCIAPI.cpp:1968
void setShapeClass(const std::string &typeID, const std::string &shapeClass) const
Definition: TraCIAPI.cpp:2029
#define VAR_APPARENT_DECEL
#define LAST_STEP_OCCUPANCY
std::string getLaneID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2159
double getFuelConsumption(const std::string &edgeID) const
Definition: TraCIAPI.cpp:677
#define VAR_SPEED_WITHOUT_TRACI
long long int SUMOTime
Definition: TraCIDefs.h:51
double length
The length than can be driven from that lane without lane change.
Definition: TraCIDefs.h:195
#define TL_CONTROLLED_LANES
std::string getString(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:465
double getElectricityConsumption(const std::string &laneID) const
Definition: TraCIAPI.cpp:1114
int getLastStepVehicleNumber(const std::string &loopID) const
Definition: TraCIAPI.cpp:894
#define VAR_MAXSPEED
SUMOTime getDeltaT() const
Definition: TraCIAPI.cpp:1544
#define VAR_MINGAP_LAT
double getDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1820
std::vector< std::vector< libsumo::TraCILink > > getControlledLinks(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1669
#define CMD_SET_PERSON_VARIABLE
#define VAR_DECEL
#define VAR_ROUTE_VALID
#define RESPONSE_SUBSCRIBE_PERSON_VARIABLE
int getStage(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:2785
double getLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2199
TraCIAPI()
Constructor.
Definition: TraCIAPI.cpp:49
double entryTime
Entry-time of the vehicle in [s].
Definition: TraCIDefs.h:171
#define ID_COUNT
#define VAR_LANE_INDEX
void removeStages(const std::string &personID) const
Definition: TraCIAPI.cpp:2801
libsumo::TraCIPositionVector getShape(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1370
double getAccel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1815
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:2476
#define VAR_LANE_ID
#define VAR_LINE
double getAccel(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2381
std::vector< std::string > stringList
Definition: TraCIDefs.h:103
double getAdaptedTraveltime(const std::string &edgeID, double time) const
Definition: TraCIAPI.cpp:635
A 3D-position.
Definition: TraCIDefs.h:71
int getRouteIndex(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2179
#define RTYPE_ERR
double getNOxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:672
#define TYPE_INTEGER
#define VAR_MINGAP
#define ID_LIST
double getZoom(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:789
void setType(const std::string &personID, const std::string &typeID) const
Definition: TraCIAPI.cpp:2926
#define ADD_FULL
double getHCEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:1089
void moveTo(const std::string &vehicleID, const std::string &laneID, double position) const
Definition: TraCIAPI.cpp:2605
#define VAR_STAGES_REMAINING
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:229
std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:2793
#define TL_PHASE_INDEX
double getAllowedSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2441
std::vector< std::string > getInternalFoes(const std::string &laneID) const
Definition: TraCIAPI.cpp:1171
int tlIndex
The tls index of the controlled link.
Definition: TraCIDefs.h:183
#define VAR_ARRIVED_VEHICLES_IDS
void setMaxSpeed(const std::string &laneID, double speed) const
Definition: TraCIAPI.cpp:1203
A list of positions.
double getLength(const std::string &typeID) const
Definition: TraCIAPI.cpp:1795
#define VAR_VIEW_OFFSET
std::vector< std::string > getFoes(const std::string &laneID, const std::string &toLaneID) const
Definition: TraCIAPI.cpp:1155
double getLastStepLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:1129
double getWidth(const std::string &typeID) const
Definition: TraCIAPI.cpp:1880
#define VAR_MAXSPEED_LAT
int getLastStepVehicleNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:712
double getMinGapLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1865
#define LAST_STEP_VEHICLE_HALTING_NUMBER
#define VAR_DISTANCE
#define CMD_SIMSTEP
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
Definition: TraCIDefs.h:203
virtual int readByte()
#define VAR_HCEMISSION
void close()
Definition: socket.cpp:356
libsumo::TraCIPosition getPosition(const std::string &poiID) const
Definition: TraCIAPI.cpp:1278
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:2734
#define VAR_FOES
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:2119
double getCOEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:657
#define VAR_WIDTH
double getNoiseEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:1109
std::string getSchema(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:799
double getLastStepLength(const std::string &edgeID) const
Definition: TraCIAPI.cpp:702
libsumo::TraCIPosition getOffset(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:794
void setApparentDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2069
double getSpeedWithoutTraCI(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2451