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