comparison 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
comparison
equal deleted inserted replaced
591:4a944663fa8d 592:03b48ec0bb03
1 #[derive(RustcDecodable, RustcEncodable, Debug)]
2 pub struct Params {
3 pub fridge_setpoint: f32,
4 pub fridge_difference: f32,
5 pub overshoot_delay: u32,
6 pub overshoot_factor: f32,
7 pub disabled: bool,
8 pub nowort: bool,
9 pub fridge_range_lower: f32,
10 pub fridge_range_upper: f32,
11 }
12
13 impl Params {
14 pub fn defaults() -> Params {
15 Params {
16 fridge_setpoint: 16.0,
17 fridge_difference: 0.2,
18 overshoot_delay: 720, // 12 minutes
19 overshoot_factor: 1.0,
20 disabled: false,
21 nowort: false,
22 fridge_range_lower: 3.0,
23 fridge_range_upper: 3.0,
24 }
25 }
26 }
27
28 #[derive(Debug)]
29 pub struct ParamHolder {
30 pub p: Params,
31 epoch: String, // XXX or a byte array?
32 }
33
34 impl ParamHolder {
35 pub fn new() -> ParamHolder {
36 ParamHolder {
37 p: Params::defaults(),
38 epoch: String::new(),
39 }
40 }
41 }
42
43 #[derive(Debug)]
44 pub struct Reading {
45 name: String,
46 value: Option<f32>,
47 }
48
49 impl Reading {
50 pub fn new(name: String, value: f32) -> Reading {
51 Reading { name: name, value: Some(value) }
52 }
53 pub fn new_none(name: String) -> Reading {
54 Reading { name: name, value: None }
55 }
56 }
57
58 pub struct Readings {
59 temps: Vec<Vec<Reading>>,
60 }
61
62 impl Readings {
63 pub fn new() -> Readings {
64 Readings {
65 temps: Vec::new(),
66 }
67 }
68 pub fn fridge(&self) -> Option<f32> {
69 unimplemented!();
70 }
71
72 pub fn wort(&self) -> Option<f32> {
73 unimplemented!();
74 }
75 }
76