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-2015 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),
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;
438  std::string acknowledgement;
439  check_resultState(inMsg, CMD_SIMSTEP2, false, &acknowledgement);
440 }
441 
442 
443 // ---------------------------------------------------------------------------
444 // TraCIAPI::EdgeScope-methods
445 // ---------------------------------------------------------------------------
446 std::vector<std::string>
448  return myParent.getStringVector(CMD_GET_EDGE_VARIABLE, ID_LIST, "");
449 }
450 
451 unsigned int
453  return myParent.getInt(CMD_GET_EDGE_VARIABLE, ID_COUNT, "");
454 }
455 
456 SUMOReal
457 TraCIAPI::EdgeScope::getAdaptedTraveltime(const std::string& edgeID, SUMOTime time) const {
458  tcpip::Storage content;
459  content.writeInt((int)time);
460  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CO2EMISSION, edgeID, &content);
461 }
462 
463 SUMOReal
464 TraCIAPI::EdgeScope::getEffort(const std::string& edgeID, SUMOTime time) const {
465  tcpip::Storage content;
466  content.writeInt((int)time);
467  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CO2EMISSION, edgeID, &content);
468 }
469 
470 SUMOReal
471 TraCIAPI::EdgeScope::getCO2Emission(const std::string& edgeID) const {
472  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CO2EMISSION, edgeID);
473 }
474 
475 SUMOReal
476 TraCIAPI::EdgeScope::getCOEmission(const std::string& edgeID) const {
477  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_COEMISSION, edgeID);
478 }
479 
480 SUMOReal
481 TraCIAPI::EdgeScope::getHCEmission(const std::string& edgeID) const {
482  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_HCEMISSION, edgeID);
483 }
484 
485 SUMOReal
486 TraCIAPI::EdgeScope::getPMxEmission(const std::string& edgeID) const {
487  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_PMXEMISSION, edgeID);
488 }
489 
490 SUMOReal
491 TraCIAPI::EdgeScope::getNOxEmission(const std::string& edgeID) const {
492  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_NOXEMISSION, edgeID);
493 }
494 
495 SUMOReal
496 TraCIAPI::EdgeScope::getFuelConsumption(const std::string& edgeID) const {
497  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_FUELCONSUMPTION, edgeID);
498 }
499 
500 SUMOReal
501 TraCIAPI::EdgeScope::getNoiseEmission(const std::string& edgeID) const {
502  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_NOISEEMISSION, edgeID);
503 }
504 
505 SUMOReal
506 TraCIAPI::EdgeScope::getLastStepMeanSpeed(const std::string& edgeID) const {
507  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_MEAN_SPEED, edgeID);
508 }
509 
510 SUMOReal
511 TraCIAPI::EdgeScope::getLastStepOccupancy(const std::string& edgeID) const {
512  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_OCCUPANCY, edgeID);
513 }
514 
515 SUMOReal
516 TraCIAPI::EdgeScope::getLastStepLength(const std::string& edgeID) const {
517  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_LENGTH, edgeID);
518 }
519 
520 SUMOReal
521 TraCIAPI::EdgeScope::getTraveltime(const std::string& edgeID) const {
522  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CURRENT_TRAVELTIME, edgeID);
523 }
524 
525 unsigned int
526 TraCIAPI::EdgeScope::getLastStepVehicleNumber(const std::string& edgeID) const {
527  return myParent.getInt(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_NUMBER, edgeID);
528 }
529 
530 SUMOReal
531 TraCIAPI::EdgeScope::getLastStepHaltingNumber(const std::string& edgeID) const {
532  return myParent.getInt(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_HALTING_NUMBER, edgeID);
533 }
534 
535 std::vector<std::string>
536 TraCIAPI::EdgeScope::getLastStepVehicleIDs(const std::string& edgeID) const {
537  return myParent.getStringVector(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, edgeID);
538 }
539 
540 
541 
542 void
543 TraCIAPI::EdgeScope::adaptTraveltime(const std::string& edgeID, SUMOReal time) const {
544  tcpip::Storage content;
545  content.writeDouble(time);
546  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_EDGE_TRAVELTIME, edgeID, content);
547 }
548 
549 void
550 TraCIAPI::EdgeScope::setEffort(const std::string& edgeID, SUMOReal effort) const {
551  tcpip::Storage content;
552  content.writeDouble(effort);
553  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_EDGE_EFFORT, edgeID, content);
554 }
555 
556 void
557 TraCIAPI::EdgeScope::setMaxSpeed(const std::string& edgeID, SUMOReal speed) const {
558  tcpip::Storage content;
559  content.writeDouble(speed);
560  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_MAXSPEED, edgeID, content);
561 }
562 
563 
564 
565 
566 // ---------------------------------------------------------------------------
567 // TraCIAPI::GUIScope-methods
568 // ---------------------------------------------------------------------------
569 std::vector<std::string>
571  return myParent.getStringVector(CMD_GET_GUI_VARIABLE, ID_LIST, "");
572 }
573 
574 SUMOReal
575 TraCIAPI::GUIScope::getZoom(const std::string& viewID) const {
576  return myParent.getDouble(CMD_GET_GUI_VARIABLE, VAR_VIEW_ZOOM, viewID);
577 }
578 
580 TraCIAPI::GUIScope::getOffset(const std::string& viewID) const {
581  return myParent.getPosition(CMD_GET_GUI_VARIABLE, VAR_VIEW_OFFSET, viewID);
582 }
583 
584 std::string
585 TraCIAPI::GUIScope::getSchema(const std::string& viewID) const {
586  return myParent.getString(CMD_GET_GUI_VARIABLE, VAR_VIEW_SCHEMA, viewID);
587 }
588 
590 TraCIAPI::GUIScope::getBoundary(const std::string& viewID) const {
591  return myParent.getBoundingBox(CMD_GET_GUI_VARIABLE, VAR_VIEW_BOUNDARY, viewID);
592 }
593 
594 
595 void
596 TraCIAPI::GUIScope::setZoom(const std::string& viewID, SUMOReal zoom) const {
597  tcpip::Storage content;
598  content.writeDouble(zoom);
599  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_ZOOM, viewID, content);
600 }
601 
602 void
603 TraCIAPI::GUIScope::setOffset(const std::string& viewID, SUMOReal x, SUMOReal y) const {
604  tcpip::Storage content;
606  content.writeDouble(x);
607  content.writeDouble(y);
608  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_OFFSET, viewID, content);
609 }
610 
611 void
612 TraCIAPI::GUIScope::setSchema(const std::string& viewID, const std::string& schemeName) const {
613  tcpip::Storage content;
614  content.writeString(schemeName);
615  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_SCHEMA, viewID, content);
616 }
617 
618 void
619 TraCIAPI::GUIScope::setBoundary(const std::string& viewID, SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax) const {
620  tcpip::Storage content;
622  content.writeDouble(xmin);
623  content.writeDouble(ymin);
624  content.writeDouble(xmax);
625  content.writeDouble(ymax);
626  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_BOUNDARY, viewID, content);
627 }
628 
629 void
630 TraCIAPI::GUIScope::screenshot(const std::string& viewID, const std::string& filename) const {
631  tcpip::Storage content;
632  content.writeString(filename);
633  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_SCREENSHOT, viewID, content);
634 }
635 
636 void
637 TraCIAPI::GUIScope::trackVehicle(const std::string& viewID, const std::string& vehID) const {
638  tcpip::Storage content;
639  content.writeString(vehID);
640  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_TRACK_VEHICLE, viewID, content);
641 }
642 
643 
644 
645 
646 // ---------------------------------------------------------------------------
647 // TraCIAPI::InductionLoopScope-methods
648 // ---------------------------------------------------------------------------
649 std::vector<std::string>
651  return myParent.getStringVector(CMD_GET_INDUCTIONLOOP_VARIABLE, ID_LIST, "");
652 }
653 
654 SUMOReal
655 TraCIAPI::InductionLoopScope::getPosition(const std::string& loopID) const {
656  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, VAR_POSITION, loopID);
657 }
658 
659 std::string
660 TraCIAPI::InductionLoopScope::getLaneID(const std::string& loopID) const {
661  return myParent.getString(CMD_GET_INDUCTIONLOOP_VARIABLE, VAR_LANE_ID, loopID);
662 }
663 
664 unsigned int
666  return myParent.getInt(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_NUMBER, loopID);
667 }
668 
669 SUMOReal
670 TraCIAPI::InductionLoopScope::getLastStepMeanSpeed(const std::string& loopID) const {
671  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_MEAN_SPEED, loopID);
672 }
673 
674 std::vector<std::string>
675 TraCIAPI::InductionLoopScope::getLastStepVehicleIDs(const std::string& loopID) const {
676  return myParent.getStringVector(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, loopID);
677 }
678 
679 SUMOReal
680 TraCIAPI::InductionLoopScope::getLastStepOccupancy(const std::string& loopID) const {
681  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_OCCUPANCY, loopID);
682 }
683 
684 SUMOReal
685 TraCIAPI::InductionLoopScope::getLastStepMeanLength(const std::string& loopID) const {
686  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_LENGTH, loopID);
687 }
688 
689 SUMOReal
690 TraCIAPI::InductionLoopScope::getTimeSinceDetection(const std::string& loopID) const {
691  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_TIME_SINCE_DETECTION, loopID);
692 }
693 
694 unsigned int
695 TraCIAPI::InductionLoopScope::getVehicleData(const std::string& loopID) const {
696  return myParent.getInt(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_DATA, loopID);
697 }
698 
699 
700 
701 
702 // ---------------------------------------------------------------------------
703 // TraCIAPI::JunctionScope-methods
704 // ---------------------------------------------------------------------------
705 std::vector<std::string>
707  return myParent.getStringVector(CMD_GET_JUNCTION_VARIABLE, ID_LIST, "");
708 }
709 
711 TraCIAPI::JunctionScope::getPosition(const std::string& junctionID) const {
712  return myParent.getPosition(CMD_GET_JUNCTION_VARIABLE, VAR_POSITION, junctionID);
713 }
714 
715 
716 
717 
718 // ---------------------------------------------------------------------------
719 // TraCIAPI::LaneScope-methods
720 // ---------------------------------------------------------------------------
721 std::vector<std::string>
723  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, ID_LIST, "");
724 }
725 
726 SUMOReal
727 TraCIAPI::LaneScope::getLength(const std::string& laneID) const {
728  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_LENGTH, laneID);
729 }
730 
731 SUMOReal
732 TraCIAPI::LaneScope::getMaxSpeed(const std::string& laneID) const {
733  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_MAXSPEED, laneID);
734 }
735 
736 SUMOReal
737 TraCIAPI::LaneScope::getWidth(const std::string& laneID) const {
738  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_WIDTH, laneID);
739 }
740 
741 std::vector<std::string>
742 TraCIAPI::LaneScope::getAllowed(const std::string& laneID) const {
743  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, LANE_ALLOWED, laneID);
744 }
745 
746 std::vector<std::string>
747 TraCIAPI::LaneScope::getDisallowed(const std::string& laneID) const {
748  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, LANE_DISALLOWED, laneID);
749 }
750 
751 unsigned int
752 TraCIAPI::LaneScope::getLinkNumber(const std::string& /* laneID */) const {
753  throw tcpip::SocketException("Not implemented!");
754 }
755 
757 TraCIAPI::LaneScope::getShape(const std::string& laneID) const {
758  throw myParent.getPolygon(CMD_GET_LANE_VARIABLE, VAR_SHAPE, laneID);
759 }
760 
761 std::string
762 TraCIAPI::LaneScope::getEdgeID(const std::string& laneID) const {
763  throw myParent.getString(CMD_GET_LANE_VARIABLE, LANE_EDGE_ID, laneID);
764 }
765 
766 SUMOReal
767 TraCIAPI::LaneScope::getCO2Emission(const std::string& laneID) const {
768  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_CO2EMISSION, laneID);
769 }
770 
771 SUMOReal
772 TraCIAPI::LaneScope::getCOEmission(const std::string& laneID) const {
773  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_COEMISSION, laneID);
774 }
775 
776 SUMOReal
777 TraCIAPI::LaneScope::getHCEmission(const std::string& laneID) const {
778  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_HCEMISSION, laneID);
779 }
780 
781 SUMOReal
782 TraCIAPI::LaneScope::getPMxEmission(const std::string& laneID) const {
783  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_PMXEMISSION, laneID);
784 }
785 
786 SUMOReal
787 TraCIAPI::LaneScope::getNOxEmission(const std::string& laneID) const {
788  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_NOXEMISSION, laneID);
789 }
790 
791 SUMOReal
792 TraCIAPI::LaneScope::getFuelConsumption(const std::string& laneID) const {
793  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_FUELCONSUMPTION, laneID);
794 }
795 
796 SUMOReal
797 TraCIAPI::LaneScope::getNoiseEmission(const std::string& laneID) const {
798  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_NOISEEMISSION, laneID);
799 }
800 
801 SUMOReal
802 TraCIAPI::LaneScope::getLastStepMeanSpeed(const std::string& laneID) const {
803  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_MEAN_SPEED, laneID);
804 }
805 
806 SUMOReal
807 TraCIAPI::LaneScope::getLastStepOccupancy(const std::string& laneID) const {
808  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_OCCUPANCY, laneID);
809 }
810 
811 SUMOReal
812 TraCIAPI::LaneScope::getLastStepLength(const std::string& laneID) const {
813  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_LENGTH, laneID);
814 }
815 
816 SUMOReal
817 TraCIAPI::LaneScope::getTraveltime(const std::string& laneID) const {
818  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_CURRENT_TRAVELTIME, laneID);
819 }
820 
821 unsigned int
822 TraCIAPI::LaneScope::getLastStepVehicleNumber(const std::string& laneID) const {
823  throw myParent.getInt(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_NUMBER, laneID);
824 }
825 
826 unsigned int
827 TraCIAPI::LaneScope::getLastStepHaltingNumber(const std::string& laneID) const {
828  throw myParent.getInt(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_HALTING_NUMBER, laneID);
829 }
830 
831 std::vector<std::string>
832 TraCIAPI::LaneScope::getLastStepVehicleIDs(const std::string& laneID) const {
833  throw myParent.getStringVector(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, laneID);
834 }
835 
836 
837 void
838 TraCIAPI::LaneScope::setAllowed(const std::string& laneID, const std::vector<std::string>& allowedClasses) const {
839  tcpip::Storage content;
841  content.writeInt((int)allowedClasses.size());
842  for (unsigned int i = 0; i < allowedClasses.size(); ++i) {
843  content.writeString(allowedClasses[i]);
844  }
845  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, LANE_ALLOWED, laneID, content);
846 }
847 
848 void
849 TraCIAPI::LaneScope::setDisallowed(const std::string& laneID, const std::vector<std::string>& disallowedClasses) const {
850  tcpip::Storage content;
852  content.writeInt((int)disallowedClasses.size());
853  for (unsigned int i = 0; i < disallowedClasses.size(); ++i) {
854  content.writeString(disallowedClasses[i]);
855  }
856  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, LANE_DISALLOWED, laneID, content);
857 }
858 
859 void
860 TraCIAPI::LaneScope::setMaxSpeed(const std::string& laneID, SUMOReal speed) const {
861  tcpip::Storage content;
863  content.writeDouble(speed);
864  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, VAR_MAXSPEED, laneID, content);
865 }
866 
867 void
868 TraCIAPI::LaneScope::setLength(const std::string& laneID, SUMOReal length) const {
869  tcpip::Storage content;
871  content.writeDouble(length);
872  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, VAR_LENGTH, laneID, content);
873 }
874 
875 
876 // ---------------------------------------------------------------------------
877 // TraCIAPI::AreaDetector-methods
878 // ---------------------------------------------------------------------------
879 std::vector<std::string>
881  return myParent.getStringVector(CMD_GET_AREAL_DETECTOR_VARIABLE, ID_LIST, "");
882 }
883 
884 
885 
886 
887 // ---------------------------------------------------------------------------
888 // TraCIAPI::MeMeScope-methods
889 // ---------------------------------------------------------------------------
890 std::vector<std::string>
892  return myParent.getStringVector(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, ID_LIST, "");
893 }
894 
895 unsigned int
896 TraCIAPI::MeMeScope::getLastStepVehicleNumber(const std::string& detID) const {
898 }
899 
900 SUMOReal
901 TraCIAPI::MeMeScope::getLastStepMeanSpeed(const std::string& detID) const {
903 }
904 
905 std::vector<std::string>
906 TraCIAPI::MeMeScope::getLastStepVehicleIDs(const std::string& detID) const {
907  return myParent.getStringVector(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, detID);
908 }
909 
910 unsigned int
911 TraCIAPI::MeMeScope::getLastStepHaltingNumber(const std::string& detID) const {
913 }
914 
915 
916 
917 // ---------------------------------------------------------------------------
918 // TraCIAPI::POIScope-methods
919 // ---------------------------------------------------------------------------
920 std::vector<std::string>
922  return myParent.getStringVector(CMD_GET_POI_VARIABLE, ID_LIST, "");
923 }
924 
925 std::string
926 TraCIAPI::POIScope::getType(const std::string& poiID) const {
927  return myParent.getString(CMD_GET_POI_VARIABLE, VAR_TYPE, poiID);
928 }
929 
931 TraCIAPI::POIScope::getPosition(const std::string& poiID) const {
932  return myParent.getPosition(CMD_GET_POI_VARIABLE, VAR_POSITION, poiID);
933 }
934 
936 TraCIAPI::POIScope::getColor(const std::string& poiID) const {
937  return myParent.getColor(CMD_GET_POI_VARIABLE, VAR_COLOR, poiID);
938 }
939 
940 
941 void
942 TraCIAPI::POIScope::setType(const std::string& poiID, const std::string& setType) const {
943  tcpip::Storage content;
945  content.writeString(setType);
946  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_TYPE, poiID, content);
947 }
948 
949 void
950 TraCIAPI::POIScope::setPosition(const std::string& poiID, SUMOReal x, SUMOReal y) const {
951  tcpip::Storage content;
953  content.writeDouble(x);
954  content.writeDouble(y);
955  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_POSITION, poiID, content);
956 }
957 
958 void
959 TraCIAPI::POIScope::setColor(const std::string& poiID, const TraCIColor& c) const {
960  tcpip::Storage content;
961  content.writeUnsignedByte(TYPE_COLOR);
962  content.writeUnsignedByte(c.r);
963  content.writeUnsignedByte(c.g);
964  content.writeUnsignedByte(c.b);
965  content.writeUnsignedByte(c.a);
966  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_COLOR, poiID, content);
967 }
968 
969 void
970 TraCIAPI::POIScope::add(const std::string& poiID, SUMOReal x, SUMOReal y, const TraCIColor& c, const std::string& type, int layer) const {
971  tcpip::Storage content;
973  content.writeInt(4);
975  content.writeString(type);
976  content.writeUnsignedByte(TYPE_COLOR);
977  content.writeUnsignedByte(c.r);
978  content.writeUnsignedByte(c.g);
979  content.writeUnsignedByte(c.b);
980  content.writeUnsignedByte(c.a);
982  content.writeInt(layer);
984  content.writeDouble(x);
985  content.writeDouble(y);
986  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, ADD, poiID, content);
987 }
988 
989 void
990 TraCIAPI::POIScope::remove(const std::string& poiID, int layer) const {
991  tcpip::Storage content;
993  content.writeInt(layer);
994  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, REMOVE, poiID, content);
995 }
996 
997 
998 
999 // ---------------------------------------------------------------------------
1000 // TraCIAPI::PolygonScope-methods
1001 // ---------------------------------------------------------------------------
1002 std::vector<std::string>
1004  return myParent.getStringVector(CMD_GET_POLYGON_VARIABLE, ID_LIST, "");
1005 }
1006 
1007 std::string
1008 TraCIAPI::PolygonScope::getType(const std::string& polygonID) const {
1009  return myParent.getString(CMD_GET_POLYGON_VARIABLE, VAR_TYPE, polygonID);
1010 }
1011 
1013 TraCIAPI::PolygonScope::getShape(const std::string& polygonID) const {
1014  return myParent.getPolygon(CMD_GET_POLYGON_VARIABLE, VAR_SHAPE, polygonID);
1015 }
1016 
1018 TraCIAPI::PolygonScope::getColor(const std::string& polygonID) const {
1019  return myParent.getColor(CMD_GET_POLYGON_VARIABLE, VAR_COLOR, polygonID);
1020 }
1021 
1022 
1023 void
1024 TraCIAPI::PolygonScope::setType(const std::string& polygonID, const std::string& setType) const {
1025  tcpip::Storage content;
1026  content.writeUnsignedByte(TYPE_STRING);
1027  content.writeString(setType);
1028  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_TYPE, polygonID, content);
1029 }
1030 
1031 void
1032 TraCIAPI::PolygonScope::setShape(const std::string& polygonID, const TraCIAPI::TraCIPositionVector& shape) const {
1033  tcpip::Storage content;
1035  content.writeInt((int)shape.size());
1036  for (unsigned int i = 0; i < shape.size(); ++i) {
1037  content.writeDouble(shape[i].x);
1038  content.writeDouble(shape[i].y);
1039  }
1040  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_POSITION, polygonID, content);
1041 }
1042 
1043 void
1044 TraCIAPI::PolygonScope::setColor(const std::string& polygonID, const TraCIColor& c) const {
1045  tcpip::Storage content;
1046  content.writeUnsignedByte(TYPE_COLOR);
1047  content.writeUnsignedByte(c.r);
1048  content.writeUnsignedByte(c.g);
1049  content.writeUnsignedByte(c.b);
1050  content.writeUnsignedByte(c.a);
1051  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_COLOR, polygonID, content);
1052 }
1053 
1054 void
1055 TraCIAPI::PolygonScope::add(const std::string& polygonID, const TraCIAPI::TraCIPositionVector& shape, const TraCIColor& c, bool fill, const std::string& type, int layer) const {
1056  tcpip::Storage content;
1058  content.writeInt(4);
1059  content.writeUnsignedByte(TYPE_STRING);
1060  content.writeString(type);
1061  content.writeUnsignedByte(TYPE_COLOR);
1062  content.writeUnsignedByte(c.r);
1063  content.writeUnsignedByte(c.g);
1064  content.writeUnsignedByte(c.b);
1065  content.writeUnsignedByte(c.a);
1066  content.writeUnsignedByte(TYPE_UBYTE);
1067  int f = fill ? 1 : 0;
1068  content.writeUnsignedByte(f);
1070  content.writeInt(layer);
1072  content.writeInt((int)shape.size());
1073  for (unsigned int i = 0; i < shape.size(); ++i) {
1074  content.writeDouble(shape[i].x);
1075  content.writeDouble(shape[i].y);
1076  }
1077  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, ADD, polygonID, content);
1078 }
1079 
1080 void
1081 TraCIAPI::PolygonScope::remove(const std::string& polygonID, int layer) const {
1082  tcpip::Storage content;
1084  content.writeInt(layer);
1085  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, REMOVE, polygonID, content);
1086 }
1087 
1088 
1089 
1090 // ---------------------------------------------------------------------------
1091 // TraCIAPI::RouteScope-methods
1092 // ---------------------------------------------------------------------------
1093 std::vector<std::string>
1095  return myParent.getStringVector(CMD_GET_ROUTE_VARIABLE, ID_LIST, "");
1096 }
1097 
1098 std::vector<std::string>
1099 TraCIAPI::RouteScope::getEdges(const std::string& routeID) const {
1100  return myParent.getStringVector(CMD_GET_ROUTE_VARIABLE, VAR_EDGES, routeID);
1101 }
1102 
1103 
1104 void
1105 TraCIAPI::RouteScope::add(const std::string& routeID, const std::vector<std::string>& edges) const {
1106  tcpip::Storage content;
1108  content.writeStringList(edges);
1109  myParent.send_commandSetValue(CMD_SET_ROUTE_VARIABLE, VAR_POSITION, routeID, content);
1110 }
1111 
1112 
1113 
1114 
1115 
1116 // ---------------------------------------------------------------------------
1117 // TraCIAPI::SimulationScope-methods
1118 // ---------------------------------------------------------------------------
1119 SUMOTime
1121  return myParent.getSUMOTime(CMD_GET_SIM_VARIABLE, VAR_TIME_STEP, "");
1122 }
1123 
1124 unsigned int
1126  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_LOADED_VEHICLES_NUMBER, "");
1127 }
1128 
1129 std::vector<std::string>
1131  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_LOADED_VEHICLES_IDS, "");
1132 }
1133 
1134 unsigned int
1136  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_DEPARTED_VEHICLES_NUMBER, "");
1137 }
1138 
1139 std::vector<std::string>
1141  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_DEPARTED_VEHICLES_IDS, "");
1142 }
1143 
1144 unsigned int
1146  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_ARRIVED_VEHICLES_NUMBER, "");
1147 }
1148 
1149 std::vector<std::string>
1151  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_ARRIVED_VEHICLES_IDS, "");
1152 }
1153 
1154 unsigned int
1156  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_STARTING_VEHICLES_NUMBER, "");
1157 }
1158 
1159 std::vector<std::string>
1161  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_STARTING_VEHICLES_IDS, "");
1162 }
1163 
1164 unsigned int
1166  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_ENDING_VEHICLES_NUMBER, "");
1167 }
1168 
1169 std::vector<std::string>
1171  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_ENDING_VEHICLES_IDS, "");
1172 }
1173 
1174 SUMOTime
1176  return myParent.getSUMOTime(CMD_GET_SIM_VARIABLE, VAR_DELTA_T, "");
1177 }
1178 
1181  return myParent.getBoundingBox(CMD_GET_SIM_VARIABLE, VAR_NET_BOUNDING_BOX, "");
1182 }
1183 
1184 unsigned int
1186  return myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_MIN_EXPECTED_VEHICLES, "");
1187 }
1188 
1189 
1190 
1191 // ---------------------------------------------------------------------------
1192 // TraCIAPI::TrafficLightScope-methods
1193 // ---------------------------------------------------------------------------
1194 std::vector<std::string>
1196  return myParent.getStringVector(CMD_GET_TL_VARIABLE, ID_LIST, "");
1197 }
1198 
1199 std::string
1201  return myParent.getString(CMD_GET_TL_VARIABLE, TL_RED_YELLOW_GREEN_STATE, tlsID);
1202 }
1203 
1204 std::vector<TraCIAPI::TraCILogic>
1206  tcpip::Storage inMsg;
1207  myParent.send_commandGetVariable(CMD_GET_TL_VARIABLE, TL_COMPLETE_DEFINITION_RYG, tlsID);
1208  myParent.processGET(inMsg, CMD_GET_TL_VARIABLE, TYPE_COMPOUND);
1209  std::vector<TraCIAPI::TraCILogic> ret;
1210  int logicNo = inMsg.readInt();
1211  for (int i = 0; i < logicNo; ++i) {
1212  inMsg.readUnsignedByte();
1213  std::string subID = inMsg.readString();
1214  inMsg.readUnsignedByte();
1215  int type = inMsg.readInt();
1216  inMsg.readUnsignedByte();
1217  inMsg.readInt(); // add
1218  inMsg.readUnsignedByte();
1219  int phaseIndex = inMsg.readInt();
1220  inMsg.readUnsignedByte();
1221  int phaseNumber = inMsg.readInt();
1222  std::vector<TraCIAPI::TraCIPhase> phases;
1223  for (int j = 0; j < phaseNumber; ++j) {
1224  inMsg.readUnsignedByte();
1225  int duration = inMsg.readInt();
1226  inMsg.readUnsignedByte();
1227  int duration1 = inMsg.readInt();
1228  inMsg.readUnsignedByte();
1229  int duration2 = inMsg.readInt();
1230  inMsg.readUnsignedByte();
1231  std::string phase = inMsg.readString();
1232  phases.push_back(TraCIAPI::TraCIPhase(duration, duration1, duration2, phase));
1233  }
1234  ret.push_back(TraCIAPI::TraCILogic(subID, type, std::map<std::string, SUMOReal>(), phaseIndex, phases));
1235  }
1236  return ret;
1237 }
1238 
1239 std::vector<std::string>
1240 TraCIAPI::TrafficLightScope::getControlledLanes(const std::string& tlsID) const {
1241  return myParent.getStringVector(CMD_GET_TL_VARIABLE, TL_CONTROLLED_LANES, tlsID);
1242 }
1243 
1244 std::vector<TraCIAPI::TraCILink>
1245 TraCIAPI::TrafficLightScope::getControlledLinks(const std::string& tlsID) const {
1246  tcpip::Storage inMsg;
1247  myParent.send_commandGetVariable(CMD_GET_TL_VARIABLE, TL_CONTROLLED_LINKS, tlsID);
1248  myParent.processGET(inMsg, CMD_GET_TL_VARIABLE, TYPE_COMPOUND);
1249  std::vector<TraCIAPI::TraCILink> ret;
1250  int linkNo = inMsg.readInt();
1251  for (int i = 0; i < linkNo; ++i) {
1252  inMsg.readUnsignedByte();
1253  std::string from = inMsg.readString();
1254  inMsg.readUnsignedByte();
1255  std::string via = inMsg.readString();
1256  inMsg.readUnsignedByte();
1257  std::string to = inMsg.readString();
1258  ret.push_back(TraCIAPI::TraCILink(from, via, to));
1259  }
1260  return ret;
1261 }
1262 
1263 std::string
1264 TraCIAPI::TrafficLightScope::getProgram(const std::string& tlsID) const {
1265  return myParent.getString(CMD_GET_TL_VARIABLE, TL_CURRENT_PROGRAM, tlsID);
1266 }
1267 
1268 unsigned int
1269 TraCIAPI::TrafficLightScope::getPhase(const std::string& tlsID) const {
1270  return myParent.getInt(CMD_GET_TL_VARIABLE, TL_CURRENT_PHASE, tlsID);
1271 }
1272 
1273 unsigned int
1274 TraCIAPI::TrafficLightScope::getNextSwitch(const std::string& tlsID) const {
1275  return myParent.getInt(CMD_GET_TL_VARIABLE, TL_NEXT_SWITCH, tlsID);
1276 }
1277 
1278 
1279 void
1280 TraCIAPI::TrafficLightScope::setRedYellowGreenState(const std::string& tlsID, const std::string& state) const {
1281  tcpip::Storage content;
1282  content.writeUnsignedByte(TYPE_STRING);
1283  content.writeString(state);
1284  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_RED_YELLOW_GREEN_STATE, tlsID, content);
1285 }
1286 
1287 void
1288 TraCIAPI::TrafficLightScope::setPhase(const std::string& tlsID, unsigned int index) const {
1289  tcpip::Storage content;
1291  content.writeInt(index);
1292  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PHASE_INDEX, tlsID, content);
1293 }
1294 
1295 void
1296 TraCIAPI::TrafficLightScope::setProgram(const std::string& tlsID, const std::string& programID) const {
1297  tcpip::Storage content;
1298  content.writeUnsignedByte(TYPE_STRING);
1299  content.writeString(programID);
1300  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PROGRAM, tlsID, content);
1301 }
1302 
1303 void
1304 TraCIAPI::TrafficLightScope::setPhaseDuration(const std::string& tlsID, unsigned int phaseDuration) const {
1305  tcpip::Storage content;
1307  content.writeInt(int(1000 * phaseDuration));
1308  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PHASE_DURATION, tlsID, content);
1309 }
1310 
1311 void
1313  tcpip::Storage content;
1315  content.writeInt(5 + 4 * (int)logic.phases.size());
1316  content.writeUnsignedByte(TYPE_STRING);
1317  content.writeString(logic.subID);
1319  content.writeInt(logic.type);
1321  content.writeInt(0);
1323  content.writeInt(logic.currentPhaseIndex);
1325  content.writeInt((int)logic.phases.size());
1326  for (int i = 0; i < (int) logic.phases.size(); ++i) {
1328  content.writeInt((int)logic.phases[i].duration);
1330  content.writeInt((int)logic.phases[i].duration1);
1332  content.writeInt((int)logic.phases[i].duration2);
1333  content.writeUnsignedByte(TYPE_STRING);
1334  content.writeString(logic.phases[i].phase);
1335  }
1336  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_COMPLETE_PROGRAM_RYG, tlsID, content);
1337 }
1338 
1339 
1340 
1341 
1342 
1343 // ---------------------------------------------------------------------------
1344 // TraCIAPI::VehicleTypeScope-methods
1345 // ---------------------------------------------------------------------------
1346 std::vector<std::string>
1348  return myParent.getStringVector(CMD_GET_VEHICLETYPE_VARIABLE, ID_LIST, "");
1349 }
1350 
1351 SUMOReal
1352 TraCIAPI::VehicleTypeScope::getLength(const std::string& typeID) const {
1353  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_LENGTH, typeID);
1354 }
1355 
1356 SUMOReal
1357 TraCIAPI::VehicleTypeScope::getMaxSpeed(const std::string& typeID) const {
1358  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_MAXSPEED, typeID);
1359 }
1360 
1361 SUMOReal
1362 TraCIAPI::VehicleTypeScope::getSpeedFactor(const std::string& typeID) const {
1363  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_SPEED_FACTOR, typeID);
1364 }
1365 
1366 SUMOReal
1367 TraCIAPI::VehicleTypeScope::getSpeedDeviation(const std::string& typeID) const {
1368  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_SPEED_DEVIATION, typeID);
1369 }
1370 
1371 SUMOReal
1372 TraCIAPI::VehicleTypeScope::getAccel(const std::string& typeID) const {
1373  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_ACCEL, typeID);
1374 }
1375 
1376 SUMOReal
1377 TraCIAPI::VehicleTypeScope::getDecel(const std::string& typeID) const {
1378  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_DECEL, typeID);
1379 }
1380 
1381 SUMOReal
1382 TraCIAPI::VehicleTypeScope::getImperfection(const std::string& typeID) const {
1383  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_IMPERFECTION, typeID);
1384 }
1385 
1386 SUMOReal
1387 TraCIAPI::VehicleTypeScope::getTau(const std::string& typeID) const {
1388  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_TAU, typeID);
1389 }
1390 
1391 std::string
1392 TraCIAPI::VehicleTypeScope::getVehicleClass(const std::string& typeID) const {
1393  return myParent.getString(CMD_GET_TL_VARIABLE, VAR_VEHICLECLASS, typeID);
1394 }
1395 
1396 std::string
1397 TraCIAPI::VehicleTypeScope::getEmissionClass(const std::string& typeID) const {
1398  return myParent.getString(CMD_GET_TL_VARIABLE, VAR_EMISSIONCLASS, typeID);
1399 }
1400 
1401 std::string
1402 TraCIAPI::VehicleTypeScope::getShapeClass(const std::string& typeID) const {
1403  return myParent.getString(CMD_GET_TL_VARIABLE, VAR_SHAPECLASS, typeID);
1404 }
1405 
1406 SUMOReal
1407 TraCIAPI::VehicleTypeScope::getMinGap(const std::string& typeID) const {
1408  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_MINGAP, typeID);
1409 }
1410 
1411 SUMOReal
1412 TraCIAPI::VehicleTypeScope::getWidth(const std::string& typeID) const {
1413  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_WIDTH, typeID);
1414 }
1415 
1417 TraCIAPI::VehicleTypeScope::getColor(const std::string& typeID) const {
1418  return myParent.getColor(CMD_GET_TL_VARIABLE, VAR_COLOR, typeID);
1419 }
1420 
1421 
1422 
1423 void
1424 TraCIAPI::VehicleTypeScope::setLength(const std::string& typeID, SUMOReal length) const {
1425  tcpip::Storage content;
1426  content.writeUnsignedByte(TYPE_DOUBLE);
1427  content.writeDouble(length);
1428  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_LENGTH, typeID, content);
1429 }
1430 
1431 void
1432 TraCIAPI::VehicleTypeScope::setMaxSpeed(const std::string& typeID, SUMOReal speed) const {
1433  tcpip::Storage content;
1434  content.writeUnsignedByte(TYPE_DOUBLE);
1435  content.writeDouble(speed);
1436  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_MAXSPEED, typeID, content);
1437 }
1438 
1439 void
1440 TraCIAPI::VehicleTypeScope::setVehicleClass(const std::string& typeID, const std::string& clazz) const {
1441  tcpip::Storage content;
1442  content.writeUnsignedByte(TYPE_STRING);
1443  content.writeString(clazz);
1444  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_VEHICLECLASS, typeID, content);
1445 }
1446 
1447 void
1448 TraCIAPI::VehicleTypeScope::setSpeedFactor(const std::string& typeID, SUMOReal factor) const {
1449  tcpip::Storage content;
1450  content.writeUnsignedByte(TYPE_DOUBLE);
1451  content.writeDouble(factor);
1452  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SPEED_FACTOR, typeID, content);
1453 }
1454 
1455 void
1456 TraCIAPI::VehicleTypeScope::setSpeedDeviation(const std::string& typeID, SUMOReal deviation) const {
1457  tcpip::Storage content;
1458  content.writeUnsignedByte(TYPE_DOUBLE);
1459  content.writeDouble(deviation);
1460  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SPEED_DEVIATION, typeID, content);
1461 }
1462 
1463 void
1464 TraCIAPI::VehicleTypeScope::setEmissionClass(const std::string& typeID, const std::string& clazz) const {
1465  tcpip::Storage content;
1466  content.writeUnsignedByte(TYPE_STRING);
1467  content.writeString(clazz);
1468  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_EMISSIONCLASS, typeID, content);
1469 }
1470 
1471 void
1472 TraCIAPI::VehicleTypeScope::setWidth(const std::string& typeID, SUMOReal width) const {
1473  tcpip::Storage content;
1474  content.writeUnsignedByte(TYPE_DOUBLE);
1475  content.writeDouble(width);
1476  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_WIDTH, typeID, content);
1477 }
1478 
1479 void
1480 TraCIAPI::VehicleTypeScope::setMinGap(const std::string& typeID, SUMOReal minGap) const {
1481  tcpip::Storage content;
1482  content.writeUnsignedByte(TYPE_DOUBLE);
1483  content.writeDouble(minGap);
1484  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_MINGAP, typeID, content);
1485 }
1486 
1487 void
1488 TraCIAPI::VehicleTypeScope::setShapeClass(const std::string& typeID, const std::string& clazz) const {
1489  tcpip::Storage content;
1490  content.writeUnsignedByte(TYPE_STRING);
1491  content.writeString(clazz);
1492  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SHAPECLASS, typeID, content);
1493 }
1494 
1495 void
1496 TraCIAPI::VehicleTypeScope::setAccel(const std::string& typeID, SUMOReal accel) const {
1497  tcpip::Storage content;
1498  content.writeUnsignedByte(TYPE_DOUBLE);
1499  content.writeDouble(accel);
1500  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_ACCEL, typeID, content);
1501 }
1502 
1503 void
1504 TraCIAPI::VehicleTypeScope::setDecel(const std::string& typeID, SUMOReal decel) const {
1505  tcpip::Storage content;
1506  content.writeUnsignedByte(TYPE_DOUBLE);
1507  content.writeDouble(decel);
1508  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_DECEL, typeID, content);
1509 }
1510 
1511 void
1512 TraCIAPI::VehicleTypeScope::setImperfection(const std::string& typeID, SUMOReal imperfection) const {
1513  tcpip::Storage content;
1514  content.writeUnsignedByte(TYPE_DOUBLE);
1515  content.writeDouble(imperfection);
1516  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_IMPERFECTION, typeID, content);
1517 }
1518 
1519 void
1520 TraCIAPI::VehicleTypeScope::setTau(const std::string& typeID, SUMOReal tau) const {
1521  tcpip::Storage content;
1522  content.writeUnsignedByte(TYPE_DOUBLE);
1523  content.writeDouble(tau);
1524  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_TAU, typeID, content);
1525 }
1526 
1527 void
1528 TraCIAPI::VehicleTypeScope::setColor(const std::string& typeID, const TraCIColor& c) const {
1529  tcpip::Storage content;
1530  content.writeUnsignedByte(TYPE_COLOR);
1531  content.writeUnsignedByte(c.r);
1532  content.writeUnsignedByte(c.g);
1533  content.writeUnsignedByte(c.b);
1534  content.writeUnsignedByte(c.a);
1535  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_COLOR, typeID, content);
1536 }
1537 
1538 
1539 
1540 /****************************************************************************/
1541 
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1094
SUMOReal getImperfection(const std::string &typeID) const
Definition: TraCIAPI.cpp:1382
#define LAST_STEP_MEAN_SPEED
TraCIPosition getPosition(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:385
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:722
#define TL_NEXT_SWITCH
SUMOReal getMaxSpeed(const std::string &typeID) const
Definition: TraCIAPI.cpp:1357
#define VAR_TIME_STEP
TraCIPosition getOffset(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:580
void setLength(const std::string &typeID, SUMOReal length) const
Definition: TraCIAPI.cpp:1424
#define VAR_EMISSIONCLASS
long long int SUMOTime
Definition: SUMOTime.h:43
void setMaxSpeed(const std::string &edgeID, SUMOReal speed) const
Definition: TraCIAPI.cpp:557
SUMOReal getNoiseEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:797
tcpip::Socket * mySocket
The socket.
Definition: TraCIAPI.h:749
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1347
#define VAR_CO2EMISSION
std::vector< std::string > getLoadedIDList() const
Definition: TraCIAPI.cpp:1130
unsigned int getLastStepVehicleNumber(const std::string &loopID) const
Definition: TraCIAPI.cpp:665
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:1150
#define VAR_LENGTH
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:570
unsigned int getLastStepVehicleNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:526
#define TYPE_COMPOUND
#define VAR_CURRENT_TRAVELTIME
TraCIColor getColor(const std::string &poiID) const
Definition: TraCIAPI.cpp:936
#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:970
SUMOReal getLastStepMeanSpeed(const std::string &edgeID) const
Definition: TraCIAPI.cpp:506
std::vector< std::string > getDisallowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:747
#define POSITION_2D
SUMOReal getCOEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:476
#define VAR_POSITION
void setShapeClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1488
void setPhase(const std::string &tlsID, unsigned int index) const
Definition: TraCIAPI.cpp:1288
void setProgram(const std::string &tlsID, const std::string &programID) const
Definition: TraCIAPI.cpp:1296
void setVehicleClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1440
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:1392
#define LANE_EDGE_ID
void setColor(const std::string &polygonID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:1044
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
#define TYPE_UBYTE
#define RTYPE_OK
virtual double readDouble()
void setMaxSpeed(const std::string &typeID, SUMOReal speed) const
Definition: TraCIAPI.cpp:1432
void setCompleteRedYellowGreenDefinition(const std::string &tlsID, const TraCIAPI::TraCILogic &logic) const
Definition: TraCIAPI.cpp:1312
#define VAR_TYPE
#define TYPE_POLYGON
unsigned int currentPhaseIndex
Definition: TraCIAPI.h:108
std::string getEmissionClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1397
void add(const std::string &polygonID, const TraCIPositionVector &shape, const TraCIColor &c, bool fill, const std::string &type, int layer) const
Definition: TraCIAPI.cpp:1055
SUMOReal getLastStepMeanSpeed(const std::string &detID) const
Definition: TraCIAPI.cpp:901
#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:782
#define VAR_SPEED_FACTOR
SUMOReal getLastStepOccupancy(const std::string &edgeID) const
Definition: TraCIAPI.cpp:511
#define VAR_COLOR
unsigned int getLastStepHaltingNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:911
#define VAR_LOADED_VEHICLES_IDS
std::vector< std::string > getLastStepVehicleIDs(const std::string &loopID) const
Definition: TraCIAPI.cpp:675
TraCIPosition getPosition(const std::string &junctionID) const
Definition: TraCIAPI.cpp:711
void trackVehicle(const std::string &viewID, const std::string &vehID) const
Definition: TraCIAPI.cpp:637
#define TYPE_COLOR
#define TYPE_STRINGLIST
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:706
SUMOTime getCurrentTime() const
Definition: TraCIAPI.cpp:1120
SUMOReal getLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:727
SUMOReal getLastStepMeanSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:802
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1003
SUMOReal getMinGap(const std::string &typeID) const
Definition: TraCIAPI.cpp:1407
#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:1240
SUMOReal getLastStepMeanLength(const std::string &loopID) const
Definition: TraCIAPI.cpp:685
void setAllowed(const std::string &laneID, const std::vector< std::string > &allowedClasses) const
Definition: TraCIAPI.cpp:838
virtual void writeUnsignedByte(int)
#define CMD_SET_EDGE_VARIABLE
#define CMD_SET_GUI_VARIABLE
SUMOReal getWidth(const std::string &typeID) const
Definition: TraCIAPI.cpp:1412
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:807
#define TL_CURRENT_PHASE
std::string getProgram(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1264
#define VAR_LOADED_VEHICLES_NUMBER
#define VAR_SHAPE
#define VAR_SPEED_DEVIATION
#define VAR_NOISEEMISSION
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:447
#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:849
void setTau(const std::string &typeID, SUMOReal tau) const
Definition: TraCIAPI.cpp:1520
SUMOReal getCO2Emission(const std::string &laneID) const
Definition: TraCIAPI.cpp:767
std::vector< std::string > getAllowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:742
void setBoundary(const std::string &viewID, SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax) const
Definition: TraCIAPI.cpp:619
#define TYPE_STRING
void setMaxSpeed(const std::string &laneID, SUMOReal speed) const
Definition: TraCIAPI.cpp:860
virtual int readUnsignedByte()
#define TL_PHASE_DURATION
void connect()
Connects to host_:port_.
Definition: socket.cpp:314
#define LAST_STEP_LENGTH
unsigned int getIDCount() const
Definition: TraCIAPI.cpp:452
#define VAR_NOXEMISSION
#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:193
#define CMD_GET_VEHICLETYPE_VARIABLE
void remove(const std::string &polygonID, int layer=0) const
Definition: TraCIAPI.cpp:1081
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:1200
#define VAR_DEPARTED_VEHICLES_NUMBER
void adaptTraveltime(const std::string &edgeID, SUMOReal time) const
Definition: TraCIAPI.cpp:543
#define LAST_STEP_TIME_SINCE_DETECTION
#define CMD_SET_ROUTE_VARIABLE
#define TYPE_FLOAT
#define VAR_SHAPECLASS
#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:1504
void setLength(const std::string &laneID, SUMOReal length) const
Definition: TraCIAPI.cpp:868
#define VAR_ACCEL
SUMOTime getDeltaT() const
Definition: TraCIAPI.cpp:1175
void setSchema(const std::string &viewID, const std::string &schemeName) const
Definition: TraCIAPI.cpp:612
TraCIColor getColor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1417
virtual int readInt()
#define TL_COMPLETE_PROGRAM_RYG
std::string getType(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1008
SUMOReal getTraveltime(const std::string &laneID) const
Definition: TraCIAPI.cpp:817
void setType(const std::string &poiID, const std::string &setType) const
Definition: TraCIAPI.cpp:942
SUMOReal getNOxEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:787
#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
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:921
~TraCIAPI()
Destructor.
Definition: TraCIAPI.cpp:63
void screenshot(const std::string &viewID, const std::string &filename) const
Definition: TraCIAPI.cpp:630
std::vector< std::string > getDepartedIDList() const
Definition: TraCIAPI.cpp:1140
#define TL_COMPLETE_DEFINITION_RYG
#define VAR_TELEPORT_STARTING_VEHICLES_NUMBER
unsigned int getLastStepHaltingNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:827
#define CMD_SET_VEHICLETYPE_VARIABLE
std::vector< TraCIAPI::TraCILink > getControlledLinks(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1245
#define TYPE_BOUNDINGBOX
unsigned int getArrivedNumber() const
Definition: TraCIAPI.cpp:1145
SUMOReal getHCEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:777
void setWidth(const std::string &typeID, SUMOReal width) const
Definition: TraCIAPI.cpp:1472
A 3D-bounding box.
Definition: TraCIAPI.h:81
void setEmissionClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1464
unsigned int getNextSwitch(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1274
TraCIPositionVector getShape(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1013
void setSpeedFactor(const std::string &typeID, SUMOReal factor) const
Definition: TraCIAPI.cpp:1448
#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
SUMOReal getSpeedFactor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1362
#define VAR_IMPERFECTION
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1195
SUMOReal getLastStepLength(const std::string &edgeID) const
Definition: TraCIAPI.cpp:516
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
Definition: TraCIAPI.cpp:1280
#define CMD_GET_SIM_VARIABLE
virtual std::string readString()
std::string getShapeClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1402
#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:585
SUMOReal getLastStepOccupancy(const std::string &loopID) const
Definition: TraCIAPI.cpp:680
#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:1480
TraCIColor getColor(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1018
SUMOReal getDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1377
void setPhaseDuration(const std::string &tlsID, unsigned int phaseDuration) const
Definition: TraCIAPI.cpp:1304
std::vector< std::string > getEndingTeleportIDList() const
Definition: TraCIAPI.cpp:1170
#define ADD
SUMOReal getPosition(const std::string &loopID) const
Definition: TraCIAPI.cpp:655
#define CMD_GET_JUNCTION_VARIABLE
TraCIBoundary getBoundary(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:590
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:53
SUMOReal getTimeSinceDetection(const std::string &loopID) const
Definition: TraCIAPI.cpp:690
#define VAR_DELTA_T
#define REMOVE
void setOffset(const std::string &viewID, SUMOReal x, SUMOReal y) const
Definition: TraCIAPI.cpp:603
std::string getEdgeID(const std::string &laneID) const
Definition: TraCIAPI.cpp:762
unsigned int getEndingTeleportNumber() const
Definition: TraCIAPI.cpp:1165
virtual void writeStorage(tcpip::Storage &store)
#define TL_CONTROLLED_LINKS
SUMOReal getMaxSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:732
unsigned int getLastStepVehicleNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:822
SUMOReal getLastStepMeanSpeed(const std::string &loopID) const
Definition: TraCIAPI.cpp:670
void setAccel(const std::string &typeID, SUMOReal accel) const
Definition: TraCIAPI.cpp:1496
void setImperfection(const std::string &typeID, SUMOReal imperfection) const
Definition: TraCIAPI.cpp:1512
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:772
TraCIPosition getPosition(const std::string &poiID) const
Definition: TraCIAPI.cpp:931
#define TL_RED_YELLOW_GREEN_STATE
SUMOReal getFuelConsumption(const std::string &edgeID) const
Definition: TraCIAPI.cpp:496
#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:575
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:737
#define CMD_SET_POLYGON_VARIABLE
#define VAR_COEMISSION
std::vector< TraCIAPI::TraCILogic > getCompleteRedYellowGreenDefinition(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1205
virtual void writeString(const std::string &s)
#define RTYPE_NOTIMPLEMENTED
void setType(const std::string &polygonID, const std::string &setType) const
Definition: TraCIAPI.cpp:1024
TraCIPositionVector getShape(const std::string &laneID) const
Definition: TraCIAPI.cpp:757
#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:550
#define LANE_DISALLOWED
#define TL_PROGRAM
SUMOReal getEffort(const std::string &edgeID, SUMOTime time) const
Definition: TraCIAPI.cpp:464
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:481
std::vector< std::string > getLastStepVehicleIDs(const std::string &detID) const
Definition: TraCIAPI.cpp:906
unsigned int getDepartedNumber() const
Definition: TraCIAPI.cpp:1135
void sendExact(const Storage &)
Definition: socket.cpp:394
virtual float readFloat()
#define TYPE_BYTE
std::string getType(const std::string &poiID) const
Definition: TraCIAPI.cpp:926
#define CMD_SET_LANE_VARIABLE
std::string getLaneID(const std::string &loopID) const
Definition: TraCIAPI.cpp:660
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:650
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:752
SUMOReal getNoiseEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:501
SUMOReal getAccel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1372
SUMOReal getTraveltime(const std::string &edgeID) const
Definition: TraCIAPI.cpp:521
void setZoom(const std::string &viewID, SUMOReal zoom) const
Definition: TraCIAPI.cpp:596
std::string subID
Definition: TraCIAPI.h:105
std::vector< std::string > getLastStepVehicleIDs(const std::string &laneID) const
Definition: TraCIAPI.cpp:832
virtual void writeDouble(double)
#define VAR_TELEPORT_ENDING_VEHICLES_NUMBER
SUMOReal getLastStepLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:812
void setShape(const std::string &polygonID, const TraCIPositionVector &shape) const
Definition: TraCIAPI.cpp:1032
void setColor(const std::string &typeID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:1528
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:880
unsigned int getStartingTeleportNumber() const
Definition: TraCIAPI.cpp:1155
SUMOReal getPMxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:486
void setPosition(const std::string &poiID, SUMOReal x, SUMOReal y) const
Definition: TraCIAPI.cpp:950
#define SUMOReal
Definition: config.h:214
SUMOReal getSpeedDeviation(const std::string &typeID) const
Definition: TraCIAPI.cpp:1367
SUMOReal getCO2Emission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:471
#define LAST_STEP_OCCUPANCY
unsigned int getLoadedNumber() const
Definition: TraCIAPI.cpp:1125
#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:1456
#define VAR_MAXSPEED
SUMOReal getNOxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:491
#define VAR_DECEL
TraCIAPI()
Constructor.
Definition: TraCIAPI.cpp:52
#define ID_COUNT
TraCIBoundary getNetBoundary() const
Definition: TraCIAPI.cpp:1180
std::vector< TraCIPosition > TraCIPositionVector
Definition: TraCIAPI.h:76
#define VAR_LANE_ID
unsigned int getMinExpectedNumber() const
Definition: TraCIAPI.cpp:1185
SUMOReal getAdaptedTraveltime(const std::string &edgeID, SUMOTime time) const
Definition: TraCIAPI.cpp:457
std::vector< std::string > getEdges(const std::string &routeID) const
Definition: TraCIAPI.cpp:1099
void remove(const std::string &poiID, int layer=0) const
Definition: TraCIAPI.cpp:990
SUMOReal getFloat(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:333
unsigned int getVehicleData(const std::string &loopID) const
Definition: TraCIAPI.cpp:695
unsigned int getPhase(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1269
#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:1352
SUMOReal getTau(const std::string &typeID) const
Definition: TraCIAPI.cpp:1387
unsigned int getLastStepVehicleNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:896
#define TL_PHASE_INDEX
#define VAR_ARRIVED_VEHICLES_IDS
std::vector< std::string > getLastStepVehicleIDs(const std::string &edgeID) const
Definition: TraCIAPI.cpp:536
A list of positions.
#define VAR_VIEW_OFFSET
#define LAST_STEP_VEHICLE_HALTING_NUMBER
SUMOReal getFuelConsumption(const std::string &laneID) const
Definition: TraCIAPI.cpp:792
virtual int readByte()
#define VAR_HCEMISSION
void setColor(const std::string &poiID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:959
void close()
Definition: socket.cpp:345
void add(const std::string &routeID, const std::vector< std::string > &edges) const
Definition: TraCIAPI.cpp:1105
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:891
A 3D-position.
Definition: TraCIAPI.h:62
#define VAR_WIDTH
SUMOReal getLastStepHaltingNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:531
std::vector< std::string > getStartingTeleportIDList() const
Definition: TraCIAPI.cpp:1160