![]() |
Eclipse SUMO - Simulation of Urban MObility
|
One phase in the NEMAController. More...
#include <NEMAController.h>
Data Structures | |
struct | PhaseDetectorInfo |
stores information about the phase's detector(s) More... | |
Public Types | |
typedef PhaseDetectorInfo | PhaseDetectorInfo |
typedef NEMAPhase * | PhasePtr |
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 | 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 | 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 | |
PhaseTransitionLogic * | getTransition (int toPhase) |
return the PhaseTransitionLogic matching the toPhase | |
SUMOTime | getTransitionTime (NEMALogic *controller) |
Get the Transition Time. | |
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. | |
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 | |
MSPhaseDefinition * | myCorePhase = 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 | |
PhaseTransitionLogic * | lastTransitionDecision |
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 | |
One phase in the NEMAController.
This represents one phase and all its parameters in a NEMA traffic light The phse ultimately controls it's transition to the next phase, and is resbonisble for determining the valid transitions given it's current state
Definition at line 554 of file NEMAController.h.
Definition at line 588 of file NEMAController.h.
typedef NEMAPhase* NEMAPhase::PhasePtr |
Typedef for commonly used phase pointer.
Definition at line 557 of file NEMAController.h.
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.
phaseName | the "name" of the phase as an integer |
isBarrier | if the phase is located at a barrier or not |
isGreenRest | if it is a phase in which the traffic signal can green rest |
isCoordinated | if it is a coordinated phase |
minRecall | whether or not the phase has minimum recall or not |
maxRecall | whether or not the phase has maximum recall or not |
fixForceOff | if the phase has a force off or not |
barrierNum | the barrier to which the phase belongs (0 or 1) |
ringNum | the ring to which the phase belongs (0 or 1) |
phaseStringInds | the indexes of lanes that I control, ie. "srrrrGG" is {5, 6} |
phase | the MSPhaseDefinition base class |
Definition at line 1232 of file NEMAController.cpp.
References forceOffTime, greenRestTimer, lastDetectActive, MSPhaseDefinition::maxDuration, maxGreenDynamic, MSPhaseDefinition::minDuration, myCorePhase, myExpectedDuration, myInstance, myLastEnd, myLastPhaseInstance, myLightState, myStartTime, readyToSwitch, Red, sequentialPriorPhase, setMyNEMAStates(), TIME2STEPS, and transitionActive.
NEMAPhase::~NEMAPhase | ( | ) |
}
Applies the vehicle extension timer if appropriate
duration | the current phase duration |
Definition at line 1511 of file NEMAController.cpp.
References NEMAPhase::PhaseDetectorInfo::detectActive, MAX2(), maxGreenDynamic, MIN2(), minDuration, myDetectorInfo, myExpectedDuration, and vehExt.
Referenced by update().
|
inline |
simple method to check if there is either a recall or an active detector
Definition at line 672 of file NEMAController.h.
References NEMAPhase::PhaseDetectorInfo::detectActive, maxRecall, minRecall, and myDetectorInfo.
Referenced by PhaseTransitionLogic::freeBase().
void NEMAPhase::checkMyDetectors | ( | void | ) |
Check Detectors. Called on all phases at every step.
Definition at line 1350 of file NEMAController.cpp.
References NEMAPhase::PhaseDetectorInfo::cpdSource, NEMAPhase::PhaseDetectorInfo::cpdTarget, NEMAPhase::PhaseDetectorInfo::detectActive, NEMAPhase::PhaseDetectorInfo::detectors, getCurrentState(), getDetectors(), Green, myDetectorInfo, and myLightState.
void NEMAPhase::clearMyDetectors | ( | void | ) |
Clear My Detectors. Called on all phases at every step.
Definition at line 1341 of file NEMAController.cpp.
References NEMAPhase::PhaseDetectorInfo::detectActive, Green, lastDetectActive, NEMAPhase::PhaseDetectorInfo::latching, myDetectorInfo, and myLightState.
|
inline |
Return whether or not the phase index is controlled by me.
Definition at line 756 of file NEMAController.h.
References myPhaseStringInds.
|
inline |
simple method to check if a detector is active
Definition at line 677 of file NEMAController.h.
References NEMAPhase::PhaseDetectorInfo::detectActive, and myDetectorInfo.
handles entry to the phase during simulation Sets the color to green and determines maximum duration
controller | a reference to the controller |
lastPhase | a reference to the last phase |
Definition at line 1384 of file NEMAController.cpp.
References 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, phaseName, readyToSwitch, ringNum, NEMALogic::setActivePhase(), and SIMTIME.
Referenced by exit(), forceEnter(), and update().
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
controller | a reference to the NEMAController |
nextPhases | the next phases that the controller wants to transition to |
Definition at line 1437 of file NEMAController.cpp.
References barrierNum, DELTA_T, enter(), exit(), getCurrentState(), NEMALogic::getCurrentTime(), NEMALogic::getOtherPhase(), PhaseTransitionLogic::getToPhase(), getTransitionTime(), Green, GreenRest, greenRestTimer, GreenXfer, isAtBarrier, isGreenRest, lastTransitionDecision, maxDuration, minDuration, myExpectedDuration, myLastEnd, myLightState, myStartTime, readyToSwitch, Red, red, RedXfer, ringNum, transitionActive, Yellow, and yellow.
Referenced by exit().
|
inline |
Force Enter. This Should only be called at initialization time.
Definition at line 751 of file NEMAController.h.
References enter(), and sequentialPriorPhase.
Referenced by NEMALogic::calculateInitialPhases170(), and NEMALogic::constructTimingAndPhaseDefs().
|
inline |
gets the current light state
Definition at line 621 of file NEMAController.h.
References myLightState.
Referenced by checkMyDetectors(), exit(), PhaseTransitionLogic::fromBarrier(), NEMALogic::getDefaultTransition(), PhaseTransitionLogic::getDistance(), PhaseTransitionLogic::okay(), and update().
|
inline |
returns a vector of the phases detectors
Definition at line 625 of file NEMAController.h.
References NEMAPhase::PhaseDetectorInfo::detectors, and myDetectorInfo.
Referenced by checkMyDetectors().
char NEMAPhase::getNEMAChar | ( | int | i | ) |
Return the ryg light string for the phase.
Definition at line 1315 of file NEMAController.cpp.
References Green, myGreenString, myLightState, myRedString, myYellowString, and Red.
|
inline |
get the prior phase
Definition at line 719 of file NEMAController.h.
References sequentialPriorPhase.
Referenced by NEMALogic::calculateInitialPhases170(), and PhaseTransitionLogic::fromCoord().
PhaseTransitionLogic * NEMAPhase::getTransition | ( | int | toPhase | ) |
return the PhaseTransitionLogic matching the toPhase
toPhase | a integer representing the target phase |
Definition at line 1589 of file NEMAController.cpp.
References myTransitions.
Referenced by NEMALogic::getDefaultTransition().
Get the Transition Time.
controller |
Definition at line 1501 of file NEMAController.cpp.
References NEMALogic::getCurrentTime(), MAX2(), myLastEnd, red, TIME2STEPS, transitionActive, and yellow.
Referenced by PhaseTransitionLogic::coordBase(), exit(), and PhaseTransitionLogic::fromCoord().
|
inline |
simple method to check if there is a recall on the phase.
Definition at line 667 of file NEMAController.h.
void NEMAPhase::init | ( | NEMALogic * | controller, |
int | crossPhaseTarget, | ||
int | crossPhaseSource, | ||
bool | latching | ||
) |
initializes the object
controller | a pointer to the controller object |
crossPhaseTarget | the cross phase switching target |
crossPhaseSource | the cross phase switching source |
latching | whether the phase has latching detectors or not |
Definition at line 1278 of file NEMAController.cpp.
References NEMALogic::getPhaseObj(), NEMALogic::getPhasesByRing(), NEMALogic::measureRingDistance(), myDetectorInfo, myTransitions, phaseName, recalculateTiming(), and ringNum.
|
inline |
check if a transition is active
Definition at line 636 of file NEMAController.h.
References Green, and myLightState.
Referenced by PhaseTransitionLogic::fromCoord().
void NEMAPhase::recalculateTiming | ( | void | ) |
accessory function to recalculate timing
Definition at line 1301 of file NEMAController.cpp.
References MSPhaseDefinition::maxDuration, maxDuration, maxGreenDynamic, MSPhaseDefinition::minDuration, minDuration, myCorePhase, nextMaxDuration, MSPhaseDefinition::red, red, MSPhaseDefinition::vehext, vehExt, MSPhaseDefinition::yellow, and yellow.
Referenced by init().
|
inline |
sets the detectors for the phase
Definition at line 631 of file NEMAController.h.
References NEMAPhase::PhaseDetectorInfo::detectors, and myDetectorInfo.
Referenced by NEMALogic::init().
|
private |
this function replaces getNEMAStates calculation at every call It sets my myGreenString, myYellowString, and myRedString on class creation
Definition at line 1326 of file NEMAController.cpp.
References MSPhaseDefinition::getState(), myCorePhase, myGreenString, myRedString, and myYellowString.
Referenced by NEMAPhase().
|
inline |
set the prior phase
Definition at line 724 of file NEMAController.h.
References sequentialPriorPhase.
std::vector< PhaseTransitionLogic * > NEMAPhase::trySwitch | ( | NEMALogic * | controller | ) |
calculate a vector of potention next phases
controller |
Definition at line 1602 of file NEMAController.cpp.
References barrierNum, PhaseTransitionLogic::getToPhase(), lastTransitionDecision, myTransitions, and readyToSwitch.
void NEMAPhase::update | ( | NEMALogic * | controller | ) |
update is called on the active phases by the NEMAController at every time step
controller | a reference to the controller |
Definition at line 1521 of file NEMAController.cpp.
References calcVehicleExtension(), coordinatePhase, DELTA_T, enter(), forceOffTime, getCurrentState(), NEMALogic::getCurrentTime(), NEMALogic::getOtherPhase(), NEMALogic::getPhaseObjs(), NEMALogic::getTimeInCycle(), Green, GreenRest, greenRestTimer, GreenXfer, MAX2(), maxDuration, maxGreenDynamic, minDuration, myExpectedDuration, myLightState, myStartTime, phaseName, readyToSwitch, and TIME2STEPS.
int NEMAPhase::barrierNum |
Definition at line 691 of file NEMAController.h.
Referenced by NEMALogic::calculateInitialPhases170(), NEMALogic::constructTimingAndPhaseDefs(), PhaseTransitionLogic::coordBase(), exit(), PhaseTransitionLogic::freeBase(), PhaseTransitionLogic::fromBarrier(), NEMALogic::getDefaultTransition(), PhaseTransitionLogic::getDistance(), NEMALogic::getNextPhases(), and trySwitch().
bool NEMAPhase::coordinatePhase |
Definition at line 692 of file NEMAController.h.
Referenced by PhaseTransitionLogic::coordBase(), enter(), PhaseTransitionLogic::okay(), and update().
bool NEMAPhase::fixForceOff |
Definition at line 695 of file NEMAController.h.
Referenced by enter().
SUMOTime NEMAPhase::forceOffTime |
stores the force off time in coordinated mode
Definition at line 705 of file NEMAController.h.
Referenced by NEMALogic::calculateForceOffs170(), PhaseTransitionLogic::coordBase(), enter(), PhaseTransitionLogic::fromCoord(), NEMAPhase(), and update().
SUMOTime NEMAPhase::greatestStartTime |
Definition at line 703 of file NEMAController.h.
Referenced by NEMALogic::calculateInitialPhases170().
SUMOTime NEMAPhase::greenRestTimer |
a count down timer to track green rest transition time
Definition at line 702 of file NEMAController.h.
Referenced by enter(), exit(), NEMAPhase(), and update().
bool NEMAPhase::isAtBarrier |
Definition at line 689 of file NEMAController.h.
Referenced by exit(), and PhaseTransitionLogic::okay().
bool NEMAPhase::isGreenRest |
Definition at line 690 of file NEMAController.h.
bool NEMAPhase::lastDetectActive |
store the last detect check for traci purposes
Definition at line 699 of file NEMAController.h.
Referenced by clearMyDetectors(), and NEMAPhase().
|
private |
pointer to save the last transition
Definition at line 831 of file NEMAController.h.
Referenced by enter(), exit(), and trySwitch().
SUMOTime NEMAPhase::maxDuration |
Definition at line 765 of file NEMAController.h.
Referenced by enter(), exit(), recalculateTiming(), and update().
|
private |
Definition at line 787 of file NEMAController.h.
Referenced by calcVehicleExtension(), enter(), NEMAPhase(), recalculateTiming(), and update().
bool NEMAPhase::maxRecall |
Definition at line 694 of file NEMAController.h.
Referenced by callActive(), enter(), and hasRecall().
SUMOTime NEMAPhase::minDuration |
Definition at line 764 of file NEMAController.h.
Referenced by calcVehicleExtension(), PhaseTransitionLogic::coordBase(), enter(), exit(), PhaseTransitionLogic::fromCoord(), recalculateTiming(), and update().
bool NEMAPhase::minRecall |
Definition at line 693 of file NEMAController.h.
Referenced by callActive(), and hasRecall().
|
private |
A reference to the core phase of which NEMAPhase wraps.
Definition at line 772 of file NEMAController.h.
Referenced by NEMAPhase(), recalculateTiming(), and setMyNEMAStates().
|
private |
Definition at line 783 of file NEMAController.h.
Referenced by calcVehicleExtension(), callActive(), checkMyDetectors(), clearMyDetectors(), detectActive(), getDetectors(), init(), and setDetectors().
|
private |
Definition at line 789 of file NEMAController.h.
Referenced by calcVehicleExtension(), enter(), exit(), NEMAPhase(), and update().
|
private |
Definition at line 796 of file NEMAController.h.
Referenced by getNEMAChar(), and setMyNEMAStates().
|
private |
Definition at line 776 of file NEMAController.h.
Referenced by NEMAPhase().
|
private |
Definition at line 790 of file NEMAController.h.
Referenced by exit(), getTransitionTime(), and NEMAPhase().
|
private |
Definition at line 777 of file NEMAController.h.
Referenced by enter(), and NEMAPhase().
|
private |
Definition at line 782 of file NEMAController.h.
Referenced by checkMyDetectors(), clearMyDetectors(), enter(), exit(), getCurrentState(), getNEMAChar(), isTransitionActive(), NEMAPhase(), and update().
|
private |
Definition at line 795 of file NEMAController.h.
Referenced by controlledIndex().
|
private |
Definition at line 798 of file NEMAController.h.
Referenced by getNEMAChar(), and setMyNEMAStates().
|
private |
Definition at line 788 of file NEMAController.h.
Referenced by enter(), exit(), NEMAPhase(), and update().
|
private |
stores a sorted list of potential transitions
Definition at line 810 of file NEMAController.h.
Referenced by getTransition(), init(), trySwitch(), and ~NEMAPhase().
|
private |
Definition at line 797 of file NEMAController.h.
Referenced by getNEMAChar(), and setMyNEMAStates().
SUMOTime NEMAPhase::nextMaxDuration |
Definition at line 766 of file NEMAController.h.
Referenced by recalculateTiming().
int NEMAPhase::phaseName |
Definition at line 688 of file NEMAController.h.
Referenced by NEMALogic::constructTimingAndPhaseDefs(), enter(), NEMALogic::getDefaultTransition(), init(), and update().
bool NEMAPhase::readyToSwitch |
flag to for the supervisory controller to denote whether phase is ready to switch or not.
Definition at line 708 of file NEMAController.h.
Referenced by PhaseTransitionLogic::coordBase(), enter(), exit(), PhaseTransitionLogic::freeBase(), PhaseTransitionLogic::fromBarrier(), PhaseTransitionLogic::fromCoord(), NEMALogic::getDefaultTransition(), NEMAPhase(), trySwitch(), and update().
SUMOTime NEMAPhase::red |
Definition at line 763 of file NEMAController.h.
Referenced by exit(), getTransitionTime(), and recalculateTiming().
int NEMAPhase::ringNum |
Definition at line 696 of file NEMAController.h.
Referenced by enter(), exit(), PhaseTransitionLogic::fromBarrier(), NEMALogic::getDefaultTransition(), NEMALogic::getOtherPhase(), init(), and NEMALogic::setActivePhase().
|
private |
Definition at line 778 of file NEMAController.h.
Referenced by forceEnter(), getSequentialPriorPhase(), NEMAPhase(), and setSequentialPriorPhase().
|
private |
variable to store whether a transition is active or not
Definition at line 828 of file NEMAController.h.
Referenced by exit(), getTransitionTime(), and NEMAPhase().
SUMOTime NEMAPhase::vehExt |
Definition at line 767 of file NEMAController.h.
Referenced by calcVehicleExtension(), and recalculateTiming().
SUMOTime NEMAPhase::yellow |
Definition at line 762 of file NEMAController.h.
Referenced by exit(), getTransitionTime(), and recalculateTiming().