MSEdge Class Reference

#include <MSEdge.h>

Inheritance diagram for MSEdge:

GUIEdge

Detailed Description

A road/street connecting two junctions.

A single connection between two junctions. Holds lanes which are reponsible for vehicle movements.

Definition at line 62 of file MSEdge.h.


Static edge container

typedef std::map< std::string,
MSEdge * > 
DictType
 definition of the static dictionary type
static DictType myDict
 Static dictionary to associate string-ids with objects.
static std::vector< MSEdge * > myEdges
 Static list of edges.

Public Types

typedef std::map< const MSEdge
*, std::vector< MSLane * > * > 
AllowedLanesCont
 Suceeding edges (keys) and allowed lanes to reach these edges (values).
typedef std::map
< SUMOVehicleClass,
AllowedLanesCont
ClassedAllowedLanesCont
 Map from vehicle types to lanes that may be used to reach one of the next edges.
enum  EdgeBasicFunction {
  EDGEFUNCTION_UNKNOWN = -1, EDGEFUNCTION_NORMAL = 0, EDGEFUNCTION_CONNECTOR = 1, EDGEFUNCTION_INTERNAL = 2,
  EDGEFUNCTION_DISTRICT = 3
}
 Defines possible edge types. More...

Public Member Functions

virtual void changeLanes (SUMOTime t) throw ()
 Performs lane changing on this edge.
void closeBuilding ()
SUMOReal getCurrentTravelTime () const throw ()
 Computes and returns the current travel time for this edge.
void initialize (MSLane *departLane, std::vector< MSLane * > *lanes, EdgeBasicFunction function) throw ()
 Initialize the edge.
 MSEdge (const std::string &id, unsigned int numericalID) throw ()
 Constructor.
bool prohibits (const SUMOVehicle *const vehicle) const throw ()
 Returns whether the vehicle (class) is not allowed on the edge.
void rebuildAllowedLanes () throw ()
virtual ~MSEdge () throw ()
 Destructor.
Access to succeeding/predecessing edges
void addFollower (MSEdge *edge) throw ()
 Returns the list of edges which may be reached from this edge.
const MSEdge *const getFollower (unsigned int n) const throw ()
 Returns the n-th of the following edges.
const std::vector< MSEdge * > & getIncomingEdges () const throw ()
 Returns the list of edges from which this edge may be reached.
unsigned int getNoFollowing () const throw ()
 Returns the number of edges that may be reached from this edge.
Access to the edge's lanes
const std::vector< MSLane * > * allowedLanes (SUMOVehicleClass vclass=SVC_UNKNOWN) const throw ()
 Get the allowed lanes for the given vehicle class.
const std::vector< MSLane * > * allowedLanes (const MSEdge &destination, SUMOVehicleClass vclass=SVC_UNKNOWN) const throw ()
 Get the allowed lanes to reach the destination-edge.
const std::vector< MSLane * > & getLanes () const throw ()
 Returns this edge's lanes.
MSLane *const leftLane (const MSLane *const lane) const throw ()
 Returns the lane left to the one given, 0 if the given lane is leftmost.
MSLane *const rightLane (const MSLane *const lane) const throw ()
 Returns the lane right to the one given, 0 if the given lane is rightmost.
Access to vaporizing interface
SUMOTime decVaporization (SUMOTime t) throw (ProcessError)
 Disables vaporization.
SUMOTime incVaporization (SUMOTime t) throw (ProcessError)
 Enables vaporization.
bool isVaporizing () const throw ()
 Returns whether vehicles on this edge shall be vaporized.
Methods releated to vehicle emission
bool emit (MSVehicle &v, SUMOTime time) const throw (ProcessError)
 Emits the given vehicle.
MSLanegetDepartLane (const MSVehicle &v) const throw ()
 Finds a depart lane for the given vehicle.
MSLanegetFreeLane (const SUMOVehicleClass vclass) const throw ()
 Finds the emptiest lane allowing the vehicle class.
SUMOTime getLastFailedEmissionTime () const throw ()
 Returns the last time a vehicle could not be inserted.
void setLastFailedEmissionTime (SUMOTime time) const throw ()
 Sets the last time a vehicle could not be inserted.
Access to other edge attributes
const std::string & getID () const throw ()
 Returns the id of the edge.
unsigned int getNumericalID () const throw ()
 Returns the numerical id of the edge.
EdgeBasicFunction getPurpose () const throw ()
 Returns the edge type (EdgeBasicFunction).

Static Public Member Functions

static void clear () throw ()
 Clears the dictionary.
static MSEdgedictionary (size_t index) throw ()
 Returns the MSEdge at the index.
static MSEdgedictionary (const std::string &id) throw ()
 Returns the MSEdge associated to the key id if exists, otherwise returns 0.
static bool dictionary (const std::string &id, MSEdge *edge) throw ()
 Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary. Otherwise returns false.
static size_t dictSize () throw ()
 Returns the number of edges.
static void insertIDs (std::vector< std::string > &into) throw ()
 Inserts IDs of all known edges into the given vector.
Static parser helper
static void parseEdgesList (const std::vector< std::string > &desc, std::vector< const MSEdge * > &into, const std::string &rid) throw (ProcessError)
 Parses the given string vector assuming it edge ids.
static void parseEdgesList (const std::string &desc, std::vector< const MSEdge * > &into, const std::string &rid) throw (ProcessError)
 Parses the given string assuming it contains a list of edge ids divided by spaces.

