Expand description
Contains functions for execution of all queries relevant for schedule (permission) Manages time-based scheduling for various application modules.
This module provides a dedicated interface, SqlInterfaceSchedule, for reading and
interpreting time-based restrictions from the schedule table in the database.
Its primary purpose is to allow users to inhibit certain activities that may cause
noise or other disturbances (e.g., pumps for Balling or Refill) during specific
times, such as at night.
§Key Components
-
SqlInterfaceSchedule: The main struct that holds a database connection, performs validation, and provides methods to read and query schedule data. -
ScheduleEntry: A processed, type-safe representation of a single schedule rule. It converts raw string data from the database into strongly typedScheduleTypeandchrono::NaiveTimefields. -
ScheduleType: An enum that identifies the specific application module (e.g.,Balling,Refill,Heating) that a schedule rule applies to.
§Design and Purpose
The module is designed to be a robust and centralized point for all scheduling logic.
-
Fail-Fast Validation: The
new()constructor performs several “fail-fast” checks at startup. It verifies that thescheduletable contains noNULLvalues and that the number of entries does not exceed a configured limit. This prevents the application from starting in an invalid state. -
Data Processing and Caching: The
read_schedule()method fetches all rules from the database, parses them intoScheduleEntryobjects, and stores them in an internal cache (Vec). This is efficient as the database is only queried once. -
Robust Error Handling: During processing,
read_schedule()does not fail on the first malformed entry. Instead, it collects all parsing errors (e.g., for an invalid time string) and returns them in aVec, allowing for comprehensive diagnostics of database integrity issues. -
Time Window Logic: The
ScheduleEntry::check_if_allowed()method provides a simple way to determine if the current system time falls within the active window of a given schedule.
Structs§
- Schedule
Entry - Contains one schedule data set after post-processing
- SqlInterface
Schedule - Contains the configuration and the implementation of the SQL interface for Schedule.
- SqlSchedule
Entry - Contains one schedule data set as read from the database
Enums§
- Schedule
Type - List of all modules that are subject to limitations by schedule. Background: These activities cause noise - the user shall be able to inhibit these noises during nighttime.