43 #ifdef CHECK_MEMORY_LEAKS 45 #endif // CHECK_MEMORY_LEAKS 94 std::vector<MSTrafficLightLogic*> logics = vars.
getAllLogics();
99 tempContent.
writeInt((
int) logics.size());
101 for (
int i = 0; i < (int)logics.size(); ++i) {
123 for (
int j = 0; j < phaseNo; ++j) {
134 const std::string& state = phase.
getState();
148 std::vector<std::string> laneIDs;
149 for (MSTrafficLightLogic::LaneVectorVector::const_iterator i = lanes.begin(); i != lanes.end(); ++i) {
151 for (MSTrafficLightLogic::LaneVector::const_iterator j = llanes.begin(); j != llanes.end(); ++j) {
152 laneIDs.push_back((*j)->getID());
166 int no = (int) lanes.size();
168 for (
int i = 0; i < no; ++i) {
173 int no2 = (int) llanes.size();
176 for (
int j = 0; j < no2; ++j) {
178 std::vector<std::string> def;
180 def.push_back(llanes[j]->getID());
184 #ifdef HAVE_INTERNAL_LANES 185 def.push_back(link->getViaLane() != 0 ? link->getViaLane()->getID() :
"");
215 std::string paramName =
"";
229 const std::map<std::string, std::string>& params = tls->
getMap();
231 for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
232 if (
"connection:" == (*i).first.substr(0, 11)) {
240 for (std::map<std::string, std::string>::const_iterator i = params.begin(); i != params.end(); ++i) {
241 if (
"connection:" != (*i).first.substr(0, 11)) {
246 std::string connection = (*i).first.substr(11);
247 std::string from, to;
248 const std::string::size_type b = connection.find(
"->");
249 if (b == std::string::npos) {
252 from = connection.substr(0, b);
253 to = connection.substr(b + 2);
255 bool denotesEdge = from.find(
"_") == std::string::npos;
258 MSTrafficLightLogic::LaneVectorVector::const_iterator j = lanes.begin();
259 for (; j != lanes.end() && fromLane == 0;) {
260 for (MSTrafficLightLogic::LaneVector::const_iterator k = (*j).begin(); k != (*j).end() && fromLane == 0;) {
261 if (denotesEdge && (*k)->getEdge().getID() == from) {
263 }
else if (!denotesEdge && (*k)->getID() == from) {
277 int pos = (int)std::distance(lanes.begin(), j);
296 std::string warning =
"";
358 int type = 0, index = 0, phaseNo = 0;
379 if (index >= phaseNo) {
383 std::vector<MSPhaseDefinition*> phases;
384 for (
int j = 0; j < phaseNo; ++j) {
385 int duration = 0, minDuration = 0, maxDuration = 0;
400 phases.push_back(phase);
404 vars.
addLogic(subid, logic,
true,
true);
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
Storage for all programs of a single tls.
MSLane * getLane() const
Returns the connected lane.
virtual void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)=0
Changes the current phase and her duration.
const LaneVectorVector & getLaneVectors() const
Returns the list of lists of all lanes controlled by this tls.
virtual const MSPhaseDefinition & getPhase(int givenstep) const =0
Returns the definition of the phase from the given position within the plan.
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.
#define RESPONSE_GET_TL_VARIABLE
virtual int getCurrentPhaseIndex() const =0
Returns the current index within the program.
const std::string & getID() const
Returns the id.
virtual void writeUnsignedByte(int)
#define TL_CONTROLLED_JUNCTIONS
bool writeErrorStatusCmd(int commandId, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage with status = RTYPE_ERR.
const LinkVectorVector & getLinks() const
Returns the list of lists of all affected links.
virtual void writeInt(int)
A fixed traffic light logic.
virtual int readUnsignedByte()
#define TL_PHASE_DURATION
#define TL_CURRENT_PROGRAM
#define CMD_SET_TL_VARIABLE
A class that stores and controls tls and switching of their programs.
SUMOTime duration
The duration of the phase.
std::vector< MSTrafficLightLogic * > getAllLogics() const
bool addLogic(const std::string &programID, MSTrafficLightLogic *logic, bool netWasLoaded, bool isNewDefault=true)
Adds a logic (program)
std::vector< LinkVector > LinkVectorVector
Definition of a list that holds lists of links that do have the same attribute.
virtual int getPhaseNumber() const =0
Returns the number of phases.
#define TL_COMPLETE_PROGRAM_RYG
const std::string & getProgramID() const
Returns this tl-logic's id.
MSTLLogicControl & getTLSControl()
Returns the tls logics control.
#define TL_COMPLETE_DEFINITION_RYG
virtual void writeStringList(const std::vector< std::string > &s)
#define TL_EXTERNAL_STATE
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
virtual std::string readString()
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
TraCI server used to control sumo by a remote TraCI client.
void setStateInstantiatingOnline(MSTLLogicControl &tlc, const std::string &state)
virtual void writeStorage(tcpip::Storage &store)
#define TL_CONTROLLED_LINKS
void writeResponseWithLength(tcpip::Storage &outputStorage, tcpip::Storage &tempMsg)
bool knows(const std::string &id) const
Returns the information whether the named tls is stored.
#define TL_RED_YELLOW_GREEN_STATE
std::vector< MSLink * > LinkVector
Definition of the list of links that participate in this tl-light.
void addParameter(const std::string &key, const std::string &value)
Adds a parameter.
const std::string & getParameter(const std::string &key, const std::string &defaultValue) const
Returns the value for a given key.
void switchTo(MSTLLogicControl &tlc, const std::string &programID)
std::vector< MSLane * > LaneVector
Definition of the list of links that participate in this tl-light.
std::vector< LaneVector > LaneVectorVector
Definition of a list that holds lists of links that do have the same attribute.
virtual void writeString(const std::string &s)
SUMOTime maxDuration
The maximum duration of the phase.
std::string toHex(const T i, std::streamsize numDigits=0)
SUMOTime getNextSwitchTime() const
Returns the assumed next switch time.
const std::map< std::string, std::string > & getMap() const
Returns the inner key/value map.
SUMOTime minDuration
The minimum duration of the phase.
The parent class for traffic light logics.
static bool processSet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a set value command (Command 0xc2: Change Traffic Lights State)
void writeStatusCmd(int commandId, int status, const std::string &description, tcpip::Storage &outputStorage)
Writes a status command to the given storage.
#define TL_CONTROLLED_LANES
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
MSTrafficLightLogic * getActive() const
std::vector< std::string > getAllTLIds() const
MSTrafficLightLogic * getLogic(const std::string &programID) const
Representation of a lane in the micro simulation.
The definition of a single phase of a tls logic.
static bool processGet(TraCIServer &server, tcpip::Storage &inputStorage, tcpip::Storage &outputStorage)
Processes a get value command (Command 0xa2: Get Traffic Lights Variable)