74 const std::string& device,
double haltingSpeedThreshold,
76 const std::string& vTypes)
77 : myID(id), myDevice(device),
78 myHaltingSpeedThreshold(haltingSpeedThreshold),
79 myHaltingTimeThreshold(haltingTimeThreshold),
80 mySampleInterval(splInterval),
81 myVehicleTypes(vTypes) {}
101 const std::string& lane,
double pos,
SUMOTime splInterval,
102 const std::string& device,
bool friendlyPos,
103 const std::string& vTypes) {
118 const std::string& lane,
double pos,
119 const std::string& device,
bool friendlyPos,
120 const std::string& vTypes) {
134 const std::string& device,
SUMOTime frequency,
135 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
136 const std::string& vTypes,
bool friendlyPos,
bool showDetector,
139 bool tlsGiven = tlls != 0;
140 bool toLaneGiven = toLane != 0;
144 assert(posGiven || endPosGiven);
149 std::stringstream ss;
150 ss <<
"The given position (=" << pos <<
") for detector '" <<
id 151 <<
"' does not lie on the given lane '" << lane->
getID()
152 <<
"' with length " << lane->
getLength();
155 ss <<
" (adjusting to new position " << newPos;
159 ss <<
" (0 <= pos < lane->getLength() is required)";
166 std::stringstream ss;
167 ss <<
"The given end position (=" << endPos <<
") for detector '" <<
id 168 <<
"' does not lie on the given lane '" << lane->
getID()
169 <<
"' with length " << lane->
getLength();
172 ss <<
" (adjusting to new position " << newEndPos;
176 std::stringstream ss;
177 ss <<
" (0 <= pos < lane->getLength() is required)";
186 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, showDetector);
191 MSLane* lastLane = det->getLastLane();
195 "The detector '" +
id +
"' cannot be build as no connection between lanes '" 196 + lastLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
206 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, showDetector);
214 const std::string& device,
SUMOTime frequency,
215 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
216 const std::string& vTypes,
bool friendlyPos,
bool showDetector,
219 bool tlsGiven = tlls != 0;
220 bool toLaneGiven = toLane != 0;
223 assert(lanes.size() != 0);
225 MSLane* firstLane = lanes[0];
226 MSLane* lastLane = lanes[lanes.size() - 1];
229 if (pos >= firstLane->getLength() || (pos < 0 && -pos > firstLane->getLength())) {
230 std::stringstream ss;
231 ss <<
"The given position (=" << pos <<
") for detector '" <<
id 232 <<
"' does not lie on the given lane '" << firstLane->
getID()
233 <<
"' with length " << firstLane->getLength();
235 double newPos = pos > 0 ? firstLane->getLength() -
POSITION_EPS : 0.;
236 ss <<
" (adjusting to new position " << newPos;
240 ss <<
" (0 <= pos < lane->getLength() is required)";
244 if (endPos > lastLane->
getLength() || (endPos <= 0 && -endPos >= lastLane->
getLength())) {
245 std::stringstream ss;
246 ss <<
"The given end position (=" << endPos <<
") for detector '" <<
id 247 <<
"' does not lie on the given lane '" << lastLane->
getID()
248 <<
"' with length " << lastLane->
getLength();
251 ss <<
" (adjusting to new position " << newEndPos;
255 ss <<
" (0 <= pos < lane->getLength() is required)";
268 MSLane* lastLane = det->getLastLane();
272 "The detector '" +
id +
"' cannot be build as no connection between lanes '" 273 + lastLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
294 const std::string& device,
SUMOTime splInterval,
295 double haltingSpeedThreshold,
297 const std::string& vTypes) {
305 double pos,
bool friendlyPos) {
319 double pos,
bool friendlyPos) {
364 const std::string& vtype,
SUMOTime frequency,
365 const std::string& device) {
374 const std::string& device,
375 const std::string& vTypes) {
386 const std::string& vTypes,
bool) {
396 MSLane* lane,
double pos,
const std::string& od,
397 const std::string& vTypes) {
405 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
406 const std::string& vTypes,
bool ) {
407 return new MSE2Collector(
id, usage, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes);
412 DetectorUsage usage, std::vector<MSLane*> lanes,
double pos,
double endPos,
413 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
414 const std::string& vTypes,
bool ) {
415 return new MSE2Collector(
id, usage, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes);
422 double haltingSpeedThreshold,
424 const std::string& vTypes) {
425 return new MSE3Collector(
id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, vTypes);
431 const std::string& detid) {
441 throw InvalidArgument(
"The position of detector '" + detid +
"' lies beyond the lane's '" + lane->
getID() +
"' end.");
448 throw InvalidArgument(
"The position of detector '" + detid +
"' lies before the lane's '" + lane->
getID() +
"' begin.");
458 const bool useLanes,
const bool withEmpty,
const bool printDefaults,
459 const bool withInternal,
const bool trackVehicles,
460 const double maxTravelTime,
const double minSamples,
461 const double haltSpeed,
const std::string& vTypes,
462 const std::string& device) {
464 throw InvalidArgument(
"Negative begin time for meandata dump '" +
id +
"'.");
470 throw InvalidArgument(
"End before or at begin for meandata dump '" +
id +
"'.");
473 if (type ==
"" || type ==
"performance" || type ==
"traffic") {
475 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, haltSpeed, vTypes);
476 }
else if (type ==
"emissions" || type ==
"hbefa") {
477 if (type ==
"hbefa") {
478 WRITE_WARNING(
"The netstate type 'hbefa' is deprecated. Please use the type 'emissions' instead.");
481 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes);
482 }
else if (type ==
"harmonoise") {
484 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes);
485 }
else if (type ==
"amitran") {
487 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, haltSpeed, vTypes);
489 throw InvalidArgument(
"Invalid type '" + type +
"' for meandata dump '" +
id +
"'.");
493 frequency = end - begin;
505 const std::string& detid) {
509 throw InvalidArgument(
"The lane with the id '" + edgeID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
517 const std::string& detid) {
521 throw InvalidArgument(
"The lane with the id '" + laneID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
529 if (splInterval < 0) {
532 if (splInterval == 0) {
Data collector for edges/lanes.
double getPositionChecking(double pos, MSLane *lane, bool friendlyPos, const std::string &detid)
Computes the position to use.
SumoXMLTag
Numbers representing SUMO-XML - element names.
MSEdge & getEdge() const
Returns the lane's edge.
alternative tag for e1 detector
Storage for all programs of a single tls.
void buildInstantInductLoop(const std::string &id, const std::string &lane, double pos, const std::string &device, bool friendlyPos, const std::string &vTypes)
Builds an instantenous induction and adds it to the net.
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)
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 double maxTravelTime, const double minSamples, const double haltSpeed, const std::string &vTypes, const std::string &device)
Creates edge based mean data collector using the given specification.
An areal detector corresponding to a sequence of consecutive lanes.
Network state mean data collector for edges/lanes.
Writes routes of vehicles passing a certain edge.
void beginE3Detector(const std::string &id, const std::string &device, SUMOTime splInterval, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes)
Stores temporary the initial information about an e3 detector to build.
virtual MSDetectorFileOutput * createE3Detector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes)
Creates an instance of an e3 detector using the given values.
void addE3Entry(const std::string &lane, double pos, bool friendlyPos)
Builds an entry point of an e3 detector.
const std::string myID
The id of the detector.
std::vector< MSCrossSection > CrossSectionVector
An instantaneous induction loop.
static MSNet * getInstance()
Returns the pointer to the unique instance of MSNet (singleton).
void buildRouteProbe(const std::string &id, const std::string &edge, SUMOTime frequency, SUMOTime begin, const std::string &device, const std::string &vTypes)
Builds a routeProbe and adds it to the net.
double getLength() const
Returns the lane's length.
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(const std::string &id, const std::string &device, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, SUMOTime splInterval, const std::string &vTypes)
Constructor.
~E3DetectorDefinition()
Destructor.
const std::string & getID() const
Returns the id.
Noise data collector for edges/lanes.
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.
#define WRITE_WARNING(msg)
The simulated network and simulation perfomer.
void addE3Exit(const std::string &lane, double pos, bool friendlyPos)
Builds an exit point of an e3 detector.
const std::string myVehicleTypes
The device the detector shall use.
A road/street connecting two junctions.
virtual MSDetectorFileOutput * createInductLoop(const std::string &id, MSLane *lane, double pos, const std::string &vTypes, bool show=true)
Creates an instance of an e1 detector using the given values.
Holds the incoming definitions of an e3 detector unless the detector is build.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Writes positions of vehicles that have a certain (named) type.
An instantenous induction loop.
Writes e2 state on each tls switch.
virtual MSDetectorFileOutput * createInstantInductLoop(const std::string &id, MSLane *lane, double pos, const std::string &od, const std::string &vTypes)
Creates an instance of an e1 detector using the given values.
SUMOTime getCurrentTimeStep() const
Returns the current simulation step.
void add(SumoXMLTag type, MSDetectorFileOutput *d, const std::string &device, SUMOTime splInterval, SUMOTime begin=-1)
Adds a detector/output combination into the containers.
Emission data collector for edges/lanes.
std::string getCurrentE3ID() const
Returns the id of the currently built e3 detector.
MSDetectorControl & getDetectorControl()
Returns the detector control.
CrossSectionVector myExits
List of detector's exits.
void buildInductLoop(const std::string &id, const std::string &lane, double pos, SUMOTime splInterval, const std::string &device, bool friendlyPos, const std::string &vTypes)
Builds an e1 detector and adds it to the net.
virtual MSE2Collector * createE2Detector(const std::string &id, DetectorUsage usage, MSLane *lane, double pos, double endPos, double length, SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold, const std::string &vTypes, bool showDetector=true)
Creates a MSE2Collector instance, overridden by GUIE2Collector::createE2Detector() ...
MSEdge * getEdgeChecking(const std::string &edgeID, SumoXMLTag type, const std::string &detid)
Returns the named edge.
SUMOTime mySampleInterval
The aggregation interval.
static bool dictionary(const std::string &id, MSLane *lane)
Static (sic!) container methods {.
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.
double myHaltingSpeedThreshold
The speed a vehicle's speed must be below to be assigned as jammed.
NLDetectorBuilder(MSNet &net)
Constructor.
static MELoop * gMesoNet
mesoscopic simulation infrastructure
void checkSampleInterval(SUMOTime splInterval, SumoXMLTag type, const std::string &id)
Checks whether the given frequency (sample interval) is valid.
A detector of vehicles passing an area between entry/exit points.
void buildE2Detector(const std::string &id, MSLane *lane, double pos, double endPos, double length, const std::string &device, SUMOTime frequency, SUMOTime haltingTimeThreshold, double haltingSpeedThreshold, double jamDistThreshold, const std::string &vTypes, bool friendlyPos, bool showDetector, MSTLLogicControl::TLSLogicVariants *tlls=0, MSLane *toLane=0)
Builds a new E2 detector and adds it to the net's detector control. Also performs some consistency ch...
Network state mean data collector for edges/lanes.
virtual ~NLDetectorBuilder()
Destructor.
E3DetectorDefinition * myE3Definition
definition of the currently parsed e3 detector
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.
alternative tag for e3 detector
const std::string myDevice
The device the detector shall use.
alternative tag for e2 detector
An induction loop for mesoscopic simulation.
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.