LCOV - code coverage report
Current view: top level - src/microsim/devices - MSDevice_Emissions.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 2 0.0 %
Date: 2024-04-30 15:40:33 Functions: 0 1 0.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    MSDevice_Emissions.h
      15             : /// @author  Daniel Krajzewicz
      16             : /// @author  Michael Behrisch
      17             : /// @date    Fri, 30.01.2009
      18             : ///
      19             : // A device which collects vehicular emissions
      20             : /****************************************************************************/
      21             : #pragma once
      22             : #include <config.h>
      23             : 
      24             : #include <set>
      25             : #include <vector>
      26             : #include <map>
      27             : #include <utils/common/SUMOTime.h>
      28             : #include <utils/common/WrappingCommand.h>
      29             : #include <utils/emissions/PollutantsInterface.h>
      30             : #include <utils/emissions/EnergyParams.h>
      31             : #include <microsim/MSVehicle.h>
      32             : #include "MSVehicleDevice.h"
      33             : 
      34             : 
      35             : // ===========================================================================
      36             : // class declarations
      37             : // ===========================================================================
      38             : class MSLane;
      39             : 
      40             : 
      41             : // ===========================================================================
      42             : // class definitions
      43             : // ===========================================================================
      44             : /**
      45             :  * @class MSDevice_Emissions
      46             :  * @brief A device which collects vehicular emissions
      47             :  *
      48             :  * Each device collects the vehicular emissions / fuel consumption by being
      49             :  *  called each time step, computing the current values using
      50             :  *  PollutantsInterface, and aggregating them into internal storages over
      51             :  *  the complete journey.
      52             :  *
      53             :  * @see MSDevice
      54             :  * @see PollutantsInterface
      55             :  */
      56             : class MSDevice_Emissions : public MSVehicleDevice {
      57             : public:
      58             :     /** @brief Inserts MSDevice_Emissions-options
      59             :      */
      60             :     static void insertOptions(OptionsCont& oc);
      61             : 
      62             : 
      63             :     /** @brief Build devices for the given vehicle, if needed
      64             :      *
      65             :      * The options are read and evaluated whether emissions-devices shall be built
      66             :      *  for the given vehicle.
      67             :      *
      68             :      * For each seen vehicle, the global vehicle index is increased.
      69             :      *
      70             :      * The built device is stored in the given vector.
      71             :      *
      72             :      * @param[in] v The vehicle for which a device may be built
      73             :      * @param[in, filled] into The vector to store the built device in
      74             :      */
      75             :     static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
      76             : 
      77             : 
      78             : public:
      79             :     /** @brief Constructor
      80             :      *
      81             :      * @param[in] holder The vehicle that holds this device
      82             :      */
      83             :     MSDevice_Emissions(SUMOVehicle& holder);
      84             : 
      85             :     /// @brief Destructor.
      86             :     ~MSDevice_Emissions();
      87             : 
      88             :     /// @name Methods called on vehicle movement / state change, overwriting MSDevice
      89             :     /// @{
      90             : 
      91             :     /** @brief Computes current emission values and adds them to their sums
      92             :         *
      93             :         * The vehicle's current emission values
      94             :         *  are computed using the current velocity and acceleration.
      95             :         *
      96             :         * @param[in] veh The regarded vehicle
      97             :         * @param[in] oldPos Position before the move-micro-timestep.
      98             :         * @param[in] newPos Position after the move-micro-timestep.
      99             :         * @param[in] newSpeed The vehicle's current speed
     100             :         * @return false, if the vehicle is beyond the lane, true otherwise
     101             :         * @see MSMoveReminder
     102             :         * @see MSMoveReminder::notifyMove
     103             :         * @see PollutantsInterface
     104             :         */
     105             :     bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
     106             : 
     107             :     /** @brief Computes idling emission values and adds them to the emission sums
     108             :         *
     109             :         * Idling implied by zero velocity, acceleration and slope
     110             :         *
     111             :         * @param[in] veh The vehicle
     112             :         *
     113             :         * @see MSMoveReminder::notifyMove
     114             :         * @see PollutantsInterface
     115             :         */
     116             :     bool notifyIdle(SUMOTrafficObject& veh);
     117             : 
     118             :     /// @}
     119             : 
     120             :     /// @brief return the name for this type of device
     121           0 :     const std::string deviceName() const {
     122           0 :         return "emissions";
     123             :     }
     124             : 
     125             :     /** @brief Called on writing tripinfo output
     126             :      *
     127             :      * @param[in] os The stream to write the information into
     128             :      * @exception IOError not yet implemented
     129             :      * @see MSDevice::tripInfoOutput
     130             :      */
     131             :     void generateOutput(OutputDevice* tripinfoOut) const;
     132             : 
     133             : protected:
     134             :     /** @brief Internal notification about the vehicle moves, see MSMoveReminder::notifyMoveInternal()
     135             :      *
     136             :      */
     137             :     void notifyMoveInternal(const SUMOTrafficObject& veh,
     138             :                             const double frontOnLane,
     139             :                             const double timeOnLane,
     140             :                             const double meanSpeedFrontOnLane,
     141             :                             const double meanSpeedVehicleOnLane,
     142             :                             const double travelledDistanceFrontOnLane,
     143             :                             const double travelledDistanceVehicleOnLane,
     144             :                             const double meanLengthOnLane);
     145             : 
     146             : private:
     147             :     /// @brief Internal storages for pollutant/fuel sum in mg or ml
     148             :     PollutantsInterface::Emissions myEmissions;
     149             : 
     150             : private:
     151             :     /// @brief Invalidated copy constructor.
     152             :     MSDevice_Emissions(const MSDevice_Emissions&);
     153             : 
     154             :     /// @brief Invalidated assignment operator.
     155             :     MSDevice_Emissions& operator=(const MSDevice_Emissions&);
     156             : 
     157             : };

Generated by: LCOV version 1.14