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