21 #ifndef MSPhaseDefinition_h 22 #define MSPhaseDefinition_h 25 #define TRANSIENT_NOTDECISIONAL_BIT 1 27 #define UNDEFINED_BIT 3 111 const std::vector<int> nextPhasesArg,
const std::string& nameArg) {
112 this->duration = durationArg;
113 this->state = stateArg;
114 this->minDuration = minDurationArg < 0 ? durationArg : minDurationArg;
115 this->maxDuration = (maxDurationArg < 0 || maxDurationArg < minDurationArg) ? durationArg : maxDurationArg;
120 this->nextPhases = nextPhasesArg;
121 this->name = nameArg;
125 const std::vector<int>& nextPhasesArg,
const std::string& nameArg, LaneIdVector* targetLaneSetArg) {
126 init(durationArg, stateArg, minDurationArg, maxDurationArg, nextPhasesArg, nameArg);
128 if (targetLaneSetArg !=
nullptr) {
129 this->targetLaneSet = *targetLaneSetArg;
142 MSPhaseDefinition(
SUMOTime durationArg,
const std::string& stateArg,
const std::vector<int>& nextPhases,
const std::string& name =
"") {
149 init(durationArg, stateArg, durationArg, durationArg, nextPhases, name);
161 const std::vector<int>& nextPhases = std::vector<int>(),
const std::string& name =
"") {
168 init(durationArg, stateArg, minDurationArg, maxDurationArg, nextPhases, name);
179 const std::vector<int>& nextPhases,
const std::string& name,
bool transient_notdecisional,
bool commit, LaneIdVector* targetLaneSetArg =
nullptr) {
180 if (targetLaneSetArg !=
nullptr && targetLaneSetArg->size() == 0) {
188 phaseType[
TARGET_BIT] = targetLaneSetArg ==
nullptr ? 0 : 1;
190 init(durationArg, minDurationArg, maxDurationArg, stateArg, nextPhases, name, targetLaneSetArg);
232 if (state.find_first_of(
"gG") == std::string::npos) {
235 if (state.find_first_of(
"yY") != std::string::npos) {
258 return state != pd.
state;
std::vector< int > nextPhases
The index of the phase that suceeds this one (or -1)
const std::string & getState() const
Returns the state within this phase.
static MsgHandler * getErrorInstance()
Returns the instance to add errors to.
MSPhaseDefinition(SUMOTime durationArg, const std::string &stateArg, SUMOTime minDurationArg, SUMOTime maxDurationArg, const std::vector< int > &nextPhases, const std::string &name, bool transient_notdecisional, bool commit, LaneIdVector *targetLaneSetArg=nullptr)
#define TRANSIENT_NOTDECISIONAL_BIT
LaneIdVector targetLaneSet
std::bitset< 4 > PhaseType
LinkState getSignalState(int pos) const
Returns the state of the tls signal at the given position.
void init(SUMOTime durationArg, SUMOTime minDurationArg, SUMOTime maxDurationArg, const std::string &stateArg, const std::vector< int > &nextPhasesArg, const std::string &nameArg, LaneIdVector *targetLaneSetArg)
MSPhaseDefinition(SUMOTime durationArg, const std::string &stateArg, const std::vector< int > &nextPhases, const std::string &name="")
Constructor.
void init(SUMOTime durationArg, const std::string &stateArg, SUMOTime minDurationArg, SUMOTime maxDurationArg, const std::vector< int > nextPhasesArg, const std::string &nameArg)
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.
std::string name
Optional name or description for the current phase.
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)
SUMOTime lastDuration
The previous duration of the phase.
const std::vector< int > & getNextPhases() const
std::string state
The phase definition.
SUMOTime maxDuration
The maximum duration of the phase.
std::vector< std::string > LaneIdVector
virtual void inform(std::string msg, bool addType=true)
adds a new error to the list
MSPhaseDefinition(SUMOTime durationArg, const std::string &stateArg, SUMOTime minDurationArg=-1, SUMOTime maxDurationArg=-1, const std::vector< int > &nextPhases=std::vector< int >(), const std::string &name="")
Constructor In this phase the duration is constrained between min and max duration.
void setName(const std::string &_name)
bool operator!=(const MSPhaseDefinition &pd)
Comparison operator.
SUMOTime minDuration
The minimum duration of the phase.
bool isGreenPhase() const
Returns whether this phase is a pure "green" phase.
virtual ~MSPhaseDefinition()
Destructor.
const LaneIdVector & getTargetLaneSet() const
const std::string & getName() const
The definition of a single phase of a tls logic.
bool isDecisional() const