diff --git a/src/machine.rs b/src/machine.rs index 1527b49..0872098 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -76,6 +76,11 @@ impl Machine { let mut guard = self.inner.try_lock().unwrap(); guard.request_state_change(who, new_state) } + + pub fn signal(&self) -> impl Signal { + let mut guard = self.inner.try_lock().unwrap(); + guard.signal() + } } impl Deref for Machine { @@ -227,7 +232,14 @@ impl MachineDescription { } pub fn load(config: &crate::config::Settings) -> Result> { - unimplemented!() + let mut map = MachineDescription::load_file(&config.machines)?; + + Ok(map.drain() + .map(|(k,v)| { + // TODO: Read state from the state db + Machine::construct(k, v, MachineState::new()) + }) + .collect()) } #[cfg(test_DISABLED)] diff --git a/src/main.rs b/src/main.rs index ef1a120..173ad8a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -133,10 +133,9 @@ fn maybe(matches: clap::ArgMatches, log: Arc) -> Result<(), Error> { error!(log, "Loading is currently not implemented"); Ok(()) } else { - - //let machines = machine::load(&config)?; let ex = Executor::new(); + let machines = machine::load(&config)?; let m = futures_signals::signal::Mutable::new(crate::db::machine::MachineState::new()); let (mut tx, actor) = actor::load()?; @@ -145,7 +144,8 @@ fn maybe(matches: clap::ArgMatches, log: Arc) -> Result<(), Error> { // TODO HERE: restore connections between initiators, machines, actors // Like so - tx.try_send(Some(m.signal_cloned())).unwrap(); + let m = machines[0].signal(); + tx.try_send(Some(m)).unwrap(); // TODO HERE: Spawn all actors & inits