67 const std::string& device,
double haltingSpeedThreshold,
69 const std::string& vTypes,
bool openEntry) :
70 myID(id), myDevice(device),
71 myHaltingSpeedThreshold(haltingSpeedThreshold),
72 myHaltingTimeThreshold(haltingTimeThreshold),
73 mySampleInterval(splInterval),
74 myVehicleTypes(vTypes),
75 myOpenEntry(openEntry) {
96 const std::string& lane,
double pos,
SUMOTime splInterval,
97 const std::string& device,
bool friendlyPos,
98 const std::string& vTypes) {
113 const std::string& lane,
double pos,
114 const std::string& device,
bool friendlyPos,
115 const std::string& vTypes) {
129 const std::string& device,
SUMOTime frequency,
130 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
131 const std::string& vTypes,
bool friendlyPos,
bool showDetector,
134 bool tlsGiven = tlls !=
nullptr;
135 bool toLaneGiven = toLane !=
nullptr;
136 bool posGiven = pos != std::numeric_limits<double>::max();
137 bool endPosGiven = endPos != std::numeric_limits<double>::max();
139 assert(posGiven || endPosGiven);
144 std::stringstream ss;
145 ss <<
"The given position (=" << pos <<
") for detector '" <<
id 146 <<
"' does not lie on the given lane '" << lane->
getID()
147 <<
"' with length " << lane->
getLength();
150 ss <<
" (adjusting to new position " << newPos;
154 ss <<
" (0 <= pos < lane->getLength() is required)";
161 std::stringstream ss;
162 ss <<
"The given end position (=" << endPos <<
") for detector '" <<
id 163 <<
"' does not lie on the given lane '" << lane->
getID()
164 <<
"' with length " << lane->
getLength();
167 ss <<
" (adjusting to new position " << newEndPos;
171 std::stringstream ss;
172 ss <<
" (0 <= pos < lane->getLength() is required)";
181 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, showDetector);
186 MSLane* lastLane = det->getLastLane();
188 if (link ==
nullptr) {
190 "The detector '" +
id +
"' cannot be build as no connection between lanes '" 191 + lastLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
201 det =
createE2Detector(
id,
DU_USER_DEFINED, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes, showDetector);
209 const std::string& device,
SUMOTime frequency,
210 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
211 const std::string& vTypes,
bool friendlyPos,
bool showDetector,
214 bool tlsGiven = tlls !=
nullptr;
215 bool toLaneGiven = toLane !=
nullptr;
216 assert(pos != std::numeric_limits<double>::max());
217 assert(endPos != std::numeric_limits<double>::max());
218 assert(lanes.size() != 0);
220 MSLane* firstLane = lanes[0];
221 MSLane* lastLane = lanes[lanes.size() - 1];
224 if (pos >= firstLane->getLength() || (pos < 0 && -pos > firstLane->getLength())) {
225 std::stringstream ss;
226 ss <<
"The given position (=" << pos <<
") for detector '" <<
id 227 <<
"' does not lie on the given lane '" << firstLane->
getID()
228 <<
"' with length " << firstLane->getLength();
230 double newPos = pos > 0 ? firstLane->getLength() -
POSITION_EPS : 0.;
231 ss <<
" (adjusting to new position " << newPos;
235 ss <<
" (0 <= pos < lane->getLength() is required)";
239 if (endPos > lastLane->
getLength() || (endPos <= 0 && -endPos >= lastLane->
getLength())) {
240 std::stringstream ss;
241 ss <<
"The given end position (=" << endPos <<
") for detector '" <<
id 242 <<
"' does not lie on the given lane '" << lastLane->
getID()
243 <<
"' with length " << lastLane->
getLength();
246 ss <<
" (adjusting to new position " << newEndPos;
250 ss <<
" (0 <= pos < lane->getLength() is required)";
263 MSLane* lastLane = det->getLastLane();
265 if (link ==
nullptr) {
267 "The detector '" +
id +
"' cannot be build as no connection between lanes '" 268 + lastLane->
getID() +
"' and '" + toLane->
getID() +
"' exists.");
289 const std::string& device,
SUMOTime splInterval,
290 double haltingSpeedThreshold,
292 const std::string& vTypes,
bool openEntry) {
300 double pos,
bool friendlyPos) {
314 double pos,
bool friendlyPos) {
360 const std::string& vtype,
SUMOTime frequency,
361 const std::string& device) {
370 const std::string& device,
371 const std::string& vTypes) {
382 const std::string& vTypes,
bool) {
392 MSLane* lane,
double pos,
const std::string& od,
393 const std::string& vTypes) {
401 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
402 const std::string& vTypes,
bool ) {
403 return new MSE2Collector(
id, usage, lane, pos, endPos, length, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes);
408 DetectorUsage usage, std::vector<MSLane*> lanes,
double pos,
double endPos,
409 SUMOTime haltingTimeThreshold,
double haltingSpeedThreshold,
double jamDistThreshold,
410 const std::string& vTypes,
bool ) {
411 return new MSE2Collector(
id, usage, lanes, pos, endPos, haltingTimeThreshold, haltingSpeedThreshold, jamDistThreshold, vTypes);
418 double haltingSpeedThreshold,
420 const std::string& vTypes,
422 return new MSE3Collector(
id, entries, exits, haltingSpeedThreshold, haltingTimeThreshold, vTypes, openEntry);
428 const std::string& detid) {
438 throw InvalidArgument(
"The position of detector '" + detid +
"' lies beyond the lane's '" + lane->
getID() +
"' end.");
445 throw InvalidArgument(
"The position of detector '" + detid +
"' lies before the lane's '" + lane->
getID() +
"' begin.");
455 const bool useLanes,
const bool withEmpty,
const bool printDefaults,
456 const bool withInternal,
const bool trackVehicles,
457 const double maxTravelTime,
const double minSamples,
458 const double haltSpeed,
const std::string& vTypes,
459 const std::string& device) {
461 throw InvalidArgument(
"Negative begin time for meandata dump '" +
id +
"'.");
467 throw InvalidArgument(
"End before or at begin for meandata dump '" +
id +
"'.");
470 if (type ==
"" || type ==
"performance" || type ==
"traffic") {
472 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, haltSpeed, vTypes);
473 }
else if (type ==
"emissions" || type ==
"hbefa") {
474 if (type ==
"hbefa") {
475 WRITE_WARNING(
"The netstate type 'hbefa' is deprecated. Please use the type 'emissions' instead.");
478 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes);
479 }
else if (type ==
"harmonoise") {
481 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, vTypes);
482 }
else if (type ==
"amitran") {
484 printDefaults, withInternal, trackVehicles, maxTravelTime, minSamples, haltSpeed, vTypes);
486 throw InvalidArgument(
"Invalid type '" + type +
"' for meandata dump '" +
id +
"'.");
488 if (det !=
nullptr) {
490 frequency = end - begin;
502 const std::string& detid) {
505 if (edge ==
nullptr) {
506 throw InvalidArgument(
"The lane with the id '" + edgeID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
514 const std::string& detid) {
517 if (lane ==
nullptr) {
518 throw InvalidArgument(
"The lane with the id '" + laneID +
"' is not known (while building " +
toString(type) +
" '" + detid +
"').");
526 if (splInterval < 0) {
529 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 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()
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.
virtual MSDetectorFileOutput * createE3Detector(const std::string &id, const CrossSectionVector &entries, const CrossSectionVector &exits, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes, bool openEntry)
Creates an instance of an e3 detector using the given values.
void endE3Detector()
Builds of an e3 detector using collected values.
E3DetectorDefinition(const std::string &id, const std::string &device, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, SUMOTime splInterval, const std::string &vTypes, bool openEntry)
Constructor.
#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 {.
void beginE3Detector(const std::string &id, const std::string &device, SUMOTime splInterval, double haltingSpeedThreshold, SUMOTime haltingTimeThreshold, const std::string &vTypes, bool openEntry)
Stores temporary the initial information about an e3 detector to build.
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.
bool myOpenEntry
Whether the detector is declared as having incomplete entry detectors.
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.