Skip to content

Commit

Permalink
propagated SetCumulatiive trait/macro
Browse files Browse the repository at this point in the history
  • Loading branch information
calbaker committed Jan 20, 2025
1 parent 6a09c4a commit 2b33fe0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
5 changes: 2 additions & 3 deletions fastsim-core/src/vehicle/cabin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,13 @@ pub struct LumpedCabin {
pub history: LumpedCabinStateHistoryVec,
// TODO: add `save_interval` and associated method
}

impl SerdeAPI for LumpedCabin {}
impl Init for LumpedCabin {}
impl SetCumulative for LumpedCabin {
fn set_cumulative(&mut self, dt: si::Time) {
self.state.set_cumulative(dt);
}
}
impl SerdeAPI for LumpedCabin {}
impl Init for LumpedCabin {}

impl LumpedCabin {
/// Solve temperatures, HVAC powers, and cumulative energies of cabin and HVAC system
Expand Down
13 changes: 13 additions & 0 deletions fastsim-core/src/vehicle/powertrain/fuel_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,14 @@ impl Init for FuelConverterThermalOption {
}
}
impl SerdeAPI for FuelConverterThermalOption {}
impl SetCumulative for FuelConverterThermalOption {
fn set_cumulative(&mut self, dt: si::Time) {
match self {
Self::FuelConverterThermal(fct) => fct.set_cumulative(dt),
Self::None => {}
}
}
}
impl FuelConverterThermalOption {
/// Solve change in temperature and other thermal effects
/// # Arguments
Expand Down Expand Up @@ -669,6 +677,11 @@ impl FuelConverterThermal {
}
}
impl SerdeAPI for FuelConverterThermal {}
impl SetCumulative for FuelConverterThermal {
fn set_cumulative(&mut self, dt: si::Time) {
self.state.set_cumulative(dt);
}
}
impl Init for FuelConverterThermal {
fn init(&mut self) -> anyhow::Result<()> {
self.tstat_te_sto = self
Expand Down
15 changes: 13 additions & 2 deletions fastsim-core/src/vehicle/powertrain/reversible_energy_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,6 @@ impl Default for ReversibleEnergyStorageState {
}
}
}

impl Init for ReversibleEnergyStorageState {}
impl SerdeAPI for ReversibleEnergyStorageState {}

Expand All @@ -723,6 +722,14 @@ pub enum RESThermalOption {
#[default]
None,
}
impl SetCumulative for RESThermalOption {
fn set_cumulative(&mut self, dt: si::Time) {
match self {
Self::RESLumpedThermal(rlt) => rlt.set_cumulative(dt),
Self::None => {}
}
}
}
impl SaveState for RESThermalOption {
fn save_state(&mut self) {
match self {
Expand Down Expand Up @@ -814,7 +821,11 @@ pub struct RESLumpedThermal {
pub history: RESLumpedThermalStateHistoryVec,
// TODO: add `save_interval` and associated methods
}

impl SetCumulative for RESLumpedThermal {
fn set_cumulative(&mut self, dt: si::Time) {
self.state.set_cumulative(dt);
}
}
impl SerdeAPI for RESLumpedThermal {}
impl Init for RESLumpedThermal {}
impl RESLumpedThermal {
Expand Down

0 comments on commit 2b33fe0

Please sign in to comment.