 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
42 const std::string
id = inputStorage.
readString();
51 storage.
writeInt((
int)logics.size());
62 storage.
writeInt(logic.currentPhaseIndex);
65 storage.
writeInt((
int)logic.phases.size());
79 for (
int n : phase.
next) {
88 storage.
writeInt((
int)logic.subParameter.size());
89 for (
const auto& item : logic.subParameter) {
104 tempContent.
writeInt((
int)links.size());
105 for (
const std::vector<libsumo::TraCILink>& sublinks : links) {
107 tempContent.
writeInt((
int)sublinks.size());
111 tempContent.
writeStringList(std::vector<std::string>({ link.fromLane, link.toLane, link.viaLane }));
129 std::string paramName =
"";
145 for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
146 if (
"connection:" == (*i).first.substr(0, 11)) {
154 for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
155 if (
"connection:" != (*i).first.substr(0, 11)) {
160 std::string connection = (*i).first.substr(11);
161 std::string from, to;
162 const std::string::size_type b = connection.find(
"->");
163 if (b == std::string::npos) {
166 from = connection.substr(0, b);
167 to = connection.substr(b + 2);
169 bool denotesEdge = from.find(
"_") == std::string::npos;
170 MSLane* fromLane =
nullptr;
172 MSTrafficLightLogic::LaneVectorVector::const_iterator j = lanes.begin();
173 for (; j != lanes.end() && fromLane ==
nullptr;) {
174 for (MSTrafficLightLogic::LaneVector::const_iterator k = (*j).begin(); k != (*j).end() && fromLane ==
nullptr;) {
175 if (denotesEdge && (*k)->getEdge().getID() == from) {
177 }
else if (!denotesEdge && (*k)->getID() == from) {
180 if (fromLane ==
nullptr) {
184 if (fromLane ==
nullptr) {
188 if (fromLane ==
nullptr) {
191 int pos = (int)std::distance(lanes.begin(), j);
213 std::string warning =
"";
222 const std::string
id = inputStorage.
readString();
250 double duration = 0.;
284 const int numPhases = inputStorage.
readInt();
285 for (
int j = 0; j < numPhases; ++j) {
289 const int items = inputStorage.
readInt();
290 if (items != 6 && items != 5) {
293 double duration = 0., minDuration = 0., maxDuration = 0.;
294 std::vector<int> next;
312 const int numNext = inputStorage.
readInt();
313 for (
int k = 0; k < numNext; k++) {
318 next.push_back(nextEntry);
330 const int numParams = inputStorage.
readInt();
331 for (
int j = 0; j < numParams; j++) {
332 std::vector<std::string> par;
TRACI_CONST int CMD_GET_TL_VARIABLE
virtual void writeUnsignedByte(int)
TRACI_CONST int TL_PHASE_INDEX
static std::vector< std::vector< TraCILink > > getControlledLinks(const std::string &tlsID)
static void setParameter(const std::string &tlsID, const std::string ¶mName, const std::string &value)
static void setProgram(const std::string &tlsID, const std::string &programID)
TRACI_CONST int TL_CONTROLLED_LINKS
Representation of a lane in the micro simulation.
TRACI_CONST int TL_PROGRAM
TRACI_CONST int TL_COMPLETE_PROGRAM_RYG
TRACI_CONST int TL_PHASE_DURATION
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
TRACI_CONST int VAR_PERSON_NUMBER
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int TL_EXTERNAL_STATE
static void setPhase(const std::string &tlsID, const int index)
tcpip::Storage & getWrapperStorage()
MSTrafficLightLogic * getActive() const
static void setCompleteRedYellowGreenDefinition(const std::string &tlsID, const TraCILogic &logic)
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
virtual void writeDouble(double)
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
static void setRedYellowGreenState(const std::string &tlsID, const std::string &state)
void initWrapper(const int domainID, const int variable, const std::string &objID)
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
virtual void writeString(const std::string &s)
virtual void writeInt(int)
TRACI_CONST int TYPE_DOUBLE
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
virtual void writeStorage(tcpip::Storage &store)
virtual int readUnsignedByte()
TRACI_CONST int TYPE_INTEGER
const std::string & getState() const
Returns the state within this phase.
virtual void writeStringList(const std::vector< std::string > &s)
std::string toHex(const T i, std::streamsize numDigits=0)
TRACI_CONST int CMD_SET_TL_VARIABLE
static void setPhaseDuration(const std::string &tlsID, const double phaseDuration)
The parent class for traffic light logics.
static void setPhaseName(const std::string &tlsID, const std::string &name)
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
static std::string getParameter(const std::string &tlsID, const std::string ¶mName)
TRACI_CONST int TYPE_STRINGLIST
const LaneVectorVector & getLaneVectors() const
Returns the list of lists of all lanes controlled by this tls.
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
std::vector< TraCIPhase > phases
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa2: Get Traffic Lights Variable)
static int getServedPersonCount(const std::string &tlsID, int index)
TRACI_CONST int TYPE_STRING
TRACI_CONST int TL_RED_YELLOW_GREEN_STATE
TRACI_CONST int TYPE_UBYTE
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
TRACI_CONST int RESPONSE_GET_TL_VARIABLE
std::map< std::string, std::string > subParameter
virtual std::string readString()
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc2: Change Traffic Lights State)
TraCI server used to control sumo by a remote TraCI client.
TRACI_CONST int TL_COMPLETE_DEFINITION_RYG
static std::vector< TraCILogic > getCompleteRedYellowGreenDefinition(const std::string &tlsID)
virtual const MSPhaseDefinition & getCurrentPhaseDef() const =0
Returns the definition of the current phase.
TRACI_CONST int TYPE_COMPOUND
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.