diff rust/src/main.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 e1bab5b36352
children a85c0c9bc1fa
line wrap: on
line diff
--- a/rust/src/main.rs	Tue Mar 07 23:04:02 2017 +0800
+++ b/rust/src/main.rs	Tue Mar 07 23:56:12 2017 +0800
@@ -31,7 +31,7 @@
 mod sensor;
 mod fridge;
 mod types;
-mod paramwaiter;
+mod params;
 
 use types::*;
 use config::Config;
@@ -41,8 +41,9 @@
     let mut core = Core::new().unwrap();
     let handle = core.handle();
 
-    let mut paramh = ParamHolder::new();
-    let mut fridge = fridge::Fridge::new(&config, nowait, paramh.p, &handle);
+    let params = params::Params::load(&config);
+    let epoch = params.epoch.clone();
+    let mut fridge = fridge::Fridge::new(&config, nowait, params, &handle);
 
     let (fridge_reading_s, fridge_reading_r) = mpsc::channel(1);
     let fridge_reading_r = fridge_reading_r.map_err(|e| TemplogError::new("Problem with fridge_reading_r channel"));
@@ -71,7 +72,7 @@
         r
     });
 
-    let param_stream = paramwaiter::ParamWaiter::stream(config, &handle);
+    let param_stream = params::ParamWaiter::stream(config, epoch, &handle);
     let p = param_stream.map(|p| {
             fridge::Message::Params(p)
         });
@@ -99,7 +100,7 @@
   -d, --debug
   -t, --test    Use fake sensors etc
   --nowait      Skip initial fridge wait
-  --defconf     Print default config (customise in tempserver.conf)
+  --defconf     Print default config (customise in local.conf)
   --thisconf    Print used config
 ";
 
@@ -138,7 +139,7 @@
 
     if args.flag_defconf {
         println!("Default configuration:\n{}\n\n{}",
-            "(custom options go in tempserver.conf)",
+            "(custom options go in local.conf)",
             config::Config::default().to_toml_string());
         std::process::exit(0);
     }
@@ -148,7 +149,7 @@
 fn load_config() -> Config {
     let nconfig = config::Config::default();
 
-    let conf_filename = "tempserver.conf";
+    let conf_filename = "local.conf";
     nconfig.merge_file(conf_filename)
         .unwrap_or_else(|e| {
             println!("Couldn't parse {}: {}", conf_filename, e);