Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
NEMAPhase Class Reference

One phase in the NEMAController. More...

#include <NEMAController.h>

Collaboration diagram for NEMAPhase:
[legend]

Data Structures

struct  PhaseDetectorInfo
 stores information about the phase's detector(s) More...

Public Types

typedef PhaseDetectorInfo PhaseDetectorInfo
typedef NEMAPhasePhasePtr
 Typedef for commonly used phase pointer.

Public Member Functions

bool callActive (void)
 simple method to check if there is either a recall or an active detector
void checkMyDetectors (void)
 Check Detectors. Called on all phases at every step.
void cleanupExit (void)
 public method to set whether phase is active or not
void clearMyDetectors (void)
 Clear My Detectors. Called on all phases at every step.
bool controlledIndex (int i)
 Return whether or not the phase index is controlled by me.
bool detectActive (void)
 simple method to check if a detector is active
void enterYellow (NEMALogic *controller)
 handles the transition into yellow
void exit (NEMALogic *controller, PhaseTransitionLogic *nextPhases[2])
 handles the transition out of a phase into the next (puts the phase through (G -> Y -> R) transition
void forceEnter (NEMALogic *controller)
 Force Enter. This Should only be called at initialization time.
LightState getCurrentState () const
 gets the current light state
std::vector< MSE2Collector * > getDetectors () const
 returns a vector of the phases detectors
char getNEMAChar (int i)
 Return the ryg light string for the phase.
PhasePtr getSequentialPriorPhase (void)
 get the prior phase
PhaseTransitionLogicgetTransition (int toPhase)
 return the PhaseTransitionLogic matching the toPhase
SUMOTime getTransitionTime (NEMALogic *controller)
 Get the Transition Time.
SUMOTime getTransitionTimeStateless (void)
 Get the Transition time given.
void handleGreenRestOrTransfer (NEMALogic *controller, PhaseTransitionLogic *nextPhases[2])
 handles the transition into a green rest state
void handleRedXferOrNextPhase (NEMALogic *controller, PhaseTransitionLogic *nextPhases[2])
 handles the transition into a red xfer state, which is roughly the same as green rest
bool hasRecall (void)
 simple method to check if there is a recall on the phase.
void init (NEMALogic *controller, int crossPhaseTarget, int crossPhaseSource, bool latching)
 initializes the object
bool isTransitionActive () const
 check if a transition is active
 NEMAPhase (int phaseName, bool isBarrier, bool isGreenRest, bool isCoordinated, bool minRecall, bool maxRecall, bool fixForceOff, int barrierNum, int ringNum, IntVector phaseStringInds, MSPhaseDefinition *phase)
 Construct a new NEMAPhase object.
bool okay2ForceSwitch (NEMALogic *controller)
 simple internal check to see if done okay to transition
void recalculateTiming (void)
 accessory function to recalculate timing
void setDetectors (std::vector< MSE2Collector * > detectors)
 sets the detectors for the phase
void setSequentialPriorPhase (PhasePtr priorPhase)
 set the prior phase
std::vector< PhaseTransitionLogic * > trySwitch (NEMALogic *controller)
 calculate a vector of potention next phases
void update (NEMALogic *controller)
 update is called on the active phases by the NEMAController at every time step
 ~NEMAPhase ()
 Destructor.

Data Fields

int barrierNum
bool coordinatePhase
bool fixForceOff
SUMOTime forceOffTime
 stores the force off time in coordinated mode
SUMOTime greatestStartTime
SUMOTime greenRestTimer
 a count down timer to track green rest transition time
bool isAtBarrier
bool isGreenRest
bool lastDetectActive
 store the last detect check for traci purposes
bool maxRecall
bool minRecall
int phaseName
bool readyToSwitch
 flag to for the supervisory controller to denote whether phase is ready to switch or not.
int ringNum
Basic Phase Timing Parameters
SUMOTime yellow
SUMOTime red
SUMOTime minDuration
SUMOTime maxDuration
SUMOTime nextMaxDuration
SUMOTime vehExt

Private Attributes

MSPhaseDefinitionmyCorePhase = nullptr
 A reference to the core phase of which NEMAPhase wraps.
PhaseDetectorInfo myDetectorInfo
LightState myLightState
store references to myself, the last phase I was in, and the sequentially next phase
PhasePtr myInstance = nullptr
PhasePtr myLastPhaseInstance = nullptr
PhasePtr sequentialPriorPhase = nullptr
Timing Parameters
SUMOTime maxGreenDynamic
SUMOTime myStartTime
SUMOTime myExpectedDuration
SUMOTime myLastEnd

Light String Parameters

IntVector myPhaseStringInds
std::string myGreenString
std::string myYellowString
std::string myRedString
std::vector< PhaseTransitionLogic * > myTransitions
 stores a sorted list of potential transitions
bool transitionActive
 variable to store whether a transition is active or not
PhaseTransitionLogiclastTransitionDecision
 pointer to save the last transition
SUMOTime calcVehicleExtension (SUMOTime duration)
 }
