Path: blob/main/src/foreign/PHEMlight/V5/cpp/CEPHandler.h
169688 views
/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2016-2025 German Aerospace Center (DLR) and others.3// PHEMlight module4// Copyright (C) 2016-2023 Technische Universitaet Graz, https://www.tugraz.at/5// This program and the accompanying materials are made available under the6// terms of the Eclipse Public License 2.0 which is available at7// https://www.eclipse.org/legal/epl-2.0/8// This Source Code may also be made available under the following Secondary9// Licenses when the conditions for such availability set forth in the Eclipse10// Public License 2.0 are satisfied: GNU General Public License, version 211// or later which is available at12// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html13// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later14/****************************************************************************/15/// @file CEPHandler.h16/// @author Martin Dippold17/// @author Michael Behrisch18/// @date July 201619///20//21/****************************************************************************/22#pragma once2324#include <string>25#include <map>26#include <vector>27#include <utility>2829//C# TO C++ CONVERTER NOTE: Forward class declarations:30namespace PHEMlightdllV5 { class CEP; }31namespace PHEMlightdllV5 { class Correction; }32namespace PHEMlightdllV5 { class Helpers; }33namespace PHEMlightdllV5 { class VEHPHEMLightJSON; }34namespace PHEMlightdllV5 { class Vehicle_Data; }35namespace PHEMlightdllV5 { class VEH; }36namespace PHEMlightdllV5 { class Aux_Data; }37namespace PHEMlightdllV5 { class Engine_Data; }38namespace PHEMlightdllV5 { class Rollres_Data; }39namespace PHEMlightdllV5 { class FullLoadDrag_Data; }40namespace PHEMlightdllV5 { class Transmission_Data; }41namespace PHEMlightdllV5 { class ICE_Data; }42namespace PHEMlightdllV5 { class EM_Data; }4344namespace PHEMlightdllV5 {45//PHEMLight vehicle46class VEHPHEMLightJSON {47// Vehicle data48public:49class Vehicle_Data {50private:51std::string privateMassType;52std::string privateFuelType;53std::string privateCalcType;54double privateMass;55double privateLoading;56double privateRedMassWheel;57double privateWheelDiameter;58double privateCw;59double privateA;60double privateMileage;6162public:63const std::string& getMassType() const;64void setMassType(const std::string& value);65const std::string& getFuelType() const;66void setFuelType(const std::string& value);67const std::string& getCalcType() const;68void setCalcType(const std::string& value);69const double& getMass() const;70void setMass(const double& value);71const double& getLoading() const;72void setLoading(const double& value);73const double& getRedMassWheel() const;74void setRedMassWheel(const double& value);75const double& getWheelDiameter() const;76void setWheelDiameter(const double& value);77const double& getCw() const;78void setCw(const double& value);79const double& getA() const;80void setA(const double& value);81const double& getMileage() const;82void setMileage(const double& value);83};8485// Rolling resistance data86public:87class Rollres_Data {88private:89double privateFr0;90double privateFr1;91double privateFr2;92double privateFr3;93double privateFr4;9495public:96const double& getFr0() const;97void setFr0(const double& value);98const double& getFr1() const;99void setFr1(const double& value);100const double& getFr2() const;101void setFr2(const double& value);102const double& getFr3() const;103void setFr3(const double& value);104const double& getFr4() const;105void setFr4(const double& value);106};107108// ICE engine109public:110class ICE_Data {111private:112double privatePrated;113double privatenrated;114double privateIdling;115116public:117const double& getPrated() const;118void setPrated(const double& value);119const double& getnrated() const;120void setnrated(const double& value);121const double& getIdling() const;122void setIdling(const double& value);123};124125// EM engine126public:127class EM_Data {128private:129double privatePrated;130double privatenrated;131132public:133const double& getPrated() const;134void setPrated(const double& value);135const double& getnrated() const;136void setnrated(const double& value);137};138139// Engine data140public:141class Engine_Data {142private:143ICE_Data privateICEData;144EM_Data privateEMData;145146public:147ICE_Data* getICEData();148EM_Data* getEMData();149};150151// Auxiliaries data152public:153class Aux_Data {154private:155double privatePauxnorm;156157public:158const double& getPauxnorm() const;159void setPauxnorm(const double& value);160};161162// Full load and Drag data163public:164class FullLoadDrag_Data {165private:166double privateP_n_max_v0;167double privateP_n_max_p0;168double privateP_n_max_v1;169double privateP_n_max_p1;170std::map<std::string, std::vector<double> > privateDragCurve;171172public:173const double& getP_n_max_v0() const;174void setP_n_max_v0(const double& value);175const double& getP_n_max_p0() const;176void setP_n_max_p0(const double& value);177const double& getP_n_max_v1() const;178void setP_n_max_v1(const double& value);179const double& getP_n_max_p1() const;180void setP_n_max_p1(const double& value);181std::map<std::string, std::vector<double> >& getDragCurve();182void setDragCurve(const std::map<std::string, std::vector<double> >& value);183184FullLoadDrag_Data();185};186187// Transmission data188public:189class Transmission_Data {190private:191double privateAxelRatio;192std::map<std::string, std::vector<double> > privateTransm;193194public:195const double& getAxelRatio() const;196void setAxelRatio(const double& value);197std::map<std::string, std::vector<double> >& getTransm();198void setTransm(const std::map<std::string, std::vector<double> >& value);199200Transmission_Data();201};202203//Root object204public:205class VEH {206private:207std::string privateType;208std::string privateVersion;209Vehicle_Data privateVehicleData;210Aux_Data privateAuxiliariesData;211Engine_Data privateEngineData;212Rollres_Data privateRollingResData;213FullLoadDrag_Data privateFLDData;214Transmission_Data privateTransmissionData;215216public:217const std::string& getType() const;218void setType(const std::string& value);219const std::string& getVersion() const;220void setVersion(const std::string& value);221Vehicle_Data* getVehicleData();222Aux_Data* getAuxiliariesData();223Engine_Data* getEngineData();224Rollres_Data* getRollingResData();225FullLoadDrag_Data* getFLDData();226Transmission_Data* getTransmissionData();227};228229};230231class CEPHandler {232public:233CEPHandler();234235private:236std::map<std::string, CEP*> _ceps;237public:238const std::map<std::string, CEP*>& getCEPS() const;239240241bool GetCEP(std::vector<std::string>& DataPath, Helpers* Helper, Correction* DataCor);242243244private:245bool CalcCorrection(Correction* DataCor, Helpers* Helper, VEHPHEMLightJSON::Vehicle_Data* vehicle_Data);246247bool Load(std::vector<std::string>& DataPath, Helpers* Helper, Correction* DataCor, bool fleetMix = false);248249bool ReadVehicleFile(const std::vector<std::string>& DataPath, const std::string& emissionClass, Helpers* Helper, bool fleetMix, VEHPHEMLightJSON::VEH*& Vehicle);250251bool ReadEmissionData(bool readFC, const std::vector<std::string>& DataPath, const std::string& emissionClass, Helpers* Helper, bool fleetMix, Correction* DataCor, std::vector<std::string>& header, std::vector<std::vector<double> >& matrix, std::vector<double>& idlingValues);252253bool CorrectEmissionData(Correction* DataCor, std::vector<std::string>& header, std::vector<std::vector<double> >& matrix, std::vector<double>& idlingValues);254255//Calculate correction factor for detoriation and temperature correction256double GetDetTempCor(Correction* DataCor, const std::string& Emi);257258259//Split the string260const std::vector<std::string> split(const std::string& s, char delim);261262//Convert string to double263double todouble(const std::string& s);264265//Convert string to double list266std::vector<double> todoubleList(const std::vector<std::string>& s);267268//Read a line from file269std::string ReadLine(std::ifstream& s);270};271}272273274