73 const std::string& device,
double haltingSpeedThreshold,
75 const std::string& vTypes)
76 : myID(id), myDevice(device),
77 myHaltingSpeedThreshold(haltingSpeedThreshold),
78 myHaltingTimeThreshold(haltingTimeThreshold),
79 mySampleInterval(splInterval),
80 myVehicleTypes(vTypes) {}
100 const std::string& lane,
double pos,
SUMOTime splInterval,
101 const std::string& device,
bool friendlyPos,
102 const std::string& vTypes) {
117 const std::string& lane,
double pos,
118 const std::string& device,
bool friendlyPos,
119 const std::string& vTypes) {
133 const std::string& device,
SUMOTime frequency,
134 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
135 const std::string& vTypes,
bool friendlyPos,
bool showDetector,
138 bool tlsGiven = tlls != 0;
139 bool toLaneGiven = toLane != 0;
140 bool posGiven = pos != std::numeric_limits<double>::max();
141 bool endPosGiven = endPos != std::numeric_limits<double>::max();
143 assert(posGiven || endPosGiven);
148 std::stringstream ss;
149 ss <<
"The given position (=" << pos <<
") for detector '" <<
id 150 <<
"' does not lie on the given lane '" << lane->
getID()
151 <<
"' with length " << lane->
getLength();
154 ss <<
" (adjusting to new position " << newPos;
158 ss <<
" (0 <= pos < lane->getLength() is required)";
165 std::stringstream ss;
166 ss <<
"The given end position (=" << endPos <<
") for detector '" <<
id 167 <<
"' does not lie on the given lane '" << lane->
getID()
168 <<
"' with length " << lane->
getLength();
171 ss <<
" (adjusting to new position " << newEndPos;
175 std::stringstream ss;
176 ss <<
" (0 <= pos < lane->getLength() is required)";
185 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, showDetector);
190 MSLane* lastLane = det->getLastLane();
194 "The detector '" +
id +
"' cannot be build as no connection between lanes '" 195 + lastLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
205 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, showDetector);
213 const std::string& device,
SUMOTime frequency,
214 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
215 const std::string& vTypes,
bool friendlyPos,
bool showDetector,
218 bool tlsGiven = tlls != 0;
219 bool toLaneGiven = toLane != 0;
220 assert(pos != std::numeric_limits<double>::max());
221 assert(endPos != std::numeric_limits<double>::max());
222 assert(lanes.size() != 0);
224 MSLane* firstLane = lanes[0];
225 MSLane* lastLane = lanes[lanes.size() - 1];
228 if (pos >= firstLane->getLength() || (pos < 0 && -pos > firstLane->getLength())) {
229 std::stringstream ss;
230 ss <<
"The given position (=" << pos <<
") for detector '" <<
id 231 <<
"' does not lie on the given lane '" << firstLane->
getID()
232 <<
"' with length " << firstLane->getLength();
234 double newPos = pos > 0 ? firstLane->getLength() -
POSITION_EPS : 0.;
235 ss <<
" (adjusting to new position " << newPos;
239 ss <<
" (0 <= pos < lane->getLength() is required)";
243 if (endPos > lastLane->
getLength() || (endPos <= 0 && -endPos >= lastLane->
getLength())) {
244 std::stringstream ss;
245 ss <<
"The given end position (=" << endPos <<
") for detector '" <<
id 246 <<
"' does not lie on the given lane '" << lastLane->
getID()
247 <<
"' with length " << lastLane->
getLength();
250 ss <<
" (adjusting to new position " << newEndPos;
254 ss <<
" (0 <= pos < lane->getLength() is required)";
267 MSLane* lastLane = det->getLastLane();
271 "The detector '" +
id +
"' cannot be build as no connection between lanes '" 272 + lastLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
293 const std::string& device,
SUMOTime splInterval,
294 double haltingSpeedThreshold,
296 const std::string& vTypes) {
304 double pos,
bool friendlyPos) {
318 double pos,
bool friendlyPos) {
363 const std::string& vtype,
SUMOTime frequency,
364 const std::string& device) {
373 const std::string& device,
374 const std::string& vTypes) {
385 const std::string& vTypes,
bool) {
395 MSLane* lane,
double pos,
const std::string& od,
396 const std::string& vTypes) {
404 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
405 const std::string& vTypes,
bool ) {
406 return new MSE2Collector(
id, usage, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes);
411 DetectorUsage usage, std::vector<MSLane*> lanes,
double pos,
double endPos,
412 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
413 const std::string& vTypes,
bool ) {
414 return new MSE2Collector(
id, usage, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes);
421 double haltingSpeedThreshold,
423 const std::string& vTypes) {
424 return new MSE3Collector(
id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, vTypes);
430 const std::string& detid) {
440 throw InvalidArgument(
"The position of detector '" + detid +
"' lies beyond the lane's '" + lane->
getID() +
"' end.");
447 throw InvalidArgument(
"The position of detector '" + detid +
"' lies before the lane's '" + lane->
getID() +
"' begin.");
457 const bool useLanes,
const bool withEmpty,
const bool printDefaults,
458 const bool withInternal,
const bool trackVehicles,
459 const double maxTravelTime,
const double minSamples,
460 const double haltSpeed,
const std::string& vTypes,
461 const std::string& device) {
463 throw InvalidArgument(
"Negative begin time for meandata dump '" +
id +
"'.");
469 throw InvalidArgument(
"End before or at begin for meandata dump '" +
id +
"'.");
472 if (type ==
"" || type ==
"performance" || type ==
"traffic") {
474 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, haltSpeed, vTypes);
475 }
else if (type ==
"emissions" || type ==
"hbefa") {
476 if (type ==
"hbefa") {
477 WRITE_WARNING(
"The netstate type 'hbefa' is deprecated. Please use the type 'emissions' instead.");
480 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes);
481 }
else if (type ==
"harmonoise") {
483 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes);
484 }
else if (type ==
"amitran") {
486 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, haltSpeed, vTypes);
488 throw InvalidArgument(
"Invalid type '" + type +
"' for meandata dump '" +
id +
"'.");
492 frequency = end - begin;
504 const std::string& detid) {
508 throw InvalidArgument(
"The lane with the id '" + edgeID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
516 const std::string& detid) {
520 throw InvalidArgument(
"The lane with the id '" + laneID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
528 if (splInterval < 0) {
531 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.