SUMO - Simulation of Urban MObility
MEInductLoop.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // An induction loop for mesoscopic simulation
18 /****************************************************************************/
19 
20 
21 /* =========================================================================
22  * included modules
23  * ======================================================================= */
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
30 #include "MEInductLoop.h"
31 #include <cassert>
32 #include <numeric>
33 #include <utility>
34 #include <limits>
36 #include <utils/common/ToString.h>
37 #include <microsim/MSEdge.h>
39 #include <mesosim/MESegment.h>
43 
44 
45 // ===========================================================================
46 // method definitions
47 // ===========================================================================
48 MEInductLoop::MEInductLoop(const std::string& id,
49  MESegment* s,
50  double positionInMeters,
51  const std::string& vTypes) :
52  MSDetectorFileOutput(id, vTypes), mySegment(s),
53  myPosition(positionInMeters),
54  myMeanData(0, mySegment->getLength(), false, 0) {
55  myMeanData.setDescription("inductionLoop_" + id);
57 }
58 
59 
61 
62 
63 void
65  SUMOTime startTime, SUMOTime stopTime) {
69  myMeanData.write(dev, stopTime - startTime, (double)mySegment->getEdge().getLanes().size(), -1.0);
70  myMeanData.reset();
71 }
72 
73 
74 /****************************************************************************/
75 
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:260
MEInductLoop()
Hidden default constructor.
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:59
weights: time range begin
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:167
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.
void addDetector(MSMoveReminder *data)
Adds a data collector for a detector to this segment.
Definition: MESegment.cpp:204
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
void setDescription(const std::string &description)
std::string myID
The name of the object.
Definition: Named.h:135
weights: time range end
A single mesoscopic segment (cell)
Definition: MESegment.h:56
an aggreagated-output interval
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:70
virtual double getSamples() const
Returns the number of collected sample seconds.
Definition: MSMeanData.cpp:281
long long int SUMOTime
Definition: TraCIDefs.h:51
void reset(bool afterWrite=false)
Resets values so they may be used for the next interval.
MSMeanData_Net::MSLaneMeanDataValues myMeanData
data collector for the loop
Definition: MEInductLoop.h:104
void prepareDetectorForWriting(MSMoveReminder &data)
Updates data of a detector for all vehicle queues.
Definition: MESegment.cpp:246
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition: MESegment.h:270
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
MESegment *const mySegment
mesoscopic edge segment the loop lies on
Definition: MEInductLoop.h:98
Base of value-generating classes (detectors)