42 #ifdef CHECK_MEMORY_LEAKS
44 #endif // CHECK_MEMORY_LEAKS
56 #ifndef HAVE_INTERNAL_LANES
62 myRequestIdx(0), myRespondIdx(0),
63 myState(state), myDirection(dir), myLength(length) {}
69 myRequestIdx(0), myRespondIdx(0),
70 myState(state), myDirection(dir), myLength(length),
71 myJunctionInlane(via) {}
80 const std::vector<MSLink*>& foeLinks,
81 const std::vector<MSLane*>& foeLanes) {
93 const bool setRequest,
const SUMOTime arrivalTimeBraking,
const SUMOReal arrivalSpeedBraking,
const SUMOTime waitingTime) {
97 arrivalTimeBraking, arrivalSpeedBraking, waitingTime)));
111 if ((*i)->isBlockingAnyone()) {
127 std::map<const SUMOVehicle*, ApproachingVehicleInformation>::const_iterator i =
myApproachingVehicles.find(veh);
138 return arrivalTime +
TIME2STEPS((
getLength() + vehicleLength) / (0.5 * (arrivalSpeed + leaveSpeed)));
145 std::vector<const SUMOVehicle*>* collectFoes)
const {
164 if ((*i)->blockedAtTime(arrivalTime, leaveTime, arrivalSpeed, leaveSpeed,
myLane == (*i)->getLane(),
165 impatience, decel, waitingTime, collectFoes)) {
176 std::vector<const SUMOVehicle*>* collectFoes)
const {
178 if (!i->second.willPass) {
182 assert(waitingTime > 0);
183 if (waitingTime > i->second.waitingTime) {
186 if (waitingTime == i->second.waitingTime && arrivalTime < i->second.arrivalTime) {
190 const SUMOTime foeArrivalTime = (
SUMOTime)((1.0 - impatience) * i->second.arrivalTime + impatience * i->second.arrivalTimeBraking);
191 if (i->second.leavingTime < arrivalTime) {
193 if (sameTargetLane && (arrivalTime - i->second.leavingTime <
myLookaheadTime
195 i->first->getVehicleType().getCarFollowModel().getMaxDecel(), decel))) {
196 if (collectFoes == 0) {
199 collectFoes->push_back(i->first);
202 }
else if (foeArrivalTime > leaveTime) {
206 decel, i->first->getVehicleType().getCarFollowModel().getMaxDecel()))) {
207 if (collectFoes == 0) {
210 collectFoes->push_back(i->first);
215 if (collectFoes == 0) {
218 collectFoes->push_back(i->first);
239 assert(distLeft > 0);
250 if ((*i)->blockedAtTime(arrivalTime, leaveTime, speed, speed,
myLane == (*i)->getLane(), 0, decel, 0)) {
255 if ((*i)->getVehicleNumber() > 0 || (*i)->getPartialOccupator() != 0) {
286 #ifdef HAVE_INTERNAL_LANES
287 const std::string via = getViaLane() == 0 ?
"" : getViaLane()->getID();
289 const std::string via =
"";
293 std::vector<std::pair<SUMOTime, const SUMOVehicle*> > toSort;
295 toSort.push_back(std::make_pair(it->second.arrivalTime, it->first));
297 std::sort(toSort.begin(), toSort.end());
298 for (std::vector<std::pair<SUMOTime, const SUMOVehicle*> >::const_iterator it = toSort.begin(); it != toSort.end(); ++it) {
314 #ifdef HAVE_INTERNAL_LANES
316 MSLink::getViaLane()
const {
317 return myJunctionInlane;
322 MSLink::getLeaderInfo(
SUMOReal dist)
const {
327 for (std::vector<MSLane*>::const_iterator it_lane =
myFoeLanes.begin(); it_lane !=
myFoeLanes.end(); ++it_lane) {
335 (*it_lane)->releaseVehicles();
336 for (MSLane::VehCont::const_iterator it_veh = vehicles.begin(); it_veh != vehicles.end(); ++it_veh) {
340 result.push_back(std::make_pair(leader,
346 MSVehicle* leader = (*it_lane)->getPartialOccupator();
348 result.push_back(std::make_pair(leader,
350 dist - ((*it_lane)->getLength() - (*it_lane)->getPartialOccupatorEnd())));
361 #ifdef HAVE_INTERNAL_LANES
362 if (myJunctionInlane != 0) {
363 return myJunctionInlane;
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Representation of a vehicle in the micro simulation.
MSLane * myLane
The lane approached by this link.
void addBlockedLink(MSLink *link)
ApproachingVehicleInformation getApproaching(const SUMOVehicle *veh) const
LinkState myState
The state of the link.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
SUMOReal getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
std::vector< std::pair< MSVehicle *, SUMOReal > > LinkLeaders
This is an uncontrolled, minor link, has to stop.
SUMOReal getLength() const
Returns the lane's length.
std::vector< MSLink * > myFoeLinks
bool hasApproachingFoe(SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal speed, SUMOReal decel=DEFAULT_VEH_DECEL) const
Returns the information whether a vehicle is approaching on one of the link's foe streams...
void setTLState(LinkState state, SUMOTime t)
Sets the current tl-state.
std::vector< MSVehicle * > VehCont
Container for vehicles.
std::string time2string(SUMOTime t)
SUMOReal getLength() const
Get vehicle's length [m].
LinkDirection myDirection
An abstract (hopefully human readable) definition of the link's direction.
LinkDirection getDirection() const
Returns the direction the vehicle passing this link take.
SUMOReal getPositionOnLane() const
Get the vehicle's position along the lane.
std::map< const SUMOVehicle *, ApproachingVehicleInformation > myApproachingVehicles
This is an uncontrolled, all-way stop link.
unsigned int myRequestIdx
The position of the link within this request.
bool blockedAtTime(SUMOTime arrivalTime, SUMOTime leaveTime, SUMOReal arrivalSpeed, SUMOReal leaveSpeed, bool sameTargetLane, SUMOReal impatience, SUMOReal decel, SUMOTime waitingTime, std::vector< const SUMOVehicle * > *collectFoes=0) const
Returns the information whether this link is blocked Valid after the vehicles have set their requests...
SUMOReal getPartialOccupatorEnd() const
Returns the position of the in-lapping vehicle's end.
LinkDirection
The different directions a link between two lanes may take (or a stream between two edges)...
Representation of a vehicle.
MSLane * getLane() const
Returns the connected lane.
bool myIsCrossing
Whether any foe links exist.
std::set< MSLink * > myBlockedFoeLinks
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic, in MSLink and GNEInternalLane.
void setRequestInformation(unsigned int requestIdx, unsigned int respondIdx, bool isCrossing, bool isCont, const std::vector< MSLink * > &foeLinks, const std::vector< MSLane * > &foeLanes)
Sets the request information.
static bool gUsingInternalLanes
Information whether the simulation regards internal lanes.
SUMOReal getMaxDecel() const
Get the vehicle type's maximum deceleration [m/s^2].
virtual MSVehicle * getLastVehicle() const
returns the last vehicle
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
static bool unsafeMergeSpeeds(SUMOReal leaderSpeed, SUMOReal followerSpeed, SUMOReal leaderDecel, SUMOReal followerDecel)
return whether the given vehicles may NOT merge safely
SUMOReal getLength() const
Returns the length of this link.
static bool maybeOccupied(MSLane *lane)
returns whether the given lane may still be occupied by a vehicle currently on it ...
std::vector< MSLane * > myFoeLanes
bool willHaveBlockedFoe() const
MSLane * getViaLaneOrLane() const
return the via lane if it exists and the lane otherwise
The link has red light (must brake)
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
SUMOReal getSpeed() const
Returns the vehicle's current speed.
void writeApproaching(OutputDevice &od, const std::string fromLaneID) const
write information about all approaching vehicles to the given output device
bool isCrossing() const
Returns whether this link belongs to a junction where more than one edge is incoming.
unsigned int myRespondIdx
The position within this respond.
MSLink(MSLane *succLane, LinkDirection dir, LinkState state, SUMOReal length)
Constructor for simulation not using internal lanes.
MSVehicle * getPartialOccupator() const
Returns the vehicle which laps into this lane.
Static storage of an output device and its base (abstract) implementation.
bool closeTag()
Closes the most recently opened tag.
static const bool gUseMesoSim
void setApproaching(const SUMOVehicle *approaching, const SUMOTime arrivalTime, const SUMOReal arrivalSpeed, const SUMOReal leaveSpeed, const bool setRequest, const SUMOTime arrivalTimeBraking, const SUMOReal arrivalSpeedBraking, const SUMOTime waitingTime)
Sets the information about an approaching vehicle.
void removeApproaching(const SUMOVehicle *veh)
removes the vehicle from myApproachingVehicles
SUMOTime getLeaveTime(SUMOTime arrivalTime, SUMOReal arrivalSpeed, SUMOReal leaveSpeed, SUMOReal vehicleLength) const
return the expected time at which the given vehicle will clear the link
The edge is an internal edge.
static SUMOTime myLookaheadTime
Representation of a lane in the micro simulation.
unsigned int getRespondIndex() const
Returns the respond index (for visualization)
bool opened(SUMOTime arrivalTime, SUMOReal arrivalSpeed, SUMOReal leaveSpeed, SUMOReal vehicleLength, SUMOReal impatience, SUMOReal decel, SUMOTime waitingTime, std::vector< const SUMOVehicle * > *collectFoes=0) const
Returns the information whether the link may be passed.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.