aquarium_control/thermal/
heating_config.rs

1/* Copyright 2025 Uwe Martin
2
3Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
5The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
7THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8*/
9use crate::utilities::sawtooth_profile::SawToothProfileConfig;
10use serde_derive::Deserialize;
11
12/// Holds the configuration data for the heating control.
13/// The configuration is loaded from the .toml configuration file.
14/// This struct does not contain any implementation.
15#[derive(Deserialize, Clone)]
16pub struct HeatingConfig {
17    /// Control will only be active when the flag is set to true.
18    pub active: bool,
19
20    /// indicates if the thread shall be started or not
21    pub execute: bool,
22
23    /// The temperature at which the heater is switched on for 100% of the time.
24    /// This temperature must be lower than switch_off_temperature.
25    /// It is overwritten with valid database values once obtained.
26    pub switch_on_temperature: f32,
27
28    /// The temperature at which the heater is switched off for 100% of the time.
29    /// This temperature must be higher than switch_on_temperature.
30    /// It is overwritten with valid database values once obtained.
31    pub switch_off_temperature: f32,
32
33    /// Flag to determine behavior in case the refill control has a problem
34    /// and the water level stays low for longer periods of time.
35    /// If this flag is true, then the heating control will switch off the heater
36    /// regardless of measured temperature to avoid overheating
37    /// of the fish tank or the heater itself.
38    /// Background: If the water level is too low, the temperature sensor may be exposed to ambient air instead of water.
39    /// This condition results in a wrong temperature reading and thus in the wrong actuation of the heater.
40    /// Furthermore, exposing the heater to air instead of water and switching it on
41    /// will not allow the heater to dissipate the heat, and it therefore might suffer damage.
42    pub stop_on_refill_error: bool,
43
44    /// Number of seconds which need to pass with low water level before the heater is switched off
45    pub stop_on_refill_error_delay: u32,
46
47    /// Configuration of saw tooth profile for generation of low-frequency PWM signal
48    pub saw_tooth_profile_config: SawToothProfileConfig,
49
50    /// Electrical power consumption of heater in Watt
51    pub heater_power: f32,
52
53    /// strategy when schedule check does not allow operation:
54    /// true=heating will be switched on; false=heating will be switched off
55    pub switch_on_when_out_of_schedule: bool,
56
57    /// strategy when the external request for stopping heating control has been received:
58    /// true=heating will be switched on; false=heating will be switched off
59    pub switch_on_when_external_stop: bool,
60
61    /// interval in seconds for polling the database
62    pub set_value_check_interval: u64,
63}