pub struct HeatingStatsEntry {
pub date: NaiveDate,
pub energy: f64,
pub ambient_temperature_average_value: f64,
pub ambient_temperature_average_counter: i64,
pub water_temperature_average_value: f64,
pub water_temperature_average_counter: i64,
pub heating_control_runtime: i64,
}Expand description
Holds the statistical data of heating for one day. It is filled with post-processed data from a database query which is then updated by the control application.
Fields§
§date: NaiveDatecalendar date of the entry after having postprocessed the SQL data read as String
energy: f64energy used for heating on a specific date in kWh
ambient_temperature_average_value: f64average ambient temperature value on a specific date in °C
ambient_temperature_average_counter: i64counter how many samples were used to calculate the average value
water_temperature_average_value: f64average water temperature value on a specific date in °C
water_temperature_average_counter: i64counter how many samples were used to calculate the average value
heating_control_runtime: i64counter how many seconds the heating control was active on a specific date
Implementations§
Source§impl HeatingStatsEntry
impl HeatingStatsEntry
Sourcepub fn new(conn: &mut PooledConn) -> HeatingStatsEntry
pub fn new(conn: &mut PooledConn) -> HeatingStatsEntry
Creates a new HeatingStatsEntry initialized for the current local date.
This constructor is used when there’s no existing heating statistics
record for the current day in the database. It sets the date field to today’s
date and initializes all statistical counters and values to zero.
§Returns
A new HeatingStatsEntry struct with default values for the current date.
Sourcepub fn update(
&mut self,
water_temperature_opt: Option<f64>,
ambient_temperature_opt: Option<f64>,
energy_increment: f64,
)
pub fn update( &mut self, water_temperature_opt: Option<f64>, ambient_temperature_opt: Option<f64>, energy_increment: f64, )
Updates the heating statistics entry with new sensor readings and energy consumption data.
This method incorporates new samples to incrementally calculate average water and ambient temperatures, sum up energy consumption, and track the heating control’s active runtime.
§Arguments
water_temperature_opt- AnOption<f64>representing the latest water temperature reading. IfSome, it contributes to the average; ifNone, the water temperature average remains unchanged.ambient_temperature_opt- AnOption<f64>representing the latest ambient air temperature reading. IfSome, it contributes to the average; ifNone, the ambient temperature average remains unchanged.energy_increment- The amount of energy (in kWh) consumed by the heater since the last update.
Trait Implementations§
Source§impl Clone for HeatingStatsEntry
impl Clone for HeatingStatsEntry
Source§fn clone(&self) -> HeatingStatsEntry
fn clone(&self) -> HeatingStatsEntry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Display for HeatingStatsEntry
impl Display for HeatingStatsEntry
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the HeatingStatsEntry struct into a multi-line, human-readable string.
This implementation is primarily intended for debugging and logging, providing a clear overview of the heating statistics for a given date, including average temperatures, energy consumption, and control runtime.
§Arguments
f- A mutable reference to the formatter, as required by thefmt::Displaytrait.
§Returns
A fmt::Result indicating whether the formatting operation was successful.