31 #include "../../config.h" 38 #ifdef CHECK_MEMORY_LEAKS 40 #endif // CHECK_MEMORY_LEAKS 50 #pragma warning(disable: 4355) 53 : edge(*this), gui(*this), inductionloop(*this),
54 junction(*this), lane(*this), multientryexit(*this), poi(*this),
55 polygon(*this), route(*this), simulation(*this), trafficlights(*this),
56 vehicletype(*this), vehicle(*this),
59 #pragma warning(default: 4355) 123 unsigned int length = 1 + 1 + 1 + 4 + (int) objID.length();
125 length += (int)add->
size();
166 const std::vector<int>& vars)
const {
172 int varNo = (int) vars.
size();
174 outMsg.
writeInt(5 + 1 + 4 + 4 + 4 + (
int) objID.length() + 1 + varNo);
184 for (
int i = 0; i < varNo; ++i) {
194 int domain,
SUMOReal range,
const std::vector<int>& vars)
const {
200 int varNo = (int) vars.
size();
202 outMsg.
writeInt(5 + 1 + 4 + 4 + 4 + (
int) objID.length() + 1 + 8 + 1 + varNo);
215 for (
int i = 0; i < varNo; ++i) {
237 if (command != cmdId && !ignoreCommandId) {
242 }
catch (std::invalid_argument&) {
245 switch (resultType) {
251 if (acknowledgement != 0) {
252 (*acknowledgement) =
".. Command acknowledged (" +
toString(command) +
"), [description: " + msg +
"]";
258 if ((cmdStart + cmdLength) != (
int) inMsg.
position()) {
272 if (!ignoreCommandId && cmdId != (command + 0x10)) {
275 if (expectedType >= 0) {
280 if (valueDataType != expectedType) {
371 unsigned int size = inMsg.
readInt();
373 for (
unsigned int i = 0; i < size; ++i) {
406 std::vector<std::string>
411 unsigned int size = inMsg.
readInt();
412 std::vector<std::string> r;
413 for (
unsigned int i = 0; i < size; ++i) {
445 std::vector<std::string>
534 std::vector<std::string>
574 std::vector<std::string>
667 std::vector<std::string>
692 std::vector<std::string>
712 std::vector<TraCIAPI::InductionLoopScope::VehicleData>
717 std::vector<VehicleData> result;
722 for (
int i = 0; i < n; ++i) {
740 result.push_back(vd);
751 std::vector<std::string>
767 std::vector<std::string>
787 std::vector<std::string>
792 std::vector<std::string>
877 std::vector<std::string>
887 content.
writeInt((
int)allowedClasses.size());
888 for (
unsigned int i = 0; i < allowedClasses.size(); ++i) {
900 content.
writeInt((
int)disallowedClasses.size());
901 for (
unsigned int i = 0; i < disallowedClasses.size(); ++i) {
933 std::vector<std::string>
944 std::vector<std::string>
959 std::vector<std::string>
974 std::vector<std::string>
1066 std::vector<std::string>
1101 content.
writeInt((
int)shape.size());
1102 for (
unsigned int i = 0; i < shape.size(); ++i) {
1137 int f = fill ? 1 : 0;
1142 content.
writeInt((
int)shape.size());
1143 for (
unsigned int i = 0; i < shape.size(); ++i) {
1167 std::vector<std::string>
1172 std::vector<std::string>
1205 std::vector<std::string>
1215 std::vector<std::string>
1225 std::vector<std::string>
1235 std::vector<std::string>
1245 std::vector<std::string>
1270 std::vector<std::string>
1280 std::vector<TraCIAPI::TraCILogic>
1285 std::vector<TraCIAPI::TraCILogic> ret;
1286 int logicNo = inMsg.
readInt();
1287 for (
int i = 0; i < logicNo; ++i) {
1295 int phaseIndex = inMsg.
readInt();
1297 int phaseNumber = inMsg.
readInt();
1298 std::vector<TraCIAPI::TraCIPhase> phases;
1299 for (
int j = 0; j < phaseNumber; ++j) {
1301 int duration = inMsg.
readInt();
1303 int duration1 = inMsg.
readInt();
1305 int duration2 = inMsg.
readInt();
1310 ret.push_back(
TraCIAPI::TraCILogic(subID, type, std::map<std::string, SUMOReal>(), phaseIndex, phases));
1315 std::vector<std::string>
1320 std::vector<TraCIAPI::TraCILink>
1325 std::vector<TraCIAPI::TraCILink> ret;
1327 for (
int i = 0; i < linkNo; ++i) {
1389 content.
writeInt(
int(1000 * phaseDuration));
1410 for (
int i = 0; i < (int) logic.
phases.size(); ++i) {
1432 std::vector<std::string>
1659 std::vector<std::string>
1714 std::vector<std::string>
std::vector< std::string > getIDList() const
SUMOReal getImperfection(const std::string &typeID) const
#define LAST_STEP_MEAN_SPEED
TraCIPosition getPosition(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
SUMOReal entryTime
Entry-time of the vehicle in [s].
std::vector< std::string > getIDList() const
SUMOReal getMaxSpeed(const std::string &typeID) const
TraCIPosition getOffset(const std::string &viewID=DEFAULT_VIEW) const
void setLength(const std::string &typeID, SUMOReal length) const
#define VAR_EMISSIONCLASS
void setMaxSpeed(const std::string &edgeID, SUMOReal speed) const
SUMOReal getNoiseEmission(const std::string &laneID) const
tcpip::Socket * mySocket
The socket.
std::vector< std::string > getIDList() const
std::vector< std::string > getLoadedIDList() const
unsigned int getLastStepVehicleNumber(const std::string &loopID) const
void close()
Closes the connection.
void connect(const std::string &host, int port)
Connects to the specified SUMO server.
#define CMD_GET_TL_VARIABLE
std::vector< std::string > getArrivedIDList() const
std::string getRouteID(const std::string &typeID) const
std::vector< std::string > getIDList() const
unsigned int getLastStepVehicleNumber(const std::string &edgeID) const
std::string typeID
Type of the vehicle in.
#define CMD_GET_VEHICLE_VARIABLE
#define VAR_CURRENT_TRAVELTIME
unsigned int getRouteIndex(const std::string &typeID) const
TraCIColor getColor(const std::string &poiID) const
void add(const std::string &poiID, SUMOReal x, SUMOReal y, const TraCIColor &c, const std::string &type, int layer) const
SUMOReal getLastStepMeanSpeed(const std::string &edgeID) const
std::vector< std::string > getDisallowed(const std::string &laneID) const
SUMOReal getCOEmission(const std::string &edgeID) const
void setShapeClass(const std::string &typeID, const std::string &clazz) const
void setPhase(const std::string &tlsID, unsigned int index) const
void setProgram(const std::string &tlsID, const std::string &programID) const
void setVehicleClass(const std::string &typeID, const std::string &clazz) const
std::string getLaneID(const std::string &typeID) const
bool receiveExact(Storage &)
Receive a complete TraCI message from Socket::socket_.
#define CMD_GET_INDUCTIONLOOP_VARIABLE
std::string getVehicleClass(const std::string &typeID) const
void slowDown(const std::string &typeID, SUMOReal speed, int duration) const
void setColor(const std::string &polygonID, const TraCIColor &c) const
SUMOReal getDouble(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
#define LAST_STEP_VEHICLE_DATA
void send_commandClose() const
Sends a Close command.
virtual unsigned int position() const
unsigned int getIDCount() const
unsigned int getLaneIndex(const std::string &typeID) const
virtual double readDouble()
void setMaxSpeed(const std::string &typeID, SUMOReal speed) const
void setCompleteRedYellowGreenDefinition(const std::string &tlsID, const TraCIAPI::TraCILogic &logic) const
unsigned int currentPhaseIndex
std::string getEmissionClass(const std::string &typeID) const
void add(const std::string &polygonID, const TraCIPositionVector &shape, const TraCIColor &c, bool fill, const std::string &type, int layer) const
std::vector< std::string > getIDList() const
SUMOReal getLastStepMeanSpeed(const std::string &detID) const
void processGET(tcpip::Storage &inMsg, int command, int expectedType, bool ignoreCommandId=false) const
StorageType::size_type size() const
SUMOReal getPMxEmission(const std::string &laneID) const
SUMOReal getSpeed(const std::string &typeID) const
SUMOReal getLastStepOccupancy(const std::string &edgeID) const
unsigned int getLastStepHaltingNumber(const std::string &detID) const
#define VAR_LOADED_VEHICLES_IDS
std::vector< std::string > getLastStepVehicleIDs(const std::string &loopID) const
TraCIPosition getPosition(const std::string &junctionID) const
void trackVehicle(const std::string &viewID, const std::string &vehID) const
std::string getRoadID(const std::string &typeID) const
std::vector< std::string > getIDList() const
SUMOTime getCurrentTime() const
SUMOReal getLength(const std::string &laneID) const
SUMOReal getLastStepMeanSpeed(const std::string &laneID) const
std::vector< std::string > getIDList() const
SUMOReal getMinGap(const std::string &typeID) const
#define VAR_TELEPORT_STARTING_VEHICLES_IDS
#define CMD_GET_POLYGON_VARIABLE
void simulationStep(SUMOTime time=0)
Advances by one step (or up to the given time)
std::vector< std::string > getControlledLanes(const std::string &tlsID) const
SUMOReal getLastStepMeanLength(const std::string &loopID) const
void setAllowed(const std::string &laneID, const std::vector< std::string > &allowedClasses) const
virtual void writeUnsignedByte(int)
#define CMD_SET_EDGE_VARIABLE
#define CMD_SET_GUI_VARIABLE
SUMOReal getWidth(const std::string &typeID) const
TraCIPositionVector getPolygon(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
SUMOReal getLastStepOccupancy(const std::string &laneID) const
std::string getProgram(const std::string &tlsID) const
#define VAR_LOADED_VEHICLES_NUMBER
#define VAR_SPEED_DEVIATION
#define VAR_NOISEEMISSION
std::vector< std::string > getIDList() const
#define VAR_FUELCONSUMPTION
#define CMD_GET_ROUTE_VARIABLE
TraCIBoundary getBoundingBox(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
virtual void writeInt(int)
void setDisallowed(const std::string &laneID, const std::vector< std::string > &disallowedClasses) const
void setTau(const std::string &typeID, SUMOReal tau) const
SUMOReal getCO2Emission(const std::string &laneID) const
SUMOReal leaveTime
Leave-time of the vehicle in [s].
std::vector< std::string > getAllowed(const std::string &laneID) const
void setBoundary(const std::string &viewID, SUMOReal xmin, SUMOReal ymin, SUMOReal xmax, SUMOReal ymax) const
void setMaxSpeed(const std::string &laneID, SUMOReal speed) const
virtual int readUnsignedByte()
#define TL_PHASE_DURATION
void connect()
Connects to host_:port_.
void moveTo(const std::string &typeID, const std::string &laneID, SUMOReal position) const
unsigned int getIDCount() const
#define TL_CURRENT_PROGRAM
std::vector< std::string > getEdges(const std::string &typeID) const
#define CMD_SET_TL_VARIABLE
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.
#define CMD_GET_VEHICLETYPE_VARIABLE
void remove(const std::string &polygonID, int layer=0) const
std::string getTypeID(const std::string &typeID) const
void send_commandSimulationStep(SUMOTime time) const
Sends a SimulationStep command.
std::string getRedYellowGreenState(const std::string &tlsID) const
#define VAR_DEPARTED_VEHICLES_NUMBER
void adaptTraveltime(const std::string &edgeID, SUMOReal time) const
#define LAST_STEP_TIME_SINCE_DETECTION
#define CMD_SET_ROUTE_VARIABLE
SUMOReal length
Length of the vehicle.
#define CMD_GET_AREAL_DETECTOR_VARIABLE
#define VAR_MIN_EXPECTED_VEHICLES
#define VAR_VIEW_BOUNDARY
#define VAR_TRACK_VEHICLE
void setDecel(const std::string &typeID, SUMOReal decel) const
void setLength(const std::string &laneID, SUMOReal length) const
SUMOTime getDeltaT() const
void setSchema(const std::string &viewID, const std::string &schemeName) const
TraCIColor getColor(const std::string &typeID) const
#define TL_COMPLETE_PROGRAM_RYG
std::string getType(const std::string &polygonID) const
SUMOReal getTraveltime(const std::string &laneID) const
void setType(const std::string &poiID, const std::string &setType) const
SUMOReal getNOxEmission(const std::string &laneID) const
#define VAR_NET_BOUNDING_BOX
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)
#define CMD_GET_POI_VARIABLE
std::vector< std::string > getIDList() const
void screenshot(const std::string &viewID, const std::string &filename) const
std::vector< std::string > getDepartedIDList() const
#define TL_COMPLETE_DEFINITION_RYG
#define VAR_TELEPORT_STARTING_VEHICLES_NUMBER
unsigned int getLastStepHaltingNumber(const std::string &laneID) const
#define CMD_SET_VEHICLETYPE_VARIABLE
std::vector< TraCIAPI::TraCILink > getControlledLinks(const std::string &tlsID) const
unsigned int getArrivedNumber() const
SUMOReal getHCEmission(const std::string &laneID) const
void setWidth(const std::string &typeID, SUMOReal width) const
void setEmissionClass(const std::string &typeID, const std::string &clazz) const
unsigned int getNextSwitch(const std::string &tlsID) const
TraCIPositionVector getShape(const std::string &polygonID) const
void setSpeedFactor(const std::string &typeID, SUMOReal factor) const
virtual void writeStringList(const std::vector< std::string > &s)
#define VAR_TELEPORT_ENDING_VEHICLES_IDS
#define CMD_GET_LANE_VARIABLE
std::vector< TraCIPhase > phases
int getInt(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
#define CMD_SET_VEHICLE_VARIABLE
SUMOReal getSpeedFactor(const std::string &typeID) const
std::vector< std::string > getIDList() const
SUMOReal getLastStepLength(const std::string &edgeID) const
void setRedYellowGreenState(const std::string &tlsID, const std::string &state) const
#define CMD_GET_SIM_VARIABLE
virtual std::string readString()
std::string getShapeClass(const std::string &typeID) const
#define CMD_GET_EDGE_VARIABLE
int getByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
#define CMD_GET_GUI_VARIABLE
std::string getSchema(const std::string &viewID=DEFAULT_VIEW) const
SUMOReal getLastStepOccupancy(const std::string &loopID) const
#define VAR_DEPARTED_VEHICLES_IDS
#define CMD_SET_POI_VARIABLE
int getUnsignedByte(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
void setMinGap(const std::string &typeID, SUMOReal minGap) const
TraCIColor getColor(const std::string &polygonID) const
SUMOReal getDecel(const std::string &typeID) const
void setPhaseDuration(const std::string &tlsID, unsigned int phaseDuration) const
std::vector< std::string > getEndingTeleportIDList() const
SUMOReal getPosition(const std::string &loopID) const
#define CMD_GET_JUNCTION_VARIABLE
TraCIBoundary getBoundary(const std::string &viewID=DEFAULT_VIEW) const
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
SUMOReal getTimeSinceDetection(const std::string &loopID) const
void setOffset(const std::string &viewID, SUMOReal x, SUMOReal y) const
std::string getEdgeID(const std::string &laneID) const
unsigned int getEndingTeleportNumber() const
virtual void writeStorage(tcpip::Storage &store)
#define TL_CONTROLLED_LINKS
SUMOReal getMaxSpeed(const std::string &laneID) const
unsigned int getLastStepVehicleNumber(const std::string &laneID) const
SUMOReal getLanePosition(const std::string &typeID) const
SUMOReal getLastStepMeanSpeed(const std::string &loopID) const
void setAccel(const std::string &typeID, SUMOReal accel) const
void setImperfection(const std::string &typeID, SUMOReal imperfection) const
std::vector< std::string > getStringVector(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
SUMOReal getCOEmission(const std::string &laneID) const
TraCIPosition getPosition(const std::string &poiID) const
#define TL_RED_YELLOW_GREEN_STATE
SUMOReal getFuelConsumption(const std::string &edgeID) const
#define LAST_STEP_VEHICLE_NUMBER
#define VAR_EDGE_TRAVELTIME
#define VAR_ARRIVED_VEHICLES_NUMBER
SUMOReal getZoom(const std::string &viewID=DEFAULT_VIEW) const
TraCIColor getColor(const std::string &typeID) const
void send_commandSubscribeObjectVariable(int domID, const std::string &objID, SUMOTime beginTime, SUMOTime endTime, const std::vector< int > &vars) const
Sends a SubscribeVariable request.
SUMOReal getWidth(const std::string &laneID) const
#define CMD_SET_POLYGON_VARIABLE
std::vector< TraCIAPI::TraCILogic > getCompleteRedYellowGreenDefinition(const std::string &tlsID) const
SUMOReal getAngle(const std::string &typeID) const
virtual void writeString(const std::string &s)
#define RTYPE_NOTIMPLEMENTED
void setType(const std::string &polygonID, const std::string &setType) const
TraCIPositionVector getShape(const std::string &laneID) const
#define LAST_STEP_VEHICLE_ID_LIST
#define CMD_GET_MULTI_ENTRY_EXIT_DETECTOR_VARIABLE
void setEffort(const std::string &edgeID, SUMOReal effort) const
SUMOReal getEffort(const std::string &edgeID, SUMOTime time) const
SUMOTime getSUMOTime(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
SUMOReal getHCEmission(const std::string &edgeID) const
std::vector< std::string > getLastStepVehicleIDs(const std::string &detID) const
unsigned int getDepartedNumber() const
void sendExact(const Storage &)
virtual float readFloat()
void setSpeed(const std::string &typeID, SUMOReal speed) const
std::string getType(const std::string &poiID) const
#define CMD_SET_LANE_VARIABLE
std::string getLaneID(const std::string &loopID) const
std::vector< std::string > getIDList() const
void check_resultState(tcpip::Storage &inMsg, int command, bool ignoreCommandId=false, std::string *acknowledgement=0) const
Validates the result state of a command.
unsigned int getLinkNumber(const std::string &laneID) const
SUMOReal getNoiseEmission(const std::string &edgeID) const
SUMOReal getAccel(const std::string &typeID) const
SUMOReal getTraveltime(const std::string &edgeID) const
void setZoom(const std::string &viewID, SUMOReal zoom) const
std::vector< std::string > getLastStepVehicleIDs(const std::string &laneID) const
virtual void writeDouble(double)
#define VAR_TELEPORT_ENDING_VEHICLES_NUMBER
SUMOReal getLastStepLength(const std::string &laneID) const
void setShape(const std::string &polygonID, const TraCIPositionVector &shape) const
void setColor(const std::string &typeID, const TraCIColor &c) const
void send_commandSetValue(int domID, int varID, const std::string &objID, tcpip::Storage &content) const
Sends a SetVariable request.
std::vector< std::string > getIDList() const
unsigned int getStartingTeleportNumber() const
SUMOReal getPMxEmission(const std::string &edgeID) const
void setPosition(const std::string &poiID, SUMOReal x, SUMOReal y) const
SUMOReal getSpeedDeviation(const std::string &typeID) const
SUMOReal getCO2Emission(const std::string &edgeID) const
#define LAST_STEP_OCCUPANCY
unsigned int getLoadedNumber() const
#define TL_CONTROLLED_LANES
void check_commandGetResult(tcpip::Storage &inMsg, int command, int expectedType=-1, bool ignoreCommandId=false) const
std::string getString(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
void setSpeedDeviation(const std::string &typeID, SUMOReal deviation) const
TraCIPosition getPosition(const std::string &typeID) const
SUMOReal getNOxEmission(const std::string &edgeID) const
std::vector< VehicleData > getVehicleData(const std::string &loopID) const
TraCIBoundary getNetBoundary() const
std::vector< TraCIPosition > TraCIPositionVector
unsigned int getMinExpectedNumber() const
SUMOReal getAdaptedTraveltime(const std::string &edgeID, SUMOTime time) const
std::vector< std::string > getEdges(const std::string &routeID) const
void remove(const std::string &poiID, int layer=0) const
SUMOReal getFloat(int cmd, int var, const std::string &id, tcpip::Storage *add=0)
std::string id
The id of the vehicle.
unsigned int getPhase(const std::string &tlsID) const
SUMOReal getLength(const std::string &typeID) const
SUMOReal getTau(const std::string &typeID) const
unsigned int getLastStepVehicleNumber(const std::string &detID) const
#define VAR_ARRIVED_VEHICLES_IDS
std::vector< std::string > getLastStepVehicleIDs(const std::string &edgeID) const
#define LAST_STEP_VEHICLE_HALTING_NUMBER
SUMOReal getFuelConsumption(const std::string &laneID) const
void setColor(const std::string &poiID, const TraCIColor &c) const
void add(const std::string &routeID, const std::vector< std::string > &edges) const
std::vector< std::string > getIDList() const
SUMOReal getLastStepHaltingNumber(const std::string &edgeID) const
std::vector< std::string > getStartingTeleportIDList() const