Eclipse 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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
14 // An induction loop for mesoscopic simulation
15 /****************************************************************************/
16 
17 
18 /* =========================================================================
19  * included modules
20  * ======================================================================= */
21 #include <config.h>
22 
23 #include "MEInductLoop.h"
24 #include <cassert>
25 #include <numeric>
26 #include <utility>
27 #include <limits>
29 #include <utils/common/ToString.h>
30 #include <microsim/MSEdge.h>
32 #include <mesosim/MESegment.h>
36 
37 
38 // ===========================================================================
39 // method definitions
40 // ===========================================================================
41 MEInductLoop::MEInductLoop(const std::string& id,
42  MESegment* s,
43  double positionInMeters,
44  const std::string& vTypes) :
45  MSDetectorFileOutput(id, vTypes), mySegment(s),
46  myPosition(positionInMeters),
47  myMeanData(nullptr, mySegment->getLength(), false, nullptr) {
48  myMeanData.setDescription("inductionLoop_" + id);
50 }
51 
52 
54 
55 
56 void
58  SUMOTime startTime, SUMOTime stopTime) {
62  myMeanData.write(dev, stopTime - startTime, (double)mySegment->getEdge().getLanes().size(), -1.0);
63  myMeanData.reset();
64 }
65 
66 
67 /****************************************************************************/
68 
ToString.h
MSDetectorFileOutput
Base of value-generating classes (detectors)
Definition: MSDetectorFileOutput.h:63
MESegment
A single mesoscopic segment (cell)
Definition: MESegment.h:49
OutputDevice
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:63
MESegment::addDetector
void addDetector(MSMoveReminder *data)
Adds a data collector for a detector to this segment.
Definition: MESegment.cpp:211
MESegment::getEdge
const MSEdge & getEdge() const
Returns the edge this segment belongs to.
Definition: MESegment.h:265
MsgHandler.h
MEInductLoop.h
MSMeanData_Net::MSLaneMeanDataValues::write
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.
Definition: MSMeanData_Net.cpp:232
WrappingCommand.h
SUMOTime
long long int SUMOTime
Definition: SUMOTime.h:34
MEInductLoop::myMeanData
MSMeanData_Net::MSLaneMeanDataValues myMeanData
data collector for the loop
Definition: MEInductLoop.h:97
SUMO_ATTR_ID
@ SUMO_ATTR_ID
Definition: SUMOXMLDefinitions.h:378
MSEdge.h
MSMeanData_Net::MSLaneMeanDataValues::reset
void reset(bool afterWrite=false)
Resets values so they may be used for the next interval.
Definition: MSMeanData_Net.cpp:73
SUMO_ATTR_BEGIN
@ SUMO_ATTR_BEGIN
weights: time range begin
Definition: SUMOXMLDefinitions.h:678
MESegment.h
OutputDevice::writeAttr
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
Definition: OutputDevice.h:255
MEInductLoop::~MEInductLoop
~MEInductLoop()
Definition: MEInductLoop.cpp:53
MESegment::prepareDetectorForWriting
void prepareDetectorForWriting(MSMoveReminder &data)
Updates data of a detector for all vehicle queues.
Definition: MESegment.cpp:237
MEInductLoop::mySegment
MESegment *const mySegment
mesoscopic edge segment the loop lies on
Definition: MEInductLoop.h:91
MEInductLoop::MEInductLoop
MEInductLoop()
Hidden default constructor.
MEInductLoop::writeXMLOutput
void writeXMLOutput(OutputDevice &dev, SUMOTime startTime, SUMOTime stopTime)
Definition: MEInductLoop.cpp:57
StringUtils::escapeXML
static std::string escapeXML(const std::string &orig, const bool maskDoubleHyphen=false)
Replaces the standard escapes by their XML entities.
Definition: StringUtils.cpp:190
time2string
std::string time2string(SUMOTime t)
Definition: SUMOTime.cpp:67
UtilExceptions.h
OutputDevice::openTag
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
Definition: OutputDevice.cpp:239
StringUtils.h
MSMeanData::MeanDataValues::getSamples
virtual double getSamples() const
Returns the number of collected sample seconds.
Definition: MSMeanData.cpp:277
MSMoveReminder::setDescription
void setDescription(const std::string &description)
Definition: MSMoveReminder.h:226
MSEdge::getLanes
const std::vector< MSLane * > & getLanes() const
Returns this edge's lanes.
Definition: MSEdge.h:167
config.h
SUMO_ATTR_END
@ SUMO_ATTR_END
weights: time range end
Definition: SUMOXMLDefinitions.h:680
SUMO_TAG_INTERVAL
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
Definition: SUMOXMLDefinitions.h:159
MSEventControl.h
Named::myID
std::string myID
The name of the object.
Definition: Named.h:133