Protected Member Functions

const std::vector< MSLane * > * allowedLanes (const MSEdge *destination, SUMOVehicleClass vclass=SVC_UNKNOWN) const throw ()
 Get the allowed lanes to reach the destination-edge.

Protected Attributes

MSLanemyDepartLane
 Lane from which vehicles will depart, usually the rightmost.
EdgeBasicFunction myFunction
 the purpose of the edge
std::string myID
 Unique ID.
MSLaneChangermyLaneChanger
 This member will do the lane-change.
std::vector< MSLane * > * myLanes
 Container for the edge's lane; should be sorted: (right-hand-traffic) the more left the lane, the higher the container-index.
SUMOTime myLastFailedEmissionTime
 The time of last emission failure.
unsigned int myNumericalID
 This edge's numerical id.
std::vector< MSEdge * > myPredeccesors
 The preceeding edges.
std::vector< MSEdge * > mySuccessors
 The succeeding edges.
int myVaporizationRequests
 Vaporizer counter.
Storages for allowed lanes (depending on vehicle classes)
AllowedLanesCont myAllowed
 Associative container from destination-edge to allowed-lanes.
ClassedAllowedLanesCont myClassedAllowed
 From vehicle class to lanes allowed to be used by it.
bool myHaveClassConstraints
 Whether any class constraints exist for this edge.

Private Member Functions

 MSEdge (const MSEdge &)
 Invalidated copy constructor.
MSEdgeoperator= (const MSEdge &)
 assignment operator.

Data Structures

class  by_id_sorter
 Sorts edges by their ids. More...

Member Typedef Documentation

typedef std::map< const MSEdge*, std::vector<MSLane*>* > MSEdge::AllowedLanesCont

Suceeding edges (keys) and allowed lanes to reach these edges (values).

Definition at line 86 of file MSEdge.h.

Map from vehicle types to lanes that may be used to reach one of the next edges.

Definition at line 89 of file MSEdge.h.

typedef std::map< std::string, MSEdge* > MSEdge::DictType [protected]

definition of the static dictionary type

Definition at line 499 of file MSEdge.h.


Member Enumeration Documentation

Defines possible edge types.

For different purposes, it is necessary to know whether the edge is a normal street or something special.

Enumerator:
EDGEFUNCTION_UNKNOWN  The purpose of the edge is not known.
EDGEFUNCTION_NORMAL  The edge is a normal street.
EDGEFUNCTION_CONNECTOR  The edge is a macroscopic connector (source/sink).
EDGEFUNCTION_INTERNAL  The edge is an internal edge.
EDGEFUNCTION_DISTRICT  The edge is a district edge.

Definition at line 71 of file MSEdge.h.

00071                            {
00073         EDGEFUNCTION_UNKNOWN = -1,
00075         EDGEFUNCTION_NORMAL = 0,
00077         EDGEFUNCTION_CONNECTOR = 1,
00079         EDGEFUNCTION_INTERNAL = 2,
00081         EDGEFUNCTION_DISTRICT = 3
00082     };


Constructor & Destructor Documentation

MSEdge::MSEdge ( const std::string &  id,
unsigned int  numericalID 
) throw ()

Constructor.

After calling this constructor, the edge is not yet initialised completely. A call to "initialize" with proper values is needed for this.

Parameters:
[in] id The id of the edge
[in] numericalID The numerical id (index) of the edge

Definition at line 60 of file MSEdge.cpp.

00061         : myID(id), myNumericalID(numericalID), myLanes(0),
00062         myLaneChanger(0), myVaporizationRequests(0), myLastFailedEmissionTime(-1) {}

MSEdge::~MSEdge (  )  throw () [virtual]

Destructor.

Definition at line 65 of file MSEdge.cpp.

References myAllowed, myClassedAllowed, myLaneChanger, and myLanes.

00065                         {
00066     delete myLaneChanger;
00067     for (AllowedLanesCont::iterator i1=myAllowed.begin(); i1!=myAllowed.end(); i1++) {
00068         delete(*i1).second;
00069     }
00070     for (ClassedAllowedLanesCont::iterator i2=myClassedAllowed.begin(); i2!=myClassedAllowed.end(); i2++) {
00071         for (AllowedLanesCont::iterator i1=(*i2).second.begin(); i1!=(*i2).second.end(); i1++) {
00072             delete(*i1).second;
00073         }
00074     }
00075     delete myLanes;
00076     // Note: Lanes are delete using MSLane::clear();
00077 }

MSEdge::MSEdge ( const MSEdge  )  [private]

Invalidated copy constructor.


Member Function Documentation

void MSEdge::addFollower ( MSEdge edge  )  throw () [inline]

Returns the list of edges which may be reached from this edge.

Returns:
Edges reachable from this edge

Definition at line 213 of file MSEdge.h.

References mySuccessors.

Referenced by NLHandler::addDistrict(), and NLHandler::addDistrictEdge().

00213                                            {
00214         mySuccessors.push_back(edge);
00215     }

const std::vector< MSLane * > * MSEdge::allowedLanes ( const MSEdge destination,
SUMOVehicleClass  vclass = SVC_UNKNOWN 
) const throw () [protected]

Get the allowed lanes to reach the destination-edge.

If there is no such edge, get 0. Then you are on the wrong edge.

