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