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