46 #define DEFAULT_VIEW "View #0" 105 : duration(_duration), duration1(_duration1), duration2(_duration2), phase(_phase) {}
115 TraCILogic(
const std::string& _subID,
int _type,
const std::map<std::string, SUMOReal>& _subParameter,
int _currentPhaseIndex,
const std::vector<TraCIPhase>& _phases)
116 : subID(_subID), type(_type), subParameter(_subParameter), currentPhaseIndex(_currentPhaseIndex), phases(_phases) {}
128 TraCILink(
const std::string& _from,
const std::string& _via,
const std::string& _to)
129 : from(_from), via(_via), to(_to) {}
158 void connect(
const std::string& host,
int port);
230 std::vector<std::string> getIDList()
const;
231 int getIDCount()
const;
232 SUMOReal getAdaptedTraveltime(
const std::string& edgeID,
SUMOTime time)
const;
234 SUMOReal getCO2Emission(
const std::string& edgeID)
const;
235 SUMOReal getCOEmission(
const std::string& edgeID)
const;
236 SUMOReal getHCEmission(
const std::string& edgeID)
const;
237 SUMOReal getPMxEmission(
const std::string& edgeID)
const;
238 SUMOReal getNOxEmission(
const std::string& edgeID)
const;
239 SUMOReal getFuelConsumption(
const std::string& edgeID)
const;
240 SUMOReal getNoiseEmission(
const std::string& edgeID)
const;
241 SUMOReal getElectricityConsumption(
const std::string& edgeID)
const;
242 SUMOReal getLastStepMeanSpeed(
const std::string& edgeID)
const;
243 SUMOReal getLastStepOccupancy(
const std::string& edgeID)
const;
244 SUMOReal getLastStepLength(
const std::string& edgeID)
const;
245 SUMOReal getTraveltime(
const std::string& edgeID)
const;
246 int getLastStepVehicleNumber(
const std::string& edgeID)
const;
247 SUMOReal getLastStepHaltingNumber(
const std::string& edgeID)
const;
248 std::vector<std::string> getLastStepVehicleIDs(
const std::string& edgeID)
const;
250 void adaptTraveltime(
const std::string& edgeID,
SUMOReal time)
const;
251 void setEffort(
const std::string& edgeID,
SUMOReal effort)
const;
252 void setMaxSpeed(
const std::string& edgeID,
SUMOReal speed)
const;
275 std::vector<std::string> getIDList()
const;
278 std::string getSchema(
const std::string& viewID =
DEFAULT_VIEW)
const;
280 void setZoom(
const std::string& viewID,
SUMOReal zoom)
const;
282 void setSchema(
const std::string& viewID,
const std::string& schemeName)
const;
284 void screenshot(
const std::string& viewID,
const std::string& filename)
const;
285 void trackVehicle(
const std::string& viewID,
const std::string& vehID)
const;
324 std::vector<std::string> getIDList()
const;
326 std::string getLaneID(
const std::string& loopID)
const;
327 int getLastStepVehicleNumber(
const std::string& loopID)
const;
328 SUMOReal getLastStepMeanSpeed(
const std::string& loopID)
const;
329 std::vector<std::string> getLastStepVehicleIDs(
const std::string& loopID)
const;
330 SUMOReal getLastStepOccupancy(
const std::string& loopID)
const;
331 SUMOReal getLastStepMeanLength(
const std::string& loopID)
const;
332 SUMOReal getTimeSinceDetection(
const std::string& loopID)
const;
333 std::vector<VehicleData> getVehicleData(
const std::string& loopID)
const;
357 std::vector<std::string> getIDList()
const;
381 std::vector<std::string> getIDList()
const;
382 SUMOReal getLength(
const std::string& laneID)
const;
383 SUMOReal getMaxSpeed(
const std::string& laneID)
const;
384 SUMOReal getWidth(
const std::string& laneID)
const;
385 std::vector<std::string> getAllowed(
const std::string& laneID)
const;
386 std::vector<std::string> getDisallowed(
const std::string& laneID)
const;
387 int getLinkNumber(
const std::string& laneID)
const;
388 TraCIPositionVector getShape(
const std::string& laneID)
const;
389 std::string getEdgeID(
const std::string& laneID)
const;
390 SUMOReal getCO2Emission(
const std::string& laneID)
const;
391 SUMOReal getCOEmission(
const std::string& laneID)
const;
392 SUMOReal getHCEmission(
const std::string& laneID)
const;
393 SUMOReal getPMxEmission(
const std::string& laneID)
const;
394 SUMOReal getNOxEmission(
const std::string& laneID)
const;
395 SUMOReal getFuelConsumption(
const std::string& laneID)
const;
396 SUMOReal getNoiseEmission(
const std::string& laneID)
const;
397 SUMOReal getElectricityConsumption(
const std::string& laneID)
const;
398 SUMOReal getLastStepMeanSpeed(
const std::string& laneID)
const;
399 SUMOReal getLastStepOccupancy(
const std::string& laneID)
const;
400 SUMOReal getLastStepLength(
const std::string& laneID)
const;
401 SUMOReal getTraveltime(
const std::string& laneID)
const;
402 int getLastStepVehicleNumber(
const std::string& laneID)
const;
403 int getLastStepHaltingNumber(
const std::string& laneID)
const;
404 std::vector<std::string> getLastStepVehicleIDs(
const std::string& laneID)
const;
406 void setAllowed(
const std::string& laneID,
const std::vector<std::string>& allowedClasses)
const;
407 void setDisallowed(
const std::string& laneID,
const std::vector<std::string>& disallowedClasses)
const;
408 void setMaxSpeed(
const std::string& laneID,
SUMOReal speed)
const;
409 void setLength(
const std::string& laneID,
SUMOReal length)
const;
429 std::vector<std::string> getIDList()
const;
430 int getJamLengthVehicle(
const std::string& laneID)
const;
431 SUMOReal getJamLengthMeters(
const std::string& laneID)
const;
451 std::vector<std::string> getIDList()
const;
452 int getLastStepVehicleNumber(
const std::string& detID)
const;
453 SUMOReal getLastStepMeanSpeed(
const std::string& detID)
const;
454 std::vector<std::string> getLastStepVehicleIDs(
const std::string& detID)
const;
455 int getLastStepHaltingNumber(
const std::string& detID)
const;
478 std::vector<std::string> getIDList()
const;
479 std::string getType(
const std::string& poiID)
const;
483 void setType(
const std::string& poiID,
const std::string& setType)
const;
485 void setColor(
const std::string& poiID,
const TraCIColor& c)
const;
487 void remove(
const std::string& poiID,
int layer = 0)
const;
510 std::vector<std::string> getIDList()
const;
511 std::string getType(
const std::string& polygonID)
const;
512 TraCIPositionVector getShape(
const std::string& polygonID)
const;
514 void setType(
const std::string& polygonID,
const std::string& setType)
const;
515 void setShape(
const std::string& polygonID,
const TraCIPositionVector& shape)
const;
516 void setColor(
const std::string& polygonID,
const TraCIColor& c)
const;
517 void add(
const std::string& polygonID,
const TraCIPositionVector& shape,
const TraCIColor& c,
bool fill,
const std::string& type,
int layer)
const;
518 void remove(
const std::string& polygonID,
int layer = 0)
const;
541 std::vector<std::string> getIDList()
const;
542 std::vector<std::string> getEdges(
const std::string& routeID)
const;
544 void add(
const std::string& routeID,
const std::vector<std::string>& edges)
const;
572 int getLoadedNumber()
const;
573 std::vector<std::string> getLoadedIDList()
const;
574 int getDepartedNumber()
const;
575 std::vector<std::string> getDepartedIDList()
const;
576 int getArrivedNumber()
const;
577 std::vector<std::string> getArrivedIDList()
const;
578 int getStartingTeleportNumber()
const;
579 std::vector<std::string> getStartingTeleportIDList()
const;
580 int getEndingTeleportNumber()
const;
581 std::vector<std::string> getEndingTeleportIDList()
const;
584 int getMinExpectedNumber()
const;
586 void subscribe(
int domID,
const std::string& objID,
SUMOTime beginTime,
SUMOTime endTime,
const std::vector<int>& vars)
const;
587 void subscribeContext(
int domID,
const std::string& objID,
SUMOTime beginTime,
SUMOTime endTime,
int domain,
SUMOReal range,
const std::vector<int>& vars)
const;
589 SubscribedValues getSubscriptionResults();
590 TraCIValues getSubscriptionResults(
const std::string& objID);
592 SubscribedContextValues getContextSubscriptionResults();
593 SubscribedValues getContextSubscriptionResults(
const std::string& objID);
616 std::vector<std::string> getIDList()
const;
617 std::string getRedYellowGreenState(
const std::string& tlsID)
const;
618 std::vector<TraCIAPI::TraCILogic> getCompleteRedYellowGreenDefinition(
const std::string& tlsID)
const;
619 std::vector<std::string> getControlledLanes(
const std::string& tlsID)
const;
620 std::vector<TraCIAPI::TraCILink> getControlledLinks(
const std::string& tlsID)
const;
621 std::string getProgram(
const std::string& tlsID)
const;
622 int getPhase(
const std::string& tlsID)
const;
623 int getNextSwitch(
const std::string& tlsID)
const;
625 void setRedYellowGreenState(
const std::string& tlsID,
const std::string& state)
const;
626 void setPhase(
const std::string& tlsID,
int index)
const;
627 void setProgram(
const std::string& tlsID,
const std::string& programID)
const;
628 void setPhaseDuration(
const std::string& tlsID,
int phaseDuration)
const;
629 void setCompleteRedYellowGreenDefinition(
const std::string& tlsID,
const TraCIAPI::TraCILogic& logic)
const;
652 std::vector<std::string> getIDList()
const;
653 SUMOReal getLength(
const std::string& typeID)
const;
654 SUMOReal getMaxSpeed(
const std::string& typeID)
const;
655 SUMOReal getSpeedFactor(
const std::string& typeID)
const;
656 SUMOReal getSpeedDeviation(
const std::string& typeID)
const;
657 SUMOReal getAccel(
const std::string& typeID)
const;
658 SUMOReal getDecel(
const std::string& typeID)
const;
659 SUMOReal getImperfection(
const std::string& typeID)
const;
660 SUMOReal getTau(
const std::string& typeID)
const;
661 std::string getVehicleClass(
const std::string& typeID)
const;
662 std::string getEmissionClass(
const std::string& typeID)
const;
663 std::string getShapeClass(
const std::string& typeID)
const;
664 SUMOReal getMinGap(
const std::string& typeID)
const;
665 SUMOReal getWidth(
const std::string& typeID)
const;
668 void setLength(
const std::string& typeID,
SUMOReal length)
const;
669 void setMaxSpeed(
const std::string& typeID,
SUMOReal speed)
const;
670 void setVehicleClass(
const std::string& typeID,
const std::string& clazz)
const;
671 void setSpeedFactor(
const std::string& typeID,
SUMOReal factor)
const;
672 void setSpeedDeviation(
const std::string& typeID,
SUMOReal deviation)
const;
673 void setEmissionClass(
const std::string& typeID,
const std::string& clazz)
const;
674 void setWidth(
const std::string& typeID,
SUMOReal width)
const;
675 void setMinGap(
const std::string& typeID,
SUMOReal minGap)
const;
676 void setShapeClass(
const std::string& typeID,
const std::string& clazz)
const;
677 void setAccel(
const std::string& typeID,
SUMOReal accel)
const;
678 void setDecel(
const std::string& typeID,
SUMOReal decel)
const;
679 void setImperfection(
const std::string& typeID,
SUMOReal imperfection)
const;
680 void setTau(
const std::string& typeID,
SUMOReal tau)
const;
681 void setColor(
const std::string& typeID,
const TraCIColor& c)
const;
719 std::vector<std::string> getIDList()
const;
720 int getIDCount()
const;
721 SUMOReal getSpeed(
const std::string& vehicleID)
const;
723 SUMOReal getAngle(
const std::string& vehicleID)
const;
724 std::string getRoadID(
const std::string& vehicleID)
const;
725 std::string getLaneID(
const std::string& vehicleID)
const;
726 int getLaneIndex(
const std::string& vehicleID)
const;
727 std::string getTypeID(
const std::string& vehicleID)
const;
728 std::string getRouteID(
const std::string& vehicleID)
const;
729 int getRouteIndex(
const std::string& vehicleID)
const;
730 std::vector<std::string> getEdges(
const std::string& vehicleID)
const;
732 SUMOReal getLanePosition(
const std::string& vehicleID)
const;
733 SUMOReal getCO2Emission(
const std::string& vehicleID)
const;
734 SUMOReal getCOEmission(
const std::string& vehicleID)
const;
735 SUMOReal getHCEmission(
const std::string& vehicleID)
const;
736 SUMOReal getPMxEmission(
const std::string& vehicleID)
const;
737 SUMOReal getNOxEmission(
const std::string& vehicleID)
const;
738 SUMOReal getFuelConsumption(
const std::string& vehicleID)
const;
739 SUMOReal getNoiseEmission(
const std::string& vehicleID)
const;
740 SUMOReal getElectricityConsumption(
const std::string& vehicleID)
const;
741 int getSignalStates(
const std::string& vehicleID)
const;
742 SUMOReal getWaitingTime(
const std::string& vehicleID)
const;
743 std::vector<NextTLSData> getNextTLS(
const std::string& vehID)
const;
744 int getSpeedMode(
const std::string& vehicleID)
const;
745 SUMOReal getSlope(
const std::string& vehicleID)
const;
772 void add(
const std::string& vehicleID,
773 const std::string& routeID,
774 const std::string& typeID =
"DEFAULT_VEHTYPE",
775 std::string depart =
"-1",
776 const std::string& departLane =
"first",
777 const std::string& departPos =
"base",
778 const std::string& departSpeed =
"0",
779 const std::string& arrivalLane =
"current",
780 const std::string& arrivalPos =
"max",
781 const std::string& arrivalSpeed =
"current",
782 const std::string& fromTaz =
"",
783 const std::string& toTaz =
"",
784 const std::string& line =
"",
785 int personCapacity = 0,
786 int personNumber = 0)
const;
788 void moveTo(
const std::string& vehicleID,
const std::string& laneID,
SUMOReal position)
const;
789 void moveToXY(
const std::string& vehicleID,
const std::string& edgeID,
const int lane,
const SUMOReal x,
const SUMOReal y,
const SUMOReal angle,
const int keepRoute)
const;
790 void slowDown(
const std::string& vehicleID,
SUMOReal speed,
int duration)
const;
791 void setSpeed(
const std::string& vehicleID,
SUMOReal speed)
const;
792 void remove(
const std::string& vehicleID,
char reason =
REMOVE_VAPORIZED)
const;
811 std::vector<std::string> getIDList()
const;
812 int getIDCount()
const;
813 SUMOReal getSpeed(
const std::string& typeID)
const;
815 std::string getRoadID(
const std::string& typeID)
const;
816 std::string getTypeID(
const std::string& typeID)
const;
817 SUMOReal getWaitingTime(
const std::string& typeID)
const;
818 std::string getNextEdge(
const std::string& typeID)
const;
913 int domain,
SUMOReal range,
const std::vector<int>& vars)
const;
917 void send_commandMoveToXY(
const std::string& vehicleID,
const std::string& edgeID,
const int lane,
946 std::ostringstream oss;
947 oss.setf(std::ios::fixed , std::ios::floatfield);
948 oss << std::setprecision(accuracy);
EdgeScope edge
Scope for interaction with edges.
TraCIPosition getPosition(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
SUMOReal entryTime
Entry-time of the vehicle in [s].
char state
The current state of the tls.
LaneScope(TraCIAPI &parent)
tcpip::Socket * mySocket
The socket.
C++ TraCI client API implementation.
void close()
Closes the connection.
Scope for interaction with edges.
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
MeMeScope(TraCIAPI &parent)
std::string typeID
Type of the vehicle in.
TraCILink(const std::string &_from, const std::string &_via, const std::string &_to)
std::map< int, TraCIValue > TraCIValues
{object->{variable->value}}
GUIScope(TraCIAPI &parent)
SUMOReal getDouble(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
virtual ~TrafficLightScope()
void send_commandClose() const
Sends a Close command.
JunctionScope junction
Scope for interaction with junctions.
PersonScope(TraCIAPI &parent)
TraCIPhase(const SUMOTime _duration, const SUMOTime _duration1, const SUMOTime _duration2, const std::string &_phase)
LaneScope lane
Scope for interaction with lanes.
PersonScope person
Scope for interaction with persons.
void processGET(tcpip::Storage &inMsg, int command, int expectedType, bool ignoreCommandId=false) const
Scope for interaction with vehicles.
Scope for interaction with traffic lights.
SubscribedContextValues mySubscribedContextValues
void simulationStep(SUMOTime time=0)
Advances by one step (or up to the given time)
Scope for interaction with the gui.
void send_commandMoveToXY(const std::string &vehicleID, const std::string &edgeID, const int lane, const SUMOReal x, const SUMOReal y, const SUMOReal angle, const int keepRoute) const
TrafficLightScope trafficlights
Scope for interaction with traffic lights.
TraCIPositionVector getPolygon(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
void readVariableSubscription(tcpip::Storage &inMsg)
std::map< std::string, SubscribedValues > SubscribedContextValues
Scope for interaction with routes.
TraCIBoundary getBoundingBox(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
InductionLoopScope inductionloop
Scope for interaction with inductive loops.
SUMOReal leaveTime
Leave-time of the vehicle in [s].
Scope for interaction with inductive loops.
POIScope(TraCIAPI &parent)
AreaScope(TraCIAPI &parent)
Scope for interaction with POIs.
void send_commandSubscribeObjectContext(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, int domain, SUMOReal range, const std::vector< int > &vars) const
Sends a SubscribeContext request.
Scope for interaction with the simulation.
Scope for interaction with multi entry/-exit detectors.
void send_commandSimulationStep(SUMOTime time) const
Sends a SimulationStep command.
SubscribedValues mySubscribedValues
InductionLoopScope(TraCIAPI &parent)
SUMOReal length
Length of the vehicle.
MeMeScope multientryexit
Scope for interaction with multi-entry/-exit detectors.
std::map< std::string, TraCIValues > SubscribedValues
Scope for interaction with vehicle types.
PolygonScope(TraCIAPI &parent)
void send_commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *add=0) const
Sends a GetVariable request.
TraCIColor getColor(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
RouteScope route
Scope for interaction with routes.
virtual ~InductionLoopScope()
Scope for interaction with polygons.
static std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
std::vector< TraCIPhase > phases
int getInt(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
int getByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
int getUnsignedByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
Scope for interaction with vehicles.
Scope for interaction with junctions.
TrafficLightScope(TraCIAPI &parent)
void readContextSubscription(tcpip::Storage &inMsg)
int check_commandGetResult(tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const
Validates the result state of a command.
void readVariables(tcpip::Storage &inMsg, const std::string &objectID, int variableCount, SubscribedValues &into)
virtual ~SimulationScope()
std::vector< std::string > getStringVector(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
EdgeScope(TraCIAPI &parent)
Scope for interaction with areal detectors.
POIScope poi
Scope for interaction with POIs.
SUMOReal dist
The distance to the tls.
void send_commandSubscribeObjectVariable(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, const std::vector< int > &vars) const
Sends a SubscribeVariable request.
SimulationScope simulation
Scope for interaction with the simulation.
Scope for interaction with lanes.
TraCIScopeWrapper(TraCIAPI &parent)
Constructor.
RouteScope(TraCIAPI &parent)
VehicleScope vehicle
Scope for interaction with vehicles.
SUMOTime getSUMOTime(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
TraCILogic(const std::string &_subID, int _type, const std::map< std::string, SUMOReal > &_subParameter, int _currentPhaseIndex, const std::vector< TraCIPhase > &_phases)
std::string id
The id of the next tls.
PolygonScope polygon
Scope for interaction with polygons.
virtual ~TraCIScopeWrapper()
Destructor.
void check_resultState(tcpip::Storage &inMsg, int command, bool ignoreCommandId=false, std::string *acknowledgement=0) const
Validates the result state of a command.
VehicleTypeScope(TraCIAPI &parent)
std::map< std::string, SUMOReal > subParameter
TraCIAPI & myParent
The parent TraCI client which offers the connection.
GUIScope gui
Scope for interaction with the gui.
void send_commandSetValue(int domID, int varID, const std::string &objID, tcpip::Storage &content) const
Sends a SetVariable request.
std::string getString(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
VehicleScope(TraCIAPI &parent)
SimulationScope(TraCIAPI &parent)
An abstract interface for accessing type-dependent values.
std::vector< TraCIPosition > TraCIPositionVector
virtual ~VehicleTypeScope()
int tlIndex
The tls index of the controlled link.
SUMOReal getFloat(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
std::string id
The id of the vehicle.
JunctionScope(TraCIAPI &parent)
VehicleTypeScope vehicletype
Scope for interaction with vehicle types.