Expand description
Contains functions for execution of all queries relevant for heating set values (thermal) Manages database interactions for the heating system’s user-configurable set points.
This module provides a dedicated interface, SqlInterfaceHeatingSetVals, for handling
all SQL operations related to the heatingsetvals table. It encapsulates logic for
reading the heating on/off temperature thresholds and implements the
ThermalSetValueUpdaterTrait to periodically poll the database for changes.
§Key Components
-
SqlInterfaceHeatingSetValsStruct: The primary struct that holds a database connection and manages the periodic update logic. -
HeatingSetValsStruct: A simple data structure representing the on/off temperature thresholds for the heater. -
new()Constructor: A critical entry point that performs “fail-fast” validation at initialization. It checks the database to ensure:- The
heatingsetvalstable contains noNULLvalues. - The table contains at most one row, as there should only be a single set of heating parameters for the system.
- The
-
get_heating_set_values(): The core data-fetching method. It retrieves the heating thresholds and performs a critical consistency check to ensure theheating_switch_on_temperatureis not greater than theheating_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 heating subsystem’s configuration data.
-
Encapsulation: All SQL queries and logic specific to heating set points are contained within this module, separating concerns.
-
Data Integrity: The constructor’s validation logic and the consistency checks in
get_heating_set_valuesenforce data integrity rules, preventing runtime errors caused by invalid database states.
Structs§
- Heating
SetVals - Contains the heating set values which can be set by the user.
- SqlInterface
Heating SetVals