SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TraCIAPI.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // C++ TraCI client API implementation
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
10 // Copyright (C) 2001-2014 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 // ===========================================================================
23 // included modules
24 // ===========================================================================
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include "TraCIAPI.h"
33 #include <utils/common/ToString.h>
34 
35 #ifdef CHECK_MEMORY_LEAKS
36 #include <foreign/nvwa/debug_new.h>
37 #endif // CHECK_MEMORY_LEAKS
38 
39 
40 // ===========================================================================
41 // member definitions
42 // ===========================================================================
43 // ---------------------------------------------------------------------------
44 // TraCIAPI-methods
45 // ---------------------------------------------------------------------------
46 #ifdef _MSC_VER
47 #pragma warning(disable: 4355)
48 #endif
50  : edge(*this), gui(*this), inductionloop(*this),
51  junction(*this), lane(*this), multientryexit(*this), poi(*this),
52  polygon(*this), route(*this), simulation(*this), trafficlights(*this),
53  vehicletype(*this),
54  mySocket(0) {}
55 #ifdef _MSC_VER
56 #pragma warning(default: 4355)
57 #endif
58 
59 
61  delete mySocket;
62 }
63 
64 
65 void
66 TraCIAPI::connect(const std::string& host, int port) {
67  mySocket = new tcpip::Socket(host, port);
68  try {
69  mySocket->connect();
70  } catch (tcpip::SocketException&) {
71  delete mySocket;
72  mySocket = 0;
73  throw;
74  }
75 }
76 
77 
78 void
80  if (mySocket == 0) {
81  return;
82  }
83  mySocket->close();
84  delete mySocket;
85  mySocket = 0;
86 }
87 
88 
89 void
91  tcpip::Storage outMsg;
92  // command length
93  outMsg.writeUnsignedByte(1 + 1 + 4);
94  // command id
96  outMsg.writeInt(time);
97  // send request message
98  mySocket->sendExact(outMsg);
99 }
100 
101 
102 void
104  tcpip::Storage outMsg;
105  // command length
106  outMsg.writeUnsignedByte(1 + 1);
107  // command id
109  mySocket->sendExact(outMsg);
110 }
111 
112 
113 void
114 TraCIAPI::send_commandGetVariable(int domID, int varID, const std::string& objID, tcpip::Storage* add) const {
115  if (mySocket == 0) {
116  throw tcpip::SocketException("Socket is not initialised");
117  }
118  tcpip::Storage outMsg;
119  // command length
120  unsigned int length = 1 + 1 + 1 + 4 + (int) objID.length();
121  if (add != 0) {
122  length += (int)add->size();
123  }
124  outMsg.writeUnsignedByte(length);
125  // command id
126  outMsg.writeUnsignedByte(domID);
127  // variable id
128  outMsg.writeUnsignedByte(varID);
129  // object id
130  outMsg.writeString(objID);
131  // additional values
132  if (add != 0) {
133  outMsg.writeStorage(*add);
134  }
135  // send request message
136  mySocket->sendExact(outMsg);
137 }
138 
139 
140 void
141 TraCIAPI::send_commandSetValue(int domID, int varID, const std::string& objID, tcpip::Storage& content) const {
142  if (mySocket == 0) {
143  throw tcpip::SocketException("Socket is not initialised");
144  }
145  tcpip::Storage outMsg;
146  // command length (domID, varID, objID, dataType, data)
147  outMsg.writeUnsignedByte(1 + 1 + 1 + 4 + (int) objID.length() + (int)content.size());
148  // command id
149  outMsg.writeUnsignedByte(domID);
150  // variable id
151  outMsg.writeUnsignedByte(varID);
152  // object id
153  outMsg.writeString(objID);
154  // data type
155  outMsg.writeStorage(content);
156  // send message
157  mySocket->sendExact(outMsg);
158 }
159 
160 
161 void
162 TraCIAPI::send_commandSubscribeObjectVariable(int domID, const std::string& objID, int beginTime, int endTime,
163  const std::vector<int>& vars) const {
164  if (mySocket == 0) {
165  throw tcpip::SocketException("Socket is not initialised");
166  }
167  tcpip::Storage outMsg;
168  // command length (domID, objID, beginTime, endTime, length, vars)
169  int varNo = (int) vars.size();
170  outMsg.writeUnsignedByte(0);
171  outMsg.writeInt(5 + 1 + 4 + 4 + 4 + (int) objID.length() + 1 + varNo);
172  // command id
173  outMsg.writeUnsignedByte(domID);
174  // time
175  outMsg.writeInt(beginTime);
176  outMsg.writeInt(endTime);
177  // object id
178  outMsg.writeString(objID);
179  // command id
180  outMsg.writeUnsignedByte((int)vars.size());
181  for (int i = 0; i < varNo; ++i) {
182  outMsg.writeUnsignedByte(vars[i]);
183  }
184  // send message
185  mySocket->sendExact(outMsg);
186 }
187 
188 
189 void
190 TraCIAPI::send_commandSubscribeObjectContext(int domID, const std::string& objID, int beginTime, int endTime,
191  int domain, SUMOReal range, const std::vector<int>& vars) const {
192  if (mySocket == 0) {
193  throw tcpip::SocketException("Socket is not initialised");
194  }
195  tcpip::Storage outMsg;
196  // command length (domID, objID, beginTime, endTime, length, vars)
197  int varNo = (int) vars.size();
198  outMsg.writeUnsignedByte(0);
199  outMsg.writeInt(5 + 1 + 4 + 4 + 4 + (int) objID.length() + 1 + 8 + 1 + varNo);
200  // command id
201  outMsg.writeUnsignedByte(domID);
202  // time
203  outMsg.writeInt(beginTime);
204  outMsg.writeInt(endTime);
205  // object id
206  outMsg.writeString(objID);
207  // domain and range
208  outMsg.writeUnsignedByte(domain);
209  outMsg.writeDouble(range);
210  // command id
211  outMsg.writeUnsignedByte((int)vars.size());
212  for (int i = 0; i < varNo; ++i) {
213  outMsg.writeUnsignedByte(vars[i]);
214  }
215  // send message
216  mySocket->sendExact(outMsg);
217 }
218 
219 
220 
221 
222 void
223 TraCIAPI::check_resultState(tcpip::Storage& inMsg, int command, bool ignoreCommandId, std::string* acknowledgement) const {
224  mySocket->receiveExact(inMsg);
225  int cmdLength;
226  int cmdId;
227  int resultType;
228  int cmdStart;
229  std::string msg;
230  try {
231  cmdStart = inMsg.position();
232  cmdLength = inMsg.readUnsignedByte();
233  cmdId = inMsg.readUnsignedByte();
234  if (command != cmdId && !ignoreCommandId) {
235  throw tcpip::SocketException("#Error: received status response to command: " + toString(cmdId) + " but expected: " + toString(command));
236  }
237  resultType = inMsg.readUnsignedByte();
238  msg = inMsg.readString();
239  } catch (std::invalid_argument&) {
240  throw tcpip::SocketException("#Error: an exception was thrown while reading result state message");
241  }
242  switch (resultType) {
243  case RTYPE_ERR:
244  throw tcpip::SocketException(".. Answered with error to command (" + toString(command) + "), [description: " + msg + "]");
246  throw tcpip::SocketException(".. Sent command is not implemented (" + toString(command) + "), [description: " + msg + "]");
247  case RTYPE_OK:
248  if (acknowledgement != 0) {
249  (*acknowledgement) = ".. Command acknowledged (" + toString(command) + "), [description: " + msg + "]";
250  }
251  break;
252  default:
253  throw tcpip::SocketException(".. Answered with unknown result code(" + toString(resultType) + ") to command(" + toString(command) + "), [description: " + msg + "]");
254  }
255  if ((cmdStart + cmdLength) != (int) inMsg.position()) {
256  throw tcpip::SocketException("#Error: command at position " + toString(cmdStart) + " has wrong length");
257  }
258 }
259 
260 
261 void
262 TraCIAPI::check_commandGetResult(tcpip::Storage& inMsg, int command, int expectedType, bool ignoreCommandId) const {
263  inMsg.position(); // respStart
264  int length = inMsg.readUnsignedByte();
265  if (length == 0) {
266  length = inMsg.readInt();
267  }
268  int cmdId = inMsg.readUnsignedByte();
269  if (!ignoreCommandId && cmdId != (command + 0x10)) {
270  throw tcpip::SocketException("#Error: received response with command id: " + toString(cmdId) + "but expected: " + toString(command + 0x10));
271  }
272  if (expectedType >= 0) {
273  int valueDataType = inMsg.readUnsignedByte();
274  if (valueDataType != expectedType) {
275  throw tcpip::SocketException("Expected " + toString(expectedType) + " but got " + toString(valueDataType));
276  }
277  }
278 }
279 
280 
281 void
282 TraCIAPI::processGET(tcpip::Storage& inMsg, int command, int expectedType, bool ignoreCommandId) const {
283  check_resultState(inMsg, command, ignoreCommandId);
284  check_commandGetResult(inMsg, command, expectedType, ignoreCommandId);
285 }
286 
287 
288 
289 
290 SUMOTime
291 TraCIAPI::getSUMOTime(int cmd, int var, const std::string& id, tcpip::Storage* add) {
292  tcpip::Storage inMsg;
293  send_commandGetVariable(cmd, var, id, add);
294  processGET(inMsg, cmd, TYPE_INTEGER);
295  return inMsg.readInt();
296 }
297 
298 
299 int
300 TraCIAPI::getUnsignedByte(int cmd, int var, const std::string& id, tcpip::Storage* add) {
301  tcpip::Storage inMsg;
302  send_commandGetVariable(cmd, var, id, add);
303  processGET(inMsg, cmd, TYPE_UBYTE);
304  return inMsg.readUnsignedByte();
305 }
306 
307 
308 int
309 TraCIAPI::getByte(int cmd, int var, const std::string& id, tcpip::Storage* add) {
310  tcpip::Storage inMsg;
311  send_commandGetVariable(cmd, var, id, add);
312  processGET(inMsg, cmd, TYPE_BYTE);
313  return inMsg.readByte();
314 }
315 
316 
317 int
318 TraCIAPI::getInt(int cmd, int var, const std::string& id, tcpip::Storage* add) {
319  tcpip::Storage inMsg;
320  send_commandGetVariable(cmd, var, id, add);
321  processGET(inMsg, cmd, TYPE_INTEGER);
322  return inMsg.readInt();
323 }
324 
325 
326 SUMOReal
327 TraCIAPI::getFloat(int cmd, int var, const std::string& id, tcpip::Storage* add) {
328  tcpip::Storage inMsg;
329  send_commandGetVariable(cmd, var, id, add);
330  processGET(inMsg, cmd, TYPE_FLOAT);
331  return inMsg.readFloat();
332 }
333 
334 
335 SUMOReal
336 TraCIAPI::getDouble(int cmd, int var, const std::string& id, tcpip::Storage* add) {
337  tcpip::Storage inMsg;
338  send_commandGetVariable(cmd, var, id, add);
339  processGET(inMsg, cmd, TYPE_DOUBLE);
340  return inMsg.readDouble();
341 }
342 
343 
345 TraCIAPI::getBoundingBox(int cmd, int var, const std::string& id, tcpip::Storage* add) {
346  tcpip::Storage inMsg;
347  send_commandGetVariable(cmd, var, id, add);
348  processGET(inMsg, cmd, TYPE_BOUNDINGBOX);
349  TraCIBoundary b;
350  b.xMin = inMsg.readDouble();
351  b.yMin = inMsg.readDouble();
352  b.zMin = 0;
353  b.xMax = inMsg.readDouble();
354  b.yMax = inMsg.readDouble();
355  b.zMax = 0;
356  return b;
357 }
358 
359 
361 TraCIAPI::getPolygon(int cmd, int var, const std::string& id, tcpip::Storage* add) {
362  tcpip::Storage inMsg;
363  send_commandGetVariable(cmd, var, id, add);
364  processGET(inMsg, cmd, TYPE_POLYGON);
365  unsigned int size = inMsg.readInt();
367  for (unsigned int i = 0; i < size; ++i) {
368  TraCIPosition p;
369  p.x = inMsg.readDouble();
370  p.y = inMsg.readDouble();
371  p.z = 0;
372  ret.push_back(p);
373  }
374  return ret;
375 }
376 
377 
379 TraCIAPI::getPosition(int cmd, int var, const std::string& id, tcpip::Storage* add) {
380  tcpip::Storage inMsg;
381  send_commandGetVariable(cmd, var, id, add);
382  processGET(inMsg, cmd, POSITION_2D);
383  TraCIPosition p;
384  p.x = inMsg.readDouble();
385  p.y = inMsg.readDouble();
386  p.z = 0;
387  return p;
388 }
389 
390 
391 std::string
392 TraCIAPI::getString(int cmd, int var, const std::string& id, tcpip::Storage* add) {
393  tcpip::Storage inMsg;
394  send_commandGetVariable(cmd, var, id, add);
395  processGET(inMsg, cmd, TYPE_STRING);
396  return inMsg.readString();
397 }
398 
399 
400 std::vector<std::string>
401 TraCIAPI::getStringVector(int cmd, int var, const std::string& id, tcpip::Storage* add) {
402  tcpip::Storage inMsg;
403  send_commandGetVariable(cmd, var, id, add);
404  processGET(inMsg, cmd, TYPE_STRINGLIST);
405  unsigned int size = inMsg.readInt();
406  std::vector<std::string> r;
407  for (unsigned int i = 0; i < size; ++i) {
408  r.push_back(inMsg.readString());
409  }
410  return r;
411 }
412 
413 
415 TraCIAPI::getColor(int cmd, int var, const std::string& id, tcpip::Storage* add) {
416  tcpip::Storage inMsg;
417  send_commandGetVariable(cmd, var, id, add);
418  processGET(inMsg, cmd, TYPE_COLOR);
419  TraCIColor c;
420  c.r = inMsg.readUnsignedByte();
421  c.g = inMsg.readUnsignedByte();
422  c.b = inMsg.readUnsignedByte();
423  c.a = inMsg.readUnsignedByte();
424  return c;
425 }
426 
427 
428 
429 // ---------------------------------------------------------------------------
430 // TraCIAPI::EdgeScope-methods
431 // ---------------------------------------------------------------------------
432 std::vector<std::string>
435 }
436 
437 unsigned int
439  return myParent.getInt(CMD_GET_EDGE_VARIABLE, ID_COUNT, "");
440 }
441 
442 SUMOReal
443 TraCIAPI::EdgeScope::getAdaptedTraveltime(const std::string& edgeID, SUMOTime time) const {
444  tcpip::Storage content;
445  content.writeInt(time);
446  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CO2EMISSION, edgeID, &content);
447 }
448 
449 SUMOReal
450 TraCIAPI::EdgeScope::getEffort(const std::string& edgeID, SUMOTime time) const {
451  tcpip::Storage content;
452  content.writeInt(time);
453  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CO2EMISSION, edgeID, &content);
454 }
455 
456 SUMOReal
457 TraCIAPI::EdgeScope::getCO2Emission(const std::string& edgeID) const {
458  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CO2EMISSION, edgeID);
459 }
460 
461 SUMOReal
462 TraCIAPI::EdgeScope::getCOEmission(const std::string& edgeID) const {
463  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_COEMISSION, edgeID);
464 }
465 
466 SUMOReal
467 TraCIAPI::EdgeScope::getHCEmission(const std::string& edgeID) const {
468  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_HCEMISSION, edgeID);
469 }
470 
471 SUMOReal
472 TraCIAPI::EdgeScope::getPMxEmission(const std::string& edgeID) const {
473  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_PMXEMISSION, edgeID);
474 }
475 
476 SUMOReal
477 TraCIAPI::EdgeScope::getNOxEmission(const std::string& edgeID) const {
478  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_NOXEMISSION, edgeID);
479 }
480 
481 SUMOReal
482 TraCIAPI::EdgeScope::getFuelConsumption(const std::string& edgeID) const {
483  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_FUELCONSUMPTION, edgeID);
484 }
485 
486 SUMOReal
487 TraCIAPI::EdgeScope::getNoiseEmission(const std::string& edgeID) const {
488  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_NOISEEMISSION, edgeID);
489 }
490 
491 SUMOReal
492 TraCIAPI::EdgeScope::getLastStepMeanSpeed(const std::string& edgeID) const {
493  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_MEAN_SPEED, edgeID);
494 }
495 
496 SUMOReal
497 TraCIAPI::EdgeScope::getLastStepOccupancy(const std::string& edgeID) const {
498  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_OCCUPANCY, edgeID);
499 }
500 
501 SUMOReal
502 TraCIAPI::EdgeScope::getLastStepLength(const std::string& edgeID) const {
503  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, LAST_STEP_LENGTH, edgeID);
504 }
505 
506 SUMOReal
507 TraCIAPI::EdgeScope::getTraveltime(const std::string& edgeID) const {
508  return myParent.getDouble(CMD_GET_EDGE_VARIABLE, VAR_CURRENT_TRAVELTIME, edgeID);
509 }
510 
511 unsigned int
512 TraCIAPI::EdgeScope::getLastStepVehicleNumber(const std::string& edgeID) const {
513  return myParent.getInt(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_NUMBER, edgeID);
514 }
515 
516 SUMOReal
517 TraCIAPI::EdgeScope::getLastStepHaltingNumber(const std::string& edgeID) const {
518  return myParent.getInt(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_HALTING_NUMBER, edgeID);
519 }
520 
521 std::vector<std::string>
522 TraCIAPI::EdgeScope::getLastStepVehicleIDs(const std::string& edgeID) const {
523  return myParent.getStringVector(CMD_GET_EDGE_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, edgeID);
524 }
525 
526 
527 
528 void
529 TraCIAPI::EdgeScope::adaptTraveltime(const std::string& edgeID, SUMOReal time) const {
530  tcpip::Storage content;
531  content.writeDouble(time);
532  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_EDGE_TRAVELTIME, edgeID, content);
533 }
534 
535 void
536 TraCIAPI::EdgeScope::setEffort(const std::string& edgeID, SUMOReal effort) const {
537  tcpip::Storage content;
538  content.writeDouble(effort);
539  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_EDGE_EFFORT, edgeID, content);
540 }
541 
542 void
543 TraCIAPI::EdgeScope::setMaxSpeed(const std::string& edgeID, SUMOReal speed) const {
544  tcpip::Storage content;
545  content.writeDouble(speed);
546  myParent.send_commandSetValue(CMD_SET_EDGE_VARIABLE, VAR_MAXSPEED, edgeID, content);
547 }
548 
549 
550 
551 
552 // ---------------------------------------------------------------------------
553 // TraCIAPI::GUIScope-methods
554 // ---------------------------------------------------------------------------
555 std::vector<std::string>
557  return myParent.getStringVector(CMD_GET_GUI_VARIABLE, ID_LIST, "");
558 }
559 
560 SUMOReal
561 TraCIAPI::GUIScope::getZoom(const std::string& viewID) const {
562  return myParent.getDouble(CMD_GET_GUI_VARIABLE, VAR_VIEW_ZOOM, viewID);
563 }
564 
566 TraCIAPI::GUIScope::getOffset(const std::string& viewID) const {
567  return myParent.getPosition(CMD_GET_GUI_VARIABLE, VAR_VIEW_OFFSET, viewID);
568 }
569 
570 std::string
571 TraCIAPI::GUIScope::getSchema(const std::string& viewID) const {
572  return myParent.getString(CMD_GET_GUI_VARIABLE, VAR_VIEW_SCHEMA, viewID);
573 }
574 
576 TraCIAPI::GUIScope::getBoundary(const std::string& viewID) const {
577  return myParent.getBoundingBox(CMD_GET_GUI_VARIABLE, VAR_VIEW_BOUNDARY, viewID);
578 }
579 
580 
581 void
582 TraCIAPI::GUIScope::setZoom(const std::string& viewID, SUMOReal zoom) const {
583  tcpip::Storage content;
584  content.writeDouble(zoom);
585  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_ZOOM, viewID, content);
586 }
587 
588 void
589 TraCIAPI::GUIScope::setOffset(const std::string& viewID, SUMOReal x, SUMOReal y) const {
590  tcpip::Storage content;
592  content.writeDouble(x);
593  content.writeDouble(y);
594  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_OFFSET, viewID, content);
595 }
596 
597 void
598 TraCIAPI::GUIScope::setSchema(const std::string& viewID, const std::string& schemeName) const {
599  tcpip::Storage content;
600  content.writeString(schemeName);
601  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_SCHEMA, viewID, content);
602 }
603 
604 void
605 TraCIAPI::GUIScope::setBoundary(const std::string& viewID, SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax) const {
606  tcpip::Storage content;
608  content.writeDouble(xmin);
609  content.writeDouble(ymin);
610  content.writeDouble(xmax);
611  content.writeDouble(ymax);
612  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_VIEW_BOUNDARY, viewID, content);
613 }
614 
615 void
616 TraCIAPI::GUIScope::screenshot(const std::string& viewID, const std::string& filename) const {
617  tcpip::Storage content;
618  content.writeString(filename);
619  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_SCREENSHOT, viewID, content);
620 }
621 
622 void
623 TraCIAPI::GUIScope::trackVehicle(const std::string& viewID, const std::string& vehID) const {
624  tcpip::Storage content;
625  content.writeString(vehID);
626  myParent.send_commandSetValue(CMD_SET_GUI_VARIABLE, VAR_TRACK_VEHICLE, viewID, content);
627 }
628 
629 
630 
631 
632 // ---------------------------------------------------------------------------
633 // TraCIAPI::InductionLoopScope-methods
634 // ---------------------------------------------------------------------------
635 std::vector<std::string>
637  return myParent.getStringVector(CMD_GET_INDUCTIONLOOP_VARIABLE, ID_LIST, "");
638 }
639 
640 SUMOReal
641 TraCIAPI::InductionLoopScope::getPosition(const std::string& loopID) const {
642  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, VAR_POSITION, loopID);
643 }
644 
645 std::string
646 TraCIAPI::InductionLoopScope::getLaneID(const std::string& loopID) const {
647  return myParent.getString(CMD_GET_INDUCTIONLOOP_VARIABLE, VAR_LANE_ID, loopID);
648 }
649 
650 unsigned int
652  return myParent.getInt(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_NUMBER, loopID);
653 }
654 
655 SUMOReal
656 TraCIAPI::InductionLoopScope::getLastStepMeanSpeed(const std::string& loopID) const {
657  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_MEAN_SPEED, loopID);
658 }
659 
660 std::vector<std::string>
661 TraCIAPI::InductionLoopScope::getLastStepVehicleIDs(const std::string& loopID) const {
662  return myParent.getStringVector(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, loopID);
663 }
664 
665 SUMOReal
666 TraCIAPI::InductionLoopScope::getLastStepOccupancy(const std::string& loopID) const {
667  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_OCCUPANCY, loopID);
668 }
669 
670 SUMOReal
671 TraCIAPI::InductionLoopScope::getLastStepMeanLength(const std::string& loopID) const {
672  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_LENGTH, loopID);
673 }
674 
675 SUMOReal
676 TraCIAPI::InductionLoopScope::getTimeSinceDetection(const std::string& loopID) const {
677  return myParent.getDouble(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_TIME_SINCE_DETECTION, loopID);
678 }
679 
680 unsigned int
681 TraCIAPI::InductionLoopScope::getVehicleData(const std::string& loopID) const {
682  return myParent.getInt(CMD_GET_INDUCTIONLOOP_VARIABLE, LAST_STEP_VEHICLE_DATA, loopID);
683 }
684 
685 
686 
687 
688 // ---------------------------------------------------------------------------
689 // TraCIAPI::JunctionScope-methods
690 // ---------------------------------------------------------------------------
691 std::vector<std::string>
693  return myParent.getStringVector(CMD_GET_JUNCTION_VARIABLE, ID_LIST, "");
694 }
695 
697 TraCIAPI::JunctionScope::getPosition(const std::string& junctionID) const {
698  return myParent.getPosition(CMD_GET_JUNCTION_VARIABLE, VAR_POSITION, junctionID);
699 }
700 
701 
702 
703 
704 // ---------------------------------------------------------------------------
705 // TraCIAPI::LaneScope-methods
706 // ---------------------------------------------------------------------------
707 std::vector<std::string>
709  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, ID_LIST, "");
710 }
711 
712 SUMOReal
713 TraCIAPI::LaneScope::getLength(const std::string& laneID) const {
714  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_LENGTH, laneID);
715 }
716 
717 SUMOReal
718 TraCIAPI::LaneScope::getMaxSpeed(const std::string& laneID) const {
719  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_MAXSPEED, laneID);
720 }
721 
722 SUMOReal
723 TraCIAPI::LaneScope::getWidth(const std::string& laneID) const {
724  return myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_WIDTH, laneID);
725 }
726 
727 std::vector<std::string>
728 TraCIAPI::LaneScope::getAllowed(const std::string& laneID) const {
729  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, LANE_ALLOWED, laneID);
730 }
731 
732 std::vector<std::string>
733 TraCIAPI::LaneScope::getDisallowed(const std::string& laneID) const {
734  return myParent.getStringVector(CMD_GET_LANE_VARIABLE, LANE_DISALLOWED, laneID);
735 }
736 
737 unsigned int
738 TraCIAPI::LaneScope::getLinkNumber(const std::string& /* laneID */) const {
739  throw tcpip::SocketException("Not implemented!");
740 }
741 
743 TraCIAPI::LaneScope::getShape(const std::string& laneID) const {
744  throw myParent.getPolygon(CMD_GET_LANE_VARIABLE, VAR_SHAPE, laneID);
745 }
746 
747 std::string
748 TraCIAPI::LaneScope::getEdgeID(const std::string& laneID) const {
749  throw myParent.getString(CMD_GET_LANE_VARIABLE, LANE_EDGE_ID, laneID);
750 }
751 
752 SUMOReal
753 TraCIAPI::LaneScope::getCO2Emission(const std::string& laneID) const {
754  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_CO2EMISSION, laneID);
755 }
756 
757 SUMOReal
758 TraCIAPI::LaneScope::getCOEmission(const std::string& laneID) const {
759  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_COEMISSION, laneID);
760 }
761 
762 SUMOReal
763 TraCIAPI::LaneScope::getHCEmission(const std::string& laneID) const {
764  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_HCEMISSION, laneID);
765 }
766 
767 SUMOReal
768 TraCIAPI::LaneScope::getPMxEmission(const std::string& laneID) const {
769  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_PMXEMISSION, laneID);
770 }
771 
772 SUMOReal
773 TraCIAPI::LaneScope::getNOxEmission(const std::string& laneID) const {
774  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_NOXEMISSION, laneID);
775 }
776 
777 SUMOReal
778 TraCIAPI::LaneScope::getFuelConsumption(const std::string& laneID) const {
779  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_FUELCONSUMPTION, laneID);
780 }
781 
782 SUMOReal
783 TraCIAPI::LaneScope::getNoiseEmission(const std::string& laneID) const {
784  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_NOISEEMISSION, laneID);
785 }
786 
787 SUMOReal
788 TraCIAPI::LaneScope::getLastStepMeanSpeed(const std::string& laneID) const {
789  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_MEAN_SPEED, laneID);
790 }
791 
792 SUMOReal
793 TraCIAPI::LaneScope::getLastStepOccupancy(const std::string& laneID) const {
794  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_OCCUPANCY, laneID);
795 }
796 
797 SUMOReal
798 TraCIAPI::LaneScope::getLastStepLength(const std::string& laneID) const {
799  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, LAST_STEP_LENGTH, laneID);
800 }
801 
802 SUMOReal
803 TraCIAPI::LaneScope::getTraveltime(const std::string& laneID) const {
804  throw myParent.getDouble(CMD_GET_LANE_VARIABLE, VAR_CURRENT_TRAVELTIME, laneID);
805 }
806 
807 unsigned int
808 TraCIAPI::LaneScope::getLastStepVehicleNumber(const std::string& laneID) const {
809  throw myParent.getInt(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_NUMBER, laneID);
810 }
811 
812 unsigned int
813 TraCIAPI::LaneScope::getLastStepHaltingNumber(const std::string& laneID) const {
814  throw myParent.getInt(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_HALTING_NUMBER, laneID);
815 }
816 
817 std::vector<std::string>
818 TraCIAPI::LaneScope::getLastStepVehicleIDs(const std::string& laneID) const {
819  throw myParent.getStringVector(CMD_GET_LANE_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, laneID);
820 }
821 
822 
823 void
824 TraCIAPI::LaneScope::setAllowed(const std::string& laneID, const std::vector<std::string>& allowedClasses) const {
825  tcpip::Storage content;
827  content.writeInt((int)allowedClasses.size());
828  for (unsigned int i = 0; i < allowedClasses.size(); ++i) {
829  content.writeString(allowedClasses[i]);
830  }
831  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, LANE_ALLOWED, laneID, content);
832 }
833 
834 void
835 TraCIAPI::LaneScope::setDisallowed(const std::string& laneID, const std::vector<std::string>& disallowedClasses) const {
836  tcpip::Storage content;
838  content.writeInt((int)disallowedClasses.size());
839  for (unsigned int i = 0; i < disallowedClasses.size(); ++i) {
840  content.writeString(disallowedClasses[i]);
841  }
842  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, LANE_DISALLOWED, laneID, content);
843 }
844 
845 void
846 TraCIAPI::LaneScope::setMaxSpeed(const std::string& laneID, SUMOReal speed) const {
847  tcpip::Storage content;
849  content.writeDouble(speed);
850  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, VAR_MAXSPEED, laneID, content);
851 }
852 
853 void
854 TraCIAPI::LaneScope::setLength(const std::string& laneID, SUMOReal length) const {
855  tcpip::Storage content;
857  content.writeDouble(length);
858  myParent.send_commandSetValue(CMD_SET_LANE_VARIABLE, VAR_LENGTH, laneID, content);
859 }
860 
861 
862 // ---------------------------------------------------------------------------
863 // TraCIAPI::AreaDetector-methods
864 // ---------------------------------------------------------------------------
865 std::vector<std::string>
867  return myParent.getStringVector(CMD_GET_AREAL_DETECTOR_VARIABLE, ID_LIST, "");
868 }
869 
870 
871 
872 
873 // ---------------------------------------------------------------------------
874 // TraCIAPI::MeMeScope-methods
875 // ---------------------------------------------------------------------------
876 std::vector<std::string>
878  return myParent.getStringVector(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, ID_LIST, "");
879 }
880 
881 unsigned int
882 TraCIAPI::MeMeScope::getLastStepVehicleNumber(const std::string& detID) const {
884 }
885 
886 SUMOReal
887 TraCIAPI::MeMeScope::getLastStepMeanSpeed(const std::string& detID) const {
889 }
890 
891 std::vector<std::string>
892 TraCIAPI::MeMeScope::getLastStepVehicleIDs(const std::string& detID) const {
893  return myParent.getStringVector(CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE, LAST_STEP_VEHICLE_ID_LIST, detID);
894 }
895 
896 unsigned int
897 TraCIAPI::MeMeScope::getLastStepHaltingNumber(const std::string& detID) const {
899 }
900 
901 
902 
903 // ---------------------------------------------------------------------------
904 // TraCIAPI::POIScope-methods
905 // ---------------------------------------------------------------------------
906 std::vector<std::string>
908  return myParent.getStringVector(CMD_GET_POI_VARIABLE, ID_LIST, "");
909 }
910 
911 std::string
912 TraCIAPI::POIScope::getType(const std::string& poiID) const {
913  return myParent.getString(CMD_GET_POI_VARIABLE, VAR_TYPE, poiID);
914 }
915 
917 TraCIAPI::POIScope::getPosition(const std::string& poiID) const {
918  return myParent.getPosition(CMD_GET_POI_VARIABLE, VAR_POSITION, poiID);
919 }
920 
922 TraCIAPI::POIScope::getColor(const std::string& poiID) const {
923  return myParent.getColor(CMD_GET_POI_VARIABLE, VAR_COLOR, poiID);
924 }
925 
926 
927 void
928 TraCIAPI::POIScope::setType(const std::string& poiID, const std::string& setType) const {
929  tcpip::Storage content;
931  content.writeString(setType);
932  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_TYPE, poiID, content);
933 }
934 
935 void
936 TraCIAPI::POIScope::setPosition(const std::string& poiID, SUMOReal x, SUMOReal y) const {
937  tcpip::Storage content;
939  content.writeDouble(x);
940  content.writeDouble(y);
941  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_POSITION, poiID, content);
942 }
943 
944 void
945 TraCIAPI::POIScope::setColor(const std::string& poiID, const TraCIColor& c) const {
946  tcpip::Storage content;
947  content.writeUnsignedByte(TYPE_COLOR);
948  content.writeUnsignedByte(c.r);
949  content.writeUnsignedByte(c.g);
950  content.writeUnsignedByte(c.b);
951  content.writeUnsignedByte(c.a);
952  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, VAR_COLOR, poiID, content);
953 }
954 
955 void
956 TraCIAPI::POIScope::add(const std::string& poiID, SUMOReal x, SUMOReal y, const TraCIColor& c, const std::string& type, int layer) const {
957  tcpip::Storage content;
959  content.writeInt(4);
961  content.writeString(type);
962  content.writeUnsignedByte(TYPE_COLOR);
963  content.writeUnsignedByte(c.r);
964  content.writeUnsignedByte(c.g);
965  content.writeUnsignedByte(c.b);
966  content.writeUnsignedByte(c.a);
968  content.writeInt(layer);
970  content.writeDouble(x);
971  content.writeDouble(y);
972  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, ADD, poiID, content);
973 }
974 
975 void
976 TraCIAPI::POIScope::remove(const std::string& poiID, int layer) const {
977  tcpip::Storage content;
979  content.writeInt(layer);
980  myParent.send_commandSetValue(CMD_SET_POI_VARIABLE, REMOVE, poiID, content);
981 }
982 
983 
984 
985 // ---------------------------------------------------------------------------
986 // TraCIAPI::PolygonScope-methods
987 // ---------------------------------------------------------------------------
988 std::vector<std::string>
990  return myParent.getStringVector(CMD_GET_POLYGON_VARIABLE, ID_LIST, "");
991 }
992 
993 std::string
994 TraCIAPI::PolygonScope::getType(const std::string& polygonID) const {
995  return myParent.getString(CMD_GET_POLYGON_VARIABLE, VAR_TYPE, polygonID);
996 }
997 
999 TraCIAPI::PolygonScope::getShape(const std::string& polygonID) const {
1000  return myParent.getPolygon(CMD_GET_POLYGON_VARIABLE, VAR_SHAPE, polygonID);
1001 }
1002 
1004 TraCIAPI::PolygonScope::getColor(const std::string& polygonID) const {
1005  return myParent.getColor(CMD_GET_POLYGON_VARIABLE, VAR_COLOR, polygonID);
1006 }
1007 
1008 
1009 void
1010 TraCIAPI::PolygonScope::setType(const std::string& polygonID, const std::string& setType) const {
1011  tcpip::Storage content;
1012  content.writeUnsignedByte(TYPE_STRING);
1013  content.writeString(setType);
1014  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_TYPE, polygonID, content);
1015 }
1016 
1017 void
1018 TraCIAPI::PolygonScope::setShape(const std::string& polygonID, const TraCIAPI::TraCIPositionVector& shape) const {
1019  tcpip::Storage content;
1021  content.writeInt((int)shape.size());
1022  for (unsigned int i = 0; i < shape.size(); ++i) {
1023  content.writeDouble(shape[i].x);
1024  content.writeDouble(shape[i].y);
1025  }
1026  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_POSITION, polygonID, content);
1027 }
1028 
1029 void
1030 TraCIAPI::PolygonScope::setColor(const std::string& polygonID, const TraCIColor& c) const {
1031  tcpip::Storage content;
1032  content.writeUnsignedByte(TYPE_COLOR);
1033  content.writeUnsignedByte(c.r);
1034  content.writeUnsignedByte(c.g);
1035  content.writeUnsignedByte(c.b);
1036  content.writeUnsignedByte(c.a);
1037  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, VAR_COLOR, polygonID, content);
1038 }
1039 
1040 void
1041 TraCIAPI::PolygonScope::add(const std::string& polygonID, const TraCIAPI::TraCIPositionVector& shape, const TraCIColor& c, bool fill, const std::string& type, int layer) const {
1042  tcpip::Storage content;
1044  content.writeInt(4);
1045  content.writeUnsignedByte(TYPE_STRING);
1046  content.writeString(type);
1047  content.writeUnsignedByte(TYPE_COLOR);
1048  content.writeUnsignedByte(c.r);
1049  content.writeUnsignedByte(c.g);
1050  content.writeUnsignedByte(c.b);
1051  content.writeUnsignedByte(c.a);
1052  content.writeUnsignedByte(TYPE_UBYTE);
1053  int f = fill ? 1 : 0;
1054  content.writeUnsignedByte(f);
1056  content.writeInt(layer);
1058  content.writeInt((int)shape.size());
1059  for (unsigned int i = 0; i < shape.size(); ++i) {
1060  content.writeDouble(shape[i].x);
1061  content.writeDouble(shape[i].y);
1062  }
1063  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, ADD, polygonID, content);
1064 }
1065 
1066 void
1067 TraCIAPI::PolygonScope::remove(const std::string& polygonID, int layer) const {
1068  tcpip::Storage content;
1070  content.writeInt(layer);
1071  myParent.send_commandSetValue(CMD_SET_POLYGON_VARIABLE, REMOVE, polygonID, content);
1072 }
1073 
1074 
1075 
1076 // ---------------------------------------------------------------------------
1077 // TraCIAPI::RouteScope-methods
1078 // ---------------------------------------------------------------------------
1079 std::vector<std::string>
1081  return myParent.getStringVector(CMD_GET_ROUTE_VARIABLE, ID_LIST, "");
1082 }
1083 
1084 std::vector<std::string>
1085 TraCIAPI::RouteScope::getEdges(const std::string& routeID) const {
1086  return myParent.getStringVector(CMD_GET_ROUTE_VARIABLE, VAR_EDGES, routeID);
1087 }
1088 
1089 
1090 void
1091 TraCIAPI::RouteScope::add(const std::string& routeID, const std::vector<std::string>& edges) const {
1092  tcpip::Storage content;
1094  content.writeStringList(edges);
1095  myParent.send_commandSetValue(CMD_SET_ROUTE_VARIABLE, VAR_POSITION, routeID, content);
1096 }
1097 
1098 
1099 
1100 
1101 
1102 // ---------------------------------------------------------------------------
1103 // TraCIAPI::SimulationScope-methods
1104 // ---------------------------------------------------------------------------
1105 SUMOTime
1107  return myParent.getSUMOTime(CMD_GET_SIM_VARIABLE, VAR_TIME_STEP, "");
1108 }
1109 
1110 unsigned int
1112  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_LOADED_VEHICLES_NUMBER, "");
1113 }
1114 
1115 std::vector<std::string>
1117  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_LOADED_VEHICLES_IDS, "");
1118 }
1119 
1120 unsigned int
1122  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_DEPARTED_VEHICLES_NUMBER, "");
1123 }
1124 
1125 std::vector<std::string>
1127  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_DEPARTED_VEHICLES_IDS, "");
1128 }
1129 
1130 unsigned int
1132  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_ARRIVED_VEHICLES_NUMBER, "");
1133 }
1134 
1135 std::vector<std::string>
1137  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_ARRIVED_VEHICLES_IDS, "");
1138 }
1139 
1140 unsigned int
1142  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_STARTING_VEHICLES_NUMBER, "");
1143 }
1144 
1145 std::vector<std::string>
1147  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_STARTING_VEHICLES_IDS, "");
1148 }
1149 
1150 unsigned int
1152  return (unsigned int) myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_ENDING_VEHICLES_NUMBER, "");
1153 }
1154 
1155 std::vector<std::string>
1157  return myParent.getStringVector(CMD_GET_SIM_VARIABLE, VAR_TELEPORT_ENDING_VEHICLES_IDS, "");
1158 }
1159 
1160 SUMOTime
1162  return myParent.getSUMOTime(CMD_GET_SIM_VARIABLE, VAR_DELTA_T, "");
1163 }
1164 
1167  return myParent.getBoundingBox(CMD_GET_SIM_VARIABLE, VAR_NET_BOUNDING_BOX, "");
1168 }
1169 
1170 unsigned int
1172  return myParent.getInt(CMD_GET_SIM_VARIABLE, VAR_MIN_EXPECTED_VEHICLES, "");
1173 }
1174 
1175 
1176 
1177 // ---------------------------------------------------------------------------
1178 // TraCIAPI::TrafficLightScope-methods
1179 // ---------------------------------------------------------------------------
1180 std::vector<std::string>
1182  return myParent.getStringVector(CMD_GET_TL_VARIABLE, ID_LIST, "");
1183 }
1184 
1185 std::string
1187  return myParent.getString(CMD_GET_TL_VARIABLE, TL_RED_YELLOW_GREEN_STATE, tlsID);
1188 }
1189 
1190 std::vector<TraCIAPI::TraCILogic>
1192  tcpip::Storage inMsg;
1193  myParent.send_commandGetVariable(CMD_GET_TL_VARIABLE, TL_COMPLETE_DEFINITION_RYG, tlsID);
1194  myParent.processGET(inMsg, CMD_GET_TL_VARIABLE, TYPE_COMPOUND);
1195  std::vector<TraCIAPI::TraCILogic> ret;
1196  int logicNo = inMsg.readInt();
1197  for (int i = 0; i < logicNo; ++i) {
1198  inMsg.readUnsignedByte();
1199  std::string subID = inMsg.readString();
1200  inMsg.readUnsignedByte();
1201  int type = inMsg.readInt();
1202  inMsg.readUnsignedByte();
1203  inMsg.readInt(); // add
1204  inMsg.readUnsignedByte();
1205  int phaseIndex = inMsg.readInt();
1206  inMsg.readUnsignedByte();
1207  int phaseNumber = inMsg.readInt();
1208  std::vector<TraCIAPI::TraCIPhase> phases;
1209  for (int j = 0; j < phaseNumber; ++j) {
1210  inMsg.readUnsignedByte();
1211  int duration = inMsg.readInt();
1212  inMsg.readUnsignedByte();
1213  int duration1 = inMsg.readInt();
1214  inMsg.readUnsignedByte();
1215  int duration2 = inMsg.readInt();
1216  inMsg.readUnsignedByte();
1217  std::string phase = inMsg.readString();
1218  phases.push_back(TraCIAPI::TraCIPhase(duration, duration1, duration2, phase));
1219  }
1220  ret.push_back(TraCIAPI::TraCILogic(subID, type, std::map<std::string, SUMOReal>(), phaseIndex, phases));
1221  }
1222  return ret;
1223 }
1224 
1225 std::vector<std::string>
1226 TraCIAPI::TrafficLightScope::getControlledLanes(const std::string& tlsID) const {
1227  return myParent.getStringVector(CMD_GET_TL_VARIABLE, TL_CONTROLLED_LANES, tlsID);
1228 }
1229 
1230 std::vector<TraCIAPI::TraCILink>
1231 TraCIAPI::TrafficLightScope::getControlledLinks(const std::string& tlsID) const {
1232  tcpip::Storage inMsg;
1233  myParent.send_commandGetVariable(CMD_GET_TL_VARIABLE, TL_CONTROLLED_LINKS, tlsID);
1234  myParent.processGET(inMsg, CMD_GET_TL_VARIABLE, TYPE_COMPOUND);
1235  std::vector<TraCIAPI::TraCILink> ret;
1236  int linkNo = inMsg.readInt();
1237  for (int i = 0; i < linkNo; ++i) {
1238  inMsg.readUnsignedByte();
1239  std::string from = inMsg.readString();
1240  inMsg.readUnsignedByte();
1241  std::string via = inMsg.readString();
1242  inMsg.readUnsignedByte();
1243  std::string to = inMsg.readString();
1244  ret.push_back(TraCIAPI::TraCILink(from, via, to));
1245  }
1246  return ret;
1247 }
1248 
1249 std::string
1250 TraCIAPI::TrafficLightScope::getProgram(const std::string& tlsID) const {
1251  return myParent.getString(CMD_GET_TL_VARIABLE, TL_CURRENT_PROGRAM, tlsID);
1252 }
1253 
1254 unsigned int
1255 TraCIAPI::TrafficLightScope::getPhase(const std::string& tlsID) const {
1256  return myParent.getInt(CMD_GET_TL_VARIABLE, TL_CURRENT_PHASE, tlsID);
1257 }
1258 
1259 unsigned int
1260 TraCIAPI::TrafficLightScope::getNextSwitch(const std::string& tlsID) const {
1261  return myParent.getInt(CMD_GET_TL_VARIABLE, TL_NEXT_SWITCH, tlsID);
1262 }
1263 
1264 
1265 void
1266 TraCIAPI::TrafficLightScope::setRedYellowGreenState(const std::string& tlsID, const std::string& state) const {
1267  tcpip::Storage content;
1268  content.writeUnsignedByte(TYPE_STRING);
1269  content.writeString(state);
1270  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_RED_YELLOW_GREEN_STATE, tlsID, content);
1271 }
1272 
1273 void
1274 TraCIAPI::TrafficLightScope::setPhase(const std::string& tlsID, unsigned int index) const {
1275  tcpip::Storage content;
1277  content.writeInt(index);
1278  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PHASE_INDEX, tlsID, content);
1279 }
1280 
1281 void
1282 TraCIAPI::TrafficLightScope::setProgram(const std::string& tlsID, const std::string& programID) const {
1283  tcpip::Storage content;
1284  content.writeUnsignedByte(TYPE_STRING);
1285  content.writeString(programID);
1286  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PROGRAM, tlsID, content);
1287 }
1288 
1289 void
1290 TraCIAPI::TrafficLightScope::setPhaseDuration(const std::string& tlsID, unsigned int phaseDuration) const {
1291  tcpip::Storage content;
1293  content.writeInt(int(1000 * phaseDuration));
1294  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_PHASE_DURATION, tlsID, content);
1295 }
1296 
1297 void
1299  tcpip::Storage content;
1301  content.writeInt(5 + 4 * (int)logic.phases.size());
1302  content.writeUnsignedByte(TYPE_STRING);
1303  content.writeString(logic.subID);
1305  content.writeInt(logic.type);
1307  content.writeInt(0);
1309  content.writeInt(logic.currentPhaseIndex);
1311  content.writeInt((int)logic.phases.size());
1312  for (int i = 0; i < (int) logic.phases.size(); ++i) {
1314  content.writeInt(logic.phases[i].duration);
1316  content.writeInt(logic.phases[i].duration1);
1318  content.writeInt(logic.phases[i].duration2);
1319  content.writeUnsignedByte(TYPE_STRING);
1320  content.writeString(logic.phases[i].phase);
1321  }
1322  myParent.send_commandSetValue(CMD_SET_TL_VARIABLE, TL_COMPLETE_PROGRAM_RYG, tlsID, content);
1323 }
1324 
1325 
1326 
1327 
1328 
1329 // ---------------------------------------------------------------------------
1330 // TraCIAPI::VehicleTypeScope-methods
1331 // ---------------------------------------------------------------------------
1332 std::vector<std::string>
1334  return myParent.getStringVector(CMD_GET_VEHICLETYPE_VARIABLE, ID_LIST, "");
1335 }
1336 
1337 SUMOReal
1338 TraCIAPI::VehicleTypeScope::getLength(const std::string& typeID) const {
1339  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_LENGTH, typeID);
1340 }
1341 
1342 SUMOReal
1343 TraCIAPI::VehicleTypeScope::getMaxSpeed(const std::string& typeID) const {
1344  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_MAXSPEED, typeID);
1345 }
1346 
1347 SUMOReal
1348 TraCIAPI::VehicleTypeScope::getSpeedFactor(const std::string& typeID) const {
1349  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_SPEED_FACTOR, typeID);
1350 }
1351 
1352 SUMOReal
1353 TraCIAPI::VehicleTypeScope::getSpeedDeviation(const std::string& typeID) const {
1354  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_SPEED_DEVIATION, typeID);
1355 }
1356 
1357 SUMOReal
1358 TraCIAPI::VehicleTypeScope::getAccel(const std::string& typeID) const {
1359  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_ACCEL, typeID);
1360 }
1361 
1362 SUMOReal
1363 TraCIAPI::VehicleTypeScope::getDecel(const std::string& typeID) const {
1364  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_DECEL, typeID);
1365 }
1366 
1367 SUMOReal
1368 TraCIAPI::VehicleTypeScope::getImperfection(const std::string& typeID) const {
1369  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_IMPERFECTION, typeID);
1370 }
1371 
1372 SUMOReal
1373 TraCIAPI::VehicleTypeScope::getTau(const std::string& typeID) const {
1374  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_TAU, typeID);
1375 }
1376 
1377 std::string
1378 TraCIAPI::VehicleTypeScope::getVehicleClass(const std::string& typeID) const {
1379  return myParent.getString(CMD_GET_TL_VARIABLE, VAR_VEHICLECLASS, typeID);
1380 }
1381 
1382 std::string
1383 TraCIAPI::VehicleTypeScope::getEmissionClass(const std::string& typeID) const {
1384  return myParent.getString(CMD_GET_TL_VARIABLE, VAR_EMISSIONCLASS, typeID);
1385 }
1386 
1387 std::string
1388 TraCIAPI::VehicleTypeScope::getShapeClass(const std::string& typeID) const {
1389  return myParent.getString(CMD_GET_TL_VARIABLE, VAR_SHAPECLASS, typeID);
1390 }
1391 
1392 SUMOReal
1393 TraCIAPI::VehicleTypeScope::getMinGap(const std::string& typeID) const {
1394  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_MINGAP, typeID);
1395 }
1396 
1397 SUMOReal
1398 TraCIAPI::VehicleTypeScope::getWidth(const std::string& typeID) const {
1399  return myParent.getDouble(CMD_GET_TL_VARIABLE, VAR_WIDTH, typeID);
1400 }
1401 
1403 TraCIAPI::VehicleTypeScope::getColor(const std::string& typeID) const {
1404  return myParent.getColor(CMD_GET_TL_VARIABLE, VAR_COLOR, typeID);
1405 }
1406 
1407 
1408 
1409 void
1410 TraCIAPI::VehicleTypeScope::setLength(const std::string& typeID, SUMOReal length) const {
1411  tcpip::Storage content;
1412  content.writeUnsignedByte(TYPE_DOUBLE);
1413  content.writeDouble(length);
1414  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_LENGTH, typeID, content);
1415 }
1416 
1417 void
1418 TraCIAPI::VehicleTypeScope::setMaxSpeed(const std::string& typeID, SUMOReal speed) const {
1419  tcpip::Storage content;
1420  content.writeUnsignedByte(TYPE_DOUBLE);
1421  content.writeDouble(speed);
1422  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_MAXSPEED, typeID, content);
1423 }
1424 
1425 void
1426 TraCIAPI::VehicleTypeScope::setVehicleClass(const std::string& typeID, const std::string& clazz) const {
1427  tcpip::Storage content;
1428  content.writeUnsignedByte(TYPE_STRING);
1429  content.writeString(clazz);
1430  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_VEHICLECLASS, typeID, content);
1431 }
1432 
1433 void
1434 TraCIAPI::VehicleTypeScope::setSpeedFactor(const std::string& typeID, SUMOReal factor) const {
1435  tcpip::Storage content;
1436  content.writeUnsignedByte(TYPE_DOUBLE);
1437  content.writeDouble(factor);
1438  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SPEED_FACTOR, typeID, content);
1439 }
1440 
1441 void
1442 TraCIAPI::VehicleTypeScope::setSpeedDeviation(const std::string& typeID, SUMOReal deviation) const {
1443  tcpip::Storage content;
1444  content.writeUnsignedByte(TYPE_DOUBLE);
1445  content.writeDouble(deviation);
1446  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SPEED_DEVIATION, typeID, content);
1447 }
1448 
1449 void
1450 TraCIAPI::VehicleTypeScope::setEmissionClass(const std::string& typeID, const std::string& clazz) const {
1451  tcpip::Storage content;
1452  content.writeUnsignedByte(TYPE_STRING);
1453  content.writeString(clazz);
1454  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_EMISSIONCLASS, typeID, content);
1455 }
1456 
1457 void
1458 TraCIAPI::VehicleTypeScope::setWidth(const std::string& typeID, SUMOReal width) const {
1459  tcpip::Storage content;
1460  content.writeUnsignedByte(TYPE_DOUBLE);
1461  content.writeDouble(width);
1462  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_WIDTH, typeID, content);
1463 }
1464 
1465 void
1466 TraCIAPI::VehicleTypeScope::setMinGap(const std::string& typeID, SUMOReal minGap) const {
1467  tcpip::Storage content;
1468  content.writeUnsignedByte(TYPE_DOUBLE);
1469  content.writeDouble(minGap);
1470  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_MINGAP, typeID, content);
1471 }
1472 
1473 void
1474 TraCIAPI::VehicleTypeScope::setShapeClass(const std::string& typeID, const std::string& clazz) const {
1475  tcpip::Storage content;
1476  content.writeUnsignedByte(TYPE_STRING);
1477  content.writeString(clazz);
1478  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_SHAPECLASS, typeID, content);
1479 }
1480 
1481 void
1482 TraCIAPI::VehicleTypeScope::setAccel(const std::string& typeID, SUMOReal accel) const {
1483  tcpip::Storage content;
1484  content.writeUnsignedByte(TYPE_DOUBLE);
1485  content.writeDouble(accel);
1486  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_ACCEL, typeID, content);
1487 }
1488 
1489 void
1490 TraCIAPI::VehicleTypeScope::setDecel(const std::string& typeID, SUMOReal decel) const {
1491  tcpip::Storage content;
1492  content.writeUnsignedByte(TYPE_DOUBLE);
1493  content.writeDouble(decel);
1494  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_DECEL, typeID, content);
1495 }
1496 
1497 void
1498 TraCIAPI::VehicleTypeScope::setImperfection(const std::string& typeID, SUMOReal imperfection) const {
1499  tcpip::Storage content;
1500  content.writeUnsignedByte(TYPE_DOUBLE);
1501  content.writeDouble(imperfection);
1502  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_IMPERFECTION, typeID, content);
1503 }
1504 
1505 void
1506 TraCIAPI::VehicleTypeScope::setTau(const std::string& typeID, SUMOReal tau) const {
1507  tcpip::Storage content;
1508  content.writeUnsignedByte(TYPE_DOUBLE);
1509  content.writeDouble(tau);
1510  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_TAU, typeID, content);
1511 }
1512 
1513 void
1514 TraCIAPI::VehicleTypeScope::setColor(const std::string& typeID, const TraCIColor& c) const {
1515  tcpip::Storage content;
1516  content.writeUnsignedByte(TYPE_COLOR);
1517  content.writeUnsignedByte(c.r);
1518  content.writeUnsignedByte(c.g);
1519  content.writeUnsignedByte(c.b);
1520  content.writeUnsignedByte(c.a);
1521  myParent.send_commandSetValue(CMD_SET_VEHICLETYPE_VARIABLE, VAR_COLOR, typeID, content);
1522 }
1523 
1524 
1525 
1526 /****************************************************************************/
1527 
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1080
SUMOReal getImperfection(const std::string &typeID) const
Definition: TraCIAPI.cpp:1368
#define LAST_STEP_MEAN_SPEED
TraCIPosition getPosition(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:379
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:708
#define TL_NEXT_SWITCH
SUMOReal getMaxSpeed(const std::string &typeID) const
Definition: TraCIAPI.cpp:1343
#define VAR_TIME_STEP
TraCIPosition getOffset(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:566
void setLength(const std::string &typeID, SUMOReal length) const
Definition: TraCIAPI.cpp:1410
#define VAR_EMISSIONCLASS
void setMaxSpeed(const std::string &edgeID, SUMOReal speed) const
Definition: TraCIAPI.cpp:543
SUMOReal getNoiseEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:783
tcpip::Socket * mySocket
The socket.
Definition: TraCIAPI.h:745
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1333
#define VAR_CO2EMISSION
std::vector< std::string > getLoadedIDList() const
Definition: TraCIAPI.cpp:1116
unsigned int getLastStepVehicleNumber(const std::string &loopID) const
Definition: TraCIAPI.cpp:651
void close()
Closes the connection.
Definition: TraCIAPI.cpp:79
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
Definition: TraCIAPI.cpp:66
#define CMD_GET_TL_VARIABLE
std::vector< std::string > getArrivedIDList() const
Definition: TraCIAPI.cpp:1136
#define VAR_LENGTH
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:556
unsigned int getLastStepVehicleNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:512
#define TYPE_COMPOUND
#define VAR_CURRENT_TRAVELTIME
TraCIColor getColor(const std::string &poiID) const
Definition: TraCIAPI.cpp:922
#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:956
SUMOReal getLastStepMeanSpeed(const std::string &edgeID) const
Definition: TraCIAPI.cpp:492
std::vector< std::string > getDisallowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:733
#define POSITION_2D
SUMOReal getCOEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:462
#define VAR_POSITION
void setShapeClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1474
void setPhase(const std::string &tlsID, unsigned int index) const
Definition: TraCIAPI.cpp:1274
void setProgram(const std::string &tlsID, const std::string &programID) const
Definition: TraCIAPI.cpp:1282
void setVehicleClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1426
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:1378
#define LANE_EDGE_ID
void setColor(const std::string &polygonID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:1030
SUMOReal getDouble(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:336
#define LAST_STEP_VEHICLE_DATA
void send_commandClose() const
Sends a Close command.
Definition: TraCIAPI.cpp:103
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:190
#define TYPE_UBYTE
#define RTYPE_OK
virtual double readDouble()
void setMaxSpeed(const std::string &typeID, SUMOReal speed) const
Definition: TraCIAPI.cpp:1418
void setCompleteRedYellowGreenDefinition(const std::string &tlsID, const TraCIAPI::TraCILogic &logic) const
Definition: TraCIAPI.cpp:1298
#define VAR_TYPE
#define TYPE_POLYGON
unsigned int currentPhaseIndex
Definition: TraCIAPI.h:106
std::string getEmissionClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1383
void add(const std::string &polygonID, const TraCIPositionVector &shape, const TraCIColor &c, bool fill, const std::string &type, int layer) const
Definition: TraCIAPI.cpp:1041
SUMOReal getLastStepMeanSpeed(const std::string &detID) const
Definition: TraCIAPI.cpp:887
#define VAR_VEHICLECLASS
void processGET(tcpip::Storage &inMsg, int command, int expectedType, bool ignoreCommandId=false) const
Definition: TraCIAPI.cpp:282
StorageType::size_type size() const
Definition: storage.h:115
SUMOReal getPMxEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:768
#define VAR_SPEED_FACTOR
SUMOReal getLastStepOccupancy(const std::string &edgeID) const
Definition: TraCIAPI.cpp:497
#define VAR_COLOR
unsigned int getLastStepHaltingNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:897
#define VAR_LOADED_VEHICLES_IDS
std::vector< std::string > getLastStepVehicleIDs(const std::string &loopID) const
Definition: TraCIAPI.cpp:661
TraCIPosition getPosition(const std::string &junctionID) const
Definition: TraCIAPI.cpp:697
void trackVehicle(const std::string &viewID, const std::string &vehID) const
Definition: TraCIAPI.cpp:623
#define TYPE_COLOR
#define TYPE_STRINGLIST
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:692
SUMOTime getCurrentTime() const
Definition: TraCIAPI.cpp:1106
SUMOReal getLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:713
SUMOReal getLastStepMeanSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:788
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:989
SUMOReal getMinGap(const std::string &typeID) const
Definition: TraCIAPI.cpp:1393
#define VAR_TELEPORT_STARTING_VEHICLES_IDS
#define CMD_GET_POLYGON_VARIABLE
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1226
SUMOReal getLastStepMeanLength(const std::string &loopID) const
Definition: TraCIAPI.cpp:671
void setAllowed(const std::string &laneID, const std::vector< std::string > &allowedClasses) const
Definition: TraCIAPI.cpp:824
virtual void writeUnsignedByte(int)
#define CMD_SET_EDGE_VARIABLE
#define CMD_SET_GUI_VARIABLE
SUMOReal getWidth(const std::string &typeID) const
Definition: TraCIAPI.cpp:1398
TraCIPositionVector getPolygon(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:361
SUMOReal getLastStepOccupancy(const std::string &laneID) const
Definition: TraCIAPI.cpp:793
#define TL_CURRENT_PHASE
std::string getProgram(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1250
#define VAR_LOADED_VEHICLES_NUMBER
#define VAR_SHAPE
#define VAR_SPEED_DEVIATION
#define VAR_NOISEEMISSION
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:433
#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:345
virtual void writeInt(int)
void setDisallowed(const std::string &laneID, const std::vector< std::string > &disallowedClasses) const
Definition: TraCIAPI.cpp:835
void setTau(const std::string &typeID, SUMOReal tau) const
Definition: TraCIAPI.cpp:1506
SUMOReal getCO2Emission(const std::string &laneID) const
Definition: TraCIAPI.cpp:753
std::vector< std::string > getAllowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:728
void setBoundary(const std::string &viewID, SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax) const
Definition: TraCIAPI.cpp:605
#define TYPE_STRING
void setMaxSpeed(const std::string &laneID, SUMOReal speed) const
Definition: TraCIAPI.cpp:846
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:438
#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:1067
void send_commandSimulationStep(SUMOTime time) const
Sends a SimulationStep command.
Definition: TraCIAPI.cpp:90
#define LANE_ALLOWED
std::string getRedYellowGreenState(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1186
#define VAR_DEPARTED_VEHICLES_NUMBER
void adaptTraveltime(const std::string &edgeID, SUMOReal time) const
Definition: TraCIAPI.cpp:529
#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:1490
void setLength(const std::string &laneID, SUMOReal length) const
Definition: TraCIAPI.cpp:854
#define VAR_ACCEL
SUMOTime getDeltaT() const
Definition: TraCIAPI.cpp:1161
void setSchema(const std::string &viewID, const std::string &schemeName) const
Definition: TraCIAPI.cpp:598
TraCIColor getColor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1403
virtual int readInt()
#define TL_COMPLETE_PROGRAM_RYG
std::string getType(const std::string &polygonID) const
Definition: TraCIAPI.cpp:994
SUMOReal getTraveltime(const std::string &laneID) const
Definition: TraCIAPI.cpp:803
void setType(const std::string &poiID, const std::string &setType) const
Definition: TraCIAPI.cpp:928
SUMOReal getNOxEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:773
#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:114
TraCIColor getColor(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:415
#define CMD_GET_POI_VARIABLE
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:907
~TraCIAPI()
Destructor.
Definition: TraCIAPI.cpp:60
void screenshot(const std::string &viewID, const std::string &filename) const
Definition: TraCIAPI.cpp:616
std::vector< std::string > getDepartedIDList() const
Definition: TraCIAPI.cpp:1126
#define TL_COMPLETE_DEFINITION_RYG
#define VAR_TELEPORT_STARTING_VEHICLES_NUMBER
unsigned int getLastStepHaltingNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:813
#define CMD_SET_VEHICLETYPE_VARIABLE
std::vector< TraCIAPI::TraCILink > getControlledLinks(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1231
#define TYPE_BOUNDINGBOX
unsigned int getArrivedNumber() const
Definition: TraCIAPI.cpp:1131
SUMOReal getHCEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:763
void setWidth(const std::string &typeID, SUMOReal width) const
Definition: TraCIAPI.cpp:1458
A 3D-bounding box.
Definition: TraCIAPI.h:79
void setEmissionClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1450
unsigned int getNextSwitch(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1260
TraCIPositionVector getShape(const std::string &polygonID) const
Definition: TraCIAPI.cpp:999
void setSpeedFactor(const std::string &typeID, SUMOReal factor) const
Definition: TraCIAPI.cpp:1434
#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:107
int getInt(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:318
SUMOReal getSpeedFactor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1348
#define VAR_IMPERFECTION
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:1181
SUMOReal getLastStepLength(const std::string &edgeID) const
Definition: TraCIAPI.cpp:502
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
Definition: TraCIAPI.cpp:1266
#define CMD_GET_SIM_VARIABLE
virtual std::string readString()
std::string getShapeClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1388
#define CMD_GET_EDGE_VARIABLE
int getByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:309
#define VAR_EDGES
#define CMD_GET_GUI_VARIABLE
std::string getSchema(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:571
SUMOReal getLastStepOccupancy(const std::string &loopID) const
Definition: TraCIAPI.cpp:666
#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:300
#define VAR_EDGE_EFFORT
void setMinGap(const std::string &typeID, SUMOReal minGap) const
Definition: TraCIAPI.cpp:1466
TraCIColor getColor(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1004
SUMOReal getDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1363
void setPhaseDuration(const std::string &tlsID, unsigned int phaseDuration) const
Definition: TraCIAPI.cpp:1290
std::vector< std::string > getEndingTeleportIDList() const
Definition: TraCIAPI.cpp:1156
#define ADD
SUMOReal getPosition(const std::string &loopID) const
Definition: TraCIAPI.cpp:641
#define CMD_GET_JUNCTION_VARIABLE
TraCIBoundary getBoundary(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:576
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:52
SUMOReal getTimeSinceDetection(const std::string &loopID) const
Definition: TraCIAPI.cpp:676
#define VAR_DELTA_T
#define REMOVE
void setOffset(const std::string &viewID, SUMOReal x, SUMOReal y) const
Definition: TraCIAPI.cpp:589
std::string getEdgeID(const std::string &laneID) const
Definition: TraCIAPI.cpp:748
unsigned int getEndingTeleportNumber() const
Definition: TraCIAPI.cpp:1151
virtual void writeStorage(tcpip::Storage &store)
#define TL_CONTROLLED_LINKS
SUMOReal getMaxSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:718
unsigned int getLastStepVehicleNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:808
SUMOReal getLastStepMeanSpeed(const std::string &loopID) const
Definition: TraCIAPI.cpp:656
void setAccel(const std::string &typeID, SUMOReal accel) const
Definition: TraCIAPI.cpp:1482
void setImperfection(const std::string &typeID, SUMOReal imperfection) const
Definition: TraCIAPI.cpp:1498
std::vector< std::string > getStringVector(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:401
SUMOReal getCOEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:758
TraCIPosition getPosition(const std::string &poiID) const
Definition: TraCIAPI.cpp:917
#define TL_RED_YELLOW_GREEN_STATE
SUMOReal getFuelConsumption(const std::string &edgeID) const
Definition: TraCIAPI.cpp:482
#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:561
SUMOReal getWidth(const std::string &laneID) const
Definition: TraCIAPI.cpp:723
#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:162
#define VAR_COEMISSION
std::vector< TraCIAPI::TraCILogic > getCompleteRedYellowGreenDefinition(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1191
virtual void writeString(const std::string &s)
#define RTYPE_NOTIMPLEMENTED
void setType(const std::string &polygonID, const std::string &setType) const
Definition: TraCIAPI.cpp:1010
TraCIPositionVector getShape(const std::string &laneID) const
Definition: TraCIAPI.cpp:743
#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:536
#define LANE_DISALLOWED
#define TL_PROGRAM
SUMOReal getEffort(const std::string &edgeID, SUMOTime time) const
Definition: TraCIAPI.cpp:450
SUMOTime getSUMOTime(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:291
#define TYPE_DOUBLE
SUMOReal getHCEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:467
std::vector< std::string > getLastStepVehicleIDs(const std::string &detID) const
Definition: TraCIAPI.cpp:892
unsigned int getDepartedNumber() const
Definition: TraCIAPI.cpp:1121
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:912
#define CMD_SET_LANE_VARIABLE
std::string getLaneID(const std::string &loopID) const
Definition: TraCIAPI.cpp:646
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:636
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:223
unsigned int getLinkNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:738
SUMOReal getNoiseEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:487
SUMOReal getAccel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1358
SUMOReal getTraveltime(const std::string &edgeID) const
Definition: TraCIAPI.cpp:507
void setZoom(const std::string &viewID, SUMOReal zoom) const
Definition: TraCIAPI.cpp:582
TraCIAPI & myParent
The parent TraCI client which offers the connection.
Definition: TraCIAPI.h:188
int SUMOTime
Definition: SUMOTime.h:43
std::string subID
Definition: TraCIAPI.h:103
std::vector< std::string > getLastStepVehicleIDs(const std::string &laneID) const
Definition: TraCIAPI.cpp:818
virtual void writeDouble(double)
#define VAR_TELEPORT_ENDING_VEHICLES_NUMBER
SUMOReal getLastStepLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:798
void setShape(const std::string &polygonID, const TraCIPositionVector &shape) const
Definition: TraCIAPI.cpp:1018
void setColor(const std::string &typeID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:1514
void send_commandSetValue(int domID, int varID, const std::string &objID, tcpip::Storage &content) const
Sends a SetVariable request.
Definition: TraCIAPI.cpp:141
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:866
unsigned int getStartingTeleportNumber() const
Definition: TraCIAPI.cpp:1141
SUMOReal getPMxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:472
void setPosition(const std::string &poiID, SUMOReal x, SUMOReal y) const
Definition: TraCIAPI.cpp:936
#define SUMOReal
Definition: config.h:215
SUMOReal getSpeedDeviation(const std::string &typeID) const
Definition: TraCIAPI.cpp:1353
SUMOReal getCO2Emission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:457
#define LAST_STEP_OCCUPANCY
unsigned int getLoadedNumber() const
Definition: TraCIAPI.cpp:1111
#define TL_CONTROLLED_LANES
void check_commandGetResult(tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const
Definition: TraCIAPI.cpp:262
std::string getString(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:392
void setSpeedDeviation(const std::string &typeID, SUMOReal deviation) const
Definition: TraCIAPI.cpp:1442
#define VAR_MAXSPEED
SUMOReal getNOxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:477
#define VAR_DECEL
TraCIAPI()
Constructor.
Definition: TraCIAPI.cpp:49
#define ID_COUNT
TraCIBoundary getNetBoundary() const
Definition: TraCIAPI.cpp:1166
std::vector< TraCIPosition > TraCIPositionVector
Definition: TraCIAPI.h:74
#define VAR_LANE_ID
unsigned int getMinExpectedNumber() const
Definition: TraCIAPI.cpp:1171
SUMOReal getAdaptedTraveltime(const std::string &edgeID, SUMOTime time) const
Definition: TraCIAPI.cpp:443
std::vector< std::string > getEdges(const std::string &routeID) const
Definition: TraCIAPI.cpp:1085
void remove(const std::string &poiID, int layer=0) const
Definition: TraCIAPI.cpp:976
SUMOReal getFloat(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Definition: TraCIAPI.cpp:327
unsigned int getVehicleData(const std::string &loopID) const
Definition: TraCIAPI.cpp:681
unsigned int getPhase(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1255
#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:1338
SUMOReal getTau(const std::string &typeID) const
Definition: TraCIAPI.cpp:1373
unsigned int getLastStepVehicleNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:882
#define TL_PHASE_INDEX
#define VAR_ARRIVED_VEHICLES_IDS
std::vector< std::string > getLastStepVehicleIDs(const std::string &edgeID) const
Definition: TraCIAPI.cpp:522
A list of positions.
#define VAR_VIEW_OFFSET
#define LAST_STEP_VEHICLE_HALTING_NUMBER
SUMOReal getFuelConsumption(const std::string &laneID) const
Definition: TraCIAPI.cpp:778
virtual int readByte()
#define VAR_HCEMISSION
void setColor(const std::string &poiID, const TraCIColor &c) const
Definition: TraCIAPI.cpp:945
void close()
Definition: socket.cpp:347
void add(const std::string &routeID, const std::vector< std::string > &edges) const
Definition: TraCIAPI.cpp:1091
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:877
A 3D-position.
Definition: TraCIAPI.h:60
#define VAR_WIDTH
SUMOReal getLastStepHaltingNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:517
std::vector< std::string > getStartingTeleportIDList() const
Definition: TraCIAPI.cpp:1146