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