pub struct Thermostat { /* private fields */ }Expand description
A hysteresis (bang-bang) controller for a single on/off actuator.
This is the controller behind “keep a temperature”. It switches a cooler or heater on and off to hold a reading near a setpoint. A deadband around the setpoint - the hysteresis - stops the output chattering when the reading hovers at the threshold, which protects relays and compressors that have a limited number of switching cycles in them.
§Examples
use pamoja_kit::Thermostat;
let mut fridge = Thermostat::cooling(4.0, 0.5);
assert!(fridge.update(5.0)); // above the deadband: the cooler runs
assert!(fridge.update(4.2)); // inside the deadband: it holds its state
assert!(!fridge.update(3.4)); // below the deadband: the cooler stopsImplementations§
Source§impl Thermostat
impl Thermostat
Sourcepub fn cooling(setpoint: f32, hysteresis: f32) -> Self
pub fn cooling(setpoint: f32, hysteresis: f32) -> Self
Creates a thermostat that drives a cooler, such as a fridge.
The output turns on when the reading rises above the deadband and off when it falls below it.
§Arguments
setpoint- the target reading.hysteresis- half the deadband width; its magnitude is used.
§Returns
A thermostat whose output starts off.
Trait Implementations§
Source§impl Clone for Thermostat
impl Clone for Thermostat
Source§fn clone(&self) -> Thermostat
fn clone(&self) -> Thermostat
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Thermostat
Source§impl Debug for Thermostat
impl Debug for Thermostat
Source§impl PartialEq for Thermostat
impl PartialEq for Thermostat
Source§fn eq(&self, other: &Thermostat) -> bool
fn eq(&self, other: &Thermostat) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for Thermostat
Auto Trait Implementations§
impl Freeze for Thermostat
impl RefUnwindSafe for Thermostat
impl Send for Thermostat
impl Sync for Thermostat
impl Unpin for Thermostat
impl UnsafeUnpin for Thermostat
impl UnwindSafe for Thermostat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more