Eclipse 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-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
21 // C++ TraCI client API implementation
22 /****************************************************************************/
23 #include "TraCIAPI.h"
24 
25 
26 // ===========================================================================
27 // member definitions
28 // ===========================================================================
29 
30 // ---------------------------------------------------------------------------
31 // TraCIAPI-methods
32 // ---------------------------------------------------------------------------
33 #ifdef _MSC_VER
34 /* Disable "decorated name length exceeded, name was truncated" warnings for the whole file. */
35 #pragma warning(disable: 4503)
36 #pragma warning(push)
37 /* Disable warning about using "this" in the constructor */
38 #pragma warning(disable: 4355)
39 #endif
41  : edge(*this), gui(*this), inductionloop(*this),
42  junction(*this), lane(*this), lanearea(*this), multientryexit(*this),
43  person(*this), poi(*this), polygon(*this),
44  rerouter(*this), route(*this), routeprobe(*this),
45  simulation(*this), trafficlights(*this),
46  vehicle(*this), vehicletype(*this),
47  mySocket(nullptr) {
64 }
65 #ifdef _MSC_VER
66 #pragma warning(pop)
67 #endif
68 
69 
71  delete mySocket;
72 }
73 
74 
75 void
76 TraCIAPI::connect(const std::string& host, int port) {
77  mySocket = new tcpip::Socket(host, port);
78  try {
79  mySocket->connect();
80  } catch (tcpip::SocketException&) {
81  delete mySocket;
82  mySocket = nullptr;
83  throw;
84  }
85 }
86 
87 
88 void
89 TraCIAPI::setOrder(int order) {
90  tcpip::Storage outMsg;
91  // command length
92  outMsg.writeUnsignedByte(1 + 1 + 4);
93  // command id
95  outMsg.writeInt(order);
96  // send request message
97  mySocket->sendExact(outMsg);
98  tcpip::Storage inMsg;
100 }
101 
102 
103 void
106  tcpip::Storage inMsg;
107  std::string acknowledgement;
108  check_resultState(inMsg, libsumo::CMD_CLOSE, false, &acknowledgement);
109  closeSocket();
110 }
111 
112 
113 void
115  if (mySocket == nullptr) {
116  return;
117  }
118  mySocket->close();
119  delete mySocket;
120  mySocket = nullptr;
121 }
122 
123 
124 void
126  tcpip::Storage outMsg;
127  // command length
128  outMsg.writeUnsignedByte(1 + 1 + 8);
129  // command id
131  outMsg.writeDouble(time);
132  // send request message
133  mySocket->sendExact(outMsg);
134 }
135 
136 
137 void
139  tcpip::Storage outMsg;
140  // command length
141  outMsg.writeUnsignedByte(1 + 1);
142  // command id
144  mySocket->sendExact(outMsg);
145 }
146 
147 
148 void
150  tcpip::Storage outMsg;
151  // command length
152  outMsg.writeUnsignedByte(1 + 1 + 4);
153  // command id
155  // client index
156  outMsg.writeInt(order);
157  mySocket->sendExact(outMsg);
158 }
159 
160 
161 void
162 TraCIAPI::createCommand(int cmdID, int varID, const std::string& objID, tcpip::Storage* add) const {
163  myOutput.reset();
164  // command length
165  int length = 1 + 1 + 1 + 4 + (int) objID.length();
166  if (add != nullptr) {
167  length += (int)add->size();
168  }
169  if (length <= 255) {
170  myOutput.writeUnsignedByte(length);
171  } else {
173  myOutput.writeInt(length + 4);
174  }
177  myOutput.writeString(objID);
178  // additional values
179  if (add != nullptr) {
180  myOutput.writeStorage(*add);
181  }
182 }
183 
184 
185 void
186 TraCIAPI::createFilterCommand(int cmdID, int varID, tcpip::Storage* add) const {
187  myOutput.reset();
188  // command length
189  int length = 1 + 1 + 1;
190  if (add != nullptr) {
191  length += (int)add->size();
192  }
193  if (length <= 255) {
194  myOutput.writeUnsignedByte(length);
195  } else {
197  myOutput.writeInt(length + 4);
198  }
201  // additional values
202  if (add != nullptr) {
203  myOutput.writeStorage(*add);
204  }
205 }
206 
207 
208 void
209 TraCIAPI::send_commandSubscribeObjectVariable(int domID, const std::string& objID, double beginTime, double endTime,
210  const std::vector<int>& vars) const {
211  if (mySocket == nullptr) {
212  throw tcpip::SocketException("Socket is not initialised");
213  }
214  tcpip::Storage outMsg;
215  // command length (domID, objID, beginTime, endTime, length, vars)
216  int varNo = (int) vars.size();
217  outMsg.writeUnsignedByte(0);
218  outMsg.writeInt(5 + 1 + 8 + 8 + 4 + (int) objID.length() + 1 + varNo);
219  // command id
220  outMsg.writeUnsignedByte(domID);
221  // time
222  outMsg.writeDouble(beginTime);
223  outMsg.writeDouble(endTime);
224  // object id
225  outMsg.writeString(objID);
226  // command id
227  outMsg.writeUnsignedByte((int)vars.size());
228  for (int i = 0; i < varNo; ++i) {
229  outMsg.writeUnsignedByte(vars[i]);
230  }
231  // send message
232  mySocket->sendExact(outMsg);
233 }
234 
235 
236 void
237 TraCIAPI::send_commandSubscribeObjectContext(int domID, const std::string& objID, double beginTime, double endTime,
238  int domain, double range, const std::vector<int>& vars) const {
239  if (mySocket == nullptr) {
240  throw tcpip::SocketException("Socket is not initialised");
241  }
242  tcpip::Storage outMsg;
243  // command length (domID, objID, beginTime, endTime, length, vars)
244  int varNo = (int) vars.size();
245  outMsg.writeUnsignedByte(0);
246  outMsg.writeInt(5 + 1 + 8 + 8 + 4 + (int) objID.length() + 1 + 8 + 1 + varNo);
247  // command id
248  outMsg.writeUnsignedByte(domID);
249  // time
250  outMsg.writeDouble(beginTime);
251  outMsg.writeDouble(endTime);
252  // object id
253  outMsg.writeString(objID);
254  // domain and range
255  outMsg.writeUnsignedByte(domain);
256  outMsg.writeDouble(range);
257  // command id
258  outMsg.writeUnsignedByte((int)vars.size());
259  for (int i = 0; i < varNo; ++i) {
260  outMsg.writeUnsignedByte(vars[i]);
261  }
262  // send message
263  mySocket->sendExact(outMsg);
264 }
265 
266 
267 void
268 TraCIAPI::check_resultState(tcpip::Storage& inMsg, int command, bool ignoreCommandId, std::string* acknowledgement) const {
269  mySocket->receiveExact(inMsg);
270  int cmdLength;
271  int cmdId;
272  int resultType;
273  int cmdStart;
274  std::string msg;
275  try {
276  cmdStart = inMsg.position();
277  cmdLength = inMsg.readUnsignedByte();
278  cmdId = inMsg.readUnsignedByte();
279  if (command != cmdId && !ignoreCommandId) {
280  throw libsumo::TraCIException("#Error: received status response to command: " + toString(cmdId) + " but expected: " + toString(command));
281  }
282  resultType = inMsg.readUnsignedByte();
283  msg = inMsg.readString();
284  } catch (std::invalid_argument&) {
285  throw libsumo::TraCIException("#Error: an exception was thrown while reading result state message");
286  }
287  switch (resultType) {
288  case libsumo::RTYPE_ERR:
289  throw libsumo::TraCIException(".. Answered with error to command (" + toString(command) + "), [description: " + msg + "]");
291  throw libsumo::TraCIException(".. Sent command is not implemented (" + toString(command) + "), [description: " + msg + "]");
292  case libsumo::RTYPE_OK:
293  if (acknowledgement != nullptr) {
294  (*acknowledgement) = ".. Command acknowledged (" + toString(command) + "), [description: " + msg + "]";
295  }
296  break;
297  default:
298  throw libsumo::TraCIException(".. Answered with unknown result code(" + toString(resultType) + ") to command(" + toString(command) + "), [description: " + msg + "]");
299  }
300  if ((cmdStart + cmdLength) != (int) inMsg.position()) {
301  throw libsumo::TraCIException("#Error: command at position " + toString(cmdStart) + " has wrong length");
302  }
303 }
304 
305 
306 int
307 TraCIAPI::check_commandGetResult(tcpip::Storage& inMsg, int command, int expectedType, bool ignoreCommandId) const {
308  inMsg.position(); // respStart
309  int length = inMsg.readUnsignedByte();
310  if (length == 0) {
311  length = inMsg.readInt();
312  }
313  int cmdId = inMsg.readUnsignedByte();
314  if (!ignoreCommandId && cmdId != (command + 0x10)) {
315  throw libsumo::TraCIException("#Error: received response with command id: " + toString(cmdId) + "but expected: " + toString(command + 0x10));
316  }
317  if (expectedType >= 0) {
318  // not called from the TraCITestClient but from within the TraCIAPI
319  inMsg.readUnsignedByte(); // variableID
320  inMsg.readString(); // objectID
321  int valueDataType = inMsg.readUnsignedByte();
322  if (valueDataType != expectedType) {
323  throw libsumo::TraCIException("Expected " + toString(expectedType) + " but got " + toString(valueDataType));
324  }
325  }
326  return cmdId;
327 }
328 
329 
330 bool
331 TraCIAPI::processGet(int command, int expectedType, bool ignoreCommandId) {
332  if (mySocket != nullptr) {
334  myInput.reset();
335  check_resultState(myInput, command, ignoreCommandId);
336  check_commandGetResult(myInput, command, expectedType, ignoreCommandId);
337  return true;
338  }
339  return false;
340 }
341 
342 
343 bool
344 TraCIAPI::processSet(int command) {
345  if (mySocket != nullptr) {
347  myInput.reset();
348  check_resultState(myInput, command);
349  return true;
350  }
351  return false;
352 }
353 
354 
355 void
356 TraCIAPI::readVariables(tcpip::Storage& inMsg, const std::string& objectID, int variableCount, libsumo::SubscriptionResults& into) {
357  while (variableCount > 0) {
358 
359  const int variableID = inMsg.readUnsignedByte();
360  const int status = inMsg.readUnsignedByte();
361  const int type = inMsg.readUnsignedByte();
362 
363  if (status == libsumo::RTYPE_OK) {
364  switch (type) {
366  into[objectID][variableID] = std::make_shared<libsumo::TraCIDouble>(inMsg.readDouble());
367  break;
369  into[objectID][variableID] = std::make_shared<libsumo::TraCIString>(inMsg.readString());
370  break;
371  case libsumo::POSITION_2D: {
372  auto p = std::make_shared<libsumo::TraCIPosition>();
373  p->x = inMsg.readDouble();
374  p->y = inMsg.readDouble();
375  p->z = 0.;
376  into[objectID][variableID] = p;
377  break;
378  }
379  case libsumo::POSITION_3D: {
380  auto p = std::make_shared<libsumo::TraCIPosition>();
381  p->x = inMsg.readDouble();
382  p->y = inMsg.readDouble();
383  p->z = inMsg.readDouble();
384  into[objectID][variableID] = p;
385  break;
386  }
387  case libsumo::TYPE_COLOR: {
388  auto c = std::make_shared<libsumo::TraCIColor>();
389  c->r = (unsigned char)inMsg.readUnsignedByte();
390  c->g = (unsigned char)inMsg.readUnsignedByte();
391  c->b = (unsigned char)inMsg.readUnsignedByte();
392  c->a = (unsigned char)inMsg.readUnsignedByte();
393  into[objectID][variableID] = c;
394  break;
395  }
397  into[objectID][variableID] = std::make_shared<libsumo::TraCIInt>(inMsg.readInt());
398  break;
400  auto sl = std::make_shared<libsumo::TraCIStringList>();
401  int n = inMsg.readInt();
402  for (int i = 0; i < n; ++i) {
403  sl->value.push_back(inMsg.readString());
404  }
405  into[objectID][variableID] = sl;
406  }
407  break;
408 
409  // TODO Other data types
410 
411  default:
412  throw libsumo::TraCIException("Unimplemented subscription type: " + toString(type));
413  }
414  } else {
415  throw libsumo::TraCIException("Subscription response error: variableID=" + toString(variableID) + " status=" + toString(status));
416  }
417 
418  variableCount--;
419  }
420 }
421 
422 
423 void
425  const std::string objectID = inMsg.readString();
426  const int variableCount = inMsg.readUnsignedByte();
427  readVariables(inMsg, objectID, variableCount, myDomains[cmdId]->getModifiableSubscriptionResults());
428 }
429 
430 
431 void
433  const std::string contextID = inMsg.readString();
434  inMsg.readUnsignedByte(); // context domain
435  const int variableCount = inMsg.readUnsignedByte();
436  int numObjects = inMsg.readInt();
437 
438  while (numObjects > 0) {
439  std::string objectID = inMsg.readString();
440  readVariables(inMsg, objectID, variableCount, myDomains[cmdId]->getModifiableContextSubscriptionResults(contextID));
441  numObjects--;
442  }
443 }
444 
445 
446 void
449  tcpip::Storage inMsg;
451 
452  for (auto it : myDomains) {
453  it.second->clearSubscriptionResults();
454  }
455  int numSubs = inMsg.readInt();
456  while (numSubs > 0) {
457  int cmdId = check_commandGetResult(inMsg, 0, -1, true);
459  readVariableSubscription(cmdId, inMsg);
460  } else {
461  readContextSubscription(cmdId + 0x50, inMsg);
462  }
463  numSubs--;
464  }
465 }
466 
467 
468 void
469 TraCIAPI::load(const std::vector<std::string>& args) {
470  int numChars = 0;
471  for (int i = 0; i < (int)args.size(); ++i) {
472  numChars += (int)args[i].size();
473  }
474  tcpip::Storage content;
475  content.writeUnsignedByte(0);
476  content.writeInt(1 + 4 + 1 + 1 + 4 + numChars + 4 * (int)args.size());
479  content.writeStringList(args);
480  mySocket->sendExact(content);
481  tcpip::Storage inMsg;
483 }
484 
485 
486 std::pair<int, std::string>
488  tcpip::Storage content;
489  content.writeUnsignedByte(2);
491  mySocket->sendExact(content);
492  tcpip::Storage inMsg;
494  inMsg.readUnsignedByte(); // msg length
495  inMsg.readUnsignedByte(); // libsumo::CMD_GETVERSION again, see #7284
496  const int traciVersion = inMsg.readInt(); // to fix evaluation order
497  return std::make_pair(traciVersion, inMsg.readString());
498 }
499 
500 
501 // ---------------------------------------------------------------------------
502 // TraCIAPI::EdgeScope-methods
503 // ---------------------------------------------------------------------------
504 double
505 TraCIAPI::EdgeScope::getAdaptedTraveltime(const std::string& edgeID, double time) const {
506  tcpip::Storage content;
508  content.writeDouble(time);
509  return getDouble(libsumo::VAR_EDGE_TRAVELTIME, edgeID, &content);
510 }
511 
512 double
513 TraCIAPI::EdgeScope::getEffort(const std::string& edgeID, double time) const {
514  tcpip::Storage content;
516  content.writeDouble(time);
517  return getDouble(libsumo::VAR_EDGE_EFFORT, edgeID, &content);
518 }
519 
520 double
521 TraCIAPI::EdgeScope::getCO2Emission(const std::string& edgeID) const {
522  return getDouble(libsumo::VAR_CO2EMISSION, edgeID);
523 }
524 
525 
526 double
527 TraCIAPI::EdgeScope::getCOEmission(const std::string& edgeID) const {
528  return getDouble(libsumo::VAR_COEMISSION, edgeID);
529 }
530 
531 double
532 TraCIAPI::EdgeScope::getHCEmission(const std::string& edgeID) const {
533  return getDouble(libsumo::VAR_HCEMISSION, edgeID);
534 }
535 
536 double
537 TraCIAPI::EdgeScope::getPMxEmission(const std::string& edgeID) const {
538  return getDouble(libsumo::VAR_PMXEMISSION, edgeID);
539 }
540 
541 double
542 TraCIAPI::EdgeScope::getNOxEmission(const std::string& edgeID) const {
543  return getDouble(libsumo::VAR_NOXEMISSION, edgeID);
544 }
545 
546 double
547 TraCIAPI::EdgeScope::getFuelConsumption(const std::string& edgeID) const {
548  return getDouble(libsumo::VAR_FUELCONSUMPTION, edgeID);
549 }
550 
551 double
552 TraCIAPI::EdgeScope::getNoiseEmission(const std::string& edgeID) const {
553  return getDouble(libsumo::VAR_NOISEEMISSION, edgeID);
554 }
555 
556 double
557 TraCIAPI::EdgeScope::getElectricityConsumption(const std::string& edgeID) const {
558  return getDouble(libsumo::VAR_ELECTRICITYCONSUMPTION, edgeID);
559 }
560 
561 double
562 TraCIAPI::EdgeScope::getLastStepMeanSpeed(const std::string& edgeID) const {
563  return getDouble(libsumo::LAST_STEP_MEAN_SPEED, edgeID);
564 }
565 
566 double
567 TraCIAPI::EdgeScope::getLastStepOccupancy(const std::string& edgeID) const {
568  return getDouble(libsumo::LAST_STEP_OCCUPANCY, edgeID);
569 }
570 
571 double
572 TraCIAPI::EdgeScope::getLastStepLength(const std::string& edgeID) const {
573  return getDouble(libsumo::LAST_STEP_LENGTH, edgeID);
574 }
575 
576 double
577 TraCIAPI::EdgeScope::getTraveltime(const std::string& edgeID) const {
578  return getDouble(libsumo::VAR_CURRENT_TRAVELTIME, edgeID);
579 }
580 
581 int
582 TraCIAPI::EdgeScope::getLastStepVehicleNumber(const std::string& edgeID) const {
583  return getInt(libsumo::LAST_STEP_VEHICLE_NUMBER, edgeID);
584 }
585 
586 double
587 TraCIAPI::EdgeScope::getLastStepHaltingNumber(const std::string& edgeID) const {
588  return getInt(libsumo::LAST_STEP_VEHICLE_HALTING_NUMBER, edgeID);
589 }
590 
591 std::vector<std::string>
592 TraCIAPI::EdgeScope::getLastStepVehicleIDs(const std::string& edgeID) const {
593  return getStringVector(libsumo::LAST_STEP_VEHICLE_ID_LIST, edgeID);
594 }
595 
596 
597 int
598 TraCIAPI::EdgeScope::getLaneNumber(const std::string& edgeID) const {
599  return getInt(libsumo::VAR_LANE_INDEX, edgeID);
600 }
601 
602 
603 std::string
604 TraCIAPI::EdgeScope::getStreetName(const std::string& edgeID) const {
605  return getString(libsumo::VAR_NAME, edgeID);
606 }
607 
608 
609 void
610 TraCIAPI::EdgeScope::adaptTraveltime(const std::string& edgeID, double time, double beginSeconds, double endSeconds) const {
611  tcpip::Storage content;
613  if (endSeconds != std::numeric_limits<double>::max()) {
614  content.writeInt(3);
616  content.writeDouble(beginSeconds);
618  content.writeDouble(endSeconds);
619  } else {
620  content.writeInt(1);
621  }
623  content.writeDouble(time);
624  myParent.createCommand(libsumo::CMD_SET_EDGE_VARIABLE, libsumo::VAR_EDGE_TRAVELTIME, edgeID, &content);
625  myParent.processSet(libsumo::CMD_SET_EDGE_VARIABLE);
626 }
627 
628 
629 void
630 TraCIAPI::EdgeScope::setEffort(const std::string& edgeID, double effort, double beginSeconds, double endSeconds) const {
631  tcpip::Storage content;
633  if (endSeconds != std::numeric_limits<double>::max()) {
634  content.writeInt(3);
636  content.writeDouble(beginSeconds);
638  content.writeDouble(endSeconds);
639  } else {
640  content.writeInt(1);
641  }
643  content.writeDouble(effort);
644  myParent.createCommand(libsumo::CMD_SET_EDGE_VARIABLE, libsumo::VAR_EDGE_EFFORT, edgeID, &content);
645  myParent.processSet(libsumo::CMD_SET_EDGE_VARIABLE);
646 }
647 
648 void
649 TraCIAPI::EdgeScope::setMaxSpeed(const std::string& edgeID, double speed) const {
650  setDouble(libsumo::VAR_MAXSPEED, edgeID, speed);
651 }
652 
653 
654 // ---------------------------------------------------------------------------
655 // TraCIAPI::GUIScope-methods
656 // ---------------------------------------------------------------------------
657 double
658 TraCIAPI::GUIScope::getZoom(const std::string& viewID) const {
659  return getDouble(libsumo::VAR_VIEW_ZOOM, viewID);
660 }
661 
663 TraCIAPI::GUIScope::getOffset(const std::string& viewID) const {
664  return getPos(libsumo::VAR_VIEW_OFFSET, viewID);
665 }
666 
667 std::string
668 TraCIAPI::GUIScope::getSchema(const std::string& viewID) const {
669  return getString(libsumo::VAR_VIEW_SCHEMA, viewID);
670 }
671 
673 TraCIAPI::GUIScope::getBoundary(const std::string& viewID) const {
674  return getPolygon(libsumo::VAR_VIEW_BOUNDARY, viewID);
675 }
676 
677 
678 void
679 TraCIAPI::GUIScope::setZoom(const std::string& viewID, double zoom) const {
680  setDouble(libsumo::VAR_VIEW_ZOOM, viewID, zoom);
681 }
682 
683 void
684 TraCIAPI::GUIScope::setOffset(const std::string& viewID, double x, double y) const {
685  tcpip::Storage content;
687  content.writeDouble(x);
688  content.writeDouble(y);
689  myParent.createCommand(libsumo::CMD_SET_GUI_VARIABLE, libsumo::VAR_VIEW_OFFSET, viewID, &content);
690  myParent.processSet(libsumo::CMD_SET_GUI_VARIABLE);
691 }
692 
693 void
694 TraCIAPI::GUIScope::setSchema(const std::string& viewID, const std::string& schemeName) const {
695  setString(libsumo::VAR_VIEW_SCHEMA, viewID, schemeName);
696 }
697 
698 void
699 TraCIAPI::GUIScope::setBoundary(const std::string& viewID, double xmin, double ymin, double xmax, double ymax) const {
700  tcpip::Storage content;
702  content.writeByte(2);
703  content.writeDouble(xmin);
704  content.writeDouble(ymin);
705  content.writeDouble(xmax);
706  content.writeDouble(ymax);
707  myParent.createCommand(libsumo::CMD_SET_GUI_VARIABLE, libsumo::VAR_VIEW_BOUNDARY, viewID, &content);
708  myParent.processSet(libsumo::CMD_SET_GUI_VARIABLE);
709 }
710 
711 void
712 TraCIAPI::GUIScope::screenshot(const std::string& viewID, const std::string& filename, const int width, const int height) const {
713  tcpip::Storage content;
715  content.writeInt(3);
717  content.writeString(filename);
719  content.writeInt(width);
721  content.writeInt(height);
722  myParent.createCommand(libsumo::CMD_SET_GUI_VARIABLE, libsumo::VAR_SCREENSHOT, viewID, &content);
723  myParent.processSet(libsumo::CMD_SET_GUI_VARIABLE);
724 }
725 
726 void
727 TraCIAPI::GUIScope::trackVehicle(const std::string& viewID, const std::string& vehID) const {
728  setString(libsumo::VAR_VIEW_SCHEMA, viewID, vehID);
729 }
730 
731 
732 // ---------------------------------------------------------------------------
733 // TraCIAPI::InductionLoopScope-methods
734 // ---------------------------------------------------------------------------
735 double
736 TraCIAPI::InductionLoopScope::getPosition(const std::string& loopID) const {
737  return getDouble(libsumo::VAR_POSITION, loopID);
738 }
739 
740 std::string
741 TraCIAPI::InductionLoopScope::getLaneID(const std::string& loopID) const {
742  return getString(libsumo::VAR_LANE_ID, loopID);
743 }
744 
745 int
747  return getInt(libsumo::LAST_STEP_VEHICLE_NUMBER, loopID);
748 }
749 
750 double
751 TraCIAPI::InductionLoopScope::getLastStepMeanSpeed(const std::string& loopID) const {
752  return getDouble(libsumo::LAST_STEP_MEAN_SPEED, loopID);
753 }
754 
755 std::vector<std::string>
756 TraCIAPI::InductionLoopScope::getLastStepVehicleIDs(const std::string& loopID) const {
757  return getStringVector(libsumo::LAST_STEP_VEHICLE_ID_LIST, loopID);
758 }
759 
760 double
761 TraCIAPI::InductionLoopScope::getLastStepOccupancy(const std::string& loopID) const {
762  return getDouble(libsumo::LAST_STEP_OCCUPANCY, loopID);
763 }
764 
765 double
766 TraCIAPI::InductionLoopScope::getLastStepMeanLength(const std::string& loopID) const {
767  return getDouble(libsumo::LAST_STEP_LENGTH, loopID);
768 }
769 
770 double
771 TraCIAPI::InductionLoopScope::getTimeSinceDetection(const std::string& loopID) const {
772  return getDouble(libsumo::LAST_STEP_TIME_SINCE_DETECTION, loopID);
773 }
774 
775 
776 std::vector<libsumo::TraCIVehicleData>
777 TraCIAPI::InductionLoopScope::getVehicleData(const std::string& loopID) const {
778  std::vector<libsumo::TraCIVehicleData> result;
781  myParent.myInput.readInt(); // components
782  // number of items
783  myParent.myInput.readUnsignedByte();
784  const int n = myParent.myInput.readInt();
785  for (int i = 0; i < n; ++i) {
787 
788  myParent.myInput.readUnsignedByte();
789  vd.id = myParent.myInput.readString();
790 
791  myParent.myInput.readUnsignedByte();
792  vd.length = myParent.myInput.readDouble();
793 
794  myParent.myInput.readUnsignedByte();
795  vd.entryTime = myParent.myInput.readDouble();
796 
797  myParent.myInput.readUnsignedByte();
798  vd.leaveTime = myParent.myInput.readDouble();
799 
800  myParent.myInput.readUnsignedByte();
801  vd.typeID = myParent.myInput.readString();
802 
803  result.push_back(vd);
804  }
805  }
806  return result;
807 }
808 
809 
810 // ---------------------------------------------------------------------------
811 // TraCIAPI::JunctionScope-methods
812 // ---------------------------------------------------------------------------
814 TraCIAPI::JunctionScope::getPosition(const std::string& junctionID) const {
815  return getPos(libsumo::VAR_POSITION, junctionID);
816 }
817 
819 TraCIAPI::JunctionScope::getShape(const std::string& junctionID) const {
820  return getPolygon(libsumo::VAR_SHAPE, junctionID);
821 }
822 
823 
824 // ---------------------------------------------------------------------------
825 // TraCIAPI::LaneScope-methods
826 // ---------------------------------------------------------------------------
827 double
828 TraCIAPI::LaneScope::getLength(const std::string& laneID) const {
829  return getDouble(libsumo::VAR_LENGTH, laneID);
830 }
831 
832 double
833 TraCIAPI::LaneScope::getMaxSpeed(const std::string& laneID) const {
834  return getDouble(libsumo::VAR_MAXSPEED, laneID);
835 }
836 
837 double
838 TraCIAPI::LaneScope::getWidth(const std::string& laneID) const {
839  return getDouble(libsumo::VAR_WIDTH, laneID);
840 }
841 
842 std::vector<std::string>
843 TraCIAPI::LaneScope::getAllowed(const std::string& laneID) const {
844  return getStringVector(libsumo::LANE_ALLOWED, laneID);
845 }
846 
847 std::vector<std::string>
848 TraCIAPI::LaneScope::getDisallowed(const std::string& laneID) const {
849  return getStringVector(libsumo::LANE_DISALLOWED, laneID);
850 }
851 
852 int
853 TraCIAPI::LaneScope::getLinkNumber(const std::string& laneID) const {
854  return getInt(libsumo::LANE_LINK_NUMBER, laneID);
855 }
856 
857 std::vector<libsumo::TraCIConnection>
858 TraCIAPI::LaneScope::getLinks(const std::string& laneID) const {
859  std::vector<libsumo::TraCIConnection> ret;
860  myParent.createCommand(libsumo::CMD_GET_LANE_VARIABLE, libsumo::LANE_LINKS, laneID);
861  if (myParent.processGet(libsumo::CMD_GET_LANE_VARIABLE, libsumo::TYPE_COMPOUND)) {
862  myParent.myInput.readUnsignedByte();
863  myParent.myInput.readInt();
864 
865  int linkNo = myParent.myInput.readInt();
866  for (int i = 0; i < linkNo; ++i) {
867 
868  myParent.myInput.readUnsignedByte();
869  std::string approachedLane = myParent.myInput.readString();
870 
871  myParent.myInput.readUnsignedByte();
872  std::string approachedLaneInternal = myParent.myInput.readString();
873 
874  myParent.myInput.readUnsignedByte();
875  bool hasPrio = myParent.myInput.readUnsignedByte() != 0;
876 
877  myParent.myInput.readUnsignedByte();
878  bool isOpen = myParent.myInput.readUnsignedByte() != 0;
879 
880  myParent.myInput.readUnsignedByte();
881  bool hasFoe = myParent.myInput.readUnsignedByte() != 0;
882 
883  myParent.myInput.readUnsignedByte();
884  std::string state = myParent.myInput.readString();
885 
886  myParent.myInput.readUnsignedByte();
887  std::string direction = myParent.myInput.readString();
888 
889  myParent.myInput.readUnsignedByte();
890  double length = myParent.myInput.readDouble();
891 
892  ret.push_back(libsumo::TraCIConnection(approachedLane,
893  hasPrio,
894  isOpen,
895  hasFoe,
896  approachedLaneInternal,
897  state,
898  direction,
899  length));
900 
901  }
902 
903  }
904  return ret;
905 }
906 
908 TraCIAPI::LaneScope::getShape(const std::string& laneID) const {
909  return getPolygon(libsumo::VAR_SHAPE, laneID);
910 }
911 
912 std::string
913 TraCIAPI::LaneScope::getEdgeID(const std::string& laneID) const {
914  return getString(libsumo::LANE_EDGE_ID, laneID);
915 }
916 
917 double
918 TraCIAPI::LaneScope::getCO2Emission(const std::string& laneID) const {
919  return getDouble(libsumo::VAR_CO2EMISSION, laneID);
920 }
921 
922 double
923 TraCIAPI::LaneScope::getCOEmission(const std::string& laneID) const {
924  return getDouble(libsumo::VAR_COEMISSION, laneID);
925 }
926 
927 double
928 TraCIAPI::LaneScope::getHCEmission(const std::string& laneID) const {
929  return getDouble(libsumo::VAR_HCEMISSION, laneID);
930 }
931 
932 double
933 TraCIAPI::LaneScope::getPMxEmission(const std::string& laneID) const {
934  return getDouble(libsumo::VAR_PMXEMISSION, laneID);
935 }
936 
937 double
938 TraCIAPI::LaneScope::getNOxEmission(const std::string& laneID) const {
939  return getDouble(libsumo::VAR_NOXEMISSION, laneID);
940 }
941 
942 double
943 TraCIAPI::LaneScope::getFuelConsumption(const std::string& laneID) const {
944  return getDouble(libsumo::VAR_FUELCONSUMPTION, laneID);
945 }
946 
947 double
948 TraCIAPI::LaneScope::getNoiseEmission(const std::string& laneID) const {
949  return getDouble(libsumo::VAR_NOISEEMISSION, laneID);
950 }
951 
952 double
953 TraCIAPI::LaneScope::getElectricityConsumption(const std::string& laneID) const {
954  return getDouble(libsumo::VAR_ELECTRICITYCONSUMPTION, laneID);
955 }
956 
957 double
958 TraCIAPI::LaneScope::getLastStepMeanSpeed(const std::string& laneID) const {
959  return getDouble(libsumo::LAST_STEP_MEAN_SPEED, laneID);
960 }
961 
962 double
963 TraCIAPI::LaneScope::getLastStepOccupancy(const std::string& laneID) const {
964  return getDouble(libsumo::LAST_STEP_OCCUPANCY, laneID);
965 }
966 
967 double
968 TraCIAPI::LaneScope::getLastStepLength(const std::string& laneID) const {
969  return getDouble(libsumo::LAST_STEP_LENGTH, laneID);
970 }
971 
972 double
973 TraCIAPI::LaneScope::getTraveltime(const std::string& laneID) const {
974  return getDouble(libsumo::VAR_CURRENT_TRAVELTIME, laneID);
975 }
976 
977 int
978 TraCIAPI::LaneScope::getLastStepVehicleNumber(const std::string& laneID) const {
979  return getInt(libsumo::LAST_STEP_VEHICLE_NUMBER, laneID);
980 }
981 
982 int
983 TraCIAPI::LaneScope::getLastStepHaltingNumber(const std::string& laneID) const {
984  return getInt(libsumo::LAST_STEP_VEHICLE_HALTING_NUMBER, laneID);
985 }
986 
987 std::vector<std::string>
988 TraCIAPI::LaneScope::getLastStepVehicleIDs(const std::string& laneID) const {
989  return getStringVector(libsumo::LAST_STEP_VEHICLE_ID_LIST, laneID);
990 }
991 
992 
993 std::vector<std::string>
994 TraCIAPI::LaneScope::getFoes(const std::string& laneID, const std::string& toLaneID) const {
995  std::vector<std::string> r;
996  tcpip::Storage content;
998  content.writeString(toLaneID);
999  myParent.createCommand(libsumo::CMD_GET_LANE_VARIABLE, libsumo::VAR_FOES, laneID, &content);
1000  if (myParent.processGet(libsumo::CMD_GET_LANE_VARIABLE, libsumo::TYPE_STRINGLIST)) {
1001  const int size = myParent.myInput.readInt();
1002  for (int i = 0; i < size; ++i) {
1003  r.push_back(myParent.myInput.readString());
1004  }
1005  }
1006  return r;
1007 }
1008 
1009 std::vector<std::string>
1010 TraCIAPI::LaneScope::getInternalFoes(const std::string& laneID) const {
1011  return getFoes(laneID, "");
1012 }
1013 
1014 
1015 void
1016 TraCIAPI::LaneScope::setAllowed(const std::string& laneID, const std::vector<std::string>& allowedClasses) const {
1017  setStringVector(libsumo::LANE_ALLOWED, laneID, allowedClasses);
1018 }
1019 
1020 void
1021 TraCIAPI::LaneScope::setDisallowed(const std::string& laneID, const std::vector<std::string>& disallowedClasses) const {
1022  setStringVector(libsumo::LANE_DISALLOWED, laneID, disallowedClasses);
1023 }
1024 
1025 void
1026 TraCIAPI::LaneScope::setMaxSpeed(const std::string& laneID, double speed) const {
1027  setDouble(libsumo::VAR_MAXSPEED, laneID, speed);
1028 }
1029 
1030 void
1031 TraCIAPI::LaneScope::setLength(const std::string& laneID, double length) const {
1032  setDouble(libsumo::VAR_LENGTH, laneID, length);
1033 }
1034 
1035 
1036 // ---------------------------------------------------------------------------
1037 // TraCIAPI::LaneAreaDetector-methods
1038 // ---------------------------------------------------------------------------
1039 
1040 
1041 // ---------------------------------------------------------------------------
1042 // TraCIAPI::MeMeScope-methods
1043 // ---------------------------------------------------------------------------
1044 int
1045 TraCIAPI::MeMeScope::getLastStepVehicleNumber(const std::string& detID) const {
1046  return getInt(libsumo::LAST_STEP_VEHICLE_NUMBER, detID);
1047 }
1048 
1049 double
1050 TraCIAPI::MeMeScope::getLastStepMeanSpeed(const std::string& detID) const {
1051  return getDouble(libsumo::LAST_STEP_MEAN_SPEED, detID);
1052 }
1053 
1054 std::vector<std::string>
1055 TraCIAPI::MeMeScope::getLastStepVehicleIDs(const std::string& detID) const {
1056  return getStringVector(libsumo::LAST_STEP_VEHICLE_ID_LIST, detID);
1057 }
1058 
1059 int
1060 TraCIAPI::MeMeScope::getLastStepHaltingNumber(const std::string& detID) const {
1061  return getInt(libsumo::LAST_STEP_VEHICLE_HALTING_NUMBER, detID);
1062 }
1063 
1064 
1065 
1066 // ---------------------------------------------------------------------------
1067 // TraCIAPI::POIScope-methods
1068 // ---------------------------------------------------------------------------
1069 std::string
1070 TraCIAPI::POIScope::getType(const std::string& poiID) const {
1071  return getString(libsumo::VAR_TYPE, poiID);
1072 }
1073 
1075 TraCIAPI::POIScope::getPosition(const std::string& poiID) const {
1076  return getPos(libsumo::VAR_POSITION, poiID);
1077 }
1078 
1080 TraCIAPI::POIScope::getColor(const std::string& poiID) const {
1081  return getCol(libsumo::VAR_COLOR, poiID);
1082 }
1083 
1084 double
1085 TraCIAPI::POIScope::getWidth(const std::string& poiID) const {
1086  return getDouble(libsumo::VAR_WIDTH, poiID);
1087 }
1088 
1089 double
1090 TraCIAPI::POIScope::getHeight(const std::string& poiID) const {
1091  return getDouble(libsumo::VAR_HEIGHT, poiID);
1092 }
1093 
1094 double
1095 TraCIAPI::POIScope::getAngle(const std::string& poiID) const {
1096  return getDouble(libsumo::VAR_ANGLE, poiID);
1097 }
1098 
1099 std::string
1100 TraCIAPI::POIScope::getImageFile(const std::string& poiID) const {
1101  return getString(libsumo::VAR_IMAGEFILE, poiID);
1102 }
1103 
1104 
1105 void
1106 TraCIAPI::POIScope::setType(const std::string& poiID, const std::string& setType) const {
1107  setString(libsumo::VAR_TYPE, poiID, setType);
1108 }
1109 
1110 
1111 void
1112 TraCIAPI::POIScope::setPosition(const std::string& poiID, double x, double y) const {
1113  tcpip::Storage content;
1115  content.writeDouble(x);
1116  content.writeDouble(y);
1117  myParent.createCommand(libsumo::CMD_SET_POI_VARIABLE, libsumo::VAR_POSITION, poiID, &content);
1118  myParent.processSet(libsumo::CMD_SET_POI_VARIABLE);
1119 }
1120 
1121 
1122 void
1123 TraCIAPI::POIScope::setColor(const std::string& poiID, const libsumo::TraCIColor& c) const {
1124  tcpip::Storage content;
1126  content.writeUnsignedByte(c.r);
1127  content.writeUnsignedByte(c.g);
1128  content.writeUnsignedByte(c.b);
1129  content.writeUnsignedByte(c.a);
1130  myParent.createCommand(libsumo::CMD_SET_POI_VARIABLE, libsumo::VAR_COLOR, poiID, &content);
1131  myParent.processSet(libsumo::CMD_SET_POI_VARIABLE);
1132 }
1133 
1134 
1135 void
1136 TraCIAPI::POIScope::setWidth(const std::string& poiID, double width) const {
1137  setDouble(libsumo::VAR_WIDTH, poiID, width);
1138 }
1139 
1140 
1141 void
1142 TraCIAPI::POIScope::setHeight(const std::string& poiID, double height) const {
1143  setDouble(libsumo::VAR_HEIGHT, poiID, height);
1144 }
1145 
1146 
1147 void
1148 TraCIAPI::POIScope::setAngle(const std::string& poiID, double angle) const {
1149  setDouble(libsumo::VAR_ANGLE, poiID, angle);
1150 }
1151 
1152 
1153 void
1154 TraCIAPI::POIScope::setImageFile(const std::string& poiID, const std::string& imageFile) const {
1155  setString(libsumo::VAR_IMAGEFILE, poiID, imageFile);
1156 }
1157 
1158 
1159 void
1160 TraCIAPI::POIScope::add(const std::string& poiID, double x, double y, const libsumo::TraCIColor& c, const std::string& type, int layer, const std::string& imgFile, double width, double height, double angle) const {
1161  tcpip::Storage content;
1163  content.writeInt(8);
1165  content.writeString(type);
1167  content.writeUnsignedByte(c.r);
1168  content.writeUnsignedByte(c.g);
1169  content.writeUnsignedByte(c.b);
1170  content.writeUnsignedByte(c.a);
1172  content.writeInt(layer);
1174  content.writeDouble(x);
1175  content.writeDouble(y);
1177  content.writeString(imgFile);
1179  content.writeDouble(width);
1181  content.writeDouble(height);
1183  content.writeDouble(angle);
1184  myParent.createCommand(libsumo::CMD_SET_POI_VARIABLE, libsumo::ADD, poiID, &content);
1185  myParent.processSet(libsumo::CMD_SET_POI_VARIABLE);
1186 }
1187 
1188 void
1189 TraCIAPI::POIScope::remove(const std::string& poiID, int layer) const {
1190  tcpip::Storage content;
1192  content.writeInt(layer);
1193  myParent.createCommand(libsumo::CMD_SET_POI_VARIABLE, libsumo::REMOVE, poiID, &content);
1194  myParent.processSet(libsumo::CMD_SET_POI_VARIABLE);
1195 }
1196 
1197 
1198 // ---------------------------------------------------------------------------
1199 // TraCIAPI::PolygonScope-methods
1200 // ---------------------------------------------------------------------------
1201 double
1202 TraCIAPI::PolygonScope::getLineWidth(const std::string& polygonID) const {
1203  return getDouble(libsumo::VAR_WIDTH, polygonID);
1204 }
1205 
1206 bool
1207 TraCIAPI::PolygonScope::getFilled(const std::string& polygonID) const {
1208  return getInt(libsumo::VAR_FILL, polygonID) != 0;
1209 }
1210 
1211 std::string
1212 TraCIAPI::PolygonScope::getType(const std::string& polygonID) const {
1213  return getString(libsumo::VAR_TYPE, polygonID);
1214 }
1215 
1217 TraCIAPI::PolygonScope::getShape(const std::string& polygonID) const {
1218  return getPolygon(libsumo::VAR_SHAPE, polygonID);
1219 }
1220 
1222 TraCIAPI::PolygonScope::getColor(const std::string& polygonID) const {
1223  return getCol(libsumo::VAR_COLOR, polygonID);
1224 }
1225 
1226 void
1227 TraCIAPI::PolygonScope::setLineWidth(const std::string& polygonID, const double lineWidth) const {
1228  tcpip::Storage content;
1230  content.writeDouble(lineWidth);
1231  myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_WIDTH, polygonID, &content);
1232  myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1233 }
1234 
1235 void
1236 TraCIAPI::PolygonScope::setType(const std::string& polygonID, const std::string& setType) const {
1237  tcpip::Storage content;
1239  content.writeString(setType);
1240  myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_TYPE, polygonID, &content);
1241  myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1242 }
1243 
1244 
1245 void
1246 TraCIAPI::PolygonScope::setShape(const std::string& polygonID, const libsumo::TraCIPositionVector& shape) const {
1247  tcpip::Storage content;
1249  if (shape.value.size() < 256) {
1250  content.writeUnsignedByte((int)shape.value.size());
1251  } else {
1252  content.writeUnsignedByte(0);
1253  content.writeInt((int)shape.value.size());
1254  }
1255  for (const libsumo::TraCIPosition& pos : shape.value) {
1256  content.writeDouble(pos.x);
1257  content.writeDouble(pos.y);
1258  }
1259  myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_SHAPE, polygonID, &content);
1260  myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1261 }
1262 
1263 
1264 void
1265 TraCIAPI::PolygonScope::setColor(const std::string& polygonID, const libsumo::TraCIColor& c) const {
1266  tcpip::Storage content;
1268  content.writeUnsignedByte(c.r);
1269  content.writeUnsignedByte(c.g);
1270  content.writeUnsignedByte(c.b);
1271  content.writeUnsignedByte(c.a);
1272  myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_COLOR, polygonID, &content);
1273  myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1274 }
1275 
1276 void
1277 TraCIAPI::PolygonScope::add(const std::string& polygonID, const libsumo::TraCIPositionVector& shape, const libsumo::TraCIColor& c, bool fill, const std::string& type, int layer) const {
1278  tcpip::Storage content;
1280  content.writeInt(5);
1282  content.writeString(type);
1284  content.writeUnsignedByte(c.r);
1285  content.writeUnsignedByte(c.g);
1286  content.writeUnsignedByte(c.b);
1287  content.writeUnsignedByte(c.a);
1289  int f = fill ? 1 : 0;
1290  content.writeUnsignedByte(f);
1292  content.writeInt(layer);
1294  content.writeUnsignedByte((int)shape.value.size());
1295  for (int i = 0; i < (int)shape.value.size(); ++i) {
1296  content.writeDouble(shape.value[i].x);
1297  content.writeDouble(shape.value[i].y);
1298  }
1299  myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::ADD, polygonID, &content);
1300  myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1301 }
1302 
1303 void
1304 TraCIAPI::PolygonScope::remove(const std::string& polygonID, int layer) const {
1305  tcpip::Storage content;
1307  content.writeInt(layer);
1308  myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::REMOVE, polygonID, &content);
1309  myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1310 }
1311 
1312 
1313 // ---------------------------------------------------------------------------
1314 // TraCIAPI::RouteScope-methods
1315 // ---------------------------------------------------------------------------
1316 std::vector<std::string>
1317 TraCIAPI::RouteScope::getEdges(const std::string& routeID) const {
1318  return getStringVector(libsumo::VAR_EDGES, routeID);
1319 }
1320 
1321 
1322 void
1323 TraCIAPI::RouteScope::add(const std::string& routeID, const std::vector<std::string>& edges) const {
1324  tcpip::Storage content;
1326  content.writeStringList(edges);
1327  myParent.createCommand(libsumo::CMD_SET_ROUTE_VARIABLE, libsumo::ADD, routeID, &content);
1328  myParent.processSet(libsumo::CMD_SET_ROUTE_VARIABLE);
1329 }
1330 
1331 
1332 // ---------------------------------------------------------------------------
1333 // TraCIAPI::SimulationScope-methods
1334 // ---------------------------------------------------------------------------
1335 int
1337  return getInt(libsumo::VAR_TIME_STEP, "");
1338 }
1339 
1340 double
1342  return getDouble(libsumo::VAR_TIME, "");
1343 }
1344 
1345 int
1347  return (int) getInt(libsumo::VAR_LOADED_VEHICLES_NUMBER, "");
1348 }
1349 
1350 std::vector<std::string>
1352  return getStringVector(libsumo::VAR_LOADED_VEHICLES_IDS, "");
1353 }
1354 
1355 int
1357  return (int) getInt(libsumo::VAR_DEPARTED_VEHICLES_NUMBER, "");
1358 }
1359 
1360 std::vector<std::string>
1362  return getStringVector(libsumo::VAR_DEPARTED_VEHICLES_IDS, "");
1363 }
1364 
1365 int
1367  return (int) getInt(libsumo::VAR_ARRIVED_VEHICLES_NUMBER, "");
1368 }
1369 
1370 std::vector<std::string>
1372  return getStringVector(libsumo::VAR_ARRIVED_VEHICLES_IDS, "");
1373 }
1374 
1375 int
1377  return (int) getInt(libsumo::VAR_TELEPORT_STARTING_VEHICLES_NUMBER, "");
1378 }
1379 
1380 std::vector<std::string>
1382  return getStringVector(libsumo::VAR_TELEPORT_STARTING_VEHICLES_IDS, "");
1383 }
1384 
1385 int
1387  return (int) getInt(libsumo::VAR_TELEPORT_ENDING_VEHICLES_NUMBER, "");
1388 }
1389 
1390 std::vector<std::string>
1392  return getStringVector(libsumo::VAR_TELEPORT_ENDING_VEHICLES_IDS, "");
1393 }
1394 
1395 int
1397  return (int)getInt(libsumo::VAR_DEPARTED_PERSONS_NUMBER, "");
1398 }
1399 
1400 std::vector<std::string>
1402  return getStringVector(libsumo::VAR_DEPARTED_PERSONS_IDS, "");
1403 }
1404 
1405 int
1407  return (int)getInt(libsumo::VAR_ARRIVED_PERSONS_NUMBER, "");
1408 }
1409 
1410 std::vector<std::string>
1412  return getStringVector(libsumo::VAR_ARRIVED_PERSONS_IDS, "");
1413 }
1414 
1415 double
1417  return getDouble(libsumo::VAR_DELTA_T, "");
1418 }
1419 
1422  return getPolygon(libsumo::VAR_NET_BOUNDING_BOX, "");
1423 }
1424 
1425 
1426 int
1428  return getInt(libsumo::VAR_MIN_EXPECTED_VEHICLES, "");
1429 }
1430 
1431 int
1432 TraCIAPI::SimulationScope::getBusStopWaiting(const std::string& stopID) const {
1433  return (int) getInt(libsumo::VAR_BUS_STOP_WAITING, stopID);
1434 }
1435 
1436 std::vector<std::string>
1437 TraCIAPI::SimulationScope::getBusStopWaitingIDList(const std::string& stopID) const {
1438  return getStringVector(libsumo::VAR_BUS_STOP_WAITING_IDS, stopID);
1439 }
1440 
1441 
1443 TraCIAPI::SimulationScope::convert2D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) const {
1444  const int posType = toGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D;
1445  libsumo::TraCIPosition result;
1446  tcpip::Storage content;
1448  content.writeInt(2);
1450  content.writeString(edgeID);
1451  content.writeDouble(pos);
1452  content.writeByte(laneIndex);
1453  content.writeByte(libsumo::TYPE_UBYTE);
1454  content.writeByte(posType);
1455  myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
1456  if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
1457  result.x = myParent.myInput.readDouble();
1458  result.y = myParent.myInput.readDouble();
1459  }
1460  return result;
1461 }
1462 
1463 
1465 TraCIAPI::SimulationScope::convert3D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) const {
1466  const int posType = toGeo ? libsumo::POSITION_LON_LAT_ALT : libsumo::POSITION_3D;
1467  libsumo::TraCIPosition result;
1468  tcpip::Storage content;
1470  content.writeInt(2);
1472  content.writeString(edgeID);
1473  content.writeDouble(pos);
1474  content.writeByte(laneIndex);
1475  content.writeByte(libsumo::TYPE_UBYTE);
1476  content.writeByte(posType);
1477  myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
1478  if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
1479  result.x = myParent.myInput.readDouble();
1480  result.y = myParent.myInput.readDouble();
1481  result.z = myParent.myInput.readDouble();
1482  }
1483  return result;
1484 }
1485 
1486 
1488 TraCIAPI::SimulationScope::convertRoad(double x, double y, bool isGeo, const std::string& vClass) const {
1490  tcpip::Storage content;
1492  content.writeInt(3);
1494  content.writeDouble(x);
1495  content.writeDouble(y);
1496  content.writeByte(libsumo::TYPE_UBYTE);
1499  content.writeString(vClass);
1500  myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
1501  if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_ROADMAP)) {
1502  result.edgeID = myParent.myInput.readString();
1503  result.pos = myParent.myInput.readDouble();
1504  result.laneIndex = myParent.myInput.readUnsignedByte();
1505  }
1506  return result;
1507 }
1508 
1509 
1511 TraCIAPI::SimulationScope::convertGeo(double x, double y, bool fromGeo) const {
1512  const int posType = fromGeo ? libsumo::POSITION_2D : libsumo::POSITION_LON_LAT;
1513  libsumo::TraCIPosition result;
1514  tcpip::Storage content;
1516  content.writeInt(2);
1518  content.writeDouble(x);
1519  content.writeDouble(y);
1520  content.writeByte(libsumo::TYPE_UBYTE);
1521  content.writeByte(posType);
1522  myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
1523  if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
1524  result.x = myParent.myInput.readDouble();
1525  result.y = myParent.myInput.readDouble();
1526  }
1527  return result;
1528 }
1529 
1530 
1531 double
1532 TraCIAPI::SimulationScope::getDistance2D(double x1, double y1, double x2, double y2, bool isGeo, bool isDriving) {
1533  tcpip::Storage content;
1535  content.writeInt(3);
1537  content.writeDouble(x1);
1538  content.writeDouble(y1);
1540  content.writeDouble(x2);
1541  content.writeDouble(y2);
1543  myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::DISTANCE_REQUEST, "", &content);
1544  if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::TYPE_DOUBLE)) {
1545  return myParent.myInput.readDouble();
1546  }
1547  return 0.;
1548 }
1549 
1550 
1551 double
1552 TraCIAPI::SimulationScope::getDistanceRoad(const std::string& edgeID1, double pos1, const std::string& edgeID2, double pos2, bool isDriving) {
1553  tcpip::Storage content;
1555  content.writeInt(3);
1557  content.writeString(edgeID1);
1558  content.writeDouble(pos1);
1559  content.writeByte(0); // lane
1561  content.writeString(edgeID2);
1562  content.writeDouble(pos2);
1563  content.writeByte(0); // lane
1565  myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::DISTANCE_REQUEST, "", &content);
1566  if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::TYPE_DOUBLE)) {
1567  return myParent.myInput.readDouble();
1568  }
1569  return 0.;
1570 }
1571 
1572 
1574 TraCIAPI::SimulationScope::findRoute(const std::string& fromEdge, const std::string& toEdge, const std::string& vType, double pos, int routingMode) const {
1575  tcpip::Storage content;
1577  content.writeInt(5);
1579  content.writeString(fromEdge);
1581  content.writeString(toEdge);
1583  content.writeString(vType);
1585  content.writeDouble(pos);
1587  content.writeInt(routingMode);
1588  return getTraCIStage(libsumo::FIND_ROUTE, "", &content);
1589 }
1590 
1591 void
1592 TraCIAPI::SimulationScope::loadState(const std::string& path) const {
1593  tcpip::Storage content;
1595  content.writeString(path);
1596  myParent.createCommand(libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_LOAD_SIMSTATE, "", &content);
1597  myParent.processSet(libsumo::CMD_SET_SIM_VARIABLE);
1598 }
1599 
1600 void
1601 TraCIAPI::SimulationScope::saveState(const std::string& destination) const {
1602  tcpip::Storage content;
1604  content.writeString(destination);
1605  myParent.createCommand(libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_SAVE_SIMSTATE, "", &content);
1606  myParent.processSet(libsumo::CMD_SET_SIM_VARIABLE);
1607 }
1608 
1609 void
1611  tcpip::Storage content;
1613  content.writeString(msg);
1614  myParent.createCommand(libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_MESSAGE, "", &content);
1615  myParent.processSet(libsumo::CMD_SET_SIM_VARIABLE);
1616 }
1617 
1618 
1619 // ---------------------------------------------------------------------------
1620 // TraCIAPI::TrafficLightScope-methods
1621 // ---------------------------------------------------------------------------
1622 std::string
1624  return getString(libsumo::TL_RED_YELLOW_GREEN_STATE, tlsID);
1625 }
1626 
1627 std::vector<libsumo::TraCILogic>
1628 TraCIAPI::TrafficLightScope::getAllProgramLogics(const std::string& tlsID) const {
1629  std::vector<libsumo::TraCILogic> ret;
1630  myParent.createCommand(libsumo::CMD_GET_TL_VARIABLE, libsumo::TL_COMPLETE_DEFINITION_RYG, tlsID);
1631  if (myParent.processGet(libsumo::CMD_GET_TL_VARIABLE, libsumo::TYPE_COMPOUND)) {
1632  const int logicNo = myParent.myInput.readInt();
1633  for (int i = 0; i < logicNo; ++i) {
1634  myParent.myInput.readUnsignedByte();
1635  myParent.myInput.readInt();
1636  myParent.myInput.readUnsignedByte();
1637  const std::string programID = myParent.myInput.readString();
1638  myParent.myInput.readUnsignedByte();
1639  const int type = myParent.myInput.readInt();
1640  myParent.myInput.readUnsignedByte();
1641  const int phaseIndex = myParent.myInput.readInt();
1642  myParent.myInput.readUnsignedByte();
1643  const int phaseNumber = myParent.myInput.readInt();
1644  libsumo::TraCILogic logic(programID, type, phaseIndex);
1645  for (int j = 0; j < phaseNumber; j++) {
1646  myParent.myInput.readUnsignedByte();
1647  myParent.myInput.readInt();
1648  myParent.myInput.readUnsignedByte();
1649  const double duration = myParent.myInput.readDouble();
1650  myParent.myInput.readUnsignedByte();
1651  const std::string state = myParent.myInput.readString();
1652  myParent.myInput.readUnsignedByte();
1653  const double minDur = myParent.myInput.readDouble();
1654  myParent.myInput.readUnsignedByte();
1655  const double maxDur = myParent.myInput.readDouble();
1656  myParent.myInput.readUnsignedByte();
1657  const int numNext = myParent.myInput.readInt();
1658  std::vector<int> next;
1659  for (int k = 0; k < numNext; k++) {
1660  myParent.myInput.readUnsignedByte();
1661  next.push_back(myParent.myInput.readInt());
1662  }
1663  myParent.myInput.readUnsignedByte();
1664  const std::string name = myParent.myInput.readString();
1665  logic.phases.emplace_back(new libsumo::TraCIPhase(duration, state, minDur, maxDur, next, name));
1666  }
1667  myParent.myInput.readUnsignedByte();
1668  const int paramNumber = myParent.myInput.readInt();
1669  for (int j = 0; j < paramNumber; j++) {
1670  myParent.myInput.readUnsignedByte();
1671  const std::vector<std::string> par = myParent.myInput.readStringList();
1672  logic.subParameter[par[0]] = par[1];
1673  }
1674  ret.emplace_back(logic);
1675  }
1676  }
1677  return ret;
1678 }
1679 
1680 std::vector<std::string>
1681 TraCIAPI::TrafficLightScope::getControlledLanes(const std::string& tlsID) const {
1682  return getStringVector(libsumo::TL_CONTROLLED_LANES, tlsID);
1683 }
1684 
1685 std::vector<std::vector<libsumo::TraCILink> >
1686 TraCIAPI::TrafficLightScope::getControlledLinks(const std::string& tlsID) const {
1687  std::vector<std::vector<libsumo::TraCILink> > result;
1688  myParent.createCommand(libsumo::CMD_GET_TL_VARIABLE, libsumo::TL_CONTROLLED_LINKS, tlsID);
1689  if (myParent.processGet(libsumo::CMD_GET_TL_VARIABLE, libsumo::TYPE_COMPOUND)) {
1690 
1691  myParent.myInput.readUnsignedByte();
1692  myParent.myInput.readInt();
1693 
1694  int linkNo = myParent.myInput.readInt();
1695  for (int i = 0; i < linkNo; ++i) {
1696  myParent.myInput.readUnsignedByte();
1697  int no = myParent.myInput.readInt();
1698  std::vector<libsumo::TraCILink> ret;
1699  for (int i1 = 0; i1 < no; ++i1) {
1700  myParent.myInput.readUnsignedByte();
1701  myParent.myInput.readInt();
1702  std::string from = myParent.myInput.readString();
1703  std::string to = myParent.myInput.readString();
1704  std::string via = myParent.myInput.readString();
1705  ret.emplace_back(libsumo::TraCILink(from, via, to));
1706  }
1707  result.emplace_back(ret);
1708  }
1709  }
1710  return result;
1711 }
1712 
1713 std::string
1714 TraCIAPI::TrafficLightScope::getProgram(const std::string& tlsID) const {
1715  return getString(libsumo::TL_CURRENT_PROGRAM, tlsID);
1716 }
1717 
1718 int
1719 TraCIAPI::TrafficLightScope::getPhase(const std::string& tlsID) const {
1720  return getInt(libsumo::TL_CURRENT_PHASE, tlsID);
1721 }
1722 
1723 std::string
1724 TraCIAPI::TrafficLightScope::getPhaseName(const std::string& tlsID) const {
1725  return getString(libsumo::VAR_NAME, tlsID);
1726 }
1727 
1728 double
1729 TraCIAPI::TrafficLightScope::getPhaseDuration(const std::string& tlsID) const {
1730  return getDouble(libsumo::TL_PHASE_DURATION, tlsID);
1731 }
1732 
1733 double
1734 TraCIAPI::TrafficLightScope::getNextSwitch(const std::string& tlsID) const {
1735  return getDouble(libsumo::TL_NEXT_SWITCH, tlsID);
1736 }
1737 
1738 
1739 int
1740 TraCIAPI::TrafficLightScope::getServedPersonCount(const std::string& tlsID, int index) const {
1741  tcpip::Storage content;
1743  content.writeInt(index);
1744  return getInt(libsumo::VAR_PERSON_NUMBER, tlsID, &content);
1745 }
1746 
1747 
1748 void
1749 TraCIAPI::TrafficLightScope::setRedYellowGreenState(const std::string& tlsID, const std::string& state) const {
1750  tcpip::Storage content;
1752  content.writeString(state);
1753  myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_RED_YELLOW_GREEN_STATE, tlsID, &content);
1754  myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1755 }
1756 
1757 void
1758 TraCIAPI::TrafficLightScope::setPhase(const std::string& tlsID, int index) const {
1759  tcpip::Storage content;
1761  content.writeInt(index);
1762  myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PHASE_INDEX, tlsID, &content);
1763  myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1764 }
1765 
1766 void
1767 TraCIAPI::TrafficLightScope::setPhaseName(const std::string& tlsID, const std::string& name) const {
1768  tcpip::Storage content;
1770  content.writeString(name);
1771  myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::VAR_NAME, tlsID, &content);
1772  myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1773 }
1774 
1775 void
1776 TraCIAPI::TrafficLightScope::setProgram(const std::string& tlsID, const std::string& programID) const {
1777  tcpip::Storage content;
1779  content.writeString(programID);
1780  myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PROGRAM, tlsID, &content);
1781  myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1782 }
1783 
1784 void
1785 TraCIAPI::TrafficLightScope::setPhaseDuration(const std::string& tlsID, double phaseDuration) const {
1786  tcpip::Storage content;
1788  content.writeDouble(phaseDuration);
1789  myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PHASE_DURATION, tlsID, &content);
1790  myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1791 }
1792 
1793 void
1794 TraCIAPI::TrafficLightScope::setProgramLogic(const std::string& tlsID, const libsumo::TraCILogic& logic) const {
1795  tcpip::Storage content;
1797  content.writeInt(5);
1799  content.writeString(logic.programID);
1801  content.writeInt(logic.type);
1803  content.writeInt(logic.currentPhaseIndex);
1805  content.writeInt((int)logic.phases.size());
1806  for (const std::shared_ptr<libsumo::TraCIPhase>& p : logic.phases) {
1808  content.writeInt(6);
1810  content.writeDouble(p->duration);
1812  content.writeString(p->state);
1814  content.writeDouble(p->minDur);
1816  content.writeDouble(p->maxDur);
1818  content.writeInt((int)p->next.size());
1819  for (int n : p->next) {
1821  content.writeInt(n);
1822  }
1824  content.writeString(p->name);
1825  }
1827  content.writeInt((int)logic.subParameter.size());
1828  for (const auto& item : logic.subParameter) {
1830  content.writeInt(2);
1831  content.writeString(item.first);
1832  content.writeString(item.second);
1833  }
1834  myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_COMPLETE_PROGRAM_RYG, tlsID, &content);
1835  myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1836 }
1837 
1838 
1839 // ---------------------------------------------------------------------------
1840 // TraCIAPI::VehicleTypeScope-methods
1841 // ---------------------------------------------------------------------------
1842 double
1843 TraCIAPI::VehicleTypeScope::getLength(const std::string& typeID) const {
1844  return getDouble(libsumo::VAR_LENGTH, typeID);
1845 }
1846 
1847 double
1848 TraCIAPI::VehicleTypeScope::getMaxSpeed(const std::string& typeID) const {
1849  return getDouble(libsumo::VAR_MAXSPEED, typeID);
1850 }
1851 
1852 double
1853 TraCIAPI::VehicleTypeScope::getSpeedFactor(const std::string& typeID) const {
1854  return getDouble(libsumo::VAR_SPEED_FACTOR, typeID);
1855 }
1856 
1857 double
1858 TraCIAPI::VehicleTypeScope::getSpeedDeviation(const std::string& typeID) const {
1859  return getDouble(libsumo::VAR_SPEED_DEVIATION, typeID);
1860 }
1861 
1862 double
1863 TraCIAPI::VehicleTypeScope::getAccel(const std::string& typeID) const {
1864  return getDouble(libsumo::VAR_ACCEL, typeID);
1865 }
1866 
1867 double
1868 TraCIAPI::VehicleTypeScope::getDecel(const std::string& typeID) const {
1869  return getDouble(libsumo::VAR_DECEL, typeID);
1870 }
1871 
1872 double
1873 TraCIAPI::VehicleTypeScope::getEmergencyDecel(const std::string& typeID) const {
1874  return getDouble(libsumo::VAR_EMERGENCY_DECEL, typeID);
1875 }
1876 
1877 double
1878 TraCIAPI::VehicleTypeScope::getApparentDecel(const std::string& typeID) const {
1879  return getDouble(libsumo::VAR_APPARENT_DECEL, typeID);
1880 }
1881 
1882 double
1883 TraCIAPI::VehicleTypeScope::getImperfection(const std::string& typeID) const {
1884  return getDouble(libsumo::VAR_IMPERFECTION, typeID);
1885 }
1886 
1887 double
1888 TraCIAPI::VehicleTypeScope::getTau(const std::string& typeID) const {
1889  return getDouble(libsumo::VAR_TAU, typeID);
1890 }
1891 
1892 std::string
1893 TraCIAPI::VehicleTypeScope::getVehicleClass(const std::string& typeID) const {
1894  return getString(libsumo::VAR_VEHICLECLASS, typeID);
1895 }
1896 
1897 std::string
1898 TraCIAPI::VehicleTypeScope::getEmissionClass(const std::string& typeID) const {
1899  return getString(libsumo::VAR_EMISSIONCLASS, typeID);
1900 }
1901 
1902 std::string
1903 TraCIAPI::VehicleTypeScope::getShapeClass(const std::string& typeID) const {
1904  return getString(libsumo::VAR_SHAPECLASS, typeID);
1905 }
1906 
1907 double
1908 TraCIAPI::VehicleTypeScope::getMinGap(const std::string& typeID) const {
1909  return getDouble(libsumo::VAR_MINGAP, typeID);
1910 }
1911 
1912 double
1913 TraCIAPI::VehicleTypeScope::getMinGapLat(const std::string& typeID) const {
1914  return getDouble(libsumo::VAR_MINGAP_LAT, typeID);
1915 }
1916 
1917 double
1918 TraCIAPI::VehicleTypeScope::getMaxSpeedLat(const std::string& typeID) const {
1919  return getDouble(libsumo::VAR_MAXSPEED_LAT, typeID);
1920 }
1921 
1922 std::string
1923 TraCIAPI::VehicleTypeScope::getLateralAlignment(const std::string& typeID) const {
1924  return getString(libsumo::VAR_LATALIGNMENT, typeID);
1925 }
1926 
1927 int
1928 TraCIAPI::VehicleTypeScope::getPersonCapacity(const std::string& typeID) const {
1929  return getInt(libsumo::VAR_PERSON_CAPACITY, typeID);
1930 }
1931 
1932 double
1933 TraCIAPI::VehicleTypeScope::getWidth(const std::string& typeID) const {
1934  return getDouble(libsumo::VAR_WIDTH, typeID);
1935 }
1936 
1937 double
1938 TraCIAPI::VehicleTypeScope::getHeight(const std::string& typeID) const {
1939  return getDouble(libsumo::VAR_HEIGHT, typeID);
1940 }
1941 
1943 TraCIAPI::VehicleTypeScope::getColor(const std::string& typeID) const {
1944  return getCol(libsumo::VAR_COLOR, typeID);
1945 }
1946 
1947 
1948 
1949 void
1950 TraCIAPI::VehicleTypeScope::setLength(const std::string& typeID, double length) const {
1951  tcpip::Storage content;
1953  content.writeDouble(length);
1954  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_LENGTH, typeID, &content);
1955  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1956 }
1957 
1958 void
1959 TraCIAPI::VehicleTypeScope::setMaxSpeed(const std::string& typeID, double speed) const {
1960  tcpip::Storage content;
1962  content.writeDouble(speed);
1963  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MAXSPEED, typeID, &content);
1964  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1965 }
1966 
1967 void
1968 TraCIAPI::VehicleTypeScope::setVehicleClass(const std::string& typeID, const std::string& clazz) const {
1969  tcpip::Storage content;
1971  content.writeString(clazz);
1972  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_VEHICLECLASS, typeID, &content);
1973  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1974 }
1975 
1976 void
1977 TraCIAPI::VehicleTypeScope::setSpeedFactor(const std::string& typeID, double factor) const {
1978  tcpip::Storage content;
1980  content.writeDouble(factor);
1981  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SPEED_FACTOR, typeID, &content);
1982  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1983 }
1984 
1985 void
1986 TraCIAPI::VehicleTypeScope::setSpeedDeviation(const std::string& typeID, double deviation) const {
1987  tcpip::Storage content;
1989  content.writeDouble(deviation);
1990  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SPEED_DEVIATION, typeID, &content);
1991  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1992 }
1993 
1994 
1995 void
1996 TraCIAPI::VehicleTypeScope::setEmissionClass(const std::string& typeID, const std::string& clazz) const {
1997  tcpip::Storage content;
1999  content.writeString(clazz);
2000  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_EMISSIONCLASS, typeID, &content);
2001  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2002 }
2003 
2004 void
2005 TraCIAPI::VehicleTypeScope::setWidth(const std::string& typeID, double width) const {
2006  tcpip::Storage content;
2008  content.writeDouble(width);
2009  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_WIDTH, typeID, &content);
2010  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2011 }
2012 
2013 void
2014 TraCIAPI::VehicleTypeScope::setHeight(const std::string& typeID, double height) const {
2015  tcpip::Storage content;
2017  content.writeDouble(height);
2018  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_HEIGHT, typeID, &content);
2019  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2020 }
2021 
2022 void
2023 TraCIAPI::VehicleTypeScope::setMinGap(const std::string& typeID, double minGap) const {
2024  tcpip::Storage content;
2026  content.writeDouble(minGap);
2027  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MINGAP, typeID, &content);
2028  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2029 }
2030 
2031 
2032 void
2033 TraCIAPI::VehicleTypeScope::setMinGapLat(const std::string& typeID, double minGapLat) const {
2034  tcpip::Storage content;
2036  content.writeDouble(minGapLat);
2037  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MINGAP_LAT, typeID, &content);
2038  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2039 }
2040 
2041 void
2042 TraCIAPI::VehicleTypeScope::setMaxSpeedLat(const std::string& typeID, double speed) const {
2043  tcpip::Storage content;
2045  content.writeDouble(speed);
2046  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MAXSPEED_LAT, typeID, &content);
2047  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2048 }
2049 
2050 void
2051 TraCIAPI::VehicleTypeScope::setLateralAlignment(const std::string& typeID, const std::string& latAlignment) const {
2052  tcpip::Storage content;
2054  content.writeString(latAlignment);
2055  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_LATALIGNMENT, typeID, &content);
2056  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2057 }
2058 
2059 void
2060 TraCIAPI::VehicleTypeScope::copy(const std::string& origTypeID, const std::string& newTypeID) const {
2061  tcpip::Storage content;
2063  content.writeString(newTypeID);
2064  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::COPY, origTypeID, &content);
2065  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2066 }
2067 
2068 void
2069 TraCIAPI::VehicleTypeScope::setShapeClass(const std::string& typeID, const std::string& clazz) const {
2070  tcpip::Storage content;
2072  content.writeString(clazz);
2073  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SHAPECLASS, typeID, &content);
2074  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2075 }
2076 
2077 void
2078 TraCIAPI::VehicleTypeScope::setAccel(const std::string& typeID, double accel) const {
2079  tcpip::Storage content;
2081  content.writeDouble(accel);
2082  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_ACCEL, typeID, &content);
2083  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2084 }
2085 
2086 void
2087 TraCIAPI::VehicleTypeScope::setDecel(const std::string& typeID, double decel) const {
2088  tcpip::Storage content;
2090  content.writeDouble(decel);
2091  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_DECEL, typeID, &content);
2092  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2093 }
2094 
2095 void
2096 TraCIAPI::VehicleTypeScope::setEmergencyDecel(const std::string& typeID, double decel) const {
2097  tcpip::Storage content;
2099  content.writeDouble(decel);
2100  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_EMERGENCY_DECEL, typeID, &content);
2101  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2102 }
2103 
2104 void
2105 TraCIAPI::VehicleTypeScope::setApparentDecel(const std::string& typeID, double decel) const {
2106  tcpip::Storage content;
2108  content.writeDouble(decel);
2109  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_APPARENT_DECEL, typeID, &content);
2110  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2111 }
2112 
2113 void
2114 TraCIAPI::VehicleTypeScope::setImperfection(const std::string& typeID, double imperfection) const {
2115  tcpip::Storage content;
2117  content.writeDouble(imperfection);
2118  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_IMPERFECTION, typeID, &content);
2119  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2120 }
2121 
2122 void
2123 TraCIAPI::VehicleTypeScope::setTau(const std::string& typeID, double tau) const {
2124  tcpip::Storage content;
2126  content.writeDouble(tau);
2127  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_TAU, typeID, &content);
2128  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2129 }
2130 
2131 void
2132 TraCIAPI::VehicleTypeScope::setColor(const std::string& typeID, const libsumo::TraCIColor& c) const {
2133  tcpip::Storage content;
2135  content.writeUnsignedByte(c.r);
2136  content.writeUnsignedByte(c.g);
2137  content.writeUnsignedByte(c.b);
2138  content.writeUnsignedByte(c.a);
2139  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_COLOR, typeID, &content);
2140  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2141 }
2142 
2143 
2144 // ---------------------------------------------------------------------------
2145 // TraCIAPI::VehicleScope-methods
2146 // ---------------------------------------------------------------------------
2147 double
2148 TraCIAPI::VehicleScope::getSpeed(const std::string& vehicleID) const {
2149  return getDouble(libsumo::VAR_SPEED, vehicleID);
2150 }
2151 
2152 double
2153 TraCIAPI::VehicleScope::getLateralSpeed(const std::string& vehicleID) const {
2154  return getDouble(libsumo::VAR_SPEED_LAT, vehicleID);
2155 }
2156 
2157 double
2158 TraCIAPI::VehicleScope::getAcceleration(const std::string& vehicleID) const {
2159  return getDouble(libsumo::VAR_ACCELERATION, vehicleID);
2160 }
2161 
2162 double
2163 TraCIAPI::VehicleScope::getFollowSpeed(const std::string& vehicleID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) const {
2164  tcpip::Storage content;
2166  content.writeInt(5);
2168  content.writeDouble(speed);
2170  content.writeDouble(gap);
2172  content.writeDouble(leaderSpeed);
2174  content.writeDouble(leaderMaxDecel);
2176  content.writeString(leaderID);
2177  return getDouble(libsumo::VAR_FOLLOW_SPEED, vehicleID, &content);
2178 }
2179 
2180 
2181 double
2182 TraCIAPI::VehicleScope::getSecureGap(const std::string& vehicleID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) const {
2183  tcpip::Storage content;
2185  content.writeInt(4);
2187  content.writeDouble(speed);
2189  content.writeDouble(leaderSpeed);
2191  content.writeDouble(leaderMaxDecel);
2193  content.writeString(leaderID);
2194  return getDouble(libsumo::VAR_SECURE_GAP, vehicleID, &content);
2195 }
2196 
2197 double
2198 TraCIAPI::VehicleScope::getStopSpeed(const std::string& vehicleID, double speed, double gap) const {
2199  tcpip::Storage content;
2201  content.writeInt(2);
2203  content.writeDouble(speed);
2205  content.writeDouble(gap);
2206  return getDouble(libsumo::VAR_STOP_SPEED, vehicleID, &content);
2207 }
2208 
2209 
2210 double
2211 TraCIAPI::VehicleScope::getMaxSpeed(const std::string& vehicleID) const {
2212  return getDouble(libsumo::VAR_MAXSPEED, vehicleID);
2213 }
2214 
2216 TraCIAPI::VehicleScope::getPosition(const std::string& vehicleID) const {
2217  return getPos(libsumo::VAR_POSITION, vehicleID);
2218 }
2219 
2221 TraCIAPI::VehicleScope::getPosition3D(const std::string& vehicleID) const {
2222  return getPos3D(libsumo::VAR_POSITION3D, vehicleID);
2223 }
2224 
2225 double
2226 TraCIAPI::VehicleScope::getAngle(const std::string& vehicleID) const {
2227  return getDouble(libsumo::VAR_ANGLE, vehicleID);
2228 }
2229 
2230 std::string
2231 TraCIAPI::VehicleScope::getRoadID(const std::string& vehicleID) const {
2232  return getString(libsumo::VAR_ROAD_ID, vehicleID);
2233 }
2234 
2235 std::string
2236 TraCIAPI::VehicleScope::getLaneID(const std::string& vehicleID) const {
2237  return getString(libsumo::VAR_LANE_ID, vehicleID);
2238 }
2239 
2240 int
2241 TraCIAPI::VehicleScope::getLaneIndex(const std::string& vehicleID) const {
2242  return getInt(libsumo::VAR_LANE_INDEX, vehicleID);
2243 }
2244 
2245 std::string
2246 TraCIAPI::VehicleScope::getTypeID(const std::string& vehicleID) const {
2247  return getString(libsumo::VAR_TYPE, vehicleID);
2248 }
2249 
2250 std::string
2251 TraCIAPI::VehicleScope::getRouteID(const std::string& vehicleID) const {
2252  return getString(libsumo::VAR_ROUTE_ID, vehicleID);
2253 }
2254 
2255 int
2256 TraCIAPI::VehicleScope::getRouteIndex(const std::string& vehicleID) const {
2257  return getInt(libsumo::VAR_ROUTE_INDEX, vehicleID);
2258 }
2259 
2260 
2261 std::vector<std::string>
2262 TraCIAPI::VehicleScope::getRoute(const std::string& vehicleID) const {
2263  return getStringVector(libsumo::VAR_EDGES, vehicleID);
2264 }
2265 
2267 TraCIAPI::VehicleScope::getColor(const std::string& vehicleID) const {
2268  return getCol(libsumo::VAR_COLOR, vehicleID);
2269 }
2270 
2271 double
2272 TraCIAPI::VehicleScope::getLanePosition(const std::string& vehicleID) const {
2273  return getDouble(libsumo::VAR_LANEPOSITION, vehicleID);
2274 }
2275 
2276 double
2277 TraCIAPI::VehicleScope::getDistance(const std::string& vehicleID) const {
2278  return getDouble(libsumo::VAR_DISTANCE, vehicleID);
2279 }
2280 
2281 int
2282 TraCIAPI::VehicleScope::getSignals(const std::string& vehicleID) const {
2283  return getInt(libsumo::VAR_SIGNALS, vehicleID);
2284 }
2285 
2286 double
2287 TraCIAPI::VehicleScope::getLateralLanePosition(const std::string& vehicleID) const {
2288  return getDouble(libsumo::VAR_LANEPOSITION_LAT, vehicleID);
2289 }
2290 
2291 double
2292 TraCIAPI::VehicleScope::getCO2Emission(const std::string& vehicleID) const {
2293  return getDouble(libsumo::VAR_CO2EMISSION, vehicleID);
2294 }
2295 
2296 double
2297 TraCIAPI::VehicleScope::getCOEmission(const std::string& vehicleID) const {
2298  return getDouble(libsumo::VAR_COEMISSION, vehicleID);
2299 }
2300 
2301 double
2302 TraCIAPI::VehicleScope::getHCEmission(const std::string& vehicleID) const {
2303  return getDouble(libsumo::VAR_HCEMISSION, vehicleID);
2304 }
2305 
2306 double
2307 TraCIAPI::VehicleScope::getPMxEmission(const std::string& vehicleID) const {
2308  return getDouble(libsumo::VAR_PMXEMISSION, vehicleID);
2309 }
2310 
2311 double
2312 TraCIAPI::VehicleScope::getNOxEmission(const std::string& vehicleID) const {
2313  return getDouble(libsumo::VAR_NOXEMISSION, vehicleID);
2314 }
2315 
2316 double
2317 TraCIAPI::VehicleScope::getFuelConsumption(const std::string& vehicleID) const {
2318  return getDouble(libsumo::VAR_FUELCONSUMPTION, vehicleID);
2319 }
2320 
2321 double
2322 TraCIAPI::VehicleScope::getNoiseEmission(const std::string& vehicleID) const {
2323  return getDouble(libsumo::VAR_NOISEEMISSION, vehicleID);
2324 }
2325 
2326 double
2327 TraCIAPI::VehicleScope::getElectricityConsumption(const std::string& vehicleID) const {
2328  return getDouble(libsumo::VAR_ELECTRICITYCONSUMPTION, vehicleID);
2329 }
2330 
2331 double
2332 TraCIAPI::VehicleScope::getWaitingTime(const std::string& vehID) const {
2333  return getDouble(libsumo::VAR_WAITING_TIME, vehID);
2334 }
2335 
2336 int
2337 TraCIAPI::VehicleScope::getLaneChangeMode(const std::string& vehID) const {
2338  return getInt(libsumo::VAR_LANECHANGE_MODE, vehID);
2339 }
2340 
2341 
2342 int
2343 TraCIAPI::VehicleScope::getSpeedMode(const std::string& vehID) const {
2344  return getInt(libsumo::VAR_SPEEDSETMODE, vehID);
2345 }
2346 
2347 
2348 double
2349 TraCIAPI::VehicleScope::getSlope(const std::string& vehID) const {
2350  return getDouble(libsumo::VAR_SLOPE, vehID);
2351 }
2352 
2353 
2354 std::string
2355 TraCIAPI::VehicleScope::getLine(const std::string& typeID) const {
2356  return getString(libsumo::VAR_LINE, typeID);
2357 }
2358 
2359 std::vector<std::string>
2360 TraCIAPI::VehicleScope::getVia(const std::string& vehicleID) const {
2361  return getStringVector(libsumo::VAR_VIA, vehicleID);
2362 }
2363 
2364 std::string
2365 TraCIAPI::VehicleScope::getEmissionClass(const std::string& vehicleID) const {
2366  return getString(libsumo::VAR_EMISSIONCLASS, vehicleID);
2367 }
2368 
2369 std::string
2370 TraCIAPI::VehicleScope::getShapeClass(const std::string& vehicleID) const {
2371  return getString(libsumo::VAR_SHAPECLASS, vehicleID);
2372 }
2373 
2374 std::vector<libsumo::TraCINextTLSData>
2375 TraCIAPI::VehicleScope::getNextTLS(const std::string& vehID) const {
2376  std::vector<libsumo::TraCINextTLSData> result;
2377  myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_NEXT_TLS, vehID);
2378  if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
2379  myParent.myInput.readInt(); // components
2380  // number of items
2381  myParent.myInput.readUnsignedByte();
2382  const int n = myParent.myInput.readInt();
2383  for (int i = 0; i < n; ++i) {
2385  myParent.myInput.readUnsignedByte();
2386  d.id = myParent.myInput.readString();
2387 
2388  myParent.myInput.readUnsignedByte();
2389  d.tlIndex = myParent.myInput.readInt();
2390 
2391  myParent.myInput.readUnsignedByte();
2392  d.dist = myParent.myInput.readDouble();
2393 
2394  myParent.myInput.readUnsignedByte();
2395  d.state = (char)myParent.myInput.readByte();
2396 
2397  result.push_back(d);
2398  }
2399  }
2400  return result;
2401 }
2402 
2403 std::vector<libsumo::TraCIBestLanesData>
2404 TraCIAPI::VehicleScope::getBestLanes(const std::string& vehicleID) const {
2405  std::vector<libsumo::TraCIBestLanesData> result;
2406  myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_BEST_LANES, vehicleID);
2407  if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
2408  myParent.myInput.readInt();
2409  myParent.myInput.readUnsignedByte();
2410 
2411  const int n = myParent.myInput.readInt(); // number of following edge information
2412  for (int i = 0; i < n; ++i) {
2414  myParent.myInput.readUnsignedByte();
2415  info.laneID = myParent.myInput.readString();
2416 
2417  myParent.myInput.readUnsignedByte();
2418  info.length = myParent.myInput.readDouble();
2419 
2420  myParent.myInput.readUnsignedByte();
2421  info.occupation = myParent.myInput.readDouble();
2422 
2423  myParent.myInput.readUnsignedByte();
2424  info.bestLaneOffset = myParent.myInput.readByte();
2425 
2426  myParent.myInput.readUnsignedByte();
2427  info.allowsContinuation = (myParent.myInput.readUnsignedByte() == 1);
2428 
2429  myParent.myInput.readUnsignedByte();
2430  const int m = myParent.myInput.readInt();
2431  for (int j = 0; j < m; ++j) {
2432  info.continuationLanes.push_back(myParent.myInput.readString());
2433  }
2434 
2435  result.push_back(info);
2436  }
2437  }
2438  return result;
2439 }
2440 
2441 
2442 std::pair<std::string, double>
2443 TraCIAPI::VehicleScope::getLeader(const std::string& vehicleID, double dist) const {
2444  tcpip::Storage content;
2446  content.writeDouble(dist);
2447  myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_LEADER, vehicleID, &content);
2448  if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
2449  myParent.myInput.readInt(); // components
2450  myParent.myInput.readUnsignedByte();
2451  const std::string leaderID = myParent.myInput.readString();
2452  myParent.myInput.readUnsignedByte();
2453  const double gap = myParent.myInput.readDouble();
2454  return std::make_pair(leaderID, gap);
2455  }
2456  return std::make_pair("", libsumo::INVALID_DOUBLE_VALUE);
2457 }
2458 
2459 
2460 std::pair<std::string, double>
2461 TraCIAPI::VehicleScope::getFollower(const std::string& vehicleID, double dist) const {
2462  tcpip::Storage content;
2464  content.writeDouble(dist);
2465  myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_FOLLOWER, vehicleID, &content);
2466  if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
2467  myParent.myInput.readInt(); // components
2468  myParent.myInput.readUnsignedByte();
2469  const std::string leaderID = myParent.myInput.readString();
2470  myParent.myInput.readUnsignedByte();
2471  const double gap = myParent.myInput.readDouble();
2472  return std::make_pair(leaderID, gap);
2473  }
2474  return std::make_pair("", libsumo::INVALID_DOUBLE_VALUE);
2475 }
2476 
2477 
2478 std::pair<int, int>
2479 TraCIAPI::VehicleScope::getLaneChangeState(const std::string& vehicleID, int direction) const {
2480  tcpip::Storage content;
2482  content.writeInt(direction);
2483  myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
2484  if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
2485  myParent.myInput.readInt(); // components
2486  myParent.myInput.readUnsignedByte();
2487  const int stateWithoutTraCI = myParent.myInput.readInt();
2488  myParent.myInput.readUnsignedByte();
2489  const int state = myParent.myInput.readInt();
2490  return std::make_pair(stateWithoutTraCI, state);
2491  }
2493 }
2494 
2495 
2496 int
2497 TraCIAPI::VehicleScope::getStopState(const std::string& vehicleID) const {
2498  return getInt(libsumo::VAR_STOPSTATE, vehicleID);
2499 }
2500 
2501 int
2502 TraCIAPI::VehicleScope::getRoutingMode(const std::string& vehicleID) const {
2503  return getInt(libsumo::VAR_ROUTING_MODE, vehicleID);
2504 }
2505 
2506 double
2507 TraCIAPI::VehicleScope::getStopDelay(const std::string& vehicleID) const {
2508  return getDouble(libsumo::VAR_STOP_DELAY, vehicleID);
2509 }
2510 
2511 double
2512 TraCIAPI::VehicleScope::getStopArrivalDelay(const std::string& vehicleID) const {
2513  return getDouble(libsumo::VAR_STOP_ARRIVALDELAY, vehicleID);
2514 }
2515 
2516 
2517 double
2518 TraCIAPI::VehicleScope::getAccel(const std::string& vehicleID) const {
2519  return getDouble(libsumo::VAR_ACCEL, vehicleID);
2520 }
2521 
2522 double
2523 TraCIAPI::VehicleScope::getDecel(const std::string& vehicleID) const {
2524  return getDouble(libsumo::VAR_DECEL, vehicleID);
2525 }
2526 
2527 double
2528 TraCIAPI::VehicleScope::getTau(const std::string& vehicleID) const {
2529  return getDouble(libsumo::VAR_TAU, vehicleID);
2530 }
2531 
2532 double
2533 TraCIAPI::VehicleScope::getImperfection(const std::string& vehicleID) const {
2534  return getDouble(libsumo::VAR_IMPERFECTION, vehicleID);
2535 }
2536 
2537 double
2538 TraCIAPI::VehicleScope::getSpeedFactor(const std::string& vehicleID) const {
2539  return getDouble(libsumo::VAR_SPEED_FACTOR, vehicleID);
2540 }
2541 
2542 double
2543 TraCIAPI::VehicleScope::getSpeedDeviation(const std::string& vehicleID) const {
2544  return getDouble(libsumo::VAR_SPEED_DEVIATION, vehicleID);
2545 }
2546 
2547 std::string
2548 TraCIAPI::VehicleScope::getVehicleClass(const std::string& vehicleID) const {
2549  return getString(libsumo::VAR_VEHICLECLASS, vehicleID);
2550 }
2551 
2552 double
2553 TraCIAPI::VehicleScope::getMinGap(const std::string& vehicleID) const {
2554  return getDouble(libsumo::VAR_MINGAP, vehicleID);
2555 }
2556 
2557 double
2558 TraCIAPI::VehicleScope::getWidth(const std::string& vehicleID) const {
2559  return getDouble(libsumo::VAR_WIDTH, vehicleID);
2560 }
2561 
2562 double
2563 TraCIAPI::VehicleScope::getLength(const std::string& vehicleID) const {
2564  return getDouble(libsumo::VAR_LENGTH, vehicleID);
2565 }
2566 
2567 double
2568 TraCIAPI::VehicleScope::getHeight(const std::string& vehicleID) const {
2569  return getDouble(libsumo::VAR_HEIGHT, vehicleID);
2570 }
2571 
2572 double
2573 TraCIAPI::VehicleScope::getAccumulatedWaitingTime(const std::string& vehicleID) const {
2574  return getDouble(libsumo::VAR_ACCUMULATED_WAITING_TIME, vehicleID);
2575 }
2576 
2577 double
2578 TraCIAPI::VehicleScope::getAllowedSpeed(const std::string& vehicleID) const {
2579  return getDouble(libsumo::VAR_ALLOWED_SPEED, vehicleID);
2580 }
2581 
2582 int
2583 TraCIAPI::VehicleScope::getPersonNumber(const std::string& vehicleID) const {
2584  return getInt(libsumo::VAR_PERSON_NUMBER, vehicleID);
2585 }
2586 
2587 int
2588 TraCIAPI::VehicleScope::getPersonCapacity(const std::string& vehicleID) const {
2589  return getInt(libsumo::VAR_PERSON_CAPACITY, vehicleID);
2590 }
2591 
2592 std::vector<std::string>
2593 TraCIAPI::VehicleScope::getPersonIDList(const std::string& vehicleID) const {
2594  return getStringVector(libsumo::LAST_STEP_PERSON_ID_LIST, vehicleID);
2595 }
2596 
2597 double
2598 TraCIAPI::VehicleScope::getSpeedWithoutTraCI(const std::string& vehicleID) const {
2599  return getDouble(libsumo::VAR_SPEED_WITHOUT_TRACI, vehicleID);
2600 }
2601 
2602 bool
2603 TraCIAPI::VehicleScope::isRouteValid(const std::string& vehicleID) const {
2604  return getInt(libsumo::VAR_ROUTE_VALID, vehicleID) != 0;
2605 }
2606 
2607 double
2608 TraCIAPI::VehicleScope::getMaxSpeedLat(const std::string& vehicleID) const {
2609  return getDouble(libsumo::VAR_MAXSPEED_LAT, vehicleID);
2610 }
2611 
2612 double
2613 TraCIAPI::VehicleScope::getMinGapLat(const std::string& vehicleID) const {
2614  return getDouble(libsumo::VAR_MINGAP_LAT, vehicleID);
2615 }
2616 
2617 std::string
2618 TraCIAPI::VehicleScope::getLateralAlignment(const std::string& vehicleID) const {
2619  return getString(libsumo::VAR_LATALIGNMENT, vehicleID);
2620 }
2621 
2622 void
2623 TraCIAPI::VehicleScope::add(const std::string& vehicleID,
2624  const std::string& routeID,
2625  const std::string& typeID,
2626  std::string depart,
2627  const std::string& departLane,
2628  const std::string& departPos,
2629  const std::string& departSpeed,
2630  const std::string& arrivalLane,
2631  const std::string& arrivalPos,
2632  const std::string& arrivalSpeed,
2633  const std::string& fromTaz,
2634  const std::string& toTaz,
2635  const std::string& line,
2636  int personCapacity,
2637  int personNumber) const {
2638 
2639  if (depart == "-1") {
2640  depart = toString(myParent.simulation.getCurrentTime() / 1000.0);
2641  }
2642  tcpip::Storage content;
2644  content.writeInt(14);
2646  content.writeString(routeID);
2648  content.writeString(typeID);
2650  content.writeString(depart);
2652  content.writeString(departLane);
2654  content.writeString(departPos);
2656  content.writeString(departSpeed);
2657 
2659  content.writeString(arrivalLane);
2661  content.writeString(arrivalPos);
2663  content.writeString(arrivalSpeed);
2664 
2666  content.writeString(fromTaz);
2668  content.writeString(toTaz);
2670  content.writeString(line);
2671 
2673  content.writeInt(personCapacity);
2675  content.writeInt(personNumber);
2676 
2677  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::ADD_FULL, vehicleID, &content);
2678  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2679 }
2680 
2681 
2682 void
2683 TraCIAPI::VehicleScope::remove(const std::string& vehicleID, char reason) const {
2684  tcpip::Storage content;
2686  content.writeUnsignedByte(reason);
2687  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::REMOVE, vehicleID, &content);
2688  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2689 
2690 }
2691 
2692 
2693 void
2694 TraCIAPI::VehicleScope::changeTarget(const std::string& vehicleID, const std::string& edgeID) const {
2695  tcpip::Storage content;
2697  content.writeString(edgeID);
2698  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGETARGET, vehicleID, &content);
2699  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2700 }
2701 
2702 
2703 void
2704 TraCIAPI::VehicleScope::changeLane(const std::string& vehicleID, int laneIndex, double duration) const {
2705  tcpip::Storage content;
2707  content.writeInt(2);
2709  content.writeByte(laneIndex);
2711  content.writeDouble(duration);
2712  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
2713  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2714 }
2715 
2716 
2717 void
2718 TraCIAPI::VehicleScope::changeLaneRelative(const std::string& vehicleID, int laneChange, double duration) const {
2719  tcpip::Storage content;
2721  content.writeInt(3);
2723  content.writeByte(laneChange);
2725  content.writeDouble(duration);
2727  content.writeByte(1);
2728  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
2729  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2730 }
2731 
2732 
2733 void
2734 TraCIAPI::VehicleScope::changeSublane(const std::string& vehicleID, double latDist) const {
2735  tcpip::Storage content;
2737  content.writeDouble(latDist);
2738  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGESUBLANE, vehicleID, &content);
2739  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2740 }
2741 
2742 
2743 void
2744 TraCIAPI::VehicleScope::setRouteID(const std::string& vehicleID, const std::string& routeID) const {
2745  tcpip::Storage content;
2747  content.writeString(routeID);
2748  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTE_ID, vehicleID, &content);
2749  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2750 }
2751 
2752 
2753 void
2754 TraCIAPI::VehicleScope::setRoute(const std::string& vehicleID, const std::vector<std::string>& edges) const {
2755  tcpip::Storage content;
2757  content.writeInt((int)edges.size());
2758  for (int i = 0; i < (int)edges.size(); ++i) {
2759  content.writeString(edges[i]);
2760  }
2761  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTE, vehicleID, &content);
2762  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2763 }
2764 
2765 
2766 void
2767 TraCIAPI::VehicleScope::rerouteTraveltime(const std::string& vehicleID, bool currentTravelTimes) const {
2768  if (currentTravelTimes) {
2769  // updated edge weights with current network traveltimes (at most once per simulation step)
2770  std::vector<std::string> edges = myParent.edge.getIDList();
2771  for (std::vector<std::string>::iterator it = edges.begin(); it != edges.end(); ++it) {
2772  myParent.edge.adaptTraveltime(*it, myParent.edge.getTraveltime(*it));
2773  }
2774  }
2775 
2776  tcpip::Storage content;
2778  content.writeInt(0);
2779  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_REROUTE_TRAVELTIME, vehicleID, &content);
2780  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2781 }
2782 
2783 void
2784 TraCIAPI::VehicleScope::moveTo(const std::string& vehicleID, const std::string& laneID, double position, int reason) const {
2785  tcpip::Storage content;
2787  content.writeInt(3);
2789  content.writeString(laneID);
2791  content.writeDouble(position);
2793  content.writeInt(reason);
2794  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MOVE_TO, vehicleID, &content);
2795  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2796 }
2797 
2798 void
2799 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 {
2800  tcpip::Storage content;
2802  content.writeInt(6);
2804  content.writeString(edgeID);
2806  content.writeInt(lane);
2808  content.writeDouble(x);
2810  content.writeDouble(y);
2812  content.writeDouble(angle);
2814  content.writeByte(keepRoute);
2815  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::MOVE_TO_XY, vehicleID, &content);
2816  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2817 }
2818 
2819 
2820 void
2821 TraCIAPI::VehicleScope::slowDown(const std::string& vehicleID, double speed, double duration) const {
2822  tcpip::Storage content;
2824  content.writeInt(2);
2826  content.writeDouble(speed);
2828  content.writeDouble(duration);
2829  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_SLOWDOWN, vehicleID, &content);
2830  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2831 }
2832 
2833 void
2834 TraCIAPI::VehicleScope::openGap(const std::string& vehicleID, double newTau, double duration, double changeRate, double maxDecel) const {
2835  tcpip::Storage content;
2837  if (maxDecel > 0) {
2838  content.writeInt(4);
2839  } else {
2840  content.writeInt(3);
2841  }
2843  content.writeDouble(newTau);
2845  content.writeDouble(duration);
2847  content.writeDouble(changeRate);
2848  if (maxDecel > 0) {
2850  content.writeDouble(maxDecel);
2851  }
2852  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_OPENGAP, vehicleID, &content);
2853  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2854 }
2855 
2856 void
2857 TraCIAPI::VehicleScope::setSpeed(const std::string& vehicleID, double speed) const {
2858  tcpip::Storage content;
2860  content.writeDouble(speed);
2861  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEED, vehicleID, &content);
2862  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2863 }
2864 
2865 void
2866 TraCIAPI::VehicleScope::setPreviousSpeed(const std::string& vehicleID, double prevspeed) const {
2867  tcpip::Storage content;
2869  content.writeDouble(prevspeed);
2870  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_PREV_SPEED, vehicleID, &content);
2871  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2872 }
2873 
2874 void
2875 TraCIAPI::VehicleScope::setLaneChangeMode(const std::string& vehicleID, int mode) const {
2876  tcpip::Storage content;
2878  content.writeInt(mode);
2879  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_LANECHANGE_MODE, vehicleID, &content);
2880  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2881 }
2882 
2883 void
2884 TraCIAPI::VehicleScope::setSpeedMode(const std::string& vehicleID, int mode) const {
2885  tcpip::Storage content;
2887  content.writeInt(mode);
2888  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEEDSETMODE, vehicleID, &content);
2889  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2890 }
2891 
2892 void
2893 TraCIAPI::VehicleScope::setStop(const std::string vehicleID, const std::string edgeID, const double endPos, const int laneIndex,
2894  const double duration, const int flags, const double startPos, const double until) const {
2895  tcpip::Storage content;
2897  content.writeInt(7);
2899  content.writeString(edgeID);
2901  content.writeDouble(endPos);
2903  content.writeByte(laneIndex);
2905  content.writeDouble(duration);
2907  content.writeByte(flags);
2909  content.writeDouble(startPos);
2911  content.writeDouble(until);
2912  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_STOP, vehicleID, &content);
2913  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2914 }
2915 
2916 void
2917 TraCIAPI::VehicleScope::setType(const std::string& vehicleID, const std::string& typeID) const {
2918  tcpip::Storage content;
2920  content.writeString(typeID);
2921  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_TYPE, vehicleID, &content);
2922  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2923 }
2924 
2925 void
2926 TraCIAPI::VehicleScope::setSpeedFactor(const std::string& vehicleID, double factor) const {
2927  tcpip::Storage content;
2929  content.writeDouble(factor);
2930  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEED_FACTOR, vehicleID, &content);
2931  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2932 }
2933 
2934 void
2935 TraCIAPI::VehicleScope::setMinGap(const std::string& vehicleID, double minGap) const {
2936  tcpip::Storage content;
2938  content.writeDouble(minGap);
2939  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MINGAP, vehicleID, &content);
2940  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2941 }
2942 
2943 void
2944 TraCIAPI::VehicleScope::setMaxSpeed(const std::string& vehicleID, double speed) const {
2945  tcpip::Storage content;
2947  content.writeDouble(speed);
2948  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MAXSPEED, vehicleID, &content);
2949  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2950 }
2951 
2952 void
2953 TraCIAPI::VehicleScope::setColor(const std::string& vehicleID, const libsumo::TraCIColor& c) const {
2954  tcpip::Storage content;
2956  content.writeUnsignedByte(c.r);
2957  content.writeUnsignedByte(c.g);
2958  content.writeUnsignedByte(c.b);
2959  content.writeUnsignedByte(c.a);
2960  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_COLOR, vehicleID, &content);
2961  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2962 }
2963 
2964 void
2965 TraCIAPI::VehicleScope::setLine(const std::string& vehicleID, const std::string& line) const {
2966  tcpip::Storage content;
2968  content.writeString(line);
2969  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_LINE, vehicleID, &content);
2970  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2971 }
2972 
2973 void
2974 TraCIAPI::VehicleScope::setVia(const std::string& vehicleID, const std::vector<std::string>& via) const {
2975  tcpip::Storage content;
2977  content.writeInt((int)via.size());
2978  for (int i = 0; i < (int)via.size(); ++i) {
2979  content.writeString(via[i]);
2980  }
2981  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_VIA, vehicleID, &content);
2982  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2983 }
2984 
2985 void
2986 TraCIAPI::VehicleScope::setSignals(const std::string& vehicleID, int signals) const {
2987  tcpip::Storage content;
2989  content.writeInt(signals);
2990  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SIGNALS, vehicleID, &content);
2991  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2992 }
2993 
2994 void
2995 TraCIAPI::VehicleScope::setRoutingMode(const std::string& vehicleID, int routingMode) const {
2996  tcpip::Storage content;
2998  content.writeInt(routingMode);
2999  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTING_MODE, vehicleID, &content);
3000  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
3001 }
3002 
3003 void
3004 TraCIAPI::VehicleScope::setShapeClass(const std::string& vehicleID, const std::string& clazz) const {
3005  tcpip::Storage content;
3007  content.writeString(clazz);
3008  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SHAPECLASS, vehicleID, &content);
3009  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
3010 }
3011 
3012 
3013 void
3014 TraCIAPI::VehicleScope::setEmissionClass(const std::string& vehicleID, const std::string& clazz) const {
3015  tcpip::Storage content;
3017  content.writeString(clazz);
3018  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_EMISSIONCLASS, vehicleID, &content);
3019  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
3020 }
3021 
3022 void
3024  bool noOpposite, double downstreamDist, double upstreamDist) const {
3025  addSubscriptionFilterByteList(libsumo::FILTER_TYPE_LANES, lanes);
3026  if (noOpposite) {
3027  addSubscriptionFilterNoOpposite();
3028  }
3029  if (downstreamDist >= 0) {
3030  addSubscriptionFilterDownstreamDistance(downstreamDist);
3031  }
3032  if (upstreamDist >= 0) {
3033  addSubscriptionFilterUpstreamDistance(upstreamDist);
3034  }
3035 }
3036 
3037 
3038 void
3040  addSubscriptionFilterEmpty(libsumo::FILTER_TYPE_NOOPPOSITE);
3041 }
3042 
3043 void
3045  addSubscriptionFilterFloat(libsumo::FILTER_TYPE_DOWNSTREAM_DIST, dist);
3046 }
3047 
3048 void
3050  addSubscriptionFilterFloat(libsumo::FILTER_TYPE_UPSTREAM_DIST, dist);
3051 }
3052 
3053 
3054 void
3055 TraCIAPI::VehicleScope::addSubscriptionFilterCFManeuver(double downstreamDist, double upstreamDist) const {
3056  addSubscriptionFilterLeadFollow(std::vector<int>({0}));
3057  if (downstreamDist >= 0) {
3058  addSubscriptionFilterDownstreamDistance(downstreamDist);
3059  }
3060  if (upstreamDist >= 0) {
3061  addSubscriptionFilterUpstreamDistance(upstreamDist);
3062  }
3063 }
3064 
3065 void
3066 TraCIAPI::VehicleScope::addSubscriptionFilterLCManeuver(int direction, bool noOpposite, double downstreamDist, double upstreamDist) const {
3067  if (abs(direction) != 1) {
3068  std::cerr << "Ignoring lane change subscription filter with non-neighboring lane offset direction " << direction << "\n";
3069  return;
3070  }
3071  addSubscriptionFilterLeadFollow(std::vector<int>({0, direction}));
3072  if (noOpposite) {
3073  addSubscriptionFilterNoOpposite();
3074  }
3075  if (downstreamDist >= 0) {
3076  addSubscriptionFilterDownstreamDistance(downstreamDist);
3077  }
3078  if (upstreamDist >= 0) {
3079  addSubscriptionFilterUpstreamDistance(upstreamDist);
3080  }
3081 }
3082 
3083 void
3084 TraCIAPI::VehicleScope::addSubscriptionFilterLeadFollow(const std::vector<int>& lanes) const {
3085  addSubscriptionFilterEmpty(libsumo::FILTER_TYPE_LEAD_FOLLOW);
3086  addSubscriptionFilterByteList(libsumo::FILTER_TYPE_LANES, lanes);
3087 }
3088 
3089 void
3090 TraCIAPI::VehicleScope::addSubscriptionFilterTurn(double downstreamDist, double foeDistToJunction) const {
3091  addSubscriptionFilterFloat(libsumo::FILTER_TYPE_TURN, foeDistToJunction);
3092  if (downstreamDist >= 0) {
3093  addSubscriptionFilterDownstreamDistance(downstreamDist);
3094  }
3095 }
3096 
3097 
3098 void
3099 TraCIAPI::VehicleScope::addSubscriptionFilterVClass(const std::vector<std::string>& vClasses) const {
3100  addSubscriptionFilterStringList(libsumo::FILTER_TYPE_VCLASS, vClasses);
3101 }
3102 
3103 
3104 void
3105 TraCIAPI::VehicleScope::addSubscriptionFilterVType(const std::vector<std::string>& vTypes) const {
3106  addSubscriptionFilterStringList(libsumo::FILTER_TYPE_VTYPE, vTypes);
3107 }
3108 
3109 
3110 void
3112  addSubscriptionFilterFloat(libsumo::FILTER_TYPE_FIELD_OF_VISION, angle);
3113 }
3114 
3115 void
3116 TraCIAPI::VehicleScope::addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist, double upstreamDist) const {
3117  addSubscriptionFilterFloat(libsumo::FILTER_TYPE_LATERAL_DIST, lateralDist);
3118  if (downstreamDist >= 0) {
3119  addSubscriptionFilterDownstreamDistance(downstreamDist);
3120  }
3121  if (upstreamDist >= 0) {
3122  addSubscriptionFilterUpstreamDistance(upstreamDist);
3123  }
3124 }
3125 
3126 void
3128  myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType);
3129  myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
3130 }
3131 
3132 void
3133 TraCIAPI::VehicleScope::addSubscriptionFilterFloat(int filterType, double val) const {
3134  tcpip::Storage content;
3136  content.writeDouble(val);
3137  myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
3138  myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
3139 }
3140 
3141 
3142 void
3143 TraCIAPI::VehicleScope::addSubscriptionFilterStringList(int filterType, const std::vector<std::string>& vals) const {
3144  tcpip::Storage content;
3146  content.writeStringList(vals);
3147  myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
3148  myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
3149 }
3150 
3151 
3152 void
3153 TraCIAPI::VehicleScope::addSubscriptionFilterByteList(int filterType, const std::vector<int>& vals) const {
3154  tcpip::Storage content;
3155  content.writeUnsignedByte((int)vals.size());
3156  for (int i : vals) {
3157  content.writeByte(i);
3158  }
3159  myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
3160  myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
3161 }
3162 
3163 
3164 // ---------------------------------------------------------------------------
3165 // TraCIAPI::PersonScope-methods
3166 // ---------------------------------------------------------------------------
3167 double
3168 TraCIAPI::PersonScope::getSpeed(const std::string& personID) const {
3169  return getDouble(libsumo::VAR_SPEED, personID);
3170 }
3171 
3173 TraCIAPI::PersonScope::getPosition(const std::string& personID) const {
3174  return getPos(libsumo::VAR_POSITION, personID);
3175 }
3176 
3178 TraCIAPI::PersonScope::getPosition3D(const std::string& personID) const {
3179  return getPos3D(libsumo::VAR_POSITION3D, personID);
3180 }
3181 
3182 double
3183 TraCIAPI::PersonScope::getAngle(const std::string& personID) const {
3184  return getDouble(libsumo::VAR_ANGLE, personID);
3185 }
3186 
3187 double
3188 TraCIAPI::PersonScope::getSlope(const std::string& personID) const {
3189  return getDouble(libsumo::VAR_SLOPE, personID);
3190 }
3191 
3192 double
3193 TraCIAPI::PersonScope::getLanePosition(const std::string& personID) const {
3194  return getDouble(libsumo::VAR_LANEPOSITION, personID);
3195 }
3196 
3198 TraCIAPI::PersonScope::getColor(const std::string& personID) const {
3199  return getCol(libsumo::VAR_COLOR, personID);
3200 }
3201 
3202 double
3203 TraCIAPI::PersonScope::getLength(const std::string& personID) const {
3204  return getDouble(libsumo::VAR_LENGTH, personID);
3205 }
3206 
3207 std::string
3208 TraCIAPI::PersonScope::getRoadID(const std::string& personID) const {
3209  return getString(libsumo::VAR_ROAD_ID, personID);
3210 }
3211 
3212 std::string
3213 TraCIAPI::PersonScope::getLaneID(const std::string& personID) const {
3214  return getString(libsumo::VAR_LANE_ID, personID);
3215 }
3216 
3217 std::string
3218 TraCIAPI::PersonScope::getTypeID(const std::string& personID) const {
3219  return getString(libsumo::VAR_TYPE, personID);
3220 }
3221 
3222 double
3223 TraCIAPI::PersonScope::getSpeedFactor(const std::string& personID) const {
3224  return getDouble(libsumo::VAR_SPEED_FACTOR, personID);
3225 }
3226 
3227 double
3228 TraCIAPI::PersonScope::getWaitingTime(const std::string& personID) const {
3229  return getDouble(libsumo::VAR_WAITING_TIME, personID);
3230 }
3231 
3232 std::string
3233 TraCIAPI::PersonScope::getNextEdge(const std::string& personID) const {
3234  return getString(libsumo::VAR_NEXT_EDGE, personID);
3235 }
3236 
3237 
3238 std::string
3239 TraCIAPI::PersonScope::getVehicle(const std::string& personID) const {
3240  return getString(libsumo::VAR_VEHICLE, personID);
3241 }
3242 
3243 int
3244 TraCIAPI::PersonScope::getRemainingStages(const std::string& personID) const {
3245  return getInt(libsumo::VAR_STAGES_REMAINING, personID);
3246 }
3247 
3249 TraCIAPI::PersonScope::getStage(const std::string& personID, int nextStageIndex) const {
3250  tcpip::Storage content;
3252  content.writeInt(nextStageIndex);
3253  return getTraCIStage(libsumo::VAR_STAGE, personID, &content);
3254 }
3255 
3256 std::vector<std::string>
3257 TraCIAPI::PersonScope::getEdges(const std::string& personID, int nextStageIndex) const {
3258  tcpip::Storage content;
3260  content.writeInt(nextStageIndex);
3261  return getStringVector(libsumo::VAR_EDGES, personID, &content);
3262 }
3263 
3264 void
3265 TraCIAPI::PersonScope::removeStages(const std::string& personID) const {
3266  // remove all stages after the current and then abort the current stage
3267  while (getRemainingStages(personID) > 1) {
3268  removeStage(personID, 1);
3269  }
3270  removeStage(personID, 0);
3271 }
3272 
3273 
3274 void
3275 TraCIAPI::PersonScope::rerouteTraveltime(const std::string& personID) const {
3276  tcpip::Storage content;
3278  content.writeInt(0);
3279  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::CMD_REROUTE_TRAVELTIME, personID, &content);
3280  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3281 }
3282 
3283 
3284 void
3285 TraCIAPI::PersonScope::add(const std::string& personID, const std::string& edgeID, double pos, double depart, const std::string typeID) {
3286  tcpip::Storage content;
3288  content.writeInt(4);
3290  content.writeString(typeID);
3292  content.writeString(edgeID);
3294  content.writeDouble(depart);
3296  content.writeDouble(pos);
3297  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::ADD, personID, &content);
3298  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3299 }
3300 
3301 void
3302 TraCIAPI::PersonScope::appendStage(const std::string& personID, const libsumo::TraCIStage& stage) {
3303  tcpip::Storage content;
3305  content.writeInt(13);
3307  content.writeInt(stage.type);
3309  content.writeString(stage.vType);
3311  content.writeString(stage.line);
3313  content.writeString(stage.destStop);
3315  content.writeStringList(stage.edges);
3317  content.writeDouble(stage.travelTime);
3319  content.writeDouble(stage.cost);
3321  content.writeDouble(stage.length);
3323  content.writeString(stage.intended);
3325  content.writeDouble(stage.depart);
3327  content.writeDouble(stage.departPos);
3329  content.writeDouble(stage.arrivalPos);
3331  content.writeString(stage.description);
3332  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
3333  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3334 }
3335 
3336 
3337 void
3338 TraCIAPI::PersonScope::appendWaitingStage(const std::string& personID, double duration, const std::string& description, const std::string& stopID) {
3339  tcpip::Storage content;
3341  content.writeInt(4);
3345  content.writeDouble(duration);
3347  content.writeString(description);
3349  content.writeString(stopID);
3350  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
3351  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3352 }
3353 
3354 void
3355 TraCIAPI::PersonScope::appendWalkingStage(const std::string& personID, const std::vector<std::string>& edges, double arrivalPos, double duration, double speed, const std::string& stopID) {
3356  tcpip::Storage content;
3358  content.writeInt(6);
3362  content.writeStringList(edges);
3364  content.writeDouble(arrivalPos);
3366  content.writeDouble(duration);
3368  content.writeDouble(speed);
3370  content.writeString(stopID);
3371  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
3372  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3373 }
3374 
3375 void
3376 TraCIAPI::PersonScope::appendDrivingStage(const std::string& personID, const std::string& toEdge, const std::string& lines, const std::string& stopID) {
3377  tcpip::Storage content;
3379  content.writeInt(4);
3383  content.writeString(toEdge);
3385  content.writeString(lines);
3387  content.writeString(stopID);
3388  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
3389  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3390 }
3391 
3392 void
3393 TraCIAPI::PersonScope::removeStage(const std::string& personID, int nextStageIndex) const {
3394  tcpip::Storage content;
3396  content.writeInt(nextStageIndex);
3397  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::REMOVE_STAGE, personID, &content);
3398  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3399 }
3400 
3401 void
3402 TraCIAPI::PersonScope::moveTo(const std::string& personID, const std::string& edgeID, double position) const {
3403  tcpip::Storage content;
3405  content.writeInt(2);
3407  content.writeString(edgeID);
3409  content.writeDouble(position);
3410  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_MOVE_TO, personID, &content);
3411  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3412 }
3413 
3414 void
3415 TraCIAPI::PersonScope::moveToXY(const std::string& personID, const std::string& edgeID, const double x, const double y, double angle, const int keepRoute) const {
3416  tcpip::Storage content;
3418  content.writeInt(5);
3420  content.writeString(edgeID);
3422  content.writeDouble(x);
3424  content.writeDouble(y);
3426  content.writeDouble(angle);
3428  content.writeByte(keepRoute);
3429  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::MOVE_TO_XY, personID, &content);
3430  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3431 }
3432 
3433 void
3434 TraCIAPI::PersonScope::setSpeed(const std::string& personID, double speed) const {
3435  tcpip::Storage content;
3437  content.writeDouble(speed);
3438  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_SPEED, personID, &content);
3439  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3440 }
3441 
3442 
3443 void
3444 TraCIAPI::PersonScope::setType(const std::string& personID, const std::string& typeID) const {
3445  tcpip::Storage content;
3447  content.writeString(typeID);
3448  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_TYPE, personID, &content);
3449  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3450 }
3451 
3452 void
3453 TraCIAPI::PersonScope::setSpeedFactor(const std::string& personID, double factor) const {
3454  tcpip::Storage content;
3456  content.writeDouble(factor);
3457  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_SPEED_FACTOR, personID, &content);
3458  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3459 }
3460 
3461 void
3462 TraCIAPI::PersonScope::setLength(const std::string& personID, double length) const {
3463  tcpip::Storage content;
3465  content.writeDouble(length);
3466  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_LENGTH, personID, &content);
3467  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3468 }
3469 
3470 
3471 void
3472 TraCIAPI::PersonScope::setWidth(const std::string& personID, double width) const {
3473  tcpip::Storage content;
3475  content.writeDouble(width);
3476  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_WIDTH, personID, &content);
3477  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3478 }
3479 
3480 void
3481 TraCIAPI::PersonScope::setHeight(const std::string& personID, double height) const {
3482  tcpip::Storage content;
3484  content.writeDouble(height);
3485  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_HEIGHT, personID, &content);
3486  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3487 }
3488 
3489 void
3490 TraCIAPI::PersonScope::setMinGap(const std::string& personID, double minGap) const {
3491  tcpip::Storage content;
3493  content.writeDouble(minGap);
3494  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_MINGAP, personID, &content);
3495  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3496 }
3497 
3498 
3499 void
3500 TraCIAPI::PersonScope::setColor(const std::string& personID, const libsumo::TraCIColor& c) const {
3501  tcpip::Storage content;
3503  content.writeUnsignedByte(c.r);
3504  content.writeUnsignedByte(c.g);
3505  content.writeUnsignedByte(c.b);
3506  content.writeUnsignedByte(c.a);
3507  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_COLOR, personID, &content);
3508  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3509 }
3510 
3511 
3512 // ---------------------------------------------------------------------------
3513 // TraCIAPI::TraCIScopeWrapper-methods
3514 // ---------------------------------------------------------------------------
3515 
3516 int
3517 TraCIAPI::TraCIScopeWrapper::getUnsignedByte(int var, const std::string& id, tcpip::Storage* add) const {
3518  myParent.createCommand(myCmdGetID, var, id, add);
3519  if (myParent.processGet(myCmdGetID, libsumo::TYPE_UBYTE)) {
3520  return myParent.myInput.readUnsignedByte();
3521  }
3523 }
3524 
3525 
3526 int
3527 TraCIAPI::TraCIScopeWrapper::getByte(int var, const std::string& id, tcpip::Storage* add) const {
3528  myParent.createCommand(myCmdGetID, var, id, add);
3529  if (myParent.processGet(myCmdGetID, libsumo::TYPE_BYTE)) {
3530  return myParent.myInput.readByte();
3531  }
3533 }
3534 
3535 
3536 
3537 int
3538 TraCIAPI::TraCIScopeWrapper::getInt(int var, const std::string& id, tcpip::Storage* add) const {
3539  myParent.createCommand(myCmdGetID, var, id, add);
3540  if (myParent.processGet(myCmdGetID, libsumo::TYPE_INTEGER)) {
3541  return myParent.myInput.readInt();
3542  }
3544 }
3545 
3546 
3547 double
3548 TraCIAPI::TraCIScopeWrapper::getDouble(int var, const std::string& id, tcpip::Storage* add) const {
3549  myParent.createCommand(myCmdGetID, var, id, add);
3550  if (myParent.processGet(myCmdGetID, libsumo::TYPE_DOUBLE)) {
3551  return myParent.myInput.readDouble();
3552  }
3554 }
3555 
3556 
3558 TraCIAPI::TraCIScopeWrapper::getPolygon(int var, const std::string& id, tcpip::Storage* add) const {
3560  myParent.createCommand(myCmdGetID, var, id, add);
3561  if (myParent.processGet(myCmdGetID, libsumo::TYPE_POLYGON)) {
3562  int size = myParent.myInput.readUnsignedByte();
3563  if (size == 0) {
3564  size = myParent.myInput.readInt();
3565  }
3566  for (int i = 0; i < size; ++i) {
3568  p.x = myParent.myInput.readDouble();
3569  p.y = myParent.myInput.readDouble();
3570  p.z = 0.;
3571  ret.value.push_back(p);
3572  }
3573  }
3574  return ret;
3575 }
3576 
3577 
3579 TraCIAPI::TraCIScopeWrapper::getPos(int var, const std::string& id, tcpip::Storage* add) const {
3581  myParent.createCommand(myCmdGetID, var, id, add);
3582  if (myParent.processGet(myCmdGetID, libsumo::POSITION_2D)) {
3583  p.x = myParent.myInput.readDouble();
3584  p.y = myParent.myInput.readDouble();
3585  p.z = 0;
3586  }
3587  return p;
3588 }
3589 
3590 
3592 TraCIAPI::TraCIScopeWrapper::getPos3D(int var, const std::string& id, tcpip::Storage* add) const {
3594  myParent.createCommand(myCmdGetID, var, id, add);
3595  if (myParent.processGet(myCmdGetID, libsumo::POSITION_3D)) {
3596  p.x = myParent.myInput.readDouble();
3597  p.y = myParent.myInput.readDouble();
3598  p.z = myParent.myInput.readDouble();
3599  }
3600  return p;
3601 }
3602 
3603 
3604 std::string
3605 TraCIAPI::TraCIScopeWrapper::getString(int var, const std::string& id, tcpip::Storage* add) const {
3606  myParent.createCommand(myCmdGetID, var, id, add);
3607  if (myParent.processGet(myCmdGetID, libsumo::TYPE_STRING)) {
3608  return myParent.myInput.readString();
3609  }
3610  return "";
3611 }
3612 
3613 
3614 std::vector<std::string>
3615 TraCIAPI::TraCIScopeWrapper::getStringVector(int var, const std::string& id, tcpip::Storage* add) const {
3616  std::vector<std::string> r;
3617  myParent.createCommand(myCmdGetID, var, id, add);
3618  if (myParent.processGet(myCmdGetID, libsumo::TYPE_STRINGLIST)) {
3619  const int size = myParent.myInput.readInt();
3620  for (int i = 0; i < size; ++i) {
3621  r.push_back(myParent.myInput.readString());
3622  }
3623  }
3624  return r;
3625 }
3626 
3627 
3629 TraCIAPI::TraCIScopeWrapper::getCol(int var, const std::string& id, tcpip::Storage* add) const {
3631  myParent.createCommand(myCmdGetID, var, id, add);
3632  if (myParent.processGet(myCmdGetID, libsumo::TYPE_COLOR)) {
3633  c.r = (unsigned char)myParent.myInput.readUnsignedByte();
3634  c.g = (unsigned char)myParent.myInput.readUnsignedByte();
3635  c.b = (unsigned char)myParent.myInput.readUnsignedByte();
3636  c.a = (unsigned char)myParent.myInput.readUnsignedByte();
3637  }
3638  return c;
3639 }
3640 
3641 
3643 TraCIAPI::TraCIScopeWrapper::getTraCIStage(int var, const std::string& id, tcpip::Storage* add) const {
3645  myParent.createCommand(myCmdGetID, var, id, add);
3646  if (myParent.processGet(myCmdGetID, libsumo::TYPE_COMPOUND)) {
3647  myParent.myInput.readInt(); // components
3648  myParent.myInput.readUnsignedByte();
3649  s.type = myParent.myInput.readInt();
3650 
3651  myParent.myInput.readUnsignedByte();
3652  s.vType = myParent.myInput.readString();
3653 
3654  myParent.myInput.readUnsignedByte();
3655  s.line = myParent.myInput.readString();
3656 
3657  myParent.myInput.readUnsignedByte();
3658  s.destStop = myParent.myInput.readString();
3659 
3660  myParent.myInput.readUnsignedByte();
3661  s.edges = myParent.myInput.readStringList();
3662 
3663  myParent.myInput.readUnsignedByte();
3664  s.travelTime = myParent.myInput.readDouble();
3665 
3666  myParent.myInput.readUnsignedByte();
3667  s.cost = myParent.myInput.readDouble();
3668 
3669  myParent.myInput.readUnsignedByte();
3670  s.length = myParent.myInput.readDouble();
3671 
3672  myParent.myInput.readUnsignedByte();
3673  s.intended = myParent.myInput.readString();
3674 
3675  myParent.myInput.readUnsignedByte();
3676  s.depart = myParent.myInput.readDouble();
3677 
3678  myParent.myInput.readUnsignedByte();
3679  s.departPos = myParent.myInput.readDouble();
3680 
3681  myParent.myInput.readUnsignedByte();
3682  s.arrivalPos = myParent.myInput.readDouble();
3683 
3684  myParent.myInput.readUnsignedByte();
3685  s.description = myParent.myInput.readString();
3686  }
3687  return s;
3688 }
3689 
3690 
3691 std::vector<std::string>
3693  return getStringVector(libsumo::TRACI_ID_LIST, "");
3694 }
3695 
3696 
3697 int
3699  return getInt(libsumo::ID_COUNT, "");
3700 }
3701 
3702 
3703 std::string
3704 TraCIAPI::TraCIScopeWrapper::getParameter(const std::string& objectID, const std::string& key) const {
3705  tcpip::Storage content;
3707  content.writeString(key);
3708  return getString(libsumo::VAR_PARAMETER, objectID, &content);
3709 }
3710 
3711 
3712 std::pair<std::string, std::string>
3713 TraCIAPI::TraCIScopeWrapper::getParameterWithKey(const std::string& objectID, const std::string& key) const {
3714  tcpip::Storage content;
3716  content.writeString(key);
3717 
3718  myParent.createCommand(myCmdGetID, libsumo::VAR_PARAMETER_WITH_KEY, objectID, &content);
3719  if (myParent.processGet(myCmdGetID, libsumo::TYPE_COMPOUND)) {
3720  myParent.myInput.readInt(); // number of components
3721  myParent.myInput.readUnsignedByte();
3722  const std::string returnedKey = myParent.myInput.readString();
3723  myParent.myInput.readUnsignedByte();
3724  const std::string value = myParent.myInput.readString();
3725  return std::make_pair(returnedKey, value);
3726  }
3727  return std::make_pair(key, "");
3728 }
3729 
3730 
3731 void
3732 TraCIAPI::TraCIScopeWrapper::setParameter(const std::string& objectID, const std::string& key, const std::string& value) const {
3733  tcpip::Storage content;
3735  content.writeInt(2);
3737  content.writeString(key);
3739  content.writeString(value);
3740  myParent.createCommand(myCmdSetID, libsumo::VAR_PARAMETER, objectID, &content);
3741  myParent.processSet(myCmdSetID);
3742 }
3743 
3744 
3745 void
3746 TraCIAPI::TraCIScopeWrapper::setInt(int var, const std::string& id, int value) const {
3747  tcpip::Storage content;
3749  content.writeInt(value);
3750  myParent.createCommand(myCmdSetID, var, id, &content);
3751  myParent.processSet(myCmdSetID);
3752 }
3753 
3754 
3755 void
3756 TraCIAPI::TraCIScopeWrapper::setDouble(int var, const std::string& id, double value) const {
3757  tcpip::Storage content;
3759  content.writeDouble(value);
3760  myParent.createCommand(myCmdSetID, var, id, &content);
3761  myParent.processSet(myCmdSetID);
3762 }
3763 
3764 
3765 void
3766 TraCIAPI::TraCIScopeWrapper::setString(int var, const std::string& id, const std::string& value) const {
3767  tcpip::Storage content;
3769  content.writeString(value);
3770  myParent.createCommand(myCmdSetID, var, id, &content);
3771  myParent.processSet(myCmdSetID);
3772 }
3773 
3774 
3775 void
3776 TraCIAPI::TraCIScopeWrapper::setStringVector(int var, const std::string& id, const std::vector<std::string>& value) const {
3777  tcpip::Storage content;
3779  content.writeInt((int)value.size());
3780  for (const std::string& s : value) {
3781  content.writeString(s);
3782  }
3783  myParent.createCommand(myCmdSetID, var, id, &content);
3784  myParent.processSet(myCmdSetID);
3785 }
3786 
3787 
3788 void
3789 TraCIAPI::TraCIScopeWrapper::subscribe(const std::string& objID, const std::vector<int>& vars, double beginTime, double endTime) const {
3790  myParent.send_commandSubscribeObjectVariable(mySubscribeID, objID, beginTime, endTime, vars);
3791  tcpip::Storage inMsg;
3792  myParent.check_resultState(inMsg, mySubscribeID);
3793  if (vars.size() > 0) {
3794  myParent.check_commandGetResult(inMsg, mySubscribeID);
3795  myParent.readVariableSubscription(mySubscribeID + 0x10, inMsg);
3796  }
3797 }
3798 
3799 
3800 void
3801 TraCIAPI::TraCIScopeWrapper::subscribeContext(const std::string& objID, int domain, double range, const std::vector<int>& vars, double beginTime, double endTime) const {
3802  myParent.send_commandSubscribeObjectContext(myContextSubscribeID, objID, beginTime, endTime, domain, range, vars);
3803  tcpip::Storage inMsg;
3804  myParent.check_resultState(inMsg, myContextSubscribeID);
3805  myParent.check_commandGetResult(inMsg, myContextSubscribeID);
3806  myParent.readContextSubscription(myContextSubscribeID + 0x60, inMsg);
3807 }
3808 
3809 
3812  return mySubscriptionResults;
3813 }
3814 
3815 
3818  if (mySubscriptionResults.find(objID) != mySubscriptionResults.end()) {
3819  return mySubscriptionResults.find(objID)->second;
3820  } else {
3821  return libsumo::TraCIResults();
3822  }
3823 }
3824 
3825 
3828  return myContextSubscriptionResults;
3829 }
3830 
3831 
3834  if (myContextSubscriptionResults.find(objID) != myContextSubscriptionResults.end()) {
3835  return myContextSubscriptionResults.find(objID)->second;
3836  } else {
3838  }
3839 }
3840 
3841 
3842 void
3844  mySubscriptionResults.clear();
3845  myContextSubscriptionResults.clear();
3846 }
3847 
3848 
3851  return mySubscriptionResults;
3852 }
3853 
3854 
3857  return myContextSubscriptionResults[objID];
3858 }
3859 
3860 
3861 /****************************************************************************/
double getElectricityConsumption(const std::string &edgeID) const
Definition: TraCIAPI.cpp:557
double getLastStepHaltingNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:587
double getHCEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:532
void adaptTraveltime(const std::string &edgeID, double time, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
Definition: TraCIAPI.cpp:610
double getLastStepOccupancy(const std::string &edgeID) const
Definition: TraCIAPI.cpp:567
double getLastStepLength(const std::string &edgeID) const
Definition: TraCIAPI.cpp:572
std::vector< std::string > getLastStepVehicleIDs(const std::string &edgeID) const
Definition: TraCIAPI.cpp:592
double getNOxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:542
void setMaxSpeed(const std::string &edgeID, double speed) const
Definition: TraCIAPI.cpp:649
double getCO2Emission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:521
double getCOEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:527
int getLaneNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:598
void setEffort(const std::string &edgeID, double effort, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
Definition: TraCIAPI.cpp:630
double getNoiseEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:552
double getFuelConsumption(const std::string &edgeID) const
Definition: TraCIAPI.cpp:547
double getTraveltime(const std::string &edgeID) const
Definition: TraCIAPI.cpp:577
int getLastStepVehicleNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:582
std::string getStreetName(const std::string &id) const
Definition: TraCIAPI.cpp:604
double getLastStepMeanSpeed(const std::string &edgeID) const
Definition: TraCIAPI.cpp:562
double getPMxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:537
double getAdaptedTraveltime(const std::string &edgeID, double time) const
Definition: TraCIAPI.cpp:505
double getEffort(const std::string &edgeID, double time) const
Definition: TraCIAPI.cpp:513
void setOffset(const std::string &viewID, double x, double y) const
Definition: TraCIAPI.cpp:684
libsumo::TraCIPositionVector getBoundary(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:673
std::string getSchema(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:668
void setBoundary(const std::string &viewID, double xmin, double ymin, double xmax, double ymax) const
Definition: TraCIAPI.cpp:699
void setZoom(const std::string &viewID, double zoom) const
Definition: TraCIAPI.cpp:679
void trackVehicle(const std::string &viewID, const std::string &vehID) const
Definition: TraCIAPI.cpp:727
void setSchema(const std::string &viewID, const std::string &schemeName) const
Definition: TraCIAPI.cpp:694
libsumo::TraCIPosition getOffset(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:663
double getZoom(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:658
void screenshot(const std::string &viewID, const std::string &filename, const int width=-1, const int height=-1) const
Definition: TraCIAPI.cpp:712
std::vector< libsumo::TraCIVehicleData > getVehicleData(const std::string &loopID) const
Definition: TraCIAPI.cpp:777
double getPosition(const std::string &loopID) const
Definition: TraCIAPI.cpp:736
double getLastStepMeanSpeed(const std::string &loopID) const
Definition: TraCIAPI.cpp:751
double getTimeSinceDetection(const std::string &loopID) const
Definition: TraCIAPI.cpp:771
double getLastStepMeanLength(const std::string &loopID) const
Definition: TraCIAPI.cpp:766
std::vector< std::string > getLastStepVehicleIDs(const std::string &loopID) const
Definition: TraCIAPI.cpp:756
double getLastStepOccupancy(const std::string &loopID) const
Definition: TraCIAPI.cpp:761
int getLastStepVehicleNumber(const std::string &loopID) const
Definition: TraCIAPI.cpp:746
std::string getLaneID(const std::string &loopID) const
Definition: TraCIAPI.cpp:741
libsumo::TraCIPosition getPosition(const std::string &junctionID) const
Definition: TraCIAPI.cpp:814
libsumo::TraCIPositionVector getShape(const std::string &junctionID) const
Definition: TraCIAPI.cpp:819
int getLastStepVehicleNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:978
double getPMxEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:933
int getLastStepHaltingNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:983
std::string getEdgeID(const std::string &laneID) const
Definition: TraCIAPI.cpp:913
void setDisallowed(const std::string &laneID, const std::vector< std::string > &disallowedClasses) const
Definition: TraCIAPI.cpp:1021
libsumo::TraCIPositionVector getShape(const std::string &laneID) const
Definition: TraCIAPI.cpp:908
double getLastStepLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:968
void setLength(const std::string &laneID, double length) const
Definition: TraCIAPI.cpp:1031
double getLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:828
int getLinkNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:853
double getTraveltime(const std::string &laneID) const
Definition: TraCIAPI.cpp:973
double getCOEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:923
void setMaxSpeed(const std::string &laneID, double speed) const
Definition: TraCIAPI.cpp:1026
std::vector< std::string > getInternalFoes(const std::string &laneID) const
Definition: TraCIAPI.cpp:1010
void setAllowed(const std::string &laneID, const std::vector< std::string > &allowedClasses) const
Definition: TraCIAPI.cpp:1016
std::vector< std::string > getDisallowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:848
double getNoiseEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:948
std::vector< std::string > getAllowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:843
double getFuelConsumption(const std::string &laneID) const
Definition: TraCIAPI.cpp:943
double getWidth(const std::string &laneID) const
Definition: TraCIAPI.cpp:838
double getCO2Emission(const std::string &laneID) const
Definition: TraCIAPI.cpp:918
double getHCEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:928
std::vector< libsumo::TraCIConnection > getLinks(const std::string &laneID) const
Definition: TraCIAPI.cpp:858
double getMaxSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:833
std::vector< std::string > getLastStepVehicleIDs(const std::string &laneID) const
Definition: TraCIAPI.cpp:988
double getElectricityConsumption(const std::string &laneID) const
Definition: TraCIAPI.cpp:953
std::vector< std::string > getFoes(const std::string &laneID, const std::string &toLaneID) const
Definition: TraCIAPI.cpp:994
double getLastStepMeanSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:958
double getNOxEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:938
double getLastStepOccupancy(const std::string &laneID) const
Definition: TraCIAPI.cpp:963
std::vector< std::string > getLastStepVehicleIDs(const std::string &detID) const
Definition: TraCIAPI.cpp:1055
int getLastStepVehicleNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:1045
double getLastStepMeanSpeed(const std::string &detID) const
Definition: TraCIAPI.cpp:1050
int getLastStepHaltingNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:1060
libsumo::TraCIColor getColor(const std::string &poiID) const
Definition: TraCIAPI.cpp:1080
void add(const std::string &poiID, double x, double y, const libsumo::TraCIColor &c, const std::string &type, int layer, const std::string &imgFile, double width, double height, double angle) const
Definition: TraCIAPI.cpp:1160
std::string getImageFile(const std::string &poiID) const
Definition: TraCIAPI.cpp:1100
void setWidth(const std::string &poiID, double width) const
Definition: TraCIAPI.cpp:1136
libsumo::TraCIPosition getPosition(const std::string &poiID) const
Definition: TraCIAPI.cpp:1075
void setImageFile(const std::string &poiID, const std::string &imageFile) const
Definition: TraCIAPI.cpp:1154
void setHeight(const std::string &poiID, double height) const
Definition: TraCIAPI.cpp:1142
void setAngle(const std::string &poiID, double angle) const
Definition: TraCIAPI.cpp:1148
double getHeight(const std::string &poiID) const
Definition: TraCIAPI.cpp:1090
double getAngle(const std::string &poiID) const
Definition: TraCIAPI.cpp:1095
void remove(const std::string &poiID, int layer=0) const
Definition: TraCIAPI.cpp:1189
void setColor(const std::string &poiID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:1123
void setPosition(const std::string &poiID, double x, double y) const
Definition: TraCIAPI.cpp:1112
double getWidth(const std::string &poiID) const
Definition: TraCIAPI.cpp:1085
void setType(const std::string &poiID, const std::string &setType) const
Definition: TraCIAPI.cpp:1106
std::string getType(const std::string &poiID) const
Definition: TraCIAPI.cpp:1070
std::string getNextEdge(const std::string &personID) const
Definition: TraCIAPI.cpp:3233
void setLength(const std::string &personID, double length) const
Definition: TraCIAPI.cpp:3462
libsumo::TraCIColor getColor(const std::string &personID) const
Definition: TraCIAPI.cpp:3198
double getSlope(const std::string &personID) const
Definition: TraCIAPI.cpp:3188
int getRemainingStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3244
double getWaitingTime(const std::string &personID) const
Definition: TraCIAPI.cpp:3228
void setSpeedFactor(const std::string &personID, double factor) const
Definition: TraCIAPI.cpp:3453
libsumo::TraCIStage getStage(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3249
void removeStage(const std::string &personID, int nextStageIndex) const
Definition: TraCIAPI.cpp:3393
void add(const std::string &personID, const std::string &edgeID, double pos, double depart=libsumo::DEPARTFLAG_NOW, const std::string typeID="DEFAULT_PEDTYPE")
Definition: TraCIAPI.cpp:3285
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:3355
void setSpeed(const std::string &personID, double speed) const
Definition: TraCIAPI.cpp:3434
double getLength(const std::string &personID) const
Definition: TraCIAPI.cpp:3203
void moveToXY(const std::string &personID, const std::string &edgeID, const double x, const double y, double angle, const int keepRoute) const
Definition: TraCIAPI.cpp:3415
void setHeight(const std::string &personID, double height) const
Definition: TraCIAPI.cpp:3481
void setType(const std::string &personID, const std::string &typeID) const
Definition: TraCIAPI.cpp:3444
void setMinGap(const std::string &personID, double minGap) const
Definition: TraCIAPI.cpp:3490
void moveTo(const std::string &personID, const std::string &edgeID, double position) const
Definition: TraCIAPI.cpp:3402
libsumo::TraCIPosition getPosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3173
double getSpeedFactor(const std::string &personID) const
Definition: TraCIAPI.cpp:3223
void removeStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3265
void setColor(const std::string &personID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:3500
std::string getRoadID(const std::string &personID) const
Definition: TraCIAPI.cpp:3208
double getSpeed(const std::string &personID) const
Definition: TraCIAPI.cpp:3168
std::string getVehicle(const std::string &personID) const
Definition: TraCIAPI.cpp:3239
void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
Definition: TraCIAPI.cpp:3376
std::string getTypeID(const std::string &personID) const
Definition: TraCIAPI.cpp:3218
void appendStage(const std::string &personID, const libsumo::TraCIStage &stage)
Definition: TraCIAPI.cpp:3302
double getAngle(const std::string &personID) const
Definition: TraCIAPI.cpp:3183
std::string getLaneID(const std::string &personID) const
Definition: TraCIAPI.cpp:3213
libsumo::TraCIPosition getPosition3D(const std::string &personID) const
Definition: TraCIAPI.cpp:3178
std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3257
void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: TraCIAPI.cpp:3338
double getLanePosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3193
void setWidth(const std::string &personID, double width) const
Definition: TraCIAPI.cpp:3472
void rerouteTraveltime(const std::string &personID) const
Definition: TraCIAPI.cpp:3275
libsumo::TraCIColor getColor(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1222
void setType(const std::string &polygonID, const std::string &setType) const
Definition: TraCIAPI.cpp:1236
bool getFilled(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1207
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:1277
libsumo::TraCIPositionVector getShape(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1217
std::string getType(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1212
void remove(const std::string &polygonID, int layer=0) const
Definition: TraCIAPI.cpp:1304
double getLineWidth(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1202
void setColor(const std::string &polygonID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:1265
void setLineWidth(const std::string &polygonID, const double lineWidth) const
Definition: TraCIAPI.cpp:1227
void setShape(const std::string &polygonID, const libsumo::TraCIPositionVector &shape) const
Definition: TraCIAPI.cpp:1246
std::vector< std::string > getEdges(const std::string &routeID) const
Definition: TraCIAPI.cpp:1317
void add(const std::string &routeID, const std::vector< std::string > &edges) const
Definition: TraCIAPI.cpp:1323
int getDepartedNumber() const
Definition: TraCIAPI.cpp:1356
double getDistance2D(double x1, double y1, double x2, double y2, bool isGeo=false, bool isDriving=false)
Definition: TraCIAPI.cpp:1532
libsumo::TraCIPosition convert2D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1443
std::vector< std::string > getStartingTeleportIDList() const
Definition: TraCIAPI.cpp:1381
int getStartingTeleportNumber() const
Definition: TraCIAPI.cpp:1376
double getTime() const
Definition: TraCIAPI.cpp:1341
int getEndingTeleportNumber() const
Definition: TraCIAPI.cpp:1386
int getBusStopWaiting(const std::string &stopID) const
Definition: TraCIAPI.cpp:1432
libsumo::TraCIStage findRoute(const std::string &fromEdge, const std::string &toEdge, const std::string &vType="", double pos=-1., int routingMode=0) const
Definition: TraCIAPI.cpp:1574
libsumo::TraCIRoadPosition convertRoad(double x, double y, bool isGeo=false, const std::string &vClass="ignoring") const
Definition: TraCIAPI.cpp:1488
void loadState(const std::string &path) const
Definition: TraCIAPI.cpp:1592
std::vector< std::string > getBusStopWaitingIDList(const std::string &stopID) const
Definition: TraCIAPI.cpp:1437
int getDepartedPersonNumber() const
Definition: TraCIAPI.cpp:1396
double getDistanceRoad(const std::string &edgeID1, double pos1, const std::string &edgeID2, double pos2, bool isDriving=false)
Definition: TraCIAPI.cpp:1552
std::vector< std::string > getArrivedPersonIDList() const
Definition: TraCIAPI.cpp:1411
void saveState(const std::string &destination) const
Definition: TraCIAPI.cpp:1601
std::vector< std::string > getEndingTeleportIDList() const
Definition: TraCIAPI.cpp:1391
double getDeltaT() const
Definition: TraCIAPI.cpp:1416
int getMinExpectedNumber() const
Definition: TraCIAPI.cpp:1427
std::vector< std::string > getDepartedPersonIDList() const
Definition: TraCIAPI.cpp:1401
std::vector< std::string > getDepartedIDList() const
Definition: TraCIAPI.cpp:1361
int getArrivedPersonNumber() const
Definition: TraCIAPI.cpp:1406
std::vector< std::string > getLoadedIDList() const
Definition: TraCIAPI.cpp:1351
std::vector< std::string > getArrivedIDList() const
Definition: TraCIAPI.cpp:1371
int getArrivedNumber() const
Definition: TraCIAPI.cpp:1366
libsumo::TraCIPositionVector getNetBoundary() const
Definition: TraCIAPI.cpp:1421
void writeMessage(const std::string msg)
Definition: TraCIAPI.cpp:1610
libsumo::TraCIPosition convertGeo(double x, double y, bool fromGeo=false) const
Definition: TraCIAPI.cpp:1511
libsumo::TraCIPosition convert3D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1465
int getUnsignedByte(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3517
const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3833
int getInt(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3538
std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3615
double getDouble(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3548
libsumo::TraCIPosition getPos3D(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3592
std::pair< std::string, std::string > getParameterWithKey(const std::string &objectID, const std::string &key) const
retrieve generic parameter and return (key, value) tuple
Definition: TraCIAPI.cpp:3713
libsumo::TraCIColor getCol(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3629
const libsumo::SubscriptionResults getAllSubscriptionResults() const
Definition: TraCIAPI.cpp:3811
void setStringVector(int var, const std::string &id, const std::vector< std::string > &value) const
Definition: TraCIAPI.cpp:3776
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:3692
libsumo::TraCIPositionVector getPolygon(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3558
libsumo::SubscriptionResults & getModifiableSubscriptionResults()
Definition: TraCIAPI.cpp:3850
const libsumo::TraCIResults getSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3817
void setString(int var, const std::string &id, const std::string &value) const
Definition: TraCIAPI.cpp:3766
void subscribeContext(const std::string &objID, int domain, double range, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3801
void setParameter(const std::string &objectID, const std::string &key, const std::string &value) const
set generic paramter
Definition: TraCIAPI.cpp:3732
std::string getParameter(const std::string &objectID, const std::string &key) const
retrieve generic parameter
Definition: TraCIAPI.cpp:3704
void setInt(int var, const std::string &id, int value) const
Definition: TraCIAPI.cpp:3746
int getByte(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3527
libsumo::TraCIStage getTraCIStage(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3643
void subscribe(const std::string &objID, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3789
std::string getString(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3605
libsumo::TraCIPosition getPos(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3579
const libsumo::ContextSubscriptionResults getAllContextSubscriptionResults() const
Definition: TraCIAPI.cpp:3827
libsumo::SubscriptionResults & getModifiableContextSubscriptionResults(const std::string &objID)
Definition: TraCIAPI.cpp:3856
void setDouble(int var, const std::string &id, double value) const
Definition: TraCIAPI.cpp:3756
int getServedPersonCount(const std::string &tlsID, int index) const
Definition: TraCIAPI.cpp:1740
std::string getRedYellowGreenState(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1623
int getPhase(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1719
std::string getPhaseName(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1724
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
Definition: TraCIAPI.cpp:1749
std::string getProgram(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1714
void setPhase(const std::string &tlsID, int index) const
Definition: TraCIAPI.cpp:1758
void setPhaseName(const std::string &tlsID, const std::string &name) const
Definition: TraCIAPI.cpp:1767
double getNextSwitch(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1734
std::vector< std::vector< libsumo::TraCILink > > getControlledLinks(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1686
double getPhaseDuration(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1729
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1681
std::vector< libsumo::TraCILogic > getAllProgramLogics(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1628
void setPhaseDuration(const std::string &tlsID, double phaseDuration) const
Definition: TraCIAPI.cpp:1785
void setProgramLogic(const std::string &tlsID, const libsumo::TraCILogic &logic) const
Definition: TraCIAPI.cpp:1794
void setProgram(const std::string &tlsID, const std::string &programID) const
Definition: TraCIAPI.cpp:1776
std::vector< libsumo::TraCINextTLSData > getNextTLS(const std::string &vehID) const
Definition: TraCIAPI.cpp:2375
void changeLane(const std::string &vehicleID, int laneIndex, double duration) const
Definition: TraCIAPI.cpp:2704
void setMinGap(const std::string &vehicleID, double minGap) const
Definition: TraCIAPI.cpp:2935
double getLateralSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2153
void setMaxSpeed(const std::string &vehicleID, double speed) const
Definition: TraCIAPI.cpp:2944
double getSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2148
int getStopState(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2497
double getWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2332
void addSubscriptionFilterCFManeuver(double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3055
double getCOEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2297
void addSubscriptionFilterStringList(int filterType, const std::vector< std::string > &vals) const
Definition: TraCIAPI.cpp:3143
void changeTarget(const std::string &vehicleID, const std::string &edgeID) const
Definition: TraCIAPI.cpp:2694
libsumo::TraCIPosition getPosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2216
bool isRouteValid(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2603
void addSubscriptionFilterByteList(int filterType, const std::vector< int > &vals) const
Definition: TraCIAPI.cpp:3153
double getSecureGap(const std::string &vehicleID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string &leaderID="") const
Definition: TraCIAPI.cpp:2182
void setSpeedFactor(const std::string &vehicleID, double factor) const
Definition: TraCIAPI.cpp:2926
void setShapeClass(const std::string &vehicleID, const std::string &clazz) const
Definition: TraCIAPI.cpp:3004
void addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist=-1, double foeDistToJunction=-1) const
Definition: TraCIAPI.cpp:3116
void setVia(const std::string &vehicleID, const std::vector< std::string > &via) const
Definition: TraCIAPI.cpp:2974
void setEmissionClass(const std::string &vehicleID, const std::string &clazz) const
Definition: TraCIAPI.cpp:3014
double getTau(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2528
double getDistance(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2277
void remove(const std::string &vehicleID, char reason=libsumo::REMOVE_VAPORIZED) const
Definition: TraCIAPI.cpp:2683
void openGap(const std::string &vehicleID, double newTau, double duration, double changeRate, double maxDecel) const
Definition: TraCIAPI.cpp:2834
void moveTo(const std::string &vehicleID, const std::string &laneID, double position, int reason=libsumo::MOVE_TELEPORT) const
Definition: TraCIAPI.cpp:2784
void setSpeed(const std::string &vehicleID, double speed) const
Definition: TraCIAPI.cpp:2857
std::string getEmissionClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2365
void setStop(const std::string vehicleID, const std::string edgeID, const double endPos=1., const int laneIndex=0, const double duration=std::numeric_limits< double >::max(), const int flags=0, const double startPos=std::numeric_limits< int >::min(), const double until=-1) const
Definition: TraCIAPI.cpp:2893
void setRouteID(const std::string &vehicleID, const std::string &routeID) const
Definition: TraCIAPI.cpp:2744
std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction) const
Definition: TraCIAPI.cpp:2479
double getNoiseEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2322
std::string getShapeClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2370
void addSubscriptionFilterLeadFollow(const std::vector< int > &lanes) const
Definition: TraCIAPI.cpp:3084
std::string getLine(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2355
double getElectricityConsumption(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2327
double getSpeedFactor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2538
double getNOxEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2312
void setRoute(const std::string &vehicleID, const std::vector< std::string > &edge) const
Definition: TraCIAPI.cpp:2754
int getSignals(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2282
libsumo::TraCIColor getColor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2267
int getPersonCapacity(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2588
void setSignals(const std::string &vehicleID, int signals) const
Definition: TraCIAPI.cpp:2986
std::string getRoadID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2231
void addSubscriptionFilterVType(const std::vector< std::string > &vTypes) const
Definition: TraCIAPI.cpp:3105
void addSubscriptionFilterUpstreamDistance(double dist) const
Definition: TraCIAPI.cpp:3049
void addSubscriptionFilterFloat(int filterType, double val) const
Definition: TraCIAPI.cpp:3133
double getAllowedSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2578
void addSubscriptionFilterLanes(const std::vector< int > &lanes, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3023
double getCO2Emission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2292
double getFuelConsumption(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2317
double getHCEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2302
void addSubscriptionFilterNoOpposite() const
Definition: TraCIAPI.cpp:3039
void addSubscriptionFilterLCManeuver(int direction, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3066
std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2443
double getAcceleration(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2158
std::vector< std::string > getVia(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2360
void addSubscriptionFilterVClass(const std::vector< std::string > &vClasses) const
Definition: TraCIAPI.cpp:3099
double getImperfection(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2533
std::string getLaneID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2236
double getAngle(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2226
void addSubscriptionFilterDownstreamDistance(double dist) const
Definition: TraCIAPI.cpp:3044
double getMinGap(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2553
void addSubscriptionFilterEmpty(int filterType) const
Definition: TraCIAPI.cpp:3127
double getStopArrivalDelay(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2512
std::vector< std::string > getPersonIDList(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2593
double getStopDelay(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2507
double getMinGapLat(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2613
void setLine(const std::string &vehicleID, const std::string &line) const
Definition: TraCIAPI.cpp:2965
double getSlope(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2349
void setColor(const std::string &vehicleID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:2953
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:2623
libsumo::TraCIPosition getPosition3D(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2221
void setLaneChangeMode(const std::string &vehicleID, int mode) const
Definition: TraCIAPI.cpp:2875
void setRoutingMode(const std::string &vehicleID, int routingMode) const
Definition: TraCIAPI.cpp:2995
void addSubscriptionFilterTurn(double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3090
double getDecel(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2523
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:2799
double getHeight(const std::string &veihcleID) const
Definition: TraCIAPI.cpp:2568
int getRouteIndex(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2256
double getMaxSpeedLat(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2608
void changeSublane(const std::string &vehicleID, double latDist) const
Definition: TraCIAPI.cpp:2734
std::string getLateralAlignment(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2618
std::string getRouteID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2251
double getLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2272
int getLaneChangeMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2337
int getSpeedMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2343
std::vector< std::string > getRoute(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2262
double getLateralLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2287
std::pair< std::string, double > getFollower(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2461
double getPMxEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2307
double getLength(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2563
double getMaxSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2211
std::string getVehicleClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2548
double getSpeedWithoutTraCI(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2598
int getRoutingMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2502
double getWidth(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2558
double getSpeedDeviation(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2543
int getPersonNumber(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2583
double getFollowSpeed(const std::string &vehicleID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string &leaderID="") const
Definition: TraCIAPI.cpp:2163
void setType(const std::string &vehicleID, const std::string &typeID) const
Definition: TraCIAPI.cpp:2917
void addSubscriptionFilterFieldOfVision(double angle) const
Definition: TraCIAPI.cpp:3111
std::vector< libsumo::TraCIBestLanesData > getBestLanes(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2404
double getAccel(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2518
void setSpeedMode(const std::string &vehicleID, int mode) const
Definition: TraCIAPI.cpp:2884
void slowDown(const std::string &vehicleID, double speed, double duration) const
Definition: TraCIAPI.cpp:2821
std::string getTypeID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2246
void setPreviousSpeed(const std::string &vehicleID, double prevspeed) const
Definition: TraCIAPI.cpp:2866
double getAccumulatedWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2573
void changeLaneRelative(const std::string &vehicleID, int laneChange, double duration) const
Definition: TraCIAPI.cpp:2718
void rerouteTraveltime(const std::string &vehicleID, bool currentTravelTimes=true) const
Definition: TraCIAPI.cpp:2767
double getStopSpeed(const std::string &vehicleID, double speed, double gap) const
Definition: TraCIAPI.cpp:2198
int getLaneIndex(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2241
double getSpeedDeviation(const std::string &typeID) const
Definition: TraCIAPI.cpp:1858
double getSpeedFactor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1853
void setImperfection(const std::string &typeID, double imperfection) const
Definition: TraCIAPI.cpp:2114
void setApparentDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2105
void setHeight(const std::string &typeID, double height) const
Definition: TraCIAPI.cpp:2014
std::string getShapeClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1903
double getMinGapLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1913
void copy(const std::string &origTypeID, const std::string &newTypeID) const
Definition: TraCIAPI.cpp:2060
int getPersonCapacity(const std::string &typeID) const
Definition: TraCIAPI.cpp:1928
void setVehicleClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1968
void setColor(const std::string &typeID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:2132
void setDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2087
void setWidth(const std::string &typeID, double width) const
Definition: TraCIAPI.cpp:2005
double getApparentDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1878
double getDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1868
void setLateralAlignment(const std::string &typeID, const std::string &latAlignment) const
Definition: TraCIAPI.cpp:2051
void setMaxSpeed(const std::string &typeID, double speed) const
Definition: TraCIAPI.cpp:1959
double getMinGap(const std::string &typeID) const
Definition: TraCIAPI.cpp:1908
std::string getVehicleClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1893
void setShapeClass(const std::string &typeID, const std::string &shapeClass) const
Definition: TraCIAPI.cpp:2069
double getMaxSpeedLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1918
double getEmergencyDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1873
double getWidth(const std::string &typeID) const
Definition: TraCIAPI.cpp:1933
libsumo::TraCIColor getColor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1943
double getTau(const std::string &typeID) const
Definition: TraCIAPI.cpp:1888
double getMaxSpeed(const std::string &typeID) const
Definition: TraCIAPI.cpp:1848
double getLength(const std::string &typeID) const
Definition: TraCIAPI.cpp:1843
std::string getEmissionClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1898
double getImperfection(const std::string &typeID) const
Definition: TraCIAPI.cpp:1883
void setEmissionClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1996
void setAccel(const std::string &typeID, double accel) const
Definition: TraCIAPI.cpp:2078
void setMinGap(const std::string &typeID, double minGap) const
Definition: TraCIAPI.cpp:2023
double getAccel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1863
void setSpeedFactor(const std::string &typeID, double factor) const
Definition: TraCIAPI.cpp:1977
double getHeight(const std::string &typeID) const
Definition: TraCIAPI.cpp:1938
void setEmergencyDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2096
void setSpeedDeviation(const std::string &typeID, double deviation) const
Definition: TraCIAPI.cpp:1986
void setMaxSpeedLat(const std::string &typeID, double speed) const
Definition: TraCIAPI.cpp:2042
std::string getLateralAlignment(const std::string &typeID) const
Definition: TraCIAPI.cpp:1923
void setMinGapLat(const std::string &typeID, double minGapLat) const
Definition: TraCIAPI.cpp:2033
void setLength(const std::string &typeID, double length) const
Definition: TraCIAPI.cpp:1950
void setTau(const std::string &typeID, double tau) const
Definition: TraCIAPI.cpp:2123
RouteScope route
Scope for interaction with routes.
Definition: TraCIAPI.h:839
std::pair< int, std::string > getVersion()
return TraCI API and SUMO version
Definition: TraCIAPI.cpp:487
void setOrder(int order)
set priority (execution order) for the client
Definition: TraCIAPI.cpp:89
void readVariableSubscription(int cmdId, tcpip::Storage &inMsg)
Definition: TraCIAPI.cpp:424
tcpip::Storage myInput
The reusable input storage.
Definition: TraCIAPI.h:948
MeMeScope multientryexit
Scope for interaction with multi-entry/-exit detectors.
Definition: TraCIAPI.h:829
VehicleTypeScope vehicletype
Scope for interaction with vehicle types.
Definition: TraCIAPI.h:849
void send_commandSubscribeObjectVariable(int domID, const std::string &objID, double beginTime, double endTime, const std::vector< int > &vars) const
Sends a SubscribeVariable request.
Definition: TraCIAPI.cpp:209
void send_commandSimulationStep(double time) const
Sends a SimulationStep command.
Definition: TraCIAPI.cpp:125
GUIScope gui
Scope for interaction with the gui.
Definition: TraCIAPI.h:819
void check_resultState(tcpip::Storage &inMsg, int command, bool ignoreCommandId=false, std::string *acknowledgement=0) const
Validates the result state of a command.
Definition: TraCIAPI.cpp:268
PolygonScope polygon
Scope for interaction with polygons.
Definition: TraCIAPI.h:835
static std::string toString(const T &t, std::streamsize accuracy=PRECISION)
Definition: TraCIAPI.h:930
TraCIAPI()
Constructor.
Definition: TraCIAPI.cpp:40
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
Definition: TraCIAPI.cpp:76
tcpip::Socket * mySocket
The socket.
Definition: TraCIAPI.h:944
void load(const std::vector< std::string > &args)
Let sumo load a simulation using the given command line like options.
Definition: TraCIAPI.cpp:469
LaneAreaScope lanearea
Scope for interaction with lanes.
Definition: TraCIAPI.h:827
void simulationStep(double time=0)
Advances by one step (or up to the given time)
Definition: TraCIAPI.cpp:447
void createFilterCommand(int cmdID, int varID, tcpip::Storage *add=nullptr) const
Definition: TraCIAPI.cpp:186
void createCommand(int cmdID, int varID, const std::string &objID, tcpip::Storage *add=nullptr) const
Sends a GetVariable / SetVariable request if mySocket is connected. Otherwise writes to myOutput only...
Definition: TraCIAPI.cpp:162
void close()
ends the simulation and closes the connection
Definition: TraCIAPI.cpp:104
LaneScope lane
Scope for interaction with lanes.
Definition: TraCIAPI.h:825
std::map< int, TraCIScopeWrapper * > myDomains
Definition: TraCIAPI.h:942
void send_commandSubscribeObjectContext(int domID, const std::string &objID, double beginTime, double endTime, int domain, double range, const std::vector< int > &vars) const
Sends a SubscribeContext request.
Definition: TraCIAPI.cpp:237
bool processSet(int command)
Definition: TraCIAPI.cpp:344
TrafficLightScope trafficlights
Scope for interaction with traffic lights.
Definition: TraCIAPI.h:845
tcpip::Storage myOutput
The reusable output storage.
Definition: TraCIAPI.h:946
POIScope poi
Scope for interaction with POIs.
Definition: TraCIAPI.h:833
void closeSocket()
Closes the connection.
Definition: TraCIAPI.cpp:114
int check_commandGetResult(tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const
Validates the result state of a command.
Definition: TraCIAPI.cpp:307
VehicleScope vehicle
Scope for interaction with vehicles.
Definition: TraCIAPI.h:847
JunctionScope junction
Scope for interaction with junctions.
Definition: TraCIAPI.h:823
void send_commandClose() const
Sends a Close command.
Definition: TraCIAPI.cpp:138
void send_commandSetOrder(int order) const
Sends a SetOrder command.
Definition: TraCIAPI.cpp:149
~TraCIAPI()
Destructor.
Definition: TraCIAPI.cpp:70
RouteProbeScope routeprobe
Scope for interaction with route probes.
Definition: TraCIAPI.h:841
EdgeScope edge
Scope for interaction with edges.
Definition: TraCIAPI.h:817
bool processGet(int command, int expectedType, bool ignoreCommandId=false)
Definition: TraCIAPI.cpp:331
SimulationScope simulation
Scope for interaction with the simulation.
Definition: TraCIAPI.h:843
void readContextSubscription(int cmdId, tcpip::Storage &inMsg)
Definition: TraCIAPI.cpp:432
void readVariables(tcpip::Storage &inMsg, const std::string &objectID, int variableCount, libsumo::SubscriptionResults &into)
Definition: TraCIAPI.cpp:356
PersonScope person
Scope for interaction with persons.
Definition: TraCIAPI.h:831
RerouterScope rerouter
Scope for interaction with rerouters.
Definition: TraCIAPI.h:837
An error which allows to continue.
Definition: TraCIDefs.h:130
std::map< std::string, std::string > subParameter
Definition: TraCIDefs.h:319
std::string programID
Definition: TraCIDefs.h:315
std::vector< std::shared_ptr< libsumo::TraCIPhase > > phases
Definition: TraCIDefs.h:318
std::string intended
id of the intended vehicle for public transport ride
Definition: TraCIDefs.h:523
int type
The type of stage (walking, driving, ...)
Definition: TraCIDefs.h:507
std::string destStop
The id of the destination stop.
Definition: TraCIDefs.h:513
double length
length in m
Definition: TraCIDefs.h:521
double travelTime
duration of the stage in seconds
Definition: TraCIDefs.h:517
double departPos
position on the lane when starting the stage
Definition: TraCIDefs.h:527
std::string description
arbitrary description string
Definition: TraCIDefs.h:531
std::string line
The line or the id of the vehicle type.
Definition: TraCIDefs.h:511
double cost
effort needed
Definition: TraCIDefs.h:519
double depart
intended depart time for public transport ride or INVALID_DOUBLE_VALUE
Definition: TraCIDefs.h:525
std::vector< std::string > edges
The sequence of edges to travel.
Definition: TraCIDefs.h:515
double arrivalPos
position on the lane when ending the stage
Definition: TraCIDefs.h:529
std::string vType
The vehicle type when using a private car or bike.
Definition: TraCIDefs.h:509
bool receiveExact(Storage &)
Receive a complete TraCI message from Socket::socket_.
Definition: socket.cpp:528
void sendExact(const Storage &)
Definition: socket.cpp:431
void connect()
Connects to host_:port_.
Definition: socket.cpp:359
void close()
Definition: socket.cpp:383
virtual std::string readString()
Definition: storage.cpp:180
virtual void writeString(const std::string &s)
Definition: storage.cpp:197
virtual unsigned int position() const
Definition: storage.cpp:76
virtual void writeInt(int)
Definition: storage.cpp:321
virtual void writeDouble(double)
Definition: storage.cpp:354
virtual int readUnsignedByte()
Definition: storage.cpp:155
virtual void writeStringList(const std::vector< std::string > &s)
Definition: storage.cpp:247
void reset()
Definition: storage.cpp:85
virtual void writeUnsignedByte(int)
Definition: storage.cpp:165
StorageType::size_type size() const
Definition: storage.h:119
virtual void writeByte(int)
Definition: storage.cpp:140
virtual void writeStorage(tcpip::Storage &store)
Definition: storage.cpp:388
virtual double readDouble()
Definition: storage.cpp:362
virtual int readInt()
Definition: storage.cpp:311
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int RESPONSE_SUBSCRIBE_GUI_VARIABLE
TRACI_CONST int LAST_STEP_VEHICLE_ID_LIST
TRACI_CONST int TYPE_COLOR
TRACI_CONST int VAR_MIN_EXPECTED_VEHICLES
TRACI_CONST int CMD_SAVE_SIMSTATE
TRACI_CONST int FILTER_TYPE_DOWNSTREAM_DIST
TRACI_CONST int VAR_IMAGEFILE
TRACI_CONST int VAR_EDGES
TRACI_CONST int CMD_LOAD
TRACI_CONST int LAST_STEP_VEHICLE_NUMBER
TRACI_CONST int POSITION_3D
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int VAR_NOXEMISSION
TRACI_CONST int VAR_LANECHANGE_MODE
TRACI_CONST int VAR_ARRIVED_VEHICLES_NUMBER
TRACI_CONST int VAR_NAME
TRACI_CONST int LAST_STEP_PERSON_ID_LIST
TRACI_CONST int RTYPE_NOTIMPLEMENTED
TRACI_CONST int RESPONSE_SUBSCRIBE_ROUTE_VARIABLE
TRACI_CONST int FILTER_TYPE_NOOPPOSITE
TRACI_CONST int VAR_VEHICLECLASS
TRACI_CONST int LANE_LINKS
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_LATALIGNMENT
TRACI_CONST int VAR_DEPARTED_VEHICLES_NUMBER
TRACI_CONST int CMD_GET_TL_VARIABLE
TRACI_CONST int VAR_VIEW_BOUNDARY
TRACI_CONST int LAST_STEP_VEHICLE_DATA
TRACI_CONST int VAR_TYPE
TRACI_CONST int CMD_CHANGESUBLANE
TRACI_CONST int CMD_LOAD_SIMSTATE
TRACI_CONST int CMD_SET_EDGE_VARIABLE
TRACI_CONST int RESPONSE_SUBSCRIBE_LANE_VARIABLE
TRACI_CONST int VAR_ROUTING_MODE
TRACI_CONST int VAR_MINGAP
TRACI_CONST int VAR_VEHICLE
TRACI_CONST int VAR_SECURE_GAP
TRACI_CONST int VAR_SHAPECLASS
TRACI_CONST int VAR_WAITING_TIME
TRACI_CONST int CMD_STOP
TRACI_CONST int VAR_LINE
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:279
TRACI_CONST int LANE_LINK_NUMBER
TRACI_CONST int VAR_EDGE_TRAVELTIME
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
TRACI_CONST int VAR_SCREENSHOT
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int MOVE_TO_XY
TRACI_CONST int VAR_FOLLOW_SPEED
TRACI_CONST int VAR_STOP_ARRIVALDELAY
TRACI_CONST int VAR_SPEED_LAT
TRACI_CONST int LAST_STEP_LENGTH
TRACI_CONST int FILTER_TYPE_FIELD_OF_VISION
TRACI_CONST int TL_CONTROLLED_LANES
TRACI_CONST int VAR_ANGLE
TRACI_CONST int VAR_TAU
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int LANE_EDGE_ID
TRACI_CONST int VAR_NEXT_TLS
TRACI_CONST int RESPONSE_SUBSCRIBE_PERSON_VARIABLE
TRACI_CONST int VAR_EDGE_EFFORT
TRACI_CONST int RESPONSE_SUBSCRIBE_TL_VARIABLE
TRACI_CONST int VAR_VIEW_OFFSET
TRACI_CONST int RESPONSE_SUBSCRIBE_MULTIENTRYEXIT_VARIABLE
TRACI_CONST int VAR_ROUTE
TRACI_CONST int VAR_BEST_LANES
TRACI_CONST int VAR_ALLOWED_SPEED
TRACI_CONST int VAR_LANE_INDEX
TRACI_CONST int VAR_PMXEMISSION
TRACI_CONST int VAR_SPEED_WITHOUT_TRACI
TRACI_CONST int VAR_DEPARTED_PERSONS_NUMBER
TRACI_CONST int TL_COMPLETE_DEFINITION_RYG
TRACI_CONST int TYPE_UBYTE
TRACI_CONST int VAR_STAGE
TRACI_CONST int CMD_SET_POI_VARIABLE
TRACI_CONST int VAR_MOVE_TO
TRACI_CONST int RESPONSE_SUBSCRIBE_VEHICLE_VARIABLE
TRACI_CONST int VAR_PERSON_NUMBER
TRACI_CONST int RESPONSE_SUBSCRIBE_REROUTER_VARIABLE
TRACI_CONST int CMD_SET_POLYGON_VARIABLE
TRACI_CONST int VAR_COEMISSION
TRACI_CONST int RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_POSITION
TRACI_CONST int VAR_WIDTH
TRACI_CONST int VAR_PERSON_CAPACITY
TRACI_CONST int VAR_VIEW_SCHEMA
TRACI_CONST int POSITION_2D
TRACI_CONST int VAR_MAXSPEED
TRACI_CONST int COPY
TRACI_CONST int VAR_ARRIVED_PERSONS_IDS
TRACI_CONST int VAR_LEADER
TRACI_CONST int CMD_CHANGETARGET
TRACI_CONST int CMD_CLOSE
TRACI_CONST int VAR_TIME
TRACI_CONST int TYPE_POLYGON
TRACI_CONST int LAST_STEP_MEAN_SPEED
TRACI_CONST int ADD_FULL
TRACI_CONST int STAGE_WAITING
TRACI_CONST int CMD_SET_ROUTE_VARIABLE
TRACI_CONST int CMD_SETORDER
TRACI_CONST int VAR_CO2EMISSION
TRACI_CONST int RESPONSE_SUBSCRIBE_JUNCTION_VARIABLE
TRACI_CONST int FILTER_TYPE_VTYPE
TRACI_CONST int CMD_REROUTE_TRAVELTIME
TRACI_CONST int VAR_NET_BOUNDING_BOX
TRACI_CONST int TYPE_STRINGLIST
TRACI_CONST int APPEND_STAGE
TRACI_CONST int VAR_VIEW_ZOOM
TRACI_CONST int CMD_SET_SIM_VARIABLE
TRACI_CONST int TL_CONTROLLED_LINKS
TRACI_CONST int TYPE_INTEGER
TRACI_CONST int VAR_PREV_SPEED
TRACI_CONST int VAR_ROUTE_VALID
TRACI_CONST int VAR_SPEEDSETMODE
TRACI_CONST int POSITION_LON_LAT
TRACI_CONST int CMD_ADD_SUBSCRIPTION_FILTER
TRACI_CONST int CMD_SET_VEHICLE_VARIABLE
TRACI_CONST int VAR_FUELCONSUMPTION
TRACI_CONST int CMD_SET_GUI_VARIABLE
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:278
TRACI_CONST int VAR_SLOPE
TRACI_CONST int VAR_SHAPE
TRACI_CONST int LAST_STEP_VEHICLE_HALTING_NUMBER
TRACI_CONST int VAR_LENGTH
TRACI_CONST int VAR_MAXSPEED_LAT
TRACI_CONST int VAR_HCEMISSION
TRACI_CONST int VAR_BUS_STOP_WAITING_IDS
TRACI_CONST int ID_COUNT
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_LANEPOSITION
TRACI_CONST int CMD_SET_VEHICLETYPE_VARIABLE
TRACI_CONST int REMOVE
TRACI_CONST int CMD_SET_PERSON_VARIABLE
TRACI_CONST int VAR_DEPARTED_VEHICLES_IDS
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_NUMBER
TRACI_CONST int CMD_GET_SIM_VARIABLE
TRACI_CONST int CMD_MESSAGE
TRACI_CONST int VAR_LANE_ID
TRACI_CONST int VAR_STOP_SPEED
TRACI_CONST int VAR_IMPERFECTION
TRACI_CONST int RESPONSE_SUBSCRIBE_ROUTEPROBE_VARIABLE
TRACI_CONST int LAST_STEP_OCCUPANCY
TRACI_CONST int VAR_HEIGHT
TRACI_CONST int RESPONSE_SUBSCRIBE_LANEAREA_VARIABLE
TRACI_CONST int VAR_APPARENT_DECEL
TRACI_CONST int TL_NEXT_SWITCH
TRACI_CONST int VAR_NOISEEMISSION
TRACI_CONST int VAR_LOADED_VEHICLES_IDS
TRACI_CONST int FILTER_TYPE_LEAD_FOLLOW
TRACI_CONST int RESPONSE_SUBSCRIBE_VEHICLETYPE_VARIABLE
TRACI_CONST int VAR_DELTA_T
TRACI_CONST int REQUEST_DRIVINGDIST
TRACI_CONST int CMD_GET_LANE_VARIABLE
TRACI_CONST int STAGE_WALKING
TRACI_CONST int VAR_POSITION3D
TRACI_CONST int LANE_DISALLOWED
TRACI_CONST int REMOVE_STAGE
TRACI_CONST int VAR_SPEED
TRACI_CONST int VAR_DECEL
TRACI_CONST int VAR_SIGNALS
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int FILTER_TYPE_UPSTREAM_DIST
TRACI_CONST int VAR_ACCUMULATED_WAITING_TIME
TRACI_CONST int VAR_MINGAP_LAT
TRACI_CONST int VAR_DEPARTED_PERSONS_IDS
TRACI_CONST int INVALID_INT_VALUE
TRACI_CONST int VAR_ARRIVED_PERSONS_NUMBER
TRACI_CONST int TL_PROGRAM
TRACI_CONST int VAR_ROUTE_INDEX
TRACI_CONST int TL_PHASE_DURATION
TRACI_CONST int CMD_SLOWDOWN
TRACI_CONST int VAR_NEXT_EDGE
TRACI_CONST int FILTER_TYPE_TURN
TRACI_CONST int VAR_ACCELERATION
TRACI_CONST int VAR_FILL
TRACI_CONST int FIND_ROUTE
TRACI_CONST int VAR_ROUTE_ID
TRACI_CONST int TL_PHASE_INDEX
TRACI_CONST int POSITION_CONVERSION
TRACI_CONST int TYPE_DOUBLE
TRACI_CONST int DISTANCE_REQUEST
TRACI_CONST int TYPE_BYTE
TRACI_CONST int TL_CURRENT_PHASE
TRACI_CONST int CMD_OPENGAP
TRACI_CONST int TL_COMPLETE_PROGRAM_RYG
TRACI_CONST int VAR_LOADED_VEHICLES_NUMBER
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_IDS
TRACI_CONST int CMD_SET_TL_VARIABLE
TRACI_CONST int VAR_LANEPOSITION_LAT
TRACI_CONST int FILTER_TYPE_VCLASS
TRACI_CONST int CMD_CHANGELANE
TRACI_CONST int VAR_CURRENT_TRAVELTIME
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_NUMBER
TRACI_CONST int TL_RED_YELLOW_GREEN_STATE
TRACI_CONST int RESPONSE_SUBSCRIBE_POI_VARIABLE
TRACI_CONST int VAR_STOP_DELAY
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_IDS
TRACI_CONST int CMD_GETVERSION
TRACI_CONST int REQUEST_AIRDIST
TRACI_CONST int VAR_BUS_STOP_WAITING
TRACI_CONST int RTYPE_ERR
TRACI_CONST int CMD_SIMSTEP
TRACI_CONST int VAR_TIME_STEP
TRACI_CONST int VAR_EMERGENCY_DECEL
TRACI_CONST int VAR_ARRIVED_VEHICLES_IDS
TRACI_CONST int RESPONSE_SUBSCRIBE_SIM_VARIABLE
TRACI_CONST int STAGE_DRIVING
TRACI_CONST int RTYPE_OK
TRACI_CONST int CMD_GET_INDUCTIONLOOP_VARIABLE
TRACI_CONST int LAST_STEP_TIME_SINCE_DETECTION
TRACI_CONST int VAR_STOPSTATE
TRACI_CONST int VAR_FOLLOWER
TRACI_CONST int POSITION_LON_LAT_ALT
TRACI_CONST int VAR_EMISSIONCLASS
TRACI_CONST int FILTER_TYPE_LANES
TRACI_CONST int VAR_ACCEL
TRACI_CONST int RESPONSE_SUBSCRIBE_POLYGON_VARIABLE
TRACI_CONST int ADD
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
Definition: TraCIDefs.h:276
TRACI_CONST int VAR_FOES
TRACI_CONST int VAR_STAGES_REMAINING
TRACI_CONST int VAR_DISTANCE
TRACI_CONST int LANE_ALLOWED
TRACI_CONST int RESPONSE_SUBSCRIBE_EDGE_VARIABLE
TRACI_CONST int TL_CURRENT_PROGRAM
TRACI_CONST int FILTER_TYPE_LATERAL_DIST
TRACI_CONST int VAR_ELECTRICITYCONSUMPTION
TRACI_CONST int VAR_SPEED_DEVIATION
TRACI_CONST int VAR_VIA
TRACI_CONST int TYPE_STRING
double length
The length than can be driven from that lane without lane change.
Definition: TraCIDefs.h:485
double occupation
The traffic density along length.
Definition: TraCIDefs.h:487
bool allowsContinuation
Whether this lane allows continuing the route.
Definition: TraCIDefs.h:491
int bestLaneOffset
The offset of this lane from the best lane.
Definition: TraCIDefs.h:489
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
Definition: TraCIDefs.h:493
std::string laneID
The id of the lane.
Definition: TraCIDefs.h:483
double dist
The distance to the tls.
Definition: TraCIDefs.h:377
int tlIndex
The tls index of the controlled link.
Definition: TraCIDefs.h:375
std::string id
The id of the next tls.
Definition: TraCIDefs.h:373
char state
The current state of the tls.
Definition: TraCIDefs.h:379
A 3D-position.
Definition: TraCIDefs.h:164
A list of positions.
Definition: TraCIDefs.h:207
std::vector< TraCIPosition > value
Definition: TraCIDefs.h:217
An edgeId, position and laneIndex.
Definition: TraCIDefs.h:176
mirrors MSInductLoop::VehicleData
Definition: TraCIDefs.h:357
std::string id
The id of the vehicle.
Definition: TraCIDefs.h:359
double entryTime
Entry-time of the vehicle in [s].
Definition: TraCIDefs.h:363
std::string typeID
Type of the vehicle in.
Definition: TraCIDefs.h:367
double length
Length of the vehicle.
Definition: TraCIDefs.h:361
double leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIDefs.h:365