 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
51 const std::string& subid,
int noLinks,
53 Named(id), myNumLinks(noLinks), mySubID(subid),
58 Named(logic->getID()),
59 myNumLinks(logic->myNumLinks),
60 mySubID(logic->getProgramID()),
61 myOffset(logic->getOffset()),
62 myPhases(logic->myPhases.begin(), logic->myPhases.end()),
63 myType(logic->getType()) {}
88 if (std::string::npos != illegal) {
89 throw ProcessError(
"When adding phase: illegal character '" +
toString(state[illegal]) +
"' in state");
92 if (index < 0 || index >= (
int)
myPhases.size()) {
102 if (index >= (
int)
myPhases.size()) {
114 p.state = p.state.substr(0, numLinks);
117 std::string add(numLinks -
myNumLinks, (
char)fill);
119 p.state = p.state + add;
136 for (PhaseDefinitionVector::const_iterator i =
myPhases.begin(); i !=
myPhases.end(); ++i) {
137 duration += (*i).duration;
145 for (
int i = 0; i < (int)
myPhases.size() - 1;) {
168 if (checkVarDurations) {
179 WRITE_WARNING(
"Non-static traffic light '" +
getID() +
"' does not define variable phase length.");
188 assert(phaseIndex < (
int)
myPhases.size());
189 std::string& phaseState =
myPhases[phaseIndex].state;
190 assert(tlIndex < (
int)phaseState.size());
191 phaseState[tlIndex] = (char)linkState;
197 assert(phaseIndex < (
int)
myPhases.size());
198 myPhases[phaseIndex].duration = duration;
203 assert(phaseIndex < (
int)
myPhases.size());
204 myPhases[phaseIndex].minDur = duration;
209 assert(phaseIndex < (
int)
myPhases.size());
210 myPhases[phaseIndex].maxDur = duration;
215 assert(phaseIndex < (
int)
myPhases.size());
221 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)