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