Mercurial > templog
diff rust/src/fridge.rs @ 603:b45b8b4cf0f5 rust
get rid of lazy_static, config is passed around
better use of threadpool for sensors
readings are no longer options
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 16 Feb 2017 23:19:12 +0800 |
parents | 8c21df3711e2 |
children | 3c1d37d78415 |
line wrap: on
line diff
--- a/rust/src/fridge.rs Thu Feb 16 23:17:51 2017 +0800 +++ b/rust/src/fridge.rs Thu Feb 16 23:19:12 2017 +0800 @@ -10,10 +10,9 @@ use tokio_core::reactor::{Timeout,Handle}; use futures::sync::{mpsc}; +use ::Config; use types::*; -use ::rigid_config; - #[derive(Debug)] pub enum Message { Sensor {wort: Option<f32>, fridge: Option<f32>}, @@ -23,6 +22,7 @@ pub struct Fridge { params: Params, + config: Config, temp_wort: Option<f32>, temp_fridge: Option<f32>, @@ -51,9 +51,10 @@ } impl Fridge { - pub fn new(nowait: bool, p: Params, handle: &Handle) -> Fridge { + pub fn new(config: &Config, nowait: bool, p: Params, handle: &Handle) -> Fridge { let (s, r) = mpsc::channel(1); let mut f = Fridge { + config: config.clone(), params: p, temp_wort: None, temp_fridge: None, @@ -65,7 +66,7 @@ last_off_time: Instant::now(), }; if nowait { - f.last_off_time -= Duration::new(rigid_config.FRIDGE_DELAY, 100); + f.last_off_time -= Duration::new(config.FRIDGE_DELAY, 100); } f.tick(); f