Eclipse SUMO - Simulation of Urban MObility
TraCIAPI.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2012-2022 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
21// C++ TraCI client API implementation
22/****************************************************************************/
23#include "TraCIAPI.h"
24
25
26// ===========================================================================
27// member definitions
28// ===========================================================================
29
30// ---------------------------------------------------------------------------
31// TraCIAPI-methods
32// ---------------------------------------------------------------------------
33#ifdef _MSC_VER
34/* Disable "decorated name length exceeded, name was truncated" warnings for the whole file. */
35#pragma warning(disable: 4503)
36#pragma warning(push)
37/* Disable warning about using "this" in the constructor */
38#pragma warning(disable: 4355)
39#endif
41 : edge(*this), gui(*this), inductionloop(*this),
42 junction(*this), lane(*this), lanearea(*this), multientryexit(*this),
43 person(*this), poi(*this), polygon(*this),
44 rerouter(*this), route(*this), routeprobe(*this),
45 simulation(*this), trafficlights(*this),
46 vehicle(*this), vehicletype(*this),
47 mySocket(nullptr) {
64}
65#ifdef _MSC_VER
66#pragma warning(pop)
67#endif
68
69
71 delete mySocket;
72}
73
74
75void
76TraCIAPI::connect(const std::string& host, int port) {
77 mySocket = new tcpip::Socket(host, port);
78 try {
80 } catch (tcpip::SocketException&) {
81 delete mySocket;
82 mySocket = nullptr;
83 throw;
84 }
85}
86
87
88void
90 tcpip::Storage outMsg;
91 // command length
92 outMsg.writeUnsignedByte(1 + 1 + 4);
93 // command id
95 outMsg.writeInt(order);
96 // send request message
97 mySocket->sendExact(outMsg);
98 tcpip::Storage inMsg;
100}
101
102
103void
106 tcpip::Storage inMsg;
107 std::string acknowledgement;
108 check_resultState(inMsg, libsumo::CMD_CLOSE, false, &acknowledgement);
109 closeSocket();
110}
111
112
113void
115 if (mySocket == nullptr) {
116 return;
117 }
118 mySocket->close();
119 delete mySocket;
120 mySocket = nullptr;
121}
122
123
124void
126 tcpip::Storage outMsg;
127 // command length
128 outMsg.writeUnsignedByte(1 + 1 + 8);
129 // command id
131 outMsg.writeDouble(time);
132 // send request message
133 mySocket->sendExact(outMsg);
134}
135
136
137void
139 tcpip::Storage outMsg;
140 // command length
141 outMsg.writeUnsignedByte(1 + 1);
142 // command id
144 mySocket->sendExact(outMsg);
145}
146
147
148void
150 tcpip::Storage outMsg;
151 // command length
152 outMsg.writeUnsignedByte(1 + 1 + 4);
153 // command id
155 // client index
156 outMsg.writeInt(order);
157 mySocket->sendExact(outMsg);
158}
159
160
161void
162TraCIAPI::createCommand(int cmdID, int varID, const std::string& objID, tcpip::Storage* add) const {
163 myOutput.reset();
164 // command length
165 int length = 1 + 1 + 1 + 4 + (int) objID.length();
166 if (add != nullptr) {
167 length += (int)add->size();
168 }
169 if (length <= 255) {
171 } else {
173 myOutput.writeInt(length + 4);
174 }
177 myOutput.writeString(objID);
178 // additional values
179 if (add != nullptr) {
181 }
182}
183
184
185void
186TraCIAPI::createFilterCommand(int cmdID, int varID, tcpip::Storage* add) const {
187 myOutput.reset();
188 // command length
189 int length = 1 + 1 + 1;
190 if (add != nullptr) {
191 length += (int)add->size();
192 }
193 if (length <= 255) {
195 } else {
197 myOutput.writeInt(length + 4);
198 }
201 // additional values
202 if (add != nullptr) {
204 }
205}
206
207
208void
209TraCIAPI::send_commandSubscribeObjectVariable(int domID, const std::string& objID, double beginTime, double endTime,
210 const std::vector<int>& vars) const {
211 if (mySocket == nullptr) {
212 throw tcpip::SocketException("Socket is not initialised");
213 }
214 tcpip::Storage outMsg;
215 // command length (domID, objID, beginTime, endTime, length, vars)
216 int varNo = (int) vars.size();
217 outMsg.writeUnsignedByte(0);
218 outMsg.writeInt(5 + 1 + 8 + 8 + 4 + (int) objID.length() + 1 + varNo);
219 // command id
220 outMsg.writeUnsignedByte(domID);
221 // time
222 outMsg.writeDouble(beginTime);
223 outMsg.writeDouble(endTime);
224 // object id
225 outMsg.writeString(objID);
226 // command id
227 outMsg.writeUnsignedByte((int)vars.size());
228 for (int i = 0; i < varNo; ++i) {
229 outMsg.writeUnsignedByte(vars[i]);
230 }
231 // send message
232 mySocket->sendExact(outMsg);
233}
234
235
236void
237TraCIAPI::send_commandSubscribeObjectContext(int domID, const std::string& objID, double beginTime, double endTime,
238 int domain, double range, const std::vector<int>& vars) const {
239 if (mySocket == nullptr) {
240 throw tcpip::SocketException("Socket is not initialised");
241 }
242 tcpip::Storage outMsg;
243 // command length (domID, objID, beginTime, endTime, length, vars)
244 int varNo = (int) vars.size();
245 outMsg.writeUnsignedByte(0);
246 outMsg.writeInt(5 + 1 + 8 + 8 + 4 + (int) objID.length() + 1 + 8 + 1 + varNo);
247 // command id
248 outMsg.writeUnsignedByte(domID);
249 // time
250 outMsg.writeDouble(beginTime);
251 outMsg.writeDouble(endTime);
252 // object id
253 outMsg.writeString(objID);
254 // domain and range
255 outMsg.writeUnsignedByte(domain);
256 outMsg.writeDouble(range);
257 // command id
258 outMsg.writeUnsignedByte((int)vars.size());
259 for (int i = 0; i < varNo; ++i) {
260 outMsg.writeUnsignedByte(vars[i]);
261 }
262 // send message
263 mySocket->sendExact(outMsg);
264}
265
266
267void
268TraCIAPI::check_resultState(tcpip::Storage& inMsg, int command, bool ignoreCommandId, std::string* acknowledgement) const {
269 mySocket->receiveExact(inMsg);
270 int cmdLength;
271 int cmdId;
272 int resultType;
273 int cmdStart;
274 std::string msg;
275 try {
276 cmdStart = inMsg.position();
277 cmdLength = inMsg.readUnsignedByte();
278 cmdId = inMsg.readUnsignedByte();
279 if (command != cmdId && !ignoreCommandId) {
280 throw libsumo::TraCIException("#Error: received status response to command: " + toString(cmdId) + " but expected: " + toString(command));
281 }
282 resultType = inMsg.readUnsignedByte();
283 msg = inMsg.readString();
284 } catch (std::invalid_argument&) {
285 throw libsumo::TraCIException("#Error: an exception was thrown while reading result state message");
286 }
287 switch (resultType) {
289 throw libsumo::TraCIException(".. Answered with error to command (" + toString(command) + "), [description: " + msg + "]");
291 throw libsumo::TraCIException(".. Sent command is not implemented (" + toString(command) + "), [description: " + msg + "]");
293 if (acknowledgement != nullptr) {
294 (*acknowledgement) = ".. Command acknowledged (" + toString(command) + "), [description: " + msg + "]";
295 }
296 break;
297 default:
298 throw libsumo::TraCIException(".. Answered with unknown result code(" + toString(resultType) + ") to command(" + toString(command) + "), [description: " + msg + "]");
299 }
300 if ((cmdStart + cmdLength) != (int) inMsg.position()) {
301 throw libsumo::TraCIException("#Error: command at position " + toString(cmdStart) + " has wrong length");
302 }
303}
304
305
306int
307TraCIAPI::check_commandGetResult(tcpip::Storage& inMsg, int command, int expectedType, bool ignoreCommandId) const {
308 inMsg.position(); // respStart
309 int length = inMsg.readUnsignedByte();
310 if (length == 0) {
311 length = inMsg.readInt();
312 }
313 int cmdId = inMsg.readUnsignedByte();
314 if (!ignoreCommandId && cmdId != (command + 0x10)) {
315 throw libsumo::TraCIException("#Error: received response with command id: " + toString(cmdId) + "but expected: " + toString(command + 0x10));
316 }
317 if (expectedType >= 0) {
318 // not called from the TraCITestClient but from within the TraCIAPI
319 inMsg.readUnsignedByte(); // variableID
320 inMsg.readString(); // objectID
321 int valueDataType = inMsg.readUnsignedByte();
322 if (valueDataType != expectedType) {
323 throw libsumo::TraCIException("Expected " + toString(expectedType) + " but got " + toString(valueDataType));
324 }
325 }
326 return cmdId;
327}
328
329
330bool
331TraCIAPI::processGet(int command, int expectedType, bool ignoreCommandId) {
332 if (mySocket != nullptr) {
334 myInput.reset();
335 check_resultState(myInput, command, ignoreCommandId);
336 check_commandGetResult(myInput, command, expectedType, ignoreCommandId);
337 return true;
338 }
339 return false;
340}
341
342
343bool
345 if (mySocket != nullptr) {
347 myInput.reset();
348 check_resultState(myInput, command);
349 return true;
350 }
351 return false;
352}
353
354
355void
356TraCIAPI::readVariables(tcpip::Storage& inMsg, const std::string& objectID, int variableCount, libsumo::SubscriptionResults& into) {
357 while (variableCount > 0) {
358
359 const int variableID = inMsg.readUnsignedByte();
360 const int status = inMsg.readUnsignedByte();
361 const int type = inMsg.readUnsignedByte();
362
363 if (status == libsumo::RTYPE_OK) {
364 switch (type) {
366 into[objectID][variableID] = std::make_shared<libsumo::TraCIDouble>(inMsg.readDouble());
367 break;
369 into[objectID][variableID] = std::make_shared<libsumo::TraCIString>(inMsg.readString());
370 break;
372 auto p = std::make_shared<libsumo::TraCIPosition>();
373 p->x = inMsg.readDouble();
374 p->y = inMsg.readDouble();
375 p->z = 0.;
376 into[objectID][variableID] = p;
377 break;
378 }
380 auto p = std::make_shared<libsumo::TraCIPosition>();
381 p->x = inMsg.readDouble();
382 p->y = inMsg.readDouble();
383 p->z = inMsg.readDouble();
384 into[objectID][variableID] = p;
385 break;
386 }
387 case libsumo::TYPE_COLOR: {
388 auto c = std::make_shared<libsumo::TraCIColor>();
389 c->r = (unsigned char)inMsg.readUnsignedByte();
390 c->g = (unsigned char)inMsg.readUnsignedByte();
391 c->b = (unsigned char)inMsg.readUnsignedByte();
392 c->a = (unsigned char)inMsg.readUnsignedByte();
393 into[objectID][variableID] = c;
394 break;
395 }
397 into[objectID][variableID] = std::make_shared<libsumo::TraCIInt>(inMsg.readInt());
398 break;
400 auto sl = std::make_shared<libsumo::TraCIStringList>();
401 int n = inMsg.readInt();
402 for (int i = 0; i < n; ++i) {
403 sl->value.push_back(inMsg.readString());
404 }
405 into[objectID][variableID] = sl;
406 }
407 break;
408
409 // TODO Other data types
410
411 default:
412 throw libsumo::TraCIException("Unimplemented subscription type: " + toString(type));
413 }
414 } else {
415 throw libsumo::TraCIException("Subscription response error: variableID=" + toString(variableID) + " status=" + toString(status));
416 }
417
418 variableCount--;
419 }
420}
421
422
423void
425 const std::string objectID = inMsg.readString();
426 const int variableCount = inMsg.readUnsignedByte();
427 readVariables(inMsg, objectID, variableCount, myDomains[cmdId]->getModifiableSubscriptionResults());
428}
429
430
431void
433 const std::string contextID = inMsg.readString();
434 inMsg.readUnsignedByte(); // context domain
435 const int variableCount = inMsg.readUnsignedByte();
436 int numObjects = inMsg.readInt();
437
438 while (numObjects > 0) {
439 std::string objectID = inMsg.readString();
440 readVariables(inMsg, objectID, variableCount, myDomains[cmdId]->getModifiableContextSubscriptionResults(contextID));
441 numObjects--;
442 }
443}
444
445
446void
449 tcpip::Storage inMsg;
451
452 for (auto it : myDomains) {
453 it.second->clearSubscriptionResults();
454 }
455 int numSubs = inMsg.readInt();
456 while (numSubs > 0) {
457 int cmdId = check_commandGetResult(inMsg, 0, -1, true);
459 readVariableSubscription(cmdId, inMsg);
460 } else {
461 readContextSubscription(cmdId + 0x50, inMsg);
462 }
463 numSubs--;
464 }
465}
466
467
468void
469TraCIAPI::load(const std::vector<std::string>& args) {
470 int numChars = 0;
471 for (int i = 0; i < (int)args.size(); ++i) {
472 numChars += (int)args[i].size();
473 }
474 tcpip::Storage content;
475 content.writeUnsignedByte(0);
476 content.writeInt(1 + 4 + 1 + 1 + 4 + numChars + 4 * (int)args.size());
479 content.writeStringList(args);
480 mySocket->sendExact(content);
481 tcpip::Storage inMsg;
483}
484
485
486std::pair<int, std::string>
488 tcpip::Storage content;
489 content.writeUnsignedByte(2);
491 mySocket->sendExact(content);
492 tcpip::Storage inMsg;
494 inMsg.readUnsignedByte(); // msg length
495 inMsg.readUnsignedByte(); // libsumo::CMD_GETVERSION again, see #7284
496 const int traciVersion = inMsg.readInt(); // to fix evaluation order
497 return std::make_pair(traciVersion, inMsg.readString());
498}
499
500
501// ---------------------------------------------------------------------------
502// TraCIAPI::EdgeScope-methods
503// ---------------------------------------------------------------------------
504double
505TraCIAPI::EdgeScope::getAdaptedTraveltime(const std::string& edgeID, double time) const {
506 tcpip::Storage content;
508 content.writeDouble(time);
509 return getDouble(libsumo::VAR_EDGE_TRAVELTIME, edgeID, &content);
510}
511
512double
513TraCIAPI::EdgeScope::getEffort(const std::string& edgeID, double time) const {
514 tcpip::Storage content;
516 content.writeDouble(time);
517 return getDouble(libsumo::VAR_EDGE_EFFORT, edgeID, &content);
518}
519
520double
521TraCIAPI::EdgeScope::getCO2Emission(const std::string& edgeID) const {
522 return getDouble(libsumo::VAR_CO2EMISSION, edgeID);
523}
524
525
526double
527TraCIAPI::EdgeScope::getCOEmission(const std::string& edgeID) const {
528 return getDouble(libsumo::VAR_COEMISSION, edgeID);
529}
530
531double
532TraCIAPI::EdgeScope::getHCEmission(const std::string& edgeID) const {
533 return getDouble(libsumo::VAR_HCEMISSION, edgeID);
534}
535
536double
537TraCIAPI::EdgeScope::getPMxEmission(const std::string& edgeID) const {
538 return getDouble(libsumo::VAR_PMXEMISSION, edgeID);
539}
540
541double
542TraCIAPI::EdgeScope::getNOxEmission(const std::string& edgeID) const {
543 return getDouble(libsumo::VAR_NOXEMISSION, edgeID);
544}
545
546double
547TraCIAPI::EdgeScope::getFuelConsumption(const std::string& edgeID) const {
548 return getDouble(libsumo::VAR_FUELCONSUMPTION, edgeID);
549}
550
551double
552TraCIAPI::EdgeScope::getNoiseEmission(const std::string& edgeID) const {
553 return getDouble(libsumo::VAR_NOISEEMISSION, edgeID);
554}
555
556double
557TraCIAPI::EdgeScope::getElectricityConsumption(const std::string& edgeID) const {
558 return getDouble(libsumo::VAR_ELECTRICITYCONSUMPTION, edgeID);
559}
560
561double
562TraCIAPI::EdgeScope::getLastStepMeanSpeed(const std::string& edgeID) const {
563 return getDouble(libsumo::LAST_STEP_MEAN_SPEED, edgeID);
564}
565
566double
567TraCIAPI::EdgeScope::getLastStepOccupancy(const std::string& edgeID) const {
568 return getDouble(libsumo::LAST_STEP_OCCUPANCY, edgeID);
569}
570
571double
572TraCIAPI::EdgeScope::getLastStepLength(const std::string& edgeID) const {
573 return getDouble(libsumo::LAST_STEP_LENGTH, edgeID);
574}
575
576double
577TraCIAPI::EdgeScope::getTraveltime(const std::string& edgeID) const {
578 return getDouble(libsumo::VAR_CURRENT_TRAVELTIME, edgeID);
579}
580
581int
582TraCIAPI::EdgeScope::getLastStepVehicleNumber(const std::string& edgeID) const {
583 return getInt(libsumo::LAST_STEP_VEHICLE_NUMBER, edgeID);
584}
585
586double
587TraCIAPI::EdgeScope::getLastStepHaltingNumber(const std::string& edgeID) const {
588 return getInt(libsumo::LAST_STEP_VEHICLE_HALTING_NUMBER, edgeID);
589}
590
591std::vector<std::string>
592TraCIAPI::EdgeScope::getLastStepVehicleIDs(const std::string& edgeID) const {
593 return getStringVector(libsumo::LAST_STEP_VEHICLE_ID_LIST, edgeID);
594}
595
596
597int
598TraCIAPI::EdgeScope::getLaneNumber(const std::string& edgeID) const {
599 return getInt(libsumo::VAR_LANE_INDEX, edgeID);
600}
601
602
603std::string
604TraCIAPI::EdgeScope::getStreetName(const std::string& edgeID) const {
605 return getString(libsumo::VAR_NAME, edgeID);
606}
607
608
609void
610TraCIAPI::EdgeScope::adaptTraveltime(const std::string& edgeID, double time, double beginSeconds, double endSeconds) const {
611 tcpip::Storage content;
613 if (endSeconds != std::numeric_limits<double>::max()) {
614 content.writeInt(3);
616 content.writeDouble(beginSeconds);
618 content.writeDouble(endSeconds);
619 } else {
620 content.writeInt(1);
621 }
623 content.writeDouble(time);
624 myParent.createCommand(libsumo::CMD_SET_EDGE_VARIABLE, libsumo::VAR_EDGE_TRAVELTIME, edgeID, &content);
625 myParent.processSet(libsumo::CMD_SET_EDGE_VARIABLE);
626}
627
628
629void
630TraCIAPI::EdgeScope::setEffort(const std::string& edgeID, double effort, double beginSeconds, double endSeconds) const {
631 tcpip::Storage content;
633 if (endSeconds != std::numeric_limits<double>::max()) {
634 content.writeInt(3);
636 content.writeDouble(beginSeconds);
638 content.writeDouble(endSeconds);
639 } else {
640 content.writeInt(1);
641 }
643 content.writeDouble(effort);
644 myParent.createCommand(libsumo::CMD_SET_EDGE_VARIABLE, libsumo::VAR_EDGE_EFFORT, edgeID, &content);
645 myParent.processSet(libsumo::CMD_SET_EDGE_VARIABLE);
646}
647
648void
649TraCIAPI::EdgeScope::setMaxSpeed(const std::string& edgeID, double speed) const {
650 setDouble(libsumo::VAR_MAXSPEED, edgeID, speed);
651}
652
653
654// ---------------------------------------------------------------------------
655// TraCIAPI::GUIScope-methods
656// ---------------------------------------------------------------------------
657double
658TraCIAPI::GUIScope::getZoom(const std::string& viewID) const {
659 return getDouble(libsumo::VAR_VIEW_ZOOM, viewID);
660}
661
663TraCIAPI::GUIScope::getOffset(const std::string& viewID) const {
664 return getPos(libsumo::VAR_VIEW_OFFSET, viewID);
665}
666
667std::string
668TraCIAPI::GUIScope::getSchema(const std::string& viewID) const {
669 return getString(libsumo::VAR_VIEW_SCHEMA, viewID);
670}
671
673TraCIAPI::GUIScope::getBoundary(const std::string& viewID) const {
674 return getPolygon(libsumo::VAR_VIEW_BOUNDARY, viewID);
675}
676
677
678void
679TraCIAPI::GUIScope::setZoom(const std::string& viewID, double zoom) const {
680 setDouble(libsumo::VAR_VIEW_ZOOM, viewID, zoom);
681}
682
683void
684TraCIAPI::GUIScope::setOffset(const std::string& viewID, double x, double y) const {
685 tcpip::Storage content;
687 content.writeDouble(x);
688 content.writeDouble(y);
689 myParent.createCommand(libsumo::CMD_SET_GUI_VARIABLE, libsumo::VAR_VIEW_OFFSET, viewID, &content);
690 myParent.processSet(libsumo::CMD_SET_GUI_VARIABLE);
691}
692
693void
694TraCIAPI::GUIScope::setSchema(const std::string& viewID, const std::string& schemeName) const {
695 setString(libsumo::VAR_VIEW_SCHEMA, viewID, schemeName);
696}
697
698void
699TraCIAPI::GUIScope::setBoundary(const std::string& viewID, double xmin, double ymin, double xmax, double ymax) const {
700 tcpip::Storage content;
702 content.writeByte(2);
703 content.writeDouble(xmin);
704 content.writeDouble(ymin);
705 content.writeDouble(xmax);
706 content.writeDouble(ymax);
707 myParent.createCommand(libsumo::CMD_SET_GUI_VARIABLE, libsumo::VAR_VIEW_BOUNDARY, viewID, &content);
708 myParent.processSet(libsumo::CMD_SET_GUI_VARIABLE);
709}
710
711void
712TraCIAPI::GUIScope::screenshot(const std::string& viewID, const std::string& filename, const int width, const int height) const {
713 tcpip::Storage content;
715 content.writeInt(3);
717 content.writeString(filename);
719 content.writeInt(width);
721 content.writeInt(height);
722 myParent.createCommand(libsumo::CMD_SET_GUI_VARIABLE, libsumo::VAR_SCREENSHOT, viewID, &content);
723 myParent.processSet(libsumo::CMD_SET_GUI_VARIABLE);
724}
725
726void
727TraCIAPI::GUIScope::trackVehicle(const std::string& viewID, const std::string& vehID) const {
728 setString(libsumo::VAR_VIEW_SCHEMA, viewID, vehID);
729}
730
731
732// ---------------------------------------------------------------------------
733// TraCIAPI::InductionLoopScope-methods
734// ---------------------------------------------------------------------------
735double
736TraCIAPI::InductionLoopScope::getPosition(const std::string& loopID) const {
737 return getDouble(libsumo::VAR_POSITION, loopID);
738}
739
740std::string
741TraCIAPI::InductionLoopScope::getLaneID(const std::string& loopID) const {
742 return getString(libsumo::VAR_LANE_ID, loopID);
743}
744
745int
747 return getInt(libsumo::LAST_STEP_VEHICLE_NUMBER, loopID);
748}
749
750double
752 return getDouble(libsumo::LAST_STEP_MEAN_SPEED, loopID);
753}
754
755std::vector<std::string>
757 return getStringVector(libsumo::LAST_STEP_VEHICLE_ID_LIST, loopID);
758}
759
760double
762 return getDouble(libsumo::LAST_STEP_OCCUPANCY, loopID);
763}
764
765double
767 return getDouble(libsumo::LAST_STEP_LENGTH, loopID);
768}
769
770double
772 return getDouble(libsumo::LAST_STEP_TIME_SINCE_DETECTION, loopID);
773}
774
775
776std::vector<libsumo::TraCIVehicleData>
777TraCIAPI::InductionLoopScope::getVehicleData(const std::string& loopID) const {
778 std::vector<libsumo::TraCIVehicleData> result;
781 myParent.myInput.readInt(); // components
782 // number of items
783 myParent.myInput.readUnsignedByte();
784 const int n = myParent.myInput.readInt();
785 for (int i = 0; i < n; ++i) {
787
788 myParent.myInput.readUnsignedByte();
789 vd.id = myParent.myInput.readString();
790
791 myParent.myInput.readUnsignedByte();
792 vd.length = myParent.myInput.readDouble();
793
794 myParent.myInput.readUnsignedByte();
795 vd.entryTime = myParent.myInput.readDouble();
796
797 myParent.myInput.readUnsignedByte();
798 vd.leaveTime = myParent.myInput.readDouble();
799
800 myParent.myInput.readUnsignedByte();
801 vd.typeID = myParent.myInput.readString();
802
803 result.push_back(vd);
804 }
805 }
806 return result;
807}
808
809
810// ---------------------------------------------------------------------------
811// TraCIAPI::JunctionScope-methods
812// ---------------------------------------------------------------------------
814TraCIAPI::JunctionScope::getPosition(const std::string& junctionID) const {
815 return getPos(libsumo::VAR_POSITION, junctionID);
816}
817
819TraCIAPI::JunctionScope::getShape(const std::string& junctionID) const {
820 return getPolygon(libsumo::VAR_SHAPE, junctionID);
821}
822
823
824// ---------------------------------------------------------------------------
825// TraCIAPI::LaneScope-methods
826// ---------------------------------------------------------------------------
827double
828TraCIAPI::LaneScope::getLength(const std::string& laneID) const {
829 return getDouble(libsumo::VAR_LENGTH, laneID);
830}
831
832double
833TraCIAPI::LaneScope::getMaxSpeed(const std::string& laneID) const {
834 return getDouble(libsumo::VAR_MAXSPEED, laneID);
835}
836
837double
838TraCIAPI::LaneScope::getWidth(const std::string& laneID) const {
839 return getDouble(libsumo::VAR_WIDTH, laneID);
840}
841
842std::vector<std::string>
843TraCIAPI::LaneScope::getAllowed(const std::string& laneID) const {
844 return getStringVector(libsumo::LANE_ALLOWED, laneID);
845}
846
847std::vector<std::string>
848TraCIAPI::LaneScope::getDisallowed(const std::string& laneID) const {
849 return getStringVector(libsumo::LANE_DISALLOWED, laneID);
850}
851
852int
853TraCIAPI::LaneScope::getLinkNumber(const std::string& laneID) const {
854 return getInt(libsumo::LANE_LINK_NUMBER, laneID);
855}
856
857std::vector<libsumo::TraCIConnection>
858TraCIAPI::LaneScope::getLinks(const std::string& laneID) const {
859 std::vector<libsumo::TraCIConnection> ret;
860 myParent.createCommand(libsumo::CMD_GET_LANE_VARIABLE, libsumo::LANE_LINKS, laneID);
861 if (myParent.processGet(libsumo::CMD_GET_LANE_VARIABLE, libsumo::TYPE_COMPOUND)) {
862 myParent.myInput.readUnsignedByte();
863 myParent.myInput.readInt();
864
865 int linkNo = myParent.myInput.readInt();
866 for (int i = 0; i < linkNo; ++i) {
867
868 myParent.myInput.readUnsignedByte();
869 std::string approachedLane = myParent.myInput.readString();
870
871 myParent.myInput.readUnsignedByte();
872 std::string approachedLaneInternal = myParent.myInput.readString();
873
874 myParent.myInput.readUnsignedByte();
875 bool hasPrio = myParent.myInput.readUnsignedByte() != 0;
876
877 myParent.myInput.readUnsignedByte();
878 bool isOpen = myParent.myInput.readUnsignedByte() != 0;
879
880 myParent.myInput.readUnsignedByte();
881 bool hasFoe = myParent.myInput.readUnsignedByte() != 0;
882
883 myParent.myInput.readUnsignedByte();
884 std::string state = myParent.myInput.readString();
885
886 myParent.myInput.readUnsignedByte();
887 std::string direction = myParent.myInput.readString();
888
889 myParent.myInput.readUnsignedByte();
890 double length = myParent.myInput.readDouble();
891
892 ret.push_back(libsumo::TraCIConnection(approachedLane,
893 hasPrio,
894 isOpen,
895 hasFoe,
896 approachedLaneInternal,
897 state,
898 direction,
899 length));
900
901 }
902
903 }
904 return ret;
905}
906
908TraCIAPI::LaneScope::getShape(const std::string& laneID) const {
909 return getPolygon(libsumo::VAR_SHAPE, laneID);
910}
911
912std::string
913TraCIAPI::LaneScope::getEdgeID(const std::string& laneID) const {
914 return getString(libsumo::LANE_EDGE_ID, laneID);
915}
916
917double
918TraCIAPI::LaneScope::getCO2Emission(const std::string& laneID) const {
919 return getDouble(libsumo::VAR_CO2EMISSION, laneID);
920}
921
922double
923TraCIAPI::LaneScope::getCOEmission(const std::string& laneID) const {
924 return getDouble(libsumo::VAR_COEMISSION, laneID);
925}
926
927double
928TraCIAPI::LaneScope::getHCEmission(const std::string& laneID) const {
929 return getDouble(libsumo::VAR_HCEMISSION, laneID);
930}
931
932double
933TraCIAPI::LaneScope::getPMxEmission(const std::string& laneID) const {
934 return getDouble(libsumo::VAR_PMXEMISSION, laneID);
935}
936
937double
938TraCIAPI::LaneScope::getNOxEmission(const std::string& laneID) const {
939 return getDouble(libsumo::VAR_NOXEMISSION, laneID);
940}
941
942double
943TraCIAPI::LaneScope::getFuelConsumption(const std::string& laneID) const {
944 return getDouble(libsumo::VAR_FUELCONSUMPTION, laneID);
945}
946
947double
948TraCIAPI::LaneScope::getNoiseEmission(const std::string& laneID) const {
949 return getDouble(libsumo::VAR_NOISEEMISSION, laneID);
950}
951
952double
953TraCIAPI::LaneScope::getElectricityConsumption(const std::string& laneID) const {
954 return getDouble(libsumo::VAR_ELECTRICITYCONSUMPTION, laneID);
955}
956
957double
958TraCIAPI::LaneScope::getLastStepMeanSpeed(const std::string& laneID) const {
959 return getDouble(libsumo::LAST_STEP_MEAN_SPEED, laneID);
960}
961
962double
963TraCIAPI::LaneScope::getLastStepOccupancy(const std::string& laneID) const {
964 return getDouble(libsumo::LAST_STEP_OCCUPANCY, laneID);
965}
966
967double
968TraCIAPI::LaneScope::getLastStepLength(const std::string& laneID) const {
969 return getDouble(libsumo::LAST_STEP_LENGTH, laneID);
970}
971
972double
973TraCIAPI::LaneScope::getTraveltime(const std::string& laneID) const {
974 return getDouble(libsumo::VAR_CURRENT_TRAVELTIME, laneID);
975}
976
977int
978TraCIAPI::LaneScope::getLastStepVehicleNumber(const std::string& laneID) const {
979 return getInt(libsumo::LAST_STEP_VEHICLE_NUMBER, laneID);
980}
981
982int
983TraCIAPI::LaneScope::getLastStepHaltingNumber(const std::string& laneID) const {
984 return getInt(libsumo::LAST_STEP_VEHICLE_HALTING_NUMBER, laneID);
985}
986
987std::vector<std::string>
988TraCIAPI::LaneScope::getLastStepVehicleIDs(const std::string& laneID) const {
989 return getStringVector(libsumo::LAST_STEP_VEHICLE_ID_LIST, laneID);
990}
991
992
993std::vector<std::string>
994TraCIAPI::LaneScope::getFoes(const std::string& laneID, const std::string& toLaneID) const {
995 std::vector<std::string> r;
996 tcpip::Storage content;
998 content.writeString(toLaneID);
999 myParent.createCommand(libsumo::CMD_GET_LANE_VARIABLE, libsumo::VAR_FOES, laneID, &content);
1000 if (myParent.processGet(libsumo::CMD_GET_LANE_VARIABLE, libsumo::TYPE_STRINGLIST)) {
1001 const int size = myParent.myInput.readInt();
1002 for (int i = 0; i < size; ++i) {
1003 r.push_back(myParent.myInput.readString());
1004 }
1005 }
1006 return r;
1007}
1008
1009std::vector<std::string>
1010TraCIAPI::LaneScope::getInternalFoes(const std::string& laneID) const {
1011 return getFoes(laneID, "");
1012}
1013
1014
1015void
1016TraCIAPI::LaneScope::setAllowed(const std::string& laneID, const std::vector<std::string>& allowedClasses) const {
1017 setStringVector(libsumo::LANE_ALLOWED, laneID, allowedClasses);
1018}
1019
1020void
1021TraCIAPI::LaneScope::setDisallowed(const std::string& laneID, const std::vector<std::string>& disallowedClasses) const {
1022 setStringVector(libsumo::LANE_DISALLOWED, laneID, disallowedClasses);
1023}
1024
1025void
1026TraCIAPI::LaneScope::setMaxSpeed(const std::string& laneID, double speed) const {
1027 setDouble(libsumo::VAR_MAXSPEED, laneID, speed);
1028}
1029
1030void
1031TraCIAPI::LaneScope::setLength(const std::string& laneID, double length) const {
1032 setDouble(libsumo::VAR_LENGTH, laneID, length);
1033}
1034
1035
1036// ---------------------------------------------------------------------------
1037// TraCIAPI::LaneAreaDetector-methods
1038// ---------------------------------------------------------------------------
1039
1040
1041// ---------------------------------------------------------------------------
1042// TraCIAPI::MeMeScope-methods
1043// ---------------------------------------------------------------------------
1044int
1045TraCIAPI::MeMeScope::getLastStepVehicleNumber(const std::string& detID) const {
1046 return getInt(libsumo::LAST_STEP_VEHICLE_NUMBER, detID);
1047}
1048
1049double
1050TraCIAPI::MeMeScope::getLastStepMeanSpeed(const std::string& detID) const {
1051 return getDouble(libsumo::LAST_STEP_MEAN_SPEED, detID);
1052}
1053
1054std::vector<std::string>
1055TraCIAPI::MeMeScope::getLastStepVehicleIDs(const std::string& detID) const {
1056 return getStringVector(libsumo::LAST_STEP_VEHICLE_ID_LIST, detID);
1057}
1058
1059int
1060TraCIAPI::MeMeScope::getLastStepHaltingNumber(const std::string& detID) const {
1061 return getInt(libsumo::LAST_STEP_VEHICLE_HALTING_NUMBER, detID);
1062}
1063
1064std::vector<std::string>
1065TraCIAPI::MeMeScope::getEntryLanes(const std::string& detID) const {
1066 return getStringVector(libsumo::VAR_LANES, detID);
1067}
1068
1069std::vector<std::string>
1070TraCIAPI::MeMeScope::getExitLanes(const std::string& detID) const {
1071 return getStringVector(libsumo::VAR_EXIT_LANES, detID);
1072}
1073
1074std::vector<double>
1075TraCIAPI::MeMeScope::getEntryPositions(const std::string& detID) const {
1076 return getDoubleVector(libsumo::VAR_POSITION, detID);
1077}
1078
1079std::vector<double>
1080TraCIAPI::MeMeScope::getExitPositions(const std::string& detID) const {
1081 return getDoubleVector(libsumo::VAR_EXIT_POSITIONS, detID);
1082}
1083
1084// ---------------------------------------------------------------------------
1085// TraCIAPI::POIScope-methods
1086// ---------------------------------------------------------------------------
1087std::string
1088TraCIAPI::POIScope::getType(const std::string& poiID) const {
1089 return getString(libsumo::VAR_TYPE, poiID);
1090}
1091
1093TraCIAPI::POIScope::getPosition(const std::string& poiID) const {
1094 return getPos(libsumo::VAR_POSITION, poiID);
1095}
1096
1098TraCIAPI::POIScope::getColor(const std::string& poiID) const {
1099 return getCol(libsumo::VAR_COLOR, poiID);
1100}
1101
1102double
1103TraCIAPI::POIScope::getWidth(const std::string& poiID) const {
1104 return getDouble(libsumo::VAR_WIDTH, poiID);
1105}
1106
1107double
1108TraCIAPI::POIScope::getHeight(const std::string& poiID) const {
1109 return getDouble(libsumo::VAR_HEIGHT, poiID);
1110}
1111
1112double
1113TraCIAPI::POIScope::getAngle(const std::string& poiID) const {
1114 return getDouble(libsumo::VAR_ANGLE, poiID);
1115}
1116
1117std::string
1118TraCIAPI::POIScope::getImageFile(const std::string& poiID) const {
1119 return getString(libsumo::VAR_IMAGEFILE, poiID);
1120}
1121
1122
1123void
1124TraCIAPI::POIScope::setType(const std::string& poiID, const std::string& setType) const {
1125 setString(libsumo::VAR_TYPE, poiID, setType);
1126}
1127
1128
1129void
1130TraCIAPI::POIScope::setPosition(const std::string& poiID, double x, double y) const {
1131 tcpip::Storage content;
1133 content.writeDouble(x);
1134 content.writeDouble(y);
1135 myParent.createCommand(libsumo::CMD_SET_POI_VARIABLE, libsumo::VAR_POSITION, poiID, &content);
1136 myParent.processSet(libsumo::CMD_SET_POI_VARIABLE);
1137}
1138
1139
1140void
1141TraCIAPI::POIScope::setColor(const std::string& poiID, const libsumo::TraCIColor& c) const {
1142 tcpip::Storage content;
1144 content.writeUnsignedByte(c.r);
1145 content.writeUnsignedByte(c.g);
1146 content.writeUnsignedByte(c.b);
1147 content.writeUnsignedByte(c.a);
1148 myParent.createCommand(libsumo::CMD_SET_POI_VARIABLE, libsumo::VAR_COLOR, poiID, &content);
1149 myParent.processSet(libsumo::CMD_SET_POI_VARIABLE);
1150}
1151
1152
1153void
1154TraCIAPI::POIScope::setWidth(const std::string& poiID, double width) const {
1155 setDouble(libsumo::VAR_WIDTH, poiID, width);
1156}
1157
1158
1159void
1160TraCIAPI::POIScope::setHeight(const std::string& poiID, double height) const {
1161 setDouble(libsumo::VAR_HEIGHT, poiID, height);
1162}
1163
1164
1165void
1166TraCIAPI::POIScope::setAngle(const std::string& poiID, double angle) const {
1167 setDouble(libsumo::VAR_ANGLE, poiID, angle);
1168}
1169
1170
1171void
1172TraCIAPI::POIScope::setImageFile(const std::string& poiID, const std::string& imageFile) const {
1173 setString(libsumo::VAR_IMAGEFILE, poiID, imageFile);
1174}
1175
1176
1177void
1178TraCIAPI::POIScope::add(const std::string& poiID, double x, double y, const libsumo::TraCIColor& c, const std::string& type, int layer, const std::string& imgFile, double width, double height, double angle) const {
1179 tcpip::Storage content;
1181 content.writeInt(8);
1183 content.writeString(type);
1185 content.writeUnsignedByte(c.r);
1186 content.writeUnsignedByte(c.g);
1187 content.writeUnsignedByte(c.b);
1188 content.writeUnsignedByte(c.a);
1190 content.writeInt(layer);
1192 content.writeDouble(x);
1193 content.writeDouble(y);
1195 content.writeString(imgFile);
1197 content.writeDouble(width);
1199 content.writeDouble(height);
1201 content.writeDouble(angle);
1202 myParent.createCommand(libsumo::CMD_SET_POI_VARIABLE, libsumo::ADD, poiID, &content);
1203 myParent.processSet(libsumo::CMD_SET_POI_VARIABLE);
1204}
1205
1206void
1207TraCIAPI::POIScope::remove(const std::string& poiID, int layer) const {
1208 tcpip::Storage content;
1210 content.writeInt(layer);
1211 myParent.createCommand(libsumo::CMD_SET_POI_VARIABLE, libsumo::REMOVE, poiID, &content);
1212 myParent.processSet(libsumo::CMD_SET_POI_VARIABLE);
1213}
1214
1215
1216// ---------------------------------------------------------------------------
1217// TraCIAPI::PolygonScope-methods
1218// ---------------------------------------------------------------------------
1219double
1220TraCIAPI::PolygonScope::getLineWidth(const std::string& polygonID) const {
1221 return getDouble(libsumo::VAR_WIDTH, polygonID);
1222}
1223
1224bool
1225TraCIAPI::PolygonScope::getFilled(const std::string& polygonID) const {
1226 return getInt(libsumo::VAR_FILL, polygonID) != 0;
1227}
1228
1229std::string
1230TraCIAPI::PolygonScope::getType(const std::string& polygonID) const {
1231 return getString(libsumo::VAR_TYPE, polygonID);
1232}
1233
1235TraCIAPI::PolygonScope::getShape(const std::string& polygonID) const {
1236 return getPolygon(libsumo::VAR_SHAPE, polygonID);
1237}
1238
1240TraCIAPI::PolygonScope::getColor(const std::string& polygonID) const {
1241 return getCol(libsumo::VAR_COLOR, polygonID);
1242}
1243
1244void
1245TraCIAPI::PolygonScope::setLineWidth(const std::string& polygonID, const double lineWidth) const {
1246 tcpip::Storage content;
1248 content.writeDouble(lineWidth);
1249 myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_WIDTH, polygonID, &content);
1250 myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1251}
1252
1253void
1254TraCIAPI::PolygonScope::setType(const std::string& polygonID, const std::string& setType) const {
1255 tcpip::Storage content;
1257 content.writeString(setType);
1258 myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_TYPE, polygonID, &content);
1259 myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1260}
1261
1262
1263void
1264TraCIAPI::PolygonScope::setShape(const std::string& polygonID, const libsumo::TraCIPositionVector& shape) const {
1265 tcpip::Storage content;
1267 if (shape.value.size() < 256) {
1268 content.writeUnsignedByte((int)shape.value.size());
1269 } else {
1270 content.writeUnsignedByte(0);
1271 content.writeInt((int)shape.value.size());
1272 }
1273 for (const libsumo::TraCIPosition& pos : shape.value) {
1274 content.writeDouble(pos.x);
1275 content.writeDouble(pos.y);
1276 }
1277 myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_SHAPE, polygonID, &content);
1278 myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1279}
1280
1281
1282void
1283TraCIAPI::PolygonScope::setColor(const std::string& polygonID, const libsumo::TraCIColor& c) const {
1284 tcpip::Storage content;
1286 content.writeUnsignedByte(c.r);
1287 content.writeUnsignedByte(c.g);
1288 content.writeUnsignedByte(c.b);
1289 content.writeUnsignedByte(c.a);
1290 myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::VAR_COLOR, polygonID, &content);
1291 myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1292}
1293
1294void
1295TraCIAPI::PolygonScope::add(const std::string& polygonID, const libsumo::TraCIPositionVector& shape, const libsumo::TraCIColor& c, bool fill, const std::string& type, int layer) const {
1296 tcpip::Storage content;
1298 content.writeInt(5);
1300 content.writeString(type);
1302 content.writeUnsignedByte(c.r);
1303 content.writeUnsignedByte(c.g);
1304 content.writeUnsignedByte(c.b);
1305 content.writeUnsignedByte(c.a);
1307 int f = fill ? 1 : 0;
1308 content.writeUnsignedByte(f);
1310 content.writeInt(layer);
1312 content.writeUnsignedByte((int)shape.value.size());
1313 for (int i = 0; i < (int)shape.value.size(); ++i) {
1314 content.writeDouble(shape.value[i].x);
1315 content.writeDouble(shape.value[i].y);
1316 }
1317 myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::ADD, polygonID, &content);
1318 myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1319}
1320
1321void
1322TraCIAPI::PolygonScope::remove(const std::string& polygonID, int layer) const {
1323 tcpip::Storage content;
1325 content.writeInt(layer);
1326 myParent.createCommand(libsumo::CMD_SET_POLYGON_VARIABLE, libsumo::REMOVE, polygonID, &content);
1327 myParent.processSet(libsumo::CMD_SET_POLYGON_VARIABLE);
1328}
1329
1330
1331// ---------------------------------------------------------------------------
1332// TraCIAPI::RouteScope-methods
1333// ---------------------------------------------------------------------------
1334std::vector<std::string>
1335TraCIAPI::RouteScope::getEdges(const std::string& routeID) const {
1336 return getStringVector(libsumo::VAR_EDGES, routeID);
1337}
1338
1339
1340void
1341TraCIAPI::RouteScope::add(const std::string& routeID, const std::vector<std::string>& edges) const {
1342 tcpip::Storage content;
1344 content.writeStringList(edges);
1345 myParent.createCommand(libsumo::CMD_SET_ROUTE_VARIABLE, libsumo::ADD, routeID, &content);
1346 myParent.processSet(libsumo::CMD_SET_ROUTE_VARIABLE);
1347}
1348
1349
1350// ---------------------------------------------------------------------------
1351// TraCIAPI::SimulationScope-methods
1352// ---------------------------------------------------------------------------
1353int
1355 return getInt(libsumo::VAR_TIME_STEP, "");
1356}
1357
1358double
1360 return getDouble(libsumo::VAR_TIME, "");
1361}
1362
1363int
1365 return (int) getInt(libsumo::VAR_LOADED_VEHICLES_NUMBER, "");
1366}
1367
1368std::vector<std::string>
1370 return getStringVector(libsumo::VAR_LOADED_VEHICLES_IDS, "");
1371}
1372
1373int
1375 return (int) getInt(libsumo::VAR_DEPARTED_VEHICLES_NUMBER, "");
1376}
1377
1378std::vector<std::string>
1380 return getStringVector(libsumo::VAR_DEPARTED_VEHICLES_IDS, "");
1381}
1382
1383int
1385 return (int) getInt(libsumo::VAR_ARRIVED_VEHICLES_NUMBER, "");
1386}
1387
1388std::vector<std::string>
1390 return getStringVector(libsumo::VAR_ARRIVED_VEHICLES_IDS, "");
1391}
1392
1393int
1395 return (int) getInt(libsumo::VAR_TELEPORT_STARTING_VEHICLES_NUMBER, "");
1396}
1397
1398std::vector<std::string>
1400 return getStringVector(libsumo::VAR_TELEPORT_STARTING_VEHICLES_IDS, "");
1401}
1402
1403int
1405 return (int) getInt(libsumo::VAR_TELEPORT_ENDING_VEHICLES_NUMBER, "");
1406}
1407
1408std::vector<std::string>
1410 return getStringVector(libsumo::VAR_TELEPORT_ENDING_VEHICLES_IDS, "");
1411}
1412
1413int
1415 return (int)getInt(libsumo::VAR_DEPARTED_PERSONS_NUMBER, "");
1416}
1417
1418std::vector<std::string>
1420 return getStringVector(libsumo::VAR_DEPARTED_PERSONS_IDS, "");
1421}
1422
1423int
1425 return (int)getInt(libsumo::VAR_ARRIVED_PERSONS_NUMBER, "");
1426}
1427
1428std::vector<std::string>
1430 return getStringVector(libsumo::VAR_ARRIVED_PERSONS_IDS, "");
1431}
1432
1433double
1435 return getDouble(libsumo::VAR_DELTA_T, "");
1436}
1437
1440 return getPolygon(libsumo::VAR_NET_BOUNDING_BOX, "");
1441}
1442
1443
1444int
1446 return getInt(libsumo::VAR_MIN_EXPECTED_VEHICLES, "");
1447}
1448
1449std::string
1450TraCIAPI::SimulationScope::getOption(const std::string& option) const {
1451 return getString(libsumo::VAR_OPTION, option);
1452}
1453
1454int
1455TraCIAPI::SimulationScope::getBusStopWaiting(const std::string& stopID) const {
1456 return (int) getInt(libsumo::VAR_BUS_STOP_WAITING, stopID);
1457}
1458
1459std::vector<std::string>
1461 return getStringVector(libsumo::VAR_BUS_STOP_WAITING_IDS, stopID);
1462}
1463
1464
1466TraCIAPI::SimulationScope::convert2D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) const {
1467 const int posType = toGeo ? libsumo::POSITION_LON_LAT : libsumo::POSITION_2D;
1469 tcpip::Storage content;
1471 content.writeInt(2);
1473 content.writeString(edgeID);
1474 content.writeDouble(pos);
1475 content.writeByte(laneIndex);
1477 content.writeByte(posType);
1478 myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
1479 if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
1480 result.x = myParent.myInput.readDouble();
1481 result.y = myParent.myInput.readDouble();
1482 }
1483 return result;
1484}
1485
1486
1488TraCIAPI::SimulationScope::convert3D(const std::string& edgeID, double pos, int laneIndex, bool toGeo) const {
1489 const int posType = toGeo ? libsumo::POSITION_LON_LAT_ALT : libsumo::POSITION_3D;
1491 tcpip::Storage content;
1493 content.writeInt(2);
1495 content.writeString(edgeID);
1496 content.writeDouble(pos);
1497 content.writeByte(laneIndex);
1499 content.writeByte(posType);
1500 myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
1501 if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
1502 result.x = myParent.myInput.readDouble();
1503 result.y = myParent.myInput.readDouble();
1504 result.z = myParent.myInput.readDouble();
1505 }
1506 return result;
1507}
1508
1509
1511TraCIAPI::SimulationScope::convertRoad(double x, double y, bool isGeo, const std::string& vClass) const {
1513 tcpip::Storage content;
1515 content.writeInt(3);
1517 content.writeDouble(x);
1518 content.writeDouble(y);
1522 content.writeString(vClass);
1523 myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
1524 if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_ROADMAP)) {
1525 result.edgeID = myParent.myInput.readString();
1526 result.pos = myParent.myInput.readDouble();
1527 result.laneIndex = myParent.myInput.readUnsignedByte();
1528 }
1529 return result;
1530}
1531
1532
1534TraCIAPI::SimulationScope::convertGeo(double x, double y, bool fromGeo) const {
1535 const int posType = fromGeo ? libsumo::POSITION_2D : libsumo::POSITION_LON_LAT;
1537 tcpip::Storage content;
1539 content.writeInt(2);
1541 content.writeDouble(x);
1542 content.writeDouble(y);
1544 content.writeByte(posType);
1545 myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::POSITION_CONVERSION, "", &content);
1546 if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, posType)) {
1547 result.x = myParent.myInput.readDouble();
1548 result.y = myParent.myInput.readDouble();
1549 }
1550 return result;
1551}
1552
1553
1554double
1555TraCIAPI::SimulationScope::getDistance2D(double x1, double y1, double x2, double y2, bool isGeo, bool isDriving) {
1556 tcpip::Storage content;
1558 content.writeInt(3);
1560 content.writeDouble(x1);
1561 content.writeDouble(y1);
1563 content.writeDouble(x2);
1564 content.writeDouble(y2);
1566 myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::DISTANCE_REQUEST, "", &content);
1567 if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::TYPE_DOUBLE)) {
1568 return myParent.myInput.readDouble();
1569 }
1570 return 0.;
1571}
1572
1573
1574double
1575TraCIAPI::SimulationScope::getDistanceRoad(const std::string& edgeID1, double pos1, const std::string& edgeID2, double pos2, bool isDriving) {
1576 tcpip::Storage content;
1578 content.writeInt(3);
1580 content.writeString(edgeID1);
1581 content.writeDouble(pos1);
1582 content.writeByte(0); // lane
1584 content.writeString(edgeID2);
1585 content.writeDouble(pos2);
1586 content.writeByte(0); // lane
1588 myParent.createCommand(libsumo::CMD_GET_SIM_VARIABLE, libsumo::DISTANCE_REQUEST, "", &content);
1589 if (myParent.processGet(libsumo::CMD_GET_SIM_VARIABLE, libsumo::TYPE_DOUBLE)) {
1590 return myParent.myInput.readDouble();
1591 }
1592 return 0.;
1593}
1594
1595
1597TraCIAPI::SimulationScope::findRoute(const std::string& fromEdge, const std::string& toEdge, const std::string& vType, double pos, int routingMode) const {
1598 tcpip::Storage content;
1600 content.writeInt(5);
1602 content.writeString(fromEdge);
1604 content.writeString(toEdge);
1606 content.writeString(vType);
1608 content.writeDouble(pos);
1610 content.writeInt(routingMode);
1611 return getTraCIStage(libsumo::FIND_ROUTE, "", &content);
1612}
1613
1614void
1615TraCIAPI::SimulationScope::loadState(const std::string& path) const {
1616 tcpip::Storage content;
1618 content.writeString(path);
1619 myParent.createCommand(libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_LOAD_SIMSTATE, "", &content);
1620 myParent.processSet(libsumo::CMD_SET_SIM_VARIABLE);
1621}
1622
1623void
1624TraCIAPI::SimulationScope::saveState(const std::string& destination) const {
1625 tcpip::Storage content;
1627 content.writeString(destination);
1628 myParent.createCommand(libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_SAVE_SIMSTATE, "", &content);
1629 myParent.processSet(libsumo::CMD_SET_SIM_VARIABLE);
1630}
1631
1632void
1634 tcpip::Storage content;
1636 content.writeString(msg);
1637 myParent.createCommand(libsumo::CMD_SET_SIM_VARIABLE, libsumo::CMD_MESSAGE, "", &content);
1638 myParent.processSet(libsumo::CMD_SET_SIM_VARIABLE);
1639}
1640
1641
1642// ---------------------------------------------------------------------------
1643// TraCIAPI::TrafficLightScope-methods
1644// ---------------------------------------------------------------------------
1645std::string
1647 return getString(libsumo::TL_RED_YELLOW_GREEN_STATE, tlsID);
1648}
1649
1650std::vector<libsumo::TraCILogic>
1652 std::vector<libsumo::TraCILogic> ret;
1654 if (myParent.processGet(libsumo::CMD_GET_TL_VARIABLE, libsumo::TYPE_COMPOUND)) {
1655 const int logicNo = myParent.myInput.readInt();
1656 for (int i = 0; i < logicNo; ++i) {
1657 myParent.myInput.readUnsignedByte();
1658 myParent.myInput.readInt();
1659 myParent.myInput.readUnsignedByte();
1660 const std::string programID = myParent.myInput.readString();
1661 myParent.myInput.readUnsignedByte();
1662 const int type = myParent.myInput.readInt();
1663 myParent.myInput.readUnsignedByte();
1664 const int phaseIndex = myParent.myInput.readInt();
1665 myParent.myInput.readUnsignedByte();
1666 const int phaseNumber = myParent.myInput.readInt();
1667 libsumo::TraCILogic logic(programID, type, phaseIndex);
1668 for (int j = 0; j < phaseNumber; j++) {
1669 myParent.myInput.readUnsignedByte();
1670 myParent.myInput.readInt();
1671 myParent.myInput.readUnsignedByte();
1672 const double duration = myParent.myInput.readDouble();
1673 myParent.myInput.readUnsignedByte();
1674 const std::string state = myParent.myInput.readString();
1675 myParent.myInput.readUnsignedByte();
1676 const double minDur = myParent.myInput.readDouble();
1677 myParent.myInput.readUnsignedByte();
1678 const double maxDur = myParent.myInput.readDouble();
1679 myParent.myInput.readUnsignedByte();
1680 const int numNext = myParent.myInput.readInt();
1681 std::vector<int> next;
1682 for (int k = 0; k < numNext; k++) {
1683 myParent.myInput.readUnsignedByte();
1684 next.push_back(myParent.myInput.readInt());
1685 }
1686 myParent.myInput.readUnsignedByte();
1687 const std::string name = myParent.myInput.readString();
1688 logic.phases.emplace_back(new libsumo::TraCIPhase(duration, state, minDur, maxDur, next, name));
1689 }
1690 myParent.myInput.readUnsignedByte();
1691 const int paramNumber = myParent.myInput.readInt();
1692 for (int j = 0; j < paramNumber; j++) {
1693 myParent.myInput.readUnsignedByte();
1694 const std::vector<std::string> par = myParent.myInput.readStringList();
1695 logic.subParameter[par[0]] = par[1];
1696 }
1697 ret.emplace_back(logic);
1698 }
1699 }
1700 return ret;
1701}
1702
1703std::vector<std::string>
1705 return getStringVector(libsumo::TL_CONTROLLED_LANES, tlsID);
1706}
1707
1708std::vector<std::vector<libsumo::TraCILink> >
1710 std::vector<std::vector<libsumo::TraCILink> > result;
1711 myParent.createCommand(libsumo::CMD_GET_TL_VARIABLE, libsumo::TL_CONTROLLED_LINKS, tlsID);
1712 if (myParent.processGet(libsumo::CMD_GET_TL_VARIABLE, libsumo::TYPE_COMPOUND)) {
1713
1714 myParent.myInput.readUnsignedByte();
1715 myParent.myInput.readInt();
1716
1717 int linkNo = myParent.myInput.readInt();
1718 for (int i = 0; i < linkNo; ++i) {
1719 myParent.myInput.readUnsignedByte();
1720 int no = myParent.myInput.readInt();
1721 std::vector<libsumo::TraCILink> ret;
1722 for (int i1 = 0; i1 < no; ++i1) {
1723 myParent.myInput.readUnsignedByte();
1724 myParent.myInput.readInt();
1725 std::string from = myParent.myInput.readString();
1726 std::string to = myParent.myInput.readString();
1727 std::string via = myParent.myInput.readString();
1728 ret.emplace_back(libsumo::TraCILink(from, via, to));
1729 }
1730 result.emplace_back(ret);
1731 }
1732 }
1733 return result;
1734}
1735
1736std::string
1737TraCIAPI::TrafficLightScope::getProgram(const std::string& tlsID) const {
1738 return getString(libsumo::TL_CURRENT_PROGRAM, tlsID);
1739}
1740
1741int
1742TraCIAPI::TrafficLightScope::getPhase(const std::string& tlsID) const {
1743 return getInt(libsumo::TL_CURRENT_PHASE, tlsID);
1744}
1745
1746std::string
1747TraCIAPI::TrafficLightScope::getPhaseName(const std::string& tlsID) const {
1748 return getString(libsumo::VAR_NAME, tlsID);
1749}
1750
1751double
1752TraCIAPI::TrafficLightScope::getPhaseDuration(const std::string& tlsID) const {
1753 return getDouble(libsumo::TL_PHASE_DURATION, tlsID);
1754}
1755
1756double
1757TraCIAPI::TrafficLightScope::getNextSwitch(const std::string& tlsID) const {
1758 return getDouble(libsumo::TL_NEXT_SWITCH, tlsID);
1759}
1760
1761
1762int
1763TraCIAPI::TrafficLightScope::getServedPersonCount(const std::string& tlsID, int index) const {
1764 tcpip::Storage content;
1766 content.writeInt(index);
1767 return getInt(libsumo::VAR_PERSON_NUMBER, tlsID, &content);
1768}
1769
1770
1771void
1772TraCIAPI::TrafficLightScope::setRedYellowGreenState(const std::string& tlsID, const std::string& state) const {
1773 tcpip::Storage content;
1775 content.writeString(state);
1776 myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_RED_YELLOW_GREEN_STATE, tlsID, &content);
1777 myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1778}
1779
1780void
1781TraCIAPI::TrafficLightScope::setPhase(const std::string& tlsID, int index) const {
1782 tcpip::Storage content;
1784 content.writeInt(index);
1785 myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PHASE_INDEX, tlsID, &content);
1786 myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1787}
1788
1789void
1790TraCIAPI::TrafficLightScope::setPhaseName(const std::string& tlsID, const std::string& name) const {
1791 tcpip::Storage content;
1793 content.writeString(name);
1794 myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::VAR_NAME, tlsID, &content);
1795 myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1796}
1797
1798void
1799TraCIAPI::TrafficLightScope::setProgram(const std::string& tlsID, const std::string& programID) const {
1800 tcpip::Storage content;
1802 content.writeString(programID);
1803 myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PROGRAM, tlsID, &content);
1804 myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1805}
1806
1807void
1808TraCIAPI::TrafficLightScope::setPhaseDuration(const std::string& tlsID, double phaseDuration) const {
1809 tcpip::Storage content;
1811 content.writeDouble(phaseDuration);
1812 myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_PHASE_DURATION, tlsID, &content);
1813 myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1814}
1815
1816void
1817TraCIAPI::TrafficLightScope::setProgramLogic(const std::string& tlsID, const libsumo::TraCILogic& logic) const {
1818 tcpip::Storage content;
1820 content.writeInt(5);
1822 content.writeString(logic.programID);
1824 content.writeInt(logic.type);
1826 content.writeInt(logic.currentPhaseIndex);
1828 content.writeInt((int)logic.phases.size());
1829 for (const std::shared_ptr<libsumo::TraCIPhase>& p : logic.phases) {
1831 content.writeInt(6);
1833 content.writeDouble(p->duration);
1835 content.writeString(p->state);
1837 content.writeDouble(p->minDur);
1839 content.writeDouble(p->maxDur);
1841 content.writeInt((int)p->next.size());
1842 for (int n : p->next) {
1844 content.writeInt(n);
1845 }
1847 content.writeString(p->name);
1848 }
1850 content.writeInt((int)logic.subParameter.size());
1851 for (const auto& item : logic.subParameter) {
1853 content.writeInt(2);
1854 content.writeString(item.first);
1855 content.writeString(item.second);
1856 }
1857 myParent.createCommand(libsumo::CMD_SET_TL_VARIABLE, libsumo::TL_COMPLETE_PROGRAM_RYG, tlsID, &content);
1858 myParent.processSet(libsumo::CMD_SET_TL_VARIABLE);
1859}
1860
1861
1862// ---------------------------------------------------------------------------
1863// TraCIAPI::VehicleTypeScope-methods
1864// ---------------------------------------------------------------------------
1865double
1866TraCIAPI::VehicleTypeScope::getLength(const std::string& typeID) const {
1867 return getDouble(libsumo::VAR_LENGTH, typeID);
1868}
1869
1870double
1871TraCIAPI::VehicleTypeScope::getMaxSpeed(const std::string& typeID) const {
1872 return getDouble(libsumo::VAR_MAXSPEED, typeID);
1873}
1874
1875double
1876TraCIAPI::VehicleTypeScope::getSpeedFactor(const std::string& typeID) const {
1877 return getDouble(libsumo::VAR_SPEED_FACTOR, typeID);
1878}
1879
1880double
1881TraCIAPI::VehicleTypeScope::getSpeedDeviation(const std::string& typeID) const {
1882 return getDouble(libsumo::VAR_SPEED_DEVIATION, typeID);
1883}
1884
1885double
1886TraCIAPI::VehicleTypeScope::getAccel(const std::string& typeID) const {
1887 return getDouble(libsumo::VAR_ACCEL, typeID);
1888}
1889
1890double
1891TraCIAPI::VehicleTypeScope::getDecel(const std::string& typeID) const {
1892 return getDouble(libsumo::VAR_DECEL, typeID);
1893}
1894
1895double
1896TraCIAPI::VehicleTypeScope::getEmergencyDecel(const std::string& typeID) const {
1897 return getDouble(libsumo::VAR_EMERGENCY_DECEL, typeID);
1898}
1899
1900double
1901TraCIAPI::VehicleTypeScope::getApparentDecel(const std::string& typeID) const {
1902 return getDouble(libsumo::VAR_APPARENT_DECEL, typeID);
1903}
1904
1905double
1906TraCIAPI::VehicleTypeScope::getImperfection(const std::string& typeID) const {
1907 return getDouble(libsumo::VAR_IMPERFECTION, typeID);
1908}
1909
1910double
1911TraCIAPI::VehicleTypeScope::getTau(const std::string& typeID) const {
1912 return getDouble(libsumo::VAR_TAU, typeID);
1913}
1914
1915std::string
1916TraCIAPI::VehicleTypeScope::getVehicleClass(const std::string& typeID) const {
1917 return getString(libsumo::VAR_VEHICLECLASS, typeID);
1918}
1919
1920std::string
1921TraCIAPI::VehicleTypeScope::getEmissionClass(const std::string& typeID) const {
1922 return getString(libsumo::VAR_EMISSIONCLASS, typeID);
1923}
1924
1925std::string
1926TraCIAPI::VehicleTypeScope::getShapeClass(const std::string& typeID) const {
1927 return getString(libsumo::VAR_SHAPECLASS, typeID);
1928}
1929
1930double
1931TraCIAPI::VehicleTypeScope::getMinGap(const std::string& typeID) const {
1932 return getDouble(libsumo::VAR_MINGAP, typeID);
1933}
1934
1935double
1936TraCIAPI::VehicleTypeScope::getMinGapLat(const std::string& typeID) const {
1937 return getDouble(libsumo::VAR_MINGAP_LAT, typeID);
1938}
1939
1940double
1941TraCIAPI::VehicleTypeScope::getMaxSpeedLat(const std::string& typeID) const {
1942 return getDouble(libsumo::VAR_MAXSPEED_LAT, typeID);
1943}
1944
1945std::string
1946TraCIAPI::VehicleTypeScope::getLateralAlignment(const std::string& typeID) const {
1947 return getString(libsumo::VAR_LATALIGNMENT, typeID);
1948}
1949
1950int
1951TraCIAPI::VehicleTypeScope::getPersonCapacity(const std::string& typeID) const {
1952 return getInt(libsumo::VAR_PERSON_CAPACITY, typeID);
1953}
1954
1955double
1956TraCIAPI::VehicleTypeScope::getWidth(const std::string& typeID) const {
1957 return getDouble(libsumo::VAR_WIDTH, typeID);
1958}
1959
1960double
1961TraCIAPI::VehicleTypeScope::getHeight(const std::string& typeID) const {
1962 return getDouble(libsumo::VAR_HEIGHT, typeID);
1963}
1964
1966TraCIAPI::VehicleTypeScope::getColor(const std::string& typeID) const {
1967 return getCol(libsumo::VAR_COLOR, typeID);
1968}
1969
1970
1971
1972void
1973TraCIAPI::VehicleTypeScope::setLength(const std::string& typeID, double length) const {
1974 tcpip::Storage content;
1976 content.writeDouble(length);
1977 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_LENGTH, typeID, &content);
1978 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1979}
1980
1981void
1982TraCIAPI::VehicleTypeScope::setMaxSpeed(const std::string& typeID, double speed) const {
1983 tcpip::Storage content;
1985 content.writeDouble(speed);
1986 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MAXSPEED, typeID, &content);
1987 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1988}
1989
1990void
1991TraCIAPI::VehicleTypeScope::setVehicleClass(const std::string& typeID, const std::string& clazz) const {
1992 tcpip::Storage content;
1994 content.writeString(clazz);
1995 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_VEHICLECLASS, typeID, &content);
1996 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
1997}
1998
1999void
2000TraCIAPI::VehicleTypeScope::setSpeedFactor(const std::string& typeID, double factor) const {
2001 tcpip::Storage content;
2003 content.writeDouble(factor);
2004 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SPEED_FACTOR, typeID, &content);
2005 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2006}
2007
2008void
2009TraCIAPI::VehicleTypeScope::setSpeedDeviation(const std::string& typeID, double deviation) const {
2010 tcpip::Storage content;
2012 content.writeDouble(deviation);
2013 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SPEED_DEVIATION, typeID, &content);
2014 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2015}
2016
2017
2018void
2019TraCIAPI::VehicleTypeScope::setEmissionClass(const std::string& typeID, const std::string& clazz) const {
2020 tcpip::Storage content;
2022 content.writeString(clazz);
2023 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_EMISSIONCLASS, typeID, &content);
2024 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2025}
2026
2027void
2028TraCIAPI::VehicleTypeScope::setWidth(const std::string& typeID, double width) const {
2029 tcpip::Storage content;
2031 content.writeDouble(width);
2032 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_WIDTH, typeID, &content);
2033 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2034}
2035
2036void
2037TraCIAPI::VehicleTypeScope::setHeight(const std::string& typeID, double height) const {
2038 tcpip::Storage content;
2040 content.writeDouble(height);
2041 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_HEIGHT, typeID, &content);
2042 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2043}
2044
2045void
2046TraCIAPI::VehicleTypeScope::setMinGap(const std::string& typeID, double minGap) const {
2047 tcpip::Storage content;
2049 content.writeDouble(minGap);
2050 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MINGAP, typeID, &content);
2051 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2052}
2053
2054
2055void
2056TraCIAPI::VehicleTypeScope::setMinGapLat(const std::string& typeID, double minGapLat) const {
2057 tcpip::Storage content;
2059 content.writeDouble(minGapLat);
2060 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MINGAP_LAT, typeID, &content);
2061 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2062}
2063
2064void
2065TraCIAPI::VehicleTypeScope::setMaxSpeedLat(const std::string& typeID, double speed) const {
2066 tcpip::Storage content;
2068 content.writeDouble(speed);
2069 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_MAXSPEED_LAT, typeID, &content);
2070 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2071}
2072
2073void
2074TraCIAPI::VehicleTypeScope::setLateralAlignment(const std::string& typeID, const std::string& latAlignment) const {
2075 tcpip::Storage content;
2077 content.writeString(latAlignment);
2078 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_LATALIGNMENT, typeID, &content);
2079 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2080}
2081
2082void
2083TraCIAPI::VehicleTypeScope::copy(const std::string& origTypeID, const std::string& newTypeID) const {
2084 tcpip::Storage content;
2086 content.writeString(newTypeID);
2087 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::COPY, origTypeID, &content);
2088 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2089}
2090
2091void
2092TraCIAPI::VehicleTypeScope::setShapeClass(const std::string& typeID, const std::string& clazz) const {
2093 tcpip::Storage content;
2095 content.writeString(clazz);
2096 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_SHAPECLASS, typeID, &content);
2097 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2098}
2099
2100void
2101TraCIAPI::VehicleTypeScope::setAccel(const std::string& typeID, double accel) const {
2102 tcpip::Storage content;
2104 content.writeDouble(accel);
2105 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_ACCEL, typeID, &content);
2106 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2107}
2108
2109void
2110TraCIAPI::VehicleTypeScope::setDecel(const std::string& typeID, double decel) const {
2111 tcpip::Storage content;
2113 content.writeDouble(decel);
2114 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_DECEL, typeID, &content);
2115 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2116}
2117
2118void
2119TraCIAPI::VehicleTypeScope::setEmergencyDecel(const std::string& typeID, double decel) const {
2120 tcpip::Storage content;
2122 content.writeDouble(decel);
2123 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_EMERGENCY_DECEL, typeID, &content);
2124 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2125}
2126
2127void
2128TraCIAPI::VehicleTypeScope::setApparentDecel(const std::string& typeID, double decel) const {
2129 tcpip::Storage content;
2131 content.writeDouble(decel);
2132 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_APPARENT_DECEL, typeID, &content);
2133 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2134}
2135
2136void
2137TraCIAPI::VehicleTypeScope::setImperfection(const std::string& typeID, double imperfection) const {
2138 tcpip::Storage content;
2140 content.writeDouble(imperfection);
2141 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_IMPERFECTION, typeID, &content);
2142 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2143}
2144
2145void
2146TraCIAPI::VehicleTypeScope::setTau(const std::string& typeID, double tau) const {
2147 tcpip::Storage content;
2149 content.writeDouble(tau);
2150 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_TAU, typeID, &content);
2151 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2152}
2153
2154void
2155TraCIAPI::VehicleTypeScope::setColor(const std::string& typeID, const libsumo::TraCIColor& c) const {
2156 tcpip::Storage content;
2158 content.writeUnsignedByte(c.r);
2159 content.writeUnsignedByte(c.g);
2160 content.writeUnsignedByte(c.b);
2161 content.writeUnsignedByte(c.a);
2162 myParent.createCommand(libsumo::CMD_SET_VEHICLETYPE_VARIABLE, libsumo::VAR_COLOR, typeID, &content);
2163 myParent.processSet(libsumo::CMD_SET_VEHICLETYPE_VARIABLE);
2164}
2165
2166
2167// ---------------------------------------------------------------------------
2168// TraCIAPI::VehicleScope-methods
2169// ---------------------------------------------------------------------------
2170double
2171TraCIAPI::VehicleScope::getSpeed(const std::string& vehicleID) const {
2172 return getDouble(libsumo::VAR_SPEED, vehicleID);
2173}
2174
2175double
2176TraCIAPI::VehicleScope::getLateralSpeed(const std::string& vehicleID) const {
2177 return getDouble(libsumo::VAR_SPEED_LAT, vehicleID);
2178}
2179
2180double
2181TraCIAPI::VehicleScope::getAcceleration(const std::string& vehicleID) const {
2182 return getDouble(libsumo::VAR_ACCELERATION, vehicleID);
2183}
2184
2185double
2186TraCIAPI::VehicleScope::getFollowSpeed(const std::string& vehicleID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) const {
2187 tcpip::Storage content;
2189 content.writeInt(5);
2191 content.writeDouble(speed);
2193 content.writeDouble(gap);
2195 content.writeDouble(leaderSpeed);
2197 content.writeDouble(leaderMaxDecel);
2199 content.writeString(leaderID);
2200 return getDouble(libsumo::VAR_FOLLOW_SPEED, vehicleID, &content);
2201}
2202
2203
2204double
2205TraCIAPI::VehicleScope::getSecureGap(const std::string& vehicleID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string& leaderID) const {
2206 tcpip::Storage content;
2208 content.writeInt(4);
2210 content.writeDouble(speed);
2212 content.writeDouble(leaderSpeed);
2214 content.writeDouble(leaderMaxDecel);
2216 content.writeString(leaderID);
2217 return getDouble(libsumo::VAR_SECURE_GAP, vehicleID, &content);
2218}
2219
2220double
2221TraCIAPI::VehicleScope::getStopSpeed(const std::string& vehicleID, double speed, double gap) const {
2222 tcpip::Storage content;
2224 content.writeInt(2);
2226 content.writeDouble(speed);
2228 content.writeDouble(gap);
2229 return getDouble(libsumo::VAR_STOP_SPEED, vehicleID, &content);
2230}
2231
2232
2233double
2234TraCIAPI::VehicleScope::getMaxSpeed(const std::string& vehicleID) const {
2235 return getDouble(libsumo::VAR_MAXSPEED, vehicleID);
2236}
2237
2239TraCIAPI::VehicleScope::getPosition(const std::string& vehicleID) const {
2240 return getPos(libsumo::VAR_POSITION, vehicleID);
2241}
2242
2244TraCIAPI::VehicleScope::getPosition3D(const std::string& vehicleID) const {
2245 return getPos3D(libsumo::VAR_POSITION3D, vehicleID);
2246}
2247
2248double
2249TraCIAPI::VehicleScope::getAngle(const std::string& vehicleID) const {
2250 return getDouble(libsumo::VAR_ANGLE, vehicleID);
2251}
2252
2253std::string
2254TraCIAPI::VehicleScope::getRoadID(const std::string& vehicleID) const {
2255 return getString(libsumo::VAR_ROAD_ID, vehicleID);
2256}
2257
2258std::string
2259TraCIAPI::VehicleScope::getLaneID(const std::string& vehicleID) const {
2260 return getString(libsumo::VAR_LANE_ID, vehicleID);
2261}
2262
2263int
2264TraCIAPI::VehicleScope::getLaneIndex(const std::string& vehicleID) const {
2265 return getInt(libsumo::VAR_LANE_INDEX, vehicleID);
2266}
2267
2268std::string
2269TraCIAPI::VehicleScope::getTypeID(const std::string& vehicleID) const {
2270 return getString(libsumo::VAR_TYPE, vehicleID);
2271}
2272
2273std::string
2274TraCIAPI::VehicleScope::getRouteID(const std::string& vehicleID) const {
2275 return getString(libsumo::VAR_ROUTE_ID, vehicleID);
2276}
2277
2278int
2279TraCIAPI::VehicleScope::getRouteIndex(const std::string& vehicleID) const {
2280 return getInt(libsumo::VAR_ROUTE_INDEX, vehicleID);
2281}
2282
2283
2284std::vector<std::string>
2285TraCIAPI::VehicleScope::getRoute(const std::string& vehicleID) const {
2286 return getStringVector(libsumo::VAR_EDGES, vehicleID);
2287}
2288
2290TraCIAPI::VehicleScope::getColor(const std::string& vehicleID) const {
2291 return getCol(libsumo::VAR_COLOR, vehicleID);
2292}
2293
2294double
2295TraCIAPI::VehicleScope::getLanePosition(const std::string& vehicleID) const {
2296 return getDouble(libsumo::VAR_LANEPOSITION, vehicleID);
2297}
2298
2299double
2300TraCIAPI::VehicleScope::getDistance(const std::string& vehicleID) const {
2301 return getDouble(libsumo::VAR_DISTANCE, vehicleID);
2302}
2303
2304int
2305TraCIAPI::VehicleScope::getSignals(const std::string& vehicleID) const {
2306 return getInt(libsumo::VAR_SIGNALS, vehicleID);
2307}
2308
2309double
2310TraCIAPI::VehicleScope::getLateralLanePosition(const std::string& vehicleID) const {
2311 return getDouble(libsumo::VAR_LANEPOSITION_LAT, vehicleID);
2312}
2313
2314double
2315TraCIAPI::VehicleScope::getCO2Emission(const std::string& vehicleID) const {
2316 return getDouble(libsumo::VAR_CO2EMISSION, vehicleID);
2317}
2318
2319double
2320TraCIAPI::VehicleScope::getCOEmission(const std::string& vehicleID) const {
2321 return getDouble(libsumo::VAR_COEMISSION, vehicleID);
2322}
2323
2324double
2325TraCIAPI::VehicleScope::getHCEmission(const std::string& vehicleID) const {
2326 return getDouble(libsumo::VAR_HCEMISSION, vehicleID);
2327}
2328
2329double
2330TraCIAPI::VehicleScope::getPMxEmission(const std::string& vehicleID) const {
2331 return getDouble(libsumo::VAR_PMXEMISSION, vehicleID);
2332}
2333
2334double
2335TraCIAPI::VehicleScope::getNOxEmission(const std::string& vehicleID) const {
2336 return getDouble(libsumo::VAR_NOXEMISSION, vehicleID);
2337}
2338
2339double
2340TraCIAPI::VehicleScope::getFuelConsumption(const std::string& vehicleID) const {
2341 return getDouble(libsumo::VAR_FUELCONSUMPTION, vehicleID);
2342}
2343
2344double
2345TraCIAPI::VehicleScope::getNoiseEmission(const std::string& vehicleID) const {
2346 return getDouble(libsumo::VAR_NOISEEMISSION, vehicleID);
2347}
2348
2349double
2350TraCIAPI::VehicleScope::getElectricityConsumption(const std::string& vehicleID) const {
2351 return getDouble(libsumo::VAR_ELECTRICITYCONSUMPTION, vehicleID);
2352}
2353
2354double
2355TraCIAPI::VehicleScope::getWaitingTime(const std::string& vehID) const {
2356 return getDouble(libsumo::VAR_WAITING_TIME, vehID);
2357}
2358
2359int
2360TraCIAPI::VehicleScope::getLaneChangeMode(const std::string& vehID) const {
2361 return getInt(libsumo::VAR_LANECHANGE_MODE, vehID);
2362}
2363
2364
2365int
2366TraCIAPI::VehicleScope::getSpeedMode(const std::string& vehID) const {
2367 return getInt(libsumo::VAR_SPEEDSETMODE, vehID);
2368}
2369
2370
2371double
2372TraCIAPI::VehicleScope::getSlope(const std::string& vehID) const {
2373 return getDouble(libsumo::VAR_SLOPE, vehID);
2374}
2375
2376
2377std::string
2378TraCIAPI::VehicleScope::getLine(const std::string& typeID) const {
2379 return getString(libsumo::VAR_LINE, typeID);
2380}
2381
2382std::vector<std::string>
2383TraCIAPI::VehicleScope::getVia(const std::string& vehicleID) const {
2384 return getStringVector(libsumo::VAR_VIA, vehicleID);
2385}
2386
2387std::string
2388TraCIAPI::VehicleScope::getEmissionClass(const std::string& vehicleID) const {
2389 return getString(libsumo::VAR_EMISSIONCLASS, vehicleID);
2390}
2391
2392std::string
2393TraCIAPI::VehicleScope::getShapeClass(const std::string& vehicleID) const {
2394 return getString(libsumo::VAR_SHAPECLASS, vehicleID);
2395}
2396
2397std::vector<libsumo::TraCINextTLSData>
2398TraCIAPI::VehicleScope::getNextTLS(const std::string& vehID) const {
2399 std::vector<libsumo::TraCINextTLSData> result;
2400 myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_NEXT_TLS, vehID);
2402 myParent.myInput.readInt(); // components
2403 // number of items
2404 myParent.myInput.readUnsignedByte();
2405 const int n = myParent.myInput.readInt();
2406 for (int i = 0; i < n; ++i) {
2408 myParent.myInput.readUnsignedByte();
2409 d.id = myParent.myInput.readString();
2410
2411 myParent.myInput.readUnsignedByte();
2412 d.tlIndex = myParent.myInput.readInt();
2413
2414 myParent.myInput.readUnsignedByte();
2415 d.dist = myParent.myInput.readDouble();
2416
2417 myParent.myInput.readUnsignedByte();
2418 d.state = (char)myParent.myInput.readByte();
2419
2420 result.push_back(d);
2421 }
2422 }
2423 return result;
2424}
2425
2426std::vector<libsumo::TraCIBestLanesData>
2427TraCIAPI::VehicleScope::getBestLanes(const std::string& vehicleID) const {
2428 std::vector<libsumo::TraCIBestLanesData> result;
2429 myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_BEST_LANES, vehicleID);
2431 myParent.myInput.readInt();
2432 myParent.myInput.readUnsignedByte();
2433
2434 const int n = myParent.myInput.readInt(); // number of following edge information
2435 for (int i = 0; i < n; ++i) {
2437 myParent.myInput.readUnsignedByte();
2438 info.laneID = myParent.myInput.readString();
2439
2440 myParent.myInput.readUnsignedByte();
2441 info.length = myParent.myInput.readDouble();
2442
2443 myParent.myInput.readUnsignedByte();
2444 info.occupation = myParent.myInput.readDouble();
2445
2446 myParent.myInput.readUnsignedByte();
2447 info.bestLaneOffset = myParent.myInput.readByte();
2448
2449 myParent.myInput.readUnsignedByte();
2450 info.allowsContinuation = (myParent.myInput.readUnsignedByte() == 1);
2451
2452 myParent.myInput.readUnsignedByte();
2453 const int m = myParent.myInput.readInt();
2454 for (int j = 0; j < m; ++j) {
2455 info.continuationLanes.push_back(myParent.myInput.readString());
2456 }
2457
2458 result.push_back(info);
2459 }
2460 }
2461 return result;
2462}
2463
2464
2465std::pair<std::string, double>
2466TraCIAPI::VehicleScope::getLeader(const std::string& vehicleID, double dist) const {
2467 tcpip::Storage content;
2469 content.writeDouble(dist);
2470 myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_LEADER, vehicleID, &content);
2472 myParent.myInput.readInt(); // components
2473 myParent.myInput.readUnsignedByte();
2474 const std::string leaderID = myParent.myInput.readString();
2475 myParent.myInput.readUnsignedByte();
2476 const double gap = myParent.myInput.readDouble();
2477 return std::make_pair(leaderID, gap);
2478 }
2479 return std::make_pair("", libsumo::INVALID_DOUBLE_VALUE);
2480}
2481
2482
2483std::pair<std::string, double>
2484TraCIAPI::VehicleScope::getFollower(const std::string& vehicleID, double dist) const {
2485 tcpip::Storage content;
2487 content.writeDouble(dist);
2488 myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::VAR_FOLLOWER, vehicleID, &content);
2490 myParent.myInput.readInt(); // components
2491 myParent.myInput.readUnsignedByte();
2492 const std::string leaderID = myParent.myInput.readString();
2493 myParent.myInput.readUnsignedByte();
2494 const double gap = myParent.myInput.readDouble();
2495 return std::make_pair(leaderID, gap);
2496 }
2497 return std::make_pair("", libsumo::INVALID_DOUBLE_VALUE);
2498}
2499
2500
2501std::pair<int, int>
2502TraCIAPI::VehicleScope::getLaneChangeState(const std::string& vehicleID, int direction) const {
2503 tcpip::Storage content;
2505 content.writeInt(direction);
2506 myParent.createCommand(libsumo::CMD_GET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
2508 myParent.myInput.readInt(); // components
2509 myParent.myInput.readUnsignedByte();
2510 const int stateWithoutTraCI = myParent.myInput.readInt();
2511 myParent.myInput.readUnsignedByte();
2512 const int state = myParent.myInput.readInt();
2513 return std::make_pair(stateWithoutTraCI, state);
2514 }
2516}
2517
2518
2519int
2520TraCIAPI::VehicleScope::getStopState(const std::string& vehicleID) const {
2521 return getInt(libsumo::VAR_STOPSTATE, vehicleID);
2522}
2523
2524int
2525TraCIAPI::VehicleScope::getRoutingMode(const std::string& vehicleID) const {
2526 return getInt(libsumo::VAR_ROUTING_MODE, vehicleID);
2527}
2528
2529double
2530TraCIAPI::VehicleScope::getStopDelay(const std::string& vehicleID) const {
2531 return getDouble(libsumo::VAR_STOP_DELAY, vehicleID);
2532}
2533
2534double
2535TraCIAPI::VehicleScope::getStopArrivalDelay(const std::string& vehicleID) const {
2536 return getDouble(libsumo::VAR_STOP_ARRIVALDELAY, vehicleID);
2537}
2538
2539
2540double
2541TraCIAPI::VehicleScope::getAccel(const std::string& vehicleID) const {
2542 return getDouble(libsumo::VAR_ACCEL, vehicleID);
2543}
2544
2545double
2546TraCIAPI::VehicleScope::getDecel(const std::string& vehicleID) const {
2547 return getDouble(libsumo::VAR_DECEL, vehicleID);
2548}
2549
2550double
2551TraCIAPI::VehicleScope::getTau(const std::string& vehicleID) const {
2552 return getDouble(libsumo::VAR_TAU, vehicleID);
2553}
2554
2555double
2556TraCIAPI::VehicleScope::getImperfection(const std::string& vehicleID) const {
2557 return getDouble(libsumo::VAR_IMPERFECTION, vehicleID);
2558}
2559
2560double
2561TraCIAPI::VehicleScope::getSpeedFactor(const std::string& vehicleID) const {
2562 return getDouble(libsumo::VAR_SPEED_FACTOR, vehicleID);
2563}
2564
2565double
2566TraCIAPI::VehicleScope::getSpeedDeviation(const std::string& vehicleID) const {
2567 return getDouble(libsumo::VAR_SPEED_DEVIATION, vehicleID);
2568}
2569
2570std::string
2571TraCIAPI::VehicleScope::getVehicleClass(const std::string& vehicleID) const {
2572 return getString(libsumo::VAR_VEHICLECLASS, vehicleID);
2573}
2574
2575double
2576TraCIAPI::VehicleScope::getMinGap(const std::string& vehicleID) const {
2577 return getDouble(libsumo::VAR_MINGAP, vehicleID);
2578}
2579
2580double
2581TraCIAPI::VehicleScope::getWidth(const std::string& vehicleID) const {
2582 return getDouble(libsumo::VAR_WIDTH, vehicleID);
2583}
2584
2585double
2586TraCIAPI::VehicleScope::getLength(const std::string& vehicleID) const {
2587 return getDouble(libsumo::VAR_LENGTH, vehicleID);
2588}
2589
2590double
2591TraCIAPI::VehicleScope::getHeight(const std::string& vehicleID) const {
2592 return getDouble(libsumo::VAR_HEIGHT, vehicleID);
2593}
2594
2595double
2596TraCIAPI::VehicleScope::getAccumulatedWaitingTime(const std::string& vehicleID) const {
2597 return getDouble(libsumo::VAR_ACCUMULATED_WAITING_TIME, vehicleID);
2598}
2599
2600double
2601TraCIAPI::VehicleScope::getAllowedSpeed(const std::string& vehicleID) const {
2602 return getDouble(libsumo::VAR_ALLOWED_SPEED, vehicleID);
2603}
2604
2605int
2606TraCIAPI::VehicleScope::getPersonNumber(const std::string& vehicleID) const {
2607 return getInt(libsumo::VAR_PERSON_NUMBER, vehicleID);
2608}
2609
2610int
2611TraCIAPI::VehicleScope::getPersonCapacity(const std::string& vehicleID) const {
2612 return getInt(libsumo::VAR_PERSON_CAPACITY, vehicleID);
2613}
2614
2615std::vector<std::string>
2616TraCIAPI::VehicleScope::getPersonIDList(const std::string& vehicleID) const {
2617 return getStringVector(libsumo::LAST_STEP_PERSON_ID_LIST, vehicleID);
2618}
2619
2620double
2621TraCIAPI::VehicleScope::getSpeedWithoutTraCI(const std::string& vehicleID) const {
2622 return getDouble(libsumo::VAR_SPEED_WITHOUT_TRACI, vehicleID);
2623}
2624
2625bool
2626TraCIAPI::VehicleScope::isRouteValid(const std::string& vehicleID) const {
2627 return getInt(libsumo::VAR_ROUTE_VALID, vehicleID) != 0;
2628}
2629
2630double
2631TraCIAPI::VehicleScope::getMaxSpeedLat(const std::string& vehicleID) const {
2632 return getDouble(libsumo::VAR_MAXSPEED_LAT, vehicleID);
2633}
2634
2635double
2636TraCIAPI::VehicleScope::getMinGapLat(const std::string& vehicleID) const {
2637 return getDouble(libsumo::VAR_MINGAP_LAT, vehicleID);
2638}
2639
2640std::string
2641TraCIAPI::VehicleScope::getLateralAlignment(const std::string& vehicleID) const {
2642 return getString(libsumo::VAR_LATALIGNMENT, vehicleID);
2643}
2644
2645void
2646TraCIAPI::VehicleScope::add(const std::string& vehicleID,
2647 const std::string& routeID,
2648 const std::string& typeID,
2649 std::string depart,
2650 const std::string& departLane,
2651 const std::string& departPos,
2652 const std::string& departSpeed,
2653 const std::string& arrivalLane,
2654 const std::string& arrivalPos,
2655 const std::string& arrivalSpeed,
2656 const std::string& fromTaz,
2657 const std::string& toTaz,
2658 const std::string& line,
2659 int personCapacity,
2660 int personNumber) const {
2661
2662 if (depart == "-1") {
2663 depart = toString(myParent.simulation.getCurrentTime() / 1000.0);
2664 }
2665 tcpip::Storage content;
2667 content.writeInt(14);
2669 content.writeString(routeID);
2671 content.writeString(typeID);
2673 content.writeString(depart);
2675 content.writeString(departLane);
2677 content.writeString(departPos);
2679 content.writeString(departSpeed);
2680
2682 content.writeString(arrivalLane);
2684 content.writeString(arrivalPos);
2686 content.writeString(arrivalSpeed);
2687
2689 content.writeString(fromTaz);
2691 content.writeString(toTaz);
2693 content.writeString(line);
2694
2696 content.writeInt(personCapacity);
2698 content.writeInt(personNumber);
2699
2700 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::ADD_FULL, vehicleID, &content);
2701 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2702}
2703
2704
2705void
2706TraCIAPI::VehicleScope::remove(const std::string& vehicleID, char reason) const {
2707 tcpip::Storage content;
2709 content.writeUnsignedByte(reason);
2710 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::REMOVE, vehicleID, &content);
2711 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2712
2713}
2714
2715
2716void
2717TraCIAPI::VehicleScope::changeTarget(const std::string& vehicleID, const std::string& edgeID) const {
2718 tcpip::Storage content;
2720 content.writeString(edgeID);
2721 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGETARGET, vehicleID, &content);
2722 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2723}
2724
2725
2726void
2727TraCIAPI::VehicleScope::changeLane(const std::string& vehicleID, int laneIndex, double duration) const {
2728 tcpip::Storage content;
2730 content.writeInt(2);
2732 content.writeByte(laneIndex);
2734 content.writeDouble(duration);
2735 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
2736 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2737}
2738
2739
2740void
2741TraCIAPI::VehicleScope::changeLaneRelative(const std::string& vehicleID, int laneChange, double duration) const {
2742 tcpip::Storage content;
2744 content.writeInt(3);
2746 content.writeByte(laneChange);
2748 content.writeDouble(duration);
2750 content.writeByte(1);
2751 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGELANE, vehicleID, &content);
2752 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2753}
2754
2755
2756void
2757TraCIAPI::VehicleScope::changeSublane(const std::string& vehicleID, double latDist) const {
2758 tcpip::Storage content;
2760 content.writeDouble(latDist);
2761 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_CHANGESUBLANE, vehicleID, &content);
2762 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2763}
2764
2765
2766void
2767TraCIAPI::VehicleScope::setRouteID(const std::string& vehicleID, const std::string& routeID) const {
2768 tcpip::Storage content;
2770 content.writeString(routeID);
2771 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTE_ID, vehicleID, &content);
2772 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2773}
2774
2775
2776void
2777TraCIAPI::VehicleScope::setRoute(const std::string& vehicleID, const std::vector<std::string>& edges) const {
2778 tcpip::Storage content;
2780 content.writeInt((int)edges.size());
2781 for (int i = 0; i < (int)edges.size(); ++i) {
2782 content.writeString(edges[i]);
2783 }
2784 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTE, vehicleID, &content);
2785 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2786}
2787
2788
2789void
2790TraCIAPI::VehicleScope::rerouteTraveltime(const std::string& vehicleID, bool currentTravelTimes) const {
2791 if (currentTravelTimes) {
2792 // updated edge weights with current network traveltimes (at most once per simulation step)
2793 std::vector<std::string> edges = myParent.edge.getIDList();
2794 for (std::vector<std::string>::iterator it = edges.begin(); it != edges.end(); ++it) {
2795 myParent.edge.adaptTraveltime(*it, myParent.edge.getTraveltime(*it));
2796 }
2797 }
2798
2799 tcpip::Storage content;
2801 content.writeInt(0);
2802 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_REROUTE_TRAVELTIME, vehicleID, &content);
2803 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2804}
2805
2806void
2807TraCIAPI::VehicleScope::moveTo(const std::string& vehicleID, const std::string& laneID, double position, int reason) const {
2808 tcpip::Storage content;
2810 content.writeInt(3);
2812 content.writeString(laneID);
2814 content.writeDouble(position);
2816 content.writeInt(reason);
2817 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MOVE_TO, vehicleID, &content);
2818 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2819}
2820
2821void
2822TraCIAPI::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 {
2823 tcpip::Storage content;
2825 content.writeInt(6);
2827 content.writeString(edgeID);
2829 content.writeInt(lane);
2831 content.writeDouble(x);
2833 content.writeDouble(y);
2835 content.writeDouble(angle);
2837 content.writeByte(keepRoute);
2838 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::MOVE_TO_XY, vehicleID, &content);
2839 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2840}
2841
2842
2843void
2844TraCIAPI::VehicleScope::slowDown(const std::string& vehicleID, double speed, double duration) const {
2845 tcpip::Storage content;
2847 content.writeInt(2);
2849 content.writeDouble(speed);
2851 content.writeDouble(duration);
2852 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_SLOWDOWN, vehicleID, &content);
2853 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2854}
2855
2856void
2857TraCIAPI::VehicleScope::openGap(const std::string& vehicleID, double newTau, double duration, double changeRate, double maxDecel) const {
2858 tcpip::Storage content;
2860 if (maxDecel > 0) {
2861 content.writeInt(4);
2862 } else {
2863 content.writeInt(3);
2864 }
2866 content.writeDouble(newTau);
2868 content.writeDouble(duration);
2870 content.writeDouble(changeRate);
2871 if (maxDecel > 0) {
2873 content.writeDouble(maxDecel);
2874 }
2875 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_OPENGAP, vehicleID, &content);
2876 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2877}
2878
2879void
2880TraCIAPI::VehicleScope::setSpeed(const std::string& vehicleID, double speed) const {
2881 tcpip::Storage content;
2883 content.writeDouble(speed);
2884 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEED, vehicleID, &content);
2885 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2886}
2887
2888void
2889TraCIAPI::VehicleScope::setAcceleration(const std::string& vehicleID, double accel, double duration) const {
2890 tcpip::Storage content;
2892 content.writeInt(2);
2894 content.writeDouble(accel);
2896 content.writeDouble(duration);
2897 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ACCELERATION, vehicleID, &content);
2898 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2899}
2900
2901void
2902TraCIAPI::VehicleScope::setPreviousSpeed(const std::string& vehicleID, double prevSpeed, double prevAcceleration) const {
2903 tcpip::Storage content;
2905 content.writeInt(2);
2907 content.writeDouble(prevSpeed);
2909 content.writeDouble(prevAcceleration);
2910 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_PREV_SPEED, vehicleID, &content);
2911 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2912}
2913
2914void
2915TraCIAPI::VehicleScope::setLaneChangeMode(const std::string& vehicleID, int mode) const {
2916 tcpip::Storage content;
2918 content.writeInt(mode);
2919 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_LANECHANGE_MODE, vehicleID, &content);
2920 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2921}
2922
2923void
2924TraCIAPI::VehicleScope::setSpeedMode(const std::string& vehicleID, int mode) const {
2925 tcpip::Storage content;
2927 content.writeInt(mode);
2928 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEEDSETMODE, vehicleID, &content);
2929 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2930}
2931
2932void
2933TraCIAPI::VehicleScope::setStop(const std::string vehicleID, const std::string edgeID, const double endPos, const int laneIndex,
2934 const double duration, const int flags, const double startPos, const double until) const {
2935 tcpip::Storage content;
2937 content.writeInt(7);
2939 content.writeString(edgeID);
2941 content.writeDouble(endPos);
2943 content.writeByte(laneIndex);
2945 content.writeDouble(duration);
2947 content.writeByte(flags);
2949 content.writeDouble(startPos);
2951 content.writeDouble(until);
2952 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::CMD_STOP, vehicleID, &content);
2953 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2954}
2955
2956void
2957TraCIAPI::VehicleScope::setType(const std::string& vehicleID, const std::string& typeID) const {
2958 tcpip::Storage content;
2960 content.writeString(typeID);
2961 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_TYPE, vehicleID, &content);
2962 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2963}
2964
2965void
2966TraCIAPI::VehicleScope::setSpeedFactor(const std::string& vehicleID, double factor) const {
2967 tcpip::Storage content;
2969 content.writeDouble(factor);
2970 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SPEED_FACTOR, vehicleID, &content);
2971 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2972}
2973
2974void
2975TraCIAPI::VehicleScope::setMinGap(const std::string& vehicleID, double minGap) const {
2976 tcpip::Storage content;
2978 content.writeDouble(minGap);
2979 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MINGAP, vehicleID, &content);
2980 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2981}
2982
2983void
2984TraCIAPI::VehicleScope::setMaxSpeed(const std::string& vehicleID, double speed) const {
2985 tcpip::Storage content;
2987 content.writeDouble(speed);
2988 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_MAXSPEED, vehicleID, &content);
2989 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
2990}
2991
2992void
2993TraCIAPI::VehicleScope::setColor(const std::string& vehicleID, const libsumo::TraCIColor& c) const {
2994 tcpip::Storage content;
2996 content.writeUnsignedByte(c.r);
2997 content.writeUnsignedByte(c.g);
2998 content.writeUnsignedByte(c.b);
2999 content.writeUnsignedByte(c.a);
3000 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_COLOR, vehicleID, &content);
3001 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
3002}
3003
3004void
3005TraCIAPI::VehicleScope::setLine(const std::string& vehicleID, const std::string& line) const {
3006 tcpip::Storage content;
3008 content.writeString(line);
3009 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_LINE, vehicleID, &content);
3010 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
3011}
3012
3013void
3014TraCIAPI::VehicleScope::setVia(const std::string& vehicleID, const std::vector<std::string>& via) const {
3015 tcpip::Storage content;
3017 content.writeInt((int)via.size());
3018 for (int i = 0; i < (int)via.size(); ++i) {
3019 content.writeString(via[i]);
3020 }
3021 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_VIA, vehicleID, &content);
3022 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
3023}
3024
3025void
3026TraCIAPI::VehicleScope::setSignals(const std::string& vehicleID, int signals) const {
3027 tcpip::Storage content;
3029 content.writeInt(signals);
3030 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SIGNALS, vehicleID, &content);
3031 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
3032}
3033
3034void
3035TraCIAPI::VehicleScope::setRoutingMode(const std::string& vehicleID, int routingMode) const {
3036 tcpip::Storage content;
3038 content.writeInt(routingMode);
3039 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_ROUTING_MODE, vehicleID, &content);
3040 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
3041}
3042
3043void
3044TraCIAPI::VehicleScope::setShapeClass(const std::string& vehicleID, const std::string& clazz) const {
3045 tcpip::Storage content;
3047 content.writeString(clazz);
3048 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_SHAPECLASS, vehicleID, &content);
3049 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
3050}
3051
3052
3053void
3054TraCIAPI::VehicleScope::setEmissionClass(const std::string& vehicleID, const std::string& clazz) const {
3055 tcpip::Storage content;
3057 content.writeString(clazz);
3058 myParent.createCommand(libsumo::CMD_SET_VEHICLE_VARIABLE, libsumo::VAR_EMISSIONCLASS, vehicleID, &content);
3059 myParent.processSet(libsumo::CMD_SET_VEHICLE_VARIABLE);
3060}
3061
3062void
3064 bool noOpposite, double downstreamDist, double upstreamDist) const {
3065 addSubscriptionFilterByteList(libsumo::FILTER_TYPE_LANES, lanes);
3066 if (noOpposite) {
3067 addSubscriptionFilterNoOpposite();
3068 }
3069 if (downstreamDist >= 0) {
3070 addSubscriptionFilterDownstreamDistance(downstreamDist);
3071 }
3072 if (upstreamDist >= 0) {
3073 addSubscriptionFilterUpstreamDistance(upstreamDist);
3074 }
3075}
3076
3077
3078void
3080 addSubscriptionFilterEmpty(libsumo::FILTER_TYPE_NOOPPOSITE);
3081}
3082
3083void
3085 addSubscriptionFilterFloat(libsumo::FILTER_TYPE_DOWNSTREAM_DIST, dist);
3086}
3087
3088void
3090 addSubscriptionFilterFloat(libsumo::FILTER_TYPE_UPSTREAM_DIST, dist);
3091}
3092
3093
3094void
3095TraCIAPI::VehicleScope::addSubscriptionFilterCFManeuver(double downstreamDist, double upstreamDist) const {
3096 addSubscriptionFilterLeadFollow(std::vector<int>({0}));
3097 if (downstreamDist >= 0) {
3098 addSubscriptionFilterDownstreamDistance(downstreamDist);
3099 }
3100 if (upstreamDist >= 0) {
3101 addSubscriptionFilterUpstreamDistance(upstreamDist);
3102 }
3103}
3104
3105void
3106TraCIAPI::VehicleScope::addSubscriptionFilterLCManeuver(int direction, bool noOpposite, double downstreamDist, double upstreamDist) const {
3107 if (abs(direction) != 1) {
3108 std::cerr << "Ignoring lane change subscription filter with non-neighboring lane offset direction " << direction << "\n";
3109 return;
3110 }
3111 addSubscriptionFilterLeadFollow(std::vector<int>({0, direction}));
3112 if (noOpposite) {
3113 addSubscriptionFilterNoOpposite();
3114 }
3115 if (downstreamDist >= 0) {
3116 addSubscriptionFilterDownstreamDistance(downstreamDist);
3117 }
3118 if (upstreamDist >= 0) {
3119 addSubscriptionFilterUpstreamDistance(upstreamDist);
3120 }
3121}
3122
3123void
3125 addSubscriptionFilterEmpty(libsumo::FILTER_TYPE_LEAD_FOLLOW);
3126 addSubscriptionFilterByteList(libsumo::FILTER_TYPE_LANES, lanes);
3127}
3128
3129void
3130TraCIAPI::VehicleScope::addSubscriptionFilterTurn(double downstreamDist, double foeDistToJunction) const {
3131 addSubscriptionFilterFloat(libsumo::FILTER_TYPE_TURN, foeDistToJunction);
3132 if (downstreamDist >= 0) {
3133 addSubscriptionFilterDownstreamDistance(downstreamDist);
3134 }
3135}
3136
3137
3138void
3139TraCIAPI::VehicleScope::addSubscriptionFilterVClass(const std::vector<std::string>& vClasses) const {
3140 addSubscriptionFilterStringList(libsumo::FILTER_TYPE_VCLASS, vClasses);
3141}
3142
3143
3144void
3145TraCIAPI::VehicleScope::addSubscriptionFilterVType(const std::vector<std::string>& vTypes) const {
3146 addSubscriptionFilterStringList(libsumo::FILTER_TYPE_VTYPE, vTypes);
3147}
3148
3149
3150void
3152 addSubscriptionFilterFloat(libsumo::FILTER_TYPE_FIELD_OF_VISION, angle);
3153}
3154
3155void
3156TraCIAPI::VehicleScope::addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist, double upstreamDist) const {
3157 addSubscriptionFilterFloat(libsumo::FILTER_TYPE_LATERAL_DIST, lateralDist);
3158 if (downstreamDist >= 0) {
3159 addSubscriptionFilterDownstreamDistance(downstreamDist);
3160 }
3161 if (upstreamDist >= 0) {
3162 addSubscriptionFilterUpstreamDistance(upstreamDist);
3163 }
3164}
3165
3166void
3168 myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType);
3169 myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
3170}
3171
3172void
3174 tcpip::Storage content;
3176 content.writeDouble(val);
3177 myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
3178 myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
3179}
3180
3181
3182void
3183TraCIAPI::VehicleScope::addSubscriptionFilterStringList(int filterType, const std::vector<std::string>& vals) const {
3184 tcpip::Storage content;
3186 content.writeStringList(vals);
3187 myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
3188 myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
3189}
3190
3191
3192void
3193TraCIAPI::VehicleScope::addSubscriptionFilterByteList(int filterType, const std::vector<int>& vals) const {
3194 tcpip::Storage content;
3195 content.writeUnsignedByte((int)vals.size());
3196 for (int i : vals) {
3197 content.writeByte(i);
3198 }
3199 myParent.createFilterCommand(libsumo::CMD_ADD_SUBSCRIPTION_FILTER, filterType, &content);
3200 myParent.processSet(libsumo::CMD_ADD_SUBSCRIPTION_FILTER);
3201}
3202
3203
3204// ---------------------------------------------------------------------------
3205// TraCIAPI::PersonScope-methods
3206// ---------------------------------------------------------------------------
3207double
3208TraCIAPI::PersonScope::getSpeed(const std::string& personID) const {
3209 return getDouble(libsumo::VAR_SPEED, personID);
3210}
3211
3213TraCIAPI::PersonScope::getPosition(const std::string& personID) const {
3214 return getPos(libsumo::VAR_POSITION, personID);
3215}
3216
3218TraCIAPI::PersonScope::getPosition3D(const std::string& personID) const {
3219 return getPos3D(libsumo::VAR_POSITION3D, personID);
3220}
3221
3222double
3223TraCIAPI::PersonScope::getAngle(const std::string& personID) const {
3224 return getDouble(libsumo::VAR_ANGLE, personID);
3225}
3226
3227double
3228TraCIAPI::PersonScope::getSlope(const std::string& personID) const {
3229 return getDouble(libsumo::VAR_SLOPE, personID);
3230}
3231
3232double
3233TraCIAPI::PersonScope::getLanePosition(const std::string& personID) const {
3234 return getDouble(libsumo::VAR_LANEPOSITION, personID);
3235}
3236
3238TraCIAPI::PersonScope::getColor(const std::string& personID) const {
3239 return getCol(libsumo::VAR_COLOR, personID);
3240}
3241
3242double
3243TraCIAPI::PersonScope::getLength(const std::string& personID) const {
3244 return getDouble(libsumo::VAR_LENGTH, personID);
3245}
3246
3247std::string
3248TraCIAPI::PersonScope::getRoadID(const std::string& personID) const {
3249 return getString(libsumo::VAR_ROAD_ID, personID);
3250}
3251
3252std::string
3253TraCIAPI::PersonScope::getLaneID(const std::string& personID) const {
3254 return getString(libsumo::VAR_LANE_ID, personID);
3255}
3256
3257std::string
3258TraCIAPI::PersonScope::getTypeID(const std::string& personID) const {
3259 return getString(libsumo::VAR_TYPE, personID);
3260}
3261
3262double
3263TraCIAPI::PersonScope::getSpeedFactor(const std::string& personID) const {
3264 return getDouble(libsumo::VAR_SPEED_FACTOR, personID);
3265}
3266
3267double
3268TraCIAPI::PersonScope::getWaitingTime(const std::string& personID) const {
3269 return getDouble(libsumo::VAR_WAITING_TIME, personID);
3270}
3271
3272std::string
3273TraCIAPI::PersonScope::getNextEdge(const std::string& personID) const {
3274 return getString(libsumo::VAR_NEXT_EDGE, personID);
3275}
3276
3277
3278std::string
3279TraCIAPI::PersonScope::getVehicle(const std::string& personID) const {
3280 return getString(libsumo::VAR_VEHICLE, personID);
3281}
3282
3283int
3284TraCIAPI::PersonScope::getRemainingStages(const std::string& personID) const {
3285 return getInt(libsumo::VAR_STAGES_REMAINING, personID);
3286}
3287
3289TraCIAPI::PersonScope::getStage(const std::string& personID, int nextStageIndex) const {
3290 tcpip::Storage content;
3292 content.writeInt(nextStageIndex);
3293 return getTraCIStage(libsumo::VAR_STAGE, personID, &content);
3294}
3295
3296std::vector<std::string>
3297TraCIAPI::PersonScope::getEdges(const std::string& personID, int nextStageIndex) const {
3298 tcpip::Storage content;
3300 content.writeInt(nextStageIndex);
3301 return getStringVector(libsumo::VAR_EDGES, personID, &content);
3302}
3303
3304void
3305TraCIAPI::PersonScope::removeStages(const std::string& personID) const {
3306 // remove all stages after the current and then abort the current stage
3307 while (getRemainingStages(personID) > 1) {
3308 removeStage(personID, 1);
3309 }
3310 removeStage(personID, 0);
3311}
3312
3313
3314void
3315TraCIAPI::PersonScope::rerouteTraveltime(const std::string& personID) const {
3316 tcpip::Storage content;
3318 content.writeInt(0);
3319 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::CMD_REROUTE_TRAVELTIME, personID, &content);
3320 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3321}
3322
3323
3324void
3325TraCIAPI::PersonScope::add(const std::string& personID, const std::string& edgeID, double pos, double depart, const std::string typeID) {
3326 tcpip::Storage content;
3328 content.writeInt(4);
3330 content.writeString(typeID);
3332 content.writeString(edgeID);
3334 content.writeDouble(depart);
3336 content.writeDouble(pos);
3337 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::ADD, personID, &content);
3338 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3339}
3340
3341void
3342TraCIAPI::PersonScope::appendStage(const std::string& personID, const libsumo::TraCIStage& stage) {
3343 tcpip::Storage content;
3345 content.writeInt(13);
3347 content.writeInt(stage.type);
3349 content.writeString(stage.vType);
3351 content.writeString(stage.line);
3353 content.writeString(stage.destStop);
3355 content.writeStringList(stage.edges);
3357 content.writeDouble(stage.travelTime);
3359 content.writeDouble(stage.cost);
3361 content.writeDouble(stage.length);
3363 content.writeString(stage.intended);
3365 content.writeDouble(stage.depart);
3367 content.writeDouble(stage.departPos);
3369 content.writeDouble(stage.arrivalPos);
3371 content.writeString(stage.description);
3372 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
3373 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3374}
3375
3376
3377void
3378TraCIAPI::PersonScope::appendWaitingStage(const std::string& personID, double duration, const std::string& description, const std::string& stopID) {
3379 tcpip::Storage content;
3381 content.writeInt(4);
3385 content.writeDouble(duration);
3387 content.writeString(description);
3389 content.writeString(stopID);
3390 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
3391 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3392}
3393
3394void
3395TraCIAPI::PersonScope::appendWalkingStage(const std::string& personID, const std::vector<std::string>& edges, double arrivalPos, double duration, double speed, const std::string& stopID) {
3396 tcpip::Storage content;
3398 content.writeInt(6);
3402 content.writeStringList(edges);
3404 content.writeDouble(arrivalPos);
3406 content.writeDouble(duration);
3408 content.writeDouble(speed);
3410 content.writeString(stopID);
3411 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
3412 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3413}
3414
3415void
3416TraCIAPI::PersonScope::appendDrivingStage(const std::string& personID, const std::string& toEdge, const std::string& lines, const std::string& stopID) {
3417 tcpip::Storage content;
3419 content.writeInt(4);
3423 content.writeString(toEdge);
3425 content.writeString(lines);
3427 content.writeString(stopID);
3428 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::APPEND_STAGE, personID, &content);
3429 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3430}
3431
3432void
3433TraCIAPI::PersonScope::removeStage(const std::string& personID, int nextStageIndex) const {
3434 tcpip::Storage content;
3436 content.writeInt(nextStageIndex);
3437 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::REMOVE_STAGE, personID, &content);
3438 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3439}
3440
3441void
3442TraCIAPI::PersonScope::moveTo(const std::string& personID, const std::string& edgeID, double position) const {
3443 tcpip::Storage content;
3445 content.writeInt(2);
3447 content.writeString(edgeID);
3449 content.writeDouble(position);
3450 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_MOVE_TO, personID, &content);
3451 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3452}
3453
3454void
3455TraCIAPI::PersonScope::moveToXY(const std::string& personID, const std::string& edgeID, const double x, const double y, double angle, const int keepRoute) const {
3456 tcpip::Storage content;
3458 content.writeInt(5);
3460 content.writeString(edgeID);
3462 content.writeDouble(x);
3464 content.writeDouble(y);
3466 content.writeDouble(angle);
3468 content.writeByte(keepRoute);
3469 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::MOVE_TO_XY, personID, &content);
3470 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3471}
3472
3473void
3474TraCIAPI::PersonScope::setSpeed(const std::string& personID, double speed) const {
3475 tcpip::Storage content;
3477 content.writeDouble(speed);
3478 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_SPEED, personID, &content);
3479 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3480}
3481
3482
3483void
3484TraCIAPI::PersonScope::setType(const std::string& personID, const std::string& typeID) const {
3485 tcpip::Storage content;
3487 content.writeString(typeID);
3488 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_TYPE, personID, &content);
3489 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3490}
3491
3492void
3493TraCIAPI::PersonScope::setSpeedFactor(const std::string& personID, double factor) const {
3494 tcpip::Storage content;
3496 content.writeDouble(factor);
3497 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_SPEED_FACTOR, personID, &content);
3498 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3499}
3500
3501void
3502TraCIAPI::PersonScope::setLength(const std::string& personID, double length) const {
3503 tcpip::Storage content;
3505 content.writeDouble(length);
3506 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_LENGTH, personID, &content);
3507 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3508}
3509
3510
3511void
3512TraCIAPI::PersonScope::setWidth(const std::string& personID, double width) const {
3513 tcpip::Storage content;
3515 content.writeDouble(width);
3516 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_WIDTH, personID, &content);
3517 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3518}
3519
3520void
3521TraCIAPI::PersonScope::setHeight(const std::string& personID, double height) const {
3522 tcpip::Storage content;
3524 content.writeDouble(height);
3525 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_HEIGHT, personID, &content);
3526 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3527}
3528
3529void
3530TraCIAPI::PersonScope::setMinGap(const std::string& personID, double minGap) const {
3531 tcpip::Storage content;
3533 content.writeDouble(minGap);
3534 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_MINGAP, personID, &content);
3535 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3536}
3537
3538
3539void
3540TraCIAPI::PersonScope::setColor(const std::string& personID, const libsumo::TraCIColor& c) const {
3541 tcpip::Storage content;
3543 content.writeUnsignedByte(c.r);
3544 content.writeUnsignedByte(c.g);
3545 content.writeUnsignedByte(c.b);
3546 content.writeUnsignedByte(c.a);
3547 myParent.createCommand(libsumo::CMD_SET_PERSON_VARIABLE, libsumo::VAR_COLOR, personID, &content);
3548 myParent.processSet(libsumo::CMD_SET_PERSON_VARIABLE);
3549}
3550
3551
3552// ---------------------------------------------------------------------------
3553// TraCIAPI::TraCIScopeWrapper-methods
3554// ---------------------------------------------------------------------------
3555
3556int
3557TraCIAPI::TraCIScopeWrapper::getUnsignedByte(int var, const std::string& id, tcpip::Storage* add) const {
3558 myParent.createCommand(myCmdGetID, var, id, add);
3559 if (myParent.processGet(myCmdGetID, libsumo::TYPE_UBYTE)) {
3560 return myParent.myInput.readUnsignedByte();
3561 }
3563}
3564
3565
3566int
3567TraCIAPI::TraCIScopeWrapper::getByte(int var, const std::string& id, tcpip::Storage* add) const {
3568 myParent.createCommand(myCmdGetID, var, id, add);
3569 if (myParent.processGet(myCmdGetID, libsumo::TYPE_BYTE)) {
3570 return myParent.myInput.readByte();
3571 }
3573}
3574
3575
3576
3577int
3578TraCIAPI::TraCIScopeWrapper::getInt(int var, const std::string& id, tcpip::Storage* add) const {
3579 myParent.createCommand(myCmdGetID, var, id, add);
3580 if (myParent.processGet(myCmdGetID, libsumo::TYPE_INTEGER)) {
3581 return myParent.myInput.readInt();
3582 }
3584}
3585
3586
3587double
3588TraCIAPI::TraCIScopeWrapper::getDouble(int var, const std::string& id, tcpip::Storage* add) const {
3589 myParent.createCommand(myCmdGetID, var, id, add);
3590 if (myParent.processGet(myCmdGetID, libsumo::TYPE_DOUBLE)) {
3591 return myParent.myInput.readDouble();
3592 }
3594}
3595
3596
3598TraCIAPI::TraCIScopeWrapper::getPolygon(int var, const std::string& id, tcpip::Storage* add) const {
3600 myParent.createCommand(myCmdGetID, var, id, add);
3601 if (myParent.processGet(myCmdGetID, libsumo::TYPE_POLYGON)) {
3602 int size = myParent.myInput.readUnsignedByte();
3603 if (size == 0) {
3604 size = myParent.myInput.readInt();
3605 }
3606 for (int i = 0; i < size; ++i) {
3608 p.x = myParent.myInput.readDouble();
3609 p.y = myParent.myInput.readDouble();
3610 p.z = 0.;
3611 ret.value.push_back(p);
3612 }
3613 }
3614 return ret;
3615}
3616
3617
3619TraCIAPI::TraCIScopeWrapper::getPos(int var, const std::string& id, tcpip::Storage* add) const {
3621 myParent.createCommand(myCmdGetID, var, id, add);
3622 if (myParent.processGet(myCmdGetID, libsumo::POSITION_2D)) {
3623 p.x = myParent.myInput.readDouble();
3624 p.y = myParent.myInput.readDouble();
3625 p.z = 0;
3626 }
3627 return p;
3628}
3629
3630
3632TraCIAPI::TraCIScopeWrapper::getPos3D(int var, const std::string& id, tcpip::Storage* add) const {
3634 myParent.createCommand(myCmdGetID, var, id, add);
3635 if (myParent.processGet(myCmdGetID, libsumo::POSITION_3D)) {
3636 p.x = myParent.myInput.readDouble();
3637 p.y = myParent.myInput.readDouble();
3638 p.z = myParent.myInput.readDouble();
3639 }
3640 return p;
3641}
3642
3643
3644std::string
3645TraCIAPI::TraCIScopeWrapper::getString(int var, const std::string& id, tcpip::Storage* add) const {
3646 myParent.createCommand(myCmdGetID, var, id, add);
3647 if (myParent.processGet(myCmdGetID, libsumo::TYPE_STRING)) {
3648 return myParent.myInput.readString();
3649 }
3650 return "";
3651}
3652
3653
3654std::vector<std::string>
3655TraCIAPI::TraCIScopeWrapper::getStringVector(int var, const std::string& id, tcpip::Storage* add) const {
3656 std::vector<std::string> r;
3657 myParent.createCommand(myCmdGetID, var, id, add);
3658 if (myParent.processGet(myCmdGetID, libsumo::TYPE_STRINGLIST)) {
3659 const int size = myParent.myInput.readInt();
3660 for (int i = 0; i < size; ++i) {
3661 r.push_back(myParent.myInput.readString());
3662 }
3663 }
3664 return r;
3665}
3666
3667
3668std::vector<double>
3669TraCIAPI::TraCIScopeWrapper::getDoubleVector(int var, const std::string& id, tcpip::Storage* add) const {
3670 std::vector<double> r;
3671 myParent.createCommand(myCmdGetID, var, id, add);
3672 if (myParent.processGet(myCmdGetID, libsumo::TYPE_DOUBLELIST)) {
3673 const int size = myParent.myInput.readInt();
3674 for (int i = 0; i < size; ++i) {
3675 r.push_back(myParent.myInput.readDouble());
3676 }
3677 }
3678 return r;
3679}
3680
3681
3683TraCIAPI::TraCIScopeWrapper::getCol(int var, const std::string& id, tcpip::Storage* add) const {
3685 myParent.createCommand(myCmdGetID, var, id, add);
3686 if (myParent.processGet(myCmdGetID, libsumo::TYPE_COLOR)) {
3687 c.r = (unsigned char)myParent.myInput.readUnsignedByte();
3688 c.g = (unsigned char)myParent.myInput.readUnsignedByte();
3689 c.b = (unsigned char)myParent.myInput.readUnsignedByte();
3690 c.a = (unsigned char)myParent.myInput.readUnsignedByte();
3691 }
3692 return c;
3693}
3694
3695
3697TraCIAPI::TraCIScopeWrapper::getTraCIStage(int var, const std::string& id, tcpip::Storage* add) const {
3699 myParent.createCommand(myCmdGetID, var, id, add);
3700 if (myParent.processGet(myCmdGetID, libsumo::TYPE_COMPOUND)) {
3701 myParent.myInput.readInt(); // components
3702 myParent.myInput.readUnsignedByte();
3703 s.type = myParent.myInput.readInt();
3704
3705 myParent.myInput.readUnsignedByte();
3706 s.vType = myParent.myInput.readString();
3707
3708 myParent.myInput.readUnsignedByte();
3709 s.line = myParent.myInput.readString();
3710
3711 myParent.myInput.readUnsignedByte();
3712 s.destStop = myParent.myInput.readString();
3713
3714 myParent.myInput.readUnsignedByte();
3715 s.edges = myParent.myInput.readStringList();
3716
3717 myParent.myInput.readUnsignedByte();
3718 s.travelTime = myParent.myInput.readDouble();
3719
3720 myParent.myInput.readUnsignedByte();
3721 s.cost = myParent.myInput.readDouble();
3722
3723 myParent.myInput.readUnsignedByte();
3724 s.length = myParent.myInput.readDouble();
3725
3726 myParent.myInput.readUnsignedByte();
3727 s.intended = myParent.myInput.readString();
3728
3729 myParent.myInput.readUnsignedByte();
3730 s.depart = myParent.myInput.readDouble();
3731
3732 myParent.myInput.readUnsignedByte();
3733 s.departPos = myParent.myInput.readDouble();
3734
3735 myParent.myInput.readUnsignedByte();
3736 s.arrivalPos = myParent.myInput.readDouble();
3737
3738 myParent.myInput.readUnsignedByte();
3739 s.description = myParent.myInput.readString();
3740 }
3741 return s;
3742}
3743
3744
3745std::vector<std::string>
3747 return getStringVector(libsumo::TRACI_ID_LIST, "");
3748}
3749
3750
3751int
3753 return getInt(libsumo::ID_COUNT, "");
3754}
3755
3756
3757std::string
3758TraCIAPI::TraCIScopeWrapper::getParameter(const std::string& objectID, const std::string& key) const {
3759 tcpip::Storage content;
3761 content.writeString(key);
3762 return getString(libsumo::VAR_PARAMETER, objectID, &content);
3763}
3764
3765
3766std::pair<std::string, std::string>
3767TraCIAPI::TraCIScopeWrapper::getParameterWithKey(const std::string& objectID, const std::string& key) const {
3768 tcpip::Storage content;
3770 content.writeString(key);
3771
3772 myParent.createCommand(myCmdGetID, libsumo::VAR_PARAMETER_WITH_KEY, objectID, &content);
3773 if (myParent.processGet(myCmdGetID, libsumo::TYPE_COMPOUND)) {
3774 myParent.myInput.readInt(); // number of components
3775 myParent.myInput.readUnsignedByte();
3776 const std::string returnedKey = myParent.myInput.readString();
3777 myParent.myInput.readUnsignedByte();
3778 const std::string value = myParent.myInput.readString();
3779 return std::make_pair(returnedKey, value);
3780 }
3781 return std::make_pair(key, "");
3782}
3783
3784
3785void
3786TraCIAPI::TraCIScopeWrapper::setParameter(const std::string& objectID, const std::string& key, const std::string& value) const {
3787 tcpip::Storage content;
3789 content.writeInt(2);
3791 content.writeString(key);
3793 content.writeString(value);
3794 myParent.createCommand(myCmdSetID, libsumo::VAR_PARAMETER, objectID, &content);
3795 myParent.processSet(myCmdSetID);
3796}
3797
3798
3799void
3800TraCIAPI::TraCIScopeWrapper::setInt(int var, const std::string& id, int value) const {
3801 tcpip::Storage content;
3803 content.writeInt(value);
3804 myParent.createCommand(myCmdSetID, var, id, &content);
3805 myParent.processSet(myCmdSetID);
3806}
3807
3808
3809void
3810TraCIAPI::TraCIScopeWrapper::setDouble(int var, const std::string& id, double value) const {
3811 tcpip::Storage content;
3813 content.writeDouble(value);
3814 myParent.createCommand(myCmdSetID, var, id, &content);
3815 myParent.processSet(myCmdSetID);
3816}
3817
3818
3819void
3820TraCIAPI::TraCIScopeWrapper::setString(int var, const std::string& id, const std::string& value) const {
3821 tcpip::Storage content;
3823 content.writeString(value);
3824 myParent.createCommand(myCmdSetID, var, id, &content);
3825 myParent.processSet(myCmdSetID);
3826}
3827
3828
3829void
3830TraCIAPI::TraCIScopeWrapper::setStringVector(int var, const std::string& id, const std::vector<std::string>& value) const {
3831 tcpip::Storage content;
3833 content.writeInt((int)value.size());
3834 for (const std::string& s : value) {
3835 content.writeString(s);
3836 }
3837 myParent.createCommand(myCmdSetID, var, id, &content);
3838 myParent.processSet(myCmdSetID);
3839}
3840
3841
3842void
3843TraCIAPI::TraCIScopeWrapper::subscribe(const std::string& objID, const std::vector<int>& vars, double beginTime, double endTime) const {
3844 myParent.send_commandSubscribeObjectVariable(mySubscribeID, objID, beginTime, endTime, vars);
3845 tcpip::Storage inMsg;
3846 myParent.check_resultState(inMsg, mySubscribeID);
3847 if (vars.size() > 0) {
3848 myParent.check_commandGetResult(inMsg, mySubscribeID);
3849 myParent.readVariableSubscription(mySubscribeID + 0x10, inMsg);
3850 }
3851}
3852
3853
3854void
3855TraCIAPI::TraCIScopeWrapper::subscribeContext(const std::string& objID, int domain, double range, const std::vector<int>& vars, double beginTime, double endTime) const {
3856 myParent.send_commandSubscribeObjectContext(myContextSubscribeID, objID, beginTime, endTime, domain, range, vars);
3857 tcpip::Storage inMsg;
3858 myParent.check_resultState(inMsg, myContextSubscribeID);
3859 myParent.check_commandGetResult(inMsg, myContextSubscribeID);
3860 myParent.readContextSubscription(myContextSubscribeID + 0x60, inMsg);
3861}
3862
3863
3866 return mySubscriptionResults;
3867}
3868
3869
3872 if (mySubscriptionResults.find(objID) != mySubscriptionResults.end()) {
3873 return mySubscriptionResults.find(objID)->second;
3874 } else {
3875 return libsumo::TraCIResults();
3876 }
3877}
3878
3879
3882 return myContextSubscriptionResults;
3883}
3884
3885
3888 if (myContextSubscriptionResults.find(objID) != myContextSubscriptionResults.end()) {
3889 return myContextSubscriptionResults.find(objID)->second;
3890 } else {
3892 }
3893}
3894
3895
3896void
3898 mySubscriptionResults.clear();
3899 myContextSubscriptionResults.clear();
3900}
3901
3902
3905 return mySubscriptionResults;
3906}
3907
3908
3911 return myContextSubscriptionResults[objID];
3912}
3913
3914
3915/****************************************************************************/
double getElectricityConsumption(const std::string &edgeID) const
Definition: TraCIAPI.cpp:557
double getLastStepHaltingNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:587
double getHCEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:532
void adaptTraveltime(const std::string &edgeID, double time, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
Definition: TraCIAPI.cpp:610
double getLastStepOccupancy(const std::string &edgeID) const
Definition: TraCIAPI.cpp:567
double getLastStepLength(const std::string &edgeID) const
Definition: TraCIAPI.cpp:572
std::vector< std::string > getLastStepVehicleIDs(const std::string &edgeID) const
Definition: TraCIAPI.cpp:592
double getNOxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:542
void setMaxSpeed(const std::string &edgeID, double speed) const
Definition: TraCIAPI.cpp:649
double getCO2Emission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:521
double getCOEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:527
int getLaneNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:598
void setEffort(const std::string &edgeID, double effort, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
Definition: TraCIAPI.cpp:630
double getNoiseEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:552
double getFuelConsumption(const std::string &edgeID) const
Definition: TraCIAPI.cpp:547
double getTraveltime(const std::string &edgeID) const
Definition: TraCIAPI.cpp:577
int getLastStepVehicleNumber(const std::string &edgeID) const
Definition: TraCIAPI.cpp:582
std::string getStreetName(const std::string &id) const
Definition: TraCIAPI.cpp:604
double getLastStepMeanSpeed(const std::string &edgeID) const
Definition: TraCIAPI.cpp:562
double getPMxEmission(const std::string &edgeID) const
Definition: TraCIAPI.cpp:537
double getAdaptedTraveltime(const std::string &edgeID, double time) const
Definition: TraCIAPI.cpp:505
double getEffort(const std::string &edgeID, double time) const
Definition: TraCIAPI.cpp:513
void setOffset(const std::string &viewID, double x, double y) const
Definition: TraCIAPI.cpp:684
libsumo::TraCIPositionVector getBoundary(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:673
std::string getSchema(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:668
void setBoundary(const std::string &viewID, double xmin, double ymin, double xmax, double ymax) const
Definition: TraCIAPI.cpp:699
void setZoom(const std::string &viewID, double zoom) const
Definition: TraCIAPI.cpp:679
void trackVehicle(const std::string &viewID, const std::string &vehID) const
Definition: TraCIAPI.cpp:727
void setSchema(const std::string &viewID, const std::string &schemeName) const
Definition: TraCIAPI.cpp:694
libsumo::TraCIPosition getOffset(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:663
double getZoom(const std::string &viewID=DEFAULT_VIEW) const
Definition: TraCIAPI.cpp:658
void screenshot(const std::string &viewID, const std::string &filename, const int width=-1, const int height=-1) const
Definition: TraCIAPI.cpp:712
std::vector< libsumo::TraCIVehicleData > getVehicleData(const std::string &loopID) const
Definition: TraCIAPI.cpp:777
double getPosition(const std::string &loopID) const
Definition: TraCIAPI.cpp:736
double getLastStepMeanSpeed(const std::string &loopID) const
Definition: TraCIAPI.cpp:751
double getTimeSinceDetection(const std::string &loopID) const
Definition: TraCIAPI.cpp:771
double getLastStepMeanLength(const std::string &loopID) const
Definition: TraCIAPI.cpp:766
std::vector< std::string > getLastStepVehicleIDs(const std::string &loopID) const
Definition: TraCIAPI.cpp:756
double getLastStepOccupancy(const std::string &loopID) const
Definition: TraCIAPI.cpp:761
int getLastStepVehicleNumber(const std::string &loopID) const
Definition: TraCIAPI.cpp:746
std::string getLaneID(const std::string &loopID) const
Definition: TraCIAPI.cpp:741
libsumo::TraCIPosition getPosition(const std::string &junctionID) const
Definition: TraCIAPI.cpp:814
libsumo::TraCIPositionVector getShape(const std::string &junctionID) const
Definition: TraCIAPI.cpp:819
int getLastStepVehicleNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:978
double getPMxEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:933
int getLastStepHaltingNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:983
std::string getEdgeID(const std::string &laneID) const
Definition: TraCIAPI.cpp:913
void setDisallowed(const std::string &laneID, const std::vector< std::string > &disallowedClasses) const
Definition: TraCIAPI.cpp:1021
libsumo::TraCIPositionVector getShape(const std::string &laneID) const
Definition: TraCIAPI.cpp:908
double getLastStepLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:968
void setLength(const std::string &laneID, double length) const
Definition: TraCIAPI.cpp:1031
double getLength(const std::string &laneID) const
Definition: TraCIAPI.cpp:828
int getLinkNumber(const std::string &laneID) const
Definition: TraCIAPI.cpp:853
double getTraveltime(const std::string &laneID) const
Definition: TraCIAPI.cpp:973
double getCOEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:923
void setMaxSpeed(const std::string &laneID, double speed) const
Definition: TraCIAPI.cpp:1026
std::vector< std::string > getInternalFoes(const std::string &laneID) const
Definition: TraCIAPI.cpp:1010
void setAllowed(const std::string &laneID, const std::vector< std::string > &allowedClasses) const
Definition: TraCIAPI.cpp:1016
std::vector< std::string > getDisallowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:848
double getNoiseEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:948
std::vector< std::string > getAllowed(const std::string &laneID) const
Definition: TraCIAPI.cpp:843
double getFuelConsumption(const std::string &laneID) const
Definition: TraCIAPI.cpp:943
double getWidth(const std::string &laneID) const
Definition: TraCIAPI.cpp:838
double getCO2Emission(const std::string &laneID) const
Definition: TraCIAPI.cpp:918
double getHCEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:928
std::vector< libsumo::TraCIConnection > getLinks(const std::string &laneID) const
Definition: TraCIAPI.cpp:858
double getMaxSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:833
std::vector< std::string > getLastStepVehicleIDs(const std::string &laneID) const
Definition: TraCIAPI.cpp:988
double getElectricityConsumption(const std::string &laneID) const
Definition: TraCIAPI.cpp:953
std::vector< std::string > getFoes(const std::string &laneID, const std::string &toLaneID) const
Definition: TraCIAPI.cpp:994
double getLastStepMeanSpeed(const std::string &laneID) const
Definition: TraCIAPI.cpp:958
double getNOxEmission(const std::string &laneID) const
Definition: TraCIAPI.cpp:938
double getLastStepOccupancy(const std::string &laneID) const
Definition: TraCIAPI.cpp:963
std::vector< std::string > getLastStepVehicleIDs(const std::string &detID) const
Definition: TraCIAPI.cpp:1055
int getLastStepVehicleNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:1045
std::vector< std::string > getExitLanes(const std::string &detID) const
Definition: TraCIAPI.cpp:1070
std::vector< double > getExitPositions(const std::string &detID) const
Definition: TraCIAPI.cpp:1080
double getLastStepMeanSpeed(const std::string &detID) const
Definition: TraCIAPI.cpp:1050
int getLastStepHaltingNumber(const std::string &detID) const
Definition: TraCIAPI.cpp:1060
std::vector< std::string > getEntryLanes(const std::string &detID) const
Definition: TraCIAPI.cpp:1065
std::vector< double > getEntryPositions(const std::string &detID) const
Definition: TraCIAPI.cpp:1075
libsumo::TraCIColor getColor(const std::string &poiID) const
Definition: TraCIAPI.cpp:1098
void add(const std::string &poiID, double x, double y, const libsumo::TraCIColor &c, const std::string &type, int layer, const std::string &imgFile, double width, double height, double angle) const
Definition: TraCIAPI.cpp:1178
std::string getImageFile(const std::string &poiID) const
Definition: TraCIAPI.cpp:1118
void setWidth(const std::string &poiID, double width) const
Definition: TraCIAPI.cpp:1154
libsumo::TraCIPosition getPosition(const std::string &poiID) const
Definition: TraCIAPI.cpp:1093
void setImageFile(const std::string &poiID, const std::string &imageFile) const
Definition: TraCIAPI.cpp:1172
void setHeight(const std::string &poiID, double height) const
Definition: TraCIAPI.cpp:1160
void setAngle(const std::string &poiID, double angle) const
Definition: TraCIAPI.cpp:1166
double getHeight(const std::string &poiID) const
Definition: TraCIAPI.cpp:1108
double getAngle(const std::string &poiID) const
Definition: TraCIAPI.cpp:1113
void remove(const std::string &poiID, int layer=0) const
Definition: TraCIAPI.cpp:1207
void setColor(const std::string &poiID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:1141
void setPosition(const std::string &poiID, double x, double y) const
Definition: TraCIAPI.cpp:1130
double getWidth(const std::string &poiID) const
Definition: TraCIAPI.cpp:1103
void setType(const std::string &poiID, const std::string &setType) const
Definition: TraCIAPI.cpp:1124
std::string getType(const std::string &poiID) const
Definition: TraCIAPI.cpp:1088
std::string getNextEdge(const std::string &personID) const
Definition: TraCIAPI.cpp:3273
void setLength(const std::string &personID, double length) const
Definition: TraCIAPI.cpp:3502
libsumo::TraCIColor getColor(const std::string &personID) const
Definition: TraCIAPI.cpp:3238
double getSlope(const std::string &personID) const
Definition: TraCIAPI.cpp:3228
int getRemainingStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3284
double getWaitingTime(const std::string &personID) const
Definition: TraCIAPI.cpp:3268
void setSpeedFactor(const std::string &personID, double factor) const
Definition: TraCIAPI.cpp:3493
libsumo::TraCIStage getStage(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3289
void removeStage(const std::string &personID, int nextStageIndex) const
Definition: TraCIAPI.cpp:3433
void add(const std::string &personID, const std::string &edgeID, double pos, double depart=libsumo::DEPARTFLAG_NOW, const std::string typeID="DEFAULT_PEDTYPE")
Definition: TraCIAPI.cpp:3325
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:3395
void setSpeed(const std::string &personID, double speed) const
Definition: TraCIAPI.cpp:3474
double getLength(const std::string &personID) const
Definition: TraCIAPI.cpp:3243
void moveToXY(const std::string &personID, const std::string &edgeID, const double x, const double y, double angle, const int keepRoute) const
Definition: TraCIAPI.cpp:3455
void setHeight(const std::string &personID, double height) const
Definition: TraCIAPI.cpp:3521
void setType(const std::string &personID, const std::string &typeID) const
Definition: TraCIAPI.cpp:3484
void setMinGap(const std::string &personID, double minGap) const
Definition: TraCIAPI.cpp:3530
void moveTo(const std::string &personID, const std::string &edgeID, double position) const
Definition: TraCIAPI.cpp:3442
libsumo::TraCIPosition getPosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3213
double getSpeedFactor(const std::string &personID) const
Definition: TraCIAPI.cpp:3263
void removeStages(const std::string &personID) const
Definition: TraCIAPI.cpp:3305
void setColor(const std::string &personID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:3540
std::string getRoadID(const std::string &personID) const
Definition: TraCIAPI.cpp:3248
double getSpeed(const std::string &personID) const
Definition: TraCIAPI.cpp:3208
std::string getVehicle(const std::string &personID) const
Definition: TraCIAPI.cpp:3279
void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
Definition: TraCIAPI.cpp:3416
std::string getTypeID(const std::string &personID) const
Definition: TraCIAPI.cpp:3258
void appendStage(const std::string &personID, const libsumo::TraCIStage &stage)
Definition: TraCIAPI.cpp:3342
double getAngle(const std::string &personID) const
Definition: TraCIAPI.cpp:3223
std::string getLaneID(const std::string &personID) const
Definition: TraCIAPI.cpp:3253
libsumo::TraCIPosition getPosition3D(const std::string &personID) const
Definition: TraCIAPI.cpp:3218
std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0) const
Definition: TraCIAPI.cpp:3297
void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
Definition: TraCIAPI.cpp:3378
double getLanePosition(const std::string &personID) const
Definition: TraCIAPI.cpp:3233
void setWidth(const std::string &personID, double width) const
Definition: TraCIAPI.cpp:3512
void rerouteTraveltime(const std::string &personID) const
Definition: TraCIAPI.cpp:3315
libsumo::TraCIColor getColor(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1240
void setType(const std::string &polygonID, const std::string &setType) const
Definition: TraCIAPI.cpp:1254
bool getFilled(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1225
void add(const std::string &polygonID, const libsumo::TraCIPositionVector &shape, const libsumo::TraCIColor &c, bool fill, const std::string &type, int layer) const
Definition: TraCIAPI.cpp:1295
libsumo::TraCIPositionVector getShape(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1235
std::string getType(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1230
void remove(const std::string &polygonID, int layer=0) const
Definition: TraCIAPI.cpp:1322
double getLineWidth(const std::string &polygonID) const
Definition: TraCIAPI.cpp:1220
void setColor(const std::string &polygonID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:1283
void setLineWidth(const std::string &polygonID, const double lineWidth) const
Definition: TraCIAPI.cpp:1245
void setShape(const std::string &polygonID, const libsumo::TraCIPositionVector &shape) const
Definition: TraCIAPI.cpp:1264
std::vector< std::string > getEdges(const std::string &routeID) const
Definition: TraCIAPI.cpp:1335
void add(const std::string &routeID, const std::vector< std::string > &edges) const
Definition: TraCIAPI.cpp:1341
int getDepartedNumber() const
Definition: TraCIAPI.cpp:1374
double getDistance2D(double x1, double y1, double x2, double y2, bool isGeo=false, bool isDriving=false)
Definition: TraCIAPI.cpp:1555
libsumo::TraCIPosition convert2D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1466
std::vector< std::string > getStartingTeleportIDList() const
Definition: TraCIAPI.cpp:1399
int getStartingTeleportNumber() const
Definition: TraCIAPI.cpp:1394
double getTime() const
Definition: TraCIAPI.cpp:1359
int getEndingTeleportNumber() const
Definition: TraCIAPI.cpp:1404
int getBusStopWaiting(const std::string &stopID) const
Definition: TraCIAPI.cpp:1455
libsumo::TraCIStage findRoute(const std::string &fromEdge, const std::string &toEdge, const std::string &vType="", double pos=-1., int routingMode=0) const
Definition: TraCIAPI.cpp:1597
libsumo::TraCIRoadPosition convertRoad(double x, double y, bool isGeo=false, const std::string &vClass="ignoring") const
Definition: TraCIAPI.cpp:1511
void loadState(const std::string &path) const
Definition: TraCIAPI.cpp:1615
std::vector< std::string > getBusStopWaitingIDList(const std::string &stopID) const
Definition: TraCIAPI.cpp:1460
int getDepartedPersonNumber() const
Definition: TraCIAPI.cpp:1414
double getDistanceRoad(const std::string &edgeID1, double pos1, const std::string &edgeID2, double pos2, bool isDriving=false)
Definition: TraCIAPI.cpp:1575
std::vector< std::string > getArrivedPersonIDList() const
Definition: TraCIAPI.cpp:1429
void saveState(const std::string &destination) const
Definition: TraCIAPI.cpp:1624
std::vector< std::string > getEndingTeleportIDList() const
Definition: TraCIAPI.cpp:1409
double getDeltaT() const
Definition: TraCIAPI.cpp:1434
int getMinExpectedNumber() const
Definition: TraCIAPI.cpp:1445
std::vector< std::string > getDepartedPersonIDList() const
Definition: TraCIAPI.cpp:1419
std::vector< std::string > getDepartedIDList() const
Definition: TraCIAPI.cpp:1379
int getArrivedPersonNumber() const
Definition: TraCIAPI.cpp:1424
std::vector< std::string > getLoadedIDList() const
Definition: TraCIAPI.cpp:1369
std::vector< std::string > getArrivedIDList() const
Definition: TraCIAPI.cpp:1389
int getArrivedNumber() const
Definition: TraCIAPI.cpp:1384
std::string getOption(const std::string &option) const
Definition: TraCIAPI.cpp:1450
libsumo::TraCIPositionVector getNetBoundary() const
Definition: TraCIAPI.cpp:1439
void writeMessage(const std::string msg)
Definition: TraCIAPI.cpp:1633
libsumo::TraCIPosition convertGeo(double x, double y, bool fromGeo=false) const
Definition: TraCIAPI.cpp:1534
libsumo::TraCIPosition convert3D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
Definition: TraCIAPI.cpp:1488
int getUnsignedByte(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3557
const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3887
int getInt(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3578
std::vector< std::string > getStringVector(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3655
double getDouble(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3588
libsumo::TraCIPosition getPos3D(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3632
std::pair< std::string, std::string > getParameterWithKey(const std::string &objectID, const std::string &key) const
retrieve generic parameter and return (key, value) tuple
Definition: TraCIAPI.cpp:3767
libsumo::TraCIColor getCol(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3683
const libsumo::SubscriptionResults getAllSubscriptionResults() const
Definition: TraCIAPI.cpp:3865
void setStringVector(int var, const std::string &id, const std::vector< std::string > &value) const
Definition: TraCIAPI.cpp:3830
std::vector< std::string > getIDList() const
Definition: TraCIAPI.cpp:3746
libsumo::TraCIPositionVector getPolygon(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3598
libsumo::SubscriptionResults & getModifiableSubscriptionResults()
Definition: TraCIAPI.cpp:3904
const libsumo::TraCIResults getSubscriptionResults(const std::string &objID) const
Definition: TraCIAPI.cpp:3871
void setString(int var, const std::string &id, const std::string &value) const
Definition: TraCIAPI.cpp:3820
void subscribeContext(const std::string &objID, int domain, double range, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3855
void setParameter(const std::string &objectID, const std::string &key, const std::string &value) const
set generic paramter
Definition: TraCIAPI.cpp:3786
std::string getParameter(const std::string &objectID, const std::string &key) const
retrieve generic parameter
Definition: TraCIAPI.cpp:3758
std::vector< double > getDoubleVector(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3669
void setInt(int var, const std::string &id, int value) const
Definition: TraCIAPI.cpp:3800
int getByte(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3567
libsumo::TraCIStage getTraCIStage(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3697
void subscribe(const std::string &objID, const std::vector< int > &vars, double beginTime, double endTime) const
Definition: TraCIAPI.cpp:3843
std::string getString(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3645
libsumo::TraCIPosition getPos(int var, const std::string &id, tcpip::Storage *add=0) const
Definition: TraCIAPI.cpp:3619
const libsumo::ContextSubscriptionResults getAllContextSubscriptionResults() const
Definition: TraCIAPI.cpp:3881
libsumo::SubscriptionResults & getModifiableContextSubscriptionResults(const std::string &objID)
Definition: TraCIAPI.cpp:3910
void setDouble(int var, const std::string &id, double value) const
Definition: TraCIAPI.cpp:3810
int getServedPersonCount(const std::string &tlsID, int index) const
Definition: TraCIAPI.cpp:1763
std::string getRedYellowGreenState(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1646
int getPhase(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1742
std::string getPhaseName(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1747
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
Definition: TraCIAPI.cpp:1772
std::string getProgram(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1737
void setPhase(const std::string &tlsID, int index) const
Definition: TraCIAPI.cpp:1781
void setPhaseName(const std::string &tlsID, const std::string &name) const
Definition: TraCIAPI.cpp:1790
double getNextSwitch(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1757
std::vector< std::vector< libsumo::TraCILink > > getControlledLinks(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1709
double getPhaseDuration(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1752
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1704
std::vector< libsumo::TraCILogic > getAllProgramLogics(const std::string &tlsID) const
Definition: TraCIAPI.cpp:1651
void setPhaseDuration(const std::string &tlsID, double phaseDuration) const
Definition: TraCIAPI.cpp:1808
void setProgramLogic(const std::string &tlsID, const libsumo::TraCILogic &logic) const
Definition: TraCIAPI.cpp:1817
void setProgram(const std::string &tlsID, const std::string &programID) const
Definition: TraCIAPI.cpp:1799
std::vector< libsumo::TraCINextTLSData > getNextTLS(const std::string &vehID) const
Definition: TraCIAPI.cpp:2398
void changeLane(const std::string &vehicleID, int laneIndex, double duration) const
Definition: TraCIAPI.cpp:2727
void setMinGap(const std::string &vehicleID, double minGap) const
Definition: TraCIAPI.cpp:2975
double getLateralSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2176
void setMaxSpeed(const std::string &vehicleID, double speed) const
Definition: TraCIAPI.cpp:2984
void setPreviousSpeed(const std::string &vehicleID, double prevSpeed, double prevAcceleration=std::numeric_limits< int >::min()) const
Definition: TraCIAPI.cpp:2902
double getSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2171
int getStopState(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2520
double getWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2355
void addSubscriptionFilterCFManeuver(double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3095
double getCOEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2320
void addSubscriptionFilterStringList(int filterType, const std::vector< std::string > &vals) const
Definition: TraCIAPI.cpp:3183
void changeTarget(const std::string &vehicleID, const std::string &edgeID) const
Definition: TraCIAPI.cpp:2717
libsumo::TraCIPosition getPosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2239
bool isRouteValid(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2626
void addSubscriptionFilterByteList(int filterType, const std::vector< int > &vals) const
Definition: TraCIAPI.cpp:3193
double getSecureGap(const std::string &vehicleID, double speed, double leaderSpeed, double leaderMaxDecel, const std::string &leaderID="") const
Definition: TraCIAPI.cpp:2205
void setSpeedFactor(const std::string &vehicleID, double factor) const
Definition: TraCIAPI.cpp:2966
void setShapeClass(const std::string &vehicleID, const std::string &clazz) const
Definition: TraCIAPI.cpp:3044
void addSubscriptionFilterLateralDistance(double lateralDist, double downstreamDist=-1, double foeDistToJunction=-1) const
Definition: TraCIAPI.cpp:3156
void setVia(const std::string &vehicleID, const std::vector< std::string > &via) const
Definition: TraCIAPI.cpp:3014
void setEmissionClass(const std::string &vehicleID, const std::string &clazz) const
Definition: TraCIAPI.cpp:3054
double getTau(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2551
double getDistance(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2300
void remove(const std::string &vehicleID, char reason=libsumo::REMOVE_VAPORIZED) const
Definition: TraCIAPI.cpp:2706
void openGap(const std::string &vehicleID, double newTau, double duration, double changeRate, double maxDecel) const
Definition: TraCIAPI.cpp:2857
void moveTo(const std::string &vehicleID, const std::string &laneID, double position, int reason=libsumo::MOVE_TELEPORT) const
Definition: TraCIAPI.cpp:2807
void setSpeed(const std::string &vehicleID, double speed) const
Definition: TraCIAPI.cpp:2880
std::string getEmissionClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2388
void setStop(const std::string vehicleID, const std::string edgeID, const double endPos=1., const int laneIndex=0, const double duration=std::numeric_limits< double >::max(), const int flags=0, const double startPos=std::numeric_limits< int >::min(), const double until=-1) const
Definition: TraCIAPI.cpp:2933
void setRouteID(const std::string &vehicleID, const std::string &routeID) const
Definition: TraCIAPI.cpp:2767
std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction) const
Definition: TraCIAPI.cpp:2502
double getNoiseEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2345
std::string getShapeClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2393
void addSubscriptionFilterLeadFollow(const std::vector< int > &lanes) const
Definition: TraCIAPI.cpp:3124
std::string getLine(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2378
double getElectricityConsumption(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2350
double getSpeedFactor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2561
double getNOxEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2335
void setRoute(const std::string &vehicleID, const std::vector< std::string > &edge) const
Definition: TraCIAPI.cpp:2777
int getSignals(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2305
libsumo::TraCIColor getColor(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2290
int getPersonCapacity(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2611
void setSignals(const std::string &vehicleID, int signals) const
Definition: TraCIAPI.cpp:3026
std::string getRoadID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2254
void addSubscriptionFilterVType(const std::vector< std::string > &vTypes) const
Definition: TraCIAPI.cpp:3145
void addSubscriptionFilterUpstreamDistance(double dist) const
Definition: TraCIAPI.cpp:3089
void addSubscriptionFilterFloat(int filterType, double val) const
Definition: TraCIAPI.cpp:3173
double getAllowedSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2601
void addSubscriptionFilterLanes(const std::vector< int > &lanes, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3063
double getCO2Emission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2315
double getFuelConsumption(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2340
double getHCEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2325
void addSubscriptionFilterNoOpposite() const
Definition: TraCIAPI.cpp:3079
void addSubscriptionFilterLCManeuver(int direction, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3106
std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2466
double getAcceleration(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2181
std::vector< std::string > getVia(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2383
void addSubscriptionFilterVClass(const std::vector< std::string > &vClasses) const
Definition: TraCIAPI.cpp:3139
double getImperfection(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2556
std::string getLaneID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2259
double getAngle(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2249
void addSubscriptionFilterDownstreamDistance(double dist) const
Definition: TraCIAPI.cpp:3084
double getMinGap(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2576
void addSubscriptionFilterEmpty(int filterType) const
Definition: TraCIAPI.cpp:3167
double getStopArrivalDelay(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2535
void setAcceleration(const std::string &vehicleID, double accel, double duration) const
Definition: TraCIAPI.cpp:2889
std::vector< std::string > getPersonIDList(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2616
double getStopDelay(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2530
double getMinGapLat(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2636
void setLine(const std::string &vehicleID, const std::string &line) const
Definition: TraCIAPI.cpp:3005
double getSlope(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2372
void setColor(const std::string &vehicleID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:2993
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:2646
libsumo::TraCIPosition getPosition3D(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2244
void setLaneChangeMode(const std::string &vehicleID, int mode) const
Definition: TraCIAPI.cpp:2915
void setRoutingMode(const std::string &vehicleID, int routingMode) const
Definition: TraCIAPI.cpp:3035
void addSubscriptionFilterTurn(double downstreamDist=-1, double upstreamDist=-1) const
Definition: TraCIAPI.cpp:3130
double getDecel(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2546
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:2822
double getHeight(const std::string &veihcleID) const
Definition: TraCIAPI.cpp:2591
int getRouteIndex(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2279
double getMaxSpeedLat(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2631
void changeSublane(const std::string &vehicleID, double latDist) const
Definition: TraCIAPI.cpp:2757
std::string getLateralAlignment(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2641
std::string getRouteID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2274
double getLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2295
int getLaneChangeMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2360
int getSpeedMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2366
std::vector< std::string > getRoute(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2285
double getLateralLanePosition(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2310
std::pair< std::string, double > getFollower(const std::string &vehicleID, double dist) const
Definition: TraCIAPI.cpp:2484
double getPMxEmission(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2330
double getLength(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2586
double getMaxSpeed(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2234
std::string getVehicleClass(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2571
double getSpeedWithoutTraCI(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2621
int getRoutingMode(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2525
double getWidth(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2581
double getSpeedDeviation(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2566
int getPersonNumber(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2606
double getFollowSpeed(const std::string &vehicleID, double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string &leaderID="") const
Definition: TraCIAPI.cpp:2186
void setType(const std::string &vehicleID, const std::string &typeID) const
Definition: TraCIAPI.cpp:2957
void addSubscriptionFilterFieldOfVision(double angle) const
Definition: TraCIAPI.cpp:3151
std::vector< libsumo::TraCIBestLanesData > getBestLanes(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2427
double getAccel(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2541
void setSpeedMode(const std::string &vehicleID, int mode) const
Definition: TraCIAPI.cpp:2924
void slowDown(const std::string &vehicleID, double speed, double duration) const
Definition: TraCIAPI.cpp:2844
std::string getTypeID(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2269
double getAccumulatedWaitingTime(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2596
void changeLaneRelative(const std::string &vehicleID, int laneChange, double duration) const
Definition: TraCIAPI.cpp:2741
void rerouteTraveltime(const std::string &vehicleID, bool currentTravelTimes=true) const
Definition: TraCIAPI.cpp:2790
double getStopSpeed(const std::string &vehicleID, double speed, double gap) const
Definition: TraCIAPI.cpp:2221
int getLaneIndex(const std::string &vehicleID) const
Definition: TraCIAPI.cpp:2264
double getSpeedDeviation(const std::string &typeID) const
Definition: TraCIAPI.cpp:1881
double getSpeedFactor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1876
void setImperfection(const std::string &typeID, double imperfection) const
Definition: TraCIAPI.cpp:2137
void setApparentDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2128
void setHeight(const std::string &typeID, double height) const
Definition: TraCIAPI.cpp:2037
std::string getShapeClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1926
double getMinGapLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1936
void copy(const std::string &origTypeID, const std::string &newTypeID) const
Definition: TraCIAPI.cpp:2083
int getPersonCapacity(const std::string &typeID) const
Definition: TraCIAPI.cpp:1951
void setVehicleClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:1991
void setColor(const std::string &typeID, const libsumo::TraCIColor &c) const
Definition: TraCIAPI.cpp:2155
void setDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2110
void setWidth(const std::string &typeID, double width) const
Definition: TraCIAPI.cpp:2028
double getApparentDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1901
double getDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1891
void setLateralAlignment(const std::string &typeID, const std::string &latAlignment) const
Definition: TraCIAPI.cpp:2074
void setMaxSpeed(const std::string &typeID, double speed) const
Definition: TraCIAPI.cpp:1982
double getMinGap(const std::string &typeID) const
Definition: TraCIAPI.cpp:1931
std::string getVehicleClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1916
void setShapeClass(const std::string &typeID, const std::string &shapeClass) const
Definition: TraCIAPI.cpp:2092
double getMaxSpeedLat(const std::string &typeID) const
Definition: TraCIAPI.cpp:1941
double getEmergencyDecel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1896
double getWidth(const std::string &typeID) const
Definition: TraCIAPI.cpp:1956
libsumo::TraCIColor getColor(const std::string &typeID) const
Definition: TraCIAPI.cpp:1966
double getTau(const std::string &typeID) const
Definition: TraCIAPI.cpp:1911
double getMaxSpeed(const std::string &typeID) const
Definition: TraCIAPI.cpp:1871
double getLength(const std::string &typeID) const
Definition: TraCIAPI.cpp:1866
std::string getEmissionClass(const std::string &typeID) const
Definition: TraCIAPI.cpp:1921
double getImperfection(const std::string &typeID) const
Definition: TraCIAPI.cpp:1906
void setEmissionClass(const std::string &typeID, const std::string &clazz) const
Definition: TraCIAPI.cpp:2019
void setAccel(const std::string &typeID, double accel) const
Definition: TraCIAPI.cpp:2101
void setMinGap(const std::string &typeID, double minGap) const
Definition: TraCIAPI.cpp:2046
double getAccel(const std::string &typeID) const
Definition: TraCIAPI.cpp:1886
void setSpeedFactor(const std::string &typeID, double factor) const
Definition: TraCIAPI.cpp:2000
double getHeight(const std::string &typeID) const
Definition: TraCIAPI.cpp:1961
void setEmergencyDecel(const std::string &typeID, double decel) const
Definition: TraCIAPI.cpp:2119
void setSpeedDeviation(const std::string &typeID, double deviation) const
Definition: TraCIAPI.cpp:2009
void setMaxSpeedLat(const std::string &typeID, double speed) const
Definition: TraCIAPI.cpp:2065
std::string getLateralAlignment(const std::string &typeID) const
Definition: TraCIAPI.cpp:1946
void setMinGapLat(const std::string &typeID, double minGapLat) const
Definition: TraCIAPI.cpp:2056
void setLength(const std::string &typeID, double length) const
Definition: TraCIAPI.cpp:1973
void setTau(const std::string &typeID, double tau) const
Definition: TraCIAPI.cpp:2146
RouteScope route
Scope for interaction with routes.
Definition: TraCIAPI.h:846
std::pair< int, std::string > getVersion()
return TraCI API and SUMO version
Definition: TraCIAPI.cpp:487
void setOrder(int order)
set priority (execution order) for the client
Definition: TraCIAPI.cpp:89
void readVariableSubscription(int cmdId, tcpip::Storage &inMsg)
Definition: TraCIAPI.cpp:424
tcpip::Storage myInput
The reusable input storage.
Definition: TraCIAPI.h:955
MeMeScope multientryexit
Scope for interaction with multi-entry/-exit detectors.
Definition: TraCIAPI.h:836
VehicleTypeScope vehicletype
Scope for interaction with vehicle types.
Definition: TraCIAPI.h:856
void send_commandSubscribeObjectVariable(int domID, const std::string &objID, double beginTime, double endTime, const std::vector< int > &vars) const
Sends a SubscribeVariable request.
Definition: TraCIAPI.cpp:209
void send_commandSimulationStep(double time) const
Sends a SimulationStep command.
Definition: TraCIAPI.cpp:125
GUIScope gui
Scope for interaction with the gui.
Definition: TraCIAPI.h:826
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:268
PolygonScope polygon
Scope for interaction with polygons.
Definition: TraCIAPI.h:842
static std::string toString(const T &t, std::streamsize accuracy=PRECISION)
Definition: TraCIAPI.h:937
TraCIAPI()
Constructor.
Definition: TraCIAPI.cpp:40
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
Definition: TraCIAPI.cpp:76
tcpip::Socket * mySocket
The socket.
Definition: TraCIAPI.h:951
void load(const std::vector< std::string > &args)
Let sumo load a simulation using the given command line like options.
Definition: TraCIAPI.cpp:469
LaneAreaScope lanearea
Scope for interaction with lanes.
Definition: TraCIAPI.h:834
void simulationStep(double time=0)
Advances by one step (or up to the given time)
Definition: TraCIAPI.cpp:447
void createFilterCommand(int cmdID, int varID, tcpip::Storage *add=nullptr) const
Definition: TraCIAPI.cpp:186
void createCommand(int cmdID, int varID, const std::string &objID, tcpip::Storage *add=nullptr) const
Sends a GetVariable / SetVariable request if mySocket is connected. Otherwise writes to myOutput only...
Definition: TraCIAPI.cpp:162
void close()
ends the simulation and closes the connection
Definition: TraCIAPI.cpp:104
LaneScope lane
Scope for interaction with lanes.
Definition: TraCIAPI.h:832
std::map< int, TraCIScopeWrapper * > myDomains
Definition: TraCIAPI.h:949
void send_commandSubscribeObjectContext(int domID, const std::string &objID, double beginTime, double endTime, int domain, double range, const std::vector< int > &vars) const
Sends a SubscribeContext request.
Definition: TraCIAPI.cpp:237
bool processSet(int command)
Definition: TraCIAPI.cpp:344
TrafficLightScope trafficlights
Scope for interaction with traffic lights.
Definition: TraCIAPI.h:852
tcpip::Storage myOutput
The reusable output storage.
Definition: TraCIAPI.h:953
POIScope poi
Scope for interaction with POIs.
Definition: TraCIAPI.h:840
void closeSocket()
Closes the connection.
Definition: TraCIAPI.cpp:114
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:307
VehicleScope vehicle
Scope for interaction with vehicles.
Definition: TraCIAPI.h:854
JunctionScope junction
Scope for interaction with junctions.
Definition: TraCIAPI.h:830
void send_commandClose() const
Sends a Close command.
Definition: TraCIAPI.cpp:138
void send_commandSetOrder(int order) const
Sends a SetOrder command.
Definition: TraCIAPI.cpp:149
~TraCIAPI()
Destructor.
Definition: TraCIAPI.cpp:70
RouteProbeScope routeprobe
Scope for interaction with route probes.
Definition: TraCIAPI.h:848
EdgeScope edge
Scope for interaction with edges.
Definition: TraCIAPI.h:824
bool processGet(int command, int expectedType, bool ignoreCommandId=false)
Definition: TraCIAPI.cpp:331
SimulationScope simulation
Scope for interaction with the simulation.
Definition: TraCIAPI.h:850
void readContextSubscription(int cmdId, tcpip::Storage &inMsg)
Definition: TraCIAPI.cpp:432
void readVariables(tcpip::Storage &inMsg, const std::string &objectID, int variableCount, libsumo::SubscriptionResults &into)
Definition: TraCIAPI.cpp:356
PersonScope person
Scope for interaction with persons.
Definition: TraCIAPI.h:838
RerouterScope rerouter
Scope for interaction with rerouters.
Definition: TraCIAPI.h:844
An error which allows to continue.
Definition: TraCIDefs.h:138
std::map< std::string, std::string > subParameter
Definition: TraCIDefs.h:341
std::string programID
Definition: TraCIDefs.h:337
std::vector< std::shared_ptr< libsumo::TraCIPhase > > phases
Definition: TraCIDefs.h:340
std::string intended
id of the intended vehicle for public transport ride
Definition: TraCIDefs.h:545
int type
The type of stage (walking, driving, ...)
Definition: TraCIDefs.h:529
std::string destStop
The id of the destination stop.
Definition: TraCIDefs.h:535
double length
length in m
Definition: TraCIDefs.h:543
double travelTime
duration of the stage in seconds
Definition: TraCIDefs.h:539
double departPos
position on the lane when starting the stage
Definition: TraCIDefs.h:549
std::string description
arbitrary description string
Definition: TraCIDefs.h:553
std::string line
The line or the id of the vehicle type.
Definition: TraCIDefs.h:533
double cost
effort needed
Definition: TraCIDefs.h:541
double depart
intended depart time for public transport ride or INVALID_DOUBLE_VALUE
Definition: TraCIDefs.h:547
std::vector< std::string > edges
The sequence of edges to travel.
Definition: TraCIDefs.h:537
double arrivalPos
position on the lane when ending the stage
Definition: TraCIDefs.h:551
std::string vType
The vehicle type when using a private car or bike.
Definition: TraCIDefs.h:531
bool receiveExact(Storage &)
Receive a complete TraCI message from Socket::socket_.
Definition: socket.cpp:536
void sendExact(const Storage &)
Definition: socket.cpp:439
void connect()
Connects to host_:port_.
Definition: socket.cpp:367
void close()
Definition: socket.cpp:391
virtual std::string readString()
Definition: storage.cpp:180
virtual void writeString(const std::string &s)
Definition: storage.cpp:197
virtual unsigned int position() const
Definition: storage.cpp:76
virtual void writeInt(int)
Definition: storage.cpp:321
virtual void writeDouble(double)
Definition: storage.cpp:354
virtual int readUnsignedByte()
Definition: storage.cpp:155
virtual void writeStringList(const std::vector< std::string > &s)
Definition: storage.cpp:247
void reset()
Definition: storage.cpp:85
virtual void writeUnsignedByte(int)
Definition: storage.cpp:165
StorageType::size_type size() const
Definition: storage.h:119
virtual void writeByte(int)
Definition: storage.cpp:140
virtual void writeStorage(tcpip::Storage &store)
Definition: storage.cpp:388
virtual double readDouble()
Definition: storage.cpp:362
virtual int readInt()
Definition: storage.cpp:311
TRACI_CONST double INVALID_DOUBLE_VALUE
TRACI_CONST int RESPONSE_SUBSCRIBE_GUI_VARIABLE
TRACI_CONST int LAST_STEP_VEHICLE_ID_LIST
TRACI_CONST int VAR_EXIT_POSITIONS
TRACI_CONST int TYPE_COLOR
TRACI_CONST int VAR_MIN_EXPECTED_VEHICLES
TRACI_CONST int CMD_SAVE_SIMSTATE
TRACI_CONST int FILTER_TYPE_DOWNSTREAM_DIST
TRACI_CONST int VAR_IMAGEFILE
TRACI_CONST int VAR_EDGES
TRACI_CONST int CMD_LOAD
TRACI_CONST int LAST_STEP_VEHICLE_NUMBER
TRACI_CONST int POSITION_3D
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int VAR_NOXEMISSION
TRACI_CONST int VAR_LANECHANGE_MODE
TRACI_CONST int VAR_ARRIVED_VEHICLES_NUMBER
TRACI_CONST int VAR_NAME
TRACI_CONST int LAST_STEP_PERSON_ID_LIST
TRACI_CONST int RTYPE_NOTIMPLEMENTED
TRACI_CONST int RESPONSE_SUBSCRIBE_ROUTE_VARIABLE
TRACI_CONST int FILTER_TYPE_NOOPPOSITE
TRACI_CONST int VAR_VEHICLECLASS
TRACI_CONST int LANE_LINKS
TRACI_CONST int TRACI_ID_LIST
TRACI_CONST int VAR_LATALIGNMENT
TRACI_CONST int VAR_DEPARTED_VEHICLES_NUMBER
TRACI_CONST int CMD_GET_TL_VARIABLE
TRACI_CONST int VAR_VIEW_BOUNDARY
TRACI_CONST int LAST_STEP_VEHICLE_DATA
TRACI_CONST int VAR_TYPE
TRACI_CONST int CMD_CHANGESUBLANE
TRACI_CONST int CMD_LOAD_SIMSTATE
TRACI_CONST int CMD_SET_EDGE_VARIABLE
TRACI_CONST int RESPONSE_SUBSCRIBE_LANE_VARIABLE
TRACI_CONST int VAR_ROUTING_MODE
TRACI_CONST int VAR_MINGAP
TRACI_CONST int VAR_VEHICLE
TRACI_CONST int VAR_SECURE_GAP
TRACI_CONST int VAR_LANES
TRACI_CONST int VAR_SHAPECLASS
TRACI_CONST int VAR_WAITING_TIME
TRACI_CONST int CMD_STOP
TRACI_CONST int VAR_LINE
std::map< std::string, libsumo::SubscriptionResults > ContextSubscriptionResults
Definition: TraCIDefs.h:301
TRACI_CONST int LANE_LINK_NUMBER
TRACI_CONST int VAR_EDGE_TRAVELTIME
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
TRACI_CONST int VAR_SCREENSHOT
TRACI_CONST int VAR_SPEED_FACTOR
TRACI_CONST int MOVE_TO_XY
TRACI_CONST int VAR_FOLLOW_SPEED
TRACI_CONST int VAR_STOP_ARRIVALDELAY
TRACI_CONST int VAR_SPEED_LAT
TRACI_CONST int LAST_STEP_LENGTH
TRACI_CONST int FILTER_TYPE_FIELD_OF_VISION
TRACI_CONST int TL_CONTROLLED_LANES
TRACI_CONST int VAR_ANGLE
TRACI_CONST int VAR_TAU
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int LANE_EDGE_ID
TRACI_CONST int VAR_NEXT_TLS
TRACI_CONST int RESPONSE_SUBSCRIBE_PERSON_VARIABLE
TRACI_CONST int VAR_EDGE_EFFORT
TRACI_CONST int RESPONSE_SUBSCRIBE_TL_VARIABLE
TRACI_CONST int VAR_VIEW_OFFSET
TRACI_CONST int RESPONSE_SUBSCRIBE_MULTIENTRYEXIT_VARIABLE
TRACI_CONST int VAR_ROUTE
TRACI_CONST int VAR_BEST_LANES
TRACI_CONST int VAR_ALLOWED_SPEED
TRACI_CONST int VAR_LANE_INDEX
TRACI_CONST int VAR_PMXEMISSION
TRACI_CONST int VAR_SPEED_WITHOUT_TRACI
TRACI_CONST int VAR_DEPARTED_PERSONS_NUMBER
TRACI_CONST int TL_COMPLETE_DEFINITION_RYG
TRACI_CONST int TYPE_UBYTE
TRACI_CONST int VAR_STAGE
TRACI_CONST int CMD_SET_POI_VARIABLE
TRACI_CONST int VAR_MOVE_TO
TRACI_CONST int RESPONSE_SUBSCRIBE_VEHICLE_VARIABLE
TRACI_CONST int VAR_PERSON_NUMBER
TRACI_CONST int RESPONSE_SUBSCRIBE_REROUTER_VARIABLE
TRACI_CONST int CMD_SET_POLYGON_VARIABLE
TRACI_CONST int VAR_COEMISSION
TRACI_CONST int RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
TRACI_CONST int VAR_COLOR
TRACI_CONST int VAR_POSITION
TRACI_CONST int VAR_WIDTH
TRACI_CONST int VAR_PERSON_CAPACITY
TRACI_CONST int VAR_VIEW_SCHEMA
TRACI_CONST int POSITION_2D
TRACI_CONST int VAR_MAXSPEED
TRACI_CONST int COPY
TRACI_CONST int VAR_ARRIVED_PERSONS_IDS
TRACI_CONST int VAR_LEADER
TRACI_CONST int CMD_CHANGETARGET
TRACI_CONST int CMD_CLOSE
TRACI_CONST int VAR_TIME
TRACI_CONST int TYPE_POLYGON
TRACI_CONST int LAST_STEP_MEAN_SPEED
TRACI_CONST int ADD_FULL
TRACI_CONST int STAGE_WAITING
TRACI_CONST int CMD_SET_ROUTE_VARIABLE
TRACI_CONST int CMD_SETORDER
TRACI_CONST int VAR_CO2EMISSION
TRACI_CONST int RESPONSE_SUBSCRIBE_JUNCTION_VARIABLE
TRACI_CONST int FILTER_TYPE_VTYPE
TRACI_CONST int CMD_REROUTE_TRAVELTIME
TRACI_CONST int VAR_NET_BOUNDING_BOX
TRACI_CONST int TYPE_STRINGLIST
TRACI_CONST int APPEND_STAGE
TRACI_CONST int VAR_VIEW_ZOOM
TRACI_CONST int CMD_SET_SIM_VARIABLE
TRACI_CONST int TL_CONTROLLED_LINKS
TRACI_CONST int TYPE_INTEGER
TRACI_CONST int VAR_PREV_SPEED
TRACI_CONST int VAR_ROUTE_VALID
TRACI_CONST int VAR_SPEEDSETMODE
TRACI_CONST int POSITION_LON_LAT
TRACI_CONST int CMD_ADD_SUBSCRIPTION_FILTER
TRACI_CONST int CMD_SET_VEHICLE_VARIABLE
TRACI_CONST int VAR_FUELCONSUMPTION
TRACI_CONST int CMD_SET_GUI_VARIABLE
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
Definition: TraCIDefs.h:300
TRACI_CONST int VAR_SLOPE
TRACI_CONST int VAR_SHAPE
TRACI_CONST int LAST_STEP_VEHICLE_HALTING_NUMBER
TRACI_CONST int VAR_LENGTH
TRACI_CONST int VAR_MAXSPEED_LAT
TRACI_CONST int VAR_HCEMISSION
TRACI_CONST int VAR_BUS_STOP_WAITING_IDS
TRACI_CONST int ID_COUNT
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_LANEPOSITION
TRACI_CONST int CMD_SET_VEHICLETYPE_VARIABLE
TRACI_CONST int REMOVE
TRACI_CONST int CMD_SET_PERSON_VARIABLE
TRACI_CONST int VAR_DEPARTED_VEHICLES_IDS
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_NUMBER
TRACI_CONST int CMD_GET_SIM_VARIABLE
TRACI_CONST int CMD_MESSAGE
TRACI_CONST int VAR_LANE_ID
TRACI_CONST int VAR_STOP_SPEED
TRACI_CONST int VAR_IMPERFECTION
TRACI_CONST int RESPONSE_SUBSCRIBE_ROUTEPROBE_VARIABLE
TRACI_CONST int LAST_STEP_OCCUPANCY
TRACI_CONST int VAR_HEIGHT
TRACI_CONST int RESPONSE_SUBSCRIBE_LANEAREA_VARIABLE
TRACI_CONST int VAR_APPARENT_DECEL
TRACI_CONST int TL_NEXT_SWITCH
TRACI_CONST int VAR_NOISEEMISSION
TRACI_CONST int VAR_LOADED_VEHICLES_IDS
TRACI_CONST int VAR_EXIT_LANES
TRACI_CONST int FILTER_TYPE_LEAD_FOLLOW
TRACI_CONST int RESPONSE_SUBSCRIBE_VEHICLETYPE_VARIABLE
TRACI_CONST int VAR_DELTA_T
TRACI_CONST int REQUEST_DRIVINGDIST
TRACI_CONST int CMD_GET_LANE_VARIABLE
TRACI_CONST int STAGE_WALKING
TRACI_CONST int VAR_POSITION3D
TRACI_CONST int LANE_DISALLOWED
TRACI_CONST int REMOVE_STAGE
TRACI_CONST int VAR_SPEED
TRACI_CONST int VAR_DECEL
TRACI_CONST int VAR_SIGNALS
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int FILTER_TYPE_UPSTREAM_DIST
TRACI_CONST int TYPE_DOUBLELIST
TRACI_CONST int VAR_ACCUMULATED_WAITING_TIME
TRACI_CONST int VAR_MINGAP_LAT
TRACI_CONST int VAR_DEPARTED_PERSONS_IDS
TRACI_CONST int INVALID_INT_VALUE
TRACI_CONST int VAR_ARRIVED_PERSONS_NUMBER
TRACI_CONST int TL_PROGRAM
TRACI_CONST int VAR_ROUTE_INDEX
TRACI_CONST int TL_PHASE_DURATION
TRACI_CONST int CMD_SLOWDOWN
TRACI_CONST int VAR_NEXT_EDGE
TRACI_CONST int FILTER_TYPE_TURN
TRACI_CONST int VAR_ACCELERATION
TRACI_CONST int VAR_FILL
TRACI_CONST int FIND_ROUTE
TRACI_CONST int VAR_ROUTE_ID
TRACI_CONST int TL_PHASE_INDEX
TRACI_CONST int POSITION_CONVERSION
TRACI_CONST int TYPE_DOUBLE
TRACI_CONST int DISTANCE_REQUEST
TRACI_CONST int TYPE_BYTE
TRACI_CONST int TL_CURRENT_PHASE
TRACI_CONST int CMD_OPENGAP
TRACI_CONST int TL_COMPLETE_PROGRAM_RYG
TRACI_CONST int VAR_LOADED_VEHICLES_NUMBER
TRACI_CONST int VAR_TELEPORT_ENDING_VEHICLES_IDS
TRACI_CONST int CMD_SET_TL_VARIABLE
TRACI_CONST int VAR_LANEPOSITION_LAT
TRACI_CONST int FILTER_TYPE_VCLASS
TRACI_CONST int CMD_CHANGELANE
TRACI_CONST int VAR_CURRENT_TRAVELTIME
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_NUMBER
TRACI_CONST int TL_RED_YELLOW_GREEN_STATE
TRACI_CONST int RESPONSE_SUBSCRIBE_POI_VARIABLE
TRACI_CONST int VAR_STOP_DELAY
TRACI_CONST int VAR_TELEPORT_STARTING_VEHICLES_IDS
TRACI_CONST int CMD_GETVERSION
TRACI_CONST int REQUEST_AIRDIST
TRACI_CONST int VAR_BUS_STOP_WAITING
TRACI_CONST int RTYPE_ERR
TRACI_CONST int CMD_SIMSTEP
TRACI_CONST int VAR_TIME_STEP
TRACI_CONST int VAR_EMERGENCY_DECEL
TRACI_CONST int VAR_ARRIVED_VEHICLES_IDS
TRACI_CONST int RESPONSE_SUBSCRIBE_SIM_VARIABLE
TRACI_CONST int STAGE_DRIVING
TRACI_CONST int RTYPE_OK
TRACI_CONST int CMD_GET_INDUCTIONLOOP_VARIABLE
TRACI_CONST int LAST_STEP_TIME_SINCE_DETECTION
TRACI_CONST int VAR_STOPSTATE
TRACI_CONST int VAR_FOLLOWER
TRACI_CONST int POSITION_LON_LAT_ALT
TRACI_CONST int VAR_EMISSIONCLASS
TRACI_CONST int FILTER_TYPE_LANES
TRACI_CONST int VAR_ACCEL
TRACI_CONST int RESPONSE_SUBSCRIBE_POLYGON_VARIABLE
TRACI_CONST int ADD
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
Definition: TraCIDefs.h:298
TRACI_CONST int VAR_FOES
TRACI_CONST int VAR_STAGES_REMAINING
TRACI_CONST int VAR_DISTANCE
TRACI_CONST int LANE_ALLOWED
TRACI_CONST int VAR_OPTION
TRACI_CONST int RESPONSE_SUBSCRIBE_EDGE_VARIABLE
TRACI_CONST int TL_CURRENT_PROGRAM
TRACI_CONST int FILTER_TYPE_LATERAL_DIST
TRACI_CONST int VAR_ELECTRICITYCONSUMPTION
TRACI_CONST int VAR_SPEED_DEVIATION
TRACI_CONST int VAR_VIA
TRACI_CONST int TYPE_STRING
double length
The length than can be driven from that lane without lane change.
Definition: TraCIDefs.h:507
double occupation
The traffic density along length.
Definition: TraCIDefs.h:509
bool allowsContinuation
Whether this lane allows continuing the route.
Definition: TraCIDefs.h:513
int bestLaneOffset
The offset of this lane from the best lane.
Definition: TraCIDefs.h:511
std::vector< std::string > continuationLanes
The sequence of lanes that best allows continuing the route without lane change.
Definition: TraCIDefs.h:515
std::string laneID
The id of the lane.
Definition: TraCIDefs.h:505
double dist
The distance to the tls.
Definition: TraCIDefs.h:399
int tlIndex
The tls index of the controlled link.
Definition: TraCIDefs.h:397
std::string id
The id of the next tls.
Definition: TraCIDefs.h:395
char state
The current state of the tls.
Definition: TraCIDefs.h:401
A 3D-position.
Definition: TraCIDefs.h:172
A list of positions.
Definition: TraCIDefs.h:215
std::vector< TraCIPosition > value
Definition: TraCIDefs.h:225
An edgeId, position and laneIndex.
Definition: TraCIDefs.h:184
mirrors MSInductLoop::VehicleData
Definition: TraCIDefs.h:379
std::string id
The id of the vehicle.
Definition: TraCIDefs.h:381
double entryTime
Entry-time of the vehicle in [s].
Definition: TraCIDefs.h:385
std::string typeID
Type of the vehicle in.
Definition: TraCIDefs.h:389
double length
Length of the vehicle.
Definition: TraCIDefs.h:383
double leaveTime
Leave-time of the vehicle in [s].
Definition: TraCIDefs.h:387