SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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-2016 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 #ifdef CHECK_MEMORY_LEAKS
46 #include <foreign/nvwa/debug_new.h>
47 #endif // CHECK_MEMORY_LEAKS
48 
49 
50 // ===========================================================================
51 // method definitions
52 // ===========================================================================
53 MEInductLoop::MEInductLoop(const std::string& id,
54  MESegment* s,
55  SUMOReal positionInMeters,
56  const std::string& vTypes) :
57  MSDetectorFileOutput(id, vTypes), mySegment(s),
58  myPosition(positionInMeters),
59  myMeanData(0, mySegment->getLength(), false, 0) {
60  myMeanData.setDescription("inductionLoop_" + id);
62 }
63 
64 
66 
67 
68 void
70  SUMOTime startTime, SUMOTime stopTime) {
74  myMeanData.write(dev, stopTime - startTime, (SUMOReal)mySegment->getEdge().getLanes().size(), -1.0);
75  myMeanData.reset();
76 }
77 
78 
79 /****************************************************************************/
80 
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:257
void write(OutputDevice &dev, const SUMOTime period, const SUMOReal numLanes, const SUMOReal defaultTravelTime, const int numVehicles=-1) const
Writes output values into the given stream.
MEInductLoop()
Hidden default constructor.
long long int SUMOTime
Definition: SUMOTime.h:43
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:192
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
static std::string escapeXML(const std::string &orig)
Replaces the standard escapes by their XML entities.
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:59
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition: MESegment.h:272
void addDetector(MSMoveReminder *data)
Adds a data collector for a detector to this segment.
Definition: MESegment.cpp:193
void setDescription(const std::string &description)
std::string myID
The name of the object.
Definition: Named.h:136
A single mesoscopic segment (cell)
Definition: MESegment.h:57
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:71
#define SUMOReal
Definition: config.h:214
virtual SUMOReal getSamples() const
Returns the number of collected sample seconds.
Definition: MSMeanData.cpp:186
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:235
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)