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