29#define _CRT_SECURE_NO_WARNINGS
31#pragma warning(disable:4820 4514 5045 4710)
54 : outputFileName(outputFileName), answerLog(
"") {
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";
671 const std::string laneID =
"e_m6_0";
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";
719 shape.
value[0].x = 42;
732 std::vector<std::string> edges;
733 edges.push_back(
"e_u1");
734 edges.push_back(
"e_u0");
737 edges.push_back(
"e_m4");
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");
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";
810 answerLog <<
" getSignals: " << signals <<
"\n";
816 for (
int i = 0; i < (int)result.size(); ++i) {
844 answerLog <<
" getLeader: " << leader.first <<
", " << leader.second <<
"\n";
846 answerLog <<
" getFollower: " << follower.first <<
", " << follower.second <<
"\n";
848 answerLog <<
" getLaneChangeState (left): " << state.first <<
", " << state.second <<
"\n";
850 answerLog <<
" getLaneChangeState (right): " << state.first <<
", " << state.second <<
"\n";
866 for (
int i = 0; i < (int)result2.size(); ++i) {
900 answerLog <<
" subscribe to road and pos of vehicle '1':\n";
902 std::vector<int> vars;
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;
945 answerLog <<
" context subscription results:\n";
947 for (
auto item : result5) {
948 answerLog <<
" vehicle=" << item.first <<
"\n";
982 std::vector<std::string> walkEdges;
983 walkEdges.push_back(
"e_u1");
984 walkEdges.push_back(
"e_shape1");
989 stage.
edges.push_back(
"e_vu2");
990 stage.
edges.push_back(
"e_vo2");
1001 walkEdges.push_back(
"e_m5");
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));
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
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");
void adaptTraveltime(const std::string &edgeID, double time, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
void setMaxSpeed(const std::string &edgeID, double speed) const
int getLaneNumber(const std::string &edgeID) const
void setEffort(const std::string &edgeID, double effort, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
double getTraveltime(const std::string &edgeID) const
std::string getStreetName(const std::string &id) const
double getAdaptedTraveltime(const std::string &edgeID, double time) const
double getEffort(const std::string &edgeID, double time) const
std::string getSchema(const std::string &viewID=DEFAULT_VIEW) const
void setZoom(const std::string &viewID, double zoom) const
void setSchema(const std::string &viewID, const std::string &schemeName) const
double getZoom(const std::string &viewID=DEFAULT_VIEW) const
void screenshot(const std::string &viewID, const std::string &filename, const int width=-1, const int height=-1) const
std::vector< libsumo::TraCIVehicleData > getVehicleData(const std::string &loopID) const
libsumo::TraCIPositionVector getShape(const std::string &junctionID) const
int getLinkNumber(const std::string &laneID) const
void setMaxSpeed(const std::string &laneID, double speed) const
std::vector< std::string > getInternalFoes(const std::string &laneID) const
std::vector< libsumo::TraCIConnection > getLinks(const std::string &laneID) const
double getMaxSpeed(const std::string &laneID) const
std::vector< std::string > getFoes(const std::string &laneID, const std::string &toLaneID) const
libsumo::TraCIColor getColor(const std::string &poiID) const
libsumo::TraCIPosition getPosition(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
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 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
libsumo::TraCIPosition getPosition(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
libsumo::TraCIPositionVector getShape(const std::string &polygonID) const
double getLineWidth(const std::string &polygonID) const
void setLineWidth(const std::string &polygonID, const double lineWidth) const
void setShape(const std::string &polygonID, const libsumo::TraCIPositionVector &shape) 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
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
int getCurrentTime() const
std::vector< std::string > getBusStopWaitingIDList(const std::string &stopID) const
double getDistanceRoad(const std::string &edgeID1, double pos1, const std::string &edgeID2, double pos2, bool isDriving=false)
std::string getOption(const std::string &option) 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
const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string &objID) 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
std::vector< std::string > getIDList() const
const libsumo::TraCIResults getSubscriptionResults(const std::string &objID) 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
void subscribe(const std::string &objID, const std::vector< int > &vars, double beginTime, double endTime) 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 setProgramLogic(const std::string &tlsID, const libsumo::TraCILogic &logic) const
std::vector< libsumo::TraCINextTLSData > getNextTLS(const std::string &vehID) const
double getLateralSpeed(const std::string &vehicleID) const
void setMaxSpeed(const std::string &vehicleID, double speed) 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
void changeTarget(const std::string &vehicleID, const std::string &edgeID) const
bool isRouteValid(const std::string &vehicleID) 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 remove(const std::string &vehicleID, char reason=libsumo::REMOVE_VAPORIZED) const
void moveTo(const std::string &vehicleID, const std::string &laneID, double position, int reason=libsumo::MOVE_TELEPORT) const
void setRouteID(const std::string &vehicleID, const std::string &routeID) const
std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction) 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
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 addSubscriptionFilterLanes(const std::vector< int > &lanes, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) 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
std::string getLaneID(const std::string &vehicleID) const
void addSubscriptionFilterDownstreamDistance(double dist) const
double getStopDelay(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
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
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
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 getMaxSpeed(const std::string &vehicleID) const
int getRoutingMode(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
void setSpeedMode(const std::string &vehicleID, int mode) const
std::string getTypeID(const std::string &vehicleID) const
double getAccumulatedWaitingTime(const std::string &vehicleID) const
void rerouteTraveltime(const std::string &vehicleID, bool currentTravelTimes=true) const
double getStopSpeed(const std::string &vehicleID, double speed, double gap) const
void setApparentDecel(const std::string &typeID, double decel) const
void setHeight(const std::string &typeID, double height) 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 setWidth(const std::string &typeID, double width) const
double getApparentDecel(const std::string &typeID) const
void setLateralAlignment(const std::string &typeID, const std::string &latAlignment) const
double getMaxSpeedLat(const std::string &typeID) const
double getEmergencyDecel(const std::string &typeID) const
double getWidth(const std::string &typeID) const
void setAccel(const std::string &typeID, double accel) const
double getAccel(const std::string &typeID) const
double getHeight(const std::string &typeID) const
void setEmergencyDecel(const std::string &typeID, double decel) 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
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.
std::string approachedLane
std::string approachedInternal
An error which allows to continue.
std::vector< std::shared_ptr< libsumo::TraCIPhase > > phases
std::string description
arbitrary description string
std::vector< std::string > edges
The sequence of edges to travel.
double arrivalPos
position on the lane when ending the stage
void sendExact(const Storage &)
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 getString() const
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
std::string getString() const
std::vector< TraCIPosition > value
std::string getString() const
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].