45 #ifdef CHECK_MEMORY_LEAKS
47 #endif // CHECK_MEMORY_LEAKS
55 const std::string&
id,
const std::string& subid,
56 const std::map<std::string, std::string>& parameters) :
65 LinkVectorVector::iterator i2;
70 LinkVector::const_iterator i;
71 for (i = links.begin(); i != links.end(); i++) {
78 std::vector<MSLane*> afferentBlock;
79 bool noRailSignal =
true;
82 afferentBlock.push_back(approachingLane);
83 const MSLane* currentLane = approachingLane;
85 while (noRailSignal) {
86 std::vector<MSLane::IncomingLaneInfo> incomingLanes = currentLane->
getIncomingLanes();
88 if (!incomingLanes.empty()) {
89 precedentLane = incomingLanes.front().lane;
93 if (precedentLane == 0) {
100 afferentBlock.push_back(precedentLane);
101 currentLane = precedentLane;
110 std::vector<const MSLane*> succeedingBlock;
111 succeedingBlock.push_back(toLane);
112 currentLane = toLane;
113 bool noRailSignal =
true;
114 while (noRailSignal) {
116 std::vector<MSLink*> outGoingLinks = currentLane->
getLinkCont();
117 std::vector<MSLink*>::const_iterator j;
118 for (j = outGoingLinks.begin(); j != outGoingLinks.end(); j++) {
121 noRailSignal =
false;
128 if (outGoingLanes.size() == 0) {
129 noRailSignal =
false;
131 if (outGoingLanes.size() > 1) {
132 WRITE_WARNING(
"Rail lane " + currentLane->
getID() +
" has more than one outgoing lane but does not have a rail signal at its end");
134 const MSLane* nextLane = outGoingLanes.front();
135 succeedingBlock.push_back(nextLane);
136 currentLane = nextLane;
170 std::string state(
myLinks.size(),
'G');
171 std::vector<MSLane*>::const_iterator i;
176 bool succeedingBlockOccupied =
false;
177 std::vector<const MSLane*>::const_iterator j;
179 if (!(*j)->isEmpty()) {
180 succeedingBlockOccupied =
true;
193 if (succeedingBlockOccupied) {
194 std::vector<MSLink*>::const_iterator k;
200 bool hasOccupiedBlock =
false;
201 std::vector<MSLink*>::const_iterator k;
203 std::vector<MSLane*>::const_iterator l;
205 if (!(*l)->isEmpty()) {
206 hasOccupiedBlock =
true;
208 std::vector<MSLink*>::const_iterator m;
217 if (hasOccupiedBlock) {
std::map< MSLink *, std::vector< MSLane * > > myAfferentBlocks
A map that maps a link from the junction to its vector of lanes leading from a previous signal to thi...
MSEdge & getEdge() const
Returns the lane's edge.
Builds detectors for microsim.
bool setTrafficLightSignals(SUMOTime t) const
Applies the current signal states to controlled links.
void updateCurrentPhase()
updates the current phase of the signal
const MSPhaseDefinition & getPhase(unsigned int givenstep) const
Returns the definition of the phase from the given position within the plan.
std::map< MSLink *, unsigned int > myLinkIndices
A map that maps a link to its link index.
The base class for an intersection.
std::map< MSLane *, std::vector< MSLink * > > myLinksToLane
A map that maps an outgoing lane from the junction to its set of links that lead to this lane...
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
#define WRITE_WARNING(msg)
LaneVectorVector myLanes
The list of LaneVectors; each vector contains the incoming lanes that belong to the same link index...
A class that stores and controls tls and switching of their programs.
const std::string & getID() const
Returns the id.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
std::vector< MSLane * > myOutgoingLanes
The set of lanes going out from the junction.
SUMOTime myDefaultCycleTime
The cycle time (without changes)
void init(NLDetectorBuilder &nb)
Initialises the rail signal with information about adjacent rail signals.
MSLane * getLane() const
Returns the connected lane.
Phases myPhases
The list of phases this logic uses.
SUMOTime getOffsetFromIndex(unsigned int index) const
Returns the position (start of a phase during a cycle) from of a given step.
virtual void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
std::map< MSLane *, std::vector< const MSLane * > > mySucceedingBlocks
A map that maps an outgoing lane from the junction to its vector of lanes leading to the next signal...
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
SumoXMLNodeType getType() const
return the type of this Junction
SUMOTime trySwitch()
Switches to the next phase.
unsigned int getPhaseNumber() const
Returns the number of phases.
std::vector< MSLink * > LinkVector
Definition of the list of links that participate in this tl-light.
std::vector< MSPhaseDefinition * > Phases
Definition of a list of phases, being the junction logic.
const MSJunction * getJunction() const
return the junction to which this link belongs
unsigned int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
std::vector< const MSLane * > getOutgoingLanes() const
get the list of outgoing lanes
LinkVectorVector myLinks
The list of LinkVectors; each vector contains the links that belong to the same link index...
unsigned int getCurrentPhaseIndex() const
Returns the current index within the program.
MSLane * getApproachingLane() const
Returns the lane leading to this link.
void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
static MSLink * getConnectingLink(const MSLane &from, const MSLane &to)
Returns the link connecting both lanes Both lanes have to be non-internal; 0 may be returned if no co...
const Phases & getPhases() const
Returns the phases of this tls program.
std::string getAppropriateState()
returns the state of the signal that actually required
The parent class for traffic light logics.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
MSPhaseDefinition myCurrentPhase
The current phase.
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
The definition of a single phase of a tls logic.
Representation of a lane in the micro simulation.
MSRailSignal(MSTLLogicControl &tlcontrol, const std::string &id, const std::string &subid, const std::map< std::string, std::string > ¶meters)
Constructor.
const MSJunction * getToJunction() const
~MSRailSignal()
Destructor.