Eclipse SUMO - Simulation of Urban MObility
MSDevice_Emissions.h
Go to the documentation of this file.
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 /****************************************************************************/
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>
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 // ===========================================================================
57 public:
60  static void insertOptions(OptionsCont& oc);
61 
62 
75  static void buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into);
76 
77 
78 public:
84 
87 
90 
105  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
106 
116  bool notifyIdle(SUMOTrafficObject& veh);
117 
119 
121  const std::string deviceName() const {
122  return "emissions";
123  }
124 
131  void generateOutput(OutputDevice* tripinfoOut) const;
132 
134  return myWrittenAttributes;
135  }
136 
138  static void cleanup();
139 
140 
141 protected:
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:
157 
161  static bool myAmInitialized;
162 
164  static void initOnce();
165 
166 private:
169 
172 
173 };
std::bitset< 96 > SumoXMLAttrMask
A device which collects vehicular emissions.
void generateOutput(OutputDevice *tripinfoOut) const
Called on writing tripinfo output.
bool notifyIdle(SUMOTrafficObject &veh)
Computes idling emission values and adds them to the emission sums.
MSDevice_Emissions & operator=(const MSDevice_Emissions &)
Invalidated assignment operator.
static SumoXMLAttrMask getWrittenAttributes()
static SumoXMLAttrMask myWrittenAttributes
bit mask for checking attributes to be written
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Computes current emission values and adds them to their sums.
const std::string deviceName() const
return the name for this type of device
static void cleanup()
resets the attribute mask
MSDevice_Emissions(SUMOVehicle &holder)
Constructor.
static SumoXMLAttrMask getDefaultMask()
static void insertOptions(OptionsCont &oc)
Inserts MSDevice_Emissions-options.
static void buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into)
Build devices for the given vehicle, if needed.
void notifyMoveInternal(const SUMOTrafficObject &veh, const double frontOnLane, const double timeOnLane, const double meanSpeedFrontOnLane, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double meanLengthOnLane)
Internal notification about the vehicle moves, see MSMoveReminder::notifyMoveInternal()
PollutantsInterface::Emissions myEmissions
Internal storages for pollutant/fuel sum in mg or ml.
~MSDevice_Emissions()
Destructor.
static void initOnce()
initialize attribute mask (once)
MSDevice_Emissions(const MSDevice_Emissions &)
Invalidated copy constructor.
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
Abstract in-vehicle device.
A storage for options typed value containers)
Definition: OptionsCont.h:89
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition: SUMOVehicle.h:62
Storage for collected values of all emission types.