From 8d8d347c56b657be96faf16e9baf07e32a2c90c9 Mon Sep 17 00:00:00 2001 From: Rahix Date: Sun, 3 Nov 2024 16:51:55 +0100 Subject: [PATCH] More log messages --- src/logic.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/logic.rs b/src/logic.rs index 535da18..9b61c05 100644 --- a/src/logic.rs +++ b/src/logic.rs @@ -125,6 +125,7 @@ impl Logic { && !self.inp.switch_run_once && !self.inp.switch_run_continuous => { + log::info!("Machine ready to start."); MachineState::Idle } @@ -132,26 +133,37 @@ impl Logic { MachineState::Idle if self.t_state.timer(now, 2.secs()) && self.inp.switch_run_continuous => { + log::info!("Starting continuous test..."); MachineState::ExecuteContinuous } MachineState::Idle if self.t_state.timer(now, 2.secs()) && self.inp.switch_run_once => { + log::info!("Starting single test..."); MachineState::ExecuteOnce } // End condition - MachineState::ExecuteContinuous | MachineState::ExecuteOnce + MachineState::ExecuteContinuous if self.inp.left_limit || self.inp.right_limit => { + log::info!("Completed continuous test. Failure after {} cycles.", self.counter); + MachineState::Completed + } + MachineState::ExecuteOnce + if self.inp.left_limit || self.inp.right_limit => + { + log::info!("Completed single test. Failure after {}.", self.t_cylinder.timer_value(now)); MachineState::Completed } // End on user request MachineState::ExecuteContinuous if !self.inp.switch_run_continuous => { + log::info!("Aborted continuous test by user request (after {} cycles).", self.counter); MachineState::Idle } MachineState::ExecuteOnce if self.t_state.timer(now, 2.secs()) && self.inp.switch_run_once => { + log::info!("Aborted single test by user request (after {}).", self.t_cylinder.timer_value(now)); MachineState::Idle } @@ -178,10 +190,12 @@ impl Logic { CylinderState::Unknown => CylinderState::Left, CylinderState::Left if self.t_cylinder.timer(now, CYCLE_MS.millis()) => { self.counter += 1; + log::debug!("Cycle counter: {}", self.counter); CylinderState::Right } CylinderState::Right if self.t_cylinder.timer(now, CYCLE_MS.millis()) => { self.counter += 1; + log::debug!("Cycle counter: {}", self.counter); CylinderState::Left } s => s, @@ -191,6 +205,7 @@ impl Logic { self.cylinder_state = match self.cylinder_state { CylinderState::Unknown => CylinderState::Left, CylinderState::Left if self.t_cylinder.timer(now, 1.secs()) => { + log::debug!("Completed preparation, starting test run..."); CylinderState::Right } s => s,