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());
80 for (
int n : phase.
next) {
89 storage.
writeInt((
int)logic.subParameter.size());
90 for (
const auto& item : logic.subParameter) {
105 tempContent.
writeInt((
int)links.size());
106 for (
const std::vector<libsumo::TraCILink>& sublinks : links) {
108 tempContent.
writeInt((
int)sublinks.size());
112 tempContent.
writeStringList(std::vector<std::string>({ link.fromLane, link.toLane, link.viaLane }));
121 std::string paramName =
"";
137 for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
138 if (
"connection:" == (*i).first.substr(0, 11)) {
146 for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
147 if (
"connection:" != (*i).first.substr(0, 11)) {
152 std::string connection = (*i).first.substr(11);
153 std::string from, to;
154 const std::string::size_type b = connection.find(
"->");
155 if (b == std::string::npos) {
158 from = connection.substr(0, b);
159 to = connection.substr(b + 2);
161 bool denotesEdge = from.find(
"_") == std::string::npos;
162 MSLane* fromLane =
nullptr;
164 MSTrafficLightLogic::LaneVectorVector::const_iterator j = lanes.begin();
165 for (; j != lanes.end() && fromLane ==
nullptr;) {
166 for (MSTrafficLightLogic::LaneVector::const_iterator k = (*j).begin(); k != (*j).end() && fromLane ==
nullptr;) {
167 if (denotesEdge && (*k)->getEdge().getID() == from) {
169 }
else if (!denotesEdge && (*k)->getID() == from) {
172 if (fromLane ==
nullptr) {
176 if (fromLane ==
nullptr) {
180 if (fromLane ==
nullptr) {
183 int pos = (int)std::distance(lanes.begin(), j);
205 std::string warning =
"";
214 const std::string
id = inputStorage.
readString();
242 double duration = 0.;
276 const int numPhases = inputStorage.
readInt();
277 for (
int j = 0; j < numPhases; ++j) {
281 int items = inputStorage.
readInt();
282 if (items != 6 && items != 5) {
285 double duration = 0., minDuration = 0., maxDuration = 0.;
286 std::vector<int> next;
303 std::cout <<
" byte:" << tmp <<
"\n";
306 const int numNext = inputStorage.
readInt();
307 for (
int k = 0; k < numNext; k++) {
324 const int numParams = inputStorage.
readInt();
325 for (
int j = 0; j < numParams; j++) {
326 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.
TRACI_CONST int CMD_GET_TL_VARIABLE
TRACI_CONST int TL_PHASE_INDEX
TRACI_CONST int TL_PROGRAM
static void setPhaseDuration(const std::string &tlsID, const double phaseDuration)
TRACI_CONST int TL_COMPLETE_PROGRAM_RYG
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)
TRACI_CONST int VAR_PARAMETER
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).
TRACI_CONST int TL_PHASE_DURATION
TRACI_CONST int TL_CONTROLLED_LINKS
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
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()
static void setRedYellowGreenState(const std::string &tlsID, const std::string &state)
TRACI_CONST int TYPE_INTEGER
TRACI_CONST int CMD_SET_TL_VARIABLE
TRACI_CONST int TL_EXTERNAL_STATE
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
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)
TRACI_CONST int TYPE_DOUBLE
tcpip::Storage & getWrapperStorage()
TRACI_CONST int TYPE_STRINGLIST
virtual std::string readString()
TRACI_CONST int TYPE_STRING
TraCI server used to control sumo by a remote TraCI client.
virtual void writeStorage(tcpip::Storage &store)
static std::vector< TraCILogic > getCompleteRedYellowGreenDefinition(const std::string &tlsID)
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
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)
TRACI_CONST int RESPONSE_GET_TL_VARIABLE
TRACI_CONST int TL_COMPLETE_DEFINITION_RYG
static void setPhase(const std::string &tlsID, const int index)
static void setPhaseName(const std::string &tlsID, const std::string &name)
TRACI_CONST int TL_RED_YELLOW_GREEN_STATE
TRACI_CONST int TYPE_UBYTE
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)
TRACI_CONST int TYPE_COMPOUND