Parameters:
[in] destination The edge to reach
[in] vclass The vehicle class for which this information shall be returned
Returns:
The lanes that may be used to reach the given edge, 0 if no such lanes exist

Definition at line 199 of file MSEdge.cpp.

References myAllowed, myClassedAllowed, myHaveClassConstraints, and SVC_UNKNOWN.

00199                                                                                      {
00200     if (myHaveClassConstraints&&vclass!=SVC_UNKNOWN) {
00201         ClassedAllowedLanesCont::const_iterator i = myClassedAllowed.find(vclass);
00202         if (i!=myClassedAllowed.end()) {
00203             const AllowedLanesCont &c = (*i).second;
00204             AllowedLanesCont::const_iterator j = (*i).second.find(destination);
00205             if (j==c.end()) {
00206                 // Destination-edge not found.
00207                 return 0;
00208             }
00209             return (*j).second;
00210         }
00211     }
00212     AllowedLanesCont::const_iterator it = myAllowed.find(destination);
00213     if (it!=myAllowed.end()) {
00214         return it->second;
00215     } else {
00216         // Destination-edge not found.
00217         return 0;
00218     }
00219 }

const std::vector< MSLane * > * MSEdge::allowedLanes ( SUMOVehicleClass  vclass = SVC_UNKNOWN  )  const throw ()

Get the allowed lanes for the given vehicle class.

If there is no such edge, get 0. Then you are on the wrong edge.

Parameters:
[in] vclass The vehicle class for which this information shall be returned
Returns:
The lanes that may be used by the given vclass

Definition at line 193 of file MSEdge.cpp.

References allowedLanes().

00193                                                           {
00194     return allowedLanes(0, vclass);
00195 }

const std::vector< MSLane * > * MSEdge::allowedLanes ( const MSEdge destination,
SUMOVehicleClass  vclass = SVC_UNKNOWN 
) const throw ()

Get the allowed lanes to reach the destination-edge.

If there is no such edge, get 0. Then you are on the wrong edge.

Parameters:
[in] destination The edge to reach
[in] vclass The vehicle class for which this information shall be returned
Returns:
The lanes that may be used to reach the given edge, 0 if no such lanes exist

Definition at line 187 of file MSEdge.cpp.

Referenced by allowedLanes(), getDepartLane(), getFreeLane(), MS_E2_ZS_CollectorOverLanes::getLanePredeccessorLanes(), and MSLane::succLinkSec().

00187                                                                                      {
00188     return allowedLanes(&destination, vclass);
00189 }

void MSEdge::changeLanes ( SUMOTime  t  )  throw () [virtual]

Performs lane changing on this edge.

Definition at line 327 of file MSEdge.cpp.

References EDGEFUNCTION_INTERNAL, MSLaneChanger::laneChange(), myFunction, and myLaneChanger.

Referenced by MSEdgeControl::changeLanes().

00327                                       {
00328     if (myFunction==EDGEFUNCTION_INTERNAL) {
00329         return;
00330     }
00331     assert(myLaneChanger != 0);
00332     myLaneChanger->laneChange(t);
00333 }

void MSEdge::clear (  )  throw () [static]

Clears the dictionary.

Definition at line 442 of file MSEdge.cpp.

References myDict.

Referenced by MSNet::clearAll().

00442                       {
00443     for (DictType::iterator i=myDict.begin(); i!=myDict.end(); ++i) {
00444         delete(*i).second;
00445     }
00446     myDict.clear();
00447 }

void MSEdge::closeBuilding (  ) 

Todo:
Has to be called after all edges were built and all connections were set...; Still, is not very nice

Definition at line 94 of file MSEdge.cpp.

References MSLane::getEdge(), myAllowed, myLanes, myPredeccesors, mySuccessors, and rebuildAllowedLanes().

00094                       {
00095     myAllowed[0] = new std::vector<MSLane*>();
00096     for (std::vector<MSLane*>::iterator i=myLanes->begin(); i!=myLanes->end(); ++i) {
00097         myAllowed[0]->push_back(*i);
00098         const MSLinkCont &lc = (*i)->getLinkCont();
00099         for (MSLinkCont::const_iterator j=lc.begin(); j!=lc.end(); ++j) {
00100             MSLane *toL = (*j)->getLane();
00101             if (toL!=0) {
00102                 MSEdge &to = toL->getEdge();
00103                 //
00104                 if (std::find(mySuccessors.begin(), mySuccessors.end(), &to)==mySuccessors.end()) {
00105                     mySuccessors.push_back(&to);
00106                 }
00107                 if (std::find(to.myPredeccesors.begin(), to.myPredeccesors.end(), this)==to.myPredeccesors.end()) {
00108                     to.myPredeccesors.push_back(this);
00109                 }
00110                 //
00111                 if (myAllowed.find(&to)==myAllowed.end()) {
00112                     myAllowed[&to] = new std::vector<MSLane*>();
00113                 }
00114                 myAllowed[&to]->push_back(*i);
00115             }
00116         }
00117     }
00118     std::sort(mySuccessors.begin(), mySuccessors.end(), by_id_sorter());
00119     rebuildAllowedLanes();
00120 }

SUMOTime MSEdge::decVaporization ( SUMOTime  t  )  throw (ProcessError)

Disables vaporization.

