60 const std::string&
id,
const std::string& programID,
64 const std::map<std::string, std::string>& parameter,
65 const std::string& basePath,
66 const std::map<std::string, std::string>& conditions = std::map<std::string, std::string>());
115 void setParameter(
const std::string& key,
const std::string& value);
173 double evalTernaryExpression(
double a,
const std::string& o,
double b,
const std::string& condition)
const;
195 template<
typename T, SumoXMLTag Tag>
197 const T* det =
dynamic_cast<const T*
>(
200 if (det ==
nullptr) {
203 return retrieveDetExpression<T, Tag>(arg, expr,
false);
205 throw ProcessError(
"Unknown detector '" + arg +
"' in expression '" + expr +
"'");
An actuated (adaptive) traffic light logic.
double myDetectorGap
The detector distance in seconds.
MSActuatedTrafficLightLogic(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &programID, const SUMOTime offset, const MSSimpleTrafficLightLogic::Phases &phases, int step, SUMOTime delay, const std::map< std::string, std::string > ¶meter, const std::string &basePath, const std::map< std::string, std::string > &conditions=std::map< std::string, std::string >())
Constructor.
double myMaxGap
The maximum gap to check in seconds.
void activateProgram()
called when switching programs
std::vector< SwitchingRules > mySwitchingRules
~MSActuatedTrafficLightLogic()
Destructor.
double evalAtomicExpression(const std::string &expr) const
evaluate atomic expression
int getTarget(int step)
get the green phase following step
void setParameter(const std::string &key, const std::string &value)
Sets a parameter and updates internal constants.
SUMOTime myLastTrySwitchTime
last time trySwitch was called
int getDetectorPriority(const InductLoopInfo &loopInfo) const
std::map< std::string, double > getConditions() const
return all named conditions defined for this traffic light
SUMOTime myFreq
The frequency for aggregating detector output.
SUMOTime getMinimumMinDuration(MSLane *lane) const
get the minimum min duration for all stretchable phases that affect the given lane
bool myShowDetectors
Whether the detectors shall be shown in the GUI.
std::vector< SUMOTime > myLinkMaxGreenTimes
maximum consecutive time that the given link may remain green
std::vector< std::vector< InductLoopInfo * > > InductLoopMap
Definition of a map from phases to induct loops controlling them.
std::string myVehicleTypes
Whether detector output separates by vType.
double gapControl()
Return the minimum detection gap of all detectors if the current phase should be extended and double:...
const T * retrieveDetExpression(const std::string &arg, const std::string &expr, bool tryPrefix) const
void init(NLDetectorBuilder &nb)
Initialises the tls with information about incoming lanes.
double evalExpression(const std::string &condition) const
evaluate custom switching condition
std::vector< SUMOTime > myLinkMinGreenTimes
minimum consecutive time that the given link must remain green
SUMOTime trySwitch()
Switches to the next phase.
static const std::vector< std::string > OPERATOR_PRECEDENCE
double myPassingTime
The passing time used in seconds.
SUMOTime getLinkMinDuration(int target) const
the minimum duratin for keeping the current phase due to linkMinDur constraints
bool canExtendLinkGreen(int target)
whether the target phase is acceptable in light of linkMaxDur constraints
InductLoopMap myInductLoopsForPhase
A map from phase to induction loops to be used for gap control.
int decideNextPhaseCustom(bool mustSwitch)
select among candidate phases based on detector states and custom switching rules
double evalTernaryExpression(double a, const std::string &o, double b, const std::string &condition) const
evaluate atomic expression
void setShowDetectors(bool show)
bool myTraCISwitch
whether the next switch time was requested via TraCI
int getPhasePriority(int step) const
count the number of active detectors for the given step
SUMOTime duration(const double detectionGap) const
Returns the minimum duration of the current phase.
std::vector< InductLoopInfo > myInductLoops
std::map< std::string, std::string > myConditions
The custom switching conditions.
bool maxLinkDurationReached()
whether the current phase cannot be continued due to linkMaxDur constraints
bool hasMajor(const std::string &state, const LaneVector &lanes) const
return whether there is a major link from the given lane in the given phase
std::vector< SUMOTime > myLinkGreenTimes
consecutive time that the given link index has been green
std::map< std::string, double > getDetectorStates() const
retrieve all detectors used by this program
bool showDetectors() const
std::vector< SUMOTime > myLinkRedTimes
std::string myFile
The output file for generated detectors.
void initSwitchingRules()
initialize custom switching rules
const std::string myDetectorPrefix
int decideNextPhase()
select among candidate phases based on detector states
void changeStepAndDuration(MSTLLogicControl &tlcontrol, SUMOTime simStep, int step, SUMOTime stepDuration)
Changes the current phase and her duration.
SUMOTime myInactiveThreshold
The time threshold to avoid starved phases.
const NamedObjectCont< MSDetectorFileOutput * > & getTypedDetectors(SumoXMLTag type) const
Returns the list of detectors of the given type.
An unextended detector measuring at a fixed position on a fixed lane.
Representation of a lane in the micro simulation.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSDetectorControl & getDetectorControl()
Returns the detector control.
A fixed traffic light logic.
A class that stores and controls tls and switching of their programs.
std::vector< MSLane * > LaneVector
Definition of the list of arrival lanes subjected to this tls.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
Builds detectors for microsim.
T get(const std::string &id) const
Retrieves an item.
InductLoopInfo(MSInductLoop *_loop, int numPhases, double _maxGap)
std::vector< bool > servedPhase