LCOV - code coverage report
Current view: top level - src/mesosim - METriggeredCalibrator.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 4 4
Test Date: 2024-11-20 15:55:46 Functions: 100.0 % 2 2

            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    METriggeredCalibrator.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @date    Tue, May 2005
      17              : ///
      18              : // Calibrates the flow on a segment to a specified one
      19              : /****************************************************************************/
      20              : #pragma once
      21              : #include <config.h>
      22              : 
      23              : #include <string>
      24              : #include <vector>
      25              : #include <microsim/trigger/MSCalibrator.h>
      26              : #include <mesosim/MESegment.h>
      27              : 
      28              : 
      29              : // ===========================================================================
      30              : // class definitions
      31              : // ===========================================================================
      32              : /**
      33              :  * @class METriggeredCalibrator
      34              :  * @brief Calibrates the flow on a segment to a specified one
      35              :  */
      36              : class METriggeredCalibrator : public MSCalibrator {
      37              : public:
      38              :     /** constructor */
      39              :     METriggeredCalibrator(const std::string& id,
      40              :                           MSEdge* const edge, const double pos,
      41              :                           const std::string& aXMLFilename,
      42              :                           const std::string& outputFilename,
      43              :                           const SUMOTime freq, const double length,
      44              :                           const MSRouteProbe* probe,
      45              :                           const double invalidJamThreshold,
      46              :                           const std::string& vTypes);
      47              : 
      48              :     /** destructor */
      49              :     virtual ~METriggeredCalibrator();
      50              : 
      51              : 
      52              :     /** the implementation of the MSTrigger / Command interface.
      53              :         Calibrating takes place here. */
      54              :     SUMOTime execute(SUMOTime currentTime);
      55              : 
      56              : protected:
      57              : 
      58              :     bool tryEmit(MESegment* s, MEVehicle* vehicle);
      59              : 
      60        54448 :     inline int passed() const {
      61              :         // calibrator measures at start of segment
      62        54448 :         return myEdgeMeanData.nVehEntered + myEdgeMeanData.nVehDeparted - myEdgeMeanData.nVehVaporized;
      63              :     }
      64              : 
      65              :     /// @brief returns whether the segment is jammed although it should not be
      66              :     bool invalidJam() const;
      67              : 
      68              :     /// @brief returns the number of vehicles (of the current type) that still fit onto the segment
      69              :     int remainingVehicleCapacity() const;
      70              : 
      71              :     /// @brief reset collected vehicle data
      72              :     void reset();
      73              : 
      74              :     /// @brief do nothing
      75          123 :     void updateMeanData() {}
      76              : 
      77              :     /// @brief returns the maximum number of vehicles that could enter from upstream until the calibrator is activated again
      78              :     inline int maximumInflow() const {
      79        76041 :         return (int)std::ceil((double)myFrequency / (double)mySegment->getMinimumHeadwayTime());
      80              :     }
      81              : 
      82              : private:
      83              :     /// @brief mesoscopic edge segment the calibrator lies on
      84              :     MESegment* mySegment;
      85              : 
      86              : };
        

Generated by: LCOV version 2.0-1