# HG changeset patch # User Matt Johnston # Date 1487258271 -28800 # Node ID 613f114feb4bdd42f71c1e03e5d5cc7b7d3cb53c # Parent 8c21df3711e24128aa8f65a6c3eb49f432213c1e missing file diff -r 8c21df3711e2 -r 613f114feb4b rust/src/configwaiter.rs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rust/src/configwaiter.rs Thu Feb 16 23:17:51 2017 +0800 @@ -0,0 +1,37 @@ +extern crate tokio_core; +extern crate futures; +extern crate rand; + +use std::time::Duration; +use std::io; + +use tokio_core::reactor::Interval; +use tokio_core::reactor::Handle; +use futures::Stream; +use types::*; + +pub struct ParamWaiter { +} + +impl ParamWaiter { + fn step(&mut self) -> Params { + let mut p = Params::defaults(); + let mut rng = rand::thread_rng(); + p.fridge_setpoint = 17.0 + 4.0*rand::random::(); + p + } + + pub fn new() -> Self { + ParamWaiter {} + } + + pub fn run(handle: &Handle, rate: u64) -> Box> { + let mut s = ParamWaiter::new(); + + let dur = Duration::from_millis(rate); + Interval::new(dur, handle).unwrap().map(move |()| { + s.step() + }).boxed() + } +} +