/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2002-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file EnergyParams.h14/// @author Jakob Erdmann15/// @author Michael Behrisch16/// @date Sept 202117///18// A class for parameters used by the emission models19/****************************************************************************/20#pragma once21#include <config.h>22#include <map>23#include <string>24#include <vector>25#include <utils/common/SUMOVehicleClass.h>26#include <utils/common/ToString.h>27#include <utils/emissions/CharacteristicMap.h>28#include <utils/xml/SUMOXMLDefinitions.h>293031// ===========================================================================32// class declarations33// ===========================================================================34class SUMOVTypeParameter;353637// ===========================================================================38// class definitions39// ===========================================================================40/**41* @class EnergyParams42* @brief An upper class for objects with additional parameters43*/44class EnergyParams {45public:46/// @brief Constructor47EnergyParams(const SUMOVTypeParameter* typeParams = nullptr);4849/// @brief Constructor50EnergyParams(const EnergyParams* secondaryParams) : mySecondaryParams(secondaryParams) {}5152/// @brief Destructor53~EnergyParams();5455/**@brief Set secondary params56* @param[in] secondaryParams The secondary parameters57*/58void setSecondary(const EnergyParams* secondaryParams) {59mySecondaryParams = secondaryParams;60}6162/**@brief Sets the values which change possibly in every simulation step and are relevant for emsssion calculation63* @param[in] stopDuration the total duration of the current stop (-1 means no current stop)64* @param[in] parking whether the current stop is a parking stop (only meaningful if stopDuration != -1)65* @param[in] waitingTime the current total waiting time66* @param[in] angle the current absolute angle of the vehicle67*/68void setDynamicValues(const SUMOTime stopDuration, const bool parking, const SUMOTime waitingTime, const double angle);6970/**@brief Sets the empty mass of the vehicle (type)71* This is to be used by traci/libsumo72* @param[in] mass the new mass73*/74void setMass(const double mass);7576/**@brief Returns the mass of all transportables in the vehicle77* @return The total mass of persons and containers in kg78*/79double getTransportableMass() const {80return myTransportableMass;81}8283/**@brief Sets the mass of all transportables in the vehicle84* @param[in] mass the new mass85*/86void setTransportableMass(const double mass);8788/**@brief Returns the sum of the empty mass (SUMO_ATTR_MASS), tthe loading (SUMO_ATTR_LOADING) and the mass of all transportables in the vehicle89* @return The total mass in kg90*/91double getTotalMass(const double defaultEmptyMass, const double defaultLoading) const;9293/**@brief Returns the angle difference between the last two calls of setDynamicValues (usually the last two time steps)94* @return The angle difference in radians95*/96double getAngleDiff() const;9798/**@brief Returns the value for a given key99* @param[in] key The key to ask for100* @return The value stored under the key101*/102double getDouble(SumoXMLAttr attr) const;103104/**@brief Returns the value for a given key with an optional default.105* SUMO_ATTR_MASS and SUMO_ATTR_FRONTSURFACEAREA get a special treatment and return the given def value106* also if the map has a value which is flagged as default.107* @param[in] key The key to ask for108* @param[in] def The default value if no value is stored or the stored value is flagged as default109* @return The value stored under the key110*/111double getDoubleOptional(SumoXMLAttr attr, const double def) const;112113/**114* @brief Return the CharacteristicMap that belongs to a given attribute.115*116* @param[in] attr Name of an attribute117* @return A CharacteristicMap118*/119const CharacteristicMap& getCharacteristicMap(SumoXMLAttr attr) const;120121/// @brief Returns a complete inner description122const std::string dump() const {123return joinToString(myMap, ", ", ":") + (mySecondaryParams ? mySecondaryParams->dump() : "");124}125126/** @brief Returns the state of the engine when the vehicle is not moving127* @return whether the engine is running128*/129bool isEngineOff() const;130131/** @brief Returns whether the vehicle is currently consuming any energy derived from the parking state132* @return whether the vehicle has any consumption133*/134bool isOff() const;135136static const EnergyParams* getDefault() {137if (myDefault == nullptr) {138myDefault = new EnergyParams();139}140return myDefault;141}142143private:144/// @brief The key->value maps145std::map<SumoXMLAttr, double> myMap;146std::map<SumoXMLAttr, CharacteristicMap> myCharacteristicMapMap;147const EnergyParams* mySecondaryParams = nullptr;148bool myHaveDefaultMass = false;149bool myHaveDefaultFrontSurfaceArea = false;150double myStopDurationSeconds = -1.;151bool myAmParking = false;152double myWaitingTimeSeconds = -1.;153double myLastAngle = INVALID_DOUBLE;154double myAngle = INVALID_DOUBLE;155double myTransportableMass = 0.;156157static const EnergyParams* myDefault;158static const std::vector<SumoXMLAttr> myParamAttrs;159160/// @brief invalidate copy constructor161EnergyParams(const EnergyParams& s) = delete;162163/// @brief invalidate assignment operator164EnergyParams& operator=(const EnergyParams& s) = delete;165};166167168