void enter (NEMALogic *controller, PhasePtr lastPhase)
 handles entry to the phase during simulation Sets the color to green and determines maximum duration
void setMyNEMAStates (void)
 this function replaces getNEMAStates calculation at every call It sets my myGreenString, myYellowString, and myRedString on class creation

Detailed Description

One phase in the NEMAController.

This represents one phase and all its parameters in a NEMA traffic light The phase ultimately controls its transition to the next phase, and is resbonisble for determining the valid transitions given its current state

Definition at line 555 of file NEMAController.h.

Member Typedef Documentation

◆ PhaseDetectorInfo

typedef PhaseDetectorInfo NEMAPhase::PhaseDetectorInfo

Definition at line 589 of file NEMAController.h.

◆ PhasePtr

Typedef for commonly used phase pointer.

Definition at line 558 of file NEMAController.h.

Constructor & Destructor Documentation

◆ NEMAPhase()

NEMAPhase::NEMAPhase ( int phaseName,
bool isBarrier,
bool isGreenRest,
bool isCoordinated,
bool minRecall,
bool maxRecall,
bool fixForceOff,
int barrierNum,
int ringNum,
IntVector phaseStringInds,
MSPhaseDefinition * phase )

Construct a new NEMAPhase object.

Parameters
phaseNamethe "name" of the phase as an integer
isBarrierif the phase is located at a barrier or not
isGreenRestif it is a phase in which the traffic signal can green rest
isCoordinatedif it is a coordinated phase
minRecallwhether or not the phase has minimum recall or not
maxRecallwhether or not the phase has maximum recall or not
fixForceOffif the phase has a force off or not
barrierNumthe barrier to which the phase belongs (0 or 1)
ringNumthe ring to which the phase belongs (0 or 1)
phaseStringIndsthe indexes of lanes that I control, ie. "srrrrGG" is {5, 6}
phasethe MSPhaseDefinition base class

Definition at line 1245 of file NEMAController.cpp.

References barrierNum, coordinatePhase, fixForceOff, forceOffTime, greenRestTimer, isAtBarrier, isGreenRest, lastDetectActive, maxGreenDynamic, maxRecall, minRecall, myCorePhase, myExpectedDuration, myInstance, myLastEnd, myLastPhaseInstance, myLightState, myPhaseStringInds, myStartTime, phaseName, readyToSwitch, Red, ringNum, sequentialPriorPhase, setMyNEMAStates(), TIME2STEPS, and transitionActive.

Referenced by enter(), handleGreenRestOrTransfer(), and update().

Here is the caller graph for this function:

◆ ~NEMAPhase()

NEMAPhase::~NEMAPhase ( )

Destructor.

Definition at line 1283 of file NEMAController.cpp.

References myTransitions.

Member Function Documentation

◆ calcVehicleExtension()

SUMOTime NEMAPhase::calcVehicleExtension ( SUMOTime duration)
private

}

Applies the vehicle extension timer if appropriate

Parameters
durationthe current phase duration
Returns
SUMOTime

Definition at line 1541 of file NEMAController.cpp.

References MAX2(), maxGreenDynamic, MIN2(), minDuration, myDetectorInfo, myExpectedDuration, and vehExt.

Referenced by update().

Here is the caller graph for this function:

◆ callActive()

bool NEMAPhase::callActive ( void )
inline

simple method to check if there is either a recall or an active detector

Definition at line 695 of file NEMAController.h.

References maxRecall, minRecall, and myDetectorInfo.

