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