46 const std::map<std::string, std::string>& parameters) :
133 assert((
int)
myPhases.size() > givenStep);
156 for (
int i = 0; i <
myStep; i++) {
169 assert(index < (
int)
myPhases.size());
174 for (
int i = 0; i < index; i++) {
188 for (
int i = 0; i < (int)
myPhases.size(); i++) {
190 if (testPos > offset) {
193 if (testPos == offset) {
194 assert((
int)
myPhases.size() > (i + 1));
227 if (latest > earliest && latest < minEnd) {
230 }
else if (latest < earliest && latest >= minEnd) {
268 if (step >= 0 && step !=
myStep) {
281 assert(step < (
int)phases.size());
290 for (
int i = 0; i < (int)
myPhases.size(); i++) {
@ SUMO_TAG_TLLOGIC
a traffic light logic
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
virtual void addEvent(Command *operation, SUMOTime execTimeStep=-1)
Adds an Event.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
MSEventControl * getBeginOfTimestepEvents()
Returns the event control for events executed at the begin of a time step.
The definition of a single phase of a tls logic.
SUMOTime maxDuration
The maximum duration of the phase.
static const SUMOTime UNSPECIFIED_DURATION
SUMOTime latestEnd
The maximum time within the cycle for switching (for coordinated actuation)
SUMOTime minDuration
The minimum duration of the phase.
SUMOTime myLastSwitch
Stores the timestep of the last on-switched of the phase.
SUMOTime duration
The duration of the phase.
SUMOTime earliestEnd
The minimum time within the cycle for switching (for coordinated actuation)
SUMOTime getLatest() const
the maximum duratin for keeping the current phase when considering 'latestEnd'
Phases myPhases
The list of phases this logic uses.
MSSimpleTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, const SUMOTime offset, const TrafficLightType logicType, const Phases &phases, int step, SUMOTime delay, const std::map< std::string, std::string > ¶meters)
Constructor.
virtual void saveState(OutputDevice &) const
Saves the current tls states into the given stream.
virtual SUMOTime mapTimeInCycle(SUMOTime t) const
map the given time into the current cycle
SUMOTime getEarliest(SUMOTime prevStart) const
the minimum duration for keeping the current phase when considering 'earliestEnd'
void setPhases(const Phases &phases, int index)
Replaces the phases and set the phase index.
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
int getPhaseNumber() const
Returns the number of phases.
~MSSimpleTrafficLightLogic()
Destructor.
int getCurrentPhaseIndex() const
Returns the current index within the program.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
const Phases & getPhases() const
Returns the phases of this tls program.
int myStep
The current step.
bool myCoordinated
whether coordination parameters earliestEnd, latestEnd are
void deletePhases()
frees memory responsibilities
virtual void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
virtual SUMOTime trySwitch()
Switches to the next phase.
void executeOnSwitchActions() const
A class that stores and controls tls and switching of their programs.
TLSLogicVariants & get(const std::string &id) const
Returns the variants of a named tls.
Class realising the switch between the traffic light phases.
void deschedule(MSTrafficLightLogic *tlLogic)
Marks this swicth as invalid (if the phase duration has changed, f.e.)
The parent class for traffic light logics.
SUMOTime myOffset
the offset parameter of the current program
std::vector< SUMOTime > myOverridingTimes
A list of duration overrides.
SUMOTime myDefaultCycleTime
The cycle time (without changes)
SUMOTime getTimeInCycle() const
return time within the current cycle
SwitchCommand * mySwitchCommand
The current switch command.
SUMOTime myCurrentDurationIncrement
A value for enlarge the current duration.
SUMOTime getNextSwitchTime() const
Returns the assumed next switch time.
SUMOTime getSpentDuration(SUMOTime simStep=-1) const
Returns the duration spent in the current phase.
bool setTrafficLightSignals(SUMOTime t) const
Applies the current signal states to controlled links.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
const std::string & getProgramID() const
Returns this tl-logic's id.
const std::string & getID() const
Returns the id.
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
virtual const std::string getParameter(const std::string &key, const std::string defaultValue="") const
Returns the value for a given key.
bool knowsParameter(const std::string &key) const
Returns whether the parameter is known.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter
static bool toBool(const std::string &sData)
converts a string into the bool value described by it by calling the char-type converter