SUMO - Simulation of Urban MObility
MEInductLoop.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // An induction loop for mesoscopic simulation
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 
22 /* =========================================================================
23  * included modules
24  * ======================================================================= */
25 #ifdef _MSC_VER
26 #include <windows_config.h>
27 #else
28 #include <config.h>
29 #endif
30 
31 #include "MEInductLoop.h"
32 #include <cassert>
33 #include <numeric>
34 #include <utility>
35 #include <limits>
37 #include <utils/common/ToString.h>
38 #include <microsim/MSEdge.h>
40 #include <mesosim/MESegment.h>
44 
45 
46 // ===========================================================================
47 // method definitions
48 // ===========================================================================
49 MEInductLoop::MEInductLoop(const std::string& id,
50  MESegment* s,
51  double positionInMeters,
52  const std::string& vTypes) :
53  MSDetectorFileOutput(id, vTypes), mySegment(s),
54  myPosition(positionInMeters),
55  myMeanData(0, mySegment->getLength(), false, 0) {
56  myMeanData.setDescription("inductionLoop_" + id);
58 }
59 
60 
62 
63 
64 void
66  SUMOTime startTime, SUMOTime stopTime) {
70  myMeanData.write(dev, stopTime - startTime, (double)mySegment->getEdge().getLanes().size(), -1.0);
71  myMeanData.reset();
72 }
73 
74 
75 /****************************************************************************/
76 
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:256
MEInductLoop()
Hidden default constructor.
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:60
weights: time range begin
const std::vector< MSLane * > & getLanes() const
Returns this edge&#39;s lanes.
Definition: MSEdge.h:192
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:205
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:136
weights: time range end
A single mesoscopic segment (cell)
Definition: MESegment.h:57
an aggreagated-output interval
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
virtual double getSamples() const
Returns the number of collected sample seconds.
Definition: MSMeanData.cpp:182
long long int SUMOTime
Definition: TraCIDefs.h:52
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:105
void prepareDetectorForWriting(MSMoveReminder &data)
Updates data of a detector for all vehicle queues.
Definition: MESegment.cpp:247
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition: MESegment.h:271
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
MESegment *const mySegment
mesoscopic edge segment the loop lies on
Definition: MEInductLoop.h:99
Base of value-generating classes (detectors)