 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
52 const std::string& subid,
int noLinks,
54 Named(id), myNumLinks(noLinks), mySubID(subid),
59 Named(logic->getID()),
60 myNumLinks(logic->myNumLinks),
61 mySubID(logic->getProgramID()),
62 myOffset(logic->getOffset()),
63 myPhases(logic->myPhases.begin(), logic->myPhases.end()),
64 myType(logic->getType()) {}
89 if (std::string::npos != illegal) {
90 throw ProcessError(
"When adding phase: illegal character '" +
toString(state[illegal]) +
"' in state");
93 if (index < 0 || index >= (
int)
myPhases.size()) {
103 if (index >= (
int)
myPhases.size()) {
115 p.state = p.state.substr(0, numLinks);
118 std::string add(numLinks -
myNumLinks, (
char)fill);
120 p.state = p.state + add;
137 for (PhaseDefinitionVector::const_iterator i =
myPhases.begin(); i !=
myPhases.end(); ++i) {
138 duration += (*i).duration;
146 for (
int i = 0; i < (int)
myPhases.size() - 1;) {
169 if (checkVarDurations) {
180 WRITE_WARNING(
"Non-static traffic light '" +
getID() +
"' does not define variable phase length.");
189 assert(phaseIndex < (
int)
myPhases.size());
190 std::string& phaseState =
myPhases[phaseIndex].state;
191 assert(tlIndex < (
int)phaseState.size());
192 phaseState[tlIndex] = (char)linkState;
198 assert(phaseIndex < (
int)
myPhases.size());
199 myPhases[phaseIndex].duration = duration;
204 assert(phaseIndex < (
int)
myPhases.size());
205 myPhases[phaseIndex].minDur = duration;
210 assert(phaseIndex < (
int)
myPhases.size());
211 myPhases[phaseIndex].maxDur = duration;
216 assert(phaseIndex < (
int)
myPhases.size());
222 assert(phaseIndex < (
int)
myPhases.size());
SUMOTime getDuration() const
Returns the duration of the complete cycle.
#define WRITE_WARNING(msg)
void setPhaseName(int phaseIndex, const std::string &name)
Base class for objects which have an id.
void closeBuilding(bool checkVarDurations=true)
closes the building process
void setPhaseDuration(int phaseIndex, SUMOTime duration)
Modifies the duration for an existing phase (used by NETEDIT)
The definition of a single phase of the logic.
PhaseDefinitionVector myPhases
The junction logic's storage for traffic light phase list.
void setPhaseState(int phaseIndex, int tlIndex, LinkState linkState)
Modifies the state for an existing phase (used by NETEDIT)
void addStep(SUMOTime duration, const std::string &state, const std::vector< int > &next=std::vector< int >(), const std::string &name="", int index=-1)
Adds a phase to the logic.
static const std::string ALLOWED_TLS_LINKSTATES
all allowed characters for phase state
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
void setPhaseMinDuration(int phaseIndex, SUMOTime duration)
static const SUMOTime UNSPECIFIED_DURATION
void setStateLength(int numLinks, LinkState fill=LINKSTATE_TL_RED)
NBTrafficLightLogic(const std::string &id, const std::string &subid, int noLinks, SUMOTime offset=0, TrafficLightType type=TLTYPE_STATIC)
Constructor.
~NBTrafficLightLogic()
Destructor.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
void deletePhase(int index)
TrafficLightType myType
The algorithm type for the traffic light.
A SUMO-compliant built logic for a traffic light.
void setPhaseNext(int phaseIndex, const std::vector< int > &next)
int myNumLinks
The number of participating links.
const std::string & getID() const
Returns the id.
void setPhaseMaxDuration(int phaseIndex, SUMOTime duration)