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"
36 #include <utils/common/ToString.h>
37 
38 #ifdef CHECK_MEMORY_LEAKS
39 #include <foreign/nvwa/debug_new.h>
40 #endif // CHECK_MEMORY_LEAKS
41 
42 
43 // ===========================================================================
44 // member definitions
45 // ===========================================================================
46 // ---------------------------------------------------------------------------
47 // TraCIAPI-methods
48 // ---------------------------------------------------------------------------
49 #ifdef _MSC_VER
50 #pragma warning(disable: 4355)
51 #endif
53  : edge(*this), gui(*this), inductionloop(*this),
54  junction(*this), lane(*this), multientryexit(*this), poi(*this),
55  polygon(*this), route(*this), simulation(*this), trafficlights(*this),
56  vehicletype(*this), vehicle(*this),
57  mySocket(0) {}
58 #ifdef _MSC_VER
59 #pragma warning(default: 4355)
60 #endif
61 
62 
64  delete mySocket;
65 }
66 
67 
68 void
69 TraCIAPI::connect(const std::string& host, int port) {
70  mySocket = new tcpip::Socket(host, port);
71  try {
72  mySocket->connect();
73  } catch (tcpip::SocketException&) {
74  delete mySocket;
75  mySocket = 0;
76  throw;
77  }
78 }
79 
80 
81 void
83  if (mySocket == 0) {
84  return;
85  }
86  mySocket->close();
87  delete mySocket;
88  mySocket = 0;
89 }
90 
91 
92 void
94  tcpip::Storage outMsg;
95  // command length
96  outMsg.writeUnsignedByte(1 + 1 + 4);
97  // command id
99  outMsg.writeInt((int)time);
100  // send request message
101  mySocket->sendExact(outMsg);
102 }
103 
104 
105 void
107  tcpip::Storage outMsg;
108  // command length
109  outMsg.writeUnsignedByte(1 + 1);
110  // command id
112  mySocket->sendExact(outMsg);
113 }
114 
115 
116 void
117 TraCIAPI::send_commandGetVariable(int domID, int varID, const std::string& objID, tcpip::Storage* add) const {
118  if (mySocket == 0) {
119  throw tcpip::SocketException("Socket is not initialised");
120  }
121  tcpip::Storage outMsg;
122  // command length
123  unsigned int length = 1 + 1 + 1 + 4 + (int) objID.length();
124  if (add != 0) {
125  length += (int)add->size();
126  }
127  outMsg.writeUnsignedByte(length);
128  // command id
129  outMsg.writeUnsignedByte(domID);
130  // variable id
131  outMsg.writeUnsignedByte(varID);
132  // object id
133  outMsg.writeString(objID);
134  // additional values
135  if (add != 0) {
136  outMsg.writeStorage(*add);
137  }
138  // send request message
139  mySocket->sendExact(outMsg);
140 }
141 
142 
143 void
144 TraCIAPI::send_commandSetValue(int domID, int varID, const std::string& objID, tcpip::Storage& content) const {
145  if (mySocket == 0) {
146  throw tcpip::SocketException("Socket is not initialised");
147  }
148  tcpip::Storage outMsg;
149  // command length (domID, varID, objID, dataType, data)
150  outMsg.writeUnsignedByte(1 + 1 + 1 + 4 + (int) objID.length() + (int)content.size());
151  // command id
152  outMsg.writeUnsignedByte(domID);
153  // variable id
154  outMsg.writeUnsignedByte(varID);
155  // object id
156  outMsg.writeString(objID);
157  // data type
158  outMsg.writeStorage(content);
159  // send message
160  mySocket->sendExact(outMsg);
161 }
162 
163 
164 void
165 TraCIAPI::send_commandSubscribeObjectVariable(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime,
166  const std::vector<int>& vars) const {
167  if (mySocket == 0) {
168  throw tcpip::SocketException("Socket is not initialised");
169  }
170  tcpip::Storage outMsg;
171  // command length (domID, objID, beginTime, endTime, length, vars)
172  int varNo = (int) vars.size();
173  outMsg.writeUnsignedByte(0);
174  outMsg.writeInt(5 + 1 + 4 + 4 + 4 + (int) objID.length() + 1 + varNo);
175  // command id
176  outMsg.writeUnsignedByte(domID);
177  // time
178  outMsg.writeInt((int)beginTime);
179  outMsg.writeInt((int)endTime);
180  // object id
181  outMsg.writeString(objID);
182  // command id
183  outMsg.writeUnsignedByte((int)vars.size());
184  for (int i = 0; i < varNo; ++i) {
185  outMsg.writeUnsignedByte(vars[i]);
186  }
187  // send message
188  mySocket->sendExact(outMsg);
189 }
190 
191 
192 void
193 TraCIAPI::send_commandSubscribeObjectContext(int domID, const std::string& objID, SUMOTime beginTime, SUMOTime endTime,
194  int domain, SUMOReal range, const std::vector<int>& vars) const {
195  if (mySocket == 0) {
196  throw tcpip::SocketException("Socket is not initialised");
197  }
198  tcpip::Storage outMsg;
199  // command length (domID, objID, beginTime, endTime, length, vars)
200  int varNo = (int) vars.size();
201  outMsg.writeUnsignedByte(0);
202  outMsg.writeInt(5 + 1 + 4 + 4 + 4 + (int) objID.length() + 1 + 8 + 1 + varNo);
203  // command id
204  outMsg.writeUnsignedByte(domID);
205  // time
206  outMsg.writeInt((int)beginTime);
207  outMsg.writeInt((int)endTime);
208  // object id
209  outMsg.writeString(objID);
210  // domain and range
211  outMsg.writeUnsignedByte(domain);
212  outMsg.writeDouble(range);
213  // command id
214  outMsg.writeUnsignedByte((int)vars.size());
215  for (int i = 0; i < varNo; ++i) {
216  outMsg.writeUnsignedByte(vars[i]);
217  }
218  // send message
219  mySocket->sendExact(outMsg);
220 }
221 
222 
223 
224 
225 void
226 TraCIAPI::check_resultState(tcpip::Storage& inMsg, int command, bool ignoreCommandId, std::string* acknowledgement) const {
227  mySocket->receiveExact(inMsg);
228  int cmdLength;
229  int cmdId;
230  int resultType;
231  int cmdStart;
232  std::string msg;
233  try {
234  cmdStart = inMsg.position();
235  cmdLength = inMsg.readUnsignedByte();
236  cmdId = inMsg.readUnsignedByte();
237  if (command != cmdId && !ignoreCommandId) {
238  throw tcpip::SocketException("#Error: received status response to command: " + toString(cmdId) + " but expected: " + toString(command));
239  }
240  resultType = inMsg.readUnsignedByte();
241  msg = inMsg.readString();
242  } catch (std::invalid_argument&) {
243  throw tcpip::SocketException("#Error: an exception was thrown while reading result state message");
244  }
245  switch (resultType) {
246  case RTYPE_ERR:
247  throw tcpip::SocketException(".. Answered with error to command (" + toString(command) + "), [description: " + msg + "]");
249  throw tcpip::SocketException(".. Sent command is not implemented (" + toString(command) + "), [description: " + msg + "]");
250  case RTYPE_OK:
251  if (acknowledgement != 0) {
252  (*acknowledgement) = ".. Command acknowledged (" + toString(command) + "), [description: " + msg + "]";
253  }
254  break;
255  default:
256  throw tcpip::SocketException(".. Answered with unknown result code(" + toString(resultType) + ") to command(" + toString(command) + "), [description: " + msg + "]");
257  }
258  if ((cmdStart + cmdLength) != (int) inMsg.position()) {
259  throw tcpip::SocketException("#Error: command at position " + toString(cmdStart) + " has wrong length");
260  }
261 }
262 
263 
264 void
265 TraCIAPI::check_commandGetResult(tcpip::Storage& inMsg, int command, int expectedType, bool ignoreCommandId) const {
266  inMsg.position(); // respStart
267  int length = inMsg.readUnsignedByte();
268  if (length == 0) {
269  length = inMsg.readInt();
270  }
271  int cmdId = inMsg.readUnsignedByte();
272  if (!ignoreCommandId && cmdId != (command + 0x10)) {
273  throw tcpip::SocketException("#Error: received response with command id: " + toString(cmdId) + "but expected: " + toString(command + 0x10));
274  }
275  if (expectedType >= 0) {
276  // not called from the TraCITestClient but from within the TraCIAPI
277  inMsg.readUnsignedByte(); // variableID
278  inMsg.readString(); // objectID
279  int valueDataType = inMsg.readUnsignedByte();
280  if (valueDataType != expectedType) {
281  throw tcpip::SocketException("Expected " + toString(expectedType) + " but got " + toString(valueDataType));
282  }
283  }
284 }
285 
286 
287 void
288 TraCIAPI::processGET(tcpip::Storage& inMsg, int command, int expectedType, bool ignoreCommandId) const {
289  check_resultState(inMsg, command, ignoreCommandId);
290  check_commandGetResult(inMsg, command, expectedType, ignoreCommandId);
291 }
292 
293 
294 
295 
296 SUMOTime
297 TraCIAPI::getSUMOTime(int cmd, int var, const std::string& id, tcpip::Storage* add) {
298  tcpip::Storage inMsg;
299  send_commandGetVariable(cmd, var, id, add);
300  processGET(inMsg, cmd, TYPE_INTEGER);
301  return inMsg.readInt();
302 }
303 
304 
305 int
306 TraCIAPI::getUnsignedByte(int cmd, int var, const std::string& id, tcpip::Storage* add) {
307  tcpip::Storage inMsg;
308  send_commandGetVariable(cmd, var, id, add);
309  processGET(inMsg, cmd, TYPE_UBYTE);
310  return inMsg.readUnsignedByte();
311 }
312 
313 
314 int
315 TraCIAPI::getByte(int cmd, int var, const std::string& id, tcpip::Storage* add) {
316  tcpip::Storage inMsg;
317  send_commandGetVariable(cmd, var, id, add);
318  processGET(inMsg, cmd, TYPE_BYTE);
319  return inMsg.readByte();
320 }
321 
322 
323 int
324 TraCIAPI::getInt(int cmd, int var, const std::string& id, tcpip::Storage* add) {
325  tcpip::Storage inMsg;
326  send_commandGetVariable(cmd, var, id, add);
327  processGET(inMsg, cmd, TYPE_INTEGER);
328  return inMsg.readInt();
329 }
330 
331 
332 SUMOReal
333 TraCIAPI::getFloat(int cmd, int var, const std::string& id, tcpip::Storage* add) {
334  tcpip::Storage inMsg;
335  send_commandGetVariable(cmd, var, id, add);
336  processGET(inMsg, cmd, TYPE_FLOAT);
337  return inMsg.readFloat();
338 }
339 
340 
341 SUMOReal
342 TraCIAPI::getDouble(int cmd, int var, const std::string& id, tcpip::Storage* add) {
343  tcpip::Storage inMsg;
344  send_commandGetVariable(cmd, var, id, add);
345  processGET(inMsg, cmd, TYPE_DOUBLE);
346  return inMsg.readDouble();
347 }
348 
349 
351 TraCIAPI::getBoundingBox(int cmd, int var, const std::string& id, tcpip::Storage* add) {
352  tcpip::Storage inMsg;
353  send_commandGetVariable(cmd, var, id, add);
354  processGET(inMsg, cmd, TYPE_BOUNDINGBOX);
355  TraCIBoundary b;
356  b.xMin = inMsg.readDouble();
357  b.yMin = inMsg.readDouble();
358  b.zMin = 0;
359  b.xMax = inMsg.readDouble();
360  b.yMax = inMsg.readDouble();
361  b.zMax = 0;
362  return b;
363 }
364 
365 
367 TraCIAPI::getPolygon(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_POLYGON);
371  unsigned int size = inMsg.readInt();
373  for (unsigned int i = 0; i < size; ++i) {
374  TraCIPosition p;
375  p.x = inMsg.readDouble();
376  p.y = inMsg.readDouble();
377  p.z = 0;
378  ret.push_back(p);
379  }
380  return ret;
381 }
382 
383 
385 TraCIAPI::getPosition(int cmd, int var, const std::string& id, tcpip::Storage* add) {
386  tcpip::Storage inMsg;
387  send_commandGetVariable(cmd, var, id, add);
388  processGET(inMsg, cmd, POSITION_2D);
389  TraCIPosition p;
390  p.x = inMsg.readDouble();
391  p.y = inMsg.readDouble();
392  p.z = 0;
393  return p;
394 }
395 
396 
397 std::string
398 TraCIAPI::getString(int cmd, int var, const std::string& id, tcpip::Storage* add) {
399  tcpip::Storage inMsg;
400  send_commandGetVariable(cmd, var, id, add);
401  processGET(inMsg, cmd, TYPE_STRING);
402  return inMsg.readString();
403 }
404 
405 
406 std::vector<std::string>
407 TraCIAPI::getStringVector(int cmd, int var, const std::string& id, tcpip::Storage* add) {
408  tcpip::Storage inMsg;
409  send_commandGetVariable(cmd, var, id, add);
410  processGET(inMsg, cmd, TYPE_STRINGLIST);
411  unsigned int size = inMsg.readInt();
412  std::vector<std::string> r;
413  for (unsigned int i = 0; i < size; ++i) {
414  r.push_back(inMsg.readString());
415  }
416  return r;
417 }
418 
419 
421 TraCIAPI::getColor(int cmd, int var, const std::string& id, tcpip::Storage* add) {
422  tcpip::Storage inMsg;
423  send_commandGetVariable(cmd, var, id, add);
424  processGET(inMsg, cmd, TYPE_COLOR);
425  TraCIColor c;
426  c.r = inMsg.readUnsignedByte();
427  c.g = inMsg.readUnsignedByte();
428  c.b = inMsg.readUnsignedByte();
429  c.a = inMsg.readUnsignedByte();
430  return c;
431 }
432 
433 
434 void
437  tcpip::Storage inMsg;
439 }
440 
441 
442 // ---------------------------------------------------------------------------
443 // TraCIAPI::EdgeScope-methods
444 // ---------------------------------------------------------------------------
445 std::vector<std::string>
447  return myParent.getStringVector(CMD_GET_EDGE_VARIABLE, ID_LIST, "");
448 }
449 
450 unsigned int
452  return myParent.getInt(CMD_GET_EDGE_VARIABLE, ID_COUNT, "");
453 }
454 
455 SUMOReal
456 TraCIAPI::EdgeScope::getAdaptedTraveltime(const std::string& edgeID, SUMOTime time) const {
457  tcpip::Storage content;
458  content.writeInt((int)time);
459  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CO2EMISSION, edgeID, &content);
460 }
461 
462 SUMOReal
463 TraCIAPI::EdgeScope::getEffort(const std::string& edgeID, SUMOTime time) const {
464  tcpip::Storage content;
465  content.writeInt((int)time);
466  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CO2EMISSION, edgeID, &content);
467 }
468 
469 SUMOReal
470 TraCIAPI::EdgeScope::getCO2Emission(const std::string& edgeID) const {
471  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CO2EMISSION, edgeID);
472 }
473 
474 SUMOReal
475 TraCIAPI::EdgeScope::getCOEmission(const std::string& edgeID) const {
476  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_COEMISSION, edgeID);
477 }
478 
479 SUMOReal
480 TraCIAPI::EdgeScope::getHCEmission(const std::string& edgeID) const {
481  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_HCEMISSION, edgeID);
482 }
483 
484 SUMOReal
485 TraCIAPI::EdgeScope::getPMxEmission(const std::string& edgeID) const {
486  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_PMXEMISSION, edgeID);
487 }
488 
489 SUMOReal
490 TraCIAPI::EdgeScope::getNOxEmission(const std::string& edgeID) const {
491  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_NOXEMISSION, edgeID);
492 }
493 
494 SUMOReal
495 TraCIAPI::EdgeScope::getFuelConsumption(const std::string& edgeID) const {
496  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_FUELCONSUMPTION, edgeID);
497 }
498 
499 SUMOReal
500 TraCIAPI::EdgeScope::getNoiseEmission(const std::string& edgeID) const {
501  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_NOISEEMISSION, edgeID);
502 }
503 
504 SUMOReal
505 TraCIAPI::EdgeScope::getLastStepMeanSpeed(const std::string& edgeID) const {
506  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_MEAN_SPEED, edgeID);
507 }
508 
509 SUMOReal
510 TraCIAPI::EdgeScope::getLastStepOccupancy(const std::string& edgeID) const {
511  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_OCCUPANCY, edgeID);
512 }
513 
514 SUMOReal
515 TraCIAPI::EdgeScope::getLastStepLength(const std::string& edgeID) const {
516  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_LENGTH, edgeID);
517 }
518 
519 SUMOReal
520 TraCIAPI::EdgeScope::getTraveltime(const std::string& edgeID) const {
521  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CURRENT_TRAVELTIME, edgeID);
522 }
523 
524 unsigned int
525 TraCIAPI::EdgeScope::getLastStepVehicleNumber(const std::string& edgeID) const {
526  return myParent.getInt(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_NUMBER, edgeID);
527 }
528 
529 SUMOReal
530 TraCIAPI::EdgeScope::getLastStepHaltingNumber(const std::string& edgeID) const {
531  return myParent.getInt(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_HALTING_NUMBER, edgeID);
532 }
533 
534 std::vector<std::string>
535 TraCIAPI::EdgeScope::getLastStepVehicleIDs(const std::string& edgeID) const {
536  return myParent.getStringVector(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, edgeID);
537 }
538 
539 
540 
541 void
542 TraCIAPI::EdgeScope::adaptTraveltime(const std::string& edgeID, SUMOReal time) const {
543  tcpip::Storage content;
544  content.writeDouble(time);
545  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_EDGE_TRAVELTIME, edgeID, content);
546  tcpip::Storage inMsg;
547  myParent.check_resultState(inMsg, CMD_SET_EDGE_VARIABLE);
548 }
549 
550 void
551 TraCIAPI::EdgeScope::setEffort(const std::string& edgeID, SUMOReal effort) const {
552  tcpip::Storage content;
553  content.writeDouble(effort);
554  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_EDGE_EFFORT, edgeID, content);
555  tcpip::Storage inMsg;
556  myParent.check_resultState(inMsg, CMD_SET_EDGE_VARIABLE);
557 }
558 
559 void
560 TraCIAPI::EdgeScope::setMaxSpeed(const std::string& edgeID, SUMOReal speed) const {
561  tcpip::Storage content;
562  content.writeDouble(speed);
563  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_MAXSPEED, edgeID, content);
564  tcpip::Storage inMsg;
565  myParent.check_resultState(inMsg, CMD_SET_EDGE_VARIABLE);
566 }
567 
568 
569 
570 
571 // ---------------------------------------------------------------------------
572 // TraCIAPI::GUIScope-methods
573 // ---------------------------------------------------------------------------
574 std::vector<std::string>
576  return myParent.getStringVector(CMD_GET_GUI_VARIABLE, ID_LIST, "");
577 }
578 
579 SUMOReal
580 TraCIAPI::GUIScope::getZoom(const std::string& viewID) const {
581  return myParent.getDouble(CMD_GET_GUI_VARIABLE, VAR_VIEW_ZOOM, viewID);
582 }
583 
585 TraCIAPI::GUIScope::getOffset(const std::string& viewID) const {
586  return myParent.getPosition(CMD_GET_GUI_VARIABLE, VAR_VIEW_OFFSET, viewID);
587 }
588 
589 std::string
590 TraCIAPI::GUIScope::getSchema(const std::string& viewID) const {
591  return myParent.getString(CMD_GET_GUI_VARIABLE, VAR_VIEW_SCHEMA, viewID);
592 }
593 
595 TraCIAPI::GUIScope::getBoundary(const std::string& viewID) const {
596  return myParent.getBoundingBox(CMD_GET_GUI_VARIABLE, VAR_VIEW_BOUNDARY, viewID);
597 }
598 
599 
600 void
601 TraCIAPI::GUIScope::setZoom(const std::string& viewID, SUMOReal zoom) const {
602  tcpip::Storage content;
603  content.writeDouble(zoom);
604  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_ZOOM, viewID, content);
605  tcpip::Storage inMsg;
606  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
607 }
608 
609 void
610 TraCIAPI::GUIScope::setOffset(const std::string& viewID, SUMOReal x, SUMOReal y) const {
611  tcpip::Storage content;
613  content.writeDouble(x);
614  content.writeDouble(y);
615  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_OFFSET, viewID, content);
616  tcpip::Storage inMsg;
617  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
618 }
619 
620 void
621 TraCIAPI::GUIScope::setSchema(const std::string& viewID, const std::string& schemeName) const {
622  tcpip::Storage content;
624  content.writeString(schemeName);
625  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_SCHEMA, viewID, content);
626  tcpip::Storage inMsg;
627  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
628 }
629 
630 void
631 TraCIAPI::GUIScope::setBoundary(const std::string& viewID, SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax) const {
632  tcpip::Storage content;
634  content.writeDouble(xmin);
635  content.writeDouble(ymin);
636  content.writeDouble(xmax);
637  content.writeDouble(ymax);
638  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_BOUNDARY, viewID, content);
639  tcpip::Storage inMsg;
640  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
641 }
642 
643 void
644 TraCIAPI::GUIScope::screenshot(const std::string& viewID, const std::string& filename) const {
645  tcpip::Storage content;
646  content.writeString(filename);
647  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_SCREENSHOT, viewID, content);
648  tcpip::Storage inMsg;
649  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
650 }
651 
652 void
653 TraCIAPI::GUIScope::trackVehicle(const std::string& viewID, const std::string& vehID) const {
654  tcpip::Storage content;
655  content.writeString(vehID);
656  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_TRACK_VEHICLE, viewID, content);
657  tcpip::Storage inMsg;
658  myParent.check_resultState(inMsg, CMD_SET_GUI_VARIABLE);
659 }
660 
661 
662 
663 
664 // ---------------------------------------------------------------------------
665 // TraCIAPI::InductionLoopScope-methods
666 // ---------------------------------------------------------------------------
667 std::vector<std::string>
669  return myParent.getStringVector(CMD_GET_INDUCTIONLOOP_VARIABLE, ID_LIST, "");
670 }
671 
672 SUMOReal
673 TraCIAPI::InductionLoopScope::getPosition(const std::string& loopID) const {
674  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, VAR_POSITION, loopID);
675 }
676 
677 std::string
678 TraCIAPI::InductionLoopScope::getLaneID(const std::string& loopID) const {
679  return myParent.getString(CMD_GET_INDUCTIONLOOP_VARIABLE, VAR_LANE_ID, loopID);
680 }
681 
682 unsigned int
684  return myParent.getInt(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_NUMBER, loopID);
685 }
686 
687 SUMOReal
688 TraCIAPI::InductionLoopScope::getLastStepMeanSpeed(const std::string& loopID) const {
689  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_MEAN_SPEED, loopID);
690 }
691 
692 std::vector<std::string>
693 TraCIAPI::InductionLoopScope::getLastStepVehicleIDs(const std::string& loopID) const {
694  return myParent.getStringVector(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, loopID);
695 }
696 
697 SUMOReal
698 TraCIAPI::InductionLoopScope::getLastStepOccupancy(const std::string& loopID) const {
699  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_OCCUPANCY, loopID);
700 }
701 
702 SUMOReal
703 TraCIAPI::InductionLoopScope::getLastStepMeanLength(const std::string& loopID) const {
704  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_LENGTH, loopID);
705 }
706 
707 SUMOReal
708 TraCIAPI::InductionLoopScope::getTimeSinceDetection(const std::string& loopID) const {
709  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_TIME_SINCE_DETECTION, loopID);
710 }
711 
712 std::vector<TraCIAPI::InductionLoopScope::VehicleData>
713 TraCIAPI::InductionLoopScope::getVehicleData(const std::string& loopID) const {
714  tcpip::Storage inMsg;
715  myParent.send_commandGetVariable(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_DATA, loopID);
716  myParent.processGET(inMsg, CMD_GET_INDUCTIONLOOP_VARIABLE, TYPE_COMPOUND);
717  std::vector<VehicleData> result;
718  inMsg.readInt(); // components
719  // number of items
720  inMsg.readUnsignedByte();
721  const int n = inMsg.readInt();
722  for (int i = 0; i < n; ++i) {
723  VehicleData vd;
724 
725  inMsg.readUnsignedByte();
726  vd.id = inMsg.readString();
727 
728  inMsg.readUnsignedByte();
729  vd.length = inMsg.readDouble();
730 
731  inMsg.readUnsignedByte();
732  vd.entryTime = inMsg.readDouble();
733 
734  inMsg.readUnsignedByte();
735  vd.leaveTime = inMsg.readDouble();
736 
737  inMsg.readUnsignedByte();
738  vd.typeID = inMsg.readString();
739 
740  result.push_back(vd);
741  }
742  return result;
743 }
744 
745 
746 
747 
748 // ---------------------------------------------------------------------------
749 // TraCIAPI::JunctionScope-methods
750 // ---------------------------------------------------------------------------
751 std::vector<std::string>
753  return myParent.getStringVector(CMD_GET_JUNCTION_VARIABLE, ID_LIST, "");
754 }
755 
757 TraCIAPI::JunctionScope::getPosition(const std::string& junctionID) const {
758  return myParent.getPosition(CMD_GET_JUNCTION_VARIABLE, VAR_POSITION, junctionID);
759 }
760 
761 
762 
763 
764 // ---------------------------------------------------------------------------
765 // TraCIAPI::LaneScope-methods
766 // ---------------------------------------------------------------------------
767 std::vector<std::string>
769  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, ID_LIST, "");
770 }
771 
772 SUMOReal
773 TraCIAPI::LaneScope::getLength(const std::string& laneID) const {
774  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_LENGTH, laneID);
775 }
776 
777 SUMOReal
778 TraCIAPI::LaneScope::getMaxSpeed(const std::string& laneID) const {
779  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_MAXSPEED, laneID);
780 }
781 
782 SUMOReal
783 TraCIAPI::LaneScope::getWidth(const std::string& laneID) const {
784  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_WIDTH, laneID);
785 }
786 
787 std::vector<std::string>
788 TraCIAPI::LaneScope::getAllowed(const std::string& laneID) const {
789  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, LANE_ALLOWED, laneID);
790 }
791 
792 std::vector<std::string>
793 TraCIAPI::LaneScope::getDisallowed(const std::string& laneID) const {
794  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, LANE_DISALLOWED, laneID);
795 }
796 
797 unsigned int
798 TraCIAPI::LaneScope::getLinkNumber(const std::string& /* laneID */) const {
799  throw tcpip::SocketException("Not implemented!");
800 }
801 
803 TraCIAPI::LaneScope::getShape(const std::string& laneID) const {
804  throw myParent.getPolygon(CMD_GET_LANE_VARIABLE, VAR_SHAPE, laneID);
805 }
806 
807 std::string
808 TraCIAPI::LaneScope::getEdgeID(const std::string& laneID) const {
809  throw myParent.getString(CMD_GET_LANE_VARIABLE, LANE_EDGE_ID, laneID);
810 }
811 
812 SUMOReal
813 TraCIAPI::LaneScope::getCO2Emission(const std::string& laneID) const {
814  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_CO2EMISSION, laneID);
815 }
816 
817 SUMOReal
818 TraCIAPI::LaneScope::getCOEmission(const std::string& laneID) const {
819  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_COEMISSION, laneID);
820 }
821 
822 SUMOReal
823 TraCIAPI::LaneScope::getHCEmission(const std::string& laneID) const {
824  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_HCEMISSION, laneID);
825 }
826 
827 SUMOReal
828 TraCIAPI::LaneScope::getPMxEmission(const std::string& laneID) const {
829  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_PMXEMISSION, laneID);
830 }
831 
832 SUMOReal
833 TraCIAPI::LaneScope::getNOxEmission(const std::string& laneID) const {
834  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_NOXEMISSION, laneID);
835 }
836 
837 SUMOReal
838 TraCIAPI::LaneScope::getFuelConsumption(const std::string& laneID) const {
839  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_FUELCONSUMPTION, laneID);
840 }
841 
842 SUMOReal
843 TraCIAPI::LaneScope::getNoiseEmission(const std::string& laneID) const {
844  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_NOISEEMISSION, laneID);
845 }
846 
847 SUMOReal
848 TraCIAPI::LaneScope::getLastStepMeanSpeed(const std::string& laneID) const {
849  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_MEAN_SPEED, laneID);
850 }
851 
852 SUMOReal
853 TraCIAPI::LaneScope::getLastStepOccupancy(const std::string& laneID) const {
854  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_OCCUPANCY, laneID);
855 }
856 
857 SUMOReal
858 TraCIAPI::LaneScope::getLastStepLength(const std::string& laneID) const {
859  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_LENGTH, laneID);
860 }
861 
862 SUMOReal
863 TraCIAPI::LaneScope::getTraveltime(const std::string& laneID) const {
864  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_CURRENT_TRAVELTIME, laneID);
865 }
866 
867 unsigned int
868 TraCIAPI::LaneScope::getLastStepVehicleNumber(const std::string& laneID) const {
869  throw myParent.getInt(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_NUMBER, laneID);
870 }
871 
872 unsigned int
873 TraCIAPI::LaneScope::getLastStepHaltingNumber(const std::string& laneID) const {
874  throw myParent.getInt(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_HALTING_NUMBER, laneID);
875 }
876 
877 std::vector<std::string>
878 TraCIAPI::LaneScope::getLastStepVehicleIDs(const std::string& laneID) const {
879  throw myParent.getStringVector(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, laneID);
880 }
881 
882 
883 void
884 TraCIAPI::LaneScope::setAllowed(const std::string& laneID, const std::vector<std::string>& allowedClasses) const {
885  tcpip::Storage content;
887  content.writeInt((int)allowedClasses.size());
888  for (unsigned int i = 0; i < allowedClasses.size(); ++i) {
889  content.writeString(allowedClasses[i]);
890  }
891  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, LANE_ALLOWED, laneID, content);
892  tcpip::Storage inMsg;
893  myParent.check_resultState(inMsg, CMD_SET_LANE_VARIABLE);
894 }
895 
896 void
897 TraCIAPI::LaneScope::setDisallowed(const std::string& laneID, const std::vector<std::string>& disallowedClasses) const {
898  tcpip::Storage content;
900  content.writeInt((int)disallowedClasses.size());
901  for (unsigned int i = 0; i < disallowedClasses.size(); ++i) {
902  content.writeString(disallowedClasses[i]);
903  }
904  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, LANE_DISALLOWED, laneID, content);
905  tcpip::Storage inMsg;
906  myParent.check_resultState(inMsg, CMD_SET_LANE_VARIABLE);
907 }
908 
909 void
910 TraCIAPI::LaneScope::setMaxSpeed(const std::string& laneID, SUMOReal speed) const {
911  tcpip::Storage content;
913  content.writeDouble(speed);
914  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, VAR_MAXSPEED, laneID, content);
915  tcpip::Storage inMsg;
916  myParent.check_resultState(inMsg, CMD_SET_LANE_VARIABLE);
917 }
918 
919 void
920 TraCIAPI::LaneScope::setLength(const std::string& laneID, SUMOReal length) const {
921  tcpip::Storage content;
923  content.writeDouble(length);
924  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, VAR_LENGTH, laneID, content);
925  tcpip::Storage inMsg;
926  myParent.check_resultState(inMsg, CMD_SET_LANE_VARIABLE);
927 }
928 
929 
930 // ---------------------------------------------------------------------------
931 // TraCIAPI::AreaDetector-methods
932 // ---------------------------------------------------------------------------
933 std::vector<std::string>
935  return myParent.getStringVector(CMD_GET_AREAL_DETECTOR_VARIABLE, ID_LIST, "");
936 }
937 
938 
939 
940 
941 // ---------------------------------------------------------------------------
942 // TraCIAPI::MeMeScope-methods
943 // ---------------------------------------------------------------------------
944 std::vector<std::string>
946  return myParent.getStringVector(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, ID_LIST, "");
947 }
948 
949 unsigned int
950 TraCIAPI::MeMeScope::getLastStepVehicleNumber(const std::string& detID) const {
952 }
953 
954 SUMOReal
955 TraCIAPI::MeMeScope::getLastStepMeanSpeed(const std::string& detID) const {
957 }
958 
959 std::vector<std::string>
960 TraCIAPI::MeMeScope::getLastStepVehicleIDs(const std::string& detID) const {
961  return myParent.getStringVector(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, detID);
962 }
963 
964 unsigned int
965 TraCIAPI::MeMeScope::getLastStepHaltingNumber(const std::string& detID) const {
967 }
968 
969 
970 
971 // ---------------------------------------------------------------------------
972 // TraCIAPI::POIScope-methods
973 // ---------------------------------------------------------------------------
974 std::vector<std::string>
976  return myParent.getStringVector(CMD_GET_POI_VARIABLE, ID_LIST, "");
977 }
978 
979 std::string
980 TraCIAPI::POIScope::getType(const std::string& poiID) const {
981  return myParent.getString(CMD_GET_POI_VARIABLE, VAR_TYPE, poiID);
982 }
983 
985 TraCIAPI::POIScope::getPosition(const std::string& poiID) const {
986  return myParent.getPosition(CMD_GET_POI_VARIABLE, VAR_POSITION, poiID);
987 }
988 
990 TraCIAPI::POIScope::getColor(const std::string& poiID) const {
991  return myParent.getColor(CMD_GET_POI_VARIABLE, VAR_COLOR, poiID);
992 }
993 
994 
995 void
996 TraCIAPI::POIScope::setType(const std::string& poiID, const std::string& setType) const {
997  tcpip::Storage content;
999  content.writeString(setType);
1000  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_TYPE, poiID, content);
1001  tcpip::Storage inMsg;
1002  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1003 }
1004 
1005 void
1006 TraCIAPI::POIScope::setPosition(const std::string& poiID, SUMOReal x, SUMOReal y) const {
1007  tcpip::Storage content;
1008  content.writeUnsignedByte(POSITION_2D);
1009  content.writeDouble(x);
1010  content.writeDouble(y);
1011  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_POSITION, poiID, content);
1012  tcpip::Storage inMsg;
1013  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1014 }
1015 
1016 void
1017 TraCIAPI::POIScope::setColor(const std::string& poiID, const TraCIColor& c) const {
1018  tcpip::Storage content;
1019  content.writeUnsignedByte(TYPE_COLOR);
1020  content.writeUnsignedByte(c.r);
1021  content.writeUnsignedByte(c.g);
1022  content.writeUnsignedByte(c.b);
1023  content.writeUnsignedByte(c.a);
1024  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_COLOR, poiID, content);
1025  tcpip::Storage inMsg;
1026  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1027 }
1028 
1029 void
1030 TraCIAPI::POIScope::add(const std::string& poiID, SUMOReal x, SUMOReal y, const TraCIColor& c, const std::string& type, int layer) const {
1031  tcpip::Storage content;
1033  content.writeInt(4);
1034  content.writeUnsignedByte(TYPE_STRING);
1035  content.writeString(type);
1036  content.writeUnsignedByte(TYPE_COLOR);
1037  content.writeUnsignedByte(c.r);
1038  content.writeUnsignedByte(c.g);
1039  content.writeUnsignedByte(c.b);
1040  content.writeUnsignedByte(c.a);
1042  content.writeInt(layer);
1043  content.writeUnsignedByte(POSITION_2D);
1044  content.writeDouble(x);
1045  content.writeDouble(y);
1046  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, ADD, poiID, content);
1047  tcpip::Storage inMsg;
1048  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1049 }
1050 
1051 void
1052 TraCIAPI::POIScope::remove(const std::string& poiID, int layer) const {
1053  tcpip::Storage content;
1055  content.writeInt(layer);
1056  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, REMOVE, poiID, content);
1057  tcpip::Storage inMsg;
1058  myParent.check_resultState(inMsg, CMD_SET_POI_VARIABLE);
1059 }
1060 
1061 
1062 
1063 // ---------------------------------------------------------------------------
1064 // TraCIAPI::PolygonScope-methods
1065 // ---------------------------------------------------------------------------
1066 std::vector<std::string>
1068  return myParent.getStringVector(CMD_GET_POLYGON_VARIABLE, ID_LIST, "");
1069 }
1070 
1071 std::string
1072 TraCIAPI::PolygonScope::getType(const std::string& polygonID) const {
1073  return myParent.getString(CMD_GET_POLYGON_VARIABLE, VAR_TYPE, polygonID);
1074 }
1075 
1077 TraCIAPI::PolygonScope::getShape(const std::string& polygonID) const {
1078  return myParent.getPolygon(CMD_GET_POLYGON_VARIABLE, VAR_SHAPE, polygonID);
1079 }
1080 
1082 TraCIAPI::PolygonScope::getColor(const std::string& polygonID) const {
1083  return myParent.getColor(CMD_GET_POLYGON_VARIABLE, VAR_COLOR, polygonID);
1084 }
1085 
1086 
1087 void
1088 TraCIAPI::PolygonScope::setType(const std::string& polygonID, const std::string& setType) const {
1089  tcpip::Storage content;
1090  content.writeUnsignedByte(TYPE_STRING);
1091  content.writeString(setType);
1092  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_TYPE, polygonID, content);
1093  tcpip::Storage inMsg;
1094  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1095 }
1096 
1097 void
1098 TraCIAPI::PolygonScope::setShape(const std::string& polygonID, const TraCIAPI::TraCIPositionVector& shape) const {
1099  tcpip::Storage content;
1101  content.writeInt((int)shape.size());
1102  for (unsigned int i = 0; i < shape.size(); ++i) {
1103  content.writeDouble(shape[i].x);
1104  content.writeDouble(shape[i].y);
1105  }
1106  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_POSITION, polygonID, content);
1107  tcpip::Storage inMsg;
1108  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1109 }
1110 
1111 void
1112 TraCIAPI::PolygonScope::setColor(const std::string& polygonID, const TraCIColor& c) const {
1113  tcpip::Storage content;
1114  content.writeUnsignedByte(TYPE_COLOR);
1115  content.writeUnsignedByte(c.r);
1116  content.writeUnsignedByte(c.g);
1117  content.writeUnsignedByte(c.b);
1118  content.writeUnsignedByte(c.a);
1119  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_COLOR, polygonID, content);
1120  tcpip::Storage inMsg;
1121  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1122 }
1123 
1124 void
1125 TraCIAPI::PolygonScope::add(const std::string& polygonID, const TraCIAPI::TraCIPositionVector& shape, const TraCIColor& c, bool fill, const std::string& type, int layer) const {
1126  tcpip::Storage content;
1128  content.writeInt(4);
1129  content.writeUnsignedByte(TYPE_STRING);
1130  content.writeString(type);
1131  content.writeUnsignedByte(TYPE_COLOR);
1132  content.writeUnsignedByte(c.r);
1133  content.writeUnsignedByte(c.g);
1134  content.writeUnsignedByte(c.b);
1135  content.writeUnsignedByte(c.a);
1136  content.writeUnsignedByte(TYPE_UBYTE);
1137  int f = fill ? 1 : 0;
1138  content.writeUnsignedByte(f);
1140  content.writeInt(layer);
1142  content.writeInt((int)shape.size());
1143  for (unsigned int i = 0; i < shape.size(); ++i) {
1144  content.writeDouble(shape[i].x);
1145  content.writeDouble(shape[i].y);
1146  }
1147  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, ADD, polygonID, content);
1148  tcpip::Storage inMsg;
1149  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1150 }
1151 
1152 void
1153 TraCIAPI::PolygonScope::remove(const std::string& polygonID, int layer) const {
1154  tcpip::Storage content;
1156  content.writeInt(layer);
1157  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, REMOVE, polygonID, content);
1158  tcpip::Storage inMsg;
1159  myParent.check_resultState(inMsg, CMD_SET_POLYGON_VARIABLE);
1160 }
1161 
1162 
1163 
1164 // ---------------------------------------------------------------------------
1165 // TraCIAPI::RouteScope-methods
1166 // ---------------------------------------------------------------------------
1167 std::vector<std::string>
1169  return myParent.getStringVector(CMD_GET_ROUTE_VARIABLE, ID_LIST, "");
1170 }
1171 
1172 std::vector<std::string>
1173 TraCIAPI::RouteScope::getEdges(const std::string& routeID) const {
1174  return myParent.getStringVector(CMD_GET_ROUTE_VARIABLE, VAR_EDGES, routeID);
1175 }
1176 
1177 
1178 void
1179 TraCIAPI::RouteScope::add(const std::string& routeID, const std::vector<std::string>& edges) const {
1180  tcpip::Storage content;
1182  content.writeStringList(edges);
1183  myParent.send_commandSetValue(CMD_SET_ROUTE_VARIABLE, VAR_POSITION, routeID, content);
1184  tcpip::Storage inMsg;
1185  myParent.check_resultState(inMsg, CMD_SET_ROUTE_VARIABLE);
1186 }
1187 
1188 
1189 
1190 
1191 
1192 // ---------------------------------------------------------------------------
1193 // TraCIAPI::SimulationScope-methods
1194 // ---------------------------------------------------------------------------
1195 SUMOTime
1197  return myParent.getSUMOTime(CMD_GET_SIM_VARIABLE, VAR_TIME_STEP, "");
1198 }
1199 
1200 unsigned int
1202  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_LOADED_VEHICLES_NUMBER, "");
1203 }
1204 
1205 std::vector<std::string>
1207  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_LOADED_VEHICLES_IDS, "");
1208 }
1209 
1210 unsigned int
1212  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_DEPARTED_VEHICLES_NUMBER, "");
1213 }
1214 
1215 std::vector<std::string>
1217  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_DEPARTED_VEHICLES_IDS, "");
1218 }
1219 
1220 unsigned int
1222  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_ARRIVED_VEHICLES_NUMBER, "");
1223 }
1224 
1225 std::vector<std::string>
1227  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_ARRIVED_VEHICLES_IDS, "");
1228 }
1229 
1230 unsigned int
1232  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_STARTING_VEHICLES_NUMBER, "");
1233 }
1234 
1235 std::vector<std::string>
1237  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_STARTING_VEHICLES_IDS, "");
1238 }
1239 
1240 unsigned int
1242  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_ENDING_VEHICLES_NUMBER, "");
1243 }
1244 
1245 std::vector<std::string>
1247  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_ENDING_VEHICLES_IDS, "");
1248 }
1249 
1250 SUMOTime
1252  return myParent.getSUMOTime(CMD_GET_SIM_VARIABLE, VAR_DELTA_T, "");
1253 }
1254 
1257  return myParent.getBoundingBox(CMD_GET_SIM_VARIABLE, VAR_NET_BOUNDING_BOX, "");
1258 }
1259 
1260 unsigned int
1262  return myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_MIN_EXPECTED_VEHICLES, "");
1263 }
1264 
1265 
1266 
1267 // ---------------------------------------------------------------------------
1268 // TraCIAPI::TrafficLightScope-methods
1269 // ---------------------------------------------------------------------------
1270 std::vector<std::string>
1272  return myParent.getStringVector(CMD_GET_TL_VARIABLE, ID_LIST, "");
1273 }
1274 
1275 std::string
1277  return myParent.getString(CMD_GET_TL_VARIABLE, TL_RED_YELLOW_GREEN_STATE, tlsID);
1278 }
1279 
1280 std::vector<TraCIAPI::TraCILogic>
1282  tcpip::Storage inMsg;
1283  myParent.send_commandGetVariable(CMD_GET_TL_VARIABLE, TL_COMPLETE_DEFINITION_RYG, tlsID);
1284  myParent.processGET(inMsg, CMD_GET_TL_VARIABLE, TYPE_COMPOUND);
1285  std::vector<TraCIAPI::TraCILogic> ret;
1286  int logicNo = inMsg.readInt();
1287  for (int i = 0; i < logicNo; ++i) {
1288  inMsg.readUnsignedByte();
1289  std::string subID = inMsg.readString();
1290  inMsg.readUnsignedByte();
1291  int type = inMsg.readInt();
1292  inMsg.readUnsignedByte();
1293  inMsg.readInt(); // add
1294  inMsg.readUnsignedByte();
1295  int phaseIndex = inMsg.readInt();
1296  inMsg.readUnsignedByte();
1297  int phaseNumber = inMsg.readInt();
1298  std::vector<TraCIAPI::TraCIPhase> phases;
1299  for (int j = 0; j < phaseNumber; ++j) {
1300  inMsg.readUnsignedByte();
1301  int duration = inMsg.readInt();
1302  inMsg.readUnsignedByte();
1303  int duration1 = inMsg.readInt();
1304  inMsg.readUnsignedByte();
1305  int duration2 = inMsg.readInt();
1306  inMsg.readUnsignedByte();
1307  std::string phase = inMsg.readString();
1308  phases.push_back(TraCIAPI::TraCIPhase(duration, duration1, duration2, phase));
1309  }
1310  ret.push_back(TraCIAPI::TraCILogic(subID, type, std::map<std::string, SUMOReal>(), phaseIndex, phases));
1311  }
1312  return ret;
1313 }
1314 
1315 std::vector<std::string>
1316 TraCIAPI::TrafficLightScope::getControlledLanes(const std::string& tlsID) const {
1317  return myParent.getStringVector(CMD_GET_TL_VARIABLE, TL_CONTROLLED_LANES, tlsID);
1318 }
1319 
1320 std::vector<TraCIAPI::TraCILink>
1321 TraCIAPI::TrafficLightScope::getControlledLinks(const std::string& tlsID) const {
1322  tcpip::Storage inMsg;
1323  myParent.send_commandGetVariable(CMD_GET_TL_VARIABLE, TL_CONTROLLED_LINKS, tlsID);
1324  myParent.processGET(inMsg, CMD_GET_TL_VARIABLE, TYPE_COMPOUND);
1325  std::vector<TraCIAPI::TraCILink> ret;
1326  int linkNo = inMsg.readInt();
1327  for (int i = 0; i < linkNo; ++i) {
1328  inMsg.readUnsignedByte();
1329  std::string from = inMsg.readString();
1330  inMsg.readUnsignedByte();
1331  std::string via = inMsg.readString();
1332  inMsg.readUnsignedByte();
1333  std::string to = inMsg.readString();
1334  ret.push_back(TraCIAPI::TraCILink(from, via, to));
1335  }
1336  return ret;
1337 }
1338 
1339 std::string
1340 TraCIAPI::TrafficLightScope::getProgram(const std::string& tlsID) const {
1341  return myParent.getString(CMD_GET_TL_VARIABLE, TL_CURRENT_PROGRAM, tlsID);
1342 }
1343 
1344 unsigned int
1345 TraCIAPI::TrafficLightScope::getPhase(const std::string& tlsID) const {
1346  return myParent.getInt(CMD_GET_TL_VARIABLE, TL_CURRENT_PHASE, tlsID);
1347 }
1348 
1349 unsigned int
1350 TraCIAPI::TrafficLightScope::getNextSwitch(const std::string& tlsID) const {
1351  return myParent.getInt(CMD_GET_TL_VARIABLE, TL_NEXT_SWITCH, tlsID);
1352 }
1353 
1354 
1355 void
1356 TraCIAPI::TrafficLightScope::setRedYellowGreenState(const std::string& tlsID, const std::string& state) const {
1357  tcpip::Storage content;
1358  content.writeUnsignedByte(TYPE_STRING);
1359  content.writeString(state);
1360  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_RED_YELLOW_GREEN_STATE, tlsID, content);
1361  tcpip::Storage inMsg;
1362  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1363 }
1364 
1365 void
1366 TraCIAPI::TrafficLightScope::setPhase(const std::string& tlsID, unsigned int index) const {
1367  tcpip::Storage content;
1369  content.writeInt(index);
1370  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PHASE_INDEX, tlsID, content);
1371  tcpip::Storage inMsg;
1372  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1373 }
1374 
1375 void
1376 TraCIAPI::TrafficLightScope::setProgram(const std::string& tlsID, const std::string& programID) const {
1377  tcpip::Storage content;
1378  content.writeUnsignedByte(TYPE_STRING);
1379  content.writeString(programID);
1380  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PROGRAM, tlsID, content);
1381  tcpip::Storage inMsg;
1382  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1383 }
1384 
1385 void
1386 TraCIAPI::TrafficLightScope::setPhaseDuration(const std::string& tlsID, unsigned int phaseDuration) const {
1387  tcpip::Storage content;
1389  content.writeInt(int(1000 * phaseDuration));
1390  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PHASE_DURATION, tlsID, content);
1391  tcpip::Storage inMsg;
1392  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1393 }
1394 
1395 void
1397  tcpip::Storage content;
1399  content.writeInt(5 + 4 * (int)logic.phases.size());
1400  content.writeUnsignedByte(TYPE_STRING);
1401  content.writeString(logic.subID);
1403  content.writeInt(logic.type);
1405  content.writeInt(0);
1407  content.writeInt(logic.currentPhaseIndex);
1409  content.writeInt((int)logic.phases.size());
1410  for (int i = 0; i < (int) logic.phases.size(); ++i) {
1412  content.writeInt((int)logic.phases[i].duration);
1414  content.writeInt((int)logic.phases[i].duration1);
1416  content.writeInt((int)logic.phases[i].duration2);
1417  content.writeUnsignedByte(TYPE_STRING);
1418  content.writeString(logic.phases[i].phase);
1419  }
1420  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_COMPLETE_PROGRAM_RYG, tlsID, content);
1421  tcpip::Storage inMsg;
1422  myParent.check_resultState(inMsg, CMD_SET_TL_VARIABLE);
1423 }
1424 
1425 
1426 
1427 
1428 
1429 // ---------------------------------------------------------------------------
1430 // TraCIAPI::VehicleTypeScope-methods
1431 // ---------------------------------------------------------------------------
1432 std::vector<std::string>
1434  return myParent.getStringVector(CMD_GET_VEHICLETYPE_VARIABLE, ID_LIST, "");
1435 }
1436 
1437 SUMOReal
1438 TraCIAPI::VehicleTypeScope::getLength(const std::string& typeID) const {
1439  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_LENGTH, typeID);
1440 }
1441 
1442 SUMOReal
1443 TraCIAPI::VehicleTypeScope::getMaxSpeed(const std::string& typeID) const {
1444  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_MAXSPEED, typeID);
1445 }
1446 
1447 SUMOReal
1448 TraCIAPI::VehicleTypeScope::getSpeedFactor(const std::string& typeID) const {
1449  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_SPEED_FACTOR, typeID);
1450 }
1451 
1452 SUMOReal
1453 TraCIAPI::VehicleTypeScope::getSpeedDeviation(const std::string& typeID) const {
1454  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_SPEED_DEVIATION, typeID);
1455 }
1456 
1457 SUMOReal
1458 TraCIAPI::VehicleTypeScope::getAccel(const std::string& typeID) const {
1459  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_ACCEL, typeID);
1460 }
1461 
1462 SUMOReal
1463 TraCIAPI::VehicleTypeScope::getDecel(const std::string& typeID) const {
1464  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_DECEL, typeID);
1465 }
1466 
1467 SUMOReal
1468 TraCIAPI::VehicleTypeScope::getImperfection(const std::string& typeID) const {
1469  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_IMPERFECTION, typeID);
1470 }
1471 
1472 SUMOReal
1473 TraCIAPI::VehicleTypeScope::getTau(const std::string& typeID) const {
1474  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_TAU, typeID);
1475 }
1476 
1477 std::string
1478 TraCIAPI::VehicleTypeScope::getVehicleClass(const std::string& typeID) const {
1479  return myParent.getString(CMD_GET_TL_VARIABLE, VAR_VEHICLECLASS, typeID);
1480 }
1481 
1482 std::string
1483 TraCIAPI::VehicleTypeScope::getEmissionClass(const std::string& typeID) const {
1484  return myParent.getString(CMD_GET_TL_VARIABLE, VAR_EMISSIONCLASS, typeID);
1485 }
1486 
1487 std::string
1488 TraCIAPI::VehicleTypeScope::getShapeClass(const std::string& typeID) const {
1489  return myParent.getString(CMD_GET_TL_VARIABLE, VAR_SHAPECLASS, typeID);
1490 }
1491 
1492 SUMOReal
1493 TraCIAPI::VehicleTypeScope::getMinGap(const std::string& typeID) const {
1494  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_MINGAP, typeID);
1495 }
1496 
1497 SUMOReal
1498 TraCIAPI::VehicleTypeScope::getWidth(const std::string& typeID) const {
1499  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_WIDTH, typeID);
1500 }
1501 
1503 TraCIAPI::VehicleTypeScope::getColor(const std::string& typeID) const {
1504  return myParent.getColor(CMD_GET_TL_VARIABLE, VAR_COLOR, typeID);
1505 }
1506 
1507 
1508 
1509 void
1510 TraCIAPI::VehicleTypeScope::setLength(const std::string& typeID, SUMOReal length) const {
1511  tcpip::Storage content;
1512  content.writeUnsignedByte(TYPE_DOUBLE);
1513  content.writeDouble(length);
1514  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_LENGTH, typeID, content);
1515  tcpip::Storage inMsg;
1516  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1517 }
1518 
1519 void
1520 TraCIAPI::VehicleTypeScope::setMaxSpeed(const std::string& typeID, SUMOReal speed) const {
1521  tcpip::Storage content;
1522  content.writeUnsignedByte(TYPE_DOUBLE);
1523  content.writeDouble(speed);
1524  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_MAXSPEED, typeID, content);
1525  tcpip::Storage inMsg;
1526  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1527 }
1528 
1529 void
1530 TraCIAPI::VehicleTypeScope::setVehicleClass(const std::string& typeID, const std::string& clazz) const {
1531  tcpip::Storage content;
1532  content.writeUnsignedByte(TYPE_STRING);
1533  content.writeString(clazz);
1534  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_VEHICLECLASS, typeID, content);
1535  tcpip::Storage inMsg;
1536  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1537 }
1538 
1539 void
1540 TraCIAPI::VehicleTypeScope::setSpeedFactor(const std::string& typeID, SUMOReal factor) const {
1541  tcpip::Storage content;
1542  content.writeUnsignedByte(TYPE_DOUBLE);
1543  content.writeDouble(factor);
1544  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SPEED_FACTOR, typeID, content);
1545  tcpip::Storage inMsg;
1546  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1547 }
1548 
1549 void
1550 TraCIAPI::VehicleTypeScope::setSpeedDeviation(const std::string& typeID, SUMOReal deviation) const {
1551  tcpip::Storage content;
1552  content.writeUnsignedByte(TYPE_DOUBLE);
1553  content.writeDouble(deviation);
1554  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SPEED_DEVIATION, typeID, content);
1555  tcpip::Storage inMsg;
1556  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1557 }
1558 
1559 void
1560 TraCIAPI::VehicleTypeScope::setEmissionClass(const std::string& typeID, const std::string& clazz) const {
1561  tcpip::Storage content;
1562  content.writeUnsignedByte(TYPE_STRING);
1563  content.writeString(clazz);
1564  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_EMISSIONCLASS, typeID, content);
1565  tcpip::Storage inMsg;
1566  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1567 }
1568 
1569 void
1570 TraCIAPI::VehicleTypeScope::setWidth(const std::string& typeID, SUMOReal width) const {
1571  tcpip::Storage content;
1572  content.writeUnsignedByte(TYPE_DOUBLE);
1573  content.writeDouble(width);
1574  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_WIDTH, typeID, content);
1575  tcpip::Storage inMsg;
1576  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1577 }
1578 
1579 void
1580 TraCIAPI::VehicleTypeScope::setMinGap(const std::string& typeID, SUMOReal minGap) const {
1581  tcpip::Storage content;
1582  content.writeUnsignedByte(TYPE_DOUBLE);
1583  content.writeDouble(minGap);
1584  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_MINGAP, typeID, content);
1585  tcpip::Storage inMsg;
1586  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1587 }
1588 
1589 void
1590 TraCIAPI::VehicleTypeScope::setShapeClass(const std::string& typeID, const std::string& clazz) const {
1591  tcpip::Storage content;
1592  content.writeUnsignedByte(TYPE_STRING);
1593  content.writeString(clazz);
1594  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SHAPECLASS, typeID, content);
1595  tcpip::Storage inMsg;
1596  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1597 }
1598 
1599 void
1600 TraCIAPI::VehicleTypeScope::setAccel(const std::string& typeID, SUMOReal accel) const {
1601  tcpip::Storage content;
1602  content.writeUnsignedByte(TYPE_DOUBLE);
1603  content.writeDouble(accel);
1604  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_ACCEL, typeID, content);
1605  tcpip::Storage inMsg;
1606  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1607 }
1608 
1609 void
1610 TraCIAPI::VehicleTypeScope::setDecel(const std::string& typeID, SUMOReal decel) const {
1611  tcpip::Storage content;
1612  content.writeUnsignedByte(TYPE_DOUBLE);
1613  content.writeDouble(decel);
1614  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_DECEL, typeID, content);
1615  tcpip::Storage inMsg;
1616  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1617 }
1618 
1619 void
1620 TraCIAPI::VehicleTypeScope::setImperfection(const std::string& typeID, SUMOReal imperfection) const {
1621  tcpip::Storage content;
1622  content.writeUnsignedByte(TYPE_DOUBLE);
1623  content.writeDouble(imperfection);
1624  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_IMPERFECTION, typeID, content);
1625  tcpip::Storage inMsg;
1626  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1627 }
1628 
1629 void
1630 TraCIAPI::VehicleTypeScope::setTau(const std::string& typeID, SUMOReal tau) const {
1631  tcpip::Storage content;
1632  content.writeUnsignedByte(TYPE_DOUBLE);
1633  content.writeDouble(tau);
1634  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_TAU, typeID, content);
1635  tcpip::Storage inMsg;
1636  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1637 }
1638 
1639 void
1640 TraCIAPI::VehicleTypeScope::setColor(const std::string& typeID, const TraCIColor& c) const {
1641  tcpip::Storage content;
1642  content.writeUnsignedByte(TYPE_COLOR);
1643  content.writeUnsignedByte(c.r);
1644  content.writeUnsignedByte(c.g);
1645  content.writeUnsignedByte(c.b);
1646  content.writeUnsignedByte(c.a);
1647  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_COLOR, typeID, content);
1648  tcpip::Storage inMsg;
1649  myParent.check_resultState(inMsg, CMD_SET_VEHICLETYPE_VARIABLE);
1650 }
1651 
1652 
1653 
1654 
1655 
1656 // ---------------------------------------------------------------------------
1657 // TraCIAPI::VehicleScope-methods
1658 // ---------------------------------------------------------------------------
1659 std::vector<std::string>
1661  return myParent.getStringVector(CMD_GET_VEHICLE_VARIABLE, ID_LIST, "");
1662 }
1663 
1664 unsigned int
1666  return myParent.getInt(CMD_GET_VEHICLE_VARIABLE, ID_COUNT, "");
1667 }
1668 
1669 SUMOReal
1670 TraCIAPI::VehicleScope::getSpeed(const std::string& typeID) const {
1671  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_SPEED, typeID);
1672 }
1673 
1675 TraCIAPI::VehicleScope::getPosition(const std::string& typeID) const {
1676  return myParent.getPosition(CMD_GET_VEHICLE_VARIABLE, VAR_POSITION, typeID);
1677 }
1678 
1679 SUMOReal
1680 TraCIAPI::VehicleScope::getAngle(const std::string& typeID) const {
1681  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_ANGLE, typeID);
1682 }
1683 
1684 std::string
1685 TraCIAPI::VehicleScope::getRoadID(const std::string& typeID) const {
1686  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_ROAD_ID, typeID);
1687 }
1688 
1689 std::string
1690 TraCIAPI::VehicleScope::getLaneID(const std::string& typeID) const {
1691  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_LANE_ID, typeID);
1692 }
1693 
1694 unsigned int
1695 TraCIAPI::VehicleScope::getLaneIndex(const std::string& typeID) const {
1696  return myParent.getInt(CMD_GET_VEHICLE_VARIABLE, VAR_LANE_INDEX, typeID);
1697 }
1698 
1699 std::string
1700 TraCIAPI::VehicleScope::getTypeID(const std::string& typeID) const {
1701  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_TYPE, typeID);
1702 }
1703 
1704 std::string
1705 TraCIAPI::VehicleScope::getRouteID(const std::string& typeID) const {
1706  return myParent.getString(CMD_GET_VEHICLE_VARIABLE, VAR_ROAD_ID, typeID);
1707 }
1708 
1709 unsigned int
1710 TraCIAPI::VehicleScope::getRouteIndex(const std::string& typeID) const {
1711  return myParent.getInt(CMD_GET_VEHICLE_VARIABLE, VAR_ROUTE_INDEX, typeID);
1712 }
1713 
1714 std::vector<std::string>
1715 TraCIAPI::VehicleScope::getEdges(const std::string& typeID) const {
1716  return myParent.getStringVector(CMD_GET_VEHICLE_VARIABLE, VAR_EDGES, typeID);
1717 }
1718 
1720 TraCIAPI::VehicleScope::getColor(const std::string& typeID) const {
1721  return myParent.getColor(CMD_GET_VEHICLE_VARIABLE, VAR_COLOR, typeID);
1722 }
1723 
1724 SUMOReal
1725 TraCIAPI::VehicleScope::getLanePosition(const std::string& typeID) const {
1726  return myParent.getDouble(CMD_GET_VEHICLE_VARIABLE, VAR_LANEPOSITION, typeID);
1727 }
1728 
1729 
1730 
1731 
1732 void
1733 TraCIAPI::VehicleScope::moveTo(const std::string& typeID, const std::string& laneID, SUMOReal position) const {
1734  tcpip::Storage content;
1736  content.writeInt(2);
1737  content.writeUnsignedByte(TYPE_STRING);
1738  content.writeString(laneID);
1739  content.writeUnsignedByte(TYPE_DOUBLE);
1740  content.writeDouble(position);
1741  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_MOVE_TO, typeID, content);
1742  tcpip::Storage inMsg;
1743  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
1744 }
1745 
1746 void
1747 TraCIAPI::VehicleScope::slowDown(const std::string& typeID, SUMOReal speed, int duration) const {
1748  tcpip::Storage content;
1750  content.writeInt(2);
1751  content.writeUnsignedByte(TYPE_DOUBLE);
1752  content.writeDouble(speed);
1754  content.writeInt(duration);
1755  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, CMD_SLOWDOWN, typeID, content);
1756  tcpip::Storage inMsg;
1757  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
1758 }
1759 
1760 void
1761 TraCIAPI::VehicleScope::setSpeed(const std::string& typeID, SUMOReal speed) const {
1762  tcpip::Storage content;
1763  content.writeUnsignedByte(TYPE_DOUBLE);
1764  content.writeDouble(speed);
1765  myParent.send_commandSetValue(CMD_SET_VEHICLE_VARIABLE, VAR_SPEED, typeID, content);
1766  tcpip::Storage inMsg;
1767  myParent.check_resultState(inMsg, CMD_SET_VEHICLE_VARIABLE);
1768 }
1769 
1770 
1771 
1772 /****************************************************************************/
1773 
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1168
SUMOReal getImperfection(const std::string &typeID) const
Definition: TraCIAPI.cpp:1468
#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:385
SUMOReal entryTime
Entry-time of the vehicle in [s].
Definition: TraCIAPI.h:302
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:768
#define TL_NEXT_SWITCH
SUMOReal getMaxSpeed(const std::string &typeID) const
Definition: TraCIAPI.cpp:1443
#define VAR_TIME_STEP
TraCIPosition getOffset(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:585
void setLength(const std::string &typeID, SUMOReal length) const
Definition: TraCIAPI.cpp:1510
#define VAR_EMISSIONCLASS
long long int SUMOTime
Definition: SUMOTime.h:43
void setMaxSpeed(const std::string &edgeID, SUMOReal speed) const
Definition: TraCIAPI.cpp:560
SUMOReal getNoiseEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:843
tcpip::Socket * mySocket
The socket.
Definition: TraCIAPI.h:832
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1433
#define VAR_CO2EMISSION
std::vector< std::string > getLoadedIDList() const
Definition: TraCIAPI.cpp:1206
unsigned int getLastStepVehicleNumber(const std::string &loopID) const
Definition: TraCIAPI.cpp:683
void close()
Closes the connection.
Definition: TraCIAPI.cpp:82
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
Definition: TraCIAPI.cpp:69
#define CMD_GET_TL_VARIABLE
std::vector< std::string > getArrivedIDList() const
Definition: TraCIAPI.cpp:1226
#define VAR_LENGTH
std::string getRouteID(const std::string &typeID) const
Definition: TraCIAPI.cpp:1705
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:575
unsigned int getLastStepVehicleNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:525
std::string typeID
Type of the vehicle in.
Definition: TraCIAPI.h:306
#define CMD_GET_VEHICLE_VARIABLE
#define TYPE_COMPOUND
#define VAR_CURRENT_TRAVELTIME
unsigned int getRouteIndex(const std::string &typeID) const
Definition: TraCIAPI.cpp:1710
TraCIColor getColor(const std::string &poiID) const
Definition: TraCIAPI.cpp:990
#define CMD_CLOSE
void add(const std::string &poiID, SUMOReal x, SUMOReal y, const TraCIColor &c, const std::string &type, int layer) const
Definition: TraCIAPI.cpp:1030
SUMOReal getLastStepMeanSpeed(const std::string &edgeID) const
Definition: TraCIAPI.cpp:505
std::vector< std::string > getDisallowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:793
#define POSITION_2D
SUMOReal getCOEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:475
#define VAR_POSITION
void setShapeClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1590
void setPhase(const std::string &tlsID, unsigned int index) const
Definition: TraCIAPI.cpp:1366
void setProgram(const std::string &tlsID, const std::string &programID) const
Definition: TraCIAPI.cpp:1376
void setVehicleClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1530
std::string getLaneID(const std::string &typeID) const
Definition: TraCIAPI.cpp:1690
bool receiveExact(Storage &)
Receive a complete TraCI message from Socket::socket_.
Definition: socket.cpp:493
#define CMD_GET_INDUCTIONLOOP_VARIABLE
#define VAR_TAU
std::string getVehicleClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1478
#define LANE_EDGE_ID
void slowDown(const std::string &typeID, SUMOReal speed, int duration) const
Definition: TraCIAPI.cpp:1747
void setColor(const std::string &polygonID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:1112
SUMOReal getDouble(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:342
#define LAST_STEP_VEHICLE_DATA
void send_commandClose() const
Sends a Close command.
Definition: TraCIAPI.cpp:106
virtual unsigned int position() const
unsigned int getIDCount() const
Definition: TraCIAPI.cpp:1665
#define TYPE_UBYTE
#define RTYPE_OK
unsigned int getLaneIndex(const std::string &typeID) const
Definition: TraCIAPI.cpp:1695
virtual double readDouble()
void setMaxSpeed(const std::string &typeID, SUMOReal speed) const
Definition: TraCIAPI.cpp:1520
void setCompleteRedYellowGreenDefinition(const std::string &tlsID, const TraCIAPI::TraCILogic &logic) const
Definition: TraCIAPI.cpp:1396
#define VAR_TYPE
#define TYPE_POLYGON
unsigned int currentPhaseIndex
Definition: TraCIAPI.h:108
std::string getEmissionClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1483
void add(const std::string &polygonID, const TraCIPositionVector &shape, const TraCIColor &c, bool fill, const std::string &type, int layer) const
Definition: TraCIAPI.cpp:1125
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1660
SUMOReal getLastStepMeanSpeed(const std::string &detID) const
Definition: TraCIAPI.cpp:955
#define VAR_VEHICLECLASS
void processGET(tcpip::Storage &inMsg, int command, int expectedType, bool ignoreCommandId=false) const
Definition: TraCIAPI.cpp:288
StorageType::size_type size() const
Definition: storage.h:115
SUMOReal getPMxEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:828
SUMOReal getSpeed(const std::string &typeID) const
Definition: TraCIAPI.cpp:1670
#define VAR_SPEED_FACTOR
SUMOReal getLastStepOccupancy(const std::string &edgeID) const
Definition: TraCIAPI.cpp:510
#define VAR_COLOR
unsigned int getLastStepHaltingNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:965
#define VAR_LOADED_VEHICLES_IDS
std::vector< std::string > getLastStepVehicleIDs(const std::string &loopID) const
Definition: TraCIAPI.cpp:693
TraCIPosition getPosition(const std::string &junctionID) const
Definition: TraCIAPI.cpp:757
void trackVehicle(const std::string &viewID, const std::string &vehID) const
Definition: TraCIAPI.cpp:653
std::string getRoadID(const std::string &typeID) const
Definition: TraCIAPI.cpp:1685
#define TYPE_COLOR
#define TYPE_STRINGLIST
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:752
SUMOTime getCurrentTime() const
Definition: TraCIAPI.cpp:1196
SUMOReal getLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:773
SUMOReal getLastStepMeanSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:848
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1067
SUMOReal getMinGap(const std::string &typeID) const
Definition: TraCIAPI.cpp:1493
#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:435
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1316
SUMOReal getLastStepMeanLength(const std::string &loopID) const
Definition: TraCIAPI.cpp:703
void setAllowed(const std::string &laneID, const std::vector< std::string > &allowedClasses) const
Definition: TraCIAPI.cpp:884
virtual void writeUnsignedByte(int)
#define CMD_SET_EDGE_VARIABLE
#define CMD_SET_GUI_VARIABLE
SUMOReal getWidth(const std::string &typeID) const
Definition: TraCIAPI.cpp:1498
TraCIPositionVector getPolygon(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:367
SUMOReal getLastStepOccupancy(const std::string &laneID) const
Definition: TraCIAPI.cpp:853
#define TL_CURRENT_PHASE
std::string getProgram(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1340
#define VAR_LOADED_VEHICLES_NUMBER
#define VAR_SHAPE
#define VAR_SPEED_DEVIATION
#define VAR_NOISEEMISSION
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:446
#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:351
virtual void writeInt(int)
void setDisallowed(const std::string &laneID, const std::vector< std::string > &disallowedClasses) const
Definition: TraCIAPI.cpp:897
void setTau(const std::string &typeID, SUMOReal tau) const
Definition: TraCIAPI.cpp:1630
SUMOReal getCO2Emission(const std::string &laneID) const
Definition: TraCIAPI.cpp:813
SUMOReal leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIAPI.h:304
std::vector< std::string > getAllowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:788
void setBoundary(const std::string &viewID, SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax) const
Definition: TraCIAPI.cpp:631
#define TYPE_STRING
void setMaxSpeed(const std::string &laneID, SUMOReal speed) const
Definition: TraCIAPI.cpp:910
virtual int readUnsignedByte()
#define TL_PHASE_DURATION
void connect()
Connects to host_:port_.
Definition: socket.cpp:314
#define LAST_STEP_LENGTH
void moveTo(const std::string &typeID, const std::string &laneID, SUMOReal position) const
Definition: TraCIAPI.cpp:1733
unsigned int getIDCount() const
Definition: TraCIAPI.cpp:451
#define VAR_NOXEMISSION
#define TL_CURRENT_PROGRAM
std::vector< std::string > getEdges(const std::string &typeID) const
Definition: TraCIAPI.cpp:1715
#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:193
#define VAR_ANGLE
#define CMD_GET_VEHICLETYPE_VARIABLE
void remove(const std::string &polygonID, int layer=0) const
Definition: TraCIAPI.cpp:1153
std::string getTypeID(const std::string &typeID) const
Definition: TraCIAPI.cpp:1700
void send_commandSimulationStep(SUMOTime time) const
Sends a SimulationStep command.
Definition: TraCIAPI.cpp:93
#define LANE_ALLOWED
std::string getRedYellowGreenState(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1276
#define VAR_DEPARTED_VEHICLES_NUMBER
void adaptTraveltime(const std::string &edgeID, SUMOReal time) const
Definition: TraCIAPI.cpp:542
#define LAST_STEP_TIME_SINCE_DETECTION
#define CMD_SLOWDOWN
#define CMD_SET_ROUTE_VARIABLE
#define TYPE_FLOAT
#define VAR_SHAPECLASS
SUMOReal length
Length of the vehicle.
Definition: TraCIAPI.h:300
#define CMD_GET_AREAL_DETECTOR_VARIABLE
#define VAR_MIN_EXPECTED_VEHICLES
#define VAR_SCREENSHOT
#define VAR_VIEW_BOUNDARY
#define VAR_TRACK_VEHICLE
void setDecel(const std::string &typeID, SUMOReal decel) const
Definition: TraCIAPI.cpp:1610
void setLength(const std::string &laneID, SUMOReal length) const
Definition: TraCIAPI.cpp:920
#define VAR_ACCEL
SUMOTime getDeltaT() const
Definition: TraCIAPI.cpp:1251
void setSchema(const std::string &viewID, const std::string &schemeName) const
Definition: TraCIAPI.cpp:621
TraCIColor getColor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1503
virtual int readInt()
#define TL_COMPLETE_PROGRAM_RYG
std::string getType(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1072
SUMOReal getTraveltime(const std::string &laneID) const
Definition: TraCIAPI.cpp:863
void setType(const std::string &poiID, const std::string &setType) const
Definition: TraCIAPI.cpp:996
SUMOReal getNOxEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:833
#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:117
TraCIColor getColor(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:421
#define CMD_GET_POI_VARIABLE
#define VAR_LANEPOSITION
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:975
~TraCIAPI()
Destructor.
Definition: TraCIAPI.cpp:63
void screenshot(const std::string &viewID, const std::string &filename) const
Definition: TraCIAPI.cpp:644
std::vector< std::string > getDepartedIDList() const
Definition: TraCIAPI.cpp:1216
#define TL_COMPLETE_DEFINITION_RYG
#define VAR_TELEPORT_STARTING_VEHICLES_NUMBER
unsigned int getLastStepHaltingNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:873
#define CMD_SET_VEHICLETYPE_VARIABLE
std::vector< TraCIAPI::TraCILink > getControlledLinks(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1321
#define TYPE_BOUNDINGBOX
unsigned int getArrivedNumber() const
Definition: TraCIAPI.cpp:1221
SUMOReal getHCEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:823
void setWidth(const std::string &typeID, SUMOReal width) const
Definition: TraCIAPI.cpp:1570
A 3D-bounding box.
Definition: TraCIAPI.h:81
void setEmissionClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1560
unsigned int getNextSwitch(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1350
TraCIPositionVector getShape(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1077
void setSpeedFactor(const std::string &typeID, SUMOReal factor) const
Definition: TraCIAPI.cpp:1540
#define VAR_VIEW_SCHEMA
virtual void writeStringList(const std::vector< std::string > &s)
#define VAR_PMXEMISSION
#define VAR_TELEPORT_ENDING_VEHICLES_IDS
#define CMD_GET_LANE_VARIABLE
std::vector< TraCIPhase > phases
Definition: TraCIAPI.h:109
int getInt(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:324
#define CMD_SET_VEHICLE_VARIABLE
SUMOReal getSpeedFactor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1448
#define VAR_IMPERFECTION
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1271
SUMOReal getLastStepLength(const std::string &edgeID) const
Definition: TraCIAPI.cpp:515
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
Definition: TraCIAPI.cpp:1356
#define CMD_GET_SIM_VARIABLE
virtual std::string readString()
std::string getShapeClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1488
#define CMD_GET_EDGE_VARIABLE
int getByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:315
#define VAR_EDGES
#define CMD_GET_GUI_VARIABLE
std::string getSchema(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:590
SUMOReal getLastStepOccupancy(const std::string &loopID) const
Definition: TraCIAPI.cpp:698
#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:306
#define VAR_EDGE_EFFORT
void setMinGap(const std::string &typeID, SUMOReal minGap) const
Definition: TraCIAPI.cpp:1580
TraCIColor getColor(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1082
SUMOReal getDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1463
void setPhaseDuration(const std::string &tlsID, unsigned int phaseDuration) const
Definition: TraCIAPI.cpp:1386
std::vector< std::string > getEndingTeleportIDList() const
Definition: TraCIAPI.cpp:1246
#define ADD
SUMOReal getPosition(const std::string &loopID) const
Definition: TraCIAPI.cpp:673
#define CMD_GET_JUNCTION_VARIABLE
TraCIBoundary getBoundary(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:595
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:54
SUMOReal getTimeSinceDetection(const std::string &loopID) const
Definition: TraCIAPI.cpp:708
#define VAR_DELTA_T
#define REMOVE
void setOffset(const std::string &viewID, SUMOReal x, SUMOReal y) const
Definition: TraCIAPI.cpp:610
std::string getEdgeID(const std::string &laneID) const
Definition: TraCIAPI.cpp:808
unsigned int getEndingTeleportNumber() const
Definition: TraCIAPI.cpp:1241
virtual void writeStorage(tcpip::Storage &store)
#define TL_CONTROLLED_LINKS
SUMOReal getMaxSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:778
unsigned int getLastStepVehicleNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:868
SUMOReal getLanePosition(const std::string &typeID) const
Definition: TraCIAPI.cpp:1725
SUMOReal getLastStepMeanSpeed(const std::string &loopID) const
Definition: TraCIAPI.cpp:688
void setAccel(const std::string &typeID, SUMOReal accel) const
Definition: TraCIAPI.cpp:1600
#define VAR_SPEED
void setImperfection(const std::string &typeID, SUMOReal imperfection) const
Definition: TraCIAPI.cpp:1620
std::vector< std::string > getStringVector(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:407
SUMOReal getCOEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:818
TraCIPosition getPosition(const std::string &poiID) const
Definition: TraCIAPI.cpp:985
#define TL_RED_YELLOW_GREEN_STATE
SUMOReal getFuelConsumption(const std::string &edgeID) const
Definition: TraCIAPI.cpp:495
#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:580
TraCIColor getColor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1720
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:165
SUMOReal getWidth(const std::string &laneID) const
Definition: TraCIAPI.cpp:783
#define CMD_SET_POLYGON_VARIABLE
#define VAR_COEMISSION
std::vector< TraCIAPI::TraCILogic > getCompleteRedYellowGreenDefinition(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1281
SUMOReal getAngle(const std::string &typeID) const
Definition: TraCIAPI.cpp:1680
virtual void writeString(const std::string &s)
#define RTYPE_NOTIMPLEMENTED
void setType(const std::string &polygonID, const std::string &setType) const
Definition: TraCIAPI.cpp:1088
TraCIPositionVector getShape(const std::string &laneID) const
Definition: TraCIAPI.cpp:803
#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:551
#define LANE_DISALLOWED
#define VAR_MOVE_TO
#define TL_PROGRAM
SUMOReal getEffort(const std::string &edgeID, SUMOTime time) const
Definition: TraCIAPI.cpp:463
SUMOTime getSUMOTime(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:297
#define TYPE_DOUBLE
SUMOReal getHCEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:480
std::vector< std::string > getLastStepVehicleIDs(const std::string &detID) const
Definition: TraCIAPI.cpp:960
unsigned int getDepartedNumber() const
Definition: TraCIAPI.cpp:1211
void sendExact(const Storage &)
Definition: socket.cpp:394
virtual float readFloat()
void setSpeed(const std::string &typeID, SUMOReal speed) const
Definition: TraCIAPI.cpp:1761
#define TYPE_BYTE
std::string getType(const std::string &poiID) const
Definition: TraCIAPI.cpp:980
#define CMD_SET_LANE_VARIABLE
#define VAR_ROUTE_INDEX
std::string getLaneID(const std::string &loopID) const
Definition: TraCIAPI.cpp:678
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:668
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:226
unsigned int getLinkNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:798
SUMOReal getNoiseEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:500
SUMOReal getAccel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1458
SUMOReal getTraveltime(const std::string &edgeID) const
Definition: TraCIAPI.cpp:520
void setZoom(const std::string &viewID, SUMOReal zoom) const
Definition: TraCIAPI.cpp:601
std::string subID
Definition: TraCIAPI.h:105
std::vector< std::string > getLastStepVehicleIDs(const std::string &laneID) const
Definition: TraCIAPI.cpp:878
virtual void writeDouble(double)
#define VAR_TELEPORT_ENDING_VEHICLES_NUMBER
SUMOReal getLastStepLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:858
void setShape(const std::string &polygonID, const TraCIPositionVector &shape) const
Definition: TraCIAPI.cpp:1098
void setColor(const std::string &typeID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:1640
void send_commandSetValue(int domID, int varID, const std::string &objID, tcpip::Storage &content) const
Sends a SetVariable request.
Definition: TraCIAPI.cpp:144
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:934
unsigned int getStartingTeleportNumber() const
Definition: TraCIAPI.cpp:1231
SUMOReal getPMxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:485
void setPosition(const std::string &poiID, SUMOReal x, SUMOReal y) const
Definition: TraCIAPI.cpp:1006
#define SUMOReal
Definition: config.h:213
SUMOReal getSpeedDeviation(const std::string &typeID) const
Definition: TraCIAPI.cpp:1453
SUMOReal getCO2Emission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:470
#define LAST_STEP_OCCUPANCY
unsigned int getLoadedNumber() const
Definition: TraCIAPI.cpp:1201
#define TL_CONTROLLED_LANES
void check_commandGetResult(tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const
Definition: TraCIAPI.cpp:265
std::string getString(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:398
void setSpeedDeviation(const std::string &typeID, SUMOReal deviation) const
Definition: TraCIAPI.cpp:1550
#define VAR_MAXSPEED
TraCIPosition getPosition(const std::string &typeID) const
Definition: TraCIAPI.cpp:1675
SUMOReal getNOxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:490
std::vector< VehicleData > getVehicleData(const std::string &loopID) const
Definition: TraCIAPI.cpp:713
#define VAR_DECEL
TraCIAPI()
Constructor.
Definition: TraCIAPI.cpp:52
#define ID_COUNT
#define VAR_LANE_INDEX
TraCIBoundary getNetBoundary() const
Definition: TraCIAPI.cpp:1256
std::vector< TraCIPosition > TraCIPositionVector
Definition: TraCIAPI.h:76
#define VAR_LANE_ID
unsigned int getMinExpectedNumber() const
Definition: TraCIAPI.cpp:1261
SUMOReal getAdaptedTraveltime(const std::string &edgeID, SUMOTime time) const
Definition: TraCIAPI.cpp:456
std::vector< std::string > getEdges(const std::string &routeID) const
Definition: TraCIAPI.cpp:1173
void remove(const std::string &poiID, int layer=0) const
Definition: TraCIAPI.cpp:1052
SUMOReal getFloat(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:333
std::string id
The id of the vehicle.
Definition: TraCIAPI.h:298
unsigned int getPhase(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1345
#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:1438
SUMOReal getTau(const std::string &typeID) const
Definition: TraCIAPI.cpp:1473
unsigned int getLastStepVehicleNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:950
#define TL_PHASE_INDEX
#define VAR_ARRIVED_VEHICLES_IDS
std::vector< std::string > getLastStepVehicleIDs(const std::string &edgeID) const
Definition: TraCIAPI.cpp:535
A list of positions.
#define VAR_VIEW_OFFSET
#define LAST_STEP_VEHICLE_HALTING_NUMBER
SUMOReal getFuelConsumption(const std::string &laneID) const
Definition: TraCIAPI.cpp:838
virtual int readByte()
#define VAR_HCEMISSION
void setColor(const std::string &poiID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:1017
void close()
Definition: socket.cpp:345
void add(const std::string &routeID, const std::vector< std::string > &edges) const
Definition: TraCIAPI.cpp:1179
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:945
A 3D-position.
Definition: TraCIAPI.h:62
#define VAR_WIDTH
SUMOReal getLastStepHaltingNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:530
std::vector< std::string > getStartingTeleportIDList() const
Definition: TraCIAPI.cpp:1236