47 #define DEBUG_COND (getID() == "disabled") 49 class ApproachingVehicleInformation;
54 const std::string&
id,
const std::string& subid,
55 const std::map<std::string, std::string>& parameters) :
64 LinkVectorVector::iterator i2;
69 LinkVector::const_iterator i;
70 for (i = links.begin(); i != links.end(); i++) {
77 std::vector<const MSLane*> afferentBlock;
78 bool noRailSignal =
true;
81 afferentBlock.push_back(approachingLane);
82 const MSLane* currentLane = approachingLane;
84 while (noRailSignal) {
85 std::vector<MSLane::IncomingLaneInfo> incomingLanes = currentLane->
getIncomingLanes();
87 if (!incomingLanes.empty()) {
88 precedentLane = incomingLanes.front().lane;
92 if (precedentLane == 0) {
99 afferentBlock.push_back(precedentLane);
100 currentLane = precedentLane;
109 std::vector<const MSLane*> succeedingBlock;
110 succeedingBlock.push_back(toLane);
111 currentLane = toLane;
112 bool noRailSignalLocal =
true;
113 while (noRailSignalLocal) {
115 std::vector<MSLink*> outGoingLinks = currentLane->
getLinkCont();
116 std::vector<MSLink*>::const_iterator j;
117 for (j = outGoingLinks.begin(); j != outGoingLinks.end(); j++) {
120 noRailSignalLocal =
false;
124 if (noRailSignalLocal) {
127 if (outGoingLanes.size() == 0) {
128 noRailSignalLocal =
false;
130 if (outGoingLanes.size() > 1) {
131 WRITE_WARNING(
"Rail lane '" + currentLane->
getID() +
"' has more than one outgoing lane but does not have a rail signal at its end");
133 const MSLane* nextLane = outGoingLanes.front();
134 succeedingBlock.push_back(nextLane);
135 currentLane = nextLane;
143 #ifdef DEBUG_SUCCEEDINGBLOCKS 145 std::cout <<
"railSignal=" <<
getID() <<
" mySucceedingBlocks:\n";
147 std::cout <<
" toLane=" << item.first->getID() <<
" succ=" <<
toString(item.second) <<
"\n";
154 std::queue<const MSLane*> revLanes;
155 for (std::vector<const MSLane*>::iterator laneIt = it->second.begin(); laneIt != it->second.end(); laneIt++) {
156 const MSLane* lane = *laneIt;
159 if (reverseEdge != 0) {
161 revLanes.push(revLane);
170 while (!revLanes.empty()) {
171 const MSLane* revLane = revLanes.front();
172 it->second.push_back(revLane);
203 std::string state(
myLinks.size(),
'G');
204 std::vector<MSLane*>::const_iterator i;
209 bool succeedingBlockOccupied =
false;
210 std::vector<const MSLane*>::const_iterator j;
212 if (!(*j)->isEmpty()) {
213 succeedingBlockOccupied =
true;
217 const MSLink* inCommingLing = it->second;
218 const std::map<const SUMOVehicle*, MSLink::ApproachingVehicleInformation, SUMOVehicle::ComparatorIdLess> approaching = inCommingLing->
getApproaching();
219 std::map<const SUMOVehicle*, MSLink::ApproachingVehicleInformation>::const_iterator apprIt = approaching.begin();
220 for (; apprIt != approaching.end(); apprIt++) {
223 succeedingBlockOccupied =
true;
230 if (succeedingBlockOccupied) {
243 if (succeedingBlockOccupied) {
244 std::vector<MSLink*>::const_iterator k;
250 bool hasOccupiedBlock =
false;
251 std::vector<MSLink*>::const_iterator k;
253 std::vector<const MSLane*>::const_iterator l;
255 if (!(*l)->isEmpty()) {
256 hasOccupiedBlock =
true;
258 std::vector<MSLink*>::const_iterator m;
267 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::string toString(const T &t, std::streamsize accuracy=gPrecision)
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.