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