The internal vaporization counter is decreased what disables the vaporization if it was only once enabled. Called from the event handler.

Parameters:
[in] t The current time (unused)
Returns:
Time to next call (always 0)
Exceptions:
ProcessError not thrown by this method, just derived

Definition at line 231 of file MSEdge.cpp.

References myVaporizationRequests.

Referenced by NLTriggerBuilder::buildVaporizer().

00231                                                     {
00232     --myVaporizationRequests;
00233     return 0;
00234 }

MSEdge * MSEdge::dictionary ( size_t  index  )  throw () [static]

Returns the MSEdge at the index.

Definition at line 429 of file MSEdge.cpp.

References myEdges.

00429                                     {
00430     assert(myEdges.size()>id);
00431     return myEdges[id];
00432 }

MSEdge * MSEdge::dictionary ( const std::string &  id  )  throw () [static]

Returns the MSEdge associated to the key id if exists, otherwise returns 0.

Definition at line 418 of file MSEdge.cpp.

References myDict.

00418                                               {
00419     DictType::iterator it = myDict.find(id);
00420     if (it == myDict.end()) {
00421         // id not in myDict.
00422         return 0;
00423     }
00424     return it->second;
00425 }

bool MSEdge::dictionary ( const std::string &  id,
MSEdge edge 
) throw () [static]

Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary. Otherwise returns false.

Definition at line 402 of file MSEdge.cpp.

References myDict, and myEdges.

Referenced by NLHandler::addDistrict(), NLHandler::addDistrictEdge(), NLBuilder::EdgeFloatTimeLineRetriever_EdgeTravelTime::addEdgeWeight(), NLBuilder::EdgeFloatTimeLineRetriever_EdgeEffort::addEdgeWeight(), MSVehicleTransfer::addVeh(), NLEdgeControlBuilder::beginEdgeParsing(), NLDetectorBuilder::buildRouteProbe(), NLTriggerBuilder::buildVaporizer(), MSDevice_Routing::buildVehicleDevices(), MSVehicleTransfer::checkEmissions(), traci::TraCIServer::commandChangeRoute(), traci::TraCIServer::commandChangeTarget(), traci::TraCIServer::commandDistanceRequest(), traci::TraCIServer::commandStopNode(), traci::TraCIServer::convertCartesianToRoadMap(), traci::TraCIServer::convertRoadMapToCartesian(), GUINet::getEdgeBoundary(), traci::TraCIServer::handleRoadMapDomain(), traci::TraCIServer::handleVehicleDomain(), GUISelectionLoader::loadSelection(), MSTriggeredRerouter::myStartElement(), MSRouteHandler::myStartElement(), NLTriggerBuilder::parseAndBuildRerouter(), parseEdgesList(), TraCIServerAPI_Vehicle::processGet(), TraCIServerAPI_Edge::processGet(), TraCIServerAPI_Vehicle::processSet(), TraCIServerAPI_Edge::processSet(), and MSVehicle::reroute().

00402                                                            {
00403     DictType::iterator it = myDict.find(id);
00404     if (it == myDict.end()) {
00405         // id not in myDict.
00406         myDict[id] = ptr;
00407         while (myEdges.size()<ptr->getNumericalID()+1) {
00408             myEdges.push_back(0);
00409         }
00410         myEdges[ptr->getNumericalID()] = ptr;
00411         return true;
00412     }
00413     return false;
00414 }

size_t MSEdge::dictSize (  )  throw () [static]

bool MSEdge::emit ( MSVehicle v,
SUMOTime  time 
) const throw (ProcessError)

Emits the given vehicle.

The procedure for choosing the proper lane is determined, first. In dependance to this, the proper emission lane is chosen.

Emission itself is done by calling the chose lane's "emit" method.

Parameters:
[in] v The vehicle to emit
[in] time The current simulation time
Returns:
Whether the vehicle could be emitted
See also:
MSLane::emit

Definition at line 280 of file MSEdge.cpp.

References DEPART_POS_FREE, DEPART_POS_GIVEN, DEPART_POS_RANDOM, DEPART_POS_RANDOM_FREE, SUMOVehicleParameter::departPos, SUMOVehicleParameter::departPosProcedure, MSLane::emit(), getDepartLane(), getLanes(), isVaporizing(), RandHelper::rand(), and SUMOReal.

Referenced by MSEmitter::childCheckEmit(), MSCalibrator::childCheckEmit(), and MSEmitControl::tryEmit().

00280                                                                   {
00281     // when vaporizing, no vehicles are emitted...
00282     if (isVaporizing()) {
00283         return false;
00284     }
00285     const SUMOVehicleParameter &pars = v.getParameter();
00286 #ifdef HAVE_MESOSIM
00287     if (MSGlobals::gUseMesoSim) {
00288         SUMOReal pos = 0.0;
00289         switch (pars.departPosProcedure) {
00290         case DEPART_POS_GIVEN:
00291             if (pars.departPos >= 0.) {
00292                 pos = pars.departPos;
00293             } else {
00294                 pos = pars.departPos + getLanes()[0]->getLength();
00295             }
00296             break;
00297         case DEPART_POS_RANDOM:
00298         case DEPART_POS_RANDOM_FREE:
00299             pos = RandHelper::rand(getLanes()[0]->getLength());
00300             break;
00301         default:
00302             break;
00303         }
00304         bool result = false;
00305         bool insertToNet = false;
00306         MESegment* segment = MSGlobals::gMesoNet->getSegmentForEdge(*this, pos);
00307         if (pars.departPosProcedure == DEPART_POS_FREE) {
00308             while (segment != 0 && !result) {
00309                 result = segment->initialise(&v, time, insertToNet);
00310                 segment = segment->getNextSegment();
00311             }
00312         } else {
00313             result = segment->initialise(&v, time, insertToNet);
00314         }
00315         if (insertToNet) {
00316             MSGlobals::gMesoNet->addCar(&v);
00317         }
00318         return result;
00319     }
00320 #endif
00321     MSLane* emitLane = getDepartLane(v);
00322     return emitLane != 0 && /*emitLane->getVehLenSum() + v.getLength() < emitLane->getLength() && */emitLane->emit(v);
00323 }

