Expand description
Contains functions for execution of all queries relevant for ventilation set values (thermal) Manages database interactions for the ventilation system’s user-configurable set points.
This module provides a dedicated interface, SqlInterfaceVentilationSetVals, for handling
all SQL operations related to the ventilationsetvals table. It encapsulates logic
for reading the ventilation on/off temperature thresholds and implements the
ThermalSetValueUpdaterTrait to periodically poll the database for changes.
§Key Components
-
SqlInterfaceVentilationSetValsStruct: The primary struct that holds a database connection and manages the periodic update logic. -
VentilationSetValsStruct: A simple data structure representing the on/off temperature thresholds for the ventilation fans. -
new()Constructor: A critical entry point that performs “fail-fast” validation at initialization. It checks the database to ensure:- The
ventilationsetvalstable contains noNULLvalues. - The table contains at most one row, as there should only be a single set of ventilation parameters for the system.
- The
-
get_ventilation_set_values(): The core data-fetching method. It retrieves the ventilation thresholds and performs a critical consistency check to ensure theventilation_switch_on_temperatureis not lower than theventilation_switch_off_temperature. -
ThermalSetValueUpdaterTraitImplementation: Theupdate_set_valuemethod allows this struct to be used by a thermal controller to periodically and efficiently check for updated set points from the database without querying on every single loop iteration.
§Design and Purpose
The main goal of this module is to provide a robust, encapsulated, and safe interface for the ventilation subsystem’s configuration data.
-
Encapsulation: All SQL queries and logic specific to ventilation set points are contained within this module, separating concerns.
-
Data Integrity: The constructor’s validation logic and the consistency checks in
get_ventilation_set_valuesenforce data integrity rules, preventing runtime errors caused by invalid database states.
Structs§
- SqlInterface
Ventilation SetVals - Ventilation
SetVals - Contains the ventilation set values which can be set by the user.