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-2020 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 getInt(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 std::string
1207 TraCIAPI::PolygonScope::getType(const std::string& polygonID) const {
1208  return getString(libsumo::VAR_TYPE, polygonID);
1209 }
1210 
1212 TraCIAPI::PolygonScope::getShape(const std::string& polygonID) const {
1213  return getPolygon(libsumo::VAR_SHAPE, polygonID);
1214 }
1215 
1217 TraCIAPI::PolygonScope::getColor(const std::string& polygonID) const {
1218  return getCol(libsumo::VAR_COLOR, polygonID);
1219 }
1220 
1221 void
1222 TraCIAPI::PolygonScope::setLineWidth(const std::string& polygonID, const double lineWidth) const {
1223  tcpip::Storage content;
1225  content.writeDouble(lineWidth);
1226  myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_WIDTH, polygonID, &content);
1227  myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1228 }
1229 
1230 void
1231 TraCIAPI::PolygonScope::setType(const std::string& polygonID, const std::string& setType) const {
1232  tcpip::Storage content;
1234  content.writeString(setType);
1235  myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_TYPE, polygonID, &content);
1236  myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1237 }
1238 
1239 
1240 void
1241 TraCIAPI::PolygonScope::setShape(const std::string& polygonID, const libsumo::TraCIPositionVector& shape) const {
1242  tcpip::Storage content;
1244  if (shape.size() < 256) {
1245  content.writeUnsignedByte((int)shape.size());
1246  } else {
1247  content.writeUnsignedByte(0);
1248  content.writeInt((int)shape.size());
1249  }
1250  for (const libsumo::TraCIPosition& pos : shape) {
1251  content.writeDouble(pos.x);
1252  content.writeDouble(pos.y);
1253  }
1254  myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_SHAPE, polygonID, &content);
1255  myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1256 }
1257 
1258 
1259 void
1260 TraCIAPI::PolygonScope::setColor(const std::string& polygonID, const libsumo::TraCIColor& c) const {
1261  tcpip::Storage content;
1263  content.writeUnsignedByte(c.r);
1264  content.writeUnsignedByte(c.g);
1265  content.writeUnsignedByte(c.b);
1266  content.writeUnsignedByte(c.a);
1267  myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_COLOR, polygonID, &content);
1268  myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1269 }
1270 
1271 void
1272 TraCIAPI::PolygonScope::add(const std::string& polygonID, const libsumo::TraCIPositionVector& shape, const libsumo::TraCIColor& c, bool fill, const std::string& type, int layer) const {
1273  tcpip::Storage content;
1275  content.writeInt(5);
1277  content.writeString(type);
1279  content.writeUnsignedByte(c.r);
1280  content.writeUnsignedByte(c.g);
1281  content.writeUnsignedByte(c.b);
1282  content.writeUnsignedByte(c.a);
1284  int f = fill ? 1 : 0;
1285  content.writeUnsignedByte(f);
1287  content.writeInt(layer);
1289  content.writeUnsignedByte((int)shape.size());
1290  for (int i = 0; i < (int)shape.size(); ++i) {
1291  content.writeDouble(shape[i].x);
1292  content.writeDouble(shape[i].y);
1293  }
1294  myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::ADD, polygonID, &content);
1295  myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1296 }
1297 
1298 void
1299 TraCIAPI::PolygonScope::remove(const std::string& polygonID, int layer) const {
1300  tcpip::Storage content;
1302  content.writeInt(layer);
1303  myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::REMOVE, polygonID, &content);
1304  myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1305 }
1306 
1307 
1308 // ---------------------------------------------------------------------------
1309 // TraCIAPI::RouteScope-methods
1310 // ---------------------------------------------------------------------------
1311 std::vector<std::string>
1312 TraCIAPI::RouteScope::getEdges(const std::string& routeID) const {
1313  return getStringVector(libsumo::VAR_EDGES, routeID);
1314 }
1315 
1316 
1317 void
1318 TraCIAPI::RouteScope::add(const std::string& routeID, const std::vector<std::string>& edges) const {
1319  tcpip::Storage content;
1321  content.writeStringList(edges);
1322  myParent.createCommand(libsumo::CMD_SET_ROUTE_VARIABLE, libsumo::ADD, routeID, &content);
1323  myParent.processSet(libsumo::CMD_SET_ROUTE_VARIABLE);
1324 }
1325 
1326 
1327 // ---------------------------------------------------------------------------
1328 // TraCIAPI::SimulationScope-methods
1329 // ---------------------------------------------------------------------------
1330 int
1332  return getInt(libsumo::VAR_TIME_STEP, "");
1333 }
1334 
1335 double
1337  return getDouble(libsumo::VAR_TIME, "");
1338 }
1339 
1340 int
1342  return (int) getInt(libsumo::VAR_LOADED_VEHICLES_NUMBER, "");
1343 }
1344 
1345 std::vector<std::string>
1347  return getStringVector(libsumo::VAR_LOADED_VEHICLES_IDS, "");
1348 }
1349 
1350 int
1352  return (int) getInt(libsumo::VAR_DEPARTED_VEHICLES_NUMBER, "");
1353 }
1354 
1355 std::vector<std::string>
1357  return getStringVector(libsumo::VAR_DEPARTED_VEHICLES_IDS, "");
1358 }
1359 
1360 int
1362  return (int) getInt(libsumo::VAR_ARRIVED_VEHICLES_NUMBER, "");
1363 }
1364 
1365 std::vector<std::string>
1367  return getStringVector(libsumo::VAR_ARRIVED_VEHICLES_IDS, "");
1368 }
1369 
1370 int
1372  return (int) getInt(libsumo::VAR_TELEPORT_STARTING_VEHICLES_NUMBER, "");
1373 }
1374 
1375 std::vector<std::string>
1377  return getStringVector(libsumo::VAR_TELEPORT_STARTING_VEHICLES_IDS, "");
1378 }
1379 
1380 int
1382  return (int) getInt(libsumo::VAR_TELEPORT_ENDING_VEHICLES_NUMBER, "");
1383 }
1384 
1385 std::vector<std::string>
1387  return getStringVector(libsumo::VAR_TELEPORT_ENDING_VEHICLES_IDS, "");
1388 }
1389 
1390 double
1392  return getDouble(libsumo::VAR_DELTA_T, "");
1393 }
1394 
1397  return getPolygon(libsumo::VAR_NET_BOUNDING_BOX, "");
1398 }
1399 
1400 
1401 int
1403  return getInt(libsumo::VAR_MIN_EXPECTED_VEHICLES, "");
1404 }
1405 
1406 int
1407 TraCIAPI::SimulationScope::getBusStopWaiting(const std::string& stopID) const {
1408  return (int) getInt(libsumo::VAR_BUS_STOP_WAITING, stopID);
1409 }
1410 
1411 std::vector<std::string>
1412 TraCIAPI::SimulationScope::getBusStopWaitingIDList(const std::string& stopID) const {
1413  return getStringVector(libsumo::VAR_BUS_STOP_WAITING_IDS, stopID);
1414 }
1415 
1416 
1418 TraCIAPI::SimulationScope::convert2D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) const {
1419  const int posType = toGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D;
1420  libsumo::TraCIPosition result;
1421  tcpip::Storage content;
1423  content.writeInt(2);
1425  content.writeString(edgeID);
1426  content.writeDouble(pos);
1427  content.writeByte(laneIndex);
1428  content.writeByte(libsumo::TYPE_UBYTE);
1429  content.writeByte(posType);
1430  myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
1431  if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
1432  result.x = myParent.myInput.readDouble();
1433  result.y = myParent.myInput.readDouble();
1434  }
1435  return result;
1436 }
1437 
1438 
1440 TraCIAPI::SimulationScope::convert3D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) const {
1441  const int posType = toGeo ? libsumo::POSITION_LON_LAT_ALT : libsumo::POSITION_3D;
1442  libsumo::TraCIPosition result;
1443  tcpip::Storage content;
1445  content.writeInt(2);
1447  content.writeString(edgeID);
1448  content.writeDouble(pos);
1449  content.writeByte(laneIndex);
1450  content.writeByte(libsumo::TYPE_UBYTE);
1451  content.writeByte(posType);
1452  myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
1453  if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
1454  result.x = myParent.myInput.readDouble();
1455  result.y = myParent.myInput.readDouble();
1456  result.z = myParent.myInput.readDouble();
1457  }
1458  return result;
1459 }
1460 
1461 
1463 TraCIAPI::SimulationScope::convertRoad(double x, double y, bool isGeo, const std::string& vClass) const {
1465  tcpip::Storage content;
1467  content.writeInt(3);
1469  content.writeDouble(x);
1470  content.writeDouble(y);
1471  content.writeByte(libsumo::TYPE_UBYTE);
1474  content.writeString(vClass);
1475  myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
1476  if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_ROADMAP)) {
1477  result.edgeID = myParent.myInput.readString();
1478  result.pos = myParent.myInput.readDouble();
1479  result.laneIndex = myParent.myInput.readUnsignedByte();
1480  }
1481  return result;
1482 }
1483 
1484 
1486 TraCIAPI::SimulationScope::convertGeo(double x, double y, bool fromGeo) const {
1487  const int posType = fromGeo ? libsumo::POSITION_2D : libsumo::POSITION_LON_LAT;
1488  libsumo::TraCIPosition result;
1489  tcpip::Storage content;
1491  content.writeInt(2);
1493  content.writeDouble(x);
1494  content.writeDouble(y);
1495  content.writeByte(libsumo::TYPE_UBYTE);
1496  content.writeByte(posType);
1497  myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
1498  if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
1499  result.x = myParent.myInput.readDouble();
1500  result.y = myParent.myInput.readDouble();
1501  }
1502  return result;
1503 }
1504 
1505 
1506 double
1507 TraCIAPI::SimulationScope::getDistance2D(double x1, double y1, double x2, double y2, bool isGeo, bool isDriving) {
1508  tcpip::Storage content;
1510  content.writeInt(3);
1512  content.writeDouble(x1);
1513  content.writeDouble(y1);
1515  content.writeDouble(x2);
1516  content.writeDouble(y2);
1518  myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::DISTANCE_REQUEST, "", &content);
1519  if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::TYPE_DOUBLE)) {
1520  return myParent.myInput.readDouble();
1521  }
1522  return 0.;
1523 }
1524 
1525 
1526 double
1527 TraCIAPI::SimulationScope::getDistanceRoad(const std::string& edgeID1, double pos1, const std::string& edgeID2, double pos2, bool isDriving) {
1528  tcpip::Storage content;
1530  content.writeInt(3);
1532  content.writeString(edgeID1);
1533  content.writeDouble(pos1);
1534  content.writeByte(0); // lane
1536  content.writeString(edgeID2);
1537  content.writeDouble(pos2);
1538  content.writeByte(0); // lane
1540  myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::DISTANCE_REQUEST, "", &content);
1541  if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::TYPE_DOUBLE)) {
1542  return myParent.myInput.readDouble();
1543  }
1544  return 0.;
1545 }
1546 
1547 
1549 TraCIAPI::SimulationScope::findRoute(const std::string& fromEdge, const std::string& toEdge, const std::string& vType, double pos, int routingMode) const {
1550  tcpip::Storage content;
1552  content.writeInt(5);
1554  content.writeString(fromEdge);
1556  content.writeString(toEdge);
1558  content.writeString(vType);
1560  content.writeDouble(pos);
1562  content.writeInt(routingMode);
1563  return getTraCIStage(libsumo::FIND_ROUTE, "", &content);
1564 }
1565 
1566 
1567 void
1569  tcpip::Storage content;
1571  content.writeString(msg);
1572  myParent.createCommand(libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_MESSAGE, "", &content);
1573  myParent.processSet(libsumo::CMD_SET_SIM_VARIABLE);
1574 }
1575 
1576 
1577 // ---------------------------------------------------------------------------
1578 // TraCIAPI::TrafficLightScope-methods
1579 // ---------------------------------------------------------------------------
1580 std::string
1582  return getString(libsumo::TL_RED_YELLOW_GREEN_STATE, tlsID);
1583 }
1584 
1585 std::vector<libsumo::TraCILogic>
1586 TraCIAPI::TrafficLightScope::getAllProgramLogics(const std::string& tlsID) const {
1587  std::vector<libsumo::TraCILogic> ret;
1588  myParent.createCommand(libsumo::CMD_GET_TL_VARIABLE, libsumo::TL_COMPLETE_DEFINITION_RYG, tlsID);
1589  if (myParent.processGet(libsumo::CMD_GET_TL_VARIABLE, libsumo::TYPE_COMPOUND)) {
1590  const int logicNo = myParent.myInput.readInt();
1591  for (int i = 0; i < logicNo; ++i) {
1592  myParent.myInput.readUnsignedByte();
1593  myParent.myInput.readInt();
1594  myParent.myInput.readUnsignedByte();
1595  const std::string programID = myParent.myInput.readString();
1596  myParent.myInput.readUnsignedByte();
1597  const int type = myParent.myInput.readInt();
1598  myParent.myInput.readUnsignedByte();
1599  const int phaseIndex = myParent.myInput.readInt();
1600  myParent.myInput.readUnsignedByte();
1601  const int phaseNumber = myParent.myInput.readInt();
1602  libsumo::TraCILogic logic(programID, type, phaseIndex);
1603  for (int j = 0; j < phaseNumber; j++) {
1604  myParent.myInput.readUnsignedByte();
1605  myParent.myInput.readInt();
1606  myParent.myInput.readUnsignedByte();
1607  const double duration = myParent.myInput.readDouble();
1608  myParent.myInput.readUnsignedByte();
1609  const std::string state = myParent.myInput.readString();
1610  myParent.myInput.readUnsignedByte();
1611  const double minDur = myParent.myInput.readDouble();
1612  myParent.myInput.readUnsignedByte();
1613  const double maxDur = myParent.myInput.readDouble();
1614  myParent.myInput.readUnsignedByte();
1615  const int numNext = myParent.myInput.readInt();
1616  std::vector<int> next;
1617  for (int k = 0; k < numNext; k++) {
1618  myParent.myInput.readUnsignedByte();
1619  next.push_back(myParent.myInput.readInt());
1620  }
1621  myParent.myInput.readUnsignedByte();
1622  const std::string name = myParent.myInput.readString();
1623  logic.phases.emplace_back(new libsumo::TraCIPhase(duration, state, minDur, maxDur, next, name));
1624  }
1625  myParent.myInput.readUnsignedByte();
1626  const int paramNumber = myParent.myInput.readInt();
1627  for (int j = 0; j < paramNumber; j++) {
1628  myParent.myInput.readUnsignedByte();
1629  const std::vector<std::string> par = myParent.myInput.readStringList();
1630  logic.subParameter[par[0]] = par[1];
1631  }
1632  ret.emplace_back(logic);
1633  }
1634  }
1635  return ret;
1636 }
1637 
1638 std::vector<std::string>
1639 TraCIAPI::TrafficLightScope::getControlledLanes(const std::string& tlsID) const {
1640  return getStringVector(libsumo::TL_CONTROLLED_LANES, tlsID);
1641 }
1642 
1643 std::vector<std::vector<libsumo::TraCILink> >
1644 TraCIAPI::TrafficLightScope::getControlledLinks(const std::string& tlsID) const {
1645  std::vector<std::vector<libsumo::TraCILink> > result;
1646  myParent.createCommand(libsumo::CMD_GET_TL_VARIABLE, libsumo::TL_CONTROLLED_LINKS, tlsID);
1647  if (myParent.processGet(libsumo::CMD_GET_TL_VARIABLE, libsumo::TYPE_COMPOUND)) {
1648 
1649  myParent.myInput.readUnsignedByte();
1650  myParent.myInput.readInt();
1651 
1652  int linkNo = myParent.myInput.readInt();
1653  for (int i = 0; i < linkNo; ++i) {
1654  myParent.myInput.readUnsignedByte();
1655  int no = myParent.myInput.readInt();
1656  std::vector<libsumo::TraCILink> ret;
1657  for (int i1 = 0; i1 < no; ++i1) {
1658  myParent.myInput.readUnsignedByte();
1659  myParent.myInput.readInt();
1660  std::string from = myParent.myInput.readString();
1661  std::string to = myParent.myInput.readString();
1662  std::string via = myParent.myInput.readString();
1663  ret.emplace_back(libsumo::TraCILink(from, via, to));
1664  }
1665  result.emplace_back(ret);
1666  }
1667  }
1668  return result;
1669 }
1670 
1671 std::string
1672 TraCIAPI::TrafficLightScope::getProgram(const std::string& tlsID) const {
1673  return getString(libsumo::TL_CURRENT_PROGRAM, tlsID);
1674 }
1675 
1676 int
1677 TraCIAPI::TrafficLightScope::getPhase(const std::string& tlsID) const {
1678  return getInt(libsumo::TL_CURRENT_PHASE, tlsID);
1679 }
1680 
1681 std::string
1682 TraCIAPI::TrafficLightScope::getPhaseName(const std::string& tlsID) const {
1683  return getString(libsumo::VAR_NAME, tlsID);
1684 }
1685 
1686 double
1687 TraCIAPI::TrafficLightScope::getPhaseDuration(const std::string& tlsID) const {
1688  return getDouble(libsumo::TL_PHASE_DURATION, tlsID);
1689 }
1690 
1691 double
1692 TraCIAPI::TrafficLightScope::getNextSwitch(const std::string& tlsID) const {
1693  return getDouble(libsumo::TL_NEXT_SWITCH, tlsID);
1694 }
1695 
1696 
1697 int
1698 TraCIAPI::TrafficLightScope::getServedPersonCount(const std::string& tlsID, int index) const {
1699  tcpip::Storage content;
1701  content.writeInt(index);
1702  return getInt(libsumo::VAR_PERSON_NUMBER, tlsID, &content);
1703 }
1704 
1705 
1706 void
1707 TraCIAPI::TrafficLightScope::setRedYellowGreenState(const std::string& tlsID, const std::string& state) const {
1708  tcpip::Storage content;
1710  content.writeString(state);
1711  myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_RED_YELLOW_GREEN_STATE, tlsID, &content);
1712  myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1713 }
1714 
1715 void
1716 TraCIAPI::TrafficLightScope::setPhase(const std::string& tlsID, int index) const {
1717  tcpip::Storage content;
1719  content.writeInt(index);
1720  myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PHASE_INDEX, tlsID, &content);
1721  myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1722 }
1723 
1724 void
1725 TraCIAPI::TrafficLightScope::setPhaseName(const std::string& tlsID, const std::string& name) const {
1726  tcpip::Storage content;
1728  content.writeString(name);
1729  myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::VAR_NAME, tlsID, &content);
1730  myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1731 }
1732 
1733 void
1734 TraCIAPI::TrafficLightScope::setProgram(const std::string& tlsID, const std::string& programID) const {
1735  tcpip::Storage content;
1737  content.writeString(programID);
1738  myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PROGRAM, tlsID, &content);
1739  myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1740 }
1741 
1742 void
1743 TraCIAPI::TrafficLightScope::setPhaseDuration(const std::string& tlsID, double phaseDuration) const {
1744  tcpip::Storage content;
1746  content.writeDouble(phaseDuration);
1747  myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PHASE_DURATION, tlsID, &content);
1748  myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1749 }
1750 
1751 void
1752 TraCIAPI::TrafficLightScope::setProgramLogic(const std::string& tlsID, const libsumo::TraCILogic& logic) const {
1753  tcpip::Storage content;
1755  content.writeInt(5);
1757  content.writeString(logic.programID);
1759  content.writeInt(logic.type);
1761  content.writeInt(logic.currentPhaseIndex);
1763  content.writeInt((int)logic.phases.size());
1764  for (const libsumo::TraCIPhase* p : logic.phases) {
1766  content.writeInt(6);
1768  content.writeDouble(p->duration);
1770  content.writeString(p->state);
1772  content.writeDouble(p->minDur);
1774  content.writeDouble(p->maxDur);
1776  content.writeInt((int)p->next.size());
1777  for (int n : p->next) {
1779  content.writeInt(n);
1780  }
1782  content.writeString(p->name);
1783  }
1785  content.writeInt((int)logic.subParameter.size());
1786  for (const auto& item : logic.subParameter) {
1788  content.writeInt(2);
1789  content.writeString(item.first);
1790  content.writeString(item.second);
1791  }
1792  myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_COMPLETE_PROGRAM_RYG, tlsID, &content);
1793  myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1794 }
1795 
1796 
1797 // ---------------------------------------------------------------------------
1798 // TraCIAPI::VehicleTypeScope-methods
1799 // ---------------------------------------------------------------------------
1800 double
1801 TraCIAPI::VehicleTypeScope::getLength(const std::string& typeID) const {
1802  return getDouble(libsumo::VAR_LENGTH, typeID);
1803 }
1804 
1805 double
1806 TraCIAPI::VehicleTypeScope::getMaxSpeed(const std::string& typeID) const {
1807  return getDouble(libsumo::VAR_MAXSPEED, typeID);
1808 }
1809 
1810 double
1811 TraCIAPI::VehicleTypeScope::getSpeedFactor(const std::string& typeID) const {
1812  return getDouble(libsumo::VAR_SPEED_FACTOR, typeID);
1813 }
1814 
1815 double
1816 TraCIAPI::VehicleTypeScope::getSpeedDeviation(const std::string& typeID) const {
1817  return getDouble(libsumo::VAR_SPEED_DEVIATION, typeID);
1818 }
1819 
1820 double
1821 TraCIAPI::VehicleTypeScope::getAccel(const std::string& typeID) const {
1822  return getDouble(libsumo::VAR_ACCEL, typeID);
1823 }
1824 
1825 double
1826 TraCIAPI::VehicleTypeScope::getDecel(const std::string& typeID) const {
1827  return getDouble(libsumo::VAR_DECEL, typeID);
1828 }
1829 
1830 double
1831 TraCIAPI::VehicleTypeScope::getEmergencyDecel(const std::string& typeID) const {
1832  return getDouble(libsumo::VAR_EMERGENCY_DECEL, typeID);
1833 }
1834 
1835 double
1836 TraCIAPI::VehicleTypeScope::getApparentDecel(const std::string& typeID) const {
1837  return getDouble(libsumo::VAR_APPARENT_DECEL, typeID);
1838 }
1839 
1840 double
1841 TraCIAPI::VehicleTypeScope::getImperfection(const std::string& typeID) const {
1842  return getDouble(libsumo::VAR_IMPERFECTION, typeID);
1843 }
1844 
1845 double
1846 TraCIAPI::VehicleTypeScope::getTau(const std::string& typeID) const {
1847  return getDouble(libsumo::VAR_TAU, typeID);
1848 }
1849 
1850 std::string
1851 TraCIAPI::VehicleTypeScope::getVehicleClass(const std::string& typeID) const {
1852  return getString(libsumo::VAR_VEHICLECLASS, typeID);
1853 }
1854 
1855 std::string
1856 TraCIAPI::VehicleTypeScope::getEmissionClass(const std::string& typeID) const {
1857  return getString(libsumo::VAR_EMISSIONCLASS, typeID);
1858 }
1859 
1860 std::string
1861 TraCIAPI::VehicleTypeScope::getShapeClass(const std::string& typeID) const {
1862  return getString(libsumo::VAR_SHAPECLASS, typeID);
1863 }
1864 
1865 double
1866 TraCIAPI::VehicleTypeScope::getMinGap(const std::string& typeID) const {
1867  return getDouble(libsumo::VAR_MINGAP, typeID);
1868 }
1869 
1870 double
1871 TraCIAPI::VehicleTypeScope::getMinGapLat(const std::string& typeID) const {
1872  return getDouble(libsumo::VAR_MINGAP_LAT, typeID);
1873 }
1874 
1875 double
1876 TraCIAPI::VehicleTypeScope::getMaxSpeedLat(const std::string& typeID) const {
1877  return getDouble(libsumo::VAR_MAXSPEED_LAT, typeID);
1878 }
1879 
1880 std::string
1881 TraCIAPI::VehicleTypeScope::getLateralAlignment(const std::string& typeID) const {
1882  return getString(libsumo::VAR_LATALIGNMENT, typeID);
1883 }
1884 
1885 int
1886 TraCIAPI::VehicleTypeScope::getPersonCapacity(const std::string& typeID) const {
1887  return getInt(libsumo::VAR_PERSON_CAPACITY, typeID);
1888 }
1889 
1890 double
1891 TraCIAPI::VehicleTypeScope::getWidth(const std::string& typeID) const {
1892  return getDouble(libsumo::VAR_WIDTH, typeID);
1893 }
1894 
1895 double
1896 TraCIAPI::VehicleTypeScope::getHeight(const std::string& typeID) const {
1897  return getDouble(libsumo::VAR_HEIGHT, typeID);
1898 }
1899 
1901 TraCIAPI::VehicleTypeScope::getColor(const std::string& typeID) const {
1902  return getCol(libsumo::VAR_COLOR, typeID);
1903 }
1904 
1905 
1906 
1907 void
1908 TraCIAPI::VehicleTypeScope::setLength(const std::string& typeID, double length) const {
1909  tcpip::Storage content;
1911  content.writeDouble(length);
1912  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_LENGTH, typeID, &content);
1913  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1914 }
1915 
1916 void
1917 TraCIAPI::VehicleTypeScope::setMaxSpeed(const std::string& typeID, double speed) const {
1918  tcpip::Storage content;
1920  content.writeDouble(speed);
1921  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MAXSPEED, typeID, &content);
1922  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1923 }
1924 
1925 void
1926 TraCIAPI::VehicleTypeScope::setVehicleClass(const std::string& typeID, const std::string& clazz) const {
1927  tcpip::Storage content;
1929  content.writeString(clazz);
1930  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_VEHICLECLASS, typeID, &content);
1931  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1932 }
1933 
1934 void
1935 TraCIAPI::VehicleTypeScope::setSpeedFactor(const std::string& typeID, double factor) const {
1936  tcpip::Storage content;
1938  content.writeDouble(factor);
1939  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SPEED_FACTOR, typeID, &content);
1940  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1941 }
1942 
1943 void
1944 TraCIAPI::VehicleTypeScope::setSpeedDeviation(const std::string& typeID, double deviation) const {
1945  tcpip::Storage content;
1947  content.writeDouble(deviation);
1948  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SPEED_DEVIATION, typeID, &content);
1949  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1950 }
1951 
1952 
1953 void
1954 TraCIAPI::VehicleTypeScope::setEmissionClass(const std::string& typeID, const std::string& clazz) const {
1955  tcpip::Storage content;
1957  content.writeString(clazz);
1958  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_EMISSIONCLASS, typeID, &content);
1959  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1960 }
1961 
1962 void
1963 TraCIAPI::VehicleTypeScope::setWidth(const std::string& typeID, double width) const {
1964  tcpip::Storage content;
1966  content.writeDouble(width);
1967  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_WIDTH, typeID, &content);
1968  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1969 }
1970 
1971 void
1972 TraCIAPI::VehicleTypeScope::setHeight(const std::string& typeID, double height) const {
1973  tcpip::Storage content;
1975  content.writeDouble(height);
1976  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_HEIGHT, typeID, &content);
1977  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1978 }
1979 
1980 void
1981 TraCIAPI::VehicleTypeScope::setMinGap(const std::string& typeID, double minGap) const {
1982  tcpip::Storage content;
1984  content.writeDouble(minGap);
1985  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MINGAP, typeID, &content);
1986  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1987 }
1988 
1989 
1990 void
1991 TraCIAPI::VehicleTypeScope::setMinGapLat(const std::string& typeID, double minGapLat) const {
1992  tcpip::Storage content;
1994  content.writeDouble(minGapLat);
1995  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MINGAP_LAT, typeID, &content);
1996  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1997 }
1998 
1999 void
2000 TraCIAPI::VehicleTypeScope::setMaxSpeedLat(const std::string& typeID, double speed) const {
2001  tcpip::Storage content;
2003  content.writeDouble(speed);
2004  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MAXSPEED_LAT, typeID, &content);
2005  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2006 }
2007 
2008 void
2009 TraCIAPI::VehicleTypeScope::setLateralAlignment(const std::string& typeID, const std::string& latAlignment) const {
2010  tcpip::Storage content;
2012  content.writeString(latAlignment);
2013  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_LATALIGNMENT, typeID, &content);
2014  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2015 }
2016 
2017 void
2018 TraCIAPI::VehicleTypeScope::copy(const std::string& origTypeID, const std::string& newTypeID) const {
2019  tcpip::Storage content;
2021  content.writeString(newTypeID);
2022  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::COPY, origTypeID, &content);
2023  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2024 }
2025 
2026 void
2027 TraCIAPI::VehicleTypeScope::setShapeClass(const std::string& typeID, const std::string& clazz) const {
2028  tcpip::Storage content;
2030  content.writeString(clazz);
2031  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SHAPECLASS, typeID, &content);
2032  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2033 }
2034 
2035 void
2036 TraCIAPI::VehicleTypeScope::setAccel(const std::string& typeID, double accel) const {
2037  tcpip::Storage content;
2039  content.writeDouble(accel);
2040  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_ACCEL, typeID, &content);
2041  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2042 }
2043 
2044 void
2045 TraCIAPI::VehicleTypeScope::setDecel(const std::string& typeID, double decel) const {
2046  tcpip::Storage content;
2048  content.writeDouble(decel);
2049  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_DECEL, typeID, &content);
2050  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2051 }
2052 
2053 void
2054 TraCIAPI::VehicleTypeScope::setEmergencyDecel(const std::string& typeID, double decel) const {
2055  tcpip::Storage content;
2057  content.writeDouble(decel);
2058  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_EMERGENCY_DECEL, typeID, &content);
2059  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2060 }
2061 
2062 void
2063 TraCIAPI::VehicleTypeScope::setApparentDecel(const std::string& typeID, double decel) const {
2064  tcpip::Storage content;
2066  content.writeDouble(decel);
2067  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_APPARENT_DECEL, typeID, &content);
2068  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2069 }
2070 
2071 void
2072 TraCIAPI::VehicleTypeScope::setImperfection(const std::string& typeID, double imperfection) const {
2073  tcpip::Storage content;
2075  content.writeDouble(imperfection);
2076  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_IMPERFECTION, typeID, &content);
2077  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2078 }
2079 
2080 void
2081 TraCIAPI::VehicleTypeScope::setTau(const std::string& typeID, double tau) const {
2082  tcpip::Storage content;
2084  content.writeDouble(tau);
2085  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_TAU, typeID, &content);
2086  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2087 }
2088 
2089 void
2090 TraCIAPI::VehicleTypeScope::setColor(const std::string& typeID, const libsumo::TraCIColor& c) const {
2091  tcpip::Storage content;
2093  content.writeUnsignedByte(c.r);
2094  content.writeUnsignedByte(c.g);
2095  content.writeUnsignedByte(c.b);
2096  content.writeUnsignedByte(c.a);
2097  myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_COLOR, typeID, &content);
2098  myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2099 }
2100 
2101 
2102 // ---------------------------------------------------------------------------
2103 // TraCIAPI::VehicleScope-methods
2104 // ---------------------------------------------------------------------------
2105 double
2106 TraCIAPI::VehicleScope::getSpeed(const std::string& vehicleID) const {
2107  return getDouble(libsumo::VAR_SPEED, vehicleID);
2108 }
2109 
2110 double
2111 TraCIAPI::VehicleScope::getLateralSpeed(const std::string& vehicleID) const {
2112  return getDouble(libsumo::VAR_SPEED_LAT, vehicleID);
2113 }
2114 
2115 double
2116 TraCIAPI::VehicleScope::getAcceleration(const std::string& vehicleID) const {
2117  return getDouble(libsumo::VAR_ACCELERATION, vehicleID);
2118 }
2119 
2120 double
2121 TraCIAPI::VehicleScope::getFollowSpeed(const std::string& vehicleID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) const {
2122  tcpip::Storage content;
2124  content.writeInt(5);
2126  content.writeDouble(speed);
2128  content.writeDouble(gap);
2130  content.writeDouble(leaderSpeed);
2132  content.writeDouble(leaderMaxDecel);
2134  content.writeString(leaderID);
2135  return getDouble(libsumo::VAR_FOLLOW_SPEED, vehicleID, &content);
2136 }
2137 
2138 
2139 double
2140 TraCIAPI::VehicleScope::getSecureGap(const std::string& vehicleID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) const {
2141  tcpip::Storage content;
2143  content.writeInt(4);
2145  content.writeDouble(speed);
2147  content.writeDouble(leaderSpeed);
2149  content.writeDouble(leaderMaxDecel);
2151  content.writeString(leaderID);
2152  return getDouble(libsumo::VAR_SECURE_GAP, vehicleID, &content);
2153 }
2154 
2155 double
2156 TraCIAPI::VehicleScope::getStopSpeed(const std::string& vehicleID, double speed, double gap) const {
2157  tcpip::Storage content;
2159  content.writeInt(2);
2161  content.writeDouble(speed);
2163  content.writeDouble(gap);
2164  return getDouble(libsumo::VAR_STOP_SPEED, vehicleID, &content);
2165 }
2166 
2167 
2168 double
2169 TraCIAPI::VehicleScope::getMaxSpeed(const std::string& vehicleID) const {
2170  return getDouble(libsumo::VAR_MAXSPEED, vehicleID);
2171 }
2172 
2174 TraCIAPI::VehicleScope::getPosition(const std::string& vehicleID) const {
2175  return getPos(libsumo::VAR_POSITION, vehicleID);
2176 }
2177 
2179 TraCIAPI::VehicleScope::getPosition3D(const std::string& vehicleID) const {
2180  return getPos3D(libsumo::VAR_POSITION3D, vehicleID);
2181 }
2182 
2183 double
2184 TraCIAPI::VehicleScope::getAngle(const std::string& vehicleID) const {
2185  return getDouble(libsumo::VAR_ANGLE, vehicleID);
2186 }
2187 
2188 std::string
2189 TraCIAPI::VehicleScope::getRoadID(const std::string& vehicleID) const {
2190  return getString(libsumo::VAR_ROAD_ID, vehicleID);
2191 }
2192 
2193 std::string
2194 TraCIAPI::VehicleScope::getLaneID(const std::string& vehicleID) const {
2195  return getString(libsumo::VAR_LANE_ID, vehicleID);
2196 }
2197 
2198 int
2199 TraCIAPI::VehicleScope::getLaneIndex(const std::string& vehicleID) const {
2200  return getInt(libsumo::VAR_LANE_INDEX, vehicleID);
2201 }
2202 
2203 std::string
2204 TraCIAPI::VehicleScope::getTypeID(const std::string& vehicleID) const {
2205  return getString(libsumo::VAR_TYPE, vehicleID);
2206 }
2207 
2208 std::string
2209 TraCIAPI::VehicleScope::getRouteID(const std::string& vehicleID) const {
2210  return getString(libsumo::VAR_ROUTE_ID, vehicleID);
2211 }
2212 
2213 int
2214 TraCIAPI::VehicleScope::getRouteIndex(const std::string& vehicleID) const {
2215  return getInt(libsumo::VAR_ROUTE_INDEX, vehicleID);
2216 }
2217 
2218 
2219 std::vector<std::string>
2220 TraCIAPI::VehicleScope::getRoute(const std::string& vehicleID) const {
2221  return getStringVector(libsumo::VAR_EDGES, vehicleID);
2222 }
2223 
2225 TraCIAPI::VehicleScope::getColor(const std::string& vehicleID) const {
2226  return getCol(libsumo::VAR_COLOR, vehicleID);
2227 }
2228 
2229 double
2230 TraCIAPI::VehicleScope::getLanePosition(const std::string& vehicleID) const {
2231  return getDouble(libsumo::VAR_LANEPOSITION, vehicleID);
2232 }
2233 
2234 double
2235 TraCIAPI::VehicleScope::getDistance(const std::string& vehicleID) const {
2236  return getDouble(libsumo::VAR_DISTANCE, vehicleID);
2237 }
2238 
2239 int
2240 TraCIAPI::VehicleScope::getSignals(const std::string& vehicleID) const {
2241  return getInt(libsumo::VAR_SIGNALS, vehicleID);
2242 }
2243 
2244 double
2245 TraCIAPI::VehicleScope::getLateralLanePosition(const std::string& vehicleID) const {
2246  return getDouble(libsumo::VAR_LANEPOSITION_LAT, vehicleID);
2247 }
2248 
2249 double
2250 TraCIAPI::VehicleScope::getCO2Emission(const std::string& vehicleID) const {
2251  return getDouble(libsumo::VAR_CO2EMISSION, vehicleID);
2252 }
2253 
2254 double
2255 TraCIAPI::VehicleScope::getCOEmission(const std::string& vehicleID) const {
2256  return getDouble(libsumo::VAR_COEMISSION, vehicleID);
2257 }
2258 
2259 double
2260 TraCIAPI::VehicleScope::getHCEmission(const std::string& vehicleID) const {
2261  return getDouble(libsumo::VAR_HCEMISSION, vehicleID);
2262 }
2263 
2264 double
2265 TraCIAPI::VehicleScope::getPMxEmission(const std::string& vehicleID) const {
2266  return getDouble(libsumo::VAR_PMXEMISSION, vehicleID);
2267 }
2268 
2269 double
2270 TraCIAPI::VehicleScope::getNOxEmission(const std::string& vehicleID) const {
2271  return getDouble(libsumo::VAR_NOXEMISSION, vehicleID);
2272 }
2273 
2274 double
2275 TraCIAPI::VehicleScope::getFuelConsumption(const std::string& vehicleID) const {
2276  return getDouble(libsumo::VAR_FUELCONSUMPTION, vehicleID);
2277 }
2278 
2279 double
2280 TraCIAPI::VehicleScope::getNoiseEmission(const std::string& vehicleID) const {
2281  return getDouble(libsumo::VAR_NOISEEMISSION, vehicleID);
2282 }
2283 
2284 double
2285 TraCIAPI::VehicleScope::getElectricityConsumption(const std::string& vehicleID) const {
2286  return getDouble(libsumo::VAR_ELECTRICITYCONSUMPTION, vehicleID);
2287 }
2288 
2289 double
2290 TraCIAPI::VehicleScope::getWaitingTime(const std::string& vehID) const {
2291  return getDouble(libsumo::VAR_WAITING_TIME, vehID);
2292 }
2293 
2294 int
2295 TraCIAPI::VehicleScope::getLaneChangeMode(const std::string& vehID) const {
2296  return getInt(libsumo::VAR_LANECHANGE_MODE, vehID);
2297 }
2298 
2299 
2300 int
2301 TraCIAPI::VehicleScope::getSpeedMode(const std::string& vehID) const {
2302  return getInt(libsumo::VAR_SPEEDSETMODE, vehID);
2303 }
2304 
2305 
2306 double
2307 TraCIAPI::VehicleScope::getSlope(const std::string& vehID) const {
2308  return getDouble(libsumo::VAR_SLOPE, vehID);
2309 }
2310 
2311 
2312 std::string
2313 TraCIAPI::VehicleScope::getLine(const std::string& typeID) const {
2314  return getString(libsumo::VAR_LINE, typeID);
2315 }
2316 
2317 std::vector<std::string>
2318 TraCIAPI::VehicleScope::getVia(const std::string& vehicleID) const {
2319  return getStringVector(libsumo::VAR_VIA, vehicleID);
2320 }
2321 
2322 std::string
2323 TraCIAPI::VehicleScope::getEmissionClass(const std::string& vehicleID) const {
2324  return getString(libsumo::VAR_EMISSIONCLASS, vehicleID);
2325 }
2326 
2327 std::string
2328 TraCIAPI::VehicleScope::getShapeClass(const std::string& vehicleID) const {
2329  return getString(libsumo::VAR_SHAPECLASS, vehicleID);
2330 }
2331 
2332 std::vector<libsumo::TraCINextTLSData>
2333 TraCIAPI::VehicleScope::getNextTLS(const std::string& vehID) const {
2334  std::vector<libsumo::TraCINextTLSData> result;
2335  myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_NEXT_TLS, vehID);
2336  if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
2337  myParent.myInput.readInt(); // components
2338  // number of items
2339  myParent.myInput.readUnsignedByte();
2340  const int n = myParent.myInput.readInt();
2341  for (int i = 0; i < n; ++i) {
2343  myParent.myInput.readUnsignedByte();
2344  d.id = myParent.myInput.readString();
2345 
2346  myParent.myInput.readUnsignedByte();
2347  d.tlIndex = myParent.myInput.readInt();
2348 
2349  myParent.myInput.readUnsignedByte();
2350  d.dist = myParent.myInput.readDouble();
2351 
2352  myParent.myInput.readUnsignedByte();
2353  d.state = (char)myParent.myInput.readByte();
2354 
2355  result.push_back(d);
2356  }
2357  }
2358  return result;
2359 }
2360 
2361 std::vector<libsumo::TraCIBestLanesData>
2362 TraCIAPI::VehicleScope::getBestLanes(const std::string& vehicleID) const {
2363  std::vector<libsumo::TraCIBestLanesData> result;
2364  myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_BEST_LANES, vehicleID);
2365  if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
2366  myParent.myInput.readInt();
2367  myParent.myInput.readUnsignedByte();
2368 
2369  const int n = myParent.myInput.readInt(); // number of following edge information
2370  for (int i = 0; i < n; ++i) {
2372  myParent.myInput.readUnsignedByte();
2373  info.laneID = myParent.myInput.readString();
2374 
2375  myParent.myInput.readUnsignedByte();
2376  info.length = myParent.myInput.readDouble();
2377 
2378  myParent.myInput.readUnsignedByte();
2379  info.occupation = myParent.myInput.readDouble();
2380 
2381  myParent.myInput.readUnsignedByte();
2382  info.bestLaneOffset = myParent.myInput.readByte();
2383 
2384  myParent.myInput.readUnsignedByte();
2385  info.allowsContinuation = (myParent.myInput.readUnsignedByte() == 1);
2386 
2387  myParent.myInput.readUnsignedByte();
2388  const int m = myParent.myInput.readInt();
2389  for (int i = 0; i < m; ++i) {
2390  info.continuationLanes.push_back(myParent.myInput.readString());
2391  }
2392 
2393  result.push_back(info);
2394  }
2395  }
2396  return result;
2397 }
2398 
2399 
2400 std::pair<std::string, double>
2401 TraCIAPI::VehicleScope::getLeader(const std::string& vehicleID, double dist) const {
2402  tcpip::Storage content;
2404  content.writeDouble(dist);
2405  myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_LEADER, vehicleID, &content);
2406  if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
2407  myParent.myInput.readInt(); // components
2408  myParent.myInput.readUnsignedByte();
2409  const std::string leaderID = myParent.myInput.readString();
2410  myParent.myInput.readUnsignedByte();
2411  const double gap = myParent.myInput.readDouble();
2412  return std::make_pair(leaderID, gap);
2413  }
2414  return std::make_pair("", libsumo::INVALID_DOUBLE_VALUE);
2415 }
2416 
2417 
2418 std::pair<std::string, double>
2419 TraCIAPI::VehicleScope::getFollower(const std::string& vehicleID, double dist) const {
2420  tcpip::Storage content;
2422  content.writeDouble(dist);
2423  myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_FOLLOWER, vehicleID, &content);
2424  if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
2425  myParent.myInput.readInt(); // components
2426  myParent.myInput.readUnsignedByte();
2427  const std::string leaderID = myParent.myInput.readString();
2428  myParent.myInput.readUnsignedByte();
2429  const double gap = myParent.myInput.readDouble();
2430  return std::make_pair(leaderID, gap);
2431  }
2432  return std::make_pair("", libsumo::INVALID_DOUBLE_VALUE);
2433 }
2434 
2435 
2436 std::pair<int, int>
2437 TraCIAPI::VehicleScope::getLaneChangeState(const std::string& vehicleID, int direction) const {
2438  tcpip::Storage content;
2440  content.writeInt(direction);
2441  myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
2442  if (myParent.processGet(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::TYPE_COMPOUND)) {
2443  myParent.myInput.readInt(); // components
2444  myParent.myInput.readUnsignedByte();
2445  const int stateWithoutTraCI = myParent.myInput.readInt();
2446  myParent.myInput.readUnsignedByte();
2447  const int state = myParent.myInput.readInt();
2448  return std::make_pair(stateWithoutTraCI, state);
2449  }
2451 }
2452 
2453 
2454 int
2455 TraCIAPI::VehicleScope::getStopState(const std::string& vehicleID) const {
2456  return getInt(libsumo::VAR_STOPSTATE, vehicleID);
2457 }
2458 
2459 int
2460 TraCIAPI::VehicleScope::getRoutingMode(const std::string& vehicleID) const {
2461  return getInt(libsumo::VAR_ROUTING_MODE, vehicleID);
2462 }
2463 
2464 double
2465 TraCIAPI::VehicleScope::getStopDelay(const std::string& vehicleID) const {
2466  return getDouble(libsumo::VAR_STOP_DELAY, vehicleID);
2467 }
2468 
2469 double
2470 TraCIAPI::VehicleScope::getStopArrivalDelay(const std::string& vehicleID) const {
2471  return getDouble(libsumo::VAR_STOP_ARRIVALDELAY, vehicleID);
2472 }
2473 
2474 
2475 double
2476 TraCIAPI::VehicleScope::getAccel(const std::string& vehicleID) const {
2477  return getDouble(libsumo::VAR_ACCEL, vehicleID);
2478 }
2479 
2480 double
2481 TraCIAPI::VehicleScope::getDecel(const std::string& vehicleID) const {
2482  return getDouble(libsumo::VAR_DECEL, vehicleID);
2483 }
2484 
2485 double
2486 TraCIAPI::VehicleScope::getTau(const std::string& vehicleID) const {
2487  return getDouble(libsumo::VAR_TAU, vehicleID);
2488 }
2489 
2490 double
2491 TraCIAPI::VehicleScope::getImperfection(const std::string& vehicleID) const {
2492  return getDouble(libsumo::VAR_IMPERFECTION, vehicleID);
2493 }
2494 
2495 double
2496 TraCIAPI::VehicleScope::getSpeedFactor(const std::string& vehicleID) const {
2497  return getDouble(libsumo::VAR_SPEED_FACTOR, vehicleID);
2498 }
2499 
2500 double
2501 TraCIAPI::VehicleScope::getSpeedDeviation(const std::string& vehicleID) const {
2502  return getDouble(libsumo::VAR_SPEED_DEVIATION, vehicleID);
2503 }
2504 
2505 std::string
2506 TraCIAPI::VehicleScope::getVehicleClass(const std::string& vehicleID) const {
2507  return getString(libsumo::VAR_VEHICLECLASS, vehicleID);
2508 }
2509 
2510 double
2511 TraCIAPI::VehicleScope::getMinGap(const std::string& vehicleID) const {
2512  return getDouble(libsumo::VAR_MINGAP, vehicleID);
2513 }
2514 
2515 double
2516 TraCIAPI::VehicleScope::getWidth(const std::string& vehicleID) const {
2517  return getDouble(libsumo::VAR_WIDTH, vehicleID);
2518 }
2519 
2520 double
2521 TraCIAPI::VehicleScope::getLength(const std::string& vehicleID) const {
2522  return getDouble(libsumo::VAR_LENGTH, vehicleID);
2523 }
2524 
2525 double
2526 TraCIAPI::VehicleScope::getHeight(const std::string& vehicleID) const {
2527  return getDouble(libsumo::VAR_HEIGHT, vehicleID);
2528 }
2529 
2530 double
2531 TraCIAPI::VehicleScope::getAccumulatedWaitingTime(const std::string& vehicleID) const {
2532  return getDouble(libsumo::VAR_ACCUMULATED_WAITING_TIME, vehicleID);
2533 }
2534 
2535 double
2536 TraCIAPI::VehicleScope::getAllowedSpeed(const std::string& vehicleID) const {
2537  return getDouble(libsumo::VAR_ALLOWED_SPEED, vehicleID);
2538 }
2539 
2540 int
2541 TraCIAPI::VehicleScope::getPersonNumber(const std::string& vehicleID) const {
2542  return getInt(libsumo::VAR_PERSON_NUMBER, vehicleID);
2543 }
2544 
2545 int
2546 TraCIAPI::VehicleScope::getPersonCapacity(const std::string& vehicleID) const {
2547  return getInt(libsumo::VAR_PERSON_CAPACITY, vehicleID);
2548 }
2549 
2550 std::vector<std::string>
2551 TraCIAPI::VehicleScope::getPersonIDList(const std::string& vehicleID) const {
2552  return getStringVector(libsumo::LAST_STEP_PERSON_ID_LIST, vehicleID);
2553 }
2554 
2555 double
2556 TraCIAPI::VehicleScope::getSpeedWithoutTraCI(const std::string& vehicleID) const {
2557  return getDouble(libsumo::VAR_SPEED_WITHOUT_TRACI, vehicleID);
2558 }
2559 
2560 bool
2561 TraCIAPI::VehicleScope::isRouteValid(const std::string& vehicleID) const {
2562  return getInt(libsumo::VAR_ROUTE_VALID, vehicleID) != 0;
2563 }
2564 
2565 double
2566 TraCIAPI::VehicleScope::getMaxSpeedLat(const std::string& vehicleID) const {
2567  return getDouble(libsumo::VAR_MAXSPEED_LAT, vehicleID);
2568 }
2569 
2570 double
2571 TraCIAPI::VehicleScope::getMinGapLat(const std::string& vehicleID) const {
2572  return getDouble(libsumo::VAR_MINGAP_LAT, vehicleID);
2573 }
2574 
2575 std::string
2576 TraCIAPI::VehicleScope::getLateralAlignment(const std::string& vehicleID) const {
2577  return getString(libsumo::VAR_LATALIGNMENT, vehicleID);
2578 }
2579 
2580 void
2581 TraCIAPI::VehicleScope::add(const std::string& vehicleID,
2582  const std::string& routeID,
2583  const std::string& typeID,
2584  std::string depart,
2585  const std::string& departLane,
2586  const std::string& departPos,
2587  const std::string& departSpeed,
2588  const std::string& arrivalLane,
2589  const std::string& arrivalPos,
2590  const std::string& arrivalSpeed,
2591  const std::string& fromTaz,
2592  const std::string& toTaz,
2593  const std::string& line,
2594  int personCapacity,
2595  int personNumber) const {
2596 
2597  if (depart == "-1") {
2598  depart = toString(myParent.simulation.getCurrentTime() / 1000.0);
2599  }
2600  tcpip::Storage content;
2602  content.writeInt(14);
2604  content.writeString(routeID);
2606  content.writeString(typeID);
2608  content.writeString(depart);
2610  content.writeString(departLane);
2612  content.writeString(departPos);
2614  content.writeString(departSpeed);
2615 
2617  content.writeString(arrivalLane);
2619  content.writeString(arrivalPos);
2621  content.writeString(arrivalSpeed);
2622 
2624  content.writeString(fromTaz);
2626  content.writeString(toTaz);
2628  content.writeString(line);
2629 
2631  content.writeInt(personCapacity);
2633  content.writeInt(personNumber);
2634 
2635  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::ADD_FULL, vehicleID, &content);
2636  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2637 }
2638 
2639 
2640 void
2641 TraCIAPI::VehicleScope::remove(const std::string& vehicleID, char reason) const {
2642  tcpip::Storage content;
2644  content.writeUnsignedByte(reason);
2645  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::REMOVE, vehicleID, &content);
2646  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2647 
2648 }
2649 
2650 
2651 void
2652 TraCIAPI::VehicleScope::changeTarget(const std::string& vehicleID, const std::string& edgeID) const {
2653  tcpip::Storage content;
2655  content.writeString(edgeID);
2656  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGETARGET, vehicleID, &content);
2657  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2658 }
2659 
2660 
2661 void
2662 TraCIAPI::VehicleScope::changeLane(const std::string& vehicleID, int laneIndex, double duration) const {
2663  tcpip::Storage content;
2665  content.writeInt(2);
2667  content.writeByte(laneIndex);
2669  content.writeDouble(duration);
2670  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
2671  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2672 }
2673 
2674 
2675 void
2676 TraCIAPI::VehicleScope::changeLaneRelative(const std::string& vehicleID, int laneChange, double duration) const {
2677  tcpip::Storage content;
2679  content.writeInt(3);
2681  content.writeByte(laneChange);
2683  content.writeDouble(duration);
2685  content.writeByte(1);
2686  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
2687  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2688 }
2689 
2690 
2691 void
2692 TraCIAPI::VehicleScope::changeSublane(const std::string& vehicleID, double latDist) const {
2693  tcpip::Storage content;
2695  content.writeDouble(latDist);
2696  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGESUBLANE, vehicleID, &content);
2697  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2698 }
2699 
2700 
2701 void
2702 TraCIAPI::VehicleScope::setRouteID(const std::string& vehicleID, const std::string& routeID) const {
2703  tcpip::Storage content;
2705  content.writeString(routeID);
2706  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTE_ID, vehicleID, &content);
2707  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2708 }
2709 
2710 
2711 void
2712 TraCIAPI::VehicleScope::setRoute(const std::string& vehicleID, const std::vector<std::string>& edges) const {
2713  tcpip::Storage content;
2715  content.writeInt((int)edges.size());
2716  for (int i = 0; i < (int)edges.size(); ++i) {
2717  content.writeString(edges[i]);
2718  }
2719  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTE, vehicleID, &content);
2720  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2721 }
2722 
2723 
2724 void
2725 TraCIAPI::VehicleScope::rerouteTraveltime(const std::string& vehicleID, bool currentTravelTimes) const {
2726  if (currentTravelTimes) {
2727  // updated edge weights with current network traveltimes (at most once per simulation step)
2728  std::vector<std::string> edges = myParent.edge.getIDList();
2729  for (std::vector<std::string>::iterator it = edges.begin(); it != edges.end(); ++it) {
2730  myParent.edge.adaptTraveltime(*it, myParent.edge.getTraveltime(*it));
2731  }
2732  }
2733 
2734  tcpip::Storage content;
2736  content.writeInt(0);
2737  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_REROUTE_TRAVELTIME, vehicleID, &content);
2738  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2739 }
2740 
2741 void
2742 TraCIAPI::VehicleScope::moveTo(const std::string& vehicleID, const std::string& laneID, double position, int reason) const {
2743  tcpip::Storage content;
2745  content.writeInt(3);
2747  content.writeString(laneID);
2749  content.writeDouble(position);
2751  content.writeInt(reason);
2752  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MOVE_TO, vehicleID, &content);
2753  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2754 }
2755 
2756 void
2757 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 {
2758  tcpip::Storage content;
2760  content.writeInt(6);
2762  content.writeString(edgeID);
2764  content.writeInt(lane);
2766  content.writeDouble(x);
2768  content.writeDouble(y);
2770  content.writeDouble(angle);
2772  content.writeByte(keepRoute);
2773  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::MOVE_TO_XY, vehicleID, &content);
2774  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2775 }
2776 
2777 
2778 void
2779 TraCIAPI::VehicleScope::slowDown(const std::string& vehicleID, double speed, double duration) const {
2780  tcpip::Storage content;
2782  content.writeInt(2);
2784  content.writeDouble(speed);
2786  content.writeDouble(duration);
2787  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_SLOWDOWN, vehicleID, &content);
2788  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2789 }
2790 
2791 void
2792 TraCIAPI::VehicleScope::openGap(const std::string& vehicleID, double newTau, double duration, double changeRate, double maxDecel) const {
2793  tcpip::Storage content;
2795  if (maxDecel > 0) {
2796  content.writeInt(4);
2797  } else {
2798  content.writeInt(3);
2799  }
2801  content.writeDouble(newTau);
2803  content.writeDouble(duration);
2805  content.writeDouble(changeRate);
2806  if (maxDecel > 0) {
2808  content.writeDouble(maxDecel);
2809  }
2810  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_OPENGAP, vehicleID, &content);
2811  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2812 }
2813 
2814 void
2815 TraCIAPI::VehicleScope::setSpeed(const std::string& vehicleID, double speed) const {
2816  tcpip::Storage content;
2818  content.writeDouble(speed);
2819  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEED, vehicleID, &content);
2820  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2821 }
2822 
2823 void
2824 TraCIAPI::VehicleScope::setPreviousSpeed(const std::string& vehicleID, double prevspeed) const {
2825  tcpip::Storage content;
2827  content.writeDouble(prevspeed);
2828  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_PREV_SPEED, vehicleID, &content);
2829  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2830 }
2831 
2832 void
2833 TraCIAPI::VehicleScope::setLaneChangeMode(const std::string& vehicleID, int mode) const {
2834  tcpip::Storage content;
2836  content.writeInt(mode);
2837  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_LANECHANGE_MODE, vehicleID, &content);
2838  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2839 }
2840 
2841 void
2842 TraCIAPI::VehicleScope::setSpeedMode(const std::string& vehicleID, int mode) const {
2843  tcpip::Storage content;
2845  content.writeInt(mode);
2846  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEEDSETMODE, vehicleID, &content);
2847  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2848 }
2849 
2850 void
2851 TraCIAPI::VehicleScope::setStop(const std::string vehicleID, const std::string edgeID, const double endPos, const int laneIndex,
2852  const double duration, const int flags, const double startPos, const double until) const {
2853  tcpip::Storage content;
2855  content.writeInt(7);
2857  content.writeString(edgeID);
2859  content.writeDouble(endPos);
2861  content.writeByte(laneIndex);
2863  content.writeDouble(duration);
2865  content.writeByte(flags);
2867  content.writeDouble(startPos);
2869  content.writeDouble(until);
2870  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_STOP, vehicleID, &content);
2871  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2872 }
2873 
2874 void
2875 TraCIAPI::VehicleScope::setType(const std::string& vehicleID, const std::string& typeID) const {
2876  tcpip::Storage content;
2878  content.writeString(typeID);
2879  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_TYPE, vehicleID, &content);
2880  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2881 }
2882 
2883 void
2884 TraCIAPI::VehicleScope::setSpeedFactor(const std::string& vehicleID, double factor) const {
2885  tcpip::Storage content;
2887  content.writeDouble(factor);
2888  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEED_FACTOR, vehicleID, &content);
2889  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2890 }
2891 
2892 void
2893 TraCIAPI::VehicleScope::setMinGap(const std::string& vehicleID, double minGap) const {
2894  tcpip::Storage content;
2896  content.writeDouble(minGap);
2897  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MINGAP, vehicleID, &content);
2898  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2899 }
2900 
2901 void
2902 TraCIAPI::VehicleScope::setMaxSpeed(const std::string& vehicleID, double speed) const {
2903  tcpip::Storage content;
2905  content.writeDouble(speed);
2906  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MAXSPEED, vehicleID, &content);
2907  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2908 }
2909 
2910 void
2911 TraCIAPI::VehicleScope::setColor(const std::string& vehicleID, const libsumo::TraCIColor& c) const {
2912  tcpip::Storage content;
2914  content.writeUnsignedByte(c.r);
2915  content.writeUnsignedByte(c.g);
2916  content.writeUnsignedByte(c.b);
2917  content.writeUnsignedByte(c.a);
2918  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_COLOR, vehicleID, &content);
2919  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2920 }
2921 
2922 void
2923 TraCIAPI::VehicleScope::setLine(const std::string& vehicleID, const std::string& line) const {
2924  tcpip::Storage content;
2926  content.writeString(line);
2927  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_LINE, vehicleID, &content);
2928  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2929 }
2930 
2931 void
2932 TraCIAPI::VehicleScope::setVia(const std::string& vehicleID, const std::vector<std::string>& via) const {
2933  tcpip::Storage content;
2935  content.writeInt((int)via.size());
2936  for (int i = 0; i < (int)via.size(); ++i) {
2937  content.writeString(via[i]);
2938  }
2939  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_VIA, vehicleID, &content);
2940  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2941 }
2942 
2943 void
2944 TraCIAPI::VehicleScope::setSignals(const std::string& vehicleID, int signals) const {
2945  tcpip::Storage content;
2947  content.writeInt(signals);
2948  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SIGNALS, vehicleID, &content);
2949  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2950 }
2951 
2952 void
2953 TraCIAPI::VehicleScope::setRoutingMode(const std::string& vehicleID, int routingMode) const {
2954  tcpip::Storage content;
2956  content.writeInt(routingMode);
2957  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTING_MODE, vehicleID, &content);
2958  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2959 }
2960 
2961 void
2962 TraCIAPI::VehicleScope::setShapeClass(const std::string& vehicleID, const std::string& clazz) const {
2963  tcpip::Storage content;
2965  content.writeString(clazz);
2966  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SHAPECLASS, vehicleID, &content);
2967  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2968 }
2969 
2970 
2971 void
2972 TraCIAPI::VehicleScope::setEmissionClass(const std::string& vehicleID, const std::string& clazz) const {
2973  tcpip::Storage content;
2975  content.writeString(clazz);
2976  myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_EMISSIONCLASS, vehicleID, &content);
2977  myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2978 }
2979 
2980 void
2982  bool noOpposite, double downstreamDist, double upstreamDist) const {
2983  addSubscriptionFilterByteList(libsumo::FILTER_TYPE_LANES, lanes);
2984  if (noOpposite) {
2985  addSubscriptionFilterNoOpposite();
2986  }
2987  if (downstreamDist >= 0) {
2988  addSubscriptionFilterDownstreamDistance(downstreamDist);
2989  }
2990  if (upstreamDist >= 0) {
2991  addSubscriptionFilterUpstreamDistance(upstreamDist);
2992  }
2993 }
2994 
2995 
2996 void
2998  addSubscriptionFilterEmpty(libsumo::FILTER_TYPE_NOOPPOSITE);
2999 }
3000 
3001 void
3003  addSubscriptionFilterFloat(libsumo::FILTER_TYPE_DOWNSTREAM_DIST, dist);
3004 }
3005 
3006 void
3008  addSubscriptionFilterFloat(libsumo::FILTER_TYPE_UPSTREAM_DIST, dist);
3009 }
3010 
3011 
3012 void
3013 TraCIAPI::VehicleScope::addSubscriptionFilterCFManeuver(double downstreamDist, double upstreamDist) const {
3014  addSubscriptionFilterLeadFollow(std::vector<int>({0}));
3015  if (downstreamDist >= 0) {
3016  addSubscriptionFilterDownstreamDistance(downstreamDist);
3017  }
3018  if (upstreamDist >= 0) {
3019  addSubscriptionFilterUpstreamDistance(upstreamDist);
3020  }
3021 }
3022 
3023 void
3024 TraCIAPI::VehicleScope::addSubscriptionFilterLCManeuver(int direction, bool noOpposite, double downstreamDist, double upstreamDist) const {
3025  if (abs(direction) != 1) {
3026  std::cerr << "Ignoring lane change subscription filter with non-neighboring lane offset direction " << direction << "\n";
3027  return;
3028  }
3029  addSubscriptionFilterLeadFollow(std::vector<int>({0, direction}));
3030  if (noOpposite) {
3031  addSubscriptionFilterNoOpposite();
3032  }
3033  if (downstreamDist >= 0) {
3034  addSubscriptionFilterDownstreamDistance(downstreamDist);
3035  }
3036  if (upstreamDist >= 0) {
3037  addSubscriptionFilterUpstreamDistance(upstreamDist);
3038  }
3039 }
3040 
3041 void
3042 TraCIAPI::VehicleScope::addSubscriptionFilterLeadFollow(const std::vector<int>& lanes) const {
3043  addSubscriptionFilterEmpty(libsumo::FILTER_TYPE_LEAD_FOLLOW);
3044  addSubscriptionFilterByteList(libsumo::FILTER_TYPE_LANES, lanes);
3045 }
3046 
3047 void
3048 TraCIAPI::VehicleScope::addSubscriptionFilterTurn(double downstreamDist, double upstreamDist) const {
3049  addSubscriptionFilterEmpty(libsumo::FILTER_TYPE_TURN);
3050  if (downstreamDist >= 0) {
3051  addSubscriptionFilterDownstreamDistance(downstreamDist);
3052  }
3053  if (upstreamDist >= 0) {
3054  addSubscriptionFilterUpstreamDistance(upstreamDist);
3055  }
3056 }
3057 
3058 
3059 void
3060 TraCIAPI::VehicleScope::addSubscriptionFilterVClass(const std::vector<std::string>& vClasses) const {
3061  addSubscriptionFilterStringList(libsumo::FILTER_TYPE_VCLASS, vClasses);
3062 }
3063 
3064 
3065 void
3066 TraCIAPI::VehicleScope::addSubscriptionFilterVType(const std::vector<std::string>& vTypes) const {
3067  addSubscriptionFilterStringList(libsumo::FILTER_TYPE_VTYPE, vTypes);
3068 }
3069 
3070 
3071 void
3073  addSubscriptionFilterFloat(libsumo::FILTER_TYPE_FIELD_OF_VISION, angle);
3074 }
3075 
3076 void
3077 TraCIAPI::VehicleScope::addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist, double upstreamDist) const {
3078  addSubscriptionFilterFloat(libsumo::FILTER_TYPE_LATERAL_DIST, lateralDist);
3079  if (downstreamDist >= 0) {
3080  addSubscriptionFilterDownstreamDistance(downstreamDist);
3081  }
3082  if (upstreamDist >= 0) {
3083  addSubscriptionFilterUpstreamDistance(upstreamDist);
3084  }
3085 }
3086 
3087 void
3089  myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType);
3090  myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
3091 }
3092 
3093 void
3094 TraCIAPI::VehicleScope::addSubscriptionFilterFloat(int filterType, double val) const {
3095  tcpip::Storage content;
3097  content.writeDouble(val);
3098  myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
3099  myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
3100 }
3101 
3102 
3103 void
3104 TraCIAPI::VehicleScope::addSubscriptionFilterStringList(int filterType, const std::vector<std::string>& vals) const {
3105  tcpip::Storage content;
3107  content.writeStringList(vals);
3108  myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
3109  myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
3110 }
3111 
3112 
3113 void
3114 TraCIAPI::VehicleScope::addSubscriptionFilterByteList(int filterType, const std::vector<int>& vals) const {
3115  tcpip::Storage content;
3116  content.writeUnsignedByte((int)vals.size());
3117  for (int i : vals) {
3118  content.writeByte(i);
3119  }
3120  myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
3121  myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
3122 }
3123 
3124 
3125 // ---------------------------------------------------------------------------
3126 // TraCIAPI::PersonScope-methods
3127 // ---------------------------------------------------------------------------
3128 double
3129 TraCIAPI::PersonScope::getSpeed(const std::string& personID) const {
3130  return getDouble(libsumo::VAR_SPEED, personID);
3131 }
3132 
3134 TraCIAPI::PersonScope::getPosition(const std::string& personID) const {
3135  return getPos(libsumo::VAR_POSITION, personID);
3136 }
3137 
3139 TraCIAPI::PersonScope::getPosition3D(const std::string& personID) const {
3140  return getPos3D(libsumo::VAR_POSITION3D, personID);
3141 }
3142 
3143 double
3144 TraCIAPI::PersonScope::getAngle(const std::string& personID) const {
3145  return getDouble(libsumo::VAR_ANGLE, personID);
3146 }
3147 
3148 double
3149 TraCIAPI::PersonScope::getSlope(const std::string& personID) const {
3150  return getDouble(libsumo::VAR_SLOPE, personID);
3151 }
3152 
3153 double
3154 TraCIAPI::PersonScope::getLanePosition(const std::string& personID) const {
3155  return getDouble(libsumo::VAR_LANEPOSITION, personID);
3156 }
3157 
3159 TraCIAPI::PersonScope::getColor(const std::string& personID) const {
3160  return getCol(libsumo::VAR_COLOR, personID);
3161 }
3162 
3163 double
3164 TraCIAPI::PersonScope::getLength(const std::string& personID) const {
3165  return getDouble(libsumo::VAR_LENGTH, personID);
3166 }
3167 
3168 std::string
3169 TraCIAPI::PersonScope::getRoadID(const std::string& personID) const {
3170  return getString(libsumo::VAR_ROAD_ID, personID);
3171 }
3172 
3173 std::string
3174 TraCIAPI::PersonScope::getLaneID(const std::string& personID) const {
3175  return getString(libsumo::VAR_LANE_ID, personID);
3176 }
3177 
3178 std::string
3179 TraCIAPI::PersonScope::getTypeID(const std::string& personID) const {
3180  return getString(libsumo::VAR_TYPE, personID);
3181 }
3182 
3183 double
3184 TraCIAPI::PersonScope::getWaitingTime(const std::string& personID) const {
3185  return getDouble(libsumo::VAR_WAITING_TIME, personID);
3186 }
3187 
3188 std::string
3189 TraCIAPI::PersonScope::getNextEdge(const std::string& personID) const {
3190  return getString(libsumo::VAR_NEXT_EDGE, personID);
3191 }
3192 
3193 
3194 std::string
3195 TraCIAPI::PersonScope::getVehicle(const std::string& personID) const {
3196  return getString(libsumo::VAR_VEHICLE, personID);
3197 }
3198 
3199 int
3200 TraCIAPI::PersonScope::getRemainingStages(const std::string& personID) const {
3201  return getInt(libsumo::VAR_STAGES_REMAINING, personID);
3202 }
3203 
3205 TraCIAPI::PersonScope::getStage(const std::string& personID, int nextStageIndex) const {
3206  tcpip::Storage content;
3208  content.writeInt(nextStageIndex);
3209  return getTraCIStage(libsumo::VAR_STAGE, personID, &content);
3210 }
3211 
3212 std::vector<std::string>
3213 TraCIAPI::PersonScope::getEdges(const std::string& personID, int nextStageIndex) const {
3214  tcpip::Storage content;
3216  content.writeInt(nextStageIndex);
3217  return getStringVector(libsumo::VAR_EDGES, personID, &content);
3218 }
3219 
3220 void
3221 TraCIAPI::PersonScope::removeStages(const std::string& personID) const {
3222  // remove all stages after the current and then abort the current stage
3223  while (getRemainingStages(personID) > 1) {
3224  removeStage(personID, 1);
3225  }
3226  removeStage(personID, 0);
3227 }
3228 
3229 
3230 void
3231 TraCIAPI::PersonScope::rerouteTraveltime(const std::string& personID) const {
3232  tcpip::Storage content;
3234  content.writeInt(0);
3235  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::CMD_REROUTE_TRAVELTIME, personID, &content);
3236  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3237 }
3238 
3239 
3240 void
3241 TraCIAPI::PersonScope::add(const std::string& personID, const std::string& edgeID, double pos, double depart, const std::string typeID) {
3242  tcpip::Storage content;
3244  content.writeInt(4);
3246  content.writeString(typeID);
3248  content.writeString(edgeID);
3250  content.writeDouble(depart);
3252  content.writeDouble(pos);
3253  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::ADD, personID, &content);
3254  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3255 }
3256 
3257 void
3258 TraCIAPI::PersonScope::appendStage(const std::string& personID, const libsumo::TraCIStage& stage) {
3259  tcpip::Storage content;
3261  content.writeInt(13);
3263  content.writeInt(stage.type);
3265  content.writeString(stage.vType);
3267  content.writeString(stage.line);
3269  content.writeString(stage.destStop);
3271  content.writeStringList(stage.edges);
3273  content.writeDouble(stage.travelTime);
3275  content.writeDouble(stage.cost);
3277  content.writeDouble(stage.length);
3279  content.writeString(stage.intended);
3281  content.writeDouble(stage.depart);
3283  content.writeDouble(stage.departPos);
3285  content.writeDouble(stage.arrivalPos);
3287  content.writeString(stage.description);
3288  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
3289  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3290 }
3291 
3292 
3293 void
3294 TraCIAPI::PersonScope::appendWaitingStage(const std::string& personID, double duration, const std::string& description, const std::string& stopID) {
3295  tcpip::Storage content;
3297  content.writeInt(4);
3301  content.writeDouble(duration);
3303  content.writeString(description);
3305  content.writeString(stopID);
3306  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
3307  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3308 }
3309 
3310 void
3311 TraCIAPI::PersonScope::appendWalkingStage(const std::string& personID, const std::vector<std::string>& edges, double arrivalPos, double duration, double speed, const std::string& stopID) {
3312  tcpip::Storage content;
3314  content.writeInt(6);
3318  content.writeStringList(edges);
3320  content.writeDouble(arrivalPos);
3322  content.writeDouble(duration);
3324  content.writeDouble(speed);
3326  content.writeString(stopID);
3327  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
3328  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3329 }
3330 
3331 void
3332 TraCIAPI::PersonScope::appendDrivingStage(const std::string& personID, const std::string& toEdge, const std::string& lines, const std::string& stopID) {
3333  tcpip::Storage content;
3335  content.writeInt(4);
3339  content.writeString(toEdge);
3341  content.writeString(lines);
3343  content.writeString(stopID);
3344  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
3345  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3346 }
3347 
3348 void
3349 TraCIAPI::PersonScope::removeStage(const std::string& personID, int nextStageIndex) const {
3350  tcpip::Storage content;
3352  content.writeInt(nextStageIndex);
3353  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::REMOVE_STAGE, personID, &content);
3354  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3355 }
3356 
3357 
3358 void
3359 TraCIAPI::PersonScope::setSpeed(const std::string& personID, double speed) const {
3360  tcpip::Storage content;
3362  content.writeDouble(speed);
3363  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_SPEED, personID, &content);
3364  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3365 }
3366 
3367 
3368 void
3369 TraCIAPI::PersonScope::setType(const std::string& personID, const std::string& typeID) const {
3370  tcpip::Storage content;
3372  content.writeString(typeID);
3373  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_TYPE, personID, &content);
3374  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3375 }
3376 
3377 void
3378 TraCIAPI::PersonScope::setLength(const std::string& personID, double length) const {
3379  tcpip::Storage content;
3381  content.writeDouble(length);
3382  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_LENGTH, personID, &content);
3383  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3384 }
3385 
3386 
3387 void
3388 TraCIAPI::PersonScope::setWidth(const std::string& personID, double width) const {
3389  tcpip::Storage content;
3391  content.writeDouble(width);
3392  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_WIDTH, personID, &content);
3393  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3394 }
3395 
3396 void
3397 TraCIAPI::PersonScope::setHeight(const std::string& personID, double height) const {
3398  tcpip::Storage content;
3400  content.writeDouble(height);
3401  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_HEIGHT, personID, &content);
3402  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3403 }
3404 
3405 void
3406 TraCIAPI::PersonScope::setMinGap(const std::string& personID, double minGap) const {
3407  tcpip::Storage content;
3409  content.writeDouble(minGap);
3410  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_MINGAP, personID, &content);
3411  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3412 }
3413 
3414 
3415 void
3416 TraCIAPI::PersonScope::setColor(const std::string& personID, const libsumo::TraCIColor& c) const {
3417  tcpip::Storage content;
3419  content.writeUnsignedByte(c.r);
3420  content.writeUnsignedByte(c.g);
3421  content.writeUnsignedByte(c.b);
3422  content.writeUnsignedByte(c.a);
3423  myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_COLOR, personID, &content);
3424  myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3425 }
3426 
3427 
3428 // ---------------------------------------------------------------------------
3429 // TraCIAPI::TraCIScopeWrapper-methods
3430 // ---------------------------------------------------------------------------
3431 
3432 int
3433 TraCIAPI::TraCIScopeWrapper::getUnsignedByte(int var, const std::string& id, tcpip::Storage* add) const {
3434  myParent.createCommand(myCmdGetID, var, id, add);
3435  if (myParent.processGet(myCmdGetID, libsumo::TYPE_UBYTE)) {
3436  return myParent.myInput.readUnsignedByte();
3437  }
3439 }
3440 
3441 
3442 int
3443 TraCIAPI::TraCIScopeWrapper::getByte(int var, const std::string& id, tcpip::Storage* add) const {
3444  myParent.createCommand(myCmdGetID, var, id, add);
3445  if (myParent.processGet(myCmdGetID, libsumo::TYPE_BYTE)) {
3446  return myParent.myInput.readByte();
3447  }
3449 }
3450 
3451 
3452 
3453 int
3454 TraCIAPI::TraCIScopeWrapper::getInt(int var, const std::string& id, tcpip::Storage* add) const {
3455  myParent.createCommand(myCmdGetID, var, id, add);
3456  if (myParent.processGet(myCmdGetID, libsumo::TYPE_INTEGER)) {
3457  return myParent.myInput.readInt();
3458  }
3460 }
3461 
3462 
3463 double
3464 TraCIAPI::TraCIScopeWrapper::getDouble(int var, const std::string& id, tcpip::Storage* add) const {
3465  myParent.createCommand(myCmdGetID, var, id, add);
3466  if (myParent.processGet(myCmdGetID, libsumo::TYPE_DOUBLE)) {
3467  return myParent.myInput.readDouble();
3468  }
3470 }
3471 
3472 
3474 TraCIAPI::TraCIScopeWrapper::getPolygon(int var, const std::string& id, tcpip::Storage* add) const {
3476  myParent.createCommand(myCmdGetID, var, id, add);
3477  if (myParent.processGet(myCmdGetID, libsumo::TYPE_POLYGON)) {
3478  int size = myParent.myInput.readUnsignedByte();
3479  if (size == 0) {
3480  size = myParent.myInput.readInt();
3481  }
3482  for (int i = 0; i < size; ++i) {
3484  p.x = myParent.myInput.readDouble();
3485  p.y = myParent.myInput.readDouble();
3486  p.z = 0.;
3487  ret.push_back(p);
3488  }
3489  }
3490  return ret;
3491 }
3492 
3493 
3495 TraCIAPI::TraCIScopeWrapper::getPos(int var, const std::string& id, tcpip::Storage* add) const {
3497  myParent.createCommand(myCmdGetID, var, id, add);
3498  if (myParent.processGet(myCmdGetID, libsumo::POSITION_2D)) {
3499  p.x = myParent.myInput.readDouble();
3500  p.y = myParent.myInput.readDouble();
3501  p.z = 0;
3502  }
3503  return p;
3504 }
3505 
3506 
3508 TraCIAPI::TraCIScopeWrapper::getPos3D(int var, const std::string& id, tcpip::Storage* add) const {
3510  myParent.createCommand(myCmdGetID, var, id, add);
3511  if (myParent.processGet(myCmdGetID, libsumo::POSITION_3D)) {
3512  p.x = myParent.myInput.readDouble();
3513  p.y = myParent.myInput.readDouble();
3514  p.z = myParent.myInput.readDouble();
3515  }
3516  return p;
3517 }
3518 
3519 
3520 std::string
3521 TraCIAPI::TraCIScopeWrapper::getString(int var, const std::string& id, tcpip::Storage* add) const {
3522  myParent.createCommand(myCmdGetID, var, id, add);
3523  if (myParent.processGet(myCmdGetID, libsumo::TYPE_STRING)) {
3524  return myParent.myInput.readString();
3525  }
3526  return "";
3527 }
3528 
3529 
3530 std::vector<std::string>
3531 TraCIAPI::TraCIScopeWrapper::getStringVector(int var, const std::string& id, tcpip::Storage* add) const {
3532  std::vector<std::string> r;
3533  myParent.createCommand(myCmdGetID, var, id, add);
3534  if (myParent.processGet(myCmdGetID, libsumo::TYPE_STRINGLIST)) {
3535  const int size = myParent.myInput.readInt();
3536  for (int i = 0; i < size; ++i) {
3537  r.push_back(myParent.myInput.readString());
3538  }
3539  }
3540  return r;
3541 }
3542 
3543 
3545 TraCIAPI::TraCIScopeWrapper::getCol(int var, const std::string& id, tcpip::Storage* add) const {
3547  myParent.createCommand(myCmdGetID, var, id, add);
3548  if (myParent.processGet(myCmdGetID, libsumo::TYPE_COLOR)) {
3549  c.r = (unsigned char)myParent.myInput.readUnsignedByte();
3550  c.g = (unsigned char)myParent.myInput.readUnsignedByte();
3551  c.b = (unsigned char)myParent.myInput.readUnsignedByte();
3552  c.a = (unsigned char)myParent.myInput.readUnsignedByte();
3553  }
3554  return c;
3555 }
3556 
3557 
3559 TraCIAPI::TraCIScopeWrapper::getTraCIStage(int var, const std::string& id, tcpip::Storage* add) const {
3561  myParent.createCommand(myCmdGetID, var, id, add);
3562  if (myParent.processGet(myCmdGetID, libsumo::TYPE_COMPOUND)) {
3563  myParent.myInput.readInt(); // components
3564  myParent.myInput.readUnsignedByte();
3565  s.type = myParent.myInput.readInt();
3566 
3567  myParent.myInput.readUnsignedByte();
3568  s.vType = myParent.myInput.readString();
3569 
3570  myParent.myInput.readUnsignedByte();
3571  s.line = myParent.myInput.readString();
3572 
3573  myParent.myInput.readUnsignedByte();
3574  s.destStop = myParent.myInput.readString();
3575 
3576  myParent.myInput.readUnsignedByte();
3577  s.edges = myParent.myInput.readStringList();
3578 
3579  myParent.myInput.readUnsignedByte();
3580  s.travelTime = myParent.myInput.readDouble();
3581 
3582  myParent.myInput.readUnsignedByte();
3583  s.cost = myParent.myInput.readDouble();
3584 
3585  myParent.myInput.readUnsignedByte();
3586  s.length = myParent.myInput.readDouble();
3587 
3588  myParent.myInput.readUnsignedByte();
3589  s.intended = myParent.myInput.readString();
3590 
3591  myParent.myInput.readUnsignedByte();
3592  s.depart = myParent.myInput.readDouble();
3593 
3594  myParent.myInput.readUnsignedByte();
3595  s.departPos = myParent.myInput.readDouble();
3596 
3597  myParent.myInput.readUnsignedByte();
3598  s.arrivalPos = myParent.myInput.readDouble();
3599 
3600  myParent.myInput.readUnsignedByte();
3601  s.description = myParent.myInput.readString();
3602  }
3603  return s;
3604 }
3605 
3606 
3607 std::vector<std::string>
3609  return getStringVector(libsumo::TRACI_ID_LIST, "");
3610 }
3611 
3612 
3613 int
3615  return getInt(libsumo::ID_COUNT, "");
3616 }
3617 
3618 
3619 std::string
3620 TraCIAPI::TraCIScopeWrapper::getParameter(const std::string& objectID, const std::string& key) const {
3621  tcpip::Storage content;
3623  content.writeString(key);
3624  return getString(libsumo::VAR_PARAMETER, objectID, &content);
3625 }
3626 
3627 
3628 std::pair<std::string, std::string>
3629 TraCIAPI::TraCIScopeWrapper::getParameterWithKey(const std::string& objectID, const std::string& key) const {
3630  tcpip::Storage content;
3632  content.writeString(key);
3633 
3634  myParent.createCommand(myCmdGetID, libsumo::VAR_PARAMETER_WITH_KEY, objectID, &content);
3635  if (myParent.processGet(myCmdGetID, libsumo::TYPE_COMPOUND)) {
3636  myParent.myInput.readInt(); // number of components
3637  myParent.myInput.readUnsignedByte();
3638  const std::string returnedKey = myParent.myInput.readString();
3639  myParent.myInput.readUnsignedByte();
3640  const std::string value = myParent.myInput.readString();
3641  return std::make_pair(returnedKey, value);
3642  }
3643  return std::make_pair(key, "");
3644 }
3645 
3646 
3647 void
3648 TraCIAPI::TraCIScopeWrapper::setParameter(const std::string& objectID, const std::string& key, const std::string& value) const {
3649  tcpip::Storage content;
3651  content.writeInt(2);
3653  content.writeString(key);
3655  content.writeString(value);
3656  myParent.createCommand(myCmdSetID, libsumo::VAR_PARAMETER, objectID, &content);
3657  myParent.processSet(myCmdSetID);
3658 }
3659 
3660 
3661 void
3662 TraCIAPI::TraCIScopeWrapper::setInt(int var, const std::string& id, int value) const {
3663  tcpip::Storage content;
3665  content.writeInt(value);
3666  myParent.createCommand(myCmdSetID, var, id, &content);
3667  myParent.processSet(myCmdSetID);
3668 }
3669 
3670 
3671 void
3672 TraCIAPI::TraCIScopeWrapper::setDouble(int var, const std::string& id, double value) const {
3673  tcpip::Storage content;
3675  content.writeDouble(value);
3676  myParent.createCommand(myCmdSetID, var, id, &content);
3677  myParent.processSet(myCmdSetID);
3678 }
3679 
3680 
3681 void
3682 TraCIAPI::TraCIScopeWrapper::setString(int var, const std::string& id, const std::string& value) const {
3683  tcpip::Storage content;
3685  content.writeString(value);
3686  myParent.createCommand(myCmdSetID, var, id, &content);
3687  myParent.processSet(myCmdSetID);
3688 }
3689 
3690 
3691 void
3692 TraCIAPI::TraCIScopeWrapper::setStringVector(int var, const std::string& id, const std::vector<std::string>& value) const {
3693  tcpip::Storage content;
3695  content.writeInt((int)value.size());
3696  for (const std::string& s : value) {
3697  content.writeString(s);
3698  }
3699  myParent.createCommand(myCmdSetID, var, id, &content);
3700  myParent.processSet(myCmdSetID);
3701 }
3702 
3703 
3704 void
3705 TraCIAPI::TraCIScopeWrapper::subscribe(const std::string& objID, const std::vector<int>& vars, double beginTime, double endTime) const {
3706  myParent.send_commandSubscribeObjectVariable(mySubscribeID, objID, beginTime, endTime, vars);
3707  tcpip::Storage inMsg;
3708  myParent.check_resultState(inMsg, mySubscribeID);
3709  if (vars.size() > 0) {
3710  myParent.check_commandGetResult(inMsg, mySubscribeID);
3711  myParent.readVariableSubscription(mySubscribeID + 0x10, inMsg);
3712  }
3713 }
3714 
3715 
3716 void
3717 TraCIAPI::TraCIScopeWrapper::subscribeContext(const std::string& objID, int domain, double range, const std::vector<int>& vars, double beginTime, double endTime) const {
3718  myParent.send_commandSubscribeObjectContext(myContextSubscribeID, objID, beginTime, endTime, domain, range, vars);
3719  tcpip::Storage inMsg;
3720  myParent.check_resultState(inMsg, myContextSubscribeID);
3721  myParent.check_commandGetResult(inMsg, myContextSubscribeID);
3722  myParent.readContextSubscription(myContextSubscribeID + 0x60, inMsg);
3723 }
3724 
3725 
3728  return mySubscriptionResults;
3729 }
3730 
3731 
3734  if (mySubscriptionResults.find(objID) != mySubscriptionResults.end()) {
3735  return mySubscriptionResults.find(objID)->second;
3736  } else {
3737  return libsumo::TraCIResults();
3738  }
3739 }
3740 
3741 
3744  return myContextSubscriptionResults;
3745 }
3746 
3747 
3750  if (myContextSubscriptionResults.find(objID) != myContextSubscriptionResults.end()) {
3751  return myContextSubscriptionResults.find(objID)->second;
3752  } else {
3754  }
3755 }
3756 
3757 
3758 void
3760  mySubscriptionResults.clear();
3761  myContextSubscriptionResults.clear();
3762 }
3763 
3764 
3767  return mySubscriptionResults;
3768 }
3769 
3770 
3773  return myContextSubscriptionResults[objID];
3774 }
3775 
3776 
3777 /****************************************************************************/
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:3189
void setLength(const std::string &personID, double length) const
Definition: TraCIAPI.cpp:3378
libsumo::TraCIColor getColor(const std::string &personID) const
Definition: TraCIAPI.cpp:3159
double getSlope(const std::string &personID) const
Definition: TraCIAPI.cpp:3149
int getRemainingStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3200
double getWaitingTime(const std::string &personID) const
Definition: TraCIAPI.cpp:3184
libsumo::TraCIStage getStage(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3205
void removeStage(const std::string &personID, int nextStageIndex) const
Definition: TraCIAPI.cpp:3349
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:3241
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:3311
void setSpeed(const std::string &personID, double speed) const
Definition: TraCIAPI.cpp:3359
double getLength(const std::string &personID) const
Definition: TraCIAPI.cpp:3164
void setHeight(const std::string &personID, double height) const
Definition: TraCIAPI.cpp:3397
void setType(const std::string &personID, const std::string &typeID) const
Definition: TraCIAPI.cpp:3369
void setMinGap(const std::string &personID, double minGap) const
Definition: TraCIAPI.cpp:3406
libsumo::TraCIPosition getPosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3134
void removeStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3221
void setColor(const std::string &personID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:3416
std::string getRoadID(const std::string &personID) const
Definition: TraCIAPI.cpp:3169
double getSpeed(const std::string &personID) const
Definition: TraCIAPI.cpp:3129
std::string getVehicle(const std::string &personID) const
Definition: TraCIAPI.cpp:3195
void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
Definition: TraCIAPI.cpp:3332
std::string getTypeID(const std::string &personID) const
Definition: TraCIAPI.cpp:3179
void appendStage(const std::string &personID, const libsumo::TraCIStage &stage)
Definition: TraCIAPI.cpp:3258
double getAngle(const std::string &personID) const
Definition: TraCIAPI.cpp:3144
std::string getLaneID(const std::string &personID) const
Definition: TraCIAPI.cpp:3174
libsumo::TraCIPosition getPosition3D(const std::string &personID) const
Definition: TraCIAPI.cpp:3139
std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3213
void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: TraCIAPI.cpp:3294
double getLanePosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3154
void setWidth(const std::string &personID, double width) const
Definition: TraCIAPI.cpp:3388
void rerouteTraveltime(const std::string &personID) const
Definition: TraCIAPI.cpp:3231
libsumo::TraCIColor getColor(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1217
void setType(const std::string &polygonID, const std::string &setType) const
Definition: TraCIAPI.cpp:1231
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:1272
libsumo::TraCIPositionVector getShape(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1212
std::string getType(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1207
void remove(const std::string &polygonID, int layer=0) const
Definition: TraCIAPI.cpp:1299
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:1260
void setLineWidth(const std::string &polygonID, const double lineWidth) const
Definition: TraCIAPI.cpp:1222
void setShape(const std::string &polygonID, const libsumo::TraCIPositionVector &shape) const
Definition: TraCIAPI.cpp:1241
std::vector< std::string > getEdges(const std::string &routeID) const
Definition: TraCIAPI.cpp:1312
void add(const std::string &routeID, const std::vector< std::string > &edges) const
Definition: TraCIAPI.cpp:1318
int getDepartedNumber() const
Definition: TraCIAPI.cpp:1351
double getDistance2D(double x1, double y1, double x2, double y2, bool isGeo=false, bool isDriving=false)
Definition: TraCIAPI.cpp:1507
libsumo::TraCIPosition convert2D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1418
std::vector< std::string > getStartingTeleportIDList() const
Definition: TraCIAPI.cpp:1376
int getStartingTeleportNumber() const
Definition: TraCIAPI.cpp:1371
double getTime() const
Definition: TraCIAPI.cpp:1336
int getEndingTeleportNumber() const
Definition: TraCIAPI.cpp:1381
int getBusStopWaiting(const std::string &stopID) const
Definition: TraCIAPI.cpp:1407
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:1549
libsumo::TraCIRoadPosition convertRoad(double x, double y, bool isGeo=false, const std::string &vClass="ignoring") const
Definition: TraCIAPI.cpp:1463
std::vector< std::string > getBusStopWaitingIDList(const std::string &stopID) const
Definition: TraCIAPI.cpp:1412
double getDistanceRoad(const std::string &edgeID1, double pos1, const std::string &edgeID2, double pos2, bool isDriving=false)
Definition: TraCIAPI.cpp:1527
std::vector< std::string > getEndingTeleportIDList() const
Definition: TraCIAPI.cpp:1386
double getDeltaT() const
Definition: TraCIAPI.cpp:1391
int getMinExpectedNumber() const
Definition: TraCIAPI.cpp:1402
std::vector< std::string > getDepartedIDList() const
Definition: TraCIAPI.cpp:1356
std::vector< std::string > getLoadedIDList() const
Definition: TraCIAPI.cpp:1346
std::vector< std::string > getArrivedIDList() const
Definition: TraCIAPI.cpp:1366
int getArrivedNumber() const
Definition: TraCIAPI.cpp:1361
libsumo::TraCIPositionVector getNetBoundary() const
Definition: TraCIAPI.cpp:1396
void writeMessage(const std::string msg)
Definition: TraCIAPI.cpp:1568
libsumo::TraCIPosition convertGeo(double x, double y, bool fromGeo=false) const
Definition: TraCIAPI.cpp:1486
libsumo::TraCIPosition convert3D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1440
int getUnsignedByte(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3433
const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3749
int getInt(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3454
std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3531
double getDouble(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3464
libsumo::TraCIPosition getPos3D(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3508
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:3629
libsumo::TraCIColor getCol(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3545
const libsumo::SubscriptionResults getAllSubscriptionResults() const
Definition: TraCIAPI.cpp:3727
void setStringVector(int var, const std::string &id, const std::vector< std::string > &value) const
Definition: TraCIAPI.cpp:3692
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:3608
libsumo::TraCIPositionVector getPolygon(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3474
libsumo::SubscriptionResults & getModifiableSubscriptionResults()
Definition: TraCIAPI.cpp:3766
const libsumo::TraCIResults getSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3733
void setString(int var, const std::string &id, const std::string &value) const
Definition: TraCIAPI.cpp:3682
void subscribeContext(const std::string &objID, int domain, double range, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3717
void setParameter(const std::string &objectID, const std::string &key, const std::string &value) const
set generic paramter
Definition: TraCIAPI.cpp:3648
std::string getParameter(const std::string &objectID, const std::string &key) const
retrieve generic parameter
Definition: TraCIAPI.cpp:3620
void setInt(int var, const std::string &id, int value) const
Definition: TraCIAPI.cpp:3662
int getByte(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3443
libsumo::TraCIStage getTraCIStage(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3559
void subscribe(const std::string &objID, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3705
std::string getString(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3521
libsumo::TraCIPosition getPos(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3495
const libsumo::ContextSubscriptionResults getAllContextSubscriptionResults() const
Definition: TraCIAPI.cpp:3743
libsumo::SubscriptionResults & getModifiableContextSubscriptionResults(const std::string &objID)
Definition: TraCIAPI.cpp:3772
void setDouble(int var, const std::string &id, double value) const
Definition: TraCIAPI.cpp:3672
int getServedPersonCount(const std::string &tlsID, int index) const
Definition: TraCIAPI.cpp:1698
std::string getRedYellowGreenState(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1581
int getPhase(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1677
std::string getPhaseName(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1682
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
Definition: TraCIAPI.cpp:1707
std::string getProgram(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1672
void setPhase(const std::string &tlsID, int index) const
Definition: TraCIAPI.cpp:1716
void setPhaseName(const std::string &tlsID, const std::string &name) const
Definition: TraCIAPI.cpp:1725
double getNextSwitch(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1692
std::vector< std::vector< libsumo::TraCILink > > getControlledLinks(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1644
double getPhaseDuration(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1687
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1639
std::vector< libsumo::TraCILogic > getAllProgramLogics(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1586
void setPhaseDuration(const std::string &tlsID, double phaseDuration) const
Definition: TraCIAPI.cpp:1743
void setProgramLogic(const std::string &tlsID, const libsumo::TraCILogic &logic) const
Definition: TraCIAPI.cpp:1752
void setProgram(const std::string &tlsID, const std::string &programID) const
Definition: TraCIAPI.cpp:1734
std::vector< libsumo::TraCINextTLSData > getNextTLS(const std::string &vehID) const
Definition: TraCIAPI.cpp:2333
void changeLane(const std::string &vehicleID, int laneIndex, double duration) const
Definition: TraCIAPI.cpp:2662
void setMinGap(const std::string &vehicleID, double minGap) const
Definition: TraCIAPI.cpp:2893
double getLateralSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2111
void addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3077
void setMaxSpeed(const std::string &vehicleID, double speed) const
Definition: TraCIAPI.cpp:2902
double getSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2106
int getStopState(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2455
double getWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2290
void addSubscriptionFilterCFManeuver(double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3013
double getCOEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2255
void addSubscriptionFilterStringList(int filterType, const std::vector< std::string > &vals) const
Definition: TraCIAPI.cpp:3104
void changeTarget(const std::string &vehicleID, const std::string &edgeID) const
Definition: TraCIAPI.cpp:2652
libsumo::TraCIPosition getPosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2174
bool isRouteValid(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2561
void addSubscriptionFilterByteList(int filterType, const std::vector< int > &vals) const
Definition: TraCIAPI.cpp:3114
double getSecureGap(const std::string &vehicleID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string &leaderID="") const
Definition: TraCIAPI.cpp:2140
void setSpeedFactor(const std::string &vehicleID, double factor) const
Definition: TraCIAPI.cpp:2884
void setShapeClass(const std::string &vehicleID, const std::string &clazz) const
Definition: TraCIAPI.cpp:2962
void setVia(const std::string &vehicleID, const std::vector< std::string > &via) const
Definition: TraCIAPI.cpp:2932
void setEmissionClass(const std::string &vehicleID, const std::string &clazz) const
Definition: TraCIAPI.cpp:2972
double getTau(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2486
double getDistance(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2235
void remove(const std::string &vehicleID, char reason=libsumo::REMOVE_VAPORIZED) const
Definition: TraCIAPI.cpp:2641
void openGap(const std::string &vehicleID, double newTau, double duration, double changeRate, double maxDecel) const
Definition: TraCIAPI.cpp:2792
void moveTo(const std::string &vehicleID, const std::string &laneID, double position, int reason=libsumo::MOVE_TELEPORT) const
Definition: TraCIAPI.cpp:2742
void setSpeed(const std::string &vehicleID, double speed) const
Definition: TraCIAPI.cpp:2815
std::string getEmissionClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2323
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:2851
void setRouteID(const std::string &vehicleID, const std::string &routeID) const
Definition: TraCIAPI.cpp:2702
std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction) const
Definition: TraCIAPI.cpp:2437
double getNoiseEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2280
std::string getShapeClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2328
void addSubscriptionFilterLeadFollow(const std::vector< int > &lanes) const
Definition: TraCIAPI.cpp:3042
std::string getLine(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2313
double getElectricityConsumption(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2285
double getSpeedFactor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2496
double getNOxEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2270
void setRoute(const std::string &vehicleID, const std::vector< std::string > &edge) const
Definition: TraCIAPI.cpp:2712
int getSignals(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2240
libsumo::TraCIColor getColor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2225
int getPersonCapacity(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2546
void setSignals(const std::string &vehicleID, int signals) const
Definition: TraCIAPI.cpp:2944
std::string getRoadID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2189
void addSubscriptionFilterVType(const std::vector< std::string > &vTypes) const
Definition: TraCIAPI.cpp:3066
void addSubscriptionFilterUpstreamDistance(double dist) const
Definition: TraCIAPI.cpp:3007
void addSubscriptionFilterFloat(int filterType, double val) const
Definition: TraCIAPI.cpp:3094
double getAllowedSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2536
void addSubscriptionFilterLanes(const std::vector< int > &lanes, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:2981
double getCO2Emission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2250
double getFuelConsumption(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2275
double getHCEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2260
void addSubscriptionFilterNoOpposite() const
Definition: TraCIAPI.cpp:2997
void addSubscriptionFilterLCManeuver(int direction, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3024
std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2401
double getAcceleration(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2116
std::vector< std::string > getVia(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2318
void addSubscriptionFilterVClass(const std::vector< std::string > &vClasses) const
Definition: TraCIAPI.cpp:3060
double getImperfection(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2491
std::string getLaneID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2194
double getAngle(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2184
void addSubscriptionFilterDownstreamDistance(double dist) const
Definition: TraCIAPI.cpp:3002
double getMinGap(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2511
void addSubscriptionFilterEmpty(int filterType) const
Definition: TraCIAPI.cpp:3088
double getStopArrivalDelay(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2470
std::vector< std::string > getPersonIDList(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2551
double getStopDelay(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2465
double getMinGapLat(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2571
void setLine(const std::string &vehicleID, const std::string &line) const
Definition: TraCIAPI.cpp:2923
double getSlope(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2307
void setColor(const std::string &vehicleID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:2911
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:2581
libsumo::TraCIPosition getPosition3D(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2179
void setLaneChangeMode(const std::string &vehicleID, int mode) const
Definition: TraCIAPI.cpp:2833
void setRoutingMode(const std::string &vehicleID, int routingMode) const
Definition: TraCIAPI.cpp:2953
void addSubscriptionFilterTurn(double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3048
double getDecel(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2481
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:2757
double getHeight(const std::string &veihcleID) const
Definition: TraCIAPI.cpp:2526
int getRouteIndex(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2214
double getMaxSpeedLat(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2566
void changeSublane(const std::string &vehicleID, double latDist) const
Definition: TraCIAPI.cpp:2692
std::string getLateralAlignment(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2576
std::string getRouteID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2209
double getLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2230
int getLaneChangeMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2295
int getSpeedMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2301
std::vector< std::string > getRoute(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2220
double getLateralLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2245
std::pair< std::string, double > getFollower(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2419
double getPMxEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2265
double getLength(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2521
double getMaxSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2169
std::string getVehicleClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2506
double getSpeedWithoutTraCI(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2556
int getRoutingMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2460
double getWidth(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2516
double getSpeedDeviation(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2501
int getPersonNumber(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2541
double getFollowSpeed(const std::string &vehicleID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string &leaderID="") const
Definition: TraCIAPI.cpp:2121
void setType(const std::string &vehicleID, const std::string &typeID) const
Definition: TraCIAPI.cpp:2875
void addSubscriptionFilterFieldOfVision(double angle) const
Definition: TraCIAPI.cpp:3072
std::vector< libsumo::TraCIBestLanesData > getBestLanes(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2362
double getAccel(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2476
void setSpeedMode(const std::string &vehicleID, int mode) const
Definition: TraCIAPI.cpp:2842
void slowDown(const std::string &vehicleID, double speed, double duration) const
Definition: TraCIAPI.cpp:2779
std::string getTypeID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2204
void setPreviousSpeed(const std::string &vehicleID, double prevspeed) const
Definition: TraCIAPI.cpp:2824
double getAccumulatedWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2531
void changeLaneRelative(const std::string &vehicleID, int laneChange, double duration) const
Definition: TraCIAPI.cpp:2676
void rerouteTraveltime(const std::string &vehicleID, bool currentTravelTimes=true) const
Definition: TraCIAPI.cpp:2725
double getStopSpeed(const std::string &vehicleID, double speed, double gap) const
Definition: TraCIAPI.cpp:2156
int getLaneIndex(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2199
double getSpeedDeviation(const std::string &typeID) const
Definition: TraCIAPI.cpp:1816
double getSpeedFactor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1811
void setImperfection(const std::string &typeID, double imperfection) const
Definition: TraCIAPI.cpp:2072
void setApparentDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2063
void setHeight(const std::string &typeID, double height) const
Definition: TraCIAPI.cpp:1972
std::string getShapeClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1861
double getMinGapLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1871
void copy(const std::string &origTypeID, const std::string &newTypeID) const
Definition: TraCIAPI.cpp:2018
int getPersonCapacity(const std::string &typeID) const
Definition: TraCIAPI.cpp:1886
void setVehicleClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1926
void setColor(const std::string &typeID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:2090
void setDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2045
void setWidth(const std::string &typeID, double width) const
Definition: TraCIAPI.cpp:1963
double getApparentDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1836
double getDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1826
void setLateralAlignment(const std::string &typeID, const std::string &latAlignment) const
Definition: TraCIAPI.cpp:2009
void setMaxSpeed(const std::string &typeID, double speed) const
Definition: TraCIAPI.cpp:1917
double getMinGap(const std::string &typeID) const
Definition: TraCIAPI.cpp:1866
std::string getVehicleClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1851
void setShapeClass(const std::string &typeID, const std::string &shapeClass) const
Definition: TraCIAPI.cpp:2027
double getMaxSpeedLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1876
double getEmergencyDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1831
double getWidth(const std::string &typeID) const
Definition: TraCIAPI.cpp:1891
libsumo::TraCIColor getColor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1901
double getTau(const std::string &typeID) const
Definition: TraCIAPI.cpp:1846
double getMaxSpeed(const std::string &typeID) const
Definition: TraCIAPI.cpp:1806
double getLength(const std::string &typeID) const
Definition: TraCIAPI.cpp:1801
std::string getEmissionClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1856
double getImperfection(const std::string &typeID) const
Definition: TraCIAPI.cpp:1841
void setEmissionClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1954
void setAccel(const std::string &typeID, double accel) const
Definition: TraCIAPI.cpp:2036
void setMinGap(const std::string &typeID, double minGap) const
Definition: TraCIAPI.cpp:1981
double getAccel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1821
void setSpeedFactor(const std::string &typeID, double factor) const
Definition: TraCIAPI.cpp:1935
double getHeight(const std::string &typeID) const
Definition: TraCIAPI.cpp:1896
void setEmergencyDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2054
void setSpeedDeviation(const std::string &typeID, double deviation) const
Definition: TraCIAPI.cpp:1944
void setMaxSpeedLat(const std::string &typeID, double speed) const
Definition: TraCIAPI.cpp:2000
std::string getLateralAlignment(const std::string &typeID) const
Definition: TraCIAPI.cpp:1881
void setMinGapLat(const std::string &typeID, double minGapLat) const
Definition: TraCIAPI.cpp:1991
void setLength(const std::string &typeID, double length) const
Definition: TraCIAPI.cpp:1908
void setTau(const std::string &typeID, double tau) const
Definition: TraCIAPI.cpp:2081
RouteScope route
Scope for interaction with routes.
Definition: TraCIAPI.h:826
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:935
MeMeScope multientryexit
Scope for interaction with multi-entry/-exit detectors.
Definition: TraCIAPI.h:816
VehicleTypeScope vehicletype
Scope for interaction with vehicle types.
Definition: TraCIAPI.h:836
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:806
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:822
static std::string toString(const T &t, std::streamsize accuracy=PRECISION)
Definition: TraCIAPI.h:917
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:931
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:814
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:812
std::map< int, TraCIScopeWrapper * > myDomains
Definition: TraCIAPI.h:929
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:832
tcpip::Storage myOutput
The reusable output storage.
Definition: TraCIAPI.h:933
POIScope poi
Scope for interaction with POIs.
Definition: TraCIAPI.h:820
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:834
JunctionScope junction
Scope for interaction with junctions.
Definition: TraCIAPI.h:810
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:828
EdgeScope edge
Scope for interaction with edges.
Definition: TraCIAPI.h:804
bool processGet(int command, int expectedType, bool ignoreCommandId=false)
Definition: TraCIAPI.cpp:331
SimulationScope simulation
Scope for interaction with the simulation.
Definition: TraCIAPI.h:830
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:818
RerouterScope rerouter
Scope for interaction with rerouters.
Definition: TraCIAPI.h:824
std::map< std::string, std::string > subParameter
Definition: TraCIDefs.h:291
std::string programID
Definition: TraCIDefs.h:287
std::vector< TraCIPhase * > phases
Definition: TraCIDefs.h:290
std::vector< int > next
Definition: TraCIDefs.h:267
std::string state
Definition: TraCIDefs.h:265
std::string name
Definition: TraCIDefs.h:268
std::string intended
id of the intended vehicle for public transport ride
Definition: TraCIDefs.h:494
int type
The type of stage (walking, driving, ...)
Definition: TraCIDefs.h:478
std::string destStop
The id of the destination stop.
Definition: TraCIDefs.h:484
double length
length in m
Definition: TraCIDefs.h:492
double travelTime
duration of the stage in seconds
Definition: TraCIDefs.h:488
double departPos
position on the lane when starting the stage
Definition: TraCIDefs.h:498
std::string description
arbitrary description string
Definition: TraCIDefs.h:502
std::string line
The line or the id of the vehicle type.
Definition: TraCIDefs.h:482
double cost
effort needed
Definition: TraCIDefs.h:490
double depart
intended depart time for public transport ride or INVALID_DOUBLE_VALUE
Definition: TraCIDefs.h:496
std::vector< std::string > edges
The sequence of edges to travel.
Definition: TraCIDefs.h:486
double arrivalPos
position on the lane when ending the stage
Definition: TraCIDefs.h:500
std::string vType
The vehicle type when using a private car or bike.
Definition: TraCIDefs.h:480
bool receiveExact(Storage &)
Receive a complete TraCI message from Socket::socket_.
Definition: socket.cpp:527
void sendExact(const Storage &)
Definition: socket.cpp:430
void connect()
Connects to host_:port_.
Definition: socket.cpp:358
void close()
Definition: socket.cpp:382
virtual std::string readString()
Definition: storage.cpp:175
virtual void writeString(const std::string &s)
Definition: storage.cpp:192
virtual unsigned int position() const
Definition: storage.cpp:76
virtual void writeInt(int)
Definition: storage.cpp:316
virtual void writeDouble(double)
Definition: storage.cpp:349
virtual int readUnsignedByte()
Definition: storage.cpp:150
virtual void writeStringList(const std::vector< std::string > &s)
Definition: storage.cpp:242
void reset()
Definition: storage.cpp:85
virtual void writeUnsignedByte(int)
Definition: storage.cpp:160
StorageType::size_type size() const
Definition: storage.h:118
virtual void writeByte(int)
Definition: storage.cpp:135
virtual void writeStorage(tcpip::Storage &store)
Definition: storage.cpp:383
virtual double readDouble()
Definition: storage.cpp:357
virtual int readInt()
Definition: storage.cpp:306
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 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
std::map< int, std::shared_ptr< TraCIResult > > TraCIResults
{variable->value}
Definition: TraCIDefs.h:248
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
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
std::vector< TraCIPosition > TraCIPositionVector
Definition: TraCIDefs.h:196
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 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_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
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
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:250
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 INVALID_INT_VALUE
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 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
std::map< std::string, SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:251
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
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:456
double occupation
The traffic density along length.
Definition: TraCIDefs.h:458
bool allowsContinuation
Whether this lane allows continuing the route.
Definition: TraCIDefs.h:462
int bestLaneOffset
The offset of this lane from the best lane.
Definition: TraCIDefs.h:460
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
Definition: TraCIDefs.h:464
std::string laneID
The id of the lane.
Definition: TraCIDefs.h:454
double dist
The distance to the tls.
Definition: TraCIDefs.h:348
int tlIndex
The tls index of the controlled link.
Definition: TraCIDefs.h:346
std::string id
The id of the next tls.
Definition: TraCIDefs.h:344
char state
The current state of the tls.
Definition: TraCIDefs.h:350
A 3D-position.
Definition: TraCIDefs.h:141
An edgeId, position and laneIndex.
Definition: TraCIDefs.h:153
mirrors MSInductLoop::VehicleData
Definition: TraCIDefs.h:328
std::string id
The id of the vehicle.
Definition: TraCIDefs.h:330
double entryTime
Entry-time of the vehicle in [s].
Definition: TraCIDefs.h:334
std::string typeID
Type of the vehicle in.
Definition: TraCIDefs.h:338
double length
Length of the vehicle.
Definition: TraCIDefs.h:332
double leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIDefs.h:336