NLDetectorBuilder Class Reference

#include <NLDetectorBuilder.h>

Inheritance diagram for NLDetectorBuilder:

GUIDetectorBuilder

Detailed Description

Builds detectors for microsim.

The building methods may be overridden, to build guisim-instances of the triggers, for example.

Definition at line 69 of file NLDetectorBuilder.h.


Public Member Functions

MS_E2_ZS_CollectorOverLanesbuildMultiLaneE2Det (const std::string &id, DetectorUsage usage, MSLane *lane, SUMOReal pos, SUMOReal length, SUMOTime haltingTimeThreshold, MetersPerSecond haltingSpeedThreshold, SUMOReal jamDistThreshold) throw ()
 Builds an e2-detector that continues on preceeding lanes.
MSE2CollectorbuildSingleLaneE2Det (const std::string &id, DetectorUsage usage, MSLane *lane, SUMOReal pos, SUMOReal length, SUMOTime haltingTimeThreshold, MetersPerSecond haltingSpeedThreshold, SUMOReal jamDistThreshold) throw ()
 Builds an e2-detector that lies on only one lane.
 NLDetectorBuilder (MSNet &net) throw ()
 Constructor.
virtual ~NLDetectorBuilder () throw ()
 Destructor.
Value parsing and detector building methods
void addE3Entry (const std::string &lane, SUMOReal pos, bool friendlyPos) throw (InvalidArgument)
 Builds an entry point of an e3 detector.
void addE3Exit (const std::string &lane, SUMOReal pos, bool friendlyPos) throw (InvalidArgument)
 Builds an exit point of an e3 detector.
void beginE3Detector (const std::string &id, OutputDevice &device, int splInterval, MetersPerSecond haltingSpeedThreshold, SUMOTime haltingTimeThreshold) throw (InvalidArgument)
 Stores temporary the initial information about an e3-detector to build.
void buildE2Detector (const std::string &id, const std::string &lane, SUMOReal pos, SUMOReal length, bool cont, MSTLLogicControl::TLSLogicVariants &tlls, const std::string &tolane, OutputDevice &device, SUMOTime haltingTimeThreshold, MetersPerSecond haltingSpeedThreshold, SUMOReal jamDistThreshold, bool friendlyPos) throw (InvalidArgument)
 Builds an e2-detector connected to a link's state.
void buildE2Detector (const std::string &id, const std::string &lane, SUMOReal pos, SUMOReal length, bool cont, MSTLLogicControl::TLSLogicVariants &tlls, OutputDevice &device, SUMOTime haltingTimeThreshold, MetersPerSecond haltingSpeedThreshold, SUMOReal jamDistThreshold, bool friendlyPos) throw (InvalidArgument)
 Builds an e2-detector connected to a lsa.
void buildE2Detector (const std::string &id, const std::string &lane, SUMOReal pos, SUMOReal length, bool cont, int splInterval, OutputDevice &device, SUMOTime haltingTimeThreshold, MetersPerSecond haltingSpeedThreshold, SUMOReal jamDistThreshold, bool friendlyPos) throw (InvalidArgument)
 Builds an e2-detector with a fixed interval and adds it to the net.
void buildInductLoop (const std::string &id, const std::string &lane, SUMOReal pos, int splInterval, OutputDevice &device, bool friendlyPos) throw (InvalidArgument)
 Builds an e1-detector and adds it to the net.
void buildRouteProbe (const std::string &id, const std::string &edge, SUMOTime frequency, SUMOTime begin, OutputDevice &device) throw (InvalidArgument)
 Builds a routeprobe and adds it to the net.
void buildVTypeProbe (const std::string &id, const std::string &vtype, SUMOTime frequency, OutputDevice &device) throw (InvalidArgument)
 Builds a vtypeprobe and adds it to the net.
void endE3Detector () throw (InvalidArgument)
 Builds of an e3-detector using collected values.
std::string getCurrentE3ID () const throw ()
 Returns the id of the currently built e3-detector.
Detector creating methods
Virtual, so they may be overwritten, for generating gui-versions of the detectors, for example.

virtual MSE3CollectorcreateE3Detector (const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, MetersPerSecond haltingSpeedThreshold, SUMOTime haltingTimeThreshold) throw ()
 Creates an instance of an e3-detector using the given values.
void createEdgeLaneMeanData (const std::string &id, SUMOTime frequency, SUMOTime begin, SUMOTime end, const std::string &type, const bool useLanes, const bool withEmpty, const bool withInternal, const bool trackVehicles, const SUMOReal maxTravelTime, const SUMOReal minSamples, const SUMOReal haltSpeed, const std::string &vTypes, OutputDevice &device) throw (InvalidArgument)
 Creates edge based mean data collector using the given specification.
virtual MSInductLoopcreateInductLoop (const std::string &id, MSLane *lane, SUMOReal pos) throw ()
 Creates an instance of an e1-detector using the given values.
virtual
MS_E2_ZS_CollectorOverLanes
createMultiLaneE2Detector (const std::string &id, DetectorUsage usage, MSLane *lane, SUMOReal pos, SUMOTime haltingTimeThreshold, MetersPerSecond haltingSpeedThreshold, SUMOReal jamDistThreshold) throw ()
 Creates an instance of an e2ol-detector using the given values.
virtual MSE2CollectorcreateSingleLaneE2Detector (const std::string &id, DetectorUsage usage, MSLane *lane, SUMOReal pos, SUMOReal length, SUMOTime haltingTimeThreshold, MetersPerSecond haltingSpeedThreshold, SUMOReal jamDistThreshold) throw ()
 Creates an instance of an e2-detector using the given values.

Protected Member Functions

void convContE2PosLength (const std::string &id, MSLane *clane, SUMOReal &pos, SUMOReal &length, bool frinedly_pos) throw (InvalidArgument)
 Converts the length and the position information for an e2ol-detector.
