SUMO - Simulation of Urban MObility
TraCIAPI.cpp
Go to the documentation of this file.
1 /****************************************************************************/
10 // C++ TraCI client API implementation
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
13 // Copyright (C) 2012-2016 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #ifdef _MSC_VER
29 #include <windows_config.h>
30 #else
31 #include "../../config.h"
32 #endif
33 
34 #include "TraCIAPI.h"
35 
36 #ifdef CHECK_MEMORY_LEAKS
37 #include <foreign/nvwa/debug_new.h>
38 #endif // CHECK_MEMORY_LEAKS
39 
40 
41 // ===========================================================================
42 // member definitions
43 // ===========================================================================
44 // ---------------------------------------------------------------------------
45 // TraCIAPI-methods
46 // ---------------------------------------------------------------------------
47 #ifdef _MSC_VER
48 #pragma warning(disable: 4355)
49 #endif
51  : edge(*this), gui(*this), inductionloop(*this),
52  junction(*this), lane(*this), multientryexit(*this), poi(*this),
53  polygon(*this), route(*this), simulation(*this), trafficlights(*this),
54  vehicletype(*this), vehicle(*this), person(*this),
55  mySocket(0) {}
56 #ifdef _MSC_VER
57 #pragma warning(default: 4355)
58 #endif
59 
60 
62  delete mySocket;
63 }
64 
65 
66 void
67 TraCIAPI::connect(const std::string& host, int port) {
68  mySocket = new tcpip::Socket(host, port);
69  try {
70  mySocket->connect();
71  } catch (tcpip::SocketException&) {
72  delete mySocket;
73  mySocket = 0;
74  throw;
75  }
76 }
77 
78 
79 void
81  if (mySocket == 0) {
82  return;
83  }
84  mySocket->close();
85  delete mySocket;
86  mySocket = 0;
87 }
88 
89 
90 void
92  tcpip::Storage outMsg;
93  // command length
94  outMsg.writeUnsignedByte(1 + 1 + 4);
95  // command id
97  outMsg.writeInt((int)time);
98  // send request message
99  mySocket->sendExact(outMsg);
100 }
101 
102 
103 void
105  tcpip::Storage outMsg;
106  // command length
107  outMsg.writeUnsignedByte(1 + 1);
108  // command id
110  mySocket->sendExact(outMsg);
111 }
112 
113 
114 void
115 TraCIAPI::send_commandGetVariable(int domID, int varID, const std::string& objID, tcpip::Storage* add) const {
116  if (mySocket == 0) {
117  throw tcpip::SocketException("Socket is not initialised");
118  }
119  tcpip::Storage outMsg;
120  // command length
121  int length = 1 + 1 + 1 + 4 + (int) objID.length();
122  if (add != 0) {
123  length += (int)add->size();
124  }
125  outMsg.writeUnsignedByte(length);
126  // command id
127  outMsg.writeUnsignedByte(domID);
128  // variable id
129  outMsg.writeUnsignedByte(varID);
130  // object id
131  outMsg.writeString(objID);
132  // additional values
133  if (add != 0) {
134  outMsg.writeStorage(*add);
135  }
136  // send request message
137  mySocket->sendExact(outMsg);
138 }
139 
140 
141 void
142 TraCIAPI::send_commandSetValue(int domID, int varID, const std::string& objID, tcpip::Storage& content) const {
143  if (mySocket == 0) {
144  throw tcpip::SocketException("Socket is not initialised");
145  }
146  tcpip::Storage outMsg;
147  // command length (domID, varID, objID, dataType, data)
148  outMsg.writeUnsignedByte(1 + 1 + 1 + 4 + (int) objID.length() + (int)content.size());
149  // command id
150  outMsg.writeUnsignedByte(domID);
151  // variable id
152  outMsg.writeUnsignedByte(varID);
153  // object id
154  outMsg.writeString(objID);
155  // data type
156  outMsg.writeStorage(content);
157  // send message
158  mySocket->sendExact(outMsg);
159 }
160 
161 
162 void
163 TraCIAPI::send_commandSubscribeObjectVariable(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime,
164  const std::vector<int>& vars) const {
165  if (mySocket == 0) {
166  throw tcpip::SocketException("Socket is not initialised");
167  }
168  tcpip::Storage outMsg;
169  // command length (domID, objID, beginTime, endTime, length, vars)
170  int varNo = (int) vars.size();
171  outMsg.writeUnsignedByte(0);
172  outMsg.writeInt(5 + 1 + 4 + 4 + 4 + (int) objID.length() + 1 + varNo);
173  // command id
174  outMsg.writeUnsignedByte(domID);
175  // time
176  outMsg.writeInt((int)beginTime);
177  outMsg.writeInt((int)endTime);
178  // object id
179  outMsg.writeString(objID);
180  // command id
181  outMsg.writeUnsignedByte((int)vars.size());
182  for (int i = 0; i < varNo; ++i) {
183  outMsg.writeUnsignedByte(vars[i]);
184  }
185  // send message
186  mySocket->sendExact(outMsg);
187 }
188 
189 
190 void
191 TraCIAPI::send_commandSubscribeObjectContext(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime,
192  int domain, SUMOReal range, const std::vector<int>& vars) const {
193  if (mySocket == 0) {
194  throw tcpip::SocketException("Socket is not initialised");
195  }
196  tcpip::Storage outMsg;
197  // command length (domID, objID, beginTime, endTime, length, vars)
198  int varNo = (int) vars.size();
199  outMsg.writeUnsignedByte(0);
200  outMsg.writeInt(5 + 1 + 4 + 4 + 4 + (int) objID.length() + 1 + 8 + 1 + varNo);
201  // command id
202  outMsg.writeUnsignedByte(domID);
203  // time
204  outMsg.writeInt((int)beginTime);
205  outMsg.writeInt((int)endTime);
206  // object id
207  outMsg.writeString(objID);
208  // domain and range
209  outMsg.writeUnsignedByte(domain);
210  outMsg.writeDouble(range);
211  // command id
212  outMsg.writeUnsignedByte((int)vars.size());
213  for (int i = 0; i < varNo; ++i) {
214  outMsg.writeUnsignedByte(vars[i]);
215  }
216  // send message
217  mySocket->sendExact(outMsg);
218 }
219 
220 void
221 TraCIAPI::send_commandMoveToXY(const std::string& vehicleID, const std::string& edgeID, const int lane, const SUMOReal x, const SUMOReal y, const SUMOReal angle, const int keepRoute) const {
222  tcpip::Storage content;
224  content.writeInt(6);
226  content.writeString(edgeID);
228  content.writeInt(lane);
230  content.writeDouble(x);
232  content.writeDouble(y);
234  content.writeDouble(angle);
235  content.writeUnsignedByte(TYPE_BYTE);
236  content.writeByte(keepRoute);
238 }
239 
240 void
241 TraCIAPI::check_resultState(tcpip::Storage& inMsg, int command, bool ignoreCommandId, std::string* acknowledgement) const {
242  mySocket->receiveExact(inMsg);
243  int cmdLength;
244  int cmdId;
245  int resultType;
246  int cmdStart;
247  std::string msg;
248  try {
249  cmdStart = inMsg.position();
250  cmdLength = inMsg.readUnsignedByte();
251  cmdId = inMsg.readUnsignedByte();
252  if (command != cmdId && !ignoreCommandId) {
253  throw tcpip::SocketException("#Error: received status response to command: " + toString(cmdId) + " but expected: " + toString(command));
254  }
255  resultType = inMsg.readUnsignedByte();
256  msg = inMsg.readString();
257  } catch (std::invalid_argument&) {
258  throw tcpip::SocketException("#Error: an exception was thrown while reading result state message");
259  }
260  switch (resultType) {
261  case RTYPE_ERR:
262  throw tcpip::SocketException(".. Answered with error to command (" + toString(command) + "), [description: " + msg + "]");
264  throw tcpip::SocketException(".. Sent command is not implemented (" + toString(command) + "), [description: " + msg + "]");
265  case RTYPE_OK:
266  if (acknowledgement != 0) {
267  (*acknowledgement) = ".. Command acknowledged (" + toString(command) + "), [description: " + msg + "]";
268  }
269  break;
270  default:
271  throw tcpip::SocketException(".. Answered with unknown result code(" + toString(resultType) + ") to command(" + toString(command) + "), [description: " + msg + "]");
272  }
273  if ((cmdStart + cmdLength) != (int) inMsg.position()) {
274  throw tcpip::SocketException("#Error: command at position " + toString(cmdStart) + " has wrong length");
275  }
276 }
277 
278 
279 int
280 TraCIAPI::check_commandGetResult(tcpip::Storage& inMsg, int command, int expectedType, bool ignoreCommandId) const {
281  inMsg.position(); // respStart
282  int length = inMsg.readUnsignedByte();
283  if (length == 0) {
284  length = inMsg.readInt();
285  }
286  int cmdId = inMsg.readUnsignedByte();
287  if (!ignoreCommandId && cmdId != (command + 0x10)) {
288  throw tcpip::SocketException("#Error: received response with command id: " + toString(cmdId) + "but expected: " + toString(command + 0x10));
289  }
290  if (expectedType >= 0) {
291  // not called from the TraCITestClient but from within the TraCIAPI
292  inMsg.readUnsignedByte(); // variableID
293  inMsg.readString(); // objectID
294  int valueDataType = inMsg.readUnsignedByte();
295  if (valueDataType != expectedType) {
296  throw tcpip::SocketException("Expected " + toString(expectedType) + " but got " + toString(valueDataType));
297  }
298  }
299  return cmdId;
300 }
301 
302 
303 void
304 TraCIAPI::processGET(tcpip::Storage& inMsg, int command, int expectedType, bool ignoreCommandId) const {
305  check_resultState(inMsg, command, ignoreCommandId);
306  check_commandGetResult(inMsg, command, expectedType, ignoreCommandId);
307 }
308 
309 
310 
311 
312 SUMOTime
313 TraCIAPI::getSUMOTime(int cmd, int var, const std::string& id, tcpip::Storage* add) {
314  tcpip::Storage inMsg;
315  send_commandGetVariable(cmd, var, id, add);
316  processGET(inMsg, cmd, TYPE_INTEGER);
317  return inMsg.readInt();
318 }
319 
320 
321 int
322 TraCIAPI::getUnsignedByte(int cmd, int var, const std::string& id, tcpip::Storage* add) {
323  tcpip::Storage inMsg;
324  send_commandGetVariable(cmd, var, id, add);
325  processGET(inMsg, cmd, TYPE_UBYTE);
326  return inMsg.readUnsignedByte();
327 }
328 
329 
330 int
331 TraCIAPI::getByte(int cmd, int var, const std::string& id, tcpip::Storage* add) {
332  tcpip::Storage inMsg;
333  send_commandGetVariable(cmd, var, id, add);
334  processGET(inMsg, cmd, TYPE_BYTE);
335  return inMsg.readByte();
336 }
337 
338 
339 int
340 TraCIAPI::getInt(int cmd, int var, const std::string& id, tcpip::Storage* add) {
341  tcpip::Storage inMsg;
342  send_commandGetVariable(cmd, var, id, add);
343  processGET(inMsg, cmd, TYPE_INTEGER);
344  return inMsg.readInt();
345 }
346 
347 
348 SUMOReal
349 TraCIAPI::getFloat(int cmd, int var, const std::string& id, tcpip::Storage* add) {
350  tcpip::Storage inMsg;
351  send_commandGetVariable(cmd, var, id, add);
352  processGET(inMsg, cmd, TYPE_FLOAT);
353  return inMsg.readFloat();
354 }
355 
356 
357 SUMOReal
358 TraCIAPI::getDouble(int cmd, int var, const std::string& id, tcpip::Storage* add) {
359  tcpip::Storage inMsg;
360  send_commandGetVariable(cmd, var, id, add);
361  processGET(inMsg, cmd, TYPE_DOUBLE);
362  return inMsg.readDouble();
363 }
364 
365 
367 TraCIAPI::getBoundingBox(int cmd, int var, const std::string& id, tcpip::Storage* add) {
368  tcpip::Storage inMsg;
369  send_commandGetVariable(cmd, var, id, add);
370  processGET(inMsg, cmd, TYPE_BOUNDINGBOX);
371  TraCIBoundary b;
372  b.xMin = inMsg.readDouble();
373  b.yMin = inMsg.readDouble();
374  b.zMin = 0;
375  b.xMax = inMsg.readDouble();
376  b.yMax = inMsg.readDouble();
377  b.zMax = 0;
378  return b;
379 }
380 
381 
383 TraCIAPI::getPolygon(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_POLYGON);
387  int size = inMsg.readInt();
389  for (int i = 0; i < size; ++i) {
390  TraCIPosition p;
391  p.x = inMsg.readDouble();
392  p.y = inMsg.readDouble();
393  p.z = 0;
394  ret.push_back(p);
395  }
396  return ret;
397 }
398 
399 
401 TraCIAPI::getPosition(int cmd, int var, const std::string& id, tcpip::Storage* add) {
402  tcpip::Storage inMsg;
403  send_commandGetVariable(cmd, var, id, add);
404  processGET(inMsg, cmd, POSITION_2D);
405  TraCIPosition p;
406  p.x = inMsg.readDouble();
407  p.y = inMsg.readDouble();
408  p.z = 0;
409  return p;
410 }
411 
412 
413 std::string
414 TraCIAPI::getString(int cmd, int var, const std::string& id, tcpip::Storage* add) {
415  tcpip::Storage inMsg;
416  send_commandGetVariable(cmd, var, id, add);
417  processGET(inMsg, cmd, TYPE_STRING);
418  return inMsg.readString();
419 }
420 
421 
422 std::vector<std::string>
423 TraCIAPI::getStringVector(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, TYPE_STRINGLIST);
427  int size = inMsg.readInt();
428  std::vector<std::string> r;
429  for (int i = 0; i < size; ++i) {
430  r.push_back(inMsg.readString());
431  }
432  return r;
433 }
434 
435 
437 TraCIAPI::getColor(int cmd, int var, const std::string& id, tcpip::Storage* add) {
438  tcpip::Storage inMsg;
439  send_commandGetVariable(cmd, var, id, add);
440  processGET(inMsg, cmd, TYPE_COLOR);
441  TraCIColor c;
442  c.r = inMsg.readUnsignedByte();
443  c.g = inMsg.readUnsignedByte();
444  c.b = inMsg.readUnsignedByte();
445  c.a = inMsg.readUnsignedByte();
446  return c;
447 }
448 
449 void
450 TraCIAPI::readVariables(tcpip::Storage& inMsg, const std::string& objectID, int variableCount, SubscribedValues& into) {
451  while (variableCount > 0) {
452 
453  const int variableID = inMsg.readUnsignedByte();
454  const int status = inMsg.readUnsignedByte();
455  const int type = inMsg.readUnsignedByte();
456 
457  if (status == RTYPE_OK) {
458 
459  TraCIValue v;
460 
461  switch (type) {
462  case TYPE_DOUBLE:
463  v.scalar = inMsg.readDouble();
464  break;
465  case TYPE_STRING:
466  v.string = inMsg.readString();
467  break;
468  case POSITION_3D:
469  v.position.x = inMsg.readDouble();
470  v.position.y = inMsg.readDouble();
471  v.position.z = inMsg.readDouble();
472  break;
473  case TYPE_COLOR:
474  v.color.r = inMsg.readUnsignedByte();
475  v.color.g = inMsg.readUnsignedByte();
476  v.color.b = inMsg.readUnsignedByte();
477  v.color.a = inMsg.readUnsignedByte();
478  break;
479  case TYPE_INTEGER:
480  v.scalar = inMsg.readInt();
481  break;
482 
483  // TODO Other data types
484 
485  default:
486  throw tcpip::SocketException("Unimplemented subscription type: " + toString(type));
487  }
488 
489  into[objectID][variableID] = v;
490  } else {
491  throw tcpip::SocketException("Subscription response error: variableID=" + toString(variableID) + " status=" + toString(status));
492  }
493 
494  variableCount--;
495  }
496 }
497 
498 void
500  const std::string objectID = inMsg.readString();
501  const int variableCount = inMsg.readUnsignedByte();
502  readVariables(inMsg, objectID, variableCount, mySubscribedValues);
503 }
504 
505 void
507  const std::string contextID = inMsg.readString();
508  inMsg.readUnsignedByte(); // context domain
509  const int variableCount = inMsg.readUnsignedByte();
510  int numObjects = inMsg.readInt();
511 
512  while (numObjects > 0) {
513  std::string objectID = inMsg.readString();
514  readVariables(inMsg, objectID, variableCount, mySubscribedContextValues[contextID]);
515  numObjects--;
516  }
517 }
518 
519 void
522  tcpip::Storage inMsg;
524 
525  mySubscribedValues.clear();
527  int numSubs = inMsg.readInt();
528  while (numSubs > 0) {
529  int cmdId = check_commandGetResult(inMsg, 0, -1, true);
532  } else {
534  }
535  numSubs--;
536  }
537 }
538 
539 
540 // ---------------------------------------------------------------------------
541 // TraCIAPI::EdgeScope-methods
542 // ---------------------------------------------------------------------------
543 std::vector<std::string>
545  return myParent.getStringVector(CMD_GET_EDGE_VARIABLE, ID_LIST, "");
546 }
547 
548 int
550  return myParent.getInt(CMD_GET_EDGE_VARIABLE, ID_COUNT, "");
551 }
552 
553 SUMOReal
554 TraCIAPI::EdgeScope::getAdaptedTraveltime(const std::string& edgeID, SUMOTime time) const {
555  tcpip::Storage content;
556  content.writeInt((int)time);
557  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CO2EMISSION, edgeID, &content);
558 }
559 
560 SUMOReal
561 TraCIAPI::EdgeScope::getEffort(const std::string& edgeID, SUMOTime time) const {
562  tcpip::Storage content;
563  content.writeInt((int)time);
564  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CO2EMISSION, edgeID, &content);
565 }
566 
567 SUMOReal
568 TraCIAPI::EdgeScope::getCO2Emission(const std::string& edgeID) const {
569  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CO2EMISSION, edgeID);
570 }
571 
572 SUMOReal
573 TraCIAPI::EdgeScope::getCOEmission(const std::string& edgeID) const {
574  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_COEMISSION, edgeID);
575 }
576 
577 SUMOReal
578 TraCIAPI::EdgeScope::getHCEmission(const std::string& edgeID) const {
579  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_HCEMISSION, edgeID);
580 }
581 
582 SUMOReal
583 TraCIAPI::EdgeScope::getPMxEmission(const std::string& edgeID) const {
584  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_PMXEMISSION, edgeID);
585 }
586 
587 SUMOReal
588 TraCIAPI::EdgeScope::getNOxEmission(const std::string& edgeID) const {
589  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_NOXEMISSION, edgeID);
590 }
591 
592 SUMOReal
593 TraCIAPI::EdgeScope::getFuelConsumption(const std::string& edgeID) const {
594  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_FUELCONSUMPTION, edgeID);
595 }
596 
597 SUMOReal
598 TraCIAPI::EdgeScope::getNoiseEmission(const std::string& edgeID) const {
599  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_NOISEEMISSION, edgeID);
600 }
601 
602 SUMOReal
603 TraCIAPI::EdgeScope::getElectricityConsumption(const std::string& edgeID) const {
604  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_ELECTRICITYCONSUMPTION, edgeID);
605 }
606 
607 SUMOReal
608 TraCIAPI::EdgeScope::getLastStepMeanSpeed(const std::string& edgeID) const {
609  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_MEAN_SPEED, edgeID);
610 }
611 
612 SUMOReal
613 TraCIAPI::EdgeScope::getLastStepOccupancy(const std::string& edgeID) const {
614  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_OCCUPANCY, edgeID);
615 }
616 
617 SUMOReal
618 TraCIAPI::EdgeScope::getLastStepLength(const std::string& edgeID) const {
619  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_LENGTH, edgeID);
620 }
621 
622 SUMOReal
623 TraCIAPI::EdgeScope::getTraveltime(const std::string& edgeID) const {
624  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CURRENT_TRAVELTIME, edgeID);
625 }
626 
627 int
628 TraCIAPI::EdgeScope::getLastStepVehicleNumber(const std::string& edgeID) const {
629  return myParent.getInt(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_NUMBER, edgeID);
630 }
631 
632 SUMOReal
633 TraCIAPI::EdgeScope::getLastStepHaltingNumber(const std::string& edgeID) const {
634  return myParent.getInt(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_HALTING_NUMBER, edgeID);
635 }
636 
637 std::vector<std::string>
638 TraCIAPI::EdgeScope::getLastStepVehicleIDs(const std::string& edgeID) const {
639  return myParent.getStringVector(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, edgeID);
640 }
641 
642 
643 
644 void
645 TraCIAPI::EdgeScope::adaptTraveltime(const std::string& edgeID, SUMOReal time) const {
646  tcpip::Storage content;
647  content.writeDouble(time);
648  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_EDGE_TRAVELTIME, edgeID, content);
649  tcpip::Storage inMsg;
650  myParent.check_resultState(inMsg, CMD_SET_EDGE_VARIABLE);
651 }
652 
653 void
654 TraCIAPI::EdgeScope::setEffort(const std::string& edgeID, SUMOReal effort) const {
655  tcpip::Storage content;
656  content.writeDouble(effort);
657  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_EDGE_EFFORT, edgeID, content);
658  tcpip::Storage inMsg;
659  myParent.check_resultState(inMsg, CMD_SET_EDGE_VARIABLE);
660 }
661 
662 void
663 TraCIAPI::EdgeScope::setMaxSpeed(const std::string& edgeID, SUMOReal speed) const {
664  tcpip::Storage content;
665  content.writeDouble(speed);
666  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_MAXSPEED, edgeID, content);
667  tcpip::Storage inMsg;
668  myParent.check_resultState(inMsg, CMD_SET_EDGE_VARIABLE);
669 }
670 
671 
672 
673 
674 // ---------------------------------------------------------------------------
675 // TraCIAPI::GUIScope-methods
676 // ---------------------------------------------------------------------------
677 std::vector<std::string>
679  return myParent.getStringVector(CMD_GET_GUI_VARIABLE, ID_LIST, "");
680 }
681 
682 SUMOReal
683 TraCIAPI::GUIScope::getZoom(const std::string& viewID) const {
684  return myParent.getDouble(CMD_GET_GUI_VARIABLE, VAR_VIEW_ZOOM, viewID);
685 }
686 
688 TraCIAPI::GUIScope::getOffset(const std::string& viewID) const {
689  return myParent.getPosition(CMD_GET_GUI_VARIABLE, VAR_VIEW_OFFSET, viewID);
690 }
691 
692 std::string
693 TraCIAPI::GUIScope::getSchema(const std::string& viewID) const {
694  return myParent.getString(CMD_GET_GUI_VARIABLE, VAR_VIEW_SCHEMA, viewID);
695 }
696 
698 TraCIAPI::GUIScope::getBoundary(const std::string& viewID) const {
699  return myParent.getBoundingBox(CMD_GET_GUI_VARIABLE, VAR_VIEW_BOUNDARY, viewID);
700 }
701 
702 
703 void
704 TraCIAPI::GUIScope::setZoom(const std::string& viewID, SUMOReal zoom) const {
705  tcpip::Storage content;
706  content.writeDouble(zoom);
707  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_ZOOM, viewID, content);
708  tcpip::Storage inMsg;
709  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
710 }
711 
712 void
713 TraCIAPI::GUIScope::setOffset(const std::string& viewID, SUMOReal x, SUMOReal y) const {
714  tcpip::Storage content;
716  content.writeDouble(x);
717  content.writeDouble(y);
718  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_OFFSET, viewID, content);
719  tcpip::Storage inMsg;
720  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
721 }
722 
723 void
724 TraCIAPI::GUIScope::setSchema(const std::string& viewID, const std::string& schemeName) const {
725  tcpip::Storage content;
727  content.writeString(schemeName);
728  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_SCHEMA, viewID, content);
729  tcpip::Storage inMsg;
730  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
731 }
732 
733 void
734 TraCIAPI::GUIScope::setBoundary(const std::string& viewID, SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax) const {
735  tcpip::Storage content;
737  content.writeDouble(xmin);
738  content.writeDouble(ymin);
739  content.writeDouble(xmax);
740  content.writeDouble(ymax);
741  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_BOUNDARY, viewID, content);
742  tcpip::Storage inMsg;
743  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
744 }
745 
746 void
747 TraCIAPI::GUIScope::screenshot(const std::string& viewID, const std::string& filename) const {
748  tcpip::Storage content;
750  content.writeString(filename);
751  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_SCREENSHOT, viewID, content);
752  tcpip::Storage inMsg;
753  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
754 }
755 
756 void
757 TraCIAPI::GUIScope::trackVehicle(const std::string& viewID, const std::string& vehID) const {
758  tcpip::Storage content;
760  content.writeString(vehID);
761  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_TRACK_VEHICLE, viewID, content);
762  tcpip::Storage inMsg;
763  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
764 }
765 
766 
767 
768 
769 // ---------------------------------------------------------------------------
770 // TraCIAPI::InductionLoopScope-methods
771 // ---------------------------------------------------------------------------
772 std::vector<std::string>
774  return myParent.getStringVector(CMD_GET_INDUCTIONLOOP_VARIABLE, ID_LIST, "");
775 }
776 
777 SUMOReal
778 TraCIAPI::InductionLoopScope::getPosition(const std::string& loopID) const {
779  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, VAR_POSITION, loopID);
780 }
781 
782 std::string
783 TraCIAPI::InductionLoopScope::getLaneID(const std::string& loopID) const {
784  return myParent.getString(CMD_GET_INDUCTIONLOOP_VARIABLE, VAR_LANE_ID, loopID);
785 }
786 
787 int
789  return myParent.getInt(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_NUMBER, loopID);
790 }
791 
792 SUMOReal
793 TraCIAPI::InductionLoopScope::getLastStepMeanSpeed(const std::string& loopID) const {
794  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_MEAN_SPEED, loopID);
795 }
796 
797 std::vector<std::string>
798 TraCIAPI::InductionLoopScope::getLastStepVehicleIDs(const std::string& loopID) const {
799  return myParent.getStringVector(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, loopID);
800 }
801 
802 SUMOReal
803 TraCIAPI::InductionLoopScope::getLastStepOccupancy(const std::string& loopID) const {
804  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_OCCUPANCY, loopID);
805 }
806 
807 SUMOReal
808 TraCIAPI::InductionLoopScope::getLastStepMeanLength(const std::string& loopID) const {
809  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_LENGTH, loopID);
810 }
811 
812 SUMOReal
813 TraCIAPI::InductionLoopScope::getTimeSinceDetection(const std::string& loopID) const {
814  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_TIME_SINCE_DETECTION, loopID);
815 }
816 
817 std::vector<TraCIAPI::InductionLoopScope::VehicleData>
818 TraCIAPI::InductionLoopScope::getVehicleData(const std::string& loopID) const {
819  tcpip::Storage inMsg;
820  myParent.send_commandGetVariable(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_DATA, loopID);
821  myParent.processGET(inMsg, CMD_GET_INDUCTIONLOOP_VARIABLE, TYPE_COMPOUND);
822  std::vector<VehicleData> result;
823  inMsg.readInt(); // components
824  // number of items
825  inMsg.readUnsignedByte();
826  const int n = inMsg.readInt();
827  for (int i = 0; i < n; ++i) {
828  VehicleData vd;
829 
830  inMsg.readUnsignedByte();
831  vd.id = inMsg.readString();
832 
833  inMsg.readUnsignedByte();
834  vd.length = inMsg.readDouble();
835 
836  inMsg.readUnsignedByte();
837  vd.entryTime = inMsg.readDouble();
838 
839  inMsg.readUnsignedByte();
840  vd.leaveTime = inMsg.readDouble();
841 
842  inMsg.readUnsignedByte();
843  vd.typeID = inMsg.readString();
844 
845  result.push_back(vd);
846  }
847  return result;
848 }
849 
850 
851 
852 
853 // ---------------------------------------------------------------------------
854 // TraCIAPI::JunctionScope-methods
855 // ---------------------------------------------------------------------------
856 std::vector<std::string>
858  return myParent.getStringVector(CMD_GET_JUNCTION_VARIABLE, ID_LIST, "");
859 }
860 
862 TraCIAPI::JunctionScope::getPosition(const std::string& junctionID) const {
863  return myParent.getPosition(CMD_GET_JUNCTION_VARIABLE, VAR_POSITION, junctionID);
864 }
865 
866 
867 
868 
869 // ---------------------------------------------------------------------------
870 // TraCIAPI::LaneScope-methods
871 // ---------------------------------------------------------------------------
872 std::vector<std::string>
874  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, ID_LIST, "");
875 }
876 
877 SUMOReal
878 TraCIAPI::LaneScope::getLength(const std::string& laneID) const {
879  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_LENGTH, laneID);
880 }
881 
882 SUMOReal
883 TraCIAPI::LaneScope::getMaxSpeed(const std::string& laneID) const {
884  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_MAXSPEED, laneID);
885 }
886 
887 SUMOReal
888 TraCIAPI::LaneScope::getWidth(const std::string& laneID) const {
889  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_WIDTH, laneID);
890 }
891 
892 std::vector<std::string>
893 TraCIAPI::LaneScope::getAllowed(const std::string& laneID) const {
894  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, LANE_ALLOWED, laneID);
895 }
896 
897 std::vector<std::string>
898 TraCIAPI::LaneScope::getDisallowed(const std::string& laneID) const {
899  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, LANE_DISALLOWED, laneID);
900 }
901 
902 int
903 TraCIAPI::LaneScope::getLinkNumber(const std::string& /* laneID */) const {
904  throw tcpip::SocketException("Not implemented!");
905 }
906 
908 TraCIAPI::LaneScope::getShape(const std::string& laneID) const {
909  return myParent.getPolygon(CMD_GET_LANE_VARIABLE, VAR_SHAPE, laneID);
910 }
911 
912 std::string
913 TraCIAPI::LaneScope::getEdgeID(const std::string& laneID) const {
914  return myParent.getString(CMD_GET_LANE_VARIABLE, LANE_EDGE_ID, laneID);
915 }
916 
917 SUMOReal
918 TraCIAPI::LaneScope::getCO2Emission(const std::string& laneID) const {
919  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_CO2EMISSION, laneID);
920 }
921 
922 SUMOReal
923 TraCIAPI::LaneScope::getCOEmission(const std::string& laneID) const {
924  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_COEMISSION, laneID);
925 }
926 
927 SUMOReal
928 TraCIAPI::LaneScope::getHCEmission(const std::string& laneID) const {
929  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_HCEMISSION, laneID);
930 }
931 
932 SUMOReal
933 TraCIAPI::LaneScope::getPMxEmission(const std::string& laneID) const {
934  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_PMXEMISSION, laneID);
935 }
936 
937 SUMOReal
938 TraCIAPI::LaneScope::getNOxEmission(const std::string& laneID) const {
939  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_NOXEMISSION, laneID);
940 }
941 
942 SUMOReal
943 TraCIAPI::LaneScope::getFuelConsumption(const std::string& laneID) const {
944  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_FUELCONSUMPTION, laneID);
945 }
946 
947 SUMOReal
948 TraCIAPI::LaneScope::getNoiseEmission(const std::string& laneID) const {
949  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_NOISEEMISSION, laneID);
950 }
951 
952 SUMOReal
953 TraCIAPI::LaneScope::getElectricityConsumption(const std::string& laneID) const {
954  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_ELECTRICITYCONSUMPTION, laneID);
955 }
956 
957 SUMOReal
958 TraCIAPI::LaneScope::getLastStepMeanSpeed(const std::string& laneID) const {
959  return myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_MEAN_SPEED, laneID);
960 }
961 
962 SUMOReal
963 TraCIAPI::LaneScope::getLastStepOccupancy(const std::string& laneID) const {
964  return myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_OCCUPANCY, laneID);
965 }
966 
967 SUMOReal
968 TraCIAPI::LaneScope::getLastStepLength(const std::string& laneID) const {
969  return myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_LENGTH, laneID);
970 }
971 
972 SUMOReal
973 TraCIAPI::LaneScope::getTraveltime(const std::string& laneID) const {
974  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_CURRENT_TRAVELTIME, laneID);
975 }
976 
977 int
978 TraCIAPI::LaneScope::getLastStepVehicleNumber(const std::string& laneID) const {
979  return myParent.getInt(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_NUMBER, laneID);
980 }
981 
982 int
983 TraCIAPI::LaneScope::getLastStepHaltingNumber(const std::string& laneID) const {
984  return myParent.getInt(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_HALTING_NUMBER, laneID);
985 }
986 
987 std::vector<std::string>
988 TraCIAPI::LaneScope::getLastStepVehicleIDs(const std::string& laneID) const {
989  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, laneID);
990 }
991 
992 
993 void
994 TraCIAPI::LaneScope::setAllowed(const std::string& laneID, const std::vector<std::string>& allowedClasses) const {
995  tcpip::Storage content;
997  content.writeInt((int)allowedClasses.size());
998  for (int i = 0; i < (int)allowedClasses.size(); ++i) {
999  content.writeString(allowedClasses[i]);
1000  }
1001  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, LANE_ALLOWED, laneID, content);
1002  tcpip::Storage inMsg;
1003  myParent.check_resultState(inMsg, CMD_SET_LANE_VARIABLE);
1004 }
1005 
1006 void
1007 TraCIAPI::LaneScope::setDisallowed(const std::string& laneID, const std::vector<std::string>& disallowedClasses) const {
1008  tcpip::Storage content;
1010  content.writeInt((int)disallowedClasses.size());
1011  for (int i = 0; i < (int)disallowedClasses.size(); ++i) {
1012  content.writeString(disallowedClasses[i]);
1013  }
1014  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, LANE_DISALLOWED, laneID, content);
1015  tcpip::Storage inMsg;
1016  myParent.check_resultState(inMsg, CMD_SET_LANE_VARIABLE);
1017 }
1018 
1019 void
1020 TraCIAPI::LaneScope::setMaxSpeed(const std::string& laneID, SUMOReal speed) const {
1021  tcpip::Storage content;
1022  content.writeUnsignedByte(TYPE_DOUBLE);
1023  content.writeDouble(speed);
1024  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, VAR_MAXSPEED, laneID, content);
1025  tcpip::Storage inMsg;
1026  myParent.check_resultState(inMsg, CMD_SET_LANE_VARIABLE);
1027 }
1028 
1029 void
1030 TraCIAPI::LaneScope::setLength(const std::string& laneID, SUMOReal length) const {
1031  tcpip::Storage content;
1032  content.writeUnsignedByte(TYPE_DOUBLE);
1033  content.writeDouble(length);
1034  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, VAR_LENGTH, laneID, content);
1035  tcpip::Storage inMsg;
1036  myParent.check_resultState(inMsg, CMD_SET_LANE_VARIABLE);
1037 }
1038 
1039 
1040 // ---------------------------------------------------------------------------
1041 // TraCIAPI::AreaDetector-methods
1042 // ---------------------------------------------------------------------------
1043 std::vector<std::string>
1045  return myParent.getStringVector(CMD_GET_AREAL_DETECTOR_VARIABLE, ID_LIST, "");
1046 }
1047 
1048 
1049 
1050 
1051 // ---------------------------------------------------------------------------
1052 // TraCIAPI::MeMeScope-methods
1053 // ---------------------------------------------------------------------------
1054 std::vector<std::string>
1056  return myParent.getStringVector(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, ID_LIST, "");
1057 }
1058 
1059 int
1060 TraCIAPI::MeMeScope::getLastStepVehicleNumber(const std::string& detID) const {
1062 }
1063 
1064 SUMOReal
1065 TraCIAPI::MeMeScope::getLastStepMeanSpeed(const std::string& detID) const {
1066  return myParent.getInt(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, LAST_STEP_MEAN_SPEED, detID);
1067 }
1068 
1069 std::vector<std::string>
1070 TraCIAPI::MeMeScope::getLastStepVehicleIDs(const std::string& detID) const {
1071  return myParent.getStringVector(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, detID);
1072 }
1073 
1074 int
1075 TraCIAPI::MeMeScope::getLastStepHaltingNumber(const std::string& detID) const {
1077 }
1078 
1079 
1080 
1081 // ---------------------------------------------------------------------------
1082 // TraCIAPI::POIScope-methods
1083 // ---------------------------------------------------------------------------
1084 std::vector<std::string>
1086  return myParent.getStringVector(CMD_GET_POI_VARIABLE, ID_LIST, "");
1087 }
1088 
1089 std::string
1090 TraCIAPI::POIScope::getType(const std::string& poiID) const {
1091  return myParent.getString(CMD_GET_POI_VARIABLE, VAR_TYPE, poiID);
1092 }
1093 
1095 TraCIAPI::POIScope::getPosition(const std::string& poiID) const {
1096  return myParent.getPosition(CMD_GET_POI_VARIABLE, VAR_POSITION, poiID);
1097 }
1098 
1100 TraCIAPI::POIScope::getColor(const std::string& poiID) const {
1101  return myParent.getColor(CMD_GET_POI_VARIABLE, VAR_COLOR, poiID);
1102 }
1103 
1104 
1105 void
1106 TraCIAPI::POIScope::setType(const std::string& poiID, const std::string& setType) const {
1107  tcpip::Storage content;
1108  content.writeUnsignedByte(TYPE_STRING);
1109  content.writeString(setType);
1110  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_TYPE, poiID, content);
1111  tcpip::Storage inMsg;
1112  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1113 }
1114 
1115 void
1116 TraCIAPI::POIScope::setPosition(const std::string& poiID, SUMOReal x, SUMOReal y) const {
1117  tcpip::Storage content;
1118  content.writeUnsignedByte(POSITION_2D);
1119  content.writeDouble(x);
1120  content.writeDouble(y);
1121  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_POSITION, poiID, content);
1122  tcpip::Storage inMsg;
1123  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1124 }
1125 
1126 void
1127 TraCIAPI::POIScope::setColor(const std::string& poiID, const TraCIColor& c) const {
1128  tcpip::Storage content;
1129  content.writeUnsignedByte(TYPE_COLOR);
1130  content.writeUnsignedByte(c.r);
1131  content.writeUnsignedByte(c.g);
1132  content.writeUnsignedByte(c.b);
1133  content.writeUnsignedByte(c.a);
1134  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_COLOR, poiID, content);
1135  tcpip::Storage inMsg;
1136  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1137 }
1138 
1139 void
1140 TraCIAPI::POIScope::add(const std::string& poiID, SUMOReal x, SUMOReal y, const TraCIColor& c, const std::string& type, int layer) const {
1141  tcpip::Storage content;
1143  content.writeInt(4);
1144  content.writeUnsignedByte(TYPE_STRING);
1145  content.writeString(type);
1146  content.writeUnsignedByte(TYPE_COLOR);
1147  content.writeUnsignedByte(c.r);
1148  content.writeUnsignedByte(c.g);
1149  content.writeUnsignedByte(c.b);
1150  content.writeUnsignedByte(c.a);
1152  content.writeInt(layer);
1153  content.writeUnsignedByte(POSITION_2D);
1154  content.writeDouble(x);
1155  content.writeDouble(y);
1156  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, ADD, poiID, content);
1157  tcpip::Storage inMsg;
1158  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1159 }
1160 
1161 void
1162 TraCIAPI::POIScope::remove(const std::string& poiID, int layer) const {
1163  tcpip::Storage content;
1165  content.writeInt(layer);
1166  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, REMOVE, poiID, content);
1167  tcpip::Storage inMsg;
1168  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1169 }
1170 
1171 
1172 
1173 // ---------------------------------------------------------------------------
1174 // TraCIAPI::PolygonScope-methods
1175 // ---------------------------------------------------------------------------
1176 std::vector<std::string>
1178  return myParent.getStringVector(CMD_GET_POLYGON_VARIABLE, ID_LIST, "");
1179 }
1180 
1181 std::string
1182 TraCIAPI::PolygonScope::getType(const std::string& polygonID) const {
1183  return myParent.getString(CMD_GET_POLYGON_VARIABLE, VAR_TYPE, polygonID);
1184 }
1185 
1187 TraCIAPI::PolygonScope::getShape(const std::string& polygonID) const {
1188  return myParent.getPolygon(CMD_GET_POLYGON_VARIABLE, VAR_SHAPE, polygonID);
1189 }
1190 
1192 TraCIAPI::PolygonScope::getColor(const std::string& polygonID) const {
1193  return myParent.getColor(CMD_GET_POLYGON_VARIABLE, VAR_COLOR, polygonID);
1194 }
1195 
1196 
1197 void
1198 TraCIAPI::PolygonScope::setType(const std::string& polygonID, const std::string& setType) const {
1199  tcpip::Storage content;
1200  content.writeUnsignedByte(TYPE_STRING);
1201  content.writeString(setType);
1202  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_TYPE, polygonID, content);
1203  tcpip::Storage inMsg;
1204  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1205 }
1206 
1207 void
1208 TraCIAPI::PolygonScope::setShape(const std::string& polygonID, const TraCIAPI::TraCIPositionVector& shape) const {
1209  tcpip::Storage content;
1211  content.writeInt((int)shape.size());
1212  for (int i = 0; i < (int)shape.size(); ++i) {
1213  content.writeDouble(shape[i].x);
1214  content.writeDouble(shape[i].y);
1215  }
1216  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_POSITION, polygonID, content);
1217  tcpip::Storage inMsg;
1218  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1219 }
1220 
1221 void
1222 TraCIAPI::PolygonScope::setColor(const std::string& polygonID, const TraCIColor& c) const {
1223  tcpip::Storage content;
1224  content.writeUnsignedByte(TYPE_COLOR);
1225  content.writeUnsignedByte(c.r);
1226  content.writeUnsignedByte(c.g);
1227  content.writeUnsignedByte(c.b);
1228  content.writeUnsignedByte(c.a);
1229  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_COLOR, polygonID, content);
1230  tcpip::Storage inMsg;
1231  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1232 }
1233 
1234 void
1235 TraCIAPI::PolygonScope::add(const std::string& polygonID, const TraCIAPI::TraCIPositionVector& shape, const TraCIColor& c, bool fill, const std::string& type, int layer) const {
1236  tcpip::Storage content;
1238  content.writeInt(4);
1239  content.writeUnsignedByte(TYPE_STRING);
1240  content.writeString(type);
1241  content.writeUnsignedByte(TYPE_COLOR);
1242  content.writeUnsignedByte(c.r);
1243  content.writeUnsignedByte(c.g);
1244  content.writeUnsignedByte(c.b);
1245  content.writeUnsignedByte(c.a);
1246  content.writeUnsignedByte(TYPE_UBYTE);
1247  int f = fill ? 1 : 0;
1248  content.writeUnsignedByte(f);
1250  content.writeInt(layer);
1252  content.writeInt((int)shape.size());
1253  for (int i = 0; i < (int)shape.size(); ++i) {
1254  content.writeDouble(shape[i].x);
1255  content.writeDouble(shape[i].y);
1256  }
1257  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, ADD, polygonID, content);
1258  tcpip::Storage inMsg;
1259  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1260 }
1261 
1262 void
1263 TraCIAPI::PolygonScope::remove(const std::string& polygonID, int layer) const {
1264  tcpip::Storage content;
1266  content.writeInt(layer);
1267  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, REMOVE, polygonID, content);
1268  tcpip::Storage inMsg;
1269  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1270 }
1271 
1272 
1273 
1274 // ---------------------------------------------------------------------------
1275 // TraCIAPI::RouteScope-methods
1276 // ---------------------------------------------------------------------------
1277 std::vector<std::string>
1279  return myParent.getStringVector(CMD_GET_ROUTE_VARIABLE, ID_LIST, "");
1280 }
1281 
1282 std::vector<std::string>
1283 TraCIAPI::RouteScope::getEdges(const std::string& routeID) const {
1284  return myParent.getStringVector(CMD_GET_ROUTE_VARIABLE, VAR_EDGES, routeID);
1285 }
1286 
1287 
1288 void
1289 TraCIAPI::RouteScope::add(const std::string& routeID, const std::vector<std::string>& edges) const {
1290  tcpip::Storage content;
1292  content.writeStringList(edges);
1293  myParent.send_commandSetValue(CMD_SET_ROUTE_VARIABLE, ADD, routeID, content);
1294  tcpip::Storage inMsg;
1295  myParent.check_resultState(inMsg, CMD_SET_ROUTE_VARIABLE);
1296 }
1297 
1298 
1299 
1300 
1301 
1302 // ---------------------------------------------------------------------------
1303 // TraCIAPI::SimulationScope-methods
1304 // ---------------------------------------------------------------------------
1305 SUMOTime
1307  return myParent.getSUMOTime(CMD_GET_SIM_VARIABLE, VAR_TIME_STEP, "");
1308 }
1309 
1310 int
1312  return (int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_LOADED_VEHICLES_NUMBER, "");
1313 }
1314 
1315 std::vector<std::string>
1317  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_LOADED_VEHICLES_IDS, "");
1318 }
1319 
1320 int
1322  return (int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_DEPARTED_VEHICLES_NUMBER, "");
1323 }
1324 
1325 std::vector<std::string>
1327  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_DEPARTED_VEHICLES_IDS, "");
1328 }
1329 
1330 int
1332  return (int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_ARRIVED_VEHICLES_NUMBER, "");
1333 }
1334 
1335 std::vector<std::string>
1337  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_ARRIVED_VEHICLES_IDS, "");
1338 }
1339 
1340 int
1342  return (int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_STARTING_VEHICLES_NUMBER, "");
1343 }
1344 
1345 std::vector<std::string>
1347  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_STARTING_VEHICLES_IDS, "");
1348 }
1349 
1350 int
1352  return (int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_ENDING_VEHICLES_NUMBER, "");
1353 }
1354 
1355 std::vector<std::string>
1357  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_ENDING_VEHICLES_IDS, "");
1358 }
1359 
1360 SUMOTime
1362  return myParent.getSUMOTime(CMD_GET_SIM_VARIABLE, VAR_DELTA_T, "");
1363 }
1364 
1367  return myParent.getBoundingBox(CMD_GET_SIM_VARIABLE, VAR_NET_BOUNDING_BOX, "");
1368 }
1369 
1370 int
1372  return myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_MIN_EXPECTED_VEHICLES, "");
1373 }
1374 
1375 void
1376 TraCIAPI::SimulationScope::subscribe(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime, const std::vector<int>& vars) const {
1377  myParent.send_commandSubscribeObjectVariable(domID, objID, beginTime, endTime, vars);
1378  tcpip::Storage inMsg;
1379  myParent.check_resultState(inMsg, domID);
1380  myParent.check_commandGetResult(inMsg, domID);
1381  myParent.readVariableSubscription(inMsg);
1382 }
1383 
1384 void
1385 TraCIAPI::SimulationScope::subscribeContext(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime, int domain, SUMOReal range, const std::vector<int>& vars) const {
1386 
1387  myParent.send_commandSubscribeObjectContext(domID, objID, beginTime, endTime, domain, range, vars);
1388  tcpip::Storage inMsg;
1389  myParent.check_resultState(inMsg, domID);
1390  myParent.check_commandGetResult(inMsg, domID);
1391  myParent.readContextSubscription(inMsg);
1392 }
1393 
1396  return myParent.mySubscribedValues;
1397 }
1398 
1399 
1402  if (myParent.mySubscribedValues.find(objID) != myParent.mySubscribedValues.end()) {
1403  return myParent.mySubscribedValues[objID];
1404  } else {
1405  throw; // Something?
1406  }
1407 }
1408 
1409 
1412  return myParent.mySubscribedContextValues;
1413 }
1414 
1415 
1418  if (myParent.mySubscribedContextValues.find(objID) != myParent.mySubscribedContextValues.end()) {
1419  return myParent.mySubscribedContextValues[objID];
1420  } else {
1421  throw; // Something?
1422  }
1423 }
1424 
1425 
1426 // ---------------------------------------------------------------------------
1427 // TraCIAPI::TrafficLightScope-methods
1428 // ---------------------------------------------------------------------------
1429 std::vector<std::string>
1431  return myParent.getStringVector(CMD_GET_TL_VARIABLE, ID_LIST, "");
1432 }
1433 
1434 std::string
1436  return myParent.getString(CMD_GET_TL_VARIABLE, TL_RED_YELLOW_GREEN_STATE, tlsID);
1437 }
1438 
1439 std::vector<TraCIAPI::TraCILogic>
1441  tcpip::Storage inMsg;
1442  myParent.send_commandGetVariable(CMD_GET_TL_VARIABLE, TL_COMPLETE_DEFINITION_RYG, tlsID);
1443  myParent.processGET(inMsg, CMD_GET_TL_VARIABLE, TYPE_COMPOUND);
1444  std::vector<TraCIAPI::TraCILogic> ret;
1445  int logicNo = inMsg.readInt();
1446  for (int i = 0; i < logicNo; ++i) {
1447  inMsg.readUnsignedByte();
1448  std::string subID = inMsg.readString();
1449  inMsg.readUnsignedByte();
1450  int type = inMsg.readInt();
1451  inMsg.readUnsignedByte();
1452  inMsg.readInt(); // add
1453  inMsg.readUnsignedByte();
1454  int phaseIndex = inMsg.readInt();
1455  inMsg.readUnsignedByte();
1456  int phaseNumber = inMsg.readInt();
1457  std::vector<TraCIAPI::TraCIPhase> phases;
1458  for (int j = 0; j < phaseNumber; ++j) {
1459  inMsg.readUnsignedByte();
1460  int duration = inMsg.readInt();
1461  inMsg.readUnsignedByte();
1462  int duration1 = inMsg.readInt();
1463  inMsg.readUnsignedByte();
1464  int duration2 = inMsg.readInt();
1465  inMsg.readUnsignedByte();
1466  std::string phase = inMsg.readString();
1467  phases.push_back(TraCIAPI::TraCIPhase(duration, duration1, duration2, phase));
1468  }
1469  ret.push_back(TraCIAPI::TraCILogic(subID, type, std::map<std::string, SUMOReal>(), phaseIndex, phases));
1470  }
1471  return ret;
1472 }
1473 
1474 std::vector<std::string>
1475 TraCIAPI::TrafficLightScope::getControlledLanes(const std::string& tlsID) const {
1476  return myParent.getStringVector(CMD_GET_TL_VARIABLE, TL_CONTROLLED_LANES, tlsID);
1477 }
1478 
1479 std::vector<TraCIAPI::TraCILink>
1480 TraCIAPI::TrafficLightScope::getControlledLinks(const std::string& tlsID) const {
1481  tcpip::Storage inMsg;
1482  myParent.send_commandGetVariable(CMD_GET_TL_VARIABLE, TL_CONTROLLED_LINKS, tlsID);
1483  myParent.processGET(inMsg, CMD_GET_TL_VARIABLE, TYPE_COMPOUND);
1484  std::vector<TraCIAPI::TraCILink> ret;
1485  int linkNo = inMsg.readInt();
1486  for (int i = 0; i < linkNo; ++i) {
1487  inMsg.readUnsignedByte();
1488  std::string from = inMsg.readString();
1489  inMsg.readUnsignedByte();
1490  std::string via = inMsg.readString();
1491  inMsg.readUnsignedByte();
1492  std::string to = inMsg.readString();
1493  ret.push_back(TraCIAPI::TraCILink(from, via, to));
1494  }
1495  return ret;
1496 }
1497 
1498 std::string
1499 TraCIAPI::TrafficLightScope::getProgram(const std::string& tlsID) const {
1500  return myParent.getString(CMD_GET_TL_VARIABLE, TL_CURRENT_PROGRAM, tlsID);
1501 }
1502 
1503 int
1504 TraCIAPI::TrafficLightScope::getPhase(const std::string& tlsID) const {
1505  return myParent.getInt(CMD_GET_TL_VARIABLE, TL_CURRENT_PHASE, tlsID);
1506 }
1507 
1508 int
1509 TraCIAPI::TrafficLightScope::getNextSwitch(const std::string& tlsID) const {
1510  return myParent.getInt(CMD_GET_TL_VARIABLE, TL_NEXT_SWITCH, tlsID);
1511 }
1512 
1513 
1514 void
1515 TraCIAPI::TrafficLightScope::setRedYellowGreenState(const std::string& tlsID, const std::string& state) const {
1516  tcpip::Storage content;
1517  content.writeUnsignedByte(TYPE_STRING);
1518  content.writeString(state);
1519  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_RED_YELLOW_GREEN_STATE, tlsID, content);
1520  tcpip::Storage inMsg;
1521  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1522 }
1523 
1524 void
1525 TraCIAPI::TrafficLightScope::setPhase(const std::string& tlsID, int index) const {
1526  tcpip::Storage content;
1528  content.writeInt(index);
1529  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PHASE_INDEX, tlsID, content);
1530  tcpip::Storage inMsg;
1531  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1532 }
1533 
1534 void
1535 TraCIAPI::TrafficLightScope::setProgram(const std::string& tlsID, const std::string& programID) const {
1536  tcpip::Storage content;
1537  content.writeUnsignedByte(TYPE_STRING);
1538  content.writeString(programID);
1539  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PROGRAM, tlsID, content);
1540  tcpip::Storage inMsg;
1541  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1542 }
1543 
1544 void
1545 TraCIAPI::TrafficLightScope::setPhaseDuration(const std::string& tlsID, int phaseDuration) const {
1546  tcpip::Storage content;
1548  content.writeInt(int(1000 * phaseDuration));
1549  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PHASE_DURATION, tlsID, content);
1550  tcpip::Storage inMsg;
1551  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1552 }
1553 
1554 void
1556  tcpip::Storage content;
1558  content.writeInt(5 + 4 * (int)logic.phases.size());
1559  content.writeUnsignedByte(TYPE_STRING);
1560  content.writeString(logic.subID);
1562  content.writeInt(logic.type);
1564  content.writeInt(0);
1566  content.writeInt(logic.currentPhaseIndex);
1568  content.writeInt((int)logic.phases.size());
1569  for (int i = 0; i < (int) logic.phases.size(); ++i) {
1571  content.writeInt((int)logic.phases[i].duration);
1573  content.writeInt((int)logic.phases[i].duration1);
1575  content.writeInt((int)logic.phases[i].duration2);
1576  content.writeUnsignedByte(TYPE_STRING);
1577  content.writeString(logic.phases[i].phase);
1578  }
1579  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_COMPLETE_PROGRAM_RYG, tlsID, content);
1580  tcpip::Storage inMsg;
1581  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1582 }
1583 
1584 
1585 
1586 
1587 
1588 // ---------------------------------------------------------------------------
1589 // TraCIAPI::VehicleTypeScope-methods
1590 // ---------------------------------------------------------------------------
1591 std::vector<std::string>
1593  return myParent.getStringVector(CMD_GET_VEHICLETYPE_VARIABLE, ID_LIST, "");
1594 }
1595 
1596 SUMOReal
1597 TraCIAPI::VehicleTypeScope::getLength(const std::string& typeID) const {
1598  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_LENGTH, typeID);
1599 }
1600 
1601 SUMOReal
1602 TraCIAPI::VehicleTypeScope::getMaxSpeed(const std::string& typeID) const {
1603  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_MAXSPEED, typeID);
1604 }
1605 
1606 SUMOReal
1607 TraCIAPI::VehicleTypeScope::getSpeedFactor(const std::string& typeID) const {
1608  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_SPEED_FACTOR, typeID);
1609 }
1610 
1611 SUMOReal
1612 TraCIAPI::VehicleTypeScope::getSpeedDeviation(const std::string& typeID) const {
1613  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_SPEED_DEVIATION, typeID);
1614 }
1615 
1616 SUMOReal
1617 TraCIAPI::VehicleTypeScope::getAccel(const std::string& typeID) const {
1618  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_ACCEL, typeID);
1619 }
1620 
1621 SUMOReal
1622 TraCIAPI::VehicleTypeScope::getDecel(const std::string& typeID) const {
1623  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_DECEL, typeID);
1624 }
1625 
1626 SUMOReal
1627 TraCIAPI::VehicleTypeScope::getImperfection(const std::string& typeID) const {
1628  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_IMPERFECTION, typeID);
1629 }
1630 
1631 SUMOReal
1632 TraCIAPI::VehicleTypeScope::getTau(const std::string& typeID) const {
1633  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_TAU, typeID);
1634 }
1635 
1636 std::string
1637 TraCIAPI::VehicleTypeScope::getVehicleClass(const std::string& typeID) const {
1638  return myParent.getString(CMD_GET_TL_VARIABLE, VAR_VEHICLECLASS, typeID);
1639 }
1640 
1641 std::string
1642 TraCIAPI::VehicleTypeScope::getEmissionClass(const std::string& typeID) const {
1643  return myParent.getString(CMD_GET_TL_VARIABLE, VAR_EMISSIONCLASS, typeID);
1644 }
1645 
1646 std::string
1647 TraCIAPI::VehicleTypeScope::getShapeClass(const std::string& typeID) const {
1648  return myParent.getString(CMD_GET_TL_VARIABLE, VAR_SHAPECLASS, typeID);
1649 }
1650 
1651 SUMOReal
1652 TraCIAPI::VehicleTypeScope::getMinGap(const std::string& typeID) const {
1653  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_MINGAP, typeID);
1654 }
1655 
1656 SUMOReal
1657 TraCIAPI::VehicleTypeScope::getWidth(const std::string& typeID) const {
1658  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_WIDTH, typeID);
1659 }
1660 
1662 TraCIAPI::VehicleTypeScope::getColor(const std::string& typeID) const {
1663  return myParent.getColor(CMD_GET_TL_VARIABLE, VAR_COLOR, typeID);
1664 }
1665 
1666 
1667 
1668 void
1669 TraCIAPI::VehicleTypeScope::setLength(const std::string& typeID, SUMOReal length) const {
1670  tcpip::Storage content;
1671  content.writeUnsignedByte(TYPE_DOUBLE);
1672  content.writeDouble(length);
1673  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_LENGTH, typeID, content);
1674  tcpip::Storage inMsg;
1675  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1676 }
1677 
1678 void
1679 TraCIAPI::VehicleTypeScope::setMaxSpeed(const std::string& typeID, SUMOReal speed) const {
1680  tcpip::Storage content;
1681  content.writeUnsignedByte(TYPE_DOUBLE);
1682  content.writeDouble(speed);
1683  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_MAXSPEED, typeID, content);
1684  tcpip::Storage inMsg;
1685  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1686 }
1687 
1688 void
1689 TraCIAPI::VehicleTypeScope::setVehicleClass(const std::string& typeID, const std::string& clazz) const {
1690  tcpip::Storage content;
1691  content.writeUnsignedByte(TYPE_STRING);
1692  content.writeString(clazz);
1693  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_VEHICLECLASS, typeID, content);
1694  tcpip::Storage inMsg;
1695  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1696 }
1697 
1698 void
1699 TraCIAPI::VehicleTypeScope::setSpeedFactor(const std::string& typeID, SUMOReal factor) const {
1700  tcpip::Storage content;
1701  content.writeUnsignedByte(TYPE_DOUBLE);
1702  content.writeDouble(factor);
1703  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SPEED_FACTOR, typeID, content);
1704  tcpip::Storage inMsg;
1705  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1706 }
1707 
1708 void
1709 TraCIAPI::VehicleTypeScope::setSpeedDeviation(const std::string& typeID, SUMOReal deviation) const {
1710  tcpip::Storage content;
1711  content.writeUnsignedByte(TYPE_DOUBLE);
1712  content.writeDouble(deviation);
1713  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SPEED_DEVIATION, typeID, content);
1714  tcpip::Storage inMsg;
1715  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1716 }
1717 
1718 void
1719 TraCIAPI::VehicleTypeScope::setEmissionClass(const std::string& typeID, const std::string& clazz) const {
1720  tcpip::Storage content;
1721  content.writeUnsignedByte(TYPE_STRING);
1722  content.writeString(clazz);
1723  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_EMISSIONCLASS, typeID, content);
1724  tcpip::Storage inMsg;
1725  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1726 }
1727 
1728 void
1729 TraCIAPI::VehicleTypeScope::setWidth(const std::string& typeID, SUMOReal width) const {
1730  tcpip::Storage content;
1731  content.writeUnsignedByte(TYPE_DOUBLE);
1732  content.writeDouble(width);
1733  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_WIDTH, typeID, content);
1734  tcpip::Storage inMsg;
1735  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1736 }
1737 
1738 void
1739 TraCIAPI::VehicleTypeScope::setMinGap(const std::string& typeID, SUMOReal minGap) const {
1740  tcpip::Storage content;
1741  content.writeUnsignedByte(TYPE_DOUBLE);
1742  content.writeDouble(minGap);
1743  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_MINGAP, typeID, content);
1744  tcpip::Storage inMsg;
1745  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1746 }
1747 
1748 void
1749 TraCIAPI::VehicleTypeScope::setShapeClass(const std::string& typeID, const std::string& clazz) const {
1750  tcpip::Storage content;
1751  content.writeUnsignedByte(TYPE_STRING);
1752  content.writeString(clazz);
1753  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SHAPECLASS, typeID, content);
1754  tcpip::Storage inMsg;
1755  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1756 }
1757 
1758 void
1759 TraCIAPI::VehicleTypeScope::setAccel(const std::string& typeID, SUMOReal accel) const {
1760  tcpip::Storage content;
1761  content.writeUnsignedByte(TYPE_DOUBLE);
1762  content.writeDouble(accel);
1763  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_ACCEL, typeID, content);
1764  tcpip::Storage inMsg;
1765  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1766 }
1767 
1768 void
1769 TraCIAPI::VehicleTypeScope::setDecel(const std::string& typeID, SUMOReal decel) const {
1770  tcpip::Storage content;
1771  content.writeUnsignedByte(TYPE_DOUBLE);
1772  content.writeDouble(decel);
1773  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_DECEL, typeID, content);
1774  tcpip::Storage inMsg;
1775  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1776 }
1777 
1778 void
1779 TraCIAPI::VehicleTypeScope::setImperfection(const std::string& typeID, SUMOReal imperfection) const {
1780  tcpip::Storage content;
1781  content.writeUnsignedByte(TYPE_DOUBLE);
1782  content.writeDouble(imperfection);
1783  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_IMPERFECTION, typeID, content);
1784  tcpip::Storage inMsg;
1785  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1786 }
1787 
1788 void
1789 TraCIAPI::VehicleTypeScope::setTau(const std::string& typeID, SUMOReal tau) const {
1790  tcpip::Storage content;
1791  content.writeUnsignedByte(TYPE_DOUBLE);
1792  content.writeDouble(tau);
1793  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_TAU, typeID, content);
1794  tcpip::Storage inMsg;
1795  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1796 }
1797 
1798 void
1799 TraCIAPI::VehicleTypeScope::setColor(const std::string& typeID, const TraCIColor& c) const {
1800  tcpip::Storage content;
1801  content.writeUnsignedByte(TYPE_COLOR);
1802  content.writeUnsignedByte(c.r);
1803  content.writeUnsignedByte(c.g);
1804  content.writeUnsignedByte(c.b);
1805  content.writeUnsignedByte(c.a);
1806  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_COLOR, typeID, content);
1807  tcpip::Storage inMsg;
1808  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1809 }
1810 
1811 
1812 
1813 
1814 
1815 // ---------------------------------------------------------------------------
1816 // TraCIAPI::VehicleScope-methods
1817 // ---------------------------------------------------------------------------
1818 std::vector<std::string>
1820  return myParent.getStringVector(CMD_GET_VEHICLE_VARIABLE, ID_LIST, "");
1821 }
1822 
1823 int
1825  return myParent.getInt(CMD_GET_VEHICLE_VARIABLE, ID_COUNT, "");
1826 }
1827 
1828 SUMOReal
1829 TraCIAPI::VehicleScope::getSpeed(const std::string& vehicleID) const {
1830  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_SPEED, vehicleID);
1831 }
1832 
1834 TraCIAPI::VehicleScope::getPosition(const std::string& vehicleID) const {
1835  return myParent.getPosition(CMD_GET_VEHICLE_VARIABLE, VAR_POSITION, vehicleID);
1836 }
1837 
1838 SUMOReal
1839 TraCIAPI::VehicleScope::getAngle(const std::string& vehicleID) const {
1840  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_ANGLE, vehicleID);
1841 }
1842 
1843 std::string
1844 TraCIAPI::VehicleScope::getRoadID(const std::string& vehicleID) const {
1845  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_ROAD_ID, vehicleID);
1846 }
1847 
1848 std::string
1849 TraCIAPI::VehicleScope::getLaneID(const std::string& vehicleID) const {
1850  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_LANE_ID, vehicleID);
1851 }
1852 
1853 int
1854 TraCIAPI::VehicleScope::getLaneIndex(const std::string& vehicleID) const {
1855  return myParent.getInt(CMD_GET_VEHICLE_VARIABLE, VAR_LANE_INDEX, vehicleID);
1856 }
1857 
1858 std::string
1859 TraCIAPI::VehicleScope::getTypeID(const std::string& vehicleID) const {
1860  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_TYPE, vehicleID);
1861 }
1862 
1863 std::string
1864 TraCIAPI::VehicleScope::getRouteID(const std::string& vehicleID) const {
1865  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_ROAD_ID, vehicleID);
1866 }
1867 
1868 int
1869 TraCIAPI::VehicleScope::getRouteIndex(const std::string& vehicleID) const {
1870  return myParent.getInt(CMD_GET_VEHICLE_VARIABLE, VAR_ROUTE_INDEX, vehicleID);
1871 }
1872 
1873 std::vector<std::string>
1874 TraCIAPI::VehicleScope::getEdges(const std::string& vehicleID) const {
1875  return myParent.getStringVector(CMD_GET_VEHICLE_VARIABLE, VAR_EDGES, vehicleID);
1876 }
1877 
1879 TraCIAPI::VehicleScope::getColor(const std::string& vehicleID) const {
1880  return myParent.getColor(CMD_GET_VEHICLE_VARIABLE, VAR_COLOR, vehicleID);
1881 }
1882 
1883 SUMOReal
1884 TraCIAPI::VehicleScope::getLanePosition(const std::string& vehicleID) const {
1885  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_LANEPOSITION, vehicleID);
1886 }
1887 
1888 SUMOReal
1889 TraCIAPI::VehicleScope::getCO2Emission(const std::string& vehicleID) const {
1890  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_CO2EMISSION, vehicleID);
1891 }
1892 
1893 SUMOReal
1894 TraCIAPI::VehicleScope::getCOEmission(const std::string& vehicleID) const {
1895  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_COEMISSION, vehicleID);
1896 }
1897 
1898 SUMOReal
1899 TraCIAPI::VehicleScope::getHCEmission(const std::string& vehicleID) const {
1900  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_HCEMISSION, vehicleID);
1901 }
1902 
1903 SUMOReal
1904 TraCIAPI::VehicleScope::getPMxEmission(const std::string& vehicleID) const {
1905  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_PMXEMISSION, vehicleID);
1906 }
1907 
1908 SUMOReal
1909 TraCIAPI::VehicleScope::getNOxEmission(const std::string& vehicleID) const {
1910  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_NOXEMISSION, vehicleID);
1911 }
1912 
1913 SUMOReal
1914 TraCIAPI::VehicleScope::getFuelConsumption(const std::string& vehicleID) const {
1915  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_FUELCONSUMPTION, vehicleID);
1916 }
1917 
1918 SUMOReal
1919 TraCIAPI::VehicleScope::getNoiseEmission(const std::string& vehicleID) const {
1920  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_NOISEEMISSION, vehicleID);
1921 }
1922 
1923 SUMOReal
1924 TraCIAPI::VehicleScope::getElectricityConsumption(const std::string& vehicleID) const {
1925  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_ELECTRICITYCONSUMPTION, vehicleID);
1926 }
1927 
1928 SUMOReal
1929 TraCIAPI::VehicleScope::getWaitingTime(const std::string& vehID) const {
1930  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_WAITING_TIME, vehID);
1931 }
1932 
1933 
1934 int
1935 TraCIAPI::VehicleScope::getSpeedMode(const std::string& vehID) const {
1936  return myParent.getInt(CMD_GET_VEHICLE_VARIABLE, VAR_SPEEDSETMODE, vehID);
1937 }
1938 
1939 
1940 SUMOReal
1941 TraCIAPI::VehicleScope::getSlope(const std::string& vehID) const {
1942  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_SLOPE, vehID);
1943 }
1944 
1945 
1946 std::vector<TraCIAPI::VehicleScope::NextTLSData>
1947 TraCIAPI::VehicleScope::getNextTLS(const std::string& vehID) const {
1948  tcpip::Storage inMsg;
1949  myParent.send_commandGetVariable(CMD_GET_VEHICLE_VARIABLE, VAR_NEXT_TLS, vehID);
1950  myParent.processGET(inMsg, CMD_GET_VEHICLE_VARIABLE, TYPE_COMPOUND);
1951  std::vector<NextTLSData> result;
1952  inMsg.readInt(); // components
1953  // number of items
1954  inMsg.readUnsignedByte();
1955  const int n = inMsg.readInt();
1956  for (int i = 0; i < n; ++i) {
1957  NextTLSData d;
1958  inMsg.readUnsignedByte();
1959  d.id = inMsg.readString();
1960 
1961  inMsg.readUnsignedByte();
1962  d.tlIndex = inMsg.readInt();
1963 
1964  inMsg.readUnsignedByte();
1965  d.dist = inMsg.readDouble();
1966 
1967  inMsg.readUnsignedByte();
1968  d.state = (char)inMsg.readByte();
1969 
1970  result.push_back(d);
1971  }
1972  return result;
1973 }
1974 
1975 
1976 void
1977 TraCIAPI::VehicleScope::add(const std::string& vehicleID,
1978  const std::string& routeID,
1979  const std::string& typeID,
1980  std::string depart,
1981  const std::string& departLane,
1982  const std::string& departPos,
1983  const std::string& departSpeed,
1984  const std::string& arrivalLane,
1985  const std::string& arrivalPos,
1986  const std::string& arrivalSpeed,
1987  const std::string& fromTaz,
1988  const std::string& toTaz,
1989  const std::string& line,
1990  int personCapacity,
1991  int personNumber) const {
1992 
1993  if (depart == "-1") {
1994  depart = toString(myParent.simulation.getCurrentTime() / 1000.0);
1995  }
1996  tcpip::Storage content;
1998  content.writeInt(14);
1999  content.writeUnsignedByte(TYPE_STRING);
2000  content.writeString(routeID);
2001  content.writeUnsignedByte(TYPE_STRING);
2002  content.writeString(typeID);
2003  content.writeUnsignedByte(TYPE_STRING);
2004  content.writeString(depart);
2005  content.writeUnsignedByte(TYPE_STRING);
2006  content.writeString(departLane);
2007  content.writeUnsignedByte(TYPE_STRING);
2008  content.writeString(departPos);
2009  content.writeUnsignedByte(TYPE_STRING);
2010  content.writeString(departSpeed);
2011 
2012  content.writeUnsignedByte(TYPE_STRING);
2013  content.writeString(arrivalLane);
2014  content.writeUnsignedByte(TYPE_STRING);
2015  content.writeString(arrivalPos);
2016  content.writeUnsignedByte(TYPE_STRING);
2017  content.writeString(arrivalSpeed);
2018 
2019  content.writeUnsignedByte(TYPE_STRING);
2020  content.writeString(fromTaz);
2021  content.writeUnsignedByte(TYPE_STRING);
2022  content.writeString(toTaz);
2023  content.writeUnsignedByte(TYPE_STRING);
2024  content.writeString(line);
2025 
2027  content.writeInt(personCapacity);
2029  content.writeInt(personNumber);
2030 
2031  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, ADD_FULL, vehicleID, content);
2032  tcpip::Storage inMsg;
2033  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2034 }
2035 
2036 
2037 void
2038 TraCIAPI::VehicleScope::remove(const std::string& vehicleID, char reason) const {
2039  tcpip::Storage content;
2040  content.writeUnsignedByte(TYPE_BYTE);
2041  content.writeUnsignedByte(reason);
2042  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, REMOVE, vehicleID, content);
2043  tcpip::Storage inMsg;
2044  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2045 
2046 }
2047 
2048 
2049 void
2050 TraCIAPI::VehicleScope::moveTo(const std::string& vehicleID, const std::string& laneID, SUMOReal position) const {
2051  tcpip::Storage content;
2053  content.writeInt(2);
2054  content.writeUnsignedByte(TYPE_STRING);
2055  content.writeString(laneID);
2056  content.writeUnsignedByte(TYPE_DOUBLE);
2057  content.writeDouble(position);
2058  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_MOVE_TO, vehicleID, content);
2059  tcpip::Storage inMsg;
2060  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2061 }
2062 
2063 void
2064 TraCIAPI::VehicleScope::moveToXY(const std::string& vehicleID, const std::string& edgeID, const int lane, const SUMOReal x, const SUMOReal y, const SUMOReal angle, const int keepRoute) const {
2065  myParent.send_commandMoveToXY(vehicleID, edgeID, lane, x, y, angle, keepRoute);
2066  tcpip::Storage inMsg;
2067  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2068 }
2069 
2070 
2071 void
2072 TraCIAPI::VehicleScope::slowDown(const std::string& vehicleID, SUMOReal speed, int duration) const {
2073  tcpip::Storage content;
2075  content.writeInt(2);
2076  content.writeUnsignedByte(TYPE_DOUBLE);
2077  content.writeDouble(speed);
2079  content.writeInt(duration);
2080  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, CMD_SLOWDOWN, vehicleID, content);
2081  tcpip::Storage inMsg;
2082  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2083 }
2084 
2085 void
2086 TraCIAPI::VehicleScope::setSpeed(const std::string& vehicleID, SUMOReal speed) const {
2087  tcpip::Storage content;
2088  content.writeUnsignedByte(TYPE_DOUBLE);
2089  content.writeDouble(speed);
2090  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_SPEED, vehicleID, content);
2091  tcpip::Storage inMsg;
2092  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
2093 }
2094 
2095 // ---------------------------------------------------------------------------
2096 // // TraCIAPI::PersonScope-methods
2097 // ---------------------------------------------------------------------------
2098 
2099 std::vector<std::string>
2101  return myParent.getStringVector(CMD_GET_PERSON_VARIABLE, ID_LIST, "");
2102 }
2103 
2104 int
2106  return myParent.getInt(CMD_GET_PERSON_VARIABLE, ID_COUNT, "");
2107 }
2108 
2109 SUMOReal
2110 TraCIAPI::PersonScope::getSpeed(const std::string& typeID) const {
2111  return myParent.getDouble(CMD_GET_PERSON_VARIABLE, VAR_SPEED, typeID);
2112 }
2113 
2115 TraCIAPI::PersonScope::getPosition(const std::string& typeID) const {
2116  return myParent.getPosition(CMD_GET_PERSON_VARIABLE, VAR_POSITION, typeID);
2117 }
2118 
2119 std::string
2120 TraCIAPI::PersonScope::getRoadID(const std::string& typeID) const {
2121  return myParent.getString(CMD_GET_PERSON_VARIABLE, VAR_ROAD_ID, typeID);
2122 }
2123 
2124 std::string
2125 TraCIAPI::PersonScope::getTypeID(const std::string& typeID) const {
2126  return myParent.getString(CMD_GET_PERSON_VARIABLE, VAR_TYPE, typeID);
2127 }
2128 
2129 SUMOReal
2130 TraCIAPI::PersonScope::getWaitingTime(const std::string& typeID) const {
2131  return myParent.getDouble(CMD_GET_PERSON_VARIABLE, VAR_WAITING_TIME, typeID);
2132 }
2133 
2134 std::string
2135 TraCIAPI::PersonScope::getNextEdge(const std::string& typeID) const {
2136  return myParent.getString(CMD_GET_PERSON_VARIABLE, VAR_NEXT_EDGE, typeID);
2137 }
2138 
2139 
2140 /****************************************************************************/
2141 
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1278
SUMOReal getImperfection(const std::string &typeID) const
Definition: TraCIAPI.cpp:1627
#define VAR_ROAD_ID
#define LAST_STEP_MEAN_SPEED
TraCIPosition getPosition(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:401
SUMOReal entryTime
Entry-time of the vehicle in [s].
Definition: TraCIAPI.h:317
char state
The current state of the tls.
Definition: TraCIAPI.h:715
TraCIColor getColor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1879
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:873
SubscribedContextValues getContextSubscriptionResults()
Definition: TraCIAPI.cpp:1411
#define TL_NEXT_SWITCH
SUMOReal getMaxSpeed(const std::string &typeID) const
Definition: TraCIAPI.cpp:1602
#define VAR_TIME_STEP
int getStartingTeleportNumber() const
Definition: TraCIAPI.cpp:1341
TraCIPosition getOffset(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:688
int getLastStepVehicleNumber(const std::string &loopID) const
Definition: TraCIAPI.cpp:788
void setLength(const std::string &typeID, SUMOReal length) const
Definition: TraCIAPI.cpp:1669
#define VAR_EMISSIONCLASS
long long int SUMOTime
Definition: SUMOTime.h:43
void setMaxSpeed(const std::string &edgeID, SUMOReal speed) const
Definition: TraCIAPI.cpp:663
SUMOReal getNoiseEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:948
tcpip::Socket * mySocket
The socket.
Definition: TraCIAPI.h:955
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1592
#define VAR_CO2EMISSION
std::vector< std::string > getLoadedIDList() const
Definition: TraCIAPI.cpp:1316
void close()
Closes the connection.
Definition: TraCIAPI.cpp:80
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
Definition: TraCIAPI.cpp:67
#define CMD_GET_TL_VARIABLE
std::vector< std::string > getArrivedIDList() const
Definition: TraCIAPI.cpp:1336
#define VAR_LENGTH
std::string getRouteID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1864
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:678
std::string typeID
Type of the vehicle in.
Definition: TraCIAPI.h:321
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:1977
#define CMD_GET_VEHICLE_VARIABLE
#define TYPE_COMPOUND
#define VAR_CURRENT_TRAVELTIME
TraCIColor getColor(const std::string &poiID) const
Definition: TraCIAPI.cpp:1100
int getIDCount() const
Definition: TraCIAPI.cpp:2105
#define CMD_CLOSE
std::string getTypeID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1859
void add(const std::string &poiID, SUMOReal x, SUMOReal y, const TraCIColor &c, const std::string &type, int layer) const
Definition: TraCIAPI.cpp:1140
SUMOReal getLastStepMeanSpeed(const std::string &edgeID) const
Definition: TraCIAPI.cpp:608
std::vector< std::string > getDisallowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:898
#define POSITION_2D
SUMOReal getCOEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:573
#define VAR_POSITION
SUMOReal getAngle(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1839
void setShapeClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1749
void slowDown(const std::string &vehicleID, SUMOReal speed, int duration) const
Definition: TraCIAPI.cpp:2072
void setProgram(const std::string &tlsID, const std::string &programID) const
Definition: TraCIAPI.cpp:1535
void setPhase(const std::string &tlsID, int index) const
Definition: TraCIAPI.cpp:1525
void setVehicleClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1689
bool receiveExact(Storage &)
Receive a complete TraCI message from Socket::socket_.
Definition: socket.cpp:497
#define CMD_GET_INDUCTIONLOOP_VARIABLE
std::map< int, TraCIValue > TraCIValues
{object->{variable->value}}
Definition: TraCIAPI.h:558
#define VAR_SPEEDSETMODE
#define VAR_TAU
std::string getVehicleClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1637
#define LANE_EDGE_ID
void setColor(const std::string &polygonID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:1222
std::string string
Definition: TraCIAPI.h:99
SUMOReal getDouble(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:358
#define LAST_STEP_VEHICLE_DATA
void send_commandClose() const
Sends a Close command.
Definition: TraCIAPI.cpp:104
virtual unsigned int position() const
#define TYPE_UBYTE
#define RTYPE_OK
int getLastStepHaltingNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:983
LaneScope lane
Scope for interaction with lanes.
Definition: TraCIAPI.h:840
#define VAR_WAITING_TIME
#define CMD_GET_PERSON_VARIABLE
virtual double readDouble()
void setMaxSpeed(const std::string &typeID, SUMOReal speed) const
Definition: TraCIAPI.cpp:1679
void setCompleteRedYellowGreenDefinition(const std::string &tlsID, const TraCIAPI::TraCILogic &logic) const
Definition: TraCIAPI.cpp:1555
#define VAR_TYPE
#define TYPE_POLYGON
std::string getEmissionClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1642
void add(const std::string &polygonID, const TraCIPositionVector &shape, const TraCIColor &c, bool fill, const std::string &type, int layer) const
Definition: TraCIAPI.cpp:1235
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1819
SUMOReal getLastStepMeanSpeed(const std::string &detID) const
Definition: TraCIAPI.cpp:1065
#define VAR_VEHICLECLASS
void processGET(tcpip::Storage &inMsg, int command, int expectedType, bool ignoreCommandId=false) const
Definition: TraCIAPI.cpp:304
StorageType::size_type size() const
Definition: storage.h:115
SUMOReal getPMxEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:933
int getLastStepHaltingNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:1075
#define VAR_SPEED_FACTOR
SUMOReal getLastStepOccupancy(const std::string &edgeID) const
Definition: TraCIAPI.cpp:613
#define VAR_COLOR
SUMOReal getCO2Emission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1889
#define VAR_LOADED_VEHICLES_IDS
std::vector< std::string > getLastStepVehicleIDs(const std::string &loopID) const
Definition: TraCIAPI.cpp:798
TraCIPosition getPosition(const std::string &junctionID) const
Definition: TraCIAPI.cpp:862
void trackVehicle(const std::string &viewID, const std::string &vehID) const
Definition: TraCIAPI.cpp:757
#define TYPE_COLOR
#define TYPE_STRINGLIST
void moveToXY(const std::string &vehicleID, const std::string &edgeID, const int lane, const SUMOReal x, const SUMOReal y, const SUMOReal angle, const int keepRoute) const
Definition: TraCIAPI.cpp:2064
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:857
SUMOReal getElectricityConsumption(const std::string &laneID) const
Definition: TraCIAPI.cpp:953
#define POSITION_3D
SUMOTime getCurrentTime() const
Definition: TraCIAPI.cpp:1306
SUMOReal getLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:878
SUMOReal getLastStepMeanSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:958
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1177
int getRouteIndex(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1869
SUMOReal getMinGap(const std::string &typeID) const
Definition: TraCIAPI.cpp:1652
SubscribedContextValues mySubscribedContextValues
Definition: TraCIAPI.h:958
#define VAR_TELEPORT_STARTING_VEHICLES_IDS
#define CMD_GET_POLYGON_VARIABLE
void simulationStep(SUMOTime time=0)
Advances by one step (or up to the given time)
Definition: TraCIAPI.cpp:520
void send_commandMoveToXY(const std::string &vehicleID, const std::string &edgeID, const int lane, const SUMOReal x, const SUMOReal y, const SUMOReal angle, const int keepRoute) const
Definition: TraCIAPI.cpp:221
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1475
SUMOReal getLastStepMeanLength(const std::string &loopID) const
Definition: TraCIAPI.cpp:808
void setAllowed(const std::string &laneID, const std::vector< std::string > &allowedClasses) const
Definition: TraCIAPI.cpp:994
virtual void writeUnsignedByte(int)
#define CMD_SET_EDGE_VARIABLE
#define VAR_NEXT_TLS
#define CMD_SET_GUI_VARIABLE
SUMOReal getWidth(const std::string &typeID) const
Definition: TraCIAPI.cpp:1657
TraCIPositionVector getPolygon(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:383
SUMOReal getLastStepOccupancy(const std::string &laneID) const
Definition: TraCIAPI.cpp:963
#define TL_CURRENT_PHASE
void readVariableSubscription(tcpip::Storage &inMsg)
Definition: TraCIAPI.cpp:499
std::string getProgram(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1499
std::map< std::string, SubscribedValues > SubscribedContextValues
Definition: TraCIAPI.h:560
#define VAR_LOADED_VEHICLES_NUMBER
#define VAR_SHAPE
TraCIColor color
Definition: TraCIAPI.h:97
#define VAR_SPEED_DEVIATION
int getLastStepVehicleNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:978
#define VAR_NOISEEMISSION
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:544
#define VAR_NEXT_EDGE
#define VAR_FUELCONSUMPTION
#define CMD_GET_ROUTE_VARIABLE
TraCIBoundary getBoundingBox(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:367
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:2100
virtual void writeInt(int)
void setDisallowed(const std::string &laneID, const std::vector< std::string > &disallowedClasses) const
Definition: TraCIAPI.cpp:1007
void setTau(const std::string &typeID, SUMOReal tau) const
Definition: TraCIAPI.cpp:1789
SUMOReal getCO2Emission(const std::string &laneID) const
Definition: TraCIAPI.cpp:918
SUMOReal leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIAPI.h:319
std::vector< std::string > getAllowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:893
void setBoundary(const std::string &viewID, SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax) const
Definition: TraCIAPI.cpp:734
#define TYPE_STRING
void setMaxSpeed(const std::string &laneID, SUMOReal speed) const
Definition: TraCIAPI.cpp:1020
virtual int readUnsignedByte()
#define TL_PHASE_DURATION
void connect()
Connects to host_:port_.
Definition: socket.cpp:324
#define LAST_STEP_LENGTH
#define VAR_NOXEMISSION
#define RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
#define TL_CURRENT_PROGRAM
#define CMD_SET_TL_VARIABLE
void send_commandSubscribeObjectContext(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, int domain, SUMOReal range, const std::vector< int > &vars) const
Sends a SubscribeContext request.
Definition: TraCIAPI.cpp:191
void setSpeed(const std::string &vehicleID, SUMOReal speed) const
Definition: TraCIAPI.cpp:2086
#define VAR_ANGLE
#define CMD_GET_VEHICLETYPE_VARIABLE
void remove(const std::string &polygonID, int layer=0) const
Definition: TraCIAPI.cpp:1263
void send_commandSimulationStep(SUMOTime time) const
Sends a SimulationStep command.
Definition: TraCIAPI.cpp:91
SubscribedValues mySubscribedValues
Definition: TraCIAPI.h:957
#define LANE_ALLOWED
std::string getRedYellowGreenState(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1435
int getLaneIndex(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1854
#define VAR_DEPARTED_VEHICLES_NUMBER
void adaptTraveltime(const std::string &edgeID, SUMOReal time) const
Definition: TraCIAPI.cpp:645
#define LAST_STEP_TIME_SINCE_DETECTION
#define CMD_SLOWDOWN
#define CMD_SET_ROUTE_VARIABLE
SUMOReal getElectricityConsumption(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1924
#define TYPE_FLOAT
#define VAR_SHAPECLASS
SUMOReal length
Length of the vehicle.
Definition: TraCIAPI.h:315
#define CMD_GET_AREAL_DETECTOR_VARIABLE
#define VAR_MIN_EXPECTED_VEHICLES
#define VAR_SCREENSHOT
#define VAR_VIEW_BOUNDARY
#define VAR_TRACK_VEHICLE
int getPhase(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1504
SUMOReal getWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1929
TraCIPosition getPosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1834
void setDecel(const std::string &typeID, SUMOReal decel) const
Definition: TraCIAPI.cpp:1769
void remove(const std::string &vehicleID, char reason=REMOVE_VAPORIZED) const
Definition: TraCIAPI.cpp:2038
std::map< std::string, TraCIValues > SubscribedValues
Definition: TraCIAPI.h:559
int getArrivedNumber() const
Definition: TraCIAPI.cpp:1331
void setLength(const std::string &laneID, SUMOReal length) const
Definition: TraCIAPI.cpp:1030
#define VAR_ACCEL
SUMOTime getDeltaT() const
Definition: TraCIAPI.cpp:1361
void setSchema(const std::string &viewID, const std::string &schemeName) const
Definition: TraCIAPI.cpp:724
TraCIColor getColor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1662
virtual int readInt()
#define TL_COMPLETE_PROGRAM_RYG
std::string getType(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1182
SUMOReal getTraveltime(const std::string &laneID) const
Definition: TraCIAPI.cpp:973
TraCIPosition position
Definition: TraCIAPI.h:96
void setType(const std::string &poiID, const std::string &setType) const
Definition: TraCIAPI.cpp:1106
SUMOReal getNOxEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:938
#define VAR_NET_BOUNDING_BOX
void send_commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *add=0) const
Sends a GetVariable request.
Definition: TraCIAPI.cpp:115
TraCIColor getColor(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:437
#define CMD_GET_POI_VARIABLE
#define VAR_LANEPOSITION
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1085
~TraCIAPI()
Destructor.
Definition: TraCIAPI.cpp:61
void screenshot(const std::string &viewID, const std::string &filename) const
Definition: TraCIAPI.cpp:747
std::vector< std::string > getDepartedIDList() const
Definition: TraCIAPI.cpp:1326
std::vector< std::string > getEdges(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1874
#define TL_COMPLETE_DEFINITION_RYG
#define VAR_TELEPORT_STARTING_VEHICLES_NUMBER
SUMOReal getNoiseEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1919
#define CMD_SET_VEHICLETYPE_VARIABLE
std::vector< TraCIAPI::TraCILink > getControlledLinks(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1480
virtual void writeByte(int)
TraCIPosition getPosition(const std::string &typeID) const
Definition: TraCIAPI.cpp:2115
#define TYPE_BOUNDINGBOX
SUMOReal getHCEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:928
void setWidth(const std::string &typeID, SUMOReal width) const
Definition: TraCIAPI.cpp:1729
A 3D-bounding box.
Definition: TraCIAPI.h:88
static std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: TraCIAPI.h:945
void setEmissionClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1719
TraCIPositionVector getShape(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1187
void setSpeedFactor(const std::string &typeID, SUMOReal factor) const
Definition: TraCIAPI.cpp:1699
#define VAR_VIEW_SCHEMA
virtual void writeStringList(const std::vector< std::string > &s)
int getEndingTeleportNumber() const
Definition: TraCIAPI.cpp:1351
#define VAR_PMXEMISSION
#define VAR_TELEPORT_ENDING_VEHICLES_IDS
std::vector< NextTLSData > getNextTLS(const std::string &vehID) const
Definition: TraCIAPI.cpp:1947
#define CMD_GET_LANE_VARIABLE
std::vector< TraCIPhase > phases
Definition: TraCIAPI.h:123
int getInt(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:340
#define CMD_SET_VEHICLE_VARIABLE
std::string getRoadID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1844
SUMOReal getSpeedFactor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1607
#define VAR_IMPERFECTION
SUMOReal getPMxEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1904
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1430
SUMOReal getLastStepLength(const std::string &edgeID) const
Definition: TraCIAPI.cpp:618
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
Definition: TraCIAPI.cpp:1515
#define CMD_GET_SIM_VARIABLE
virtual std::string readString()
std::string getShapeClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1647
#define CMD_GET_EDGE_VARIABLE
int getByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:331
#define VAR_EDGES
#define CMD_GET_GUI_VARIABLE
std::string getSchema(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:693
SUMOReal getLastStepOccupancy(const std::string &loopID) const
Definition: TraCIAPI.cpp:803
int getIDCount() const
Definition: TraCIAPI.cpp:1824
#define VAR_DEPARTED_VEHICLES_IDS
#define CMD_SET_POI_VARIABLE
int getUnsignedByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:322
#define VAR_EDGE_EFFORT
void setMinGap(const std::string &typeID, SUMOReal minGap) const
Definition: TraCIAPI.cpp:1739
TraCIColor getColor(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1192
SUMOReal getDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1622
SUMOReal getSlope(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1941
std::vector< std::string > getEndingTeleportIDList() const
Definition: TraCIAPI.cpp:1356
#define ADD
SUMOReal getPosition(const std::string &loopID) const
Definition: TraCIAPI.cpp:778
#define CMD_GET_JUNCTION_VARIABLE
#define VAR_SLOPE
TraCIBoundary getBoundary(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:698
SUMOReal getTimeSinceDetection(const std::string &loopID) const
Definition: TraCIAPI.cpp:813
#define VAR_DELTA_T
#define REMOVE
void setOffset(const std::string &viewID, SUMOReal x, SUMOReal y) const
Definition: TraCIAPI.cpp:713
std::string getEdgeID(const std::string &laneID) const
Definition: TraCIAPI.cpp:913
virtual void writeStorage(tcpip::Storage &store)
#define TL_CONTROLLED_LINKS
SUMOReal getMaxSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:883
std::string getTypeID(const std::string &typeID) const
Definition: TraCIAPI.cpp:2125
void readContextSubscription(tcpip::Storage &inMsg)
Definition: TraCIAPI.cpp:506
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:280
void readVariables(tcpip::Storage &inMsg, const std::string &objectID, int variableCount, SubscribedValues &into)
Definition: TraCIAPI.cpp:450
SUMOReal getLastStepMeanSpeed(const std::string &loopID) const
Definition: TraCIAPI.cpp:793
void setAccel(const std::string &typeID, SUMOReal accel) const
Definition: TraCIAPI.cpp:1759
#define VAR_SPEED
void setImperfection(const std::string &typeID, SUMOReal imperfection) const
Definition: TraCIAPI.cpp:1779
std::vector< std::string > getStringVector(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:423
SUMOReal getCOEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1894
SUMOReal getCOEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:923
SUMOReal getHCEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1899
TraCIPosition getPosition(const std::string &poiID) const
Definition: TraCIAPI.cpp:1095
#define TL_RED_YELLOW_GREEN_STATE
SUMOReal getFuelConsumption(const std::string &edgeID) const
Definition: TraCIAPI.cpp:593
#define LAST_STEP_VEHICLE_NUMBER
#define VAR_EDGE_TRAVELTIME
#define VAR_VIEW_ZOOM
#define VAR_ARRIVED_VEHICLES_NUMBER
SUMOReal getZoom(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:683
SUMOReal dist
The distance to the tls.
Definition: TraCIAPI.h:713
SUMOReal getSpeed(const std::string &typeID) const
Definition: TraCIAPI.cpp:2110
void send_commandSubscribeObjectVariable(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, const std::vector< int > &vars) const
Sends a SubscribeVariable request.
Definition: TraCIAPI.cpp:163
SUMOReal getWidth(const std::string &laneID) const
Definition: TraCIAPI.cpp:888
int getLastStepVehicleNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:628
#define CMD_SET_POLYGON_VARIABLE
#define VAR_COEMISSION
std::vector< TraCIAPI::TraCILogic > getCompleteRedYellowGreenDefinition(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1440
virtual void writeString(const std::string &s)
int getMinExpectedNumber() const
Definition: TraCIAPI.cpp:1371
#define RTYPE_NOTIMPLEMENTED
void setType(const std::string &polygonID, const std::string &setType) const
Definition: TraCIAPI.cpp:1198
SubscribedValues getSubscriptionResults()
Definition: TraCIAPI.cpp:1395
TraCIPositionVector getShape(const std::string &laneID) const
Definition: TraCIAPI.cpp:908
int getNextSwitch(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1509
#define LAST_STEP_VEHICLE_ID_LIST
#define CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE
void setEffort(const std::string &edgeID, SUMOReal effort) const
Definition: TraCIAPI.cpp:654
#define LANE_DISALLOWED
#define VAR_MOVE_TO
#define TL_PROGRAM
SUMOReal getEffort(const std::string &edgeID, SUMOTime time) const
Definition: TraCIAPI.cpp:561
SUMOTime getSUMOTime(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:313
SUMOReal getLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1884
#define TYPE_DOUBLE
SUMOReal getWaitingTime(const std::string &typeID) const
Definition: TraCIAPI.cpp:2130
SUMOReal getHCEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:578
void subscribeContext(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, int domain, SUMOReal range, const std::vector< int > &vars) const
Definition: TraCIAPI.cpp:1385
std::vector< std::string > getLastStepVehicleIDs(const std::string &detID) const
Definition: TraCIAPI.cpp:1070
void sendExact(const Storage &)
Definition: socket.cpp:398
virtual float readFloat()
SUMOReal getElectricityConsumption(const std::string &edgeID) const
Definition: TraCIAPI.cpp:603
#define TYPE_BYTE
std::string getType(const std::string &poiID) const
Definition: TraCIAPI.cpp:1090
#define CMD_SET_LANE_VARIABLE
#define VAR_ELECTRICITYCONSUMPTION
#define VAR_ROUTE_INDEX
std::string getLaneID(const std::string &loopID) const
Definition: TraCIAPI.cpp:783
std::string id
The id of the next tls.
Definition: TraCIAPI.h:709
int getIDCount() const
Definition: TraCIAPI.cpp:549
std::string getRoadID(const std::string &typeID) const
Definition: TraCIAPI.cpp:2120
void subscribe(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, const std::vector< int > &vars) const
Definition: TraCIAPI.cpp:1376
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:773
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:241
SUMOReal getNoiseEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:598
SUMOReal getAccel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1617
SUMOReal getTraveltime(const std::string &edgeID) const
Definition: TraCIAPI.cpp:623
void setZoom(const std::string &viewID, SUMOReal zoom) const
Definition: TraCIAPI.cpp:704
int getSpeedMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1935
std::string getNextEdge(const std::string &typeID) const
Definition: TraCIAPI.cpp:2135
SUMOReal getSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1829
void moveTo(const std::string &vehicleID, const std::string &laneID, SUMOReal position) const
Definition: TraCIAPI.cpp:2050
std::string subID
Definition: TraCIAPI.h:119
std::vector< std::string > getLastStepVehicleIDs(const std::string &laneID) const
Definition: TraCIAPI.cpp:988
int getDepartedNumber() const
Definition: TraCIAPI.cpp:1321
virtual void writeDouble(double)
#define VAR_TELEPORT_ENDING_VEHICLES_NUMBER
SUMOReal getLastStepLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:968
void setShape(const std::string &polygonID, const TraCIPositionVector &shape) const
Definition: TraCIAPI.cpp:1208
SUMOReal getFuelConsumption(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1914
#define VAR_MOVE_TO_VTD
void setColor(const std::string &typeID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:1799
void send_commandSetValue(int domID, int varID, const std::string &objID, tcpip::Storage &content) const
Sends a SetVariable request.
Definition: TraCIAPI.cpp:142
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1044
SUMOReal getPMxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:583
void setPosition(const std::string &poiID, SUMOReal x, SUMOReal y) const
Definition: TraCIAPI.cpp:1116
#define SUMOReal
Definition: config.h:213
int getLinkNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:903
SUMOReal getSpeedDeviation(const std::string &typeID) const
Definition: TraCIAPI.cpp:1612
int getLastStepVehicleNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:1060
SUMOReal getCO2Emission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:568
#define LAST_STEP_OCCUPANCY
#define TL_CONTROLLED_LANES
std::string getString(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:414
void setSpeedDeviation(const std::string &typeID, SUMOReal deviation) const
Definition: TraCIAPI.cpp:1709
std::string getLaneID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1849
#define VAR_MAXSPEED
SUMOReal getNOxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:588
std::vector< VehicleData > getVehicleData(const std::string &loopID) const
Definition: TraCIAPI.cpp:818
#define VAR_DECEL
#define RESPONSE_SUBSCRIBE_PERSON_VARIABLE
TraCIAPI()
Constructor.
Definition: TraCIAPI.cpp:50
#define ID_COUNT
#define VAR_LANE_INDEX
TraCIBoundary getNetBoundary() const
Definition: TraCIAPI.cpp:1366
std::vector< TraCIPosition > TraCIPositionVector
Definition: TraCIAPI.h:83
#define VAR_LANE_ID
SUMOReal getAdaptedTraveltime(const std::string &edgeID, SUMOTime time) const
Definition: TraCIAPI.cpp:554
std::vector< std::string > getEdges(const std::string &routeID) const
Definition: TraCIAPI.cpp:1283
void remove(const std::string &poiID, int layer=0) const
Definition: TraCIAPI.cpp:1162
int tlIndex
The tls index of the controlled link.
Definition: TraCIAPI.h:711
SUMOReal getFloat(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:349
std::string id
The id of the vehicle.
Definition: TraCIAPI.h:313
#define RTYPE_ERR
#define TYPE_INTEGER
#define VAR_MINGAP
#define CMD_SIMSTEP2
#define ID_LIST
SUMOReal getLength(const std::string &typeID) const
Definition: TraCIAPI.cpp:1597
#define ADD_FULL
SUMOReal getTau(const std::string &typeID) const
Definition: TraCIAPI.cpp:1632
#define TL_PHASE_INDEX
#define VAR_ARRIVED_VEHICLES_IDS
std::vector< std::string > getLastStepVehicleIDs(const std::string &edgeID) const
Definition: TraCIAPI.cpp:638
A list of positions.
int getLoadedNumber() const
Definition: TraCIAPI.cpp:1311
#define VAR_VIEW_OFFSET
#define LAST_STEP_VEHICLE_HALTING_NUMBER
SUMOReal getFuelConsumption(const std::string &laneID) const
Definition: TraCIAPI.cpp:943
virtual int readByte()
#define VAR_HCEMISSION
void setColor(const std::string &poiID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:1127
void close()
Definition: socket.cpp:349
void add(const std::string &routeID, const std::vector< std::string > &edges) const
Definition: TraCIAPI.cpp:1289
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1055
void setPhaseDuration(const std::string &tlsID, int phaseDuration) const
Definition: TraCIAPI.cpp:1545
A 3D-position.
Definition: TraCIAPI.h:69
#define VAR_WIDTH
SUMOReal getLastStepHaltingNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:633
std::vector< std::string > getStartingTeleportIDList() const
Definition: TraCIAPI.cpp:1346
SUMOReal getNOxEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:1909