Expand description
Contains functions for execution of all queries relevant for feed (food) Manages all database interactions for the automated feeding system.
This module provides a dedicated interface, SqlInterfaceFeed, for handling
all SQL operations related to the feeding schedule (feedschedule), feed patterns
(feedpatterns), and feed event logging (feedlog).
§Key Components
-
SqlInterfaceFeedStruct: The primary struct that holds a database connection and provides methods for all feed-related database operations. -
new()Constructor: A critical entry point that not only creates anSqlInterfaceFeedinstance but also performs essential “fail-fast” validation. At initialization, it checks the database for:- The presence of
NULLvalues in thefeedpatternsandfeedscheduletables. - Whether the number of rows in the
feedpatterns,feedschedule, andfeedlogtables exceeds the limits defined in the application configuration. This ensures the system doesn’t start in an invalid or inconsistent state.
- The presence of
-
Data-Fetching Methods: Functions like
get_feedpattern_header_from_databaseandget_feed_phase_from_databaseprovide a structured way to retrieve complex feed pattern data from the database.
§Design and Purpose
The main goal of this module is to provide a robust and encapsulated interface for the feeding subsystem’s data.
-
Encapsulation: All SQL queries and logic specific to feeding 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§
- SqlFeed
Phase - Holds the data of one feed pattern phase as retrieved from the database. The numeric data is post-processed to boolean in a further step.
- SqlFeed
Schedule Entry - Holds the data of a feed schedule entry as retrieved from the database. It is post-processed in a further step.
- SqlFeedpattern
Header - Holds the header information of a feed pattern.
- SqlInterface
Feed - Contains the configuration and the implementation of the SQL interface for Feed.