◆ checkMyDetectors()

void NEMAPhase::checkMyDetectors ( void )

Check Detectors. Called on all phases at every step.

Definition at line 1363 of file NEMAController.cpp.

References Green, myDetectorInfo, and myLightState.

◆ cleanupExit()

void NEMAPhase::cleanupExit ( void )
inline

public method to set whether phase is active or not

Definition at line 804 of file NEMAController.h.

References myLightState, readyToSwitch, Red, and transitionActive.

Referenced by enter().

Here is the caller graph for this function:

◆ clearMyDetectors()

void NEMAPhase::clearMyDetectors ( void )

Clear My Detectors. Called on all phases at every step.

Definition at line 1354 of file NEMAController.cpp.

References Green, lastDetectActive, myDetectorInfo, and myLightState.

◆ controlledIndex()

bool NEMAPhase::controlledIndex ( int i)
inline

Return whether or not the phase index is controlled by me.

Definition at line 789 of file NEMAController.h.

References myPhaseStringInds.

◆ detectActive()

bool NEMAPhase::detectActive ( void )
inline

simple method to check if a detector is active

Definition at line 700 of file NEMAController.h.

References myDetectorInfo.

◆ enter()

void NEMAPhase::enter ( NEMALogic * controller,
PhasePtr lastPhase )
private

handles entry to the phase during simulation Sets the color to green and determines maximum duration

Parameters
controllera reference to the controller
lastPhasea reference to the last phase

Definition at line 1397 of file NEMAController.cpp.

References cleanupExit(), NEMALogic::coordinateMode, coordinatePhase, NEMALogic::coordinatePhaseObjs, fixForceOff, forceOffTime, NEMALogic::getCurrentCycleLength(), NEMALogic::getCurrentTime(), Named::getID(), NEMALogic::getTimeInCycle(), Green, GreenRest, greenRestTimer, NEMALogic::implementTraciChanges(), isGreenRest, lastTransitionDecision, maxDuration, maxGreenDynamic, maxRecall, MIN2(), minDuration, NEMALogic::ModeCycle(), myExpectedDuration, myLastPhaseInstance, myLightState, myStartTime, NEMAPhase(), phaseName, readyToSwitch, ringNum, NEMALogic::setActivePhase(), and SIMTIME.

Referenced by forceEnter(), handleRedXferOrNextPhase(), and update().

Here is the caller graph for this function:

◆ enterYellow()

void NEMAPhase::enterYellow ( NEMALogic * controller)

handles the transition into yellow

Parameters
controllera reference to the NEMAController

Definition at line 1475 of file NEMAController.cpp.

References NEMALogic::getCurrentTime(), myLastEnd, myLightState, transitionActive, and Yellow.

Referenced by exit().

Here is the caller graph for this function:

◆ exit()

void NEMAPhase::exit ( NEMALogic * controller,
PhaseTransitionLogic * nextPhases[2] )

