Mercurial > templog
annotate rust/src/types.rs @ 593:bf138339d20a rust
fiddling with timeouts and closures
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 27 Dec 2016 00:51:28 +0800 |
parents | 03b48ec0bb03 |
children | aff50ee77252 |
rev | line source |
---|---|
593
bf138339d20a
fiddling with timeouts and closures
Matt Johnston <matt@ucc.asn.au>
parents:
592
diff
changeset
|
1 #[derive(RustcDecodable, RustcEncodable, Debug, Clone)] |
592 | 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 | |
593
bf138339d20a
fiddling with timeouts and closures
Matt Johnston <matt@ucc.asn.au>
parents:
592
diff
changeset
|
58 #[derive(Debug)] |
592 | 59 pub struct Readings { |
60 temps: Vec<Vec<Reading>>, | |
61 } | |
62 | |
63 impl Readings { | |
64 pub fn new() -> Readings { | |
65 Readings { | |
66 temps: Vec::new(), | |
67 } | |
68 } | |
593
bf138339d20a
fiddling with timeouts and closures
Matt Johnston <matt@ucc.asn.au>
parents:
592
diff
changeset
|
69 |
bf138339d20a
fiddling with timeouts and closures
Matt Johnston <matt@ucc.asn.au>
parents:
592
diff
changeset
|
70 pub fn push(&mut self, vals: Vec<Reading>) { |
bf138339d20a
fiddling with timeouts and closures
Matt Johnston <matt@ucc.asn.au>
parents:
592
diff
changeset
|
71 self.temps.push(vals); |
bf138339d20a
fiddling with timeouts and closures
Matt Johnston <matt@ucc.asn.au>
parents:
592
diff
changeset
|
72 } |
bf138339d20a
fiddling with timeouts and closures
Matt Johnston <matt@ucc.asn.au>
parents:
592
diff
changeset
|
73 |
592 | 74 pub fn fridge(&self) -> Option<f32> { |
75 unimplemented!(); | |
76 } | |
77 | |
78 pub fn wort(&self) -> Option<f32> { | |
79 unimplemented!(); | |
80 } | |
81 } | |
82 |