aquarium_control/food/
feed_config.rs

1/* Copyright 2024 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*/
9
10//! Defines the configuration structure for the automated feeding system.
11//!
12//! This module contains the `FeedConfig` struct, which is used with `serde` to
13//! deserialize the `[feed]` section from the application's TOML configuration file.
14//! It holds all the parameters that control the behavior of the `Feed` thread,
15//! from its activation status to its scheduling logic.
16
17use serde_derive::Deserialize;
18
19/// Holds the configuration data for the feed control.
20/// The configuration is loaded from the .toml configuration file.
21/// This struct does not contain any implementation.
22#[derive(Deserialize, Debug, PartialEq, Clone)]
23pub struct FeedConfig {
24    /// control will only be active when the flag is set to true
25    pub active: bool,
26
27    /// indicates if the thread shall be started or not
28    pub execute: bool,
29
30    /// interval for the main control in seconds    
31    pub schedule_check_interval: u32,
32
33    /// waiting time in milliseconds before switching on or off a device during feed
34    pub device_switch_delay_millis: u32,
35
36    /// Describes the strategy to use when there are multiple feed schedule entries in the past.
37    /// Using strategy_multiple_schedule_entries_in_past:
38    /// negative value: execute none of them
39    /// positive value: execute the xth entry according to how they are stacked in time
40    /// Example 0: Execute the first entry which has a timestamp closest to the current time.
41    /// Example 1: Execute the second last entry which lies closest to the current time.
42    /// Example 99: Numbers higher than the number of entries found in the past will trigger execution of the
43    /// last entry which has a timestamp furthest from the current time.
44    pub strategy_multiple_schedule_entries_in_past: i32,
45}