43 const std::string
id = inputStorage.
readString();
52 storage.
writeInt((
int)logics.size());
63 storage.
writeInt(logic.currentPhaseIndex);
66 storage.
writeInt((
int)logic.phases.size());
83 storage.
writeInt((
int)logic.subParameter.size());
84 for (
const auto& item : logic.subParameter) {
99 tempContent.
writeInt((
int)links.size());
100 for (
const std::vector<libsumo::TraCILink>& sublinks : links) {
102 tempContent.
writeInt((
int)sublinks.size());
106 tempContent.
writeStringList(std::vector<std::string>({ link.fromLane, link.toLane, link.viaLane }));
115 std::string paramName =
"";
131 for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
132 if (
"connection:" == (*i).first.substr(0, 11)) {
140 for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
141 if (
"connection:" != (*i).first.substr(0, 11)) {
146 std::string connection = (*i).first.substr(11);
147 std::string from, to;
148 const std::string::size_type b = connection.find(
"->");
149 if (b == std::string::npos) {
152 from = connection.substr(0, b);
153 to = connection.substr(b + 2);
155 bool denotesEdge = from.find(
"_") == std::string::npos;
156 MSLane* fromLane =
nullptr;
158 MSTrafficLightLogic::LaneVectorVector::const_iterator j = lanes.begin();
159 for (; j != lanes.end() && fromLane ==
nullptr;) {
160 for (MSTrafficLightLogic::LaneVector::const_iterator k = (*j).begin(); k != (*j).end() && fromLane ==
nullptr;) {
161 if (denotesEdge && (*k)->getEdge().getID() == from) {
163 }
else if (!denotesEdge && (*k)->getID() == from) {
166 if (fromLane ==
nullptr) {
170 if (fromLane ==
nullptr) {
174 if (fromLane ==
nullptr) {
177 int pos = (int)std::distance(lanes.begin(), j);
199 std::string warning =
"";
207 const std::string
id = inputStorage.
readString();
227 double duration = 0.;
261 const int numPhases = inputStorage.
readInt();
262 for (
int j = 0; j < numPhases; ++j) {
267 double duration = 0., minDuration = 0., maxDuration = 0.;
290 const int numParams = inputStorage.
readInt();
291 for (
int j = 0; j < numParams; j++) {
292 std::vector<std::string> par;
virtual const MSPhaseDefinition & getCurrentPhaseDef() const =0
Returns the definition of the current phase.
const std::string & getState() const
Returns the state within this phase.
#define CMD_GET_TL_VARIABLE
static void setPhaseDuration(const std::string &tlsID, const double phaseDuration)
const LaneVectorVector & getLaneVectors() const
Returns the list of lists of all lanes controlled by this tls.
static void setParameter(const std::string &tlsID, const std::string ¶mName, const std::string &value)
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc2: Change Traffic Lights State)
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).
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
std::map< std::string, std::string > subParameter
#define RESPONSE_GET_TL_VARIABLE
static bool handleVariable(const std::string &objID, const int variable, VariableWrapper *wrapper)
virtual void writeUnsignedByte(int)
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
std::vector< TraCIPhase > phases
virtual void writeInt(int)
virtual int readUnsignedByte()
#define TL_PHASE_DURATION
static void setRedYellowGreenState(const std::string &tlsID, const std::string &state)
#define CMD_SET_TL_VARIABLE
#define TL_COMPLETE_PROGRAM_RYG
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
#define TL_COMPLETE_DEFINITION_RYG
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
virtual void writeStringList(const std::vector< std::string > &s)
#define TL_EXTERNAL_STATE
tcpip::Storage & getWrapperStorage()
virtual std::string readString()
TraCI server used to control sumo by a remote TraCI client.
virtual void writeStorage(tcpip::Storage &store)
#define TL_CONTROLLED_LINKS
static std::vector< TraCILogic > getCompleteRedYellowGreenDefinition(const std::string &tlsID)
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
#define TL_RED_YELLOW_GREEN_STATE
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa2: Get Traffic Lights Variable)
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
virtual void writeString(const std::string &s)
std::string toHex(const T i, std::streamsize numDigits=0)
static void setPhase(const std::string &tlsID, const int index)
virtual void writeDouble(double)
static void setCompleteRedYellowGreenDefinition(const std::string &tlsID, const TraCILogic &logic)
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
The parent class for traffic light logics.
static void setProgram(const std::string &tlsID, const std::string &programID)
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
void initWrapper(const int domainID, const int variable, const std::string &objID)
MSTrafficLightLogic * getActive() const
static std::string getParameter(const std::string &tlsID, const std::string ¶mName)
Representation of a lane in the micro simulation.
static std::vector< std::vector< TraCILink > > getControlledLinks(const std::string &tlsID)