More log messages
This commit is contained in:
parent
c5c6b7f188
commit
8d8d347c56
1 changed files with 16 additions and 1 deletions
17
src/logic.rs
17
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue