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