From addc6797f51a056f49f2b470a238426f27510030 Mon Sep 17 00:00:00 2001 From: Michael Behrisch Date: Thu, 28 Nov 2024 21:59:47 +0100 Subject: [PATCH] adapting warnings about emission class parameters #21 --- src/utils/emissions/EnergyParams.cpp | 22 ++++++++++++------- .../nefz_energy_vtype/errors.complex | 4 ++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/utils/emissions/EnergyParams.cpp b/src/utils/emissions/EnergyParams.cpp index 1c2c43953433..7cfadf38b7bc 100644 --- a/src/utils/emissions/EnergyParams.cpp +++ b/src/utils/emissions/EnergyParams.cpp @@ -70,15 +70,21 @@ EnergyParams::EnergyParams(const SUMOVTypeParameter* typeParams) { if (typeParams->wasSet(VTYPEPARS_MASS_SET)) { myMap[SUMO_ATTR_MASS] = typeParams->mass; } - if (typeParams->wasSet(VTYPEPARS_WIDTH_SET)) { - myMap[SUMO_ATTR_WIDTH] = typeParams->width; - } - if (typeParams->wasSet(VTYPEPARS_HEIGHT_SET)) { - myMap[SUMO_ATTR_HEIGHT] = typeParams->height; + myMap[SUMO_ATTR_WIDTH] = typeParams->width; + myMap[SUMO_ATTR_HEIGHT] = typeParams->height; + const std::string& ecName = PollutantsInterface::getName(typeParams->emissionClass); + if ((typeParams->vehicleClass & (SVC_PASSENGER | SVC_HOV | SVC_TAXI | SVC_E_VEHICLE)) == 0 && myMap.count(SUMO_ATTR_FRONTSURFACEAREA) == 0) { + if (StringUtils::startsWith(ecName, "MMPEVEM") || StringUtils::startsWith(ecName, "Energy")) { + WRITE_WARNINGF(TL("Vehicle type '%' uses the emission class '%' which does not have proper defaults for its vehicle class. " + "Please use a different emission class or complete the vType definition with further parameters."), typeParams->id, ecName); + if (!typeParams->wasSet(VTYPEPARS_MASS_SET)) { + WRITE_WARNING(TL(" And also set a vehicle mass!")); + } + } } - if (!StringUtils::startsWith(PollutantsInterface::getName(typeParams->emissionClass), "MMPEVEM")) { - if (typeParams->hasParameter(toString(SUMO_ATTR_INTERNALMOMENTOFINERTIA))) { - WRITE_WARNINGF(TL("Vehicle type '%' uses the Energy model with parameter 'internalMomentOfInertia' which is deprecated. Use 'rotatingMass' instead."), typeParams->id); + if (!StringUtils::startsWith(ecName, "MMPEVEM")) { + if (myMap.count(SUMO_ATTR_INTERNALMOMENTOFINERTIA) > 0) { + WRITE_WARNINGF(TL("Vehicle type '%' uses the Energy model parameter 'internalMomentOfInertia' which is deprecated. Use 'rotatingMass' instead."), typeParams->id); if (!typeParams->hasParameter(toString(SUMO_ATTR_ROTATINGMASS))) { myMap[SUMO_ATTR_ROTATINGMASS] = myMap[SUMO_ATTR_INTERNALMOMENTOFINERTIA]; } diff --git a/tests/complex/emissions/nefz_energy_vtype/errors.complex b/tests/complex/emissions/nefz_energy_vtype/errors.complex index d352c93dd464..0f17faec2a48 100644 --- a/tests/complex/emissions/nefz_energy_vtype/errors.complex +++ b/tests/complex/emissions/nefz_energy_vtype/errors.complex @@ -1,2 +1,2 @@ -Warning: Vehicle type 'soulEV65' uses the Energy model with parameter 'internalMomentOfInertia' which is deprecated. Use 'rotatingMass' instead. -Warning: Vehicle type 'soulEV65' uses the Energy model with parameter 'internalMomentOfInertia' which is deprecated. Use 'rotatingMass' instead. +Warning: Vehicle type 'soulEV65' uses the Energy model parameter 'internalMomentOfInertia' which is deprecated. Use 'rotatingMass' instead. +Warning: Vehicle type 'soulEV65' uses the Energy model parameter 'internalMomentOfInertia' which is deprecated. Use 'rotatingMass' instead.