Mercurial > templog
comparison rust/src/main.rs @ 638:a9f353f488d0 rust
fix channels
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 09 Nov 2019 11:35:59 +0800 |
parents | 4424a8b30f9c |
children | 89818a14648b |
comparison
equal
deleted
inserted
replaced
637:1e147b3c2c55 | 638:a9f353f488d0 |
---|---|
1 #![feature(async_closure)] | |
2 #[macro_use] extern crate log; | 1 #[macro_use] extern crate log; |
3 // riker has its own logging? | 2 // riker has its own logging? |
4 //extern crate env_logger; | 3 //extern crate env_logger; |
5 | 4 |
6 #[macro_use] extern crate lazy_static; | 5 #[macro_use] extern crate lazy_static; |
10 mod sensor; | 9 mod sensor; |
11 mod fridge; | 10 mod fridge; |
12 mod types; | 11 mod types; |
13 mod params; | 12 mod params; |
14 | 13 |
14 use std::time::Duration; | |
15 | 15 |
16 use riker::actors::*; | 16 use riker::actors::*; |
17 | 17 |
18 use structopt::StructOpt; | 18 use structopt::StructOpt; |
19 | 19 |
22 fn run(conf_file: &str, nowait: bool, testmode: bool) -> Result<(), TemplogError> { | 22 fn run(conf_file: &str, nowait: bool, testmode: bool) -> Result<(), TemplogError> { |
23 | 23 |
24 let cf = config::Config::load(conf_file)?; | 24 let cf = config::Config::load(conf_file)?; |
25 | 25 |
26 let sys = ActorSystem::new().unwrap(); | 26 let sys = ActorSystem::new().unwrap(); |
27 let props = Props::new_args(params::ParamWaiter::new, cf.clone()); | |
28 sys.actor_of(props, "paramwaiter").unwrap(); | |
29 | 27 |
30 if testmode { | 28 let props = Props::new_args(fridge::Fridge::new_actor, (cf.clone(), testmode, nowait)); |
31 let props = Props::new_args(sensor::TestSensor::new, cf.clone()); | 29 sys.actor_of(props, "fridge").unwrap(); |
32 sys.actor_of(props, "sensor").unwrap() | |
33 } else { | |
34 let props = Props::new_args(sensor::OneWireSensor::new, cf.clone()); | |
35 sys.actor_of(props, "sensor").unwrap() | |
36 }; | |
37 | 30 |
38 let props = Props::new_args(fridge::Fridge::new_actor, (cf.clone(), nowait)); | 31 loop { |
39 sys.actor_of(props, "fridge").unwrap(); | 32 // TODO: wait for a semaphore or something? |
40 Ok(()) | 33 std::thread::sleep(Duration::from_millis(60000)); |
34 } | |
41 } | 35 } |
42 | 36 |
43 #[derive(Debug, StructOpt)] | 37 #[derive(Debug, StructOpt)] |
44 #[structopt(name = "Wort Temperature", about = "Matt Johnston 2019 [email protected]")] | 38 #[structopt(name = "Wort Temperature", about = "Matt Johnston 2019 [email protected]")] |
45 struct Opt { | 39 struct Opt { |