void convUncontE2PosLength (const std::string &id, MSLane *clane, SUMOReal &pos, SUMOReal &length, bool frinedly_pos) throw (InvalidArgument)
 Converts the length and the position information for an e2-detector.
MSLanegetLaneChecking (const std::string &id, const std::string &detid) throw (InvalidArgument)
 Returns the named lane;.
SUMOReal getPositionChecking (SUMOReal pos, MSLane *lane, bool friendlyPos, const std::string &detid) throw (InvalidArgument)
 Computes the position to use.

Protected Attributes

MSNetmyNet
 The net to fill.

Private Member Functions

 NLDetectorBuilder (const NLDetectorBuilder &)
 Invalidated copy constructor.
NLDetectorBuilderoperator= (const NLDetectorBuilder &)
 Invalidated assignment operator.

Private Attributes

E3DetectorDefinitionmyE3Definition
 definition of the currently parsed e3-detector

Data Structures

class  E3DetectorDefinition
 Holds the incoming definitions of an e3 detector unless the detector is build. More...

Constructor & Destructor Documentation

NLDetectorBuilder::NLDetectorBuilder ( MSNet net  )  throw ()

Constructor.

Parameters:
[in] net The network to which's detector control built detector shall be added

Definition at line 113 of file NLDetectorBuilder.cpp.

00114         : myNet(net), myE3Definition(0) {}

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

Destructor.

Definition at line 117 of file NLDetectorBuilder.cpp.

00117 {}

NLDetectorBuilder::NLDetectorBuilder ( const NLDetectorBuilder  )  [private]

Invalidated copy constructor.


Member Function Documentation

void NLDetectorBuilder::addE3Entry ( const std::string &  lane,
SUMOReal  pos,
bool  friendlyPos 
) throw (InvalidArgument)

Builds an entry point of an e3 detector.

If the lane is not known or the position information is not within the lane, an InvalidArgument is thrown. Otherwise a MSCrossSection is built using the obtained values and added to the list of entries of the e3-definition stored in "myE3Definition".

Parameters:
[in] lane The id of the lane the entry shall be placed at
[in] pos The position on the lane the entry shall be placed at
[in] friendlyPos Whether the position information shall be used "friendly" (see user docs)
Exceptions:
InvalidArgument If one of the values is invalid

Definition at line 349 of file NLDetectorBuilder.cpp.

References getLaneChecking(), getPositionChecking(), myE3Definition, NLDetectorBuilder::E3DetectorDefinition::myEntries, and NLDetectorBuilder::E3DetectorDefinition::myID.

Referenced by NLHandler::addE3Entry().

00350                                                                                      {
00351     if (myE3Definition==0) {
00352         return;
00353     }
00354     MSLane *clane = getLaneChecking(lane, myE3Definition->myID);
00355     // get and check the position
00356     pos = getPositionChecking(pos, clane, friendlyPos, myE3Definition->myID);
00357     // build and save the entry
00358     myE3Definition->myEntries.push_back(MSCrossSection(clane, pos));
00359 }

void NLDetectorBuilder::addE3Exit ( const std::string &  lane,
SUMOReal  pos,
bool  friendlyPos 
) throw (InvalidArgument)

Builds an exit point of an e3 detector.

If the lane is not known or the position information is not within the lane, an InvalidArgument is thrown. Otherwise a MSCrossSection is built using the obtained values and added to the list of exits of the e3-definition stored in "myE3Definition".

Parameters:
[in] lane The id of the lane the exit shall be placed at
[in] pos The position on the lane the exit shall be placed at
[in] friendlyPos Whether the position information shall be used "friendly" (see user docs)
Exceptions:
InvalidArgument If one of the values is invalid

Definition at line 363 of file NLDetectorBuilder.cpp.

References getLaneChecking(), getPositionChecking(), myE3Definition, NLDetectorBuilder::E3DetectorDefinition::myExits, and NLDetectorBuilder::E3DetectorDefinition::myID.

Referenced by NLHandler::addE3Exit().

00364                                                                                     {
00365     if (myE3Definition==0) {
00366         return;
00367     }
00368     MSLane *clane = getLaneChecking(lane, myE3Definition->myID);
00369     // get and check the position
00370     pos = getPositionChecking(pos, clane, friendlyPos, myE3Definition->myID);
00371     // build and save the exit
00372     myE3Definition->myExits.push_back(MSCrossSection(clane, pos));
00373 }

void NLDetectorBuilder::beginE3Detector ( const std::string &  id,
OutputDevice device,
int  splInterval,
MetersPerSecond  haltingSpeedThreshold,
SUMOTime  haltingTimeThreshold 
) throw (InvalidArgument)

Stores temporary the initial information about an e3-detector to build.

If the given sample interval is < 0, an InvalidArgument is thrown. Otherwise, the values are stored in a new instance of E3DetectorDefinition within "myE3Definition".

Parameters:
[in] id The id the detector shall have
[in] device The output device the detector shall write into
[in] splInterval The aggregation time span the detector shall use
[in] haltingTimeThreshold Detector parameter: the time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed
[in] haltingSpeedThreshold Detector parameter: the speed a vehicle's speed must be below to be assigned as jammed
Exceptions:
InvalidArgument If one of the values is invalid

Definition at line 332 of file NLDetectorBuilder.cpp.

References myE3Definition.

Referenced by NLHandler::beginE3Detector().

00335                                                                                          {
00336     if (splInterval<0) {
00337         throw InvalidArgument("Negative sampling frequency (in e3-detector '" + id + "').");
00338     }
00339     if (splInterval==0) {
00340         throw InvalidArgument("Sampling frequency must not be zero (in e3-detector '" + id + "').");
00341     }
00342     myE3Definition = new E3DetectorDefinition(id, device,
00343             haltingSpeedThreshold, haltingTimeThreshold,
00344             splInterval);
00345 }

