48 class ApproachingVehicleInformation;
53 const std::string&
id,
const std::string& subid,
54 const std::map<std::string, std::string>& parameters) :
63 LinkVectorVector::iterator i2;
68 LinkVector::const_iterator i;
69 for (i = links.begin(); i != links.end(); i++) {
76 std::vector<const MSLane*> afferentBlock;
77 bool noRailSignal =
true;
80 afferentBlock.push_back(approachingLane);
81 const MSLane* currentLane = approachingLane;
83 while (noRailSignal) {
84 std::vector<MSLane::IncomingLaneInfo> incomingLanes = currentLane->
getIncomingLanes();
86 if (!incomingLanes.empty()) {
87 precedentLane = incomingLanes.front().lane;
91 if (precedentLane == 0) {
98 afferentBlock.push_back(precedentLane);
99 currentLane = precedentLane;
108 std::vector<const MSLane*> succeedingBlock;
109 succeedingBlock.push_back(toLane);
110 currentLane = toLane;
111 bool noRailSignalLocal =
true;
112 while (noRailSignalLocal) {
114 std::vector<MSLink*> outGoingLinks = currentLane->
getLinkCont();
115 std::vector<MSLink*>::const_iterator j;
116 for (j = outGoingLinks.begin(); j != outGoingLinks.end(); j++) {
119 noRailSignalLocal =
false;
123 if (noRailSignalLocal) {
126 if (outGoingLanes.size() == 0) {
127 noRailSignalLocal =
false;
129 if (outGoingLanes.size() > 1) {
130 WRITE_WARNING(
"Rail lane '" + currentLane->
getID() +
"' has more than one outgoing lane but does not have a rail signal at its end");
132 const MSLane* nextLane = outGoingLanes.front();
133 succeedingBlock.push_back(nextLane);
134 currentLane = nextLane;
145 std::queue<const MSLane*> revLanes;
146 for (std::vector<const MSLane*>::iterator laneIt = it->second.begin(); laneIt != it->second.end(); laneIt++) {
147 const MSLane* lane = *laneIt;
150 if (reverseEdge != 0) {
152 revLanes.push(revLane);
161 while (!revLanes.empty()) {
162 const MSLane* revLane = revLanes.front();
163 it->second.push_back(revLane);
194 std::string state(
myLinks.size(),
'G');
195 std::vector<MSLane*>::const_iterator i;
200 bool succeedingBlockOccupied =
false;
201 std::vector<const MSLane*>::const_iterator j;
203 if (!(*j)->isEmpty()) {
204 succeedingBlockOccupied =
true;
208 const MSLink* inCommingLing = it->second;
209 const std::map<const SUMOVehicle*, MSLink::ApproachingVehicleInformation> approaching = inCommingLing->
getApproaching();
210 std::map<const SUMOVehicle*, MSLink::ApproachingVehicleInformation>::const_iterator apprIt = approaching.begin();
211 for (; apprIt != approaching.end(); apprIt++) {
214 succeedingBlockOccupied =
true;
221 if (succeedingBlockOccupied) {
234 if (succeedingBlockOccupied) {
235 std::vector<MSLink*>::const_iterator k;
241 bool hasOccupiedBlock =
false;
242 std::vector<MSLink*>::const_iterator k;
244 std::vector<const MSLane*>::const_iterator l;
246 if (!(*l)->isEmpty()) {
247 hasOccupiedBlock =
true;
249 std::vector<MSLink*>::const_iterator m;
258 if (hasOccupiedBlock) {
MSEdge & getEdge() const
Returns the lane's edge.
Builds detectors for microsim.
int getCurrentPhaseIndex() const
Returns the current index within the program.
bool setTrafficLightSignals(SUMOTime t) const
Applies the current signal states to controlled links.
ApproachingVehicleInformation getApproaching(const SUMOVehicle *veh) const
MSLink * getLinkTo(const MSLane *) const
returns the link to the given lane or 0, if it is not connected
void updateCurrentPhase()
updates the current phase of the signal
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
SUMOTime getOffsetFromIndex(int index) const
Returns the position (start of a phase during a cycle) from of a given step.
The base class for an intersection.
int getPhaseNumber() const
Returns the number of phases.
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).
const MSPhaseDefinition & getPhase(int givenstep) const
Returns the definition of the phase from the given position within the plan.
#define SUMO_MAX_CONNECTIONS
the maximum number of connections across an intersection
std::map< const MSLane *, const MSLink * > mySucceedingBlocksIncommingLinks
A map of lanes to links of approaching vehicles of succeeding blocks.
#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.
int getIndexFromOffset(SUMOTime offset) const
Returns the step (the phasenumber) of a given position of the cycle.
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
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.
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 MSEdge * getMyOppositeSuperposableEdge() const
return opposite superposable/congruent edge, if it exist and 0 else
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.
MSLane * getCanonicalPredecessorLane() const
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.
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...
void adaptLinkInformationFrom(const MSTrafficLightLogic &logic)
Applies information about controlled links and lanes from the given logic.
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 MSLane * getLaneBefore() const
return the internalLaneBefore if it exists and the laneBefore otherwise
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...
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.