51 const std::string&
id,
const std::string& subid,
52 const std::map<std::string, std::string>& parameters) :
61 LinkVectorVector::iterator i2;
66 LinkVector::const_iterator i;
67 for (i = links.begin(); i != links.end(); i++) {
74 std::vector<const MSLane*> afferentBlock;
75 bool noRailSignal =
true;
78 afferentBlock.push_back(approachingLane);
79 const MSLane* currentLane = approachingLane;
81 while (noRailSignal) {
82 std::vector<MSLane::IncomingLaneInfo> incomingLanes = currentLane->
getIncomingLanes();
84 if (!incomingLanes.empty()) {
85 precedentLane = incomingLanes.front().lane;
89 if (precedentLane == 0) {
96 afferentBlock.push_back(precedentLane);
97 currentLane = precedentLane;
106 std::vector<const MSLane*> succeedingBlock;
107 succeedingBlock.push_back(toLane);
108 currentLane = toLane;
109 bool noRailSignal =
true;
110 while (noRailSignal) {
112 std::vector<MSLink*> outGoingLinks = currentLane->
getLinkCont();
113 std::vector<MSLink*>::const_iterator j;
114 for (j = outGoingLinks.begin(); j != outGoingLinks.end(); j++) {
117 noRailSignal =
false;
124 if (outGoingLanes.size() == 0) {
125 noRailSignal =
false;
127 if (outGoingLanes.size() > 1) {
128 WRITE_WARNING(
"Rail lane '" + currentLane->
getID() +
"' has more than one outgoing lane but does not have a rail signal at its end");
130 const MSLane* nextLane = outGoingLanes.front();
131 succeedingBlock.push_back(nextLane);
132 currentLane = nextLane;
166 std::string state(
myLinks.size(),
'G');
167 std::vector<MSLane*>::const_iterator i;
172 bool succeedingBlockOccupied =
false;
173 std::vector<const MSLane*>::const_iterator j;
175 if (!(*j)->isEmpty()) {
176 succeedingBlockOccupied =
true;
189 if (succeedingBlockOccupied) {
190 std::vector<MSLink*>::const_iterator k;
196 bool hasOccupiedBlock =
false;
197 std::vector<MSLink*>::const_iterator k;
199 std::vector<const MSLane*>::const_iterator l;
201 if (!(*l)->isEmpty()) {
202 hasOccupiedBlock =
true;
204 std::vector<MSLink*>::const_iterator m;
213 if (hasOccupiedBlock) {
const std::vector< IncomingLaneInfo > & getIncomingLanes() const
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.
const MSLane * getLaneBefore() const
return the internalLaneBefore if it exists and the laneBefore otherwise
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 are subjected to this tls.
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.
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 !!!
std::map< MSLink *, std::vector< const MSLane * > > myAfferentBlocks
A map that maps a link from the junction to its vector of lanes leading from a previous signal to thi...
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.