 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
49 : outputFileName(outputFileName), answerLog(
"") {
50 answerLog.setf(std::ios::fixed, std::ios::floatfield);
63 std::ifstream defFile;
64 std::string fileContentStr;
65 std::stringstream fileContent;
66 std::string lineCommand;
67 std::stringstream msg;
69 bool commentRead =
false;
75 std::stringstream msg;
76 msg <<
"#Error while connecting: " << e.what();
82 defFile.open(fileName.c_str());
84 msg <<
"Can not open definition file " << fileName << std::endl;
88 defFile.unsetf(std::ios::dec);
90 while (defFile >> lineCommand) {
92 if (lineCommand.compare(
"%") == 0) {
94 commentRead = !commentRead;
101 if (lineCommand.compare(
"repeat") == 0) {
103 defFile >> lineCommand;
105 if (lineCommand.compare(
"simstep2") == 0) {
109 for (
int i = 0; i < repNo; i++) {
112 }
else if (lineCommand.compare(
"getvariable") == 0) {
116 defFile >> domID >> varID >> objID;
118 }
else if (lineCommand.compare(
"getvariable_plus") == 0) {
122 defFile >> domID >> varID >> objID;
123 std::stringstream msg;
126 std::string msgS = msg.str();
131 }
else if (lineCommand.compare(
"subscribevariable") == 0) {
134 double beginTime, endTime;
136 defFile >> domID >> objID >> beginTime >> endTime >> varNo;
138 }
else if (lineCommand.compare(
"subscribecontext") == 0) {
140 int domID, varNo, domain;
142 double beginTime, endTime;
144 defFile >> domID >> objID >> beginTime >> endTime >> domain >> range >> varNo;
146 }
else if (lineCommand.compare(
"setvalue") == 0) {
150 defFile >> domID >> varID >> objID;
152 }
else if (lineCommand.compare(
"testAPI") == 0) {
155 }
else if (lineCommand.compare(
"setorder") == 0) {
161 msg <<
"Error in definition file: " << lineCommand <<
" is not a valid command";
180 answerLog << std::endl <<
"-> Command sent: <SimulationStep>:" << std::endl;
182 std::string acknowledgement;
184 answerLog << acknowledgement << std::endl;
196 answerLog << std::endl <<
"-> Command sent: <Close>:" << std::endl;
198 std::string acknowledgement;
200 answerLog << acknowledgement << std::endl;
211 answerLog << std::endl <<
"-> Command sent: <SetOrder>:" << std::endl;
213 std::string acknowledgement;
215 answerLog << acknowledgement << std::endl;
228 answerLog << std::endl <<
"-> Command sent: <GetVariable>:" << std::endl
229 <<
" domID=" << domID <<
" varID=" << varID
230 <<
" objID=" << objID << std::endl;
231 std::string acknowledgement;
233 answerLog << acknowledgement << std::endl;
243 answerLog <<
" CommandID=" << (domID + 0x10) <<
" VariableID=" << variableID <<
" ObjectID=" << objectID;
245 answerLog <<
" valueDataType=" << valueDataType;
248 std::stringstream msg;
249 msg <<
"Error while receiving command: " << e.what();
258 std::stringstream msg;
261 std::string msgS = msg.str();
267 answerLog << std::endl <<
"-> Command sent: <SetValue>:" << std::endl
268 <<
" domID=" << domID <<
" varID=" << varID
269 <<
" objID=" << objID << std::endl;
271 std::string acknowledgement;
273 answerLog << acknowledgement << std::endl;
282 std::vector<int> vars;
283 for (
int i = 0; i < varNo; ++i) {
290 answerLog << std::endl <<
"-> Command sent: <SubscribeVariable>:" << std::endl
291 <<
" domID=" << domID <<
" objID=" << objID <<
" with " << varNo <<
" variables" << std::endl;
294 std::string acknowledgement;
296 answerLog << acknowledgement << std::endl;
306 int domain,
double range,
int varNo, std::ifstream& defFile) {
307 std::vector<int> vars;
308 for (
int i = 0; i < varNo; ++i) {
315 answerLog << std::endl <<
"-> Command sent: <SubscribeContext>:" << std::endl
316 <<
" domID=" << domID <<
" objID=" << objID <<
" domain=" << domain <<
" range=" << range
317 <<
" with " << varNo <<
" variables" << std::endl;
320 std::string acknowledgement;
322 answerLog << acknowledgement << std::endl;
337 std::cerr <<
"Unable to write result file" << std::endl;
340 locTime = localtime(&seconds);
341 outFile <<
"TraCITestClient output file. Date: " << asctime(locTime) << std::endl;
349 std::cerr << msg.str() << std::endl;
350 answerLog <<
"----" << std::endl << msg.str() << std::endl;
361 int noSubscriptions = inMsg.
readInt();
362 for (
int s = 0; s < noSubscriptions; ++s) {
367 }
catch (std::invalid_argument& e) {
368 answerLog <<
"#Error while reading message:" << e.what() << std::endl;
387 answerLog <<
" #variables=" << varNo << std::endl;
388 for (
int i = 0; i < varNo; ++i) {
393 answerLog <<
" valueDataType=" << valueDataType;
401 answerLog <<
" #variables=" << varNo << std::endl;
403 answerLog <<
" #objects=" << objNo << std::endl;
404 for (
int j = 0; j < objNo; ++j) {
406 for (
int i = 0; i < varNo; ++i) {
411 answerLog <<
" valueDataType=" << valueDataType;
416 answerLog <<
"#Error: received response with command id: " << cmdId <<
" but expected a subscription response (0xe0-0xef / 0x90-0x9f)" << std::endl;
419 }
catch (std::invalid_argument& e) {
420 answerLog <<
"#Error while reading message:" << e.what() << std::endl;
435 std::string dataTypeS;
436 defFile >> dataTypeS;
437 if (dataTypeS ==
"<airDist>") {
440 }
else if (dataTypeS ==
"<drivingDist>") {
443 }
else if (dataTypeS ==
"<objSubscription>") {
444 int beginTime, endTime, numVars;
445 defFile >> beginTime >> endTime >> numVars;
449 for (
int i = 0; i < numVars; ++i) {
454 return 4 + 4 + 4 + numVars;
458 if (dataTypeS ==
"<int>") {
463 }
else if (dataTypeS ==
"<byte>") {
468 }
else if (dataTypeS ==
"<ubyte>") {
473 }
else if (dataTypeS ==
"<double>") {
478 }
else if (dataTypeS ==
"<string>") {
481 if (valueS ==
"\"\"") {
486 return 4 + 1 + (int) valueS.length();
487 }
else if (dataTypeS ==
"<string*>") {
488 std::vector<std::string> slValue;
491 for (
int i = 0; i < valI; ++i) {
494 slValue.push_back(tmp);
495 length += 4 + int(tmp.length());
500 }
else if (dataTypeS ==
"<compound>") {
505 for (
int i = 0; i < valI; ++i) {
509 }
else if (dataTypeS ==
"<color>") {
513 for (
int i = 0; i < 3; ++i) {
518 }
else if (dataTypeS ==
"<position2D>") {
525 }
else if (dataTypeS ==
"<position3D>") {
533 return 1 + 8 + 8 + 8;
534 }
else if (dataTypeS ==
"<positionRoadmap>") {
539 int length = 1 + 8 + (int) valueS.length();
544 return length + 4 + 1;
545 }
else if (dataTypeS ==
"<shape>") {
550 for (
int i = 0; i < valI; ++i) {
559 msg <<
"## Unknown data type: " << dataTypeS;
568 answerLog <<
" Unsigned Byte Value: " << ubyte << std::endl;
571 answerLog <<
" Byte value: " <<
byte << std::endl;
574 answerLog <<
" Int value: " << integer << std::endl;
577 answerLog <<
" Double value: " << doublev << std::endl;
584 for (
int i = 0; i < size; i++) {
587 answerLog <<
"(" << x <<
"," << y <<
") ";
594 answerLog <<
" Position3DValue: " << std::endl;
596 <<
" z: " << z << std::endl;
601 answerLog <<
" RoadMapPositionValue: roadId=" << roadId
603 <<
" laneId=" << laneId << std::endl;
606 answerLog <<
" string value: " << s << std::endl;
609 answerLog <<
" string list value: [ " << std::endl;
610 for (std::vector<std::string>::iterator i = s.begin(); i != s.end(); ++i) {
611 if (i != s.begin()) {
619 answerLog <<
" compound value with " << no <<
" members: [ " << std::endl;
620 for (
int i = 0; i < no; ++i) {
622 answerLog <<
" valueDataType=" << currentValueDataType;
629 answerLog <<
" position value: (" << xv <<
"," << yv <<
")" << std::endl;
635 answerLog <<
" color value: (" << r <<
"," << g <<
"," << b <<
"," << a <<
")" << std::endl;
637 answerLog <<
"#Error: unknown valueDataType!" << std::endl;
651 const std::string edgeID =
"e_m0";
666 const std::string laneID =
"e_m6_0";
668 std::vector<libsumo::TraCIConnection> connections =
lane.
getLinks(laneID);
670 for (
int i = 0; i < (int)connections.size(); ++i) {
677 <<
" state=" << c.
state
687 answerLog <<
" caught TraCIException(" << e.what() <<
")\n";
691 answerLog <<
" getInternalFoes (invalid): ";
694 answerLog <<
" caught TraCIException(" << e.what() <<
")\n";
710 std::string shapeStr;
711 for (
auto pos : shape) {
712 shapeStr += pos.getString() +
" ";
716 answerLog <<
" getShape: " << shapeStr <<
"\n";
720 std::string shapeStr2;
722 shapeStr2 += pos.getString() +
" ";
724 answerLog <<
" getShape after modification: " << shapeStr2 <<
"\n";
730 std::vector<libsumo::TraCIPosition> junctionShape =
junction.
getShape(
"n_m4");
731 std::string junctionShapeStr;
732 for (
auto pos : junctionShape) {
733 junctionShapeStr += pos.getString() +
" ";
735 answerLog <<
" getShape: " << junctionShapeStr <<
"\n";
740 std::vector<std::string> edges;
741 edges.push_back(
"e_u1");
742 edges.push_back(
"e_u0");
745 edges.push_back(
"e_m4");
767 answerLog <<
" copy type 't1' to 't1_copy' and set accel to 100.\n";
777 std::vector<std::string> via;
778 via.push_back(
"e_shape1");
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) {
843 answerLog <<
" getLeader: " << leader.first <<
", " << leader.second <<
"\n";
845 answerLog <<
" getLaneChangeState (left): " << state.first <<
", " << state.second <<
"\n";
847 answerLog <<
" getLaneChangeState (right): " << state.first <<
", " << state.second <<
"\n";
859 for (
int i = 0; i < (int)result2.size(); ++i) {
884 answerLog <<
" subscribe to road and pos of vehicle '1':\n";
886 std::vector<int> vars;
895 answerLog <<
" subscribe to vehicles around edge 'e_u1':\n";
896 std::vector<int> vars2;
900 answerLog <<
" context subscription results:\n";
902 for (libsumo::SubscriptionResults::iterator it = result4.begin(); it != result4.end(); ++it) {
906 answerLog <<
" subscribe to vehicles around vehicle '1':\n";
907 std::vector<int> vars3;
926 answerLog <<
" context subscription results:\n";
928 for (
auto item : result5) {
929 answerLog <<
" vehicle=" << item.first <<
"\n";
962 std::vector<std::string> walkEdges;
963 walkEdges.push_back(
"e_u1");
964 walkEdges.push_back(
"e_shape1");
969 stage.
edges.push_back(
"e_vu2");
970 stage.
edges.push_back(
"e_vo2");
981 walkEdges.push_back(
"e_m5");
1002 for (
int i = 0; i < (int)links.size(); ++i) {
1003 for (
int j = 0; j < (int)links[i].size(); ++j) {
1004 answerLog <<
" index=" << i <<
" link=" << j <<
" fromLane=" << links[i][j].fromLane <<
" viaLane=" << links[i][j].viaLane <<
" toLane=" << links[i][j].toLane <<
"\n";
1015 for (
int i = 0; i < (int)logics.size(); ++i) {
1016 answerLog <<
" subID=" << logics[i].programID <<
" type=" << logics[i].type <<
" phase=" << logics[i].currentPhaseIndex <<
"\n";
1018 for (
int j = 0; j < (int)logics[i].phases.size(); ++j) {
1019 answerLog <<
" phase=" << logics[i].phases[j].state
1020 <<
" dur=" << logics[i].phases[j].duration
1021 <<
" minDur=" << logics[i].phases[j].minDur
1022 <<
" maxDur=" << logics[i].phases[j].maxDur
1033 std::vector<std::string> args;
1034 args.push_back(
"-n");
1035 args.push_back(
"net.net.xml");
1036 args.push_back(
"-r");
1037 args.push_back(
"input_routes.rou.xml");
1038 args.push_back(
"-a");
1039 args.push_back(
"input_additional.add.xml");
1040 args.push_back(
"--no-step-log");
1057 answerLog <<
" no support for gui commands\n";
std::pair< std::string, double > getLeader(const std::string &vehicleID, double dist) const
void setLength(const std::string &personID, double length) const
std::string getProgram(const std::string &tlsID) const
void addSubscriptionFilterNoOpposite() const
virtual double readDouble()
double getHeight(const std::string &typeID) const
std::vector< std::string > getIDList() const
std::vector< std::string > getRoute(const std::string &vehicleID) const
void setType(const std::string &personID, const std::string &typeID) const
void changeTarget(const std::string &vehicleID, const std::string &edgeID) const
void setMaxSpeed(const std::string &vehicleID, double speed) const
std::string getSchema(const std::string &viewID=DEFAULT_VIEW) const
std::string getRoadID(const std::string &vehicleID) const
TRACI_CONST int TYPE_COLOR
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
void addSubscriptionFilterCFManeuver(double downstreamDist=-1, double upstreamDist=-1) const
double getMinGapLat(const std::string &typeID) const
double getAngle(const std::string &personID) const
double getMaxSpeedLat(const std::string &typeID) const
LaneScope lane
Scope for interaction with lanes.
std::vector< std::string > getIDList() const
std::vector< std::string > getInternalFoes(const std::string &laneID) const
std::vector< std::string > getFoes(const std::string &laneID, const std::string &toLaneID) const
libsumo::TraCIPosition getPosition(const std::string &poiID) const
std::vector< std::string > getIDList() const
TRACI_CONST int POSITION_3D
void moveTo(const std::string &vehicleID, const std::string &laneID, double position) const
TRACI_CONST int VAR_ROAD_ID
std::map< int, std::shared_ptr< TraCIResult > > TraCIResults
{variable->value}
libsumo::TraCIPosition getPosition(const std::string &personID) const
void setSpeedFactor(const std::string &vehicleID, double factor) const
std::string approachedInternal
const libsumo::SubscriptionResults getContextSubscriptionResults(const std::string &objID) const
void setRoutingMode(const std::string &vehicleID, int routingMode) const
TRACI_CONST int CMD_CLOSE
virtual void writeUnsignedByte(int)
JunctionScope junction
Scope for interaction with junctions.
void send_commandSetOrder(int order) const
Sends a SetOrder command.
void setPhase(const std::string &tlsID, int index) const
std::string getVehicle(const std::string &personID) const
virtual std::vector< std::string > readStringList()
TRACI_CONST int RESPONSE_SUBSCRIBE_GUI_VARIABLE
double getDistanceRoad(const std::string &edgeID1, double pos1, const std::string &edgeID2, double pos2, bool isDriving=false)
void commandSimulationStep(double time)
Sends and validates a simulation step command.
std::string getRedYellowGreenState(const std::string &tlsID) const
void subscribe(const std::string &objID, const std::vector< int > &vars, double beginTime, double endTime) const
PersonScope person
Scope for interaction with persons.
std::vector< std::string > getIDList() const
std::vector< libsumo::TraCIConnection > getLinks(const std::string &laneID) const
void addSubscriptionFilterTurn(double downstreamDist=-1, double upstreamDist=-1) const
void setOrder(int order)
set priority (execution order) for the client
double getSlope(const std::string &vehicleID) const
std::string outputFileName
The name of the file to write the results log into.
InductionLoopScope inductionloop
Scope for interaction with inductive loops.
double leaveTime
Leave-time of the vehicle in [s].
void remove(const std::string &vehicleID, char reason=libsumo::REMOVE_VAPORIZED) const
void setPhaseName(const std::string &tlsID, const std::string &name) const
std::vector< std::string > getIDList() const
double getLanePosition(const std::string &vehicleID) const
std::vector< std::vector< libsumo::TraCILink > > getControlledLinks(const std::string &tlsID) const
std::vector< std::string > getIDList() const
TRACI_CONST int TYPE_BYTE
double getWaitingTime(const std::string &personID) const
int tlIndex
The tls index of the controlled link.
void setSignals(const std::string &vehicleID, int signals) const
libsumo::TraCIStage getStage(const std::string &personID, int nextStageIndex=0) const
void addSubscriptionFilterVType(const std::vector< std::string > &vTypes) const
void rerouteTraveltime(const std::string &vehicleID, bool currentTravelTimes=true) const
mirrors MSInductLoop::VehicleData
double getMaxSpeed(const std::string &vehicleID) const
void setLine(const std::string &vehicleID, const std::string &line) const
std::vector< std::string > getBusStopWaitingIDList(const std::string &stopID) const
double dist
The distance to the tls.
~TraCITestClient()
Destructor.
void setWidth(const std::string &personID, double width) const
void rerouteTraveltime(const std::string &personID) const
TRACI_CONST int CMD_GET_VEHICLE_VARIABLE
double arrivalPos
position on the lane when ending the stage
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
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...
virtual void writeByte(int)
void commandSubscribeObjectVariable(int domID, const std::string &objID, double beginTime, double endTime, int varNo, std::ifstream &defFile)
Sends and validates a SubscribeVariable command.
void addSubscriptionFilterLCManeuver(int direction, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
void screenshot(const std::string &viewID, const std::string &filename, const int width=-1, const int height=-1) const
void appendDrivingStage(const std::string &personID, const std::string &toEdge, const std::string &lines, const std::string &stopID="")
std::string getParameter(const std::string &objectID, const std::string &key) const
retrieve generic paramter
double getLateralSpeed(const std::string &vehicleID) const
void load(const std::vector< std::string > &args)
Let sumo load a simulation using the given command line like options.
TRACI_CONST int CMD_SETORDER
void addSubscriptionFilterLeadFollow(const std::vector< int > &lanes) const
int run(std::string fileName, int port, std::string host="localhost")
Runs a test.
std::string getStreetName(const std::string &id) const
int getStopState(const std::string &vehicleID) const
void setHeight(const std::string &personID, double height) const
void writeResult()
Writes the results file.
void closeSocket()
Closes the connection.
char state
The current state of the tls.
void commandSetValue(int domID, int varID, const std::string &objID, std::ifstream &defFile)
Sends and validates a SetVariable command.
virtual int readUnsignedByte()
TRACI_CONST int RESPONSE_SUBSCRIBE_GUI_CONTEXT
virtual void writeInt(int)
void addSubscriptionFilterUpstreamDistance(double dist) const
void simulationStep(double time=0)
Advances by one step (or up to the given time)
TRACI_CONST int TYPE_DOUBLE
void setColor(const std::string &vehicleID, const libsumo::TraCIColor &c) const
TRACI_CONST int TYPE_POLYGON
void send_commandSubscribeObjectVariable(int domID, const std::string &objID, double beginTime, double endTime, const std::vector< int > &vars) const
Sends a SubscribeVariable request.
virtual std::string readString()
libsumo::TraCIPosition convert2D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
void setType(const std::string &vehicleID, const std::string &typeID) const
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 addSubscriptionFilterFieldOfVision(double angle) const
TrafficLightScope trafficlights
Scope for interaction with traffic lights.
double getNextSwitch(const std::string &tlsID) const
std::string description
arbitrary description string
void setSchema(const std::string &viewID, const std::string &schemeName) const
TRACI_CONST int TYPE_INTEGER
void addSubscriptionFilterDownstreamDistance(double dist) const
void addSubscriptionFilterLanes(const std::vector< int > &lanes, bool noOpposite=false, double downstreamDist=-1, double upstreamDist=-1) const
std::string typeID
Type of the vehicle in.
double getWidth(const std::string &typeID) const
std::vector< libsumo::TraCIVehicleData > getVehicleData(const std::string &loopID) const
double getLanePosition(const std::string &personID) const
virtual void writeStringList(const std::vector< std::string > &s)
void writeMessage(const std::string msg)
TRACI_CONST int STAGE_WALKING
libsumo::TraCIPosition convert3D(const std::string &edgeID, double pos, int laneIndex=0, bool toGeo=false) const
void setParameter(const std::string &objectID, const std::string &key, const std::string &value) const
set generic paramter
std::vector< std::string > getVia(const std::string &vehicleID) const
std::string getLateralAlignment(const std::string &typeID) const
int getPersonCapacity(const std::string &typeID) const
void setMinGap(const std::string &personID, double minGap) const
double getSpeed(const std::string &vehicleID) const
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.
void setMinGapLat(const std::string &typeID, double minGapLat) const
int getPhase(const std::string &tlsID) const
void setWidth(const std::string &typeID, double width) const
RouteScope route
Scope for interaction with routes.
void setZoom(const std::string &viewID, double zoom) const
void setHeight(const std::string &typeID, double height) const
void appendWalkingStage(const std::string &personID, const std::vector< std::string > &edges, double arrivalPos, double duration=-1, double speed=-1, const std::string &stopID="")
double getMaxSpeed(const std::string &laneID) const
std::string id
The id of the vehicle.
libsumo::TraCIPositionVector getShape(const std::string &junctionID) const
std::vector< libsumo::TraCILogic > getCompleteRedYellowGreenDefinition(const std::string &tlsID) const
std::string approachedLane
TRACI_CONST int POSITION_ROADMAP
void setVia(const std::string &vehicleID, const std::vector< std::string > &via) const
int getSignals(const std::string &vehicleID) const
SimulationScope simulation
Scope for interaction with the simulation.
void setShapeClass(const std::string &vehicleID, const std::string &clazz) const
double getPhaseDuration(const std::string &tlsID) const
std::string getNextEdge(const std::string &personID) const
double getLateralLanePosition(const std::string &vehicleID) const
int getCurrentTime() const
libsumo::TraCIColor getColor(const std::string &polygonID) const
libsumo::TraCIColor getColor(const std::string &personID) const
TRACI_CONST int RESPONSE_SUBSCRIBE_INDUCTIONLOOP_CONTEXT
void setLineWidth(const std::string &polygonID, const double lineWidth) const
double getWaitingTime(const std::string &vehicleID) const
void adaptTraveltime(const std::string &edgeID, double time, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
tcpip::Storage myOutput
The reusable output storage.
TRACI_CONST int TYPE_STRINGLIST
std::string getPhaseName(const std::string &tlsID) const
void removeStage(const std::string &personID, int nextStageIndex) const
libsumo::TraCIRoadPosition convertRoad(double x, double y, bool isGeo=false, const std::string &vClass="ignoring") const
double length
Length of the vehicle.
virtual void writeString(const std::string &s)
std::string getShapeClass(const std::string &vehicleID) const
std::string id
The id of the next tls.
std::string getRouteID(const std::string &vehicleID) const
std::vector< TraCIPhase > phases
TRACI_CONST int ROUTING_MODE_AGGREGATED
int check_commandGetResult(tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const
Validates the result state of a command.
std::string getLine(const std::string &vehicleID) const
bool validateSimulationStep2(tcpip::Storage &inMsg)
Validates whether the given message is a valid answer to CMD_SIMSTEP.
std::vector< std::string > getIDList() const
libsumo::TraCIColor getColor(const std::string &poiID) const
std::string getRoadID(const std::string &personID) const
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.
void readAndReportTypeDependent(tcpip::Storage &inMsg, int valueDataType)
Reads a value of the given type from the given storage and reports it.
double getDistance2D(double x1, double y1, double x2, double y2, bool isGeo=false, bool isDriving=false)
VehicleScope vehicle
Scope for interaction with vehicles.
void setEffort(const std::string &edgeID, double effort, double beginSeconds=0., double endSeconds=std::numeric_limits< double >::max()) const
TRACI_CONST int POSITION_2D
void setMaxSpeedLat(const std::string &typeID, double speed) const
double getApparentDecel(const std::string &typeID) const
double getAccumulatedWaitingTime(const std::string &vehicleID) const
void setAccel(const std::string &typeID, double accel) const
TRACI_CONST int TYPE_STRING
void copy(const std::string &origTypeID, const std::string &newTypeID) const
std::vector< std::string > edges
The sequence of edges to travel.
std::pair< int, int > getLaneChangeState(const std::string &vehicleID, int direction) const
void setCompleteRedYellowGreenDefinition(const std::string &tlsID, const libsumo::TraCILogic &logic) const
int getLaneNumber(const std::string &edgeID) const
bool isRouteValid(const std::string &vehicleID) const
void commandSetOrder(int order)
Sends and validates a SetOrder command.
double getAdaptedTraveltime(const std::string &edgeID, double time) const
PolygonScope polygon
Scope for interaction with polygons.
TRACI_CONST int VAR_LANEPOSITION
void commandClose()
Sends and validates a Close command.
void send_commandSimulationStep(double time) const
Sends a SimulationStep command.
void send_commandClose() const
Sends a Close command.
std::string getLaneID(const std::string &vehicleID) const
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=gPrecision)
void setRouteID(const std::string &vehicleID, const std::string &routeID) const
TRACI_CONST int TYPE_UBYTE
libsumo::TraCIPositionVector getShape(const std::string &polygonID) const
POIScope poi
Scope for interaction with POIs.
double getLength(const std::string &personID) const
bool validateSubscription(tcpip::Storage &inMsg)
Validates whether the given message is a valid subscription return message.
int getPersonCapacity(const std::string &vehicleID) const
void setShape(const std::string &polygonID, const libsumo::TraCIPositionVector &shape) const
TRACI_CONST int REQUEST_AIRDIST
double getZoom(const std::string &viewID=DEFAULT_VIEW) const
void setRoute(const std::string &vehicleID, const std::vector< std::string > &edge) const
double getAcceleration(const std::string &vehicleID) const
void removeStages(const std::string &personID) const
void setLateralAlignment(const std::string &typeID, const std::string &latAlignment) const
void setColor(const std::string &personID, 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
GUIScope gui
Scope for interaction with the gui.
int getSpeedMode(const std::string &vehicleID) const
void add(const std::string &routeID, const std::vector< std::string > &edges) const
void setEmergencyDecel(const std::string &typeID, double decel) const
std::vector< std::string > getIDList() const
TRACI_CONST int VAR_SPEED
void setMaxSpeed(const std::string &edgeID, double speed) const
std::stringstream answerLog
Stream containing the log.
virtual void writeDouble(double)
libsumo::TraCIStage findRoute(const std::string &fromEdge, const std::string &toEdge, const std::string &vType="", double pos=-1., int routingMode=0) const
libsumo::TraCIPosition convertGeo(double x, double y, bool fromGeo=false) const
void testAPI()
call all API methods once
double getTraveltime(const std::string &edgeID) const
std::string getTypeID(const std::string &vehicleID) const
std::vector< std::string > getIDList() const
TRACI_CONST int REQUEST_DRIVINGDIST
const libsumo::TraCIResults getSubscriptionResults(const std::string &objID) const
double getEmergencyDecel(const std::string &typeID) const
int getLinkNumber(const std::string &laneID) const
void sendExact(const Storage &)
void appendWaitingStage(const std::string &personID, double duration, const std::string &description="waiting", const std::string &stopID="")
TRACI_CONST int RESPONSE_SUBSCRIBE_INDUCTIONLOOP_VARIABLE
std::vector< std::string > getIDList() const
double getSlope(const std::string &personID) const
double getLineWidth(const std::string &polygonID) const
void setApparentDecel(const std::string &typeID, double decel) const
int getBusStopWaiting(const std::string &stopID) const
void setSpeed(const std::string &personID, double speed) const
std::vector< std::string > getIDList() const
void add(const std::string &personID, const std::string &edgeID, double pos, double depart=libsumo::DEPARTFLAG_NOW, const std::string typeID="DEFAULT_PEDTYPE")
tcpip::Socket * mySocket
The socket.
void subscribeContext(const std::string &objID, int domain, double range, const std::vector< int > &vars, double beginTime, double endTime) const
std::vector< libsumo::TraCINextTLSData > getNextTLS(const std::string &vehID) const
void check_resultState(tcpip::Storage &inMsg, int command, bool ignoreCommandId=false, std::string *acknowledgement=0) const
Validates the result state of a command.
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
void appendStage(const std::string &personID, const libsumo::TraCIStage &stage)
void commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *addData=0)
Sends and validates a GetVariable command.
int getRemainingStages(const std::string &personID) const
TraCITestClient(std::string outputFileName="testclient_result.out")
Constructor.
std::map< std::string, TraCIResults > SubscriptionResults
{object->{variable->value}}
std::string getTypeID(const std::string &personID) const
void errorMsg(std::stringstream &msg)
Writes an error message.
libsumo::TraCIPosition getPosition3D(const std::string &personID) const
double getAccel(const std::string &typeID) const
double getSpeed(const std::string &personID) const
double getEffort(const std::string &edgeID, double time) const
void addSubscriptionFilterVClass(const std::vector< std::string > &vClasses) const
TRACI_CONST int CMD_SIMSTEP
double entryTime
Entry-time of the vehicle in [s].
VehicleTypeScope vehicletype
Scope for interaction with vehicle types.
EdgeScope edge
Scope for interaction with edges.
int getRoutingMode(const std::string &vehicleID) const
void setMaxSpeed(const std::string &laneID, double speed) const
TRACI_CONST int TYPE_COMPOUND
libsumo::TraCIColor getColor(const std::string &vehicleID) const
std::vector< std::string > getEdges(const std::string &personID, int nextStageIndex=0) const