47 #define DEFAULT_VIEW "View #0" 60 #define SUMOTime_MAX std::numeric_limits<SUMOTime>::max() 107 : duration(_duration), duration1(_duration1), duration2(_duration2), phase(_phase) {}
117 TraCILogic(
const std::string& _subID,
int _type,
const std::map<std::string, SUMOReal>& _subParameter,
int _currentPhaseIndex,
const std::vector<TraCIPhase>& _phases)
118 : subID(_subID), type(_type), subParameter(_subParameter), currentPhaseIndex(_currentPhaseIndex), phases(_phases) {}
130 TraCILink(
const std::string& _from,
const std::string& _via,
const std::string& _to)
131 : from(_from), via(_via), to(_to) {}
160 void connect(
const std::string& host,
int port);
232 std::vector<std::string> getIDList()
const;
233 int getIDCount()
const;
234 SUMOReal getAdaptedTraveltime(
const std::string& edgeID,
SUMOTime time)
const;
236 SUMOReal getCO2Emission(
const std::string& edgeID)
const;
237 SUMOReal getCOEmission(
const std::string& edgeID)
const;
238 SUMOReal getHCEmission(
const std::string& edgeID)
const;
239 SUMOReal getPMxEmission(
const std::string& edgeID)
const;
240 SUMOReal getNOxEmission(
const std::string& edgeID)
const;
241 SUMOReal getFuelConsumption(
const std::string& edgeID)
const;
242 SUMOReal getNoiseEmission(
const std::string& edgeID)
const;
243 SUMOReal getElectricityConsumption(
const std::string& edgeID)
const;
244 SUMOReal getLastStepMeanSpeed(
const std::string& edgeID)
const;
245 SUMOReal getLastStepOccupancy(
const std::string& edgeID)
const;
246 SUMOReal getLastStepLength(
const std::string& edgeID)
const;
247 SUMOReal getTraveltime(
const std::string& edgeID)
const;
248 int getLastStepVehicleNumber(
const std::string& edgeID)
const;
249 SUMOReal getLastStepHaltingNumber(
const std::string& edgeID)
const;
250 std::vector<std::string> getLastStepVehicleIDs(
const std::string& edgeID)
const;
254 void setMaxSpeed(
const std::string& edgeID,
SUMOReal speed)
const;
277 std::vector<std::string> getIDList()
const;
280 std::string getSchema(
const std::string& viewID =
DEFAULT_VIEW)
const;
282 void setZoom(
const std::string& viewID,
SUMOReal zoom)
const;
284 void setSchema(
const std::string& viewID,
const std::string& schemeName)
const;
286 void screenshot(
const std::string& viewID,
const std::string& filename)
const;
287 void trackVehicle(
const std::string& viewID,
const std::string& vehID)
const;
326 std::vector<std::string> getIDList()
const;
328 std::string getLaneID(
const std::string& loopID)
const;
329 int getLastStepVehicleNumber(
const std::string& loopID)
const;
330 SUMOReal getLastStepMeanSpeed(
const std::string& loopID)
const;
331 std::vector<std::string> getLastStepVehicleIDs(
const std::string& loopID)
const;
332 SUMOReal getLastStepOccupancy(
const std::string& loopID)
const;
333 SUMOReal getLastStepMeanLength(
const std::string& loopID)
const;
334 SUMOReal getTimeSinceDetection(
const std::string& loopID)
const;
335 std::vector<VehicleData> getVehicleData(
const std::string& loopID)
const;
359 std::vector<std::string> getIDList()
const;
383 std::vector<std::string> getIDList()
const;
384 SUMOReal getLength(
const std::string& laneID)
const;
385 SUMOReal getMaxSpeed(
const std::string& laneID)
const;
386 SUMOReal getWidth(
const std::string& laneID)
const;
387 std::vector<std::string> getAllowed(
const std::string& laneID)
const;
388 std::vector<std::string> getDisallowed(
const std::string& laneID)
const;
389 int getLinkNumber(
const std::string& laneID)
const;
390 TraCIPositionVector getShape(
const std::string& laneID)
const;
391 std::string getEdgeID(
const std::string& laneID)
const;
392 SUMOReal getCO2Emission(
const std::string& laneID)
const;
393 SUMOReal getCOEmission(
const std::string& laneID)
const;
394 SUMOReal getHCEmission(
const std::string& laneID)
const;
395 SUMOReal getPMxEmission(
const std::string& laneID)
const;
396 SUMOReal getNOxEmission(
const std::string& laneID)
const;
397 SUMOReal getFuelConsumption(
const std::string& laneID)
const;
398 SUMOReal getNoiseEmission(
const std::string& laneID)
const;
399 SUMOReal getElectricityConsumption(
const std::string& laneID)
const;
400 SUMOReal getLastStepMeanSpeed(
const std::string& laneID)
const;
401 SUMOReal getLastStepOccupancy(
const std::string& laneID)
const;
402 SUMOReal getLastStepLength(
const std::string& laneID)
const;
403 SUMOReal getTraveltime(
const std::string& laneID)
const;
404 int getLastStepVehicleNumber(
const std::string& laneID)
const;
405 int getLastStepHaltingNumber(
const std::string& laneID)
const;
406 std::vector<std::string> getLastStepVehicleIDs(
const std::string& laneID)
const;
408 void setAllowed(
const std::string& laneID,
const std::vector<std::string>& allowedClasses)
const;
409 void setDisallowed(
const std::string& laneID,
const std::vector<std::string>& disallowedClasses)
const;
410 void setMaxSpeed(
const std::string& laneID,
SUMOReal speed)
const;
411 void setLength(
const std::string& laneID,
SUMOReal length)
const;
431 std::vector<std::string> getIDList()
const;
432 int getJamLengthVehicle(
const std::string& laneID)
const;
433 SUMOReal getJamLengthMeters(
const std::string& laneID)
const;
453 std::vector<std::string> getIDList()
const;
454 int getLastStepVehicleNumber(
const std::string& detID)
const;
455 SUMOReal getLastStepMeanSpeed(
const std::string& detID)
const;
456 std::vector<std::string> getLastStepVehicleIDs(
const std::string& detID)
const;
457 int getLastStepHaltingNumber(
const std::string& detID)
const;
480 std::vector<std::string> getIDList()
const;
481 std::string getType(
const std::string& poiID)
const;
485 void setType(
const std::string& poiID,
const std::string& setType)
const;
487 void setColor(
const std::string& poiID,
const TraCIColor& c)
const;
489 void remove(
const std::string& poiID,
int layer = 0)
const;
512 std::vector<std::string> getIDList()
const;
513 std::string getType(
const std::string& polygonID)
const;
514 TraCIPositionVector getShape(
const std::string& polygonID)
const;
516 void setType(
const std::string& polygonID,
const std::string& setType)
const;
517 void setShape(
const std::string& polygonID,
const TraCIPositionVector& shape)
const;
518 void setColor(
const std::string& polygonID,
const TraCIColor& c)
const;
519 void add(
const std::string& polygonID,
const TraCIPositionVector& shape,
const TraCIColor& c,
bool fill,
const std::string& type,
int layer)
const;
520 void remove(
const std::string& polygonID,
int layer = 0)
const;
543 std::vector<std::string> getIDList()
const;
544 std::vector<std::string> getEdges(
const std::string& routeID)
const;
546 void add(
const std::string& routeID,
const std::vector<std::string>& edges)
const;
574 int getLoadedNumber()
const;
575 std::vector<std::string> getLoadedIDList()
const;
576 int getDepartedNumber()
const;
577 std::vector<std::string> getDepartedIDList()
const;
578 int getArrivedNumber()
const;
579 std::vector<std::string> getArrivedIDList()
const;
580 int getStartingTeleportNumber()
const;
581 std::vector<std::string> getStartingTeleportIDList()
const;
582 int getEndingTeleportNumber()
const;
583 std::vector<std::string> getEndingTeleportIDList()
const;
586 int getMinExpectedNumber()
const;
588 void subscribe(
int domID,
const std::string& objID,
SUMOTime beginTime,
SUMOTime endTime,
const std::vector<int>& vars)
const;
589 void subscribeContext(
int domID,
const std::string& objID,
SUMOTime beginTime,
SUMOTime endTime,
int domain,
SUMOReal range,
const std::vector<int>& vars)
const;
591 SubscribedValues getSubscriptionResults();
592 TraCIValues getSubscriptionResults(
const std::string& objID);
594 SubscribedContextValues getContextSubscriptionResults();
595 SubscribedValues getContextSubscriptionResults(
const std::string& objID);
618 std::vector<std::string> getIDList()
const;
619 std::string getRedYellowGreenState(
const std::string& tlsID)
const;
620 std::vector<TraCIAPI::TraCILogic> getCompleteRedYellowGreenDefinition(
const std::string& tlsID)
const;
621 std::vector<std::string> getControlledLanes(
const std::string& tlsID)
const;
622 std::vector<TraCIAPI::TraCILink> getControlledLinks(
const std::string& tlsID)
const;
623 std::string getProgram(
const std::string& tlsID)
const;
624 int getPhase(
const std::string& tlsID)
const;
625 int getNextSwitch(
const std::string& tlsID)
const;
627 void setRedYellowGreenState(
const std::string& tlsID,
const std::string& state)
const;
628 void setPhase(
const std::string& tlsID,
int index)
const;
629 void setProgram(
const std::string& tlsID,
const std::string& programID)
const;
630 void setPhaseDuration(
const std::string& tlsID,
int phaseDuration)
const;
631 void setCompleteRedYellowGreenDefinition(
const std::string& tlsID,
const TraCIAPI::TraCILogic& logic)
const;
654 std::vector<std::string> getIDList()
const;
655 SUMOReal getLength(
const std::string& typeID)
const;
656 SUMOReal getMaxSpeed(
const std::string& typeID)
const;
657 SUMOReal getSpeedFactor(
const std::string& typeID)
const;
658 SUMOReal getSpeedDeviation(
const std::string& typeID)
const;
659 SUMOReal getAccel(
const std::string& typeID)
const;
660 SUMOReal getDecel(
const std::string& typeID)
const;
661 SUMOReal getImperfection(
const std::string& typeID)
const;
662 SUMOReal getTau(
const std::string& typeID)
const;
663 std::string getVehicleClass(
const std::string& typeID)
const;
664 std::string getEmissionClass(
const std::string& typeID)
const;
665 std::string getShapeClass(
const std::string& typeID)
const;
666 SUMOReal getMinGap(
const std::string& typeID)
const;
667 SUMOReal getWidth(
const std::string& typeID)
const;
668 SUMOReal getHeight(
const std::string& typeID)
const;
671 void setLength(
const std::string& typeID,
SUMOReal length)
const;
672 void setMaxSpeed(
const std::string& typeID,
SUMOReal speed)
const;
673 void setVehicleClass(
const std::string& typeID,
const std::string& clazz)
const;
674 void setSpeedFactor(
const std::string& typeID,
SUMOReal factor)
const;
675 void setSpeedDeviation(
const std::string& typeID,
SUMOReal deviation)
const;
676 void setEmissionClass(
const std::string& typeID,
const std::string& clazz)
const;
677 void setWidth(
const std::string& typeID,
SUMOReal width)
const;
678 void setHeight(
const std::string& typeID,
SUMOReal height)
const;
679 void setMinGap(
const std::string& typeID,
SUMOReal minGap)
const;
680 void setShapeClass(
const std::string& typeID,
const std::string& clazz)
const;
681 void setAccel(
const std::string& typeID,
SUMOReal accel)
const;
682 void setDecel(
const std::string& typeID,
SUMOReal decel)
const;
683 void setImperfection(
const std::string& typeID,
SUMOReal imperfection)
const;
684 void setTau(
const std::string& typeID,
SUMOReal tau)
const;
685 void setColor(
const std::string& typeID,
const TraCIColor& c)
const;
723 std::vector<std::string> getIDList()
const;
724 int getIDCount()
const;
725 SUMOReal getSpeed(
const std::string& vehicleID)
const;
727 SUMOReal getAngle(
const std::string& vehicleID)
const;
728 std::string getRoadID(
const std::string& vehicleID)
const;
729 std::string getLaneID(
const std::string& vehicleID)
const;
730 int getLaneIndex(
const std::string& vehicleID)
const;
731 std::string getTypeID(
const std::string& vehicleID)
const;
732 std::string getRouteID(
const std::string& vehicleID)
const;
733 int getRouteIndex(
const std::string& vehicleID)
const;
734 std::vector<std::string> getEdges(
const std::string& vehicleID)
const;
736 SUMOReal getLanePosition(
const std::string& vehicleID)
const;
737 SUMOReal getCO2Emission(
const std::string& vehicleID)
const;
738 SUMOReal getCOEmission(
const std::string& vehicleID)
const;
739 SUMOReal getHCEmission(
const std::string& vehicleID)
const;
740 SUMOReal getPMxEmission(
const std::string& vehicleID)
const;
741 SUMOReal getNOxEmission(
const std::string& vehicleID)
const;
742 SUMOReal getFuelConsumption(
const std::string& vehicleID)
const;
743 SUMOReal getNoiseEmission(
const std::string& vehicleID)
const;
744 SUMOReal getElectricityConsumption(
const std::string& vehicleID)
const;
745 int getSignalStates(
const std::string& vehicleID)
const;
746 SUMOReal getWaitingTime(
const std::string& vehicleID)
const;
747 std::vector<NextTLSData> getNextTLS(
const std::string& vehID)
const;
748 int getSpeedMode(
const std::string& vehicleID)
const;
749 SUMOReal getSlope(
const std::string& vehicleID)
const;
776 void add(
const std::string& vehicleID,
777 const std::string& routeID,
778 const std::string& typeID =
"DEFAULT_VEHTYPE",
779 std::string depart =
"-1",
780 const std::string& departLane =
"first",
781 const std::string& departPos =
"base",
782 const std::string& departSpeed =
"0",
783 const std::string& arrivalLane =
"current",
784 const std::string& arrivalPos =
"max",
785 const std::string& arrivalSpeed =
"current",
786 const std::string& fromTaz =
"",
787 const std::string& toTaz =
"",
788 const std::string& line =
"",
789 int personCapacity = 0,
790 int personNumber = 0)
const;
792 void moveTo(
const std::string& vehicleID,
const std::string& laneID,
SUMOReal position)
const;
793 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;
794 void slowDown(
const std::string& vehicleID,
SUMOReal speed,
int duration)
const;
795 void setSpeed(
const std::string& vehicleID,
SUMOReal speed)
const;
796 void remove(
const std::string& vehicleID,
char reason =
REMOVE_VAPORIZED)
const;
797 void setColor(
const std::string& vehicleID,
const TraCIColor& c)
const;
816 std::vector<std::string> getIDList()
const;
817 int getIDCount()
const;
818 SUMOReal getSpeed(
const std::string& typeID)
const;
820 std::string getRoadID(
const std::string& typeID)
const;
821 std::string getTypeID(
const std::string& typeID)
const;
822 SUMOReal getWaitingTime(
const std::string& typeID)
const;
823 std::string getNextEdge(
const std::string& typeID)
const;
918 int domain,
SUMOReal range,
const std::vector<int>& vars)
const;
922 void send_commandMoveToXY(
const std::string& vehicleID,
const std::string& edgeID,
const int lane,
951 std::ostringstream oss;
952 oss.setf(std::ios::fixed , std::ios::floatfield);
953 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)
void send_commandSetValue(int domID, int varID, const std::string &objID, tcpip::Storage &content) const
Sends a SetVariable request.
tcpip::Socket * mySocket
The socket.
C++ TraCI client API implementation.
void close()
Closes the connection.
Scope for interaction with edges.
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.
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()
JunctionScope junction
Scope for interaction with junctions.
PersonScope(TraCIAPI &parent)
TraCIPhase(const SUMOTime _duration, const SUMOTime _duration1, const SUMOTime _duration2, const std::string &_phase)
void send_commandGetVariable(int domID, int varID, const std::string &objID, tcpip::Storage *add=0) const
Sends a GetVariable request.
LaneScope lane
Scope for interaction with lanes.
PersonScope person
Scope for interaction with persons.
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.
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)
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
AreaScope(TraCIAPI &parent)
Scope for interaction with POIs.
Scope for interaction with the simulation.
Scope for interaction with multi entry/-exit detectors.
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)
TraCIColor getColor(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
void send_commandSubscribeObjectVariable(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, const std::vector< int > &vars) const
Sends a SubscribeVariable request.
RouteScope route
Scope for interaction with routes.
void send_commandSimulationStep(SUMOTime time) const
Sends a SimulationStep command.
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)
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.
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.
SUMOReal dist
The distance to the tls.
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)
void processGET(tcpip::Storage &inMsg, int command, int expectedType, bool ignoreCommandId=false) const
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.
VehicleTypeScope(TraCIAPI &parent)
std::map< std::string, SUMOReal > subParameter
void send_commandClose() const
Sends a Close command.
TraCIAPI & myParent
The parent TraCI client which offers the connection.
int check_commandGetResult(tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const
Validates the result state of a command.
GUIScope gui
Scope for interaction with the gui.
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.