Crate thermostat[−][src]
This crate provides a finite state machine for a thermostat controlling a centralized HVAC system or other heating and/or cooling apparatus.
The goal of this component is to provide an abstracted thermostat that can be embedded in any device where temperature and/or humidity must be controlled (e.g., homes, offices, refigerators, kegerators). The library is starting out with a simple hysteretic control algorithm using temperature and humidity measurements. Progressing from there, this library will look at various stratgies to continually optimize in-situ for objectievs such as power conservation, system lifespan, or predicted demand.
This crate is not currently suitable for use with multi-stage or other controlled variable load applications. It was designed on a model of simple on-or-off heating and cooling devices found with in most HVAC systems and refigeration compressors.
The thermostat uses double-precision floating-point format for representing both temperature in degrees Celsius and percent relative humidity.
Usage Example
extern crate thermostat; use thermostat::{OperatingMode, Thermostat, Error as ThermostatError, ThermostatInterface}; struct MyThermostatInterface {} impl ThermostatInterface for MyThermostatInterface { fn calling_for_heat(&self) -> Result<bool, ThermostatError> { Ok(true) // return if we are currently calling for heat } fn call_for_heat(&self) -> Result<(), ThermostatError> { Ok(()) } fn stop_call_for_heat(&self) -> Result<(), ThermostatError> { Ok(()) } fn calling_for_cool(&self) -> Result<bool, ThermostatError> { Ok(true) // return if we are currently calling for cool } fn call_for_cool(&self) -> Result<(), ThermostatError> { Ok(()) } fn stop_call_for_cool(&self) -> Result<(), ThermostatError> { Ok(()) } fn calling_for_fan(&self) -> Result<bool, ThermostatError> { Ok(true) // return if we are currently calling for fan } fn call_for_fan(&self) -> Result<(), ThermostatError> { Ok(()) } fn stop_call_for_fan(&self) -> Result<(), ThermostatError> { Ok(()) } fn get_seconds(&self) -> Result<u64, ThermostatError> { Ok(0) // actually return seconds elapsed here } } fn main() { // create a new physical interface for the thermostat let interface = MyThermostatInterface {}; // create a new thermostat with our physical interface let mut thermostat = Thermostat::new(&interface); // once the thermostat has been provided with a measure routine // it will begin polling for new measurements and calling for // heat, cool, and/or fan -- depending on which methods have // been registered. // set max temp thermostat will allow before calling for cool thermostat.set_maximum_set_temperature(22.5).unwrap(); // set min temp thermostat will allow before calling for heat thermostat.set_minimum_set_temperature(18.0).unwrap(); // maintain temperatures between min and max set points thermostat.set_operating_mode(OperatingMode::MaintainRange).unwrap(); }
Structs
Thermostat |
Thermostat state machine |
Enums
Error |
Thermostat errors |
OperatingMode |
Various thermostat operating modes |
Traits
ThermostatInterface |
Wrapper for physical interface controls |