Skip to content

Commit

Permalink
access to mass inside energy params #15024
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Dec 9, 2024
1 parent b21ab68 commit fd285aa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/microsim/MSVehicleType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ void
MSVehicleType::setMass(double mass) {
myParameter.mass = mass;
myParameter.parametersSet |= VTYPEPARS_MASS_SET;
const_cast<EnergyParams&>(myEnergyParams).setMass(mass);
}


Expand Down
2 changes: 1 addition & 1 deletion src/microsim/MSVehicleType.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class MSVehicleType {
* @return The mass of this vehicle type
*/
inline double getMass() const {
return myParameter.mass;
return myEnergyParams.getDouble(SUMO_ATTR_MASS);
}


Expand Down
13 changes: 13 additions & 0 deletions src/utils/emissions/EnergyParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,19 @@ EnergyParams::setDynamicValues(const SUMOTime stopDuration, const bool parking,
}


void
EnergyParams::setMass(const double mass) {
myMap[SUMO_ATTR_MASS] = mass;
myHaveDefaultMass = false;
}


void
EnergyParams::setTransportableMass(const double mass) {
myTransportableMass = mass;
}


double
EnergyParams::getAngleDiff() const {
return myLastAngle == INVALID_DOUBLE ? 0. : GeomHelper::angleDiff(myLastAngle, myAngle);
Expand Down
8 changes: 8 additions & 0 deletions src/utils/emissions/EnergyParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ class EnergyParams {
}

void setDynamicValues(const SUMOTime stopDuration, const bool parking, const SUMOTime waitingTime, const double angle);
void setMass(const double mass);

double getTransportableMass() const {
return myTransportableMass;
}

void setTransportableMass(const double mass);

double getAngleDiff() const;

Expand Down Expand Up @@ -114,6 +121,7 @@ class EnergyParams {
double myWaitingTimeSeconds = -1.;
double myLastAngle = INVALID_DOUBLE;
double myAngle = INVALID_DOUBLE;
double myTransportableMass = 0.;

static const EnergyParams* myDefault;
static const std::vector<SumoXMLAttr> myParamAttrs;
Expand Down

0 comments on commit fd285aa

Please sign in to comment.