aquarium_control/thermal/distinct_interval_check.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::thermal::heating_config::HeatingConfig;
10use crate::thermal::ventilation_config::VentilationConfig;
11
12/// The function checks if the control parameters of heating and ventilation do not conflict each other.
13/// This shall avoid the scenario that heating and ventilation are working against each other,
14/// leading to excessive consumption of energy and fresh water and potentially triggering
15/// deactivation of the refill control.
16/// # Arguments
17///
18/// * `heating_config` - A reference to the `HeatingConfig` struct containing configuration
19/// data of the heating control.
20/// * `ventilation_config` - A reference to the `VentilationConfig` struct containing configuration
21/// data of the ventilation control.
22///
23/// # Returns
24///
25/// - `bool`: If the control intervals are distinct or one of the controls is deactivated, the
26/// function returns true, otherwise false.
27pub fn distinct_thermal_control_interval_check(
28 heating_config: &HeatingConfig,
29 ventilation_config: &VentilationConfig,
30) -> bool {
31 if heating_config.active && ventilation_config.active {
32 heating_config.switch_off_temperature < ventilation_config.switch_off_temperature
33 } else {
34 true // one of the controllers is deactivated
35 }
36}