21 #ifndef MSPhaseDefinition_h 22 #define MSPhaseDefinition_h 25 #define TRANSIENT_NOTDECISIONAL_BIT 1 27 #define UNDEFINED_BIT 3 108 this->duration = durationArg;
109 this->state = stateArg;
110 this->minDuration = minDurationArg < 0 ? durationArg : minDurationArg;
111 this->maxDuration = (maxDurationArg < 0 || maxDurationArg < minDurationArg) ? durationArg : maxDurationArg;
119 void init(
SUMOTime durationArg,
SUMOTime minDurationArg,
SUMOTime maxDurationArg,
const std::string& stateArg,
int nextPhase, LaneIdVector& targetLaneSetArg) {
120 init(durationArg, stateArg, minDurationArg, maxDurationArg, nextPhase);
122 this->targetLaneSet = targetLaneSetArg;
141 init(durationArg, stateArg, durationArg, durationArg, nextPhase);
159 init(durationArg, stateArg, minDurationArg, maxDurationArg, nextPhase);
170 MSPhaseDefinition(
SUMOTime durationArg,
const std::string& stateArg,
int nextPhase,
bool transient_notdecisional,
bool commit, LaneIdVector& targetLaneSetArg) {
171 if (targetLaneSetArg.size() == 0) {
180 init(durationArg, durationArg, durationArg, stateArg, nextPhase, targetLaneSetArg);
195 init(durationArg, stateArg, durationArg, durationArg, nextPhase);
207 if (targetLaneSetArg.size() == 0) {
217 init(durationArg, minDurationArg, maxDurationArg, stateArg, nextPhase, targetLaneSetArg);
233 init(durationArg, stateArg, minDurationArg, maxDurationArg, nextPhase);
269 if (state.find_first_of(
"gG") == std::string::npos) {
272 if (state.find_first_of(
"yY") != std::string::npos) {
295 return state != pd.
state;
const std::string & getState() const
Returns the state within this phase.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
#define TRANSIENT_NOTDECISIONAL_BIT
LaneIdVector targetLaneSet
std::bitset< 4 > PhaseType
MSPhaseDefinition(SUMOTime durationArg, const std::string &stateArg, SUMOTime minDurationArg, SUMOTime maxDurationArg, int nextPhase, bool transient_notdecisional, bool commit, LaneIdVector &targetLaneSetArg)
LinkState getSignalState(int pos) const
Returns the state of the tls signal at the given position.
MSPhaseDefinition(SUMOTime durationArg, const std::string &stateArg, int nextPhase, bool transient_notdecisional, bool commit)
static OptionsCont & getOptions()
Retrieves the options.
SUMOTime duration
The duration of the phase.
void setState(const std::string &_state)
SUMOTime myLastSwitch
Stores the timestep of the last on-switched of the phase.
void init(SUMOTime durationArg, const std::string &stateArg, SUMOTime minDurationArg, SUMOTime maxDurationArg, int nextPhase)
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
SUMOTime string2time(const std::string &r)
MSPhaseDefinition(SUMOTime durationArg, const std::string &stateArg, SUMOTime minDurationArg=-1, SUMOTime maxDurationArg=-1, int nextPhase=-1)
Constructor In this phase the duration is constrained between min and max duration.
MSPhaseDefinition(SUMOTime durationArg, const std::string &stateArg, int nextPhase)
Constructor.
MSPhaseDefinition(SUMOTime durationArg, const std::string &stateArg, SUMOTime minDurationArg, SUMOTime maxDurationArg, int nextPhase, bool transient_notdecisional, bool commit)
SUMOTime lastDuration
The previous duration of the phase.
std::string state
The phase definition.
SUMOTime maxDuration
The maximum duration of the phase.
std::vector< std::string > LaneIdVector
void inform(std::string msg, bool addType=true)
adds a new error to the list
bool operator!=(const MSPhaseDefinition &pd)
Comparison operator.
SUMOTime minDuration
The minimum duration of the phase.
MSPhaseDefinition(SUMOTime durationArg, const std::string &stateArg, int nextPhase, bool transient_notdecisional, bool commit, LaneIdVector &targetLaneSetArg)
bool isGreenPhase() const
Returns whether this phase is a pure "green" phase.
virtual ~MSPhaseDefinition()
Destructor.
const LaneIdVector & getTargetLaneSet() const
int nextPhase
The index of the phase that suceeds this one (or -1)
void init(SUMOTime durationArg, SUMOTime minDurationArg, SUMOTime maxDurationArg, const std::string &stateArg, int nextPhase, LaneIdVector &targetLaneSetArg)
The definition of a single phase of a tls logic.
bool isDecisional() const