29#define _CRT_SECURE_NO_WARNINGS
31#pragma warning(disable:4820 4514 5045 4710)
55 answerLog.setf(std::ios::fixed, std::ios::floatfield);
68 std::ifstream defFile;
69 std::string fileContentStr;
70 std::stringstream fileContent;
71 std::string lineCommand;
72 std::stringstream msg;
74 bool commentRead =
false;
80 msg <<
"#Error while connecting: " << e.what();
86 defFile.open(fileName.c_str());
88 msg <<
"Can not open definition file " << fileName << std::endl;
92 defFile.unsetf(std::ios::dec);
94 while (defFile >> lineCommand) {
96 if (lineCommand.compare(
"%") == 0) {
98 commentRead = !commentRead;
105 if (lineCommand.compare(
"repeat") == 0) {
107 defFile >> lineCommand;
109 if (lineCommand.compare(
"simstep2") == 0) {
113 for (
int i = 0; i < repNo; i++) {
116 }
else if (lineCommand.compare(
"getvariable") == 0) {
120 defFile >> domID >> varID >> objID;
122 }
else if (lineCommand.compare(
"getvariable_plus") == 0) {
126 defFile >> domID >> varID >> objID;
129 std::string msgS = msg.str();
134 }
else if (lineCommand.compare(
"subscribevariable") == 0) {
137 double beginTime, endTime;
139 defFile >> domID >> objID >> beginTime >> endTime >> varNo;
141 }
else if (lineCommand.compare(
"subscribecontext") == 0) {
143 int domID, varNo, domain;
145 double beginTime, endTime;
147 defFile >> domID >> objID >> beginTime >> endTime >> domain >> range >> varNo;
149 }
else if (lineCommand.compare(
"setvalue") == 0) {
153 defFile >> domID >> varID >> objID;
155 }
else if (lineCommand.compare(
"testAPI") == 0) {
158 }
else if (lineCommand.compare(
"setorder") == 0) {
164 msg <<
"Error in definition file: " << lineCommand <<
" is not a valid command";
183 answerLog << std::endl <<
"-> Command sent: <SimulationStep>:" << std::endl;
185 std::string acknowledgement;
187 answerLog << acknowledgement << std::endl;
199 answerLog << std::endl <<
"-> Command sent: <Close>:" << std::endl;
201 std::string acknowledgement;
203 answerLog << acknowledgement << std::endl;
214 answerLog << std::endl <<
"-> Command sent: <SetOrder>:" << std::endl;
216 std::string acknowledgement;
218 answerLog << acknowledgement << std::endl;
231 answerLog << std::endl <<
"-> Command sent: <GetVariable>:" << std::endl
232 <<
" domID=" << domID <<
" varID=" << varID
233 <<
" objID=" << objID << std::endl;
234 std::string acknowledgement;
236 answerLog << acknowledgement << std::endl;
246 answerLog <<
" CommandID=" << (domID + 0x10) <<
" VariableID=" << variableID <<
" ObjectID=" << objectID;
248 answerLog <<
" valueDataType=" << valueDataType;
251 std::stringstream msg;
252 msg <<
"Error while receiving command: " << e.what();
261 std::stringstream msg;
264 std::string msgS = msg.str();
270 answerLog << std::endl <<
"-> Command sent: <SetValue>:" << std::endl
271 <<
" domID=" << domID <<
" varID=" << varID
272 <<
" objID=" << objID << std::endl;
274 std::string acknowledgement;
276 answerLog << acknowledgement << std::endl;
285 std::vector<int> vars;
286 for (
int i = 0; i < varNo; ++i) {
293 answerLog << std::endl <<
"-> Command sent: <SubscribeVariable>:" << std::endl
294 <<
" domID=" << domID <<
" objID=" << objID <<
" with " << varNo <<
" variables" << std::endl;
297 std::string acknowledgement;
299 answerLog << acknowledgement << std::endl;
309 int domain,
double range,
int varNo, std::ifstream& defFile) {
310 std::vector<int> vars;
311 for (
int i = 0; i < varNo; ++i) {
318 answerLog << std::endl <<
"-> Command sent: <SubscribeContext>:" << std::endl
319 <<
" domID=" << domID <<
" objID=" << objID <<
" domain=" << domain <<
" range=" << range
320 <<
" with " << varNo <<
" variables" << std::endl;
323 std::string acknowledgement;
325 answerLog << acknowledgement << std::endl;
340 std::cerr <<
"Unable to write result file" << std::endl;
343 locTime = localtime(&seconds);
344 outFile <<
"TraCITestClient output file. Date: " << asctime(locTime) << std::endl;
352 std::cerr << msg.str() << std::endl;
353 answerLog <<
"----" << std::endl << msg.str() << std::endl;
364 int noSubscriptions = inMsg.
readInt();
365 for (
int s = 0; s < noSubscriptions; ++s) {
370 }
catch (std::invalid_argument& e) {
371 answerLog <<
"#Error while reading message:" << e.what() << std::endl;
390 answerLog <<
" #variables=" << varNo << std::endl;
391 for (
int i = 0; i < varNo; ++i) {
396 answerLog <<
" valueDataType=" << valueDataType;
404 answerLog <<
" #variables=" << varNo << std::endl;
406 answerLog <<
" #objects=" << objNo << std::endl;
407 for (
int j = 0; j < objNo; ++j) {
409 for (
int i = 0; i < varNo; ++i) {
414 answerLog <<
" valueDataType=" << valueDataType;
419 answerLog <<
"#Error: received response with command id: " << cmdId <<
" but expected a subscription response (0xe0-0xef / 0x90-0x9f)" << std::endl;
422 }
catch (std::invalid_argument& e) {
423 answerLog <<
"#Error while reading message:" << e.what() << std::endl;
438 std::string dataTypeS;
439 defFile >> dataTypeS;
440 if (dataTypeS ==
"<airDist>") {
443 }
else if (dataTypeS ==
"<drivingDist>") {
446 }
else if (dataTypeS ==
"<objSubscription>") {
447 int beginTime, endTime, numVars;
448 defFile >> beginTime >> endTime >> numVars;
452 for (
int i = 0; i < numVars; ++i) {
457 return 4 + 4 + 4 + numVars;
461 if (dataTypeS ==
"<int>") {
466 }
else if (dataTypeS ==
"<byte>") {
471 }
else if (dataTypeS ==
"<ubyte>") {
476 }
else if (dataTypeS ==
"<double>") {
481 }
else if (dataTypeS ==
"<string>") {
484 if (valueS ==
"\"\"") {
489 return 4 + 1 + (int) valueS.length();
490 }
else if (dataTypeS ==
"<string*>") {
491 std::vector<std::string> slValue;
494 for (
int i = 0; i < valI; ++i) {
497 slValue.push_back(tmp);
498 length += 4 + int(tmp.length());
503 }
else if (dataTypeS ==
"<compound>") {
508 for (
int i = 0; i < valI; ++i) {
512 }
else if (dataTypeS ==
"<color>") {
516 for (
int i = 0; i < 3; ++i) {
521 }
else if (dataTypeS ==
"<position2D>") {
528 }
else if (dataTypeS ==
"<position3D>") {
536 return 1 + 8 + 8 + 8;
537 }
else if (dataTypeS ==
"<positionRoadmap>") {
542 int length = 1 + 8 + (int) valueS.length();
547 return length + 4 + 1;
548 }
else if (dataTypeS ==
"<shape>") {
553 for (
int i = 0; i < valI; ++i) {
562 msg <<
"## Unknown data type: " << dataTypeS;
571 answerLog <<
" Unsigned Byte Value: " << ubyte << std::endl;
574 answerLog <<
" Byte value: " <<
byte << std::endl;
577 answerLog <<
" Int value: " << integer << std::endl;
580 answerLog <<
" Double value: " << doublev << std::endl;
587 for (
int i = 0; i < size; i++) {
590 answerLog <<
"(" << x <<
"," << y <<
") ";
599 <<
" z: " << z << std::endl;
604 answerLog <<
" RoadMapPositionValue: roadId=" << roadId
606 <<
" laneId=" << laneId << std::endl;
609 answerLog <<
" string value: " << (s.empty() ?
"''" : s) << std::endl;
613 for (std::vector<std::string>::iterator i = s.begin(); i != s.end(); ++i) {
614 if (i != s.begin()) {
622 answerLog <<
" compound value with " << no <<
" members: [";
623 for (
int i = 0; i < no; ++i) {
625 answerLog <<
" valueDataType=" << currentValueDataType;
632 answerLog <<
" position value: (" << xv <<
"," << yv <<
")" << std::endl;
638 answerLog <<
" color value: (" << r <<
"," << g <<
"," << b <<
"," << a <<
")" << std::endl;
640 answerLog <<
"#Error: unknown valueDataType!" << std::endl;
649 answerLog <<
" getVersion: " << version.first <<
", " << version.second <<
"\n";
656 const std::string edgeID =
"e_m0";
657 edge.adaptTraveltime(edgeID, 42, 0, 10);
658 edge.setEffort(edgeID, 420, 0, 10);
659 answerLog <<
" currentTraveltime: " <<
edge.getTraveltime(edgeID) <<
"\n";
660 answerLog <<
" adaptedTravelTime: " <<
edge.getAdaptedTraveltime(edgeID, 0) <<
"\n";
661 answerLog <<
" effort: " <<
edge.getEffort(edgeID, 0) <<
"\n";
662 answerLog <<
" laneNumber: " <<
edge.getLaneNumber(edgeID) <<
"\n";
663 answerLog <<
" streetName: " <<
edge.getStreetName(edgeID) <<
"\n";
664 edge.setMaxSpeed(edgeID, 42);
665 answerLog <<
" maxSpeed: " <<
lane.getMaxSpeed(edgeID +
"_0") <<
"\n";
671 const std::string laneID =
"e_m6_0";
672 answerLog <<
" getLinkNumber: " <<
lane.getLinkNumber(laneID) <<
"\n";
673 std::vector<libsumo::TraCIConnection> connections =
lane.getLinks(laneID);
675 for (
int i = 0; i < (int)connections.size(); ++i) {
682 <<
" state=" << c.
state
692 answerLog <<
" caught TraCIException(" << e.what() <<
")\n";
696 answerLog <<
" getInternalFoes (invalid): ";
699 answerLog <<
" caught TraCIException(" << e.what() <<
")\n";
701 lane.setMaxSpeed(laneID, 42);
702 answerLog <<
" maxSpeed: " <<
lane.getMaxSpeed(laneID) <<
"\n";
706 answerLog <<
" getIDCount: " <<
poi.getIDCount() <<
"\n";
707 answerLog <<
" getPosition: " <<
poi.getPosition(
"poi0").getString() <<
"\n";
708 answerLog <<
" getColor: " <<
poi.getColor(
"poi0").getString() <<
"\n";
715 polygon.setLineWidth(
"poly0", 0.6);
718 answerLog <<
" getColor: " <<
polygon.getColor(
"poly0").getString() <<
"\n";
719 shape.
value[0].x = 42;
720 polygon.setShape(
"poly0", shape);
721 answerLog <<
" getShape after modification: " <<
polygon.getShape(
"poly0").getString() <<
"\n";
732 std::vector<std::string> edges;
733 edges.push_back(
"e_u1");
734 edges.push_back(
"e_u0");
735 route.add(
"e_u1", edges);
737 edges.push_back(
"e_m4");
738 route.add(
"e_m4", edges);
759 answerLog <<
" copy type 't1' to 't1_copy' and set accel to 100.\n";
769 std::vector<std::string> via;
770 via.push_back(
"e_shape1");
772 vehicle.setType(
"0",
"t1_copy");
778 answerLog <<
" getLateralLanePosition: " <<
vehicle.getLateralLanePosition(
"0") <<
"\n";
783 answerLog <<
" getFollowSpeed: " <<
vehicle.getFollowSpeed(
"0", 10, 20, 9, 4.5) <<
"\n";
784 answerLog <<
" getSecureGap: " <<
vehicle.getSecureGap(
"0", 10, 9, 4.5) <<
"\n";
785 answerLog <<
" getStopSpeed: " <<
vehicle.getStopSpeed(
"0", 10, 20) <<
"\n";
791 answerLog <<
" getPersonCapacity: " <<
vehicle.getPersonCapacity(
"0") <<
"\n";
797 vehicle.setParameter(
"0",
"meaningOfLife",
"42");
798 answerLog <<
" param: " <<
vehicle.getParameter(
"0",
"meaningOfLife") <<
"\n";
799 std::pair<std::string, std::string> paramTuple =
vehicle.getParameterWithKey(
"0",
"meaningOfLife");
800 answerLog <<
" parameterWithKey: (" << paramTuple.first <<
", " << paramTuple.second <<
")\n";
808 answerLog <<
" getColor: r=" << (int)col2.
r <<
" g=" << (
int)col2.
g <<
" b=" << (int)col2.
b <<
" a=" << (
int)col2.
a <<
"\n";
809 int signals =
vehicle.getSignals(
"0");
810 answerLog <<
" getSignals: " << signals <<
"\n";
815 std::vector<libsumo::TraCINextTLSData> result =
vehicle.getNextTLS(
"0");
816 for (
int i = 0; i < (int)result.size(); ++i) {
821 vehicle.moveToXY(
"0",
"dummy", 0, 2231.61, 498.29, 90, 1);
826 vehicle.changeTarget(
"0",
"e_o0");
827 std::vector<std::string> edges2 =
vehicle.getRoute(
"0");
829 vehicle.setRouteID(
"0",
"e_m4");
836 vehicle.moveTo(
"2",
"e_u0_0", 5);
840 answerLog <<
" getAccumulatedWaitingTime: " <<
vehicle.getAccumulatedWaitingTime(
"0") <<
"\n";
841 vehicle.setShapeClass(
"0",
"bicycle");
843 std::pair<std::string, double> leader =
vehicle.getLeader(
"1", 1000);
844 answerLog <<
" getLeader: " << leader.first <<
", " << leader.second <<
"\n";
845 std::pair<std::string, double> follower =
vehicle.getFollower(
"1", 1000);
846 answerLog <<
" getFollower: " << follower.first <<
", " << follower.second <<
"\n";
847 std::pair<int, int> state =
vehicle.getLaneChangeState(
"1", 1);
848 answerLog <<
" getLaneChangeState (left): " << state.first <<
", " << state.second <<
"\n";
849 state =
vehicle.getLaneChangeState(
"1", -1);
850 answerLog <<
" getLaneChangeState (right): " << state.first <<
", " << state.second <<
"\n";
851 vehicle.rerouteTraveltime(
"0");
852 vehicle.setSpeedFactor(
"0", 0.8);
854 answerLog <<
" getSpeedMode after change: " <<
vehicle.getSpeedMode(
"0") <<
"\n";
855 vehicle.setLaneChangeMode(
"0", 0);
856 answerLog <<
" getLaneChangeMode after change: " <<
vehicle.getLaneChangeMode(
"0") <<
"\n";
865 std::vector<libsumo::TraCIVehicleData> result2 =
inductionloop.getVehicleData(
"det1");
866 for (
int i = 0; i < (int)result2.size(); ++i) {
883 answerLog <<
" convert2DGeo: " <<
simulation.convert2D(
"e_m5", 0, 0,
true).getString() <<
"\n";
885 answerLog <<
" convert3DGeo: " <<
simulation.convert3D(
"e_m5", 0, 0,
true).getString() <<
"\n";
887 answerLog <<
" convertRoadBus: " <<
simulation.convertRoad(2500, 500,
false,
"bus").getString() <<
"\n";
889 answerLog <<
" convertCartesian: " <<
simulation.convertGeo(12, 52,
true).getString() <<
"\n";
890 answerLog <<
" getDistance2D_air: " <<
simulation.getDistance2D(2500, 500, 2000, 500,
false,
false) <<
"\n";
891 answerLog <<
" getDistance2D_driving: " <<
simulation.getDistance2D(2500, 500, 2000, 500,
false,
true) <<
"\n";
892 answerLog <<
" getDistanceRoad_air: " <<
simulation.getDistanceRoad(
"e_m5", 0,
"e_m4", 0,
false) <<
"\n";
893 answerLog <<
" getDistanceRoad_driving: " <<
simulation.getDistanceRoad(
"e_m5", 0,
"e_m4", 0,
true) <<
"\n";
896 answerLog <<
" parkingArea param: " <<
simulation.getParameter(
"park1",
"parkingArea.capacity") <<
"\n";
899 simulation.writeMessage(
"custom message test");
900 answerLog <<
" subscribe to road and pos of vehicle '1':\n";
902 std::vector<int> vars;
905 vehicle.subscribe(
"1", vars, 0, 100);
911 answerLog <<
" subscribe to vehicles around edge 'e_u1':\n";
912 std::vector<int> vars2;
916 answerLog <<
" context subscription results:\n";
918 for (libsumo::SubscriptionResults::iterator it = result4.begin(); it != result4.end(); ++it) {
922 answerLog <<
" subscribe to vehicles around vehicle '1':\n";
923 std::vector<int> vars3;
926 vehicle.addSubscriptionFilterLanes(std::vector<int>({0, 1, 2}));
927 vehicle.addSubscriptionFilterNoOpposite();
928 vehicle.addSubscriptionFilterDownstreamDistance(1000);
929 vehicle.addSubscriptionFilterUpstreamDistance(1000);
930 vehicle.addSubscriptionFilterCFManeuver();
931 vehicle.addSubscriptionFilterLeadFollow(std::vector<int>({0, 1, 2}));
932 vehicle.addSubscriptionFilterTurn();
933 vehicle.addSubscriptionFilterVClass(std::vector<std::string>({
"passenger"}));
934 vehicle.addSubscriptionFilterVType(std::vector<std::string>({
"DEFAULT_VEHTYPE"}));
935 vehicle.addSubscriptionFilterLCManeuver(1);
938 vehicle.addSubscriptionFilterFieldOfVision(90);
941 vehicle.addSubscriptionFilterLateralDistance(50);
945 answerLog <<
" context subscription results:\n";
947 for (
auto item : result5) {
948 answerLog <<
" vehicle=" << item.first <<
"\n";
954 person.setMinGap(
"p0", 2);
955 person.setLength(
"p0", 3);
956 person.setHeight(
"p0", 4);
957 person.setColor(
"p0", col1);
958 person.setType(
"p0",
"stilts");
963 answerLog <<
" getWaitingTime: " <<
person.getWaitingTime(
"p0") <<
"\n";
965 answerLog <<
" getStage: " <<
person.getStage(
"p0").description <<
"\n";
966 answerLog <<
" getRemainingStages: " <<
person.getRemainingStages(
"p0") <<
"\n";
969 answerLog <<
" getPosition: " <<
person.getPosition(
"p0").getString() <<
"\n";
970 answerLog <<
" getPosition3D: " <<
person.getPosition3D(
"p0").getString() <<
"\n";
973 answerLog <<
" getLanePosition: " <<
person.getLanePosition(
"p0") <<
"\n";
975 answerLog <<
" getColor: " <<
person.getColor(
"p0").getString() <<
"\n";
976 person.setParameter(
"p0",
"foo",
"bar");
981 person.add(
"p1",
"e_u1", 10);
982 std::vector<std::string> walkEdges;
983 walkEdges.push_back(
"e_u1");
984 walkEdges.push_back(
"e_shape1");
985 person.appendWalkingStage(
"p1", walkEdges, -20);
986 person.appendWaitingStage(
"p1", 5);
987 person.appendDrivingStage(
"p1",
"e_vu2",
"BusLine42");
989 stage.
edges.push_back(
"e_vu2");
990 stage.
edges.push_back(
"e_vo2");
992 person.appendStage(
"p1", stage);
995 answerLog <<
" getRemainingStages: " <<
person.getRemainingStages(
"p1") <<
"\n";
996 person.removeStage(
"p1", 3);
997 answerLog <<
" getRemainingStages: " <<
person.getRemainingStages(
"p1") <<
"\n";
998 person.removeStages(
"p1");
999 answerLog <<
" getRemainingStages: " <<
person.getRemainingStages(
"p1") <<
"\n";
1000 answerLog <<
" getStage: " <<
person.getStage(
"p1").description <<
"\n";
1001 walkEdges.push_back(
"e_m5");
1002 person.appendWalkingStage(
"p1", walkEdges, -20);
1005 person.rerouteTraveltime(
"p1");
1021 std::vector<std::vector<libsumo::TraCILink> > links =
trafficlights.getControlledLinks(
"n_m4");
1023 for (
int i = 0; i < (int)links.size(); ++i) {
1024 for (
int j = 0; j < (int)links[i].size(); ++j) {
1025 answerLog <<
" index=" << i <<
" link=" << j <<
" fromLane=" << links[i][j].fromLane <<
" viaLane=" << links[i][j].viaLane <<
" toLane=" << links[i][j].toLane <<
"\n";
1029 logic.
phases.push_back(std::make_shared<libsumo::TraCIPhase>(5,
"rrrrrrr", 5, 5));
1030 logic.
phases.push_back(std::make_shared<libsumo::TraCIPhase>(10,
"ggggggg", 5, 15));
1031 logic.
phases.push_back(std::make_shared<libsumo::TraCIPhase>(3,
"GGGGGGG", 3, 3));
1032 logic.
phases.push_back(std::make_shared<libsumo::TraCIPhase>(3,
"yyyyyyy", 3, 3));
1035 std::vector<libsumo::TraCILogic> logics =
trafficlights.getAllProgramLogics(
"n_m4");
1037 for (
int i = 0; i < (int)logics.size(); ++i) {
1038 answerLog <<
" subID=" << logics[i].programID <<
" type=" << logics[i].type <<
" phase=" << logics[i].currentPhaseIndex <<
"\n";
1040 for (
int j = 0; j < (int)logics[i].phases.size(); ++j) {
1041 answerLog <<
" phase=" << logics[i].phases[j]->state
1042 <<
" dur=" << logics[i].phases[j]->duration
1043 <<
" minDur=" << logics[i].phases[j]->minDur
1044 <<
" maxDur=" << logics[i].phases[j]->maxDur
1057 gui.setSchema(
"View #0",
"real world");
1058 answerLog <<
" getScheme: " <<
gui.getSchema(
"View #0") <<
"\n";
1059 gui.setZoom(
"View #0", 50);
1062 gui.screenshot(
"View #0",
"image.png", 500, 500);
1064 answerLog <<
" no support for gui commands\n";
1068 std::vector<std::string> args;
1069 args.push_back(
"-n");
1070 args.push_back(
"net.net.xml");
1071 args.push_back(
"-r");
1072 args.push_back(
"input_routes.rou.xml");
1073 args.push_back(
"-a");
1074 args.push_back(
"input_additional.add.xml");
1075 args.push_back(
"--no-step-log");
1079 vehicle.subscribe(
"0", vars, 0, 100);
RouteScope route
Scope for interaction with routes.
std::pair< int, std::string > getVersion()
return TraCI API and SUMO version
void setOrder(int order)
set priority (execution order) for the client
VehicleTypeScope vehicletype
Scope for interaction with vehicle types.
void send_commandSubscribeObjectVariable(int domID, const std::string &objID, double beginTime, double endTime, const std::vector< int > &vars) const
Sends a SubscribeVariable request.
void send_commandSimulationStep(double time) const
Sends a SimulationStep command.
GUIScope gui
Scope for interaction with the gui.
void check_resultState(tcpip::Storage &inMsg, int command, bool ignoreCommandId=false, std::string *acknowledgement=0) const
Validates the result state of a command.
PolygonScope polygon
Scope for interaction with polygons.
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
tcpip::Socket * mySocket
The socket.
void load(const std::vector< std::string > &args)
Let sumo load a simulation using the given command line like options.
void simulationStep(double time=0)
Advances by one step (or up to the given time).
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...
LaneScope lane
Scope for interaction with lanes.
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.
TrafficLightScope trafficlights
Scope for interaction with traffic lights.
InductionLoopScope inductionloop
Scope for interaction with inductive loops.
tcpip::Storage myOutput
The reusable output storage.
POIScope poi
Scope for interaction with POIs.
void closeSocket()
Closes the connection.
int check_commandGetResult(tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const
Validates the result state of a command.
VehicleScope vehicle
Scope for interaction with vehicles.
JunctionScope junction
Scope for interaction with junctions.
void send_commandClose() const
Sends a Close command.
void send_commandSetOrder(int order) const
Sends a SetOrder command.
EdgeScope edge
Scope for interaction with edges.
SimulationScope simulation
Scope for interaction with the simulation.
PersonScope person
Scope for interaction with persons.
void readAndReportTypeDependent(tcpip::Storage &inMsg, int valueDataType)
Reads a value of the given type from the given storage and reports it.
std::string joinToString(const std::vector< std::string > &s, const std::string &between)
void commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *addData=0)
Sends and validates a GetVariable command.
void testAPI()
call all API methods once
~TraCITestClient()
Destructor.
void commandSetValue(int domID, int varID, const std::string &objID, std::ifstream &defFile)
Sends and validates a SetVariable command.
int run(std::string fileName, int port, std::string host="localhost")
Runs a test.
std::string outputFileName
The name of the file to write the results log into.
void writeResult()
Writes the results file.
int setValueTypeDependant(tcpip::Storage &into, std::ifstream &defFile, std::stringstream &msg)
Parses the next value type / value pair from the stream and inserts it into the storage.
bool validateSubscription(tcpip::Storage &inMsg)
Validates whether the given message is a valid subscription return message.
void errorMsg(std::stringstream &msg)
Writes an error message.
bool validateSimulationStep2(tcpip::Storage &inMsg)
Validates whether the given message is a valid answer to CMD_SIMSTEP.
TraCITestClient(std::string outputFileName="testclient_result.out")
Constructor.
void commandSetOrder(int order)
Sends and validates a SetOrder command.
std::stringstream answerLog
Stream containing the log.
void commandSubscribeContextVariable(int domID, const std::string &objID, double beginTime, double endTime, int domain, double range, int varNo, std::ifstream &defFile)
Sends and validates a SubscribeContext command.
void commandSubscribeObjectVariable(int domID, const std::string &objID, double beginTime, double endTime, int varNo, std::ifstream &defFile)
Sends and validates a SubscribeVariable command.
void commandClose()
Sends and validates a Close command.
void commandSimulationStep(double time)
Sends and validates a simulation step command.
An error which allows to continue.
virtual std::string readString()
virtual void writeString(const std::string &s)
virtual void writeInt(int)
virtual void writeDouble(double)
virtual int readUnsignedByte()
virtual void writeStringList(const std::vector< std::string > &s)
virtual void writeUnsignedByte(int)
virtual void writeByte(int)
virtual std::vector< std::string > readStringList()
virtual double readDouble()
TRACI_CONST int RESPONSE_SUBSCRIBE_GUI_VARIABLE
TRACI_CONST int TYPE_COLOR
TRACI_CONST int POSITION_3D
TRACI_CONST int POSITION_ROADMAP
TRACI_CONST int VAR_ROAD_ID
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int TYPE_UBYTE
TRACI_CONST int RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
TRACI_CONST int POSITION_2D
TRACI_CONST int ROUTING_MODE_AGGREGATED
TRACI_CONST int CMD_CLOSE
TRACI_CONST int TYPE_POLYGON
TRACI_CONST int CMD_SETORDER
TRACI_CONST int TYPE_STRINGLIST
TRACI_CONST int TYPE_INTEGER
std::map< std::string, libsumo::TraCIResults > SubscriptionResults
{object->{variable->value}}
TRACI_CONST int VAR_LANEPOSITION
TRACI_CONST int REQUEST_DRIVINGDIST
TRACI_CONST int STAGE_WALKING
TRACI_CONST int VAR_SPEED
TRACI_CONST int TYPE_DOUBLE
TRACI_CONST int TYPE_BYTE
TRACI_CONST int REQUEST_AIRDIST
TRACI_CONST int CMD_SIMSTEP
TRACI_CONST int RESPONSE_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
std::map< int, std::shared_ptr< libsumo::TraCIResult > > TraCIResults
{variable->value}
TRACI_CONST int RESPONSE_SUBSCRIBE_GUI_CONTEXT
TRACI_CONST int TYPE_STRING
std::string approachedLane
std::string approachedInternal
std::vector< std::shared_ptr< libsumo::TraCIPhase > > phases
double dist
The distance to the tls.
int tlIndex
The tls index of the controlled link.
std::string id
The id of the next tls.
char state
The current state of the tls.
std::string getString() const override
std::vector< TraCIPosition > value
std::vector< std::string > edges
The sequence of edges to travel.
double arrivalPos
position on the lane when ending the stage
mirrors MSInductLoop::VehicleData
std::string id
The id of the vehicle.
double entryTime
Entry-time of the vehicle in [s].
std::string typeID
Type of the vehicle in.
double length
Length of the vehicle.
double leaveTime
Leave-time of the vehicle in [s].