61 #include <mesosim/MEInductLoop.h>
62 #include <mesosim/MELoop.h>
63 #include <mesosim/MESegment.h>
66 #ifdef CHECK_MEMORY_LEAKS
68 #endif // CHECK_MEMORY_LEAKS
78 const std::string& device,
SUMOReal haltingSpeedThreshold,
79 SUMOTime haltingTimeThreshold,
int splInterval)
80 : myID(id), myDevice(device),
81 myHaltingSpeedThreshold(haltingSpeedThreshold),
82 myHaltingTimeThreshold(haltingTimeThreshold),
83 mySampleInterval(splInterval) {}
101 const std::string& lane,
SUMOReal pos,
int splInterval,
102 const std::string& device,
bool friendlyPos,
bool splitByType) {
118 MESegment* s = MSGlobals::gMesoNet->getSegmentForEdge(clane->
getEdge());
121 while (cpos + prev->getLength() < pos && s != 0) {
123 cpos += s->getLength();
124 s = s->getNextSegment();
127 if (rpos > prev->getLength() || rpos < 0) {
129 rpos = prev->getLength() - (
SUMOReal) 0.1;
131 throw InvalidArgument(
"The position of detector '" +
id +
"' lies beyond the lane's '" + lane +
"' length.");
135 createMEInductLoop(
id, prev, rpos);
144 const std::string& lane,
SUMOReal pos,
145 const std::string& device,
bool friendlyPos) {
160 bool cont,
int splInterval,
161 const std::string& device,
164 SUMOReal jamDistThreshold,
bool friendlyPos) {
186 const std::string& device,
189 SUMOReal jamDistThreshold,
bool friendlyPos) {
191 throw InvalidArgument(
"The detector '" +
id +
"' refers to the unknown lsa.");
215 const std::string& tolane,
216 const std::string& device,
219 SUMOReal jamDistThreshold,
bool friendlyPos) {
221 throw InvalidArgument(
"The detector '" +
id +
"' refers to the unknown lsa.");
228 "The detector output can not be build as no connection between lanes '"
229 + lane +
"' and '" + tolane +
"' exists.");
264 throw InvalidArgument(
"The length of detector '" +
id +
"' lies beyond the lane's '" + clane->
getID() +
"' length.");
271 throw InvalidArgument(
"The length of detector '" +
id +
"' is almost 0.");
289 const std::string& device,
int splInterval,
352 const std::string& vtype,
SUMOTime frequency,
353 const std::string& device) {
362 const std::string& device) {
380 length, haltingTimeThreshold, haltingSpeedThreshold,
392 lane, pos, haltingTimeThreshold, haltingSpeedThreshold,
415 NLDetectorBuilder::createMEInductLoop(
const std::string&
id,
417 return new MEInductLoop(
id, s, pos);
426 return new MSE2Collector(
id, usage, lane, pos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold);
444 return new MSE3Collector(
id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold);
450 const std::string& detid) {
460 throw InvalidArgument(
"The position of detector '" + detid +
"' lies beyond the lane's '" + lane->
getID() +
"' length.");
467 throw InvalidArgument(
"The position of detector '" + detid +
"' lies beyond the lane's '" + lane->
getID() +
"' length.");
477 const bool useLanes,
const bool withEmpty,
const bool printDefaults,
478 const bool withInternal,
const bool trackVehicles,
480 const SUMOReal haltSpeed,
const std::string& vTypes,
481 const std::string& device) {
483 throw InvalidArgument(
"Negative begin time for meandata dump '" +
id +
"'.");
489 throw InvalidArgument(
"End before or at begin for meandata dump '" +
id +
"'.");
491 std::set<std::string> vt;
494 vt.insert(st.
next());
497 if (type ==
"" || type ==
"performance" || type ==
"traffic") {
499 printDefaults, withInternal, trackVehicles,
500 maxTravelTime, minSamples, haltSpeed, vt);
501 }
else if (type ==
"hbefa") {
503 printDefaults, withInternal, trackVehicles,
504 maxTravelTime, minSamples, vt);
505 }
else if (type ==
"harmonoise") {
507 printDefaults, withInternal, trackVehicles,
508 maxTravelTime, minSamples, vt);
510 throw InvalidArgument(
"Invalid type '" + type +
"' for meandata dump '" +
id +
"'.");
514 frequency = end - begin;
526 const std::string& detid) {
530 throw InvalidArgument(
"The lane with the id '" + edgeID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
538 const std::string& detid) {
542 throw InvalidArgument(
"The lane with the id '" + laneID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
550 if (splInterval < 0) {
553 if (splInterval == 0) {
Data collector for edges/lanes.
SumoXMLTag
Numbers representing SUMO-XML - element names.
MSEdge & getEdge() const
Returns the lane's edge.
virtual MSDetectorFileOutput * createInductLoop(const std::string &id, MSLane *lane, SUMOReal pos, bool splitByType)
Creates an instance of an e1 detector using the given values.
E3DetectorDefinition(const std::string &id, const std::string &device, SUMOReal haltingSpeedThreshold, SUMOTime haltingTimeThreshold, int splInterval)
Constructor.
Storage for all programs of a single tls.
MSLane * getLaneChecking(const std::string &laneID, SumoXMLTag type, const std::string &detid)
Returns the named lane.
A simple description of a position on a lane (crossing of a lane)
An areal (along a single lane) detector.
void addE3Entry(const std::string &lane, SUMOReal pos, bool friendlyPos)
Builds an entry point of an e3 detector.
static bool dictionary(std::string id, MSLane *lane)
Inserts a MSLane into the static dictionary Returns true if the key id isn't already in the dictionar...
A detector which joins E2Collectors over consecutive lanes (backward)
Writes routes of vehicles passing a certain edge.
SUMOReal getLength() const
Returns the lane's length.
void addE3Exit(const std::string &lane, SUMOReal pos, bool friendlyPos)
Builds an exit point of an e3 detector.
std::vector< MSCrossSection > CrossSectionVector
An instantaneous induction loop.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
MSDetectorFileOutput * buildMultiLaneE2Det(const std::string &id, DetectorUsage usage, MSLane *lane, SUMOReal pos, SUMOReal length, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold)
Builds an e2 detector that continues on preceeding lanes.
static bool dictionary(const std::string &id, MSEdge *edge)
Inserts edge into the static dictionary Returns true if the key id isn't already in the dictionary...
~E3DetectorDefinition()
Destructor.
void createEdgeLaneMeanData(const std::string &id, SUMOTime frequency, SUMOTime begin, SUMOTime end, const std::string &type, const bool useLanes, const bool withEmpty, const bool printDefaults, const bool withInternal, const bool trackVehicles, const SUMOReal maxTravelTime, const SUMOReal minSamples, const SUMOReal haltSpeed, const std::string &vTypes, const std::string &device)
Creates edge based mean data collector using the given specification.
MSDetectorFileOutput * buildSingleLaneE2Det(const std::string &id, DetectorUsage usage, MSLane *lane, SUMOReal pos, SUMOReal length, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold)
Builds an e2 detector that lies on only one lane.
Noise data collector for edges/lanes.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step (in s)
void buildVTypeProbe(const std::string &id, const std::string &vtype, SUMOTime frequency, const std::string &device)
Builds a vTypeProbe and adds it to the net.
void endE3Detector()
Builds of an e3 detector using collected values.
void buildInductLoop(const std::string &id, const std::string &lane, SUMOReal pos, int splInterval, const std::string &device, bool friendlyPos, bool splitByType)
Builds an e1 detector and adds it to the net.
void convUncontE2PosLength(const std::string &id, MSLane *clane, SUMOReal &pos, SUMOReal &length, bool frinedly_pos)
Converts the length and the position information for an e2 detector.
The simulated network and simulation perfomer.
virtual MSDetectorFileOutput * createSingleLaneE2Detector(const std::string &id, DetectorUsage usage, MSLane *lane, SUMOReal pos, SUMOReal length, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold)
Creates an instance of an e2 detector using the given values.
const std::string & getID() const
Returns the id.
A road/street connecting two junctions.
Holds the incoming definitions of an e3 detector unless the detector is build.
MSTrafficLightLogic * getActive() const
Writes positions of vehicles that have a certain (named) type.
An instantenous induction loop.
std::string getCurrentE3ID() const
Returns the id of the currently built e3 detector.
Writes e2 state on each tls switch.
void beginE3Detector(const std::string &id, const std::string &device, int splInterval, SUMOReal haltingSpeedThreshold, SUMOTime haltingTimeThreshold)
Stores temporary the initial information about an e3 detector to build.
SUMOReal myHaltingSpeedThreshold
The speed a vehicle's speed must be below to be assigned as jammed.
void buildRouteProbe(const std::string &id, const std::string &edge, SUMOTime frequency, SUMOTime begin, const std::string &device)
Builds a routeProbe and adds it to the net.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
MSDetectorControl & getDetectorControl()
Returns the detector control.
CrossSectionVector myExits
List of detector's exits.
MSEdge * getEdgeChecking(const std::string &edgeID, SumoXMLTag type, const std::string &detid)
Returns the named edge.
virtual MSDetectorFileOutput * createE3Detector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, SUMOReal haltingSpeedThreshold, SUMOTime haltingTimeThreshold)
Creates an instance of an e3 detector using the given values.
int mySampleInterval
The aggregation interval.
void convContE2PosLength(const std::string &id, MSLane *clane, SUMOReal &pos, SUMOReal &length, bool frinedly_pos)
Converts the length and the position information for an e2ol-detector.
static MSLink * getConnectingLink(const MSLane &from, const MSLane &to)
Returns the link connecting both lanes Both lanes have to be non-internal; 0 may be returned if no co...
static OutputDevice & getDevice(const std::string &name)
Returns the described OutputDevice.
NLDetectorBuilder(MSNet &net)
Constructor.
virtual MSDetectorFileOutput * createInstantInductLoop(const std::string &id, MSLane *lane, SUMOReal pos, const std::string &od)
Creates an instance of an e1 detector using the given values.
void add(SumoXMLTag type, MSDetectorFileOutput *d, const std::string &device, int splInterval, SUMOTime begin=-1)
Adds a detector/output combination into the containers.
virtual MSDetectorFileOutput * createMultiLaneE2Detector(const std::string &id, DetectorUsage usage, MSLane *lane, SUMOReal pos, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold)
Creates an instance of an e2ol-detector using the given values.
A detector of vehicles passing an area between entry/exit points.
void checkSampleInterval(int splInterval, SumoXMLTag type, const std::string &id)
Checks whether the given frequency (sample interval) is valid.
Network state mean data collector for edges/lanes.
static const bool gUseMesoSim
void buildInstantInductLoop(const std::string &id, const std::string &lane, SUMOReal pos, const std::string &device, bool friendlyPos)
Builds an instantenous induction and adds it to the net.
virtual ~NLDetectorBuilder()
Destructor.
E3DetectorDefinition * myE3Definition
definition of the currently parsed e3 detector
void buildE2Detector(const std::string &id, const std::string &lane, SUMOReal pos, SUMOReal length, bool cont, int splInterval, const std::string &device, SUMOTime haltingTimeThreshold, SUMOReal haltingSpeedThreshold, SUMOReal jamDistThreshold, bool friendlyPos)
Builds an e2 detector with a fixed interval and adds it to the net.
MSNet & myNet
The net to fill.
Writes e2 state of a link for the time the link has yellow/red.
CrossSectionVector myEntries
List of detector's entries.
Representation of a lane in the micro simulation.
SUMOReal getPositionChecking(SUMOReal pos, MSLane *lane, bool friendlyPos, const std::string &detid)
Computes the position to use.
const std::string myDevice
The device the detector shall use.
Emission data collector for edges/lanes.
std::string myID
The id of the detector.
Base of value-generating classes (detectors)
An unextended detector measuring at a fixed position on a fixed lane.
SUMOTime myHaltingTimeThreshold
The time a vehicle's speed must be below haltingSpeedThreshold to be assigned as jammed.