LCOV - code coverage report
Current view: top level - src/mesosim - MEInductLoop.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 19 19 100.0 %
Date: 2024-04-27 15:34:54 Functions: 5 5 100.0 %

          Line data    Source code
       1             : /****************************************************************************/
       2             : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3             : // Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
       4             : // This program and the accompanying materials are made available under the
       5             : // terms of the Eclipse Public License 2.0 which is available at
       6             : // https://www.eclipse.org/legal/epl-2.0/
       7             : // This Source Code may also be made available under the following Secondary
       8             : // Licenses when the conditions for such availability set forth in the Eclipse
       9             : // Public License 2.0 are satisfied: GNU General Public License, version 2
      10             : // or later which is available at
      11             : // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
      12             : // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
      13             : /****************************************************************************/
      14             : /// @file    MEInductLoop.cpp
      15             : /// @author  Daniel Krajzewicz
      16             : /// @date    Tue, May 2005
      17             : ///
      18             : // An induction loop for mesoscopic simulation
      19             : /****************************************************************************/
      20             : 
      21             : 
      22             : /* =========================================================================
      23             :  * included modules
      24             :  * ======================================================================= */
      25             : #include <config.h>
      26             : 
      27             : #include "MEInductLoop.h"
      28             : #include <cassert>
      29             : #include <numeric>
      30             : #include <utility>
      31             : #include <limits>
      32             : #include <utils/common/WrappingCommand.h>
      33             : #include <utils/common/ToString.h>
      34             : #include <microsim/MSEdge.h>
      35             : #include <microsim/MSEventControl.h>
      36             : #include <mesosim/MESegment.h>
      37             : #include <utils/common/MsgHandler.h>
      38             : #include <utils/common/UtilExceptions.h>
      39             : #include <utils/common/StringUtils.h>
      40             : 
      41             : 
      42             : // ===========================================================================
      43             : // method definitions
      44             : // ===========================================================================
      45         373 : MEInductLoop::MEInductLoop(const std::string& id,
      46             :                            MESegment* s,
      47             :                            double positionInMeters,
      48             :                            const std::string name, const std::string& vTypes,
      49             :                            const std::string& nextEdges,
      50         373 :                            int detectPersons) :
      51             :     MSDetectorFileOutput(id, vTypes, nextEdges, detectPersons),
      52         371 :     myName(name),
      53         371 :     mySegment(s),
      54         371 :     myPosition(positionInMeters),
      55         744 :     myMeanData(nullptr, mySegment->getLength(), false, nullptr) {
      56         371 :     myMeanData.setDescription("inductionLoop_" + id);
      57         371 :     s->addDetector(&myMeanData);
      58         371 : }
      59             : 
      60             : 
      61         930 : MEInductLoop::~MEInductLoop() {}
      62             : 
      63             : 
      64             : void
      65       41512 : MEInductLoop::writeXMLOutput(OutputDevice& dev,
      66             :                              SUMOTime startTime, SUMOTime stopTime) {
      67       41512 :     mySegment->prepareDetectorForWriting(myMeanData);
      68      124536 :     dev.openTag(SUMO_TAG_INTERVAL).writeAttr(SUMO_ATTR_BEGIN, time2string(startTime)).writeAttr(SUMO_ATTR_END, time2string(stopTime));
      69      124536 :     dev.writeAttr(SUMO_ATTR_ID, StringUtils::escapeXML(myID)).writeAttr("sampledSeconds", myMeanData.getSamples());
      70       41512 :     myMeanData.write(dev, 0, stopTime - startTime, (int)mySegment->getEdge().getLanes().size(), mySegment->getEdge().getSpeedLimit(), -1.0);
      71       41512 :     myMeanData.reset();
      72       41512 : }
      73             : 
      74             : const MSEdge&
      75         222 : MEInductLoop::getEdge() const {
      76         222 :     return mySegment->getEdge();
      77             : }
      78             : 
      79             : /****************************************************************************/

Generated by: LCOV version 1.14