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) {
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
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...
Builds detectors for microsim.
MSEdge & getEdge() const
Returns the lane's edge.
MSLane * getLane() const
Returns the connected lane.
void updateCurrentPhase()
updates the current phase of the signal
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
The base class for an intersection.
std::vector< const MSLane * > getOutgoingLanes() const
get the list of outgoing lanes
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...
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
#define SUMO_MAX_CONNECTIONS
the maximum number of connections across an intersection
const std::string & getID() const
Returns the id.
const MSJunction * getToJunction() const
bool setTrafficLightSignals(SUMOTime t) const
Applies the current signal states to controlled links.
#define WRITE_WARNING(msg)
LaneVectorVector myLanes
The list of LaneVectors; each vector contains the incoming lanes that belong to the same link index...
std::map< MSLink *, int > myLinkIndices
A map that maps a link to its link index.
A class that stores and controls tls and switching of their programs.
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.
Phases myPhases
The list of phases this logic uses.
const Phases & getPhases() const
Returns the phases of this tls program.
const MSPhaseDefinition & getCurrentPhaseDef() const
Returns the definition of the current phase.
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...
int getPhaseNumber() const
Returns the number of phases.
SUMOTime trySwitch()
Switches to the next phase.
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.
LinkVectorVector myLinks
The list of LinkVectors; each vector contains the links that belong to the same link index...
void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
MSLane * getApproachingLane() const
Returns the lane leading to this link.
SUMOTime getPhaseIndexAtTime(SUMOTime simStep) const
Returns the index of the logic at the given simulation step.
std::string getAppropriateState()
returns the state of the signal that actually required
The parent class for traffic light logics.
MSPhaseDefinition myCurrentPhase
The current phase.
const MSLinkCont & getLinkCont() const
returns the container with all links !!!
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
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.
int getCurrentPhaseIndex() const
Returns the current index within the program.
SumoXMLNodeType getType() const
return the type of this Junction
~MSRailSignal()
Destructor.