46 #ifdef CHECK_MEMORY_LEAKS
48 #endif // CHECK_MEMORY_LEAKS
55 const std::string&
id,
const std::string& subid,
const Phases& phases,
57 const std::map<std::string, std::string>& parameters) :
61 for (
int i = 0; i < (int)
myPhases.size(); i++) {
124 assert((
int)
myPhases.size() > givenStep);
147 for (
int i = 0; i <
myStep; i++) {
160 assert(index < (
int)
myPhases.size());
165 for (
int i = 0; i < index; i++) {
179 for (
int i = 0; i < (int)
myPhases.size(); i++) {
181 if (testPos > offset) {
184 if (testPos == offset) {
185 assert((
int)
myPhases.size() > (i + 1));
212 assert(step < (
int)phases.size());
221 for (
int i = 0; i < (int)
myPhases.size(); i++) {
int getCurrentPhaseIndex() const
Returns the current index within the program.
SUMOTime myCurrentDurationIncrement
A value for enlarge the current duration.
MSSimpleTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &subid, const Phases &phases, int step, SUMOTime delay, const std::map< std::string, std::string > ¶meters)
Constructor.
bool setTrafficLightSignals(SUMOTime t) const
Applies the current signal states to controlled links.
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
std::vector< SUMOTime > myOverridingTimes
A list of duration overrides.
const Phases & getPhases() const
Returns the phases of this tls program.
void setPhases(const Phases &phases, int index)
Replaces the phases and set the phase index.
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
Phases myPhases
The list of phases this logic uses.
int myStep
The current step.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
A class that stores and controls tls and switching of their programs.
const std::string & getID() const
Returns the id.
SUMOTime duration
The duration of the phase.
void deschedule(MSTrafficLightLogic *tlLogic)
Marks this swicth as invalid (if the phase duration has changed, f.e.)
Class realising the switch between the traffic light phases.
SUMOTime myDefaultCycleTime
The cycle time (without changes)
SUMOTime myLastSwitch
Stores the timestep of the last on-switched of the phase.
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
virtual SUMOTime trySwitch()
Switches to the next phase.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
void deletePhases()
frees memory responsibilities
int getPhaseNumber() const
Returns the number of phases.
virtual SUMOTime addEvent(Command *operation, SUMOTime execTimeStep, AdaptType type)
Adds an Event.
~MSSimpleTrafficLightLogic()
Destructor.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
void executeOnSwitchActions() const
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
SwitchCommand * mySwitchCommand
The current switch command.
The parent class for traffic light logics.
Patch the time in a way that it is at least as high as the simulation begin time. ...
The definition of a single phase of a tls logic.