void NLDetectorBuilder::buildE2Detector ( const std::string &  id,
const std::string &  lane,
SUMOReal  pos,
SUMOReal  length,
bool  cont,
MSTLLogicControl::TLSLogicVariants tlls,
const std::string &  tolane,
OutputDevice device,
SUMOTime  haltingTimeThreshold,
MetersPerSecond  haltingSpeedThreshold,
SUMOReal  jamDistThreshold,
bool  friendlyPos 
) throw (InvalidArgument)

Builds an e2-detector connected to a link's state.

Checks the given values, first. If one of the values is invalid (lane is not known, position is larger than lane's length, length is too large, the tls or the destination lane is not known, the id is already in use), an InvalidArgument is thrown.

Otherwise the e2-detector is built, either by calling "buildMultiLaneE2Det" if the detector shall continue on consecutive lanes, or by calling "buildSingleLaneE2Det" if it is a one-lane detector.

Parameters:
[in] id The id the detector shall have
[in] lane The name of the lane the detector is placed at
[in] pos The definition of the position on the lane the detector shall be placed at
[in] length The definition of the length the detector shall have
[in] cont Whether the detector shall continue on predeceeding lanes
[in] tlls The tls the detector is assigned to
[in] tolane The name of the lane to which the link to which the detector to build shall be assigned to points
[in] device The output device the detector shall write into
[in] haltingTimeThreshold Detector parameter: the time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed
[in] haltingSpeedThreshold Detector parameter: the speed a vehicle's speed must be below to be assigned as jammed
[in] jamDistThreshold Detector parameter: the distance between two vehicles in order to not count them to one jam
[in] friendlyPos Whether the position information shall be used "friendly" (see user docs)
Exceptions:
InvalidArgument If one of the values is invalid

Definition at line 249 of file NLDetectorBuilder.cpp.

References MSDetectorControl::add(), buildMultiLaneE2Det(), buildSingleLaneE2Det(), convContE2PosLength(), convUncontE2PosLength(), DU_USER_DEFINED, MSLinkContHelper::getConnectingLink(), MSNet::getCurrentTimeStep(), MSNet::getDetectorControl(), getLaneChecking(), and myNet.

00257                                                                                                        {
00258     if (tlls.getActive()==0) {
00259         throw InvalidArgument("The detector '" + id + "' refers to the unknown lsa.");
00260     }
00261     MSLane *clane = getLaneChecking(lane, id);
00262     MSLane *ctoLane = getLaneChecking(tolane, id);
00263     MSLink *link = MSLinkContHelper::getConnectingLink(*clane, *ctoLane);
00264     if (link==0) {
00265         throw InvalidArgument(
00266             "The detector output can not be build as no connection between lanes '"
00267             + lane + "' and '" + tolane + "' exists.");
00268     }
00269     if (pos<0) {
00270         pos = -pos;
00271     }
00272     // check whether the detector may lie over more than one lane
00273     MSDetectorFileOutput *det = 0;
00274     if (!cont) {
00275         convUncontE2PosLength(id, clane, pos, length, friendlyPos);
00276         det = buildSingleLaneE2Det(id, DU_USER_DEFINED,
00277                                    clane, pos, length,
00278                                    haltingTimeThreshold, haltingSpeedThreshold,
00279                                    jamDistThreshold);
00280         myNet.getDetectorControl().add(static_cast<MSE2Collector*>(det));
00281     } else {
00282         convContE2PosLength(id, clane, pos, length, friendlyPos);
00283         det = buildMultiLaneE2Det(id, DU_USER_DEFINED,
00284                                   clane, pos, length,
00285                                   haltingTimeThreshold, haltingSpeedThreshold,
00286                                   jamDistThreshold);
00287         myNet.getDetectorControl().add(static_cast<MS_E2_ZS_CollectorOverLanes*>(det));
00288     }
00289     // add the file output
00290     new Command_SaveTLCoupledLaneDet(tlls, det, myNet.getCurrentTimeStep(), device, link);
00291 }

void NLDetectorBuilder::buildE2Detector ( const std::string &  id,
const std::string &  lane,
SUMOReal  pos,
SUMOReal  length,
bool  cont,
MSTLLogicControl::TLSLogicVariants tlls,
OutputDevice device,
SUMOTime  haltingTimeThreshold,
MetersPerSecond  haltingSpeedThreshold,
SUMOReal  jamDistThreshold,
bool  friendlyPos 
) throw (InvalidArgument)

Builds an e2-detector connected to a lsa.

Checks the given values, first. If one of the values is invalid (lane is not known, position is larger than lane's length, length is too large, the tls is not known, the id is already in use), an InvalidArgument is thrown.

Otherwise the e2-detector is built, either by calling "buildMultiLaneE2Det" if the detector shall continue on consecutive lanes, or by calling "buildSingleLaneE2Det" if it is a one-lane detector.

Parameters:
[in] id The id the detector shall have
[in] lane The name of the lane the detector is placed at
[in] pos The definition of the position on the lane the detector shall be placed at
[in] length The definition of the length the detector shall have
[in] cont Whether the detector shall continue on predeceeding lanes
[in] tlls The tls the detector is assigned to
[in] device The output device the detector shall write into
[in] haltingTimeThreshold Detector parameter: the time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed
[in] haltingSpeedThreshold Detector parameter: the speed a vehicle's speed must be below to be assigned as jammed
[in] jamDistThreshold Detector parameter: the distance between two vehicles in order to not count them to one jam
[in] friendlyPos Whether the position information shall be used "friendly" (see user docs)
Exceptions:
InvalidArgument If one of the values is invalid

Definition at line 211 of file NLDetectorBuilder.cpp.

References MSDetectorControl::add(), buildMultiLaneE2Det(), buildSingleLaneE2Det(), convContE2PosLength(), convUncontE2PosLength(), DU_USER_DEFINED, MSNet::getCurrentTimeStep(), MSNet::getDetectorControl(), getLaneChecking(), and myNet.

00218                                                                                                        {
00219     if (tlls.getActive()==0) {
00220         throw InvalidArgument("The detector '" + id + "' refers to the unknown lsa.");
00221     }
00222     MSLane *clane = getLaneChecking(lane, id);
00223     // check whether the detector may lie over more than one lane
00224     MSDetectorFileOutput *det = 0;
00225     if (!cont) {
00226         convUncontE2PosLength(id, clane, pos, length, friendlyPos);
00227         det = buildSingleLaneE2Det(id, DU_USER_DEFINED,
00228                                    clane, pos, length,
00229                                    haltingTimeThreshold, haltingSpeedThreshold,
00230                                    jamDistThreshold);
00231         myNet.getDetectorControl().add(
00232             static_cast<MSE2Collector*>(det));
00233     } else {
00234         convContE2PosLength(id, clane, pos, length, friendlyPos);
00235         det = buildMultiLaneE2Det(id, DU_USER_DEFINED,
00236                                   clane, pos, length,
00237                                   haltingTimeThreshold, haltingSpeedThreshold,
00238                                   jamDistThreshold);
00239         myNet.getDetectorControl().add(
00240             static_cast<MS_E2_ZS_CollectorOverLanes*>(det));
00241     }
00242     // add the file output
00243     new Command_SaveTLCoupledDet(tlls, det,
00244                                  myNet.getCurrentTimeStep(), device);
00245 }

void NLDetectorBuilder::buildE2Detector ( const std::string &  id,
const std::string &  lane,
SUMOReal  pos,
SUMOReal  length,
bool  cont,
int  splInterval,
OutputDevice device,
SUMOTime  haltingTimeThreshold,
MetersPerSecond  haltingSpeedThreshold,
SUMOReal  jamDistThreshold,
bool  friendlyPos 
) throw (InvalidArgument)

Builds an e2-detector with a fixed interval and adds it to the net.

Checks the given values, first. If one of the values is invalid (lane is not known, sampling frequency<=0, position is larger than lane's length, length is too large, the id is already in use), an InvalidArgument is thrown.

Otherwise the e2-detector is built, either by calling "buildMultiLaneE2Det" if the detector shall continue on consecutive lanes, or by calling "buildSingleLaneE2Det" if it is a one-lane detector.

Parameters:
[in] id The id the detector shall have
[in] lane The name of the lane the detector is placed at
[in] pos The definition of the position on the lane the detector shall be placed at
[in] length The definition of the length the detector shall have
[in] cont Whether the detector shall continue on predeceeding lanes
[in] splInterval The aggregation time span the detector shall use
[in] device The output device the detector shall write into
[in] haltingTimeThreshold Detector parameter: the time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed
[in] haltingSpeedThreshold Detector parameter: the speed a vehicle's speed must be below to be assigned as jammed
[in] jamDistThreshold Detector parameter: the distance between two vehicles in order to not count them to one jam
[in] friendlyPos Whether the position information shall be used "friendly" (see user docs)
Exceptions:
InvalidArgument If one of the values is invalid

Definition at line 174 of file NLDetectorBuilder.cpp.

References MSDetectorControl::add(), buildMultiLaneE2Det(), buildSingleLaneE2Det(), convContE2PosLength(), convUncontE2PosLength(), DU_USER_DEFINED, MSNet::getDetectorControl(), getLaneChecking(), and myNet.

Referenced by NLHandler::addE2Detector().

00180                                                                                                        {
00181     if (splInterval<0) {
00182         throw InvalidArgument("Negative sampling frequency (in e2-detector '" + id + "').");
00183     }
00184     if (splInterval==0) {
00185         throw InvalidArgument("Sampling frequency must not be zero (in e2-detector '" + id + "').");
00186     }
00187     MSLane *clane = getLaneChecking(lane, id);
00188     // check whether the detector may lie over more than one lane
00189     MSDetectorFileOutput *det = 0;
00190     if (!cont) {
00191         convUncontE2PosLength(id, clane, pos, length, friendlyPos);
00192         det = buildSingleLaneE2Det(id, DU_USER_DEFINED,
00193                                    clane, pos, length,
00194                                    haltingTimeThreshold, haltingSpeedThreshold,
00195                                    jamDistThreshold);
00196         myNet.getDetectorControl().add(
00197             static_cast<MSE2Collector*>(det), device, splInterval);
00198     } else {
00199         convContE2PosLength(id, clane, pos, length, friendlyPos);
00200         det = buildMultiLaneE2Det(id, DU_USER_DEFINED,
00201                                   clane, pos, length,
00202                                   haltingTimeThreshold, haltingSpeedThreshold,
00203                                   jamDistThreshold);
00204         myNet.getDetectorControl().add(
00205             static_cast<MS_E2_ZS_CollectorOverLanes*>(det), device, splInterval);
00206     }
00207 }

void NLDetectorBuilder::buildInductLoop ( const std::string &  id,
const std::string &  lane,
SUMOReal  pos,
int  splInterval,
OutputDevice device,
bool  friendlyPos 
) throw (InvalidArgument)

Builds an e1-detector and adds it to the net.

Checks the given values, first. If one of the values is invalid (lane is not known, sampling frequency<=0, position is larger than lane's length, the id is already in use), an InvalidArgument is thrown.

Otherwise the e1-detector is built by calling "createInductLoop".

Internally, there is also a distinction whether a mesosim e1-detector shall be built.

Parameters:
[in] id The id the detector shall have
[in] lane The name of the lane the detector is placed at
[in] pos The definition of the position on the lane the detector shall be placed at
[in] splInterval The aggregation time span the detector shall use
[in] device The output device the detector shall write into
[in] friendlyPos Whether the position information shall be used "friendly" (see user docs)
Exceptions:
InvalidArgument If one of the values is invalid

Definition at line 121 of file NLDetectorBuilder.cpp.

References MSDetectorControl::add(), createInductLoop(), MSNet::getDetectorControl(), MSLane::getEdge(), getLaneChecking(), MSLane::getLength(), getPositionChecking(), myNet, and SUMOReal.

Referenced by NLHandler::addE1Detector().

00123                                                                                                   {
00124     if (splInterval<0) {
00125         throw InvalidArgument("Negative sampling frequency (in e1-detector '" + id + "').");
00126     }
00127     if (splInterval==0) {
00128         throw InvalidArgument("Sampling frequency must not be zero (in e1-detector '" + id + "').");
00129     }
00130     // get and check the lane
00131     MSLane *clane = getLaneChecking(lane, id);
00132     if (pos<0) {
00133         pos = clane->getLength() + pos;
00134     }
00135 #ifdef HAVE_MESOSIM
00136     if (!MSGlobals::gUseMesoSim) {
00137 #endif
00138         // get and check the position
00139         pos = getPositionChecking(pos, clane, friendlyPos, id);
00140         // build the loop
00141         MSInductLoop *loop = createInductLoop(id, clane, pos);
00142         // add the file output
00143         myNet.getDetectorControl().add(loop, device, splInterval);
00144 #ifdef HAVE_MESOSIM
00145     } else {
00146         if (pos<0) {
00147             pos = clane->getLength() + pos;
00148         }
00149         MESegment *s = MSGlobals::gMesoNet->getSegmentForEdge(clane->getEdge());
00150         MESegment *prev = s;
00151         SUMOReal cpos = 0;
00152         while (cpos+prev->getLength()<pos&&s!=0) {
00153             prev = s;
00154             cpos += s->getLength();
00155             s = s->getNextSegment();
00156         }
00157         SUMOReal rpos = pos-cpos;//-prev->getLength();
00158         if (rpos>prev->getLength()||rpos<0) {
00159             if (friendlyPos) {
00160                 rpos = prev->getLength() - (SUMOReal) 0.1;
00161             } else {
00162                 throw InvalidArgument("The position of detector '" + id + "' lies beyond the lane's '" + lane + "' length.");
00163             }
00164         }
00165         MEInductLoop *loop =
00166             createMEInductLoop(id, prev, rpos);
00167         myNet.getDetectorControl().add(loop, device, splInterval);
00168     }
00169 #endif
00170 }

MS_E2_ZS_CollectorOverLanes * NLDetectorBuilder::buildMultiLaneE2Det ( const std::string &  id,
DetectorUsage  usage,
MSLane lane,
SUMOReal  pos,
SUMOReal  length,
SUMOTime  haltingTimeThreshold,
MetersPerSecond  haltingSpeedThreshold,
SUMOReal  jamDistThreshold 
) throw ()

Builds an e2-detector that continues on preceeding lanes.

Parameters:
[in] id The id the detector shall have
[in] usage Information how the detector is used within the simulation
[in] lane The lane the detector is placed at
[in] pos The position on the lane the detector is placed at
[in] length The length the detector has
[in] haltingTimeThreshold Detector parameter: the time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed
[in] haltingSpeedThreshold Detector parameter: the speed a vehicle's speed must be below to be assigned as jammed
[in] jamDistThreshold Detector parameter: the distance between two vehicles in order to not count them to one jam
Todo:
Check whether this method is really needful

Definition at line 448 of file NLDetectorBuilder.cpp.

References createMultiLaneE2Detector(), and MS_E2_ZS_CollectorOverLanes::init().

Referenced by buildE2Detector().

00452                                                                           {
00453     MS_E2_ZS_CollectorOverLanes *ret = createMultiLaneE2Detector(id, usage,
00454                                        lane, pos, haltingTimeThreshold, haltingSpeedThreshold,
00455                                        jamDistThreshold);
00456     ret->init(lane, length);
00457     return ret;
00458 }

void NLDetectorBuilder::buildRouteProbe ( const std::string &  id,
const std::string &  edge,
SUMOTime  frequency,
SUMOTime  begin,
OutputDevice device 
) throw (InvalidArgument)

Builds a routeprobe and adds it to the net.

Checks the given values, first. If one of the values is invalid (sampling frequency<=0), an InvalidArgument is thrown.

Otherwise the routeprobe is built (directly).

Parameters:
[in] id The id the detector shall have
[in] edge The name of the edge the detector shall observe
[in] frequency The reporting frequency
[in] begin The start of the first reporting interval
[in] device The output device the detector shall write into
Exceptions:
InvalidArgument If one of the values is invalid

Definition at line 417 of file NLDetectorBuilder.cpp.

References MSDetectorControl::add(), MSEdge::dictionary(), MSNet::getDetectorControl(), and myNet.

Referenced by NLHandler::addRouteProbeDetector().

00419                                                                                 {
00420     if (frequency<=0) {
00421         throw InvalidArgument("Frequency must be larger than zero (in routeprobe '" + id + "').");
00422     }
00423     MSEdge *e = MSEdge::dictionary(edge);
00424     if (e==0) {
00425         throw InvalidArgument("The edge with the id '" + edge + "' is not known (in routeprobe '" + id + "').");
00426     }
00427     MSRouteProbe *probe = new MSRouteProbe(id, e, begin);
00428     // add the file output
00429     myNet.getDetectorControl().add(probe, device, frequency, begin);
00430 }

MSE2Collector * NLDetectorBuilder::buildSingleLaneE2Det ( const std::string &  id,
DetectorUsage  usage,
MSLane lane,
SUMOReal  pos,
SUMOReal  length,
SUMOTime  haltingTimeThreshold,
MetersPerSecond  haltingSpeedThreshold,
SUMOReal  jamDistThreshold 
) throw ()

Builds an e2-detector that lies on only one lane.

Parameters:
[in] id The id the detector shall have
[in] usage Information how the detector is used within the simulation
[in] lane The lane the detector is placed at
[in] pos The position on the lane the detector is placed at
[in] length The length the detector has
[in] haltingTimeThreshold Detector parameter: the time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed
[in] haltingSpeedThreshold Detector parameter: the speed a vehicle's speed must be below to be assigned as jammed
[in] jamDistThreshold Detector parameter: the distance between two vehicles in order to not count them to one jam
Todo:
Check whether this method is really needful

Definition at line 435 of file NLDetectorBuilder.cpp.

References createSingleLaneE2Detector().

Referenced by buildE2Detector().

00440                                                                            {
00441     return createSingleLaneE2Detector(id, usage, lane, pos,
00442                                       length, haltingTimeThreshold, haltingSpeedThreshold,
00443                                       jamDistThreshold);
00444 }

void NLDetectorBuilder::buildVTypeProbe ( const std::string &  id,
const std::string &  vtype,
SUMOTime  frequency,
OutputDevice device 
) throw (InvalidArgument)

Builds a vtypeprobe and adds it to the net.

Checks the given values, first. If one of the values is invalid (sampling frequency<=0), an InvalidArgument is thrown.

Otherwise the vtypeprobe is built (directly).

Parameters:
[in] id The id the detector shall have
[in] vtype The name of the vehicle type the detector shall observe
[in] frequency The reporting frequency
[in] device The output device the detector shall write into
Exceptions:
InvalidArgument If one of the values is invalid

Definition at line 403 of file NLDetectorBuilder.cpp.

Referenced by NLHandler::addVTypeProbeDetector().

00405                                                                                 {
00406     if (frequency<0) {
00407         throw InvalidArgument("Negative frequency (in vtypeprobe '" + id + "').");
00408     }
00409     if (frequency==0) {
00410         throw InvalidArgument("Frequency must not be zero (in vtypeprobe '" + id + "').");
00411     }
00412     new MSVTypeProbe(id, vtype, device, frequency);
00413 }

void NLDetectorBuilder::convContE2PosLength ( const std::string &  id,
MSLane clane,
SUMOReal &  pos,
SUMOReal &  length,
bool  frinedly_pos 
) throw (InvalidArgument) [protected]

Converts the length and the position information for an e2ol-detector.

Parameters:
[in] id The id of the currently built detector (for error message generation)
[in] clane The lane the detector is placed at
[in,out] pos The position definition to convert
[in,out] length The length definition to convert
Exceptions:
InvalidArgument If the defined position or the defined length is invalid

Definition at line 322 of file NLDetectorBuilder.cpp.

References getPositionChecking().

Referenced by buildE2Detector().

00324                                                                                 {
00325     // get and check the position
00326     pos = getPositionChecking(pos, clane, friendlyPos, id);
00327     // length will be kept as is
00328 }

void NLDetectorBuilder::convUncontE2PosLength ( const std::string &  id,
MSLane clane,
SUMOReal &  pos,
SUMOReal &  length,
bool  frinedly_pos 
) throw (InvalidArgument) [protected]

Converts the length and the position information for an e2-detector.

Parameters:
[in] id The id of the currently built detector (for error message generation)
[in] clane The lane the detector is placed at
[in,out] pos The position definition to convert
[in,out] length The length definition to convert
Exceptions:
InvalidArgument If the defined position or the defined length is invalid

Definition at line 295 of file NLDetectorBuilder.cpp.

References MSLane::getID(), MSLane::getLength(), getPositionChecking(), and SUMOReal.

Referenced by buildE2Detector().

00297                                                  {
00298     // get and check the position
00299     pos = getPositionChecking(pos, clane, friendlyPos, id);
00300     // check length
00301     if (length<0) {
00302         length = clane->getLength() + length;
00303     }
00304     if (length+pos>clane->getLength()) {
00305         if (friendlyPos) {
00306             length = clane->getLength() - pos - (SUMOReal) 0.1;
00307         } else {
00308             throw InvalidArgument("The length of detector '" + id + "' lies beyond the lane's '" + clane->getID() + "' length.");
00309         }
00310     }
00311     if (length<0) {
00312         if (friendlyPos) {
00313             length = (SUMOReal) 0.1;
00314         } else {
00315             throw InvalidArgument("The length of detector '" + id + "' is almost 0.");
00316         }
00317     }
00318 }

MSE3Collector * NLDetectorBuilder::createE3Detector ( const std::string &  id,
const CrossSectionVector entries,
const CrossSectionVector exits,
MetersPerSecond  haltingSpeedThreshold,
SUMOTime  haltingTimeThreshold 
) throw () [virtual]

Creates an instance of an e3-detector using the given values.

Simply calls the MSE3Collector constructor.

Parameters:
[in] id The id the detector shall have
[in] entries The list of this detector's entries
[in] exits The list of this detector's exits
[in] haltingSpeedThreshold Detector parameter: the speed a vehicle's speed must be below to be assigned as jammed
[in] haltingTimeThreshold Detector parameter: the time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed

Reimplemented in GUIDetectorBuilder.

Definition at line 511 of file NLDetectorBuilder.cpp.

Referenced by endE3Detector().

00515                                                                            {
00516     return new MSE3Collector(id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold);
00517 }

void NLDetectorBuilder::createEdgeLaneMeanData ( const std::string &  id,
SUMOTime  frequency,
SUMOTime  begin,
SUMOTime  end,
const std::string &  type,
const bool  useLanes,
const bool  withEmpty,
const bool  withInternal,
const bool  trackVehicles,
const SUMOReal  maxTravelTime,
const SUMOReal  minSamples,
const SUMOReal  haltSpeed,
const std::string &  vTypes,
OutputDevice device 
) throw (InvalidArgument)

Creates edge based mean data collector using the given specification.

Parameters:
[in] id The id the detector shall have
[in] frequency The aggregation interval the detector shall use
[in] begin dump begin time
[in] end dump end time
[in] type The type of values to be generated
[in] useLanes Information whether lane-based or edge-based dump shall be generated
[in] withEmpty Information whether empty lanes/edges shall be written
[in] withInternal Information whether internal lanes/edges shall be written
[in] trackVehicles Information whether information shall be collected per vehicle
[in] maxTravelTime the maximum travel time to output
[in] minSamples the minimum number of sample seconds before the values are valid
[in] haltSpeed the maximum speed to consider a vehicle waiting
[in] vTypes the set of vehicle types to consider
Exceptions:
InvalidArgument If one of the values is invalid

Definition at line 559 of file NLDetectorBuilder.cpp.

References MSDetectorControl::addDetectorAndInterval(), MSNet::getDetectorControl(), MSNet::getInstance(), StringTokenizer::hasNext(), MSMeanData::init(), StringTokenizer::next(), and SUMOTime_MAX.

Referenced by NLHandler::addEdgeLaneMeanData().

00564                                                      {
00565     if (begin < 0) {
00566         throw InvalidArgument("Negative begin time for meandata dump '" + id + "'.");
00567     }
00568     if (end < 0) {
00569         end = SUMOTime_MAX;
00570     }
00571     if (end <= begin) {
00572         throw InvalidArgument("End before or at begin for meandata dump '" + id + "'.");
00573     }
00574     std::set<std::string> vt;
00575     StringTokenizer st(vTypes);
00576     while (st.hasNext()) {
00577         vt.insert(st.next());
00578     }
00579     MSMeanData *det = 0;
00580     if (type==""||type=="performance"||type=="traffic") {
00581         det = new MSMeanData_Net(id, begin, end, useLanes, withEmpty, trackVehicles,
00582                                  maxTravelTime, minSamples, haltSpeed, vt);
00583     } else if (type=="hbefa") {
00584         det = new MSMeanData_HBEFA(id, begin, end, useLanes, withEmpty, trackVehicles,
00585                                    maxTravelTime, minSamples, vt);
00586     } else if (type=="harmonoise") {
00587         det = new MSMeanData_Harmonoise(id, begin, end, useLanes, withEmpty, trackVehicles,
00588                                         maxTravelTime, minSamples, vt);
00589     } else {
00590         throw InvalidArgument("Invalid type '" + type + "' for meandata dump '" + id + "'.");
00591     }
00592     if (det!=0) {
00593         det->init(MSNet::getInstance()->getEdgeControl().getEdges(), withInternal);
00594         if (frequency < 0) {
00595             frequency = end - begin;
00596         }
00597         MSNet::getInstance()->getDetectorControl().addDetectorAndInterval(det, &device, frequency);
00598     }
00599 }

MSInductLoop * NLDetectorBuilder::createInductLoop ( const std::string &  id,
MSLane lane,
SUMOReal  pos 
) throw () [virtual]

Creates an instance of an e1-detector using the given values.

Simply calls the MSInductLoop constructor

Parameters:
[in] id The id the detector shall have
[in] lane The lane the detector is placed at
[in] pos The position on the lane the detector is placed at

Reimplemented in GUIDetectorBuilder.

Definition at line 470 of file NLDetectorBuilder.cpp.

Referenced by buildInductLoop(), MSUnboundActuatedTrafficLightLogic::init(), and MSCalibrator::MSCalibrator().

00471                                                                         {
00472     return new MSInductLoop(id, lane, pos);
00473 }

MS_E2_ZS_CollectorOverLanes * NLDetectorBuilder::createMultiLaneE2Detector ( const std::string &  id,
DetectorUsage  usage,
MSLane lane,
SUMOReal  pos,
SUMOTime  haltingTimeThreshold,
MetersPerSecond  haltingSpeedThreshold,
SUMOReal  jamDistThreshold 
) throw () [virtual]

Creates an instance of an e2ol-detector using the given values.

Simply calls the MS_E2_ZS_CollectorOverLanes constructor. After this call, the detector must be initialised.

Parameters:
[in] id The id the detector shall have
[in] lane The lane the detector is placed at
[in] pos The position on the lane the detector is placed at
[in] length The length the detector has
[in] haltingTimeThreshold Detector parameter: the time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed
[in] haltingSpeedThreshold Detector parameter: the speed a vehicle's speed must be below to be assigned as jammed
[in] jamDistThreshold Detector parameter: the distance between two vehicles in order to not count them to one jam

Reimplemented in GUIDetectorBuilder.

Definition at line 499 of file NLDetectorBuilder.cpp.

Referenced by buildMultiLaneE2Det().

00503                                            {
00504     return new MS_E2_ZS_CollectorOverLanes(id, usage, lane, pos,
00505                                            haltingTimeThreshold, haltingSpeedThreshold,
00506                                            jamDistThreshold);
00507 }

MSE2Collector * NLDetectorBuilder::createSingleLaneE2Detector ( const std::string &  id,
DetectorUsage  usage,
MSLane lane,
SUMOReal  pos,
SUMOReal  length,
SUMOTime  haltingTimeThreshold,
MetersPerSecond  haltingSpeedThreshold,
SUMOReal  jamDistThreshold 
) throw () [virtual]

Creates an instance of an e2-detector using the given values.

Simply calls the MSE2Collector constructor

Parameters:
[in] id The id the detector shall have
[in] lane The lane the detector is placed at
[in] pos The position on the lane the detector is placed at
[in] length The length the detector has
[in] haltingTimeThreshold Detector parameter: the time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed
[in] haltingSpeedThreshold Detector parameter: the speed a vehicle's speed must be below to be assigned as jammed
[in] jamDistThreshold Detector parameter: the distance between two vehicles in order to not count them to one jam

Reimplemented in GUIDetectorBuilder.

Definition at line 486 of file NLDetectorBuilder.cpp.

Referenced by buildSingleLaneE2Det().

00490                                            {
00491     return new MSE2Collector(id, usage, lane, pos, length,
00492                              haltingTimeThreshold, haltingSpeedThreshold,
00493                              jamDistThreshold);
00494 
00495 }

void NLDetectorBuilder::endE3Detector (  )  throw (InvalidArgument)

Builds of an e3-detector using collected values.

The parameter collected are used to build an e3-detector using "createE3Detector". The resulting detector is added to the net.

Parameters:
[in] lane The id of the lane the exit shall be placed at
[in] pos The position on the lane the exit shall be placed at
Exceptions:
InvalidArgument If one of the values is invalid

Definition at line 386 of file NLDetectorBuilder.cpp.

References MSDetectorControl::add(), createE3Detector(), MSNet::getDetectorControl(), NLDetectorBuilder::E3DetectorDefinition::myDevice, myE3Definition, NLDetectorBuilder::E3DetectorDefinition::myEntries, NLDetectorBuilder::E3DetectorDefinition::myExits, NLDetectorBuilder::E3DetectorDefinition::myHaltingSpeedThreshold, NLDetectorBuilder::E3DetectorDefinition::myHaltingTimeThreshold, NLDetectorBuilder::E3DetectorDefinition::myID, myNet, and NLDetectorBuilder::E3DetectorDefinition::mySampleInterval.

Referenced by NLHandler::endE3Detector().

00386                                                         {
00387     if (myE3Definition==0) {
00388         return;
00389     }
00390     MSE3Collector *det = createE3Detector(myE3Definition->myID,
00391                                           myE3Definition->myEntries, myE3Definition->myExits,
00392                                           myE3Definition->myHaltingSpeedThreshold, myE3Definition->myHaltingTimeThreshold);
00393     // add to net
00394     myNet.getDetectorControl().add(
00395         static_cast<MSE3Collector*>(det), myE3Definition->myDevice, myE3Definition->mySampleInterval);
00396     // clean up
00397     delete myE3Definition;
00398     myE3Definition = 0;
00399 }

std::string NLDetectorBuilder::getCurrentE3ID (  )  const throw ()

Returns the id of the currently built e3-detector.

This is used for error-message generation only. If no id is known, "<unknown>" is returned.

Returns:
The id of the currently processed e3-detector

Definition at line 377 of file NLDetectorBuilder.cpp.

References myE3Definition, and NLDetectorBuilder::E3DetectorDefinition::myID.

Referenced by NLHandler::addE3Entry(), and NLHandler::addE3Exit().

00377                                                 {
00378     if (myE3Definition==0) {
00379         return "<unknown>";
00380     }
00381     return myE3Definition->myID;
00382 }

MSLane * NLDetectorBuilder::getLaneChecking ( const std::string &  id,
const std::string &  detid 
) throw (InvalidArgument) [protected]

Returns the named lane;.

Throws an InvalidArgument if the lane does not exist

Parameters:
[in] id The id of the lane
[in] detid The id of the currently built detector (for error message generation)
Exceptions:
InvalidArgument If the named lane is not known

Definition at line 521 of file NLDetectorBuilder.cpp.

References MSLane::dictionary().

Referenced by addE3Entry(), addE3Exit(), buildE2Detector(), and buildInductLoop().

00522                                                                                   {
00523     // get and check the lane
00524     MSLane *clane = MSLane::dictionary(id);
00525     if (clane==0) {
00526         throw InvalidArgument("The lane with the id '" + id + "' is not known (while building detector '" + detid + "').");
00527     }
00528     return clane;
00529 }

SUMOReal NLDetectorBuilder::getPositionChecking ( SUMOReal  pos,
MSLane lane,
bool  friendlyPos,
const std::string &  detid 
) throw (InvalidArgument) [protected]

Computes the position to use.

At first, it is checked whether the given position is negative. If so, the position is added to the lane's length to obtain the position counted backwards.

If the resulting position is beyond or in front (<0) of the lane, it is either set to the according lane's boundary (.1 or length-.1) if friendlyPos is set, or, if friendly_pos is not set, an InvalidArgument is thrown.

Parameters:
[in] pos Definition of the position on the lane
[in] lane The lane the position must be valid for
[in] friendlyPos Whether false positions shall be made acceptable
[in] detid The id of the currently built detector (for error message generation)
Exceptions:
InvalidArgument If the defined position is invalid

Definition at line 533 of file NLDetectorBuilder.cpp.

References SUMOReal.

Referenced by addE3Entry(), addE3Exit(), buildInductLoop(), convContE2PosLength(), and convUncontE2PosLength().

00534                                                                                       {
00535     // check whether it is given from the end
00536     if (pos<0) {
00537         pos = lane->getLength() + pos;
00538     }
00539     // check whether it is on the lane
00540     if (pos>lane->getLength()) {
00541         if (friendlyPos) {
00542             pos = lane->getLength() - (SUMOReal) 0.1;
00543         } else {
00544             throw InvalidArgument("The position of detector '" + detid + "' lies beyond the lane's '" + lane->getID() + "' length.");
00545         }
00546     }
00547     if (pos<0) {
00548         if (friendlyPos) {
00549             pos = (SUMOReal) 0.1;
00550         } else {
00551             throw InvalidArgument("The position of detector '" + detid + "' lies beyond the lane's '" + lane->getID() + "' length.");
00552         }
00553     }
00554     return pos;
00555 }

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

Invalidated assignment operator.


Field Documentation

definition of the currently parsed e3-detector

Definition at line 592 of file NLDetectorBuilder.h.

Referenced by addE3Entry(), addE3Exit(), beginE3Detector(), endE3Detector(), and getCurrentE3ID().

The net to fill.

Definition at line 587 of file NLDetectorBuilder.h.

Referenced by buildE2Detector(), buildInductLoop(), buildRouteProbe(), and endE3Detector().


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

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