SUMOReal MSEdge::getCurrentTravelTime (  )  const throw ()

Computes and returns the current travel time for this edge.

The mean travel time of all lanes is summed and divided by the number of lanes. If the result is zero, 1000000. (a very large number) is returned, otherwise the edge's length divided by this speed.

Returns:
The current effort (travel time) to pass the edge

Definition at line 357 of file MSEdge.cpp.

References myLanes, and SUMOReal.

Referenced by TraCIServerAPI_Edge::processGet().

00357                                            {
00358     SUMOReal v = 0;
00359 #ifdef HAVE_MESOSIM
00360     if (MSGlobals::gUseMesoSim) {
00361         MESegment *first = MSGlobals::gMesoNet->getSegmentForEdge(*this);
00362         unsigned segments = 0;
00363         do {
00364             v += first->getMeanSpeed();
00365             first = first->getNextSegment();
00366             segments++;
00367         } while (first!=0);
00368         v /= (SUMOReal) segments;
00369     } else {
00370 #endif
00371         for (std::vector<MSLane*>::iterator i=myLanes->begin(); i!=myLanes->end(); ++i) {
00372             v += (*i)->getMeanSpeed();
00373         }
00374         v /= (SUMOReal) myLanes->size();
00375 #ifdef HAVE_MESOSIM
00376     }
00377 #endif
00378     if (v!=0) {
00379         return (*myLanes)[0]->getLength() / v;
00380     } else {
00381         return 1000000.;
00382     }
00383 }

MSLane * MSEdge::getDepartLane ( const MSVehicle v  )  const throw ()

Finds a depart lane for the given vehicle.

Depending on the depart lane procedure a depart lane is chosen. Repeated calls with the same vehicle may return different results if the procedure is "random" or "free". In case no appropriate lane was found, 0 is returned.

Parameters:
[in] v The vehicle to get the depart lane for
Returns:
a possible depart lane
See also:
MSLane::emit

Definition at line 255 of file MSEdge.cpp.

References allowedLanes(), MSLane::allowsVehicleClass(), DEPART_LANE_DEFAULT, DEPART_LANE_DEPARTLANE, DEPART_LANE_FREE, DEPART_LANE_GIVEN, DEPART_LANE_RANDOM, SUMOVehicleParameter::departLane, SUMOVehicleParameter::departLaneProcedure, getFreeLane(), RandHelper::getRandomFrom(), myDepartLane, and myLanes.

Referenced by emit().

00255                                                       {
00256     const SUMOVehicleParameter &pars = v.getParameter();
00257     switch (pars.departLaneProcedure) {
00258     case DEPART_LANE_GIVEN:
00259         if ((int) myLanes->size() <= pars.departLane || !(*myLanes)[pars.departLane]->allowsVehicleClass(v.getVehicleType().getVehicleClass())) {
00260             return 0;
00261         }
00262         return (*myLanes)[pars.departLane];
00263     case DEPART_LANE_RANDOM:
00264         return RandHelper::getRandomFrom(*allowedLanes(v.getVehicleType().getVehicleClass()));
00265     case DEPART_LANE_FREE:
00266         return getFreeLane(v.getVehicleType().getVehicleClass());
00267     case DEPART_LANE_DEPARTLANE:
00268     case DEPART_LANE_DEFAULT:
00269     default:
00270         break;
00271     }
00272     if (!myDepartLane->allowsVehicleClass(v.getVehicleType().getVehicleClass())) {
00273         return 0;
00274     }
00275     return myDepartLane;
00276 }

const MSEdge* const MSEdge::getFollower ( unsigned int  n  )  const throw () [inline]

Returns the n-th of the following edges.

Parameters:
[in] n The index within following edges of the edge to return
Returns:
The n-th of the following edges

Definition at line 237 of file MSEdge.h.

References mySuccessors.

Referenced by MSRouteHandler::myStartElement().

00237                                                                    {
00238         return mySuccessors[n];
00239     }

MSLane * MSEdge::getFreeLane ( const SUMOVehicleClass  vclass  )  const throw ()

Finds the emptiest lane allowing the vehicle class.

The emptiest lane is the one with the fewest vehicles on. If there is more than one, the first according to its index in the lane container is chosen.

Parameters:
[in] vclass The vehicle class to look for
Returns:
the least occupied lane
See also:
MSLane::emit

Definition at line 238 of file MSEdge.cpp.

References allowedLanes(), and MSLane::getVehicleNumber().

Referenced by MSVehicleTransfer::checkEmissions(), and getDepartLane().

00238                                                                {
00239     const std::vector<MSLane*>* lanes = allowedLanes(vclass);
00240     MSLane* res = 0;
00241     if (lanes != 0) {
00242         unsigned int noCars = INT_MAX;
00243         for (std::vector<MSLane*>::const_iterator i=lanes->begin(); i!=lanes->end(); ++i) {
00244             if ((*i)->getVehicleNumber()<noCars) {
00245                 res = (*i);
00246                 noCars = (*i)->getVehicleNumber();
00247             }
00248         }
00249     }
00250     return res;
00251 }

const std::string& MSEdge::getID (  )  const throw () [inline]

const std::vector<MSEdge*>& MSEdge::getIncomingEdges (  )  const throw () [inline]

Returns the list of edges from which this edge may be reached.

Returns:
Edges from which this edge may be reached

Definition at line 221 of file MSEdge.h.

References myPredeccesors.

00221                                                                {
00222         return myPredeccesors;
00223     }

const std::vector<MSLane*>& MSEdge::getLanes (  )  const throw () [inline]

SUMOTime MSEdge::getLastFailedEmissionTime (  )  const throw () [inline]

Returns the last time a vehicle could not be inserted.

Returns:
The current value

Definition at line 341 of file MSEdge.h.

References myLastFailedEmissionTime.

Referenced by MSEmitControl::tryEmit().

00341                                                               {
00342         return myLastFailedEmissionTime;
00343     }

unsigned int MSEdge::getNoFollowing (  )  const throw () [inline]

Returns the number of edges that may be reached from this edge.

Returns:
The number of following edges

Definition at line 229 of file MSEdge.h.

References mySuccessors.

Referenced by MSRouteHandler::myStartElement().

00229                                                 {
00230         return (unsigned int) mySuccessors.size();
00231     }

unsigned int MSEdge::getNumericalID (  )  const throw () [inline]

Returns the numerical id of the edge.

Returns:
This edge's numerical id

Definition at line 200 of file MSEdge.h.

References myNumericalID.

Referenced by MSEdgeControl::changeLanes(), and traci::TraCIServer::handleRoadMapDomain().

00200                                                 {
00201         return myNumericalID;
00202     }

EdgeBasicFunction MSEdge::getPurpose (  )  const throw () [inline]

Returns the edge type (EdgeBasicFunction).

Returns:
This edge's EdgeBasicFunction
See also:
EdgeBasicFunction

Definition at line 192 of file MSEdge.h.

References myFunction.

Referenced by MSLane::appropriate(), MSVehicle::checkRewindLinkLanes(), MSVehicle::enterLaneAtMove(), MSVehicle::getBestLanesContinuation(), GUILaneWrapper::getPurpose(), traci::TraCIServer::postProcessSimulationStep(), and MSVehicle::vsafeCriticalCont().

00192                                                  {
00193         return myFunction;
00194     }

SUMOTime MSEdge::incVaporization ( SUMOTime  t  )  throw (ProcessError)

Enables vaporization.

The internal vaporization counter is increased enabling the vaporization. Called from the event handler.

Parameters:
[in] t The current time (unused)
Returns:
Time to next call (always 0)
Exceptions:
ProcessError not thrown by this method, just derived

Definition at line 224 of file MSEdge.cpp.

References myVaporizationRequests.

Referenced by NLTriggerBuilder::buildVaporizer().

00224                                                     {
00225     ++myVaporizationRequests;
00226     return 0;
00227 }

void MSEdge::initialize ( MSLane departLane,
std::vector< MSLane * > *  lanes,
EdgeBasicFunction  function 
) throw ()

Initialize the edge.

Parameters:
[in] allowed Information which edges may be reached from which lanes
[in] departLane The default departure lane (may be 0)
[in] lanes List of this edge's lanes
[in] function A basic type of the edge

Definition at line 81 of file MSEdge.cpp.

References EDGEFUNCTION_DISTRICT, EDGEFUNCTION_INTERNAL, myDepartLane, myFunction, myLaneChanger, and myLanes.

Referenced by NLHandler::addDistrict(), and NLEdgeControlBuilder::closeEdge().

00082                                                                                   {
00083     assert(function == EDGEFUNCTION_DISTRICT || lanes!=0);
00084     myDepartLane = departLane;
00085     myLanes = lanes;
00086     myFunction = function;
00087     if (myLanes && myLanes->size() > 1 && function!=EDGEFUNCTION_INTERNAL) {
00088         myLaneChanger = new MSLaneChanger(myLanes);
00089     }
00090 }

void MSEdge::insertIDs ( std::vector< std::string > &  into  )  throw () [static]

Inserts IDs of all known edges into the given vector.

Definition at line 451 of file MSEdge.cpp.

References myDict.

Referenced by TraCIServerAPI_Edge::processGet().

00451                                                     {
00452     for (DictType::iterator i=myDict.begin(); i!=myDict.end(); ++i) {
00453         into.push_back((*i).first);
00454     }
00455 }

bool MSEdge::isVaporizing (  )  const throw () [inline]

Returns whether vehicles on this edge shall be vaporized.

Returns:
Whether no vehicle shall be on this edge

Definition at line 250 of file MSEdge.h.

References myVaporizationRequests.

Referenced by MSEmitter::childCheckEmit(), MSCalibrator::childCheckEmit(), emit(), and MSEmitControl::tryEmit().

00250                                       {
00251         return myVaporizationRequests>0;
00252     }

MSLane *const MSEdge::leftLane ( const MSLane *const   lane  )  const throw ()

Returns the lane left to the one given, 0 if the given lane is leftmost.

Parameters:
[in] lane The lane right to the one to be returned
Returns:
The lane left to the given, 0 if no such lane exists
Todo:
This method searches for the given in the container; probably, this could be done faster

Definition at line 167 of file MSEdge.cpp.

References myLanes.

Referenced by traci::TraCIServer::commandStopNode(), and MSLane::getLeftLane().

00167                                                         {
00168     std::vector<MSLane*>::iterator laneIt = find(myLanes->begin(), myLanes->end(), lane);
00169     if (laneIt==myLanes->end()||laneIt==myLanes->end()-1) {
00170         return 0;
00171     }
00172     return *(laneIt+1);
00173 }

MSEdge& MSEdge::operator= ( const MSEdge  )  [private]

assignment operator.

void MSEdge::parseEdgesList ( const std::vector< std::string > &  desc,
std::vector< const MSEdge * > &  into,
const std::string &  rid 
) throw (ProcessError) [static]

Parses the given string vector assuming it edge ids.

Parameters:
[in] desc The string vector containing edge ids
[out] into The vector to fill
[in] rid The id of the route these description belongs to; used for error message generation
Exceptions:
ProcessError If one of the strings contained is not a known edge id

Definition at line 467 of file MSEdge.cpp.

References dictionary().

00468                                                                  {
00469     for (std::vector<std::string>::const_iterator i=desc.begin(); i!=desc.end(); ++i) {
00470         const MSEdge *edge = MSEdge::dictionary(*i);
00471         // check whether the edge exists
00472         if (edge==0) {
00473             throw ProcessError("The edge '" + *i + "' within route '" + rid + "' is not known."
00474                                + "\n The route can not be build.");
00475         }
00476         into.push_back(edge);
00477     }
00478 }

void MSEdge::parseEdgesList ( const std::string &  desc,
std::vector< const MSEdge * > &  into,
const std::string &  rid 
) throw (ProcessError) [static]

Parses the given string assuming it contains a list of edge ids divided by spaces.

Splits the string at spaces, uses polymorph method to generate edge vector.

Parameters:
[in] desc The string containing space-separated edge ids
[out] into The vector to fill
[in] rid The id of the route these description belongs to; used for error message generation
Exceptions:
ProcessError If one of the strings contained is not a known edge id

Definition at line 459 of file MSEdge.cpp.

References StringTokenizer::getVector().

Referenced by MSRouteHandler::myCharacters(), MSRouteHandler::myStartElement(), MSRouteHandler::openRoute(), and TraCIServerAPI_Vehicle::processSet().

00460                                                                  {
00461     StringTokenizer st(desc);
00462     parseEdgesList(st.getVector(), into, rid);
00463 }

bool MSEdge::prohibits ( const SUMOVehicle *const   vehicle  )  const throw ()

Returns whether the vehicle (class) is not allowed on the edge.

Definition at line 387 of file MSEdge.cpp.

References EDGEFUNCTION_DISTRICT, myFunction, myHaveClassConstraints, and myLanes.

00387                                                                  {
00388     if (myFunction == EDGEFUNCTION_DISTRICT || !myHaveClassConstraints) {
00389         return false;
00390     }
00391     SUMOVehicleClass vclass = vehicle->getVehicleType().getVehicleClass();
00392     for (std::vector<MSLane*>::iterator i=myLanes->begin(); i!=myLanes->end(); ++i) {
00393         if ((*i)->allowsVehicleClass(vclass)) {
00394             return false;
00395         }
00396     }
00397     return true;
00398 }

void MSEdge::rebuildAllowedLanes (  )  throw ()

Definition at line 124 of file MSEdge.cpp.

References myAllowed, myClassedAllowed, myHaveClassConstraints, and myLanes.

Referenced by closeBuilding(), TraCIServerAPI_Lane::processSet(), and TraCIServerAPI_Edge::processSet().

00124                                     {
00125     // build the classed allowed lanes
00126     myHaveClassConstraints = false;
00127     // build list of vehicle classes that are constrained
00128     // ... all others will be not regarded (allowed) ...
00129     std::set<SUMOVehicleClass> vclasses;
00130     for (std::vector<MSLane*>::const_iterator i2=myLanes->begin(); i2!=myLanes->end(); ++i2) {
00131         const std::vector<SUMOVehicleClass> &allowed = (*i2)->getAllowedClasses();
00132         for (std::vector<SUMOVehicleClass>::const_iterator j=allowed.begin(); j!=allowed.end(); j++) {
00133             vclasses.insert(*j);
00134         }
00135         const std::vector<SUMOVehicleClass> &disallowed = (*i2)->getNotAllowedClasses();
00136         for (std::vector<SUMOVehicleClass>::const_iterator j=disallowed.begin(); j!=disallowed.end(); j++) {
00137             vclasses.insert(*j);
00138         }
00139     }
00140     // go through these classes
00141     for (std::set<SUMOVehicleClass>::const_iterator j=vclasses.begin(); j!=vclasses.end(); ++j) {
00142         // go through connected edges
00143         for (AllowedLanesCont::iterator i1=myAllowed.begin(); i1!=myAllowed.end(); ++i1) {
00144             delete myClassedAllowed[*j][(*i1).first];
00145             myClassedAllowed[*j][(*i1).first] = new std::vector<MSLane*>();
00146             // go through lanes approaching current edge
00147             for (std::vector<MSLane*>::iterator i2=(*i1).second->begin(); i2!=(*i1).second->end(); ++i2) {
00148                 // allows the current vehicle class?
00149                 if ((*i2)->allowsVehicleClass(*j)) {
00150                     // -> may be used
00151                     myClassedAllowed[*j][(*i1).first]->push_back(*i2);
00152                 }
00153             }
00154             // assert that 0 is returned if no connection is allowed for a class
00155             if (myClassedAllowed[*j][(*i1).first]->size()==0) {
00156                 delete myClassedAllowed[*j][(*i1).first];
00157                 myClassedAllowed[*j][(*i1).first] = 0;
00158             }
00159         }
00160         myHaveClassConstraints = true;
00161     }
00162 }

MSLane *const MSEdge::rightLane ( const MSLane *const   lane  )  const throw ()

Returns the lane right to the one given, 0 if the given lane is rightmost.

Parameters:
[in] lane The lane left to the one to be returned
Returns:
The lane right to the given, 0 if no such lane exists
Todo:
This method searches for the given in the container; probably, this could be done faster

Definition at line 177 of file MSEdge.cpp.

References myLanes.

Referenced by traci::TraCIServer::commandStopNode(), and MSLane::getRightLane().

00177                                                          {
00178     std::vector<MSLane*>::iterator laneIt = find(myLanes->begin(), myLanes->end(), lane);
00179     if (laneIt==myLanes->end()||laneIt==myLanes->begin()) {
00180         return 0;
00181     }
00182     return *(laneIt-1);
00183 }

void MSEdge::setLastFailedEmissionTime ( SUMOTime  time  )  const throw () [inline]

Sets the last time a vehicle could not be inserted.

Parameters:
[in] time the new value

Definition at line 349 of file MSEdge.h.

References myLastFailedEmissionTime.

Referenced by MSEmitControl::tryEmit().

00349                                                                        {
00350         myLastFailedEmissionTime = time;
00351     }


Field Documentation

Associative container from destination-edge to allowed-lanes.

Definition at line 484 of file MSEdge.h.

Referenced by allowedLanes(), closeBuilding(), rebuildAllowedLanes(), and ~MSEdge().

From vehicle class to lanes allowed to be used by it.

Definition at line 487 of file MSEdge.h.

Referenced by allowedLanes(), rebuildAllowedLanes(), and ~MSEdge().

Lane from which vehicles will depart, usually the rightmost.

Definition at line 458 of file MSEdge.h.

Referenced by getDepartLane(), and initialize().

MSEdge::DictType MSEdge::myDict [static, protected]

Static dictionary to associate string-ids with objects.

Deprecated:
Move to MSEdgeControl, make non-static

Definition at line 504 of file MSEdge.h.

Referenced by clear(), dictionary(), dictSize(), GUIEdge::fill(), GUIEdge::getIDs(), and insertIDs().

std::vector< MSEdge * > MSEdge::myEdges [static, protected]

Static list of edges.

Deprecated:
Move to MSEdgeControl, make non-static

Definition at line 509 of file MSEdge.h.

Referenced by dictionary().

the purpose of the edge

Definition at line 464 of file MSEdge.h.

Referenced by changeLanes(), GUIEdge::drawGL(), getPurpose(), initialize(), and prohibits().

Whether any class constraints exist for this edge.

Definition at line 490 of file MSEdge.h.

Referenced by allowedLanes(), prohibits(), and rebuildAllowedLanes().

std::string MSEdge::myID [protected]

Unique ID.

Definition at line 449 of file MSEdge.h.

Referenced by getID().

This member will do the lane-change.

Definition at line 461 of file MSEdge.h.

Referenced by changeLanes(), initialize(), and ~MSEdge().

std::vector<MSLane*>* MSEdge::myLanes [protected]

Container for the edge's lane; should be sorted: (right-hand-traffic) the more left the lane, the higher the container-index.

Definition at line 455 of file MSEdge.h.

Referenced by closeBuilding(), getCurrentTravelTime(), getDepartLane(), getLanes(), GUIEdge::getParameterWindow(), GUIEdge::initGeometry(), initialize(), leftLane(), prohibits(), rebuildAllowedLanes(), rightLane(), and ~MSEdge().

The time of last emission failure.

Definition at line 470 of file MSEdge.h.

Referenced by getLastFailedEmissionTime(), and setLastFailedEmissionTime().

unsigned int MSEdge::myNumericalID [protected]

This edge's numerical id.

Definition at line 452 of file MSEdge.h.

Referenced by getNumericalID().

std::vector<MSEdge*> MSEdge::myPredeccesors [protected]

The preceeding edges.

Definition at line 476 of file MSEdge.h.

Referenced by closeBuilding(), and getIncomingEdges().

std::vector<MSEdge*> MSEdge::mySuccessors [protected]

The succeeding edges.

Definition at line 473 of file MSEdge.h.

Referenced by addFollower(), closeBuilding(), getFollower(), and getNoFollowing().

Vaporizer counter.

Definition at line 467 of file MSEdge.h.

Referenced by decVaporization(), incVaporization(), and isVaporizing().


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:47 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6