41 const std::string
id = inputStorage.
readString();
44 if (!libsumo::TrafficLight::handleVariable(
id, variable, &server)) {
47 std::vector<libsumo::TraCILogic> logics = libsumo::TrafficLight::getCompleteRedYellowGreenDefinition(
id);
50 storage.
writeInt((
int)logics.size());
61 storage.
writeInt(logic.currentPhaseIndex);
64 storage.
writeInt((
int)logic.phases.size());
78 for (
int n : phase->
next) {
87 storage.
writeInt((
int)logic.subParameter.size());
88 for (
const auto& item : logic.subParameter) {
98 const std::vector<std::vector<libsumo::TraCILink> > links = libsumo::TrafficLight::getControlledLinks(
id);
103 tempContent.
writeInt((
int)links.size());
104 for (
const std::vector<libsumo::TraCILink>& sublinks : links) {
106 tempContent.
writeInt((
int)sublinks.size());
110 tempContent.
writeStringList(std::vector<std::string>({ link.fromLane, link.toLane, link.viaLane }));
155 std::string paramName =
"";
164 std::string paramName =
"";
184 for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
185 if (
"connection:" == (*i).first.substr(0, 11)) {
193 for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
194 if (
"connection:" != (*i).first.substr(0, 11)) {
199 std::string connection = (*i).first.substr(11);
200 std::string from, to;
201 const std::string::size_type b = connection.find(
"->");
202 if (b == std::string::npos) {
205 from = connection.substr(0, b);
206 to = connection.substr(b + 2);
208 bool denotesEdge = from.find(
"_") == std::string::npos;
209 MSLane* fromLane =
nullptr;
211 MSTrafficLightLogic::LaneVectorVector::const_iterator j = lanes.begin();
212 for (; j != lanes.end() && fromLane ==
nullptr;) {
213 for (MSTrafficLightLogic::LaneVector::const_iterator k = (*j).begin(); k != (*j).end() && fromLane ==
nullptr;) {
214 if (denotesEdge && (*k)->getEdge().getID() == from) {
216 }
else if (!denotesEdge && (*k)->getID() == from) {
219 if (fromLane ==
nullptr) {
223 if (fromLane ==
nullptr) {
227 if (fromLane ==
nullptr) {
230 int pos = (int)std::distance(lanes.begin(), j);
252 std::string warning =
"";
261 const std::string
id = inputStorage.
readString();
269 libsumo::TrafficLight::setPhase(
id, index);
277 libsumo::TrafficLight::setPhaseName(
id, name);
285 libsumo::TrafficLight::setProgram(
id, subID);
289 double duration = 0.;
293 libsumo::TrafficLight::setPhaseDuration(
id, duration);
301 libsumo::TrafficLight::setRedYellowGreenState(
id, state);
323 const int numPhases = inputStorage.
readInt();
324 for (
int j = 0; j < numPhases; ++j) {
328 const int items = inputStorage.
readInt();
329 if (items != 6 && items != 5) {
332 double duration = 0., minDuration = 0., maxDuration = 0.;
333 std::vector<int> next;
351 const int numNext = inputStorage.
readInt();
352 for (
int k = 0; k < numNext; k++) {
357 next.push_back(nextEntry);
369 const int numParams = inputStorage.
readInt();
370 for (
int j = 0; j < numParams; j++) {
371 std::vector<std::string> par;
375 libsumo::TrafficLight::setCompleteRedYellowGreenDefinition(
id, logic);
392 libsumo::TrafficLight::setParameter(
id, name, value);
std::string toHex(const T i, std::streamsize numDigits=0)
Representation of a lane in the micro simulation.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
const std::string & getState() const
Returns the state within this phase.
MSTrafficLightLogic * getActive() const
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
The parent class for traffic light logics.
virtual const MSPhaseDefinition & getCurrentPhaseDef() const =0
Returns the definition of the current phase.
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of lanes that do have the same attribute.
const LaneVectorVector & getLaneVectors() const
Returns the list of lists of all lanes controlled by this tls.
const std::map< std::string, std::string > & getParametersMap() const
Returns the inner key/value map.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa2: Get Traffic Lights Variable)
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.
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
bool readTypeCheckingString(tcpip::Storage &inputStorage, std::string &into)
Reads the value type and a string, verifying the type.
tcpip::Storage & getWrapperStorage()
void initWrapper(const int domainID, const int variable, const std::string &objID)
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
bool readTypeCheckingInt(tcpip::Storage &inputStorage, int &into)
Reads the value type and an int, verifying the type.
bool readTypeCheckingStringList(tcpip::Storage &inputStorage, std::vector< std::string > &into)
Reads the value type and a string list, verifying the type.
bool readTypeCheckingDouble(tcpip::Storage &inputStorage, double &into)
Reads the value type and a double, verifying the type.
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
std::map< std::string, std::string > subParameter
std::vector< TraCIPhase * > phases
virtual std::string readString()
virtual void writeString(const std::string &s)
virtual void writeInt(int)
virtual void writeDouble(double)
virtual int readUnsignedByte()
virtual void writeStringList(const std::vector< std::string > &s)
virtual void writeUnsignedByte(int)
virtual void writeStorage(tcpip::Storage &store)
TRACI_CONST int CMD_GET_TL_VARIABLE
TRACI_CONST int TL_BLOCKING_VEHICLES
TRACI_CONST int TL_PRIORITY_VEHICLES
TRACI_CONST int TYPE_COMPOUND
TRACI_CONST int TL_COMPLETE_DEFINITION_RYG
TRACI_CONST int TYPE_UBYTE
TRACI_CONST int VAR_PERSON_NUMBER
TRACI_CONST int TL_EXTERNAL_STATE
TRACI_CONST int TYPE_STRINGLIST
TRACI_CONST int TL_CONTROLLED_LINKS
TRACI_CONST int TYPE_INTEGER
TRACI_CONST int VAR_PARAMETER
TRACI_CONST int VAR_PARAMETER_WITH_KEY
TRACI_CONST int TL_PROGRAM
TRACI_CONST int RESPONSE_GET_TL_VARIABLE
TRACI_CONST int TL_PHASE_DURATION
TRACI_CONST int TL_PHASE_INDEX
TRACI_CONST int TYPE_DOUBLE
TRACI_CONST int TL_COMPLETE_PROGRAM_RYG
TRACI_CONST int CMD_SET_TL_VARIABLE
TRACI_CONST int TL_RED_YELLOW_GREEN_STATE
TRACI_CONST int TYPE_STRING
TRACI_CONST int TL_RIVAL_VEHICLES