handles the transition out of a phase into the next (puts the phase through (G -> Y -> R) transition

Parameters
controllera reference to the NEMAController
nextPhasesthe next phases that the controller wants to transition to

Definition at line 1449 of file NEMAController.cpp.

References enterYellow(), NEMALogic::getCurrentTime(), Green, handleGreenRestOrTransfer(), handleRedXferOrNextPhase(), lastTransitionDecision, myLastEnd, myLightState, Red, red, ringNum, and yellow.

◆ forceEnter()

void NEMAPhase::forceEnter ( NEMALogic * controller)
inline

Force Enter. This Should only be called at initialization time.

Definition at line 784 of file NEMAController.h.

References enter(), and sequentialPriorPhase.

Referenced by NEMALogic::calculateInitialPhases170(), and NEMALogic::constructTimingAndPhaseDefs().

Here is the caller graph for this function:

◆ getCurrentState()

LightState NEMAPhase::getCurrentState ( ) const
inline

gets the current light state

Definition at line 622 of file NEMAController.h.

References myLightState.

Referenced by NEMALogic::getDefaultTransition(), handleGreenRestOrTransfer(), and update().

Here is the caller graph for this function:

◆ getDetectors()

std::vector< MSE2Collector * > NEMAPhase::getDetectors ( ) const
inline

returns a vector of the phases detectors

Definition at line 626 of file NEMAController.h.

References myDetectorInfo.

◆ getNEMAChar()

char NEMAPhase::getNEMAChar ( int i)

Return the ryg light string for the phase.

Definition at line 1328 of file NEMAController.cpp.

References Green, myGreenString, myLightState, myRedString, myYellowString, and Red.

◆ getSequentialPriorPhase()

PhasePtr NEMAPhase::getSequentialPriorPhase ( void )
inline

get the prior phase

Definition at line 752 of file NEMAController.h.

References sequentialPriorPhase.

Referenced by NEMALogic::calculateInitialPhases170().

Here is the caller graph for this function:

◆ getTransition()

PhaseTransitionLogic * NEMAPhase::getTransition ( int toPhase)

return the PhaseTransitionLogic matching the toPhase

Parameters
toPhasea integer representing the target phase
Returns
PhaseTransitionLogic*

Definition at line 1619 of file NEMAController.cpp.

References myTransitions.

Referenced by NEMALogic::getDefaultTransition().

Here is the caller graph for this function:

◆ getTransitionTime()

SUMOTime NEMAPhase::getTransitionTime ( NEMALogic * controller)

Get the Transition Time.

Parameters
controller
Returns
SUMOTime

Definition at line 1527 of file NEMAController.cpp.

References NEMALogic::getCurrentTime(), getTransitionTimeStateless(), MAX2(), myLastEnd, myLightState, red, RedXfer, TIME2STEPS, transitionActive, and yellow.

Referenced by okay2ForceSwitch().

Here is the caller graph for this function:

◆ getTransitionTimeStateless()

SUMOTime NEMAPhase::getTransitionTimeStateless ( void )
inline

Get the Transition time given.

Parameters
controller
Returns
SUMOTime

Definition at line 747 of file NEMAController.h.

References red, and yellow.

Referenced by getTransitionTime().

Here is the caller graph for this function:

◆ handleGreenRestOrTransfer()

void NEMAPhase::handleGreenRestOrTransfer ( NEMALogic * controller,
PhaseTransitionLogic * nextPhases[2] )

handles the transition into a green rest state

Parameters
controllera reference to the NEMAController
nextPhasesthe next phases that the controller wants to transition to

Definition at line 1507 of file NEMAController.cpp.

References getCurrentState(), NEMALogic::getCurrentTime(), NEMALogic::getOtherPhase(), PhaseTransitionLogic::getToPhase(), GreenRest, greenRestTimer, GreenXfer, isAtBarrier, isGreenRest, maxDuration, minDuration, myExpectedDuration, myLightState, myStartTime, NEMAPhase(), readyToSwitch, and ringNum.

Referenced by exit().

Here is the caller graph for this function:

◆ handleRedXferOrNextPhase()

void NEMAPhase::handleRedXferOrNextPhase ( NEMALogic * controller,
PhaseTransitionLogic * nextPhases[2] )

handles the transition into a red xfer state, which is roughly the same as green rest

Parameters
controllera reference to the NEMAController

Definition at line 1481 of file NEMAController.cpp.

References barrierNum, enter(), NEMALogic::getOtherPhase(), PhaseTransitionLogic::getToPhase(), myLightState, okay2ForceSwitch(), readyToSwitch, RedXfer, ringNum, and transitionActive.

Referenced by exit().

Here is the caller graph for this function:

◆ hasRecall()

bool NEMAPhase::hasRecall ( void )
inline

simple method to check if there is a recall on the phase.

Definition at line 690 of file NEMAController.h.

References maxRecall, and minRecall.

◆ init()

void NEMAPhase::init ( NEMALogic * controller,
int crossPhaseTarget,
int crossPhaseSource,
bool latching )

initializes the object

Parameters
controllera pointer to the controller object
crossPhaseTargetthe cross phase switching target
crossPhaseSourcethe cross phase switching source
latchingwhether the phase has latching detectors or not

Definition at line 1291 of file NEMAController.cpp.

References NEMALogic::getPhaseObj(), NEMALogic::getPhasesByRing(), NEMALogic::measureRingDistance(), myDetectorInfo, myTransitions, phaseName, recalculateTiming(), and ringNum.

◆ isTransitionActive()

bool NEMAPhase::isTransitionActive ( ) const
inline

check if a transition is active

Definition at line 637 of file NEMAController.h.

References Green, and myLightState.

◆ okay2ForceSwitch()

bool NEMAPhase::okay2ForceSwitch ( NEMALogic * controller)
inline

simple internal check to see if done okay to transition

Definition at line 811 of file NEMAController.h.

References getTransitionTime(), readyToSwitch, TIME2STEPS, and transitionActive.

Referenced by handleRedXferOrNextPhase().

Here is the caller graph for this function:

◆ recalculateTiming()

void NEMAPhase::recalculateTiming ( void )

accessory function to recalculate timing

Definition at line 1314 of file NEMAController.cpp.

References maxDuration, maxGreenDynamic, minDuration, myCorePhase, nextMaxDuration, red, vehExt, and yellow.

Referenced by init().

Here is the caller graph for this function:

◆ setDetectors()

void NEMAPhase::setDetectors ( std::vector< MSE2Collector * > detectors)
inline

sets the detectors for the phase

Definition at line 632 of file NEMAController.h.

References myDetectorInfo.

Referenced by NEMALogic::init().

Here is the caller graph for this function:

◆ setMyNEMAStates()

void NEMAPhase::setMyNEMAStates ( void )
private

this function replaces getNEMAStates calculation at every call It sets my myGreenString, myYellowString, and myRedString on class creation

Definition at line 1339 of file NEMAController.cpp.

References myCorePhase, myGreenString, myRedString, and myYellowString.

Referenced by NEMAPhase().

Here is the caller graph for this function:

◆ setSequentialPriorPhase()

void NEMAPhase::setSequentialPriorPhase ( PhasePtr priorPhase)
inline

set the prior phase

Definition at line 757 of file NEMAController.h.

References sequentialPriorPhase.

◆ trySwitch()

std::vector< PhaseTransitionLogic * > NEMAPhase::trySwitch ( NEMALogic * controller)

calculate a vector of potention next phases

Parameters
controller
Returns
std::vector<PhaseTransitionLogic*>

Definition at line 1632 of file NEMAController.cpp.

References lastTransitionDecision, myTransitions, and readyToSwitch.

◆ update()

void NEMAPhase::update ( NEMALogic * controller)

Field Documentation

◆ barrierNum

◆ coordinatePhase

bool NEMAPhase::coordinatePhase

Definition at line 715 of file NEMAController.h.

Referenced by enter(), NEMAPhase(), and update().

◆ fixForceOff

bool NEMAPhase::fixForceOff

Definition at line 718 of file NEMAController.h.

Referenced by enter(), and NEMAPhase().

◆ forceOffTime

SUMOTime NEMAPhase::forceOffTime

stores the force off time in coordinated mode

Definition at line 728 of file NEMAController.h.

Referenced by NEMALogic::calculateForceOffs170(), enter(), PhaseTransitionLogic::fromCoord(), NEMAPhase(), and update().

◆ greatestStartTime

SUMOTime NEMAPhase::greatestStartTime

Definition at line 726 of file NEMAController.h.

Referenced by NEMALogic::calculateInitialPhases170().

◆ greenRestTimer

SUMOTime NEMAPhase::greenRestTimer

a count down timer to track green rest transition time

Definition at line 725 of file NEMAController.h.

Referenced by enter(), handleGreenRestOrTransfer(), NEMAPhase(), and update().

◆ isAtBarrier

bool NEMAPhase::isAtBarrier

Definition at line 712 of file NEMAController.h.

Referenced by handleGreenRestOrTransfer(), and NEMAPhase().

◆ isGreenRest

bool NEMAPhase::isGreenRest

Definition at line 713 of file NEMAController.h.

Referenced by enter(), handleGreenRestOrTransfer(), and NEMAPhase().

◆ lastDetectActive

bool NEMAPhase::lastDetectActive

store the last detect check for traci purposes

Definition at line 722 of file NEMAController.h.

Referenced by clearMyDetectors(), and NEMAPhase().

◆ lastTransitionDecision

PhaseTransitionLogic* NEMAPhase::lastTransitionDecision
private

pointer to save the last transition

Definition at line 876 of file NEMAController.h.

Referenced by enter(), exit(), and trySwitch().

◆ maxDuration

SUMOTime NEMAPhase::maxDuration

Definition at line 798 of file NEMAController.h.

Referenced by enter(), handleGreenRestOrTransfer(), recalculateTiming(), and update().

◆ maxGreenDynamic

SUMOTime NEMAPhase::maxGreenDynamic
private

Definition at line 832 of file NEMAController.h.

Referenced by calcVehicleExtension(), enter(), NEMAPhase(), recalculateTiming(), and update().

◆ maxRecall

bool NEMAPhase::maxRecall

Definition at line 717 of file NEMAController.h.

Referenced by callActive(), enter(), hasRecall(), and NEMAPhase().

◆ minDuration

◆ minRecall

bool NEMAPhase::minRecall

Definition at line 716 of file NEMAController.h.

Referenced by callActive(), hasRecall(), and NEMAPhase().

◆ myCorePhase

MSPhaseDefinition* NEMAPhase::myCorePhase = nullptr
private

A reference to the core phase of which NEMAPhase wraps.

Definition at line 817 of file NEMAController.h.

Referenced by NEMAPhase(), recalculateTiming(), and setMyNEMAStates().

◆ myDetectorInfo

◆ myExpectedDuration

SUMOTime NEMAPhase::myExpectedDuration
private

◆ myGreenString

std::string NEMAPhase::myGreenString
private

Definition at line 841 of file NEMAController.h.

Referenced by getNEMAChar(), and setMyNEMAStates().

◆ myInstance

PhasePtr NEMAPhase::myInstance = nullptr
private

Definition at line 821 of file NEMAController.h.

Referenced by NEMAPhase().

◆ myLastEnd

SUMOTime NEMAPhase::myLastEnd
private

Definition at line 835 of file NEMAController.h.

Referenced by enterYellow(), exit(), getTransitionTime(), and NEMAPhase().

◆ myLastPhaseInstance

PhasePtr NEMAPhase::myLastPhaseInstance = nullptr
private

Definition at line 822 of file NEMAController.h.

Referenced by enter(), and NEMAPhase().

◆ myLightState

◆ myPhaseStringInds

IntVector NEMAPhase::myPhaseStringInds
private

Definition at line 840 of file NEMAController.h.

Referenced by controlledIndex(), and NEMAPhase().

◆ myRedString

std::string NEMAPhase::myRedString
private

Definition at line 843 of file NEMAController.h.

Referenced by getNEMAChar(), and setMyNEMAStates().

◆ myStartTime

SUMOTime NEMAPhase::myStartTime
private

Definition at line 833 of file NEMAController.h.

Referenced by enter(), handleGreenRestOrTransfer(), NEMAPhase(), and update().

◆ myTransitions

std::vector<PhaseTransitionLogic*> NEMAPhase::myTransitions
private

stores a sorted list of potential transitions

Definition at line 855 of file NEMAController.h.

Referenced by getTransition(), init(), trySwitch(), and ~NEMAPhase().

◆ myYellowString

std::string NEMAPhase::myYellowString
private

Definition at line 842 of file NEMAController.h.

Referenced by getNEMAChar(), and setMyNEMAStates().

◆ nextMaxDuration

SUMOTime NEMAPhase::nextMaxDuration

Definition at line 799 of file NEMAController.h.

Referenced by recalculateTiming().

◆ phaseName

int NEMAPhase::phaseName

Definition at line 711 of file NEMAController.h.

Referenced by enter(), NEMALogic::getDefaultTransition(), init(), NEMAPhase(), and update().

◆ readyToSwitch

◆ red

SUMOTime NEMAPhase::red

◆ ringNum

◆ sequentialPriorPhase

PhasePtr NEMAPhase::sequentialPriorPhase = nullptr
private

◆ transitionActive

bool NEMAPhase::transitionActive
private

variable to store whether a transition is active or not

Definition at line 873 of file NEMAController.h.

Referenced by cleanupExit(), enterYellow(), getTransitionTime(), handleRedXferOrNextPhase(), NEMAPhase(), and okay2ForceSwitch().

◆ vehExt

SUMOTime NEMAPhase::vehExt

Definition at line 800 of file NEMAController.h.

Referenced by calcVehicleExtension(), and recalculateTiming().

◆ yellow

SUMOTime NEMAPhase::yellow

The documentation for this class was generated from the following files: