37 #define IDLE_SPEED (10 / 3.6) 55 if (eClass.size() < 6) {
59 const std::string type = eClass.substr(0, 3);
60 if (type ==
"HDV" || type ==
"LB_" || type ==
"RB_" || type ==
"LSZ" || eClass.find(
"LKW") != std::string::npos) {
67 std::vector<std::string> phemPath;
69 if (getenv(
"PHEMLIGHT_PATH") !=
nullptr) {
70 phemPath.push_back(std::string(getenv(
"PHEMLIGHT_PATH")) +
"/");
72 if (getenv(
"SUMO_HOME") !=
nullptr) {
73 phemPath.push_back(std::string(getenv(
"SUMO_HOME")) +
"/data/emissions/PHEMlight/");
87 std::string eclower = eClass;
88 std::transform(eclower.begin(), eclower.end(), eclower.begin(), tolower);
96 std::string eClassOffset =
"0";
97 if (eClass.length() == 5 && eClass.substr(0, 4) ==
"Euro") {
98 if (eClass[4] >=
'0' && eClass[4] <=
'6') {
99 eClassOffset = eClass.substr(4, 1);
103 if (vClass ==
"Passenger") {
105 if (fuel ==
"Gasoline") {
107 }
else if (fuel ==
"Diesel") {
109 }
else if (fuel ==
"HybridGasoline") {
110 desc =
"H_" + desc +
"G_";
111 }
else if (fuel ==
"HybridDiesel") {
112 desc =
"H_" + desc +
"G_";
114 desc +=
"EU" + eClassOffset;
115 }
else if (vClass ==
"Moped") {
116 desc =
"KKR_G_EU" + eClassOffset;
117 }
else if (vClass ==
"Motorcycle") {
118 desc =
"MR_G_EU" + eClassOffset;
119 if (fuel ==
"Gasoline2S") {
124 }
else if (vClass ==
"Delivery") {
126 if (fuel ==
"Gasoline") {
128 }
else if (fuel ==
"Diesel") {
131 desc +=
"EU" + eClassOffset +
"_I";
132 if (weight > 1305.) {
134 if (weight > 1760.) {
138 }
else if (vClass ==
"UrbanBus") {
139 desc =
"LB_D_EU" + eClassOffset;
140 }
else if (vClass ==
"Coach") {
141 desc =
"RB_D_EU" + eClassOffset;
142 }
else if (vClass ==
"Truck") {
143 desc =
"Solo_LKW_D_EU" + eClassOffset +
"_I";
144 if (weight > 1305.) {
147 }
else if (vClass ==
"Trailer") {
148 desc =
"LSZ_D_EU" + eClassOffset;
160 if (name.find(
"KKR_") != std::string::npos) {
162 }
else if (name.find(
"RB_") != std::string::npos) {
164 }
else if (name.find(
"LB_") != std::string::npos) {
166 }
else if (name.find(
"LNF_") != std::string::npos) {
168 }
else if (name.find(
"LSZ_") != std::string::npos) {
170 }
else if (name.find(
"MR_") != std::string::npos) {
172 }
else if (name.find(
"LKW_") != std::string::npos) {
182 std::string fuel =
"Gasoline";
183 if (name.find(
"_D_") != std::string::npos) {
186 if (name.find(
"H_") != std::string::npos) {
187 fuel =
"Hybrid" + fuel;
196 if (name.find(
"_EU1") != std::string::npos) {
198 }
else if (name.find(
"_EU2") != std::string::npos) {
200 }
else if (name.find(
"_EU3") != std::string::npos) {
202 }
else if (name.find(
"_EU4") != std::string::npos) {
204 }
else if (name.find(
"_EU5") != std::string::npos) {
206 }
else if (name.find(
"_EU6") != std::string::npos) {
216 if (name.find(
"LNF_") != std::string::npos) {
217 if (name.find(
"_III") != std::string::npos) {
219 }
else if (name.find(
"_II") != std::string::npos) {
221 }
else if (name.find(
"_I") != std::string::npos) {
225 if (name.find(
"Solo_LKW_") != std::string::npos) {
226 if (name.find(
"_II") != std::string::npos) {
228 }
else if (name.find(
"_I") != std::string::npos) {
238 if (oldCep !=
nullptr) {
248 if (currCep !=
nullptr) {
260 const double corrSpeed =
MAX2((
double) 0.0, v);
264 if (oldCep !=
nullptr) {
265 if (v >
IDLE_SPEED && a < oldCep->GetDecelCoast(corrSpeed, a, slope, 0)) {
270 power = oldCep->
CalcPower(corrSpeed, a, slope);
273 const PHEMCEP*
const oldCep = 0;
276 if (currCep !=
nullptr) {
282 power = currCep->
CalcPower(corrSpeed, corrAcc, slope);
289 if (oldCep !=
nullptr) {
293 getEmission(
nullptr, currCep,
"CO", power, corrSpeed),
Data Handler for a single CEP emission data set.
double getModifiedAccel(const SUMOEmissionClass c, const double v, const double a, const double slope) const
Returns the adapted acceleration value, useful for comparing with external PHEMlight references...
void remove(const std::string str, const T key)
double getWeight(const SUMOEmissionClass c) const
Returns a reference weight in kg described by this emission class as described in the Amitran interfa...
double getEmission(const PHEMCEP *oldCep, PHEMlightdll::CEP *currCep, const std::string &e, const double p, const double v) const
Returns the amount of emitted pollutant given the vehicle type and state (in mg/s or in ml/s for fuel...
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types...
double GetEmission(const std::string &pollutant, double power, double speed, Helpers *VehicleClass)
int myIndex
the index of the next class
const std::string & getString(const T key) const
HelpersPHEMlight()
Constructor.
EmissionType
Enumerating all emission types, including fuel.
bool setclass(const std::string &VEH)
double CalcPower(double v, double a, double slope, double vehicleLoading=0) const
Returns the power of used for a vehicle at state v,a, slope and loading.
std::string getFuel(const SUMOEmissionClass c) const
Returns the fuel type described by this emission class as described in the Amitran interface (Gasolin...
static const int HEAVY_BIT
the bit to set for denoting heavy vehicles
const std::string & getErrMsg() const
static OptionsCont & getOptions()
Retrieves the options.
static PHEMCEPHandler & getHandlerInstance()
Implementatio of Singelton pattern.
std::map< SUMOEmissionClass, PHEMlightdll::CEP * > myCEPs
void insert(const std::string str, const T key, bool checkDuplicates=true)
double GetEmission(const std::string &pollutantIdentifier, double power, double speed, bool normalized=false) const
Returns a emission measure for power[kW] level.
bool GetCEP(const std::vector< std::string > &DataPath, Helpers *Helper)
void addAlias(const std::string str, const T key)
double compute(const SUMOEmissionClass c, const PollutantsInterface::EmissionType e, const double v, const double a, const double slope, const std::map< int, double > *param) const
Returns the amount of emitted pollutant given the vehicle type and state (in mg/s or in ml/s for fuel...
T get(const std::string &str) const
static const std::string strDiesel
double GetDecelCoast(double speed, double acc, double gradient)
const std::string & GetVehicleFuelType() const
Getter function to recieve vehicle data from CEP.
const double SECONDS_PER_HOUR
static const int PHEMLIGHT_BASE
static const std::string strGasoline
double GetMaxAccel(double speed, double gradient)
StringBijection< SUMOEmissionClass > myEmissionClassStrings
Mapping between emission class names and integer representations.
SUMOEmissionClass getClassByName(const std::string &eClass, const SUMOVehicleClass vc)
Checks whether the string describes a known vehicle class.
int getEuroClass(const SUMOEmissionClass c) const
Returns the Euro emission class described by this emission class as described in the Amitran interfac...
static const std::string strBEV
void setCommentPrefix(const std::string &value)
PHEMCEP * GetCep(SUMOEmissionClass emissionClass)
Returns the CEP data for a PHEM emission class.
const std::map< std::string, CEP * > & getCEPS() const
PHEMlightdll::Helpers myHelper
PHEMlightdll::CEPHandler myCEPHandler
const std::string & getgClass() const
bool hasString(const std::string &str) const
static const double ZERO_SPEED_ACCURACY
double CalcPower(double speed, double acc, double gradient)
std::string getAmitranVehicleClass(const SUMOEmissionClass c) const
Returns the vehicle class described by this emission class as described in the Amitran interface (Pas...
SUMOEmissionClass getClass(const SUMOEmissionClass base, const std::string &vClass, const std::string &fuel, const std::string &eClass, const double weight) const
Returns the emission class described by the given parameters.
const std::string & getFuelType() const
double GetCO2Emission(double _FC, double _CO, double _HC, Helpers *VehicleClass)
Helper methods for PHEMlight-based emission computation.
void setPHEMDataV(const std::string &value)