diff rust/src/types.rs @ 592:03b48ec0bb03 rust

fridge, types, configwaiter
author Matt Johnston <matt@ucc.asn.au>
date Sat, 24 Dec 2016 00:14:58 +0800
parents
children bf138339d20a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rust/src/types.rs	Sat Dec 24 00:14:58 2016 +0800
@@ -0,0 +1,76 @@
+#[derive(RustcDecodable, RustcEncodable, Debug)]
+pub struct Params {
+    pub fridge_setpoint: f32,
+    pub fridge_difference: f32,
+    pub overshoot_delay: u32,
+    pub overshoot_factor: f32,
+    pub disabled: bool,
+    pub nowort: bool,
+    pub fridge_range_lower: f32,
+    pub fridge_range_upper: f32,
+}
+
+impl Params {
+    pub fn defaults() -> Params {
+        Params {
+            fridge_setpoint: 16.0,
+            fridge_difference: 0.2,
+            overshoot_delay: 720, // 12 minutes
+            overshoot_factor: 1.0,
+            disabled: false,
+            nowort: false,
+            fridge_range_lower: 3.0,
+            fridge_range_upper: 3.0,
+            }
+    }
+}
+
+#[derive(Debug)]
+pub struct ParamHolder {
+    pub p: Params,
+    epoch: String, // XXX or a byte array?
+}
+
+impl ParamHolder {
+    pub fn new() -> ParamHolder {
+        ParamHolder {
+            p: Params::defaults(),
+            epoch: String::new(),
+        }
+    }
+}
+
+#[derive(Debug)]
+pub struct Reading {
+    name: String,
+    value: Option<f32>,
+}
+
+impl Reading {
+    pub fn new(name: String, value: f32) -> Reading {
+        Reading { name: name, value: Some(value) }
+    }
+    pub fn new_none(name: String) -> Reading {
+        Reading { name: name, value: None }
+    }
+}
+
+pub struct Readings {
+    temps: Vec<Vec<Reading>>,
+}
+
+impl Readings {
+    pub fn new() -> Readings {
+        Readings {
+            temps: Vec::new(),
+        }
+    }
+    pub fn fridge(&self) -> Option<f32> {
+        unimplemented!();
+    }
+
+    pub fn wort(&self) -> Option<f32> {
+        unimplemented!();
+    }
+}
+