aquarium_control/water/
refill_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 serde_derive::Deserialize;
10
11/// Holds the configuration data for the refill control.
12/// The configuration is loaded from the .toml configuration file.
13/// This struct does not contain any implementation.
14#[derive(Deserialize, Clone)]
15pub struct RefillConfig {
16    /// control will only be active when the flag is set to true
17    pub active: bool,
18
19    /// indicates if the thread shall be started or not
20    pub execute: bool,
21
22    /// time interval in seconds which need to pass after initialization of the application before refill control is becoming active
23    pub initial_wait_interval: u64,
24
25    /// interval for the main control in seconds    
26    pub check_interval: u64,
27
28    /// the maximum number of permitted refill operations within the last 24h
29    /// - If this number is exceeded, then the refill control will not further refill even if the water level sensor signal value is low.
30    pub max_refill_count_24h: u64,
31
32    /// maximum permitted refill volume within the last 24h
33    /// - If this number is exceeded, then the refill control will not further refill even if the water level sensor signal value is low.
34    pub max_refill_volume_24h: f64,
35
36    /// the maximum number of permitted refill operations within the last hour
37    /// - If this number is exceeded, then the refill control will not further refill even if the water level sensor signal value is low.
38    pub max_refill_count_hour: u64,
39
40    /// maximum permitted refill volume within the last hour
41    /// - If this number is exceeded, then the refill control will not further refill even if the water level sensor signal value is low.
42    pub max_refill_volume_hour: f64,
43
44    /// minimum time which has to pass after a refill operation before a further refill operation is started
45    pub min_interval_last_refill: u64,
46
47    /// time interval in seconds which need to pass before the application recognizes a potential tank level switch fault
48    pub max_duration_since_last_refill: u64,
49
50    /// flow of the refill pump in liters / second
51    pub refill_pump_flow: f64,
52
53    /// maximum permitted refill volume in one refill operation
54    pub max_refill_volume: f64,
55
56    /// Refill volume which is added to the tank in a refill operation after the application recognizes tank level position high
57    /// Background: This volume shall avoid too frequent refill operations. Too high values may lead to unstable water level.
58    /// It is recommended to calibrate a value, which is a fraction of max_refill_volume.
59    pub additional_refill_volume: f64,
60}