LCOV - code coverage report
Current view: top level - src/microsim/devices - MSDevice_Emissions.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 33.3 % 3 1
Test Date: 2024-11-22 15:46:21 Functions: 0.0 % 1 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              :     static SumoXMLAttrMask getWrittenAttributes() {
     134        43388 :         return myWrittenAttributes;
     135              :     }
     136              : 
     137              :     /// @brief resets the attribute mask
     138              :     static void cleanup();
     139              : 
     140              : 
     141              : protected:
     142              :     /** @brief Internal notification about the vehicle moves, see MSMoveReminder::notifyMoveInternal()
     143              :      *
     144              :      */
     145              :     void notifyMoveInternal(const SUMOTrafficObject& veh,
     146              :                             const double frontOnLane,
     147              :                             const double timeOnLane,
     148              :                             const double meanSpeedFrontOnLane,
     149              :                             const double meanSpeedVehicleOnLane,
     150              :                             const double travelledDistanceFrontOnLane,
     151              :                             const double travelledDistanceVehicleOnLane,
     152              :                             const double meanLengthOnLane);
     153              : 
     154              : private:
     155              :     /// @brief Internal storages for pollutant/fuel sum in mg or ml
     156              :     PollutantsInterface::Emissions myEmissions;
     157              : 
     158              :     /// @brief bit mask for checking attributes to be written
     159              :     static SumoXMLAttrMask myWrittenAttributes;
     160              :     static SumoXMLAttrMask getDefaultMask();
     161              :     static bool myAmInitialized;
     162              : 
     163              :     /// @brief initialize attribute mask (once)
     164              :     static void initOnce();
     165              : 
     166              : private:
     167              :     /// @brief Invalidated copy constructor.
     168              :     MSDevice_Emissions(const MSDevice_Emissions&);
     169              : 
     170              :     /// @brief Invalidated assignment operator.
     171              :     MSDevice_Emissions& operator=(const MSDevice_Emissions&);
     172              : 
     173              : };
        

Generated by: LCOV version 2.0-1