Expand description
Contains functions for execution of all queries relevant for Balling mineral dosing Manages all database interactions for the Balling dosing system.
This module provides a dedicated interface, SqlInterfaceBalling, for handling
all SQL operations related to the Balling feature. It encapsulates logic for
reading pump configurations (ballingsetvals), logging dosing events
(ballingdosinglog), and retrieving dosing history.
§Key Components
-
SqlInterfaceBallingStruct: The primary struct that holds a database connection and provides methods for all Balling-related database operations. -
BallingSetValStruct: A data structure representing the configuration parameters for a single Balling pump, such as dosing speed and volume. -
new()Constructor: A critical entry point that not only creates anSqlInterfaceBallinginstance but also performs essential “fail-fast” validation. At initialization, it checks the database for:- The presence of
NULLvalues in the configuration table. - Whether the number of rows in the
ballingsetvalsandballingdosinglogtables exceeds the limits defined in the application configuration. This ensures the system doesn’t start in an invalid or inconsistent state.
- The presence of
§Design and Purpose
The main goal of this module is to provide a robust, encapsulated, and safe interface for the Balling subsystem’s data.
-
Encapsulation: All SQL queries and logic specific to Balling are contained within this module, separating concerns and making the overall database architecture cleaner.
-
Data Integrity: The constructor’s validation logic enforces data integrity rules at startup, preventing runtime errors caused by misconfigured or overgrown database tables.
Structs§
- Balling
SetVal - Contains set value data for each pump.
- SqlInterface
Balling - Contains the configuration and the implementation of the SQL interface for Balling.