 |
Eclipse SUMO - Simulation of Urban MObility
|
Go to the documentation of this file.
58 typedTravelDistance.clear();
68 for (std::map<const MSVehicleType*, int>::const_iterator it = typedAmount.begin(); it != typedAmount.end(); ++it) {
71 for (std::map<const MSVehicleType*, double>::const_iterator it = typedSamples.begin(); it != typedSamples.end(); ++it) {
74 for (std::map<const MSVehicleType*, double>::const_iterator it = typedTravelDistance.begin(); it != typedTravelDistance.end(); ++it) {
82 sampleSeconds += timeOnLane;
83 travelledDistance += travelledDistanceVehicleOnLane;
85 typedTravelDistance[&veh.
getVehicleType()] += travelledDistanceVehicleOnLane;
91 if (myParent->vehicleApplies(veh)) {
92 if (getLane() ==
nullptr || getLane() == static_cast<MSVehicle&>(veh).getLane()) {
106 return sampleSeconds == 0 && amount == 0;
112 const double ,
const double defaultTravelTime,
const int )
const {
113 if (sampleSeconds > 0) {
114 dev.
writeAttr(
"amount", amount).
writeAttr(
"averageSpeed",
int(100 * travelledDistance / sampleSeconds));
115 }
else if (defaultTravelTime >= 0.) {
116 dev.
writeAttr(
"amount", amount).
writeAttr(
"averageSpeed",
int(100 * myLaneLength / defaultTravelTime));
120 if (myParent->isTyped()) {
121 for (std::map<const MSVehicleType*, int>::const_iterator it = typedAmount.begin(); it != typedAmount.end(); ++it) {
123 dev.
writeAttr(
"amount", it->second).
writeAttr(
"averageSpeed",
int(100 * typedTravelDistance.find(it->first)->second / typedSamples.find(it->first)->second));
135 const SUMOTime dumpEnd,
const bool useLanes,
136 const bool withEmpty,
const bool printDefaults,
137 const bool withInternal,
138 const bool trackVehicles,
140 const double maxTravelTime,
141 const double minSamples,
142 const double haltSpeed,
143 const std::string& vTypes)
144 :
MSMeanData(id, dumpBegin, dumpEnd, useLanes, withEmpty, printDefaults,
145 withInternal, trackVehicles,
detectPersons, maxTravelTime, minSamples, vTypes),
167 const int duration = int(1000 *
STEPS2TIME(stopTime - startTime) + 0.5);
MSMeanData::MeanDataValues * createValues(MSLane *const lane, const double length, const bool doAdd) const
Create an instance of MeanDataValues.
Representation of a vehicle or person.
virtual void openInterval(OutputDevice &dev, const SUMOTime startTime, const SUMOTime stopTime)
Writes the interval opener.
const bool myDumpEmpty
Whether empty lanes/edges shall be written.
int getNumericalID() const
Returns the numerical id of the edge.
Representation of a lane in the micro simulation.
Static storage of an output device and its base (abstract) implementation.
void notifyMoveInternal(const SUMOTrafficObject &veh, const double, const double timeOnLane, const double, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double)
Internal notification about the vehicle moves.
virtual const MSVehicleType & getVehicleType() const =0
Returns the vehicle's type.
void reset(bool afterWrite=false)
Resets values so they may be used for the next interval.
virtual bool isEmpty() const
Returns whether any data was collected.
SumoXMLTag
Numbers representing SUMO-XML - element names.
virtual ~MSMeanData_Amitran()
Destructor.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Data collector for edges/lanes.
Network state mean data collector for edges/lanes.
MSMeanData_Amitran(const std::string &id, const SUMOTime dumpBegin, const SUMOTime dumpEnd, const bool useLanes, const bool withEmpty, const bool printDefaults, const bool withInternal, const bool trackVehicles, const int detectPersons, const double maxTravelTime, const double minSamples, const double haltSpeed, const std::string &vTypes)
Constructor.
double travelledDistance
The sum of the distances the vehicles travelled.
void write(OutputDevice &dev, const SUMOTime period, const double numLanes, const double defaultTravelTime, const int numVehicles=-1) const
Writes output values into the given stream.
A road/street connecting two junctions.
The vehicle has departed (was inserted into the network)
MSLaneMeanDataValues(MSLane *const lane, const double length, const bool doAdd, const MSMeanData_Amitran *parent)
Constructor.
virtual ~MSLaneMeanDataValues()
Destructor.
Data structure for mean (aggregated) edge/lane values.
std::map< const MSVehicleType *, double > typedSamples
The number of sampled vehicle movements by type (in s)
bool detectPersons() const
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
std::map< const MSVehicleType *, double > typedTravelDistance
The sum of the distances the vehicles travelled by type.
const double myHaltSpeed
the minimum sample seconds
std::map< const MSVehicleType *, int > typedAmount
The number of vehicles that entered this lane within the sample interval by type.
void addTo(MSMeanData::MeanDataValues &val) const
Add the values of this to the given one and store them there.
Data structure for mean (aggregated) edge/lane values.
virtual void writeXMLDetectorProlog(OutputDevice &dev) const
Opens the XML-output using "netstats" as root element.
bool isEmpty() const
Returns whether any data was collected.
virtual bool writePrefix(OutputDevice &dev, const MeanDataValues &values, const SumoXMLTag tag, const std::string id) const
Checks for emptiness and writes prefix into the given stream.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Computes current values and adds them to their sums.
bool writeXMLHeader(const std::string &rootElement, const std::string &schemaFile, std::map< SumoXMLAttr, std::string > attrs=std::map< SumoXMLAttr, std::string >())
Writes an XML header with optional configuration.
Notification
Definition of a vehicle state.
The vehicle arrived at a junction.
virtual std::string getEdgeID(const MSEdge *const edge)
Return the relevant edge id.