comparison rust/src/types.rs @ 615:f153aec221be rust

move Params, epoch code
author Matt Johnston <matt@ucc.asn.au>
date Tue, 07 Mar 2017 23:56:12 +0800
parents 5fc41e0833b4
children 87a78343140e
comparison
equal deleted inserted replaced
614:e1bab5b36352 615:f153aec221be
11 use futures::{Stream,IntoFuture}; 11 use futures::{Stream,IntoFuture};
12 use serde::{Deserialize,Serialize}; 12 use serde::{Deserialize,Serialize};
13 use toml; 13 use toml;
14 use curl; 14 use curl;
15 use serde_json; 15 use serde_json;
16
17 #[derive(Deserialize, Serialize, Debug)]
18 pub struct Params {
19 pub fridge_setpoint: f32,
20 pub fridge_difference: f32,
21 pub overshoot_delay: u32,
22 pub overshoot_factor: f32,
23 pub disabled: bool,
24 pub nowort: bool,
25 pub fridge_range_lower: f32,
26 pub fridge_range_upper: f32,
27 }
28
29 impl Params {
30 pub fn defaults() -> Params {
31 Params {
32 fridge_setpoint: 16.0,
33 fridge_difference: 0.2,
34 overshoot_delay: 720, // 12 minutes
35 overshoot_factor: 1.0,
36 disabled: false,
37 nowort: false,
38 fridge_range_lower: 3.0,
39 fridge_range_upper: 3.0,
40 }
41 }
42 }
43
44 #[derive(Debug)]
45 pub struct ParamHolder {
46 pub p: Params,
47 epoch: String,
48 }
49
50 impl ParamHolder {
51 pub fn new() -> ParamHolder {
52 ParamHolder {
53 p: Params::defaults(),
54 epoch: String::new(),
55 }
56 }
57
58 pub fn receive(&mut self, p: &Params, epoch: &String)
59 {
60
61 }
62 }
63 16
64 #[derive(Debug)] 17 #[derive(Debug)]
65 pub struct Readings { 18 pub struct Readings {
66 pub temps: HashMap<String, f32>, 19 pub temps: HashMap<String, f32>,
67 } 20 }