Expand description
Generic wait-for-axis-done function block. Common wait-for-axis-done function block.
Most state machines that command a motion axis end up writing the same
15-line wait handler over and over: poll is_busy, then check is_error,
then handle state.timed_out, then route to the next state. AxisWait
collapses that into a single call returning a WaitStatus the caller
matches on.
It is stateless — all state lives in the AxisHandle (the drive) and
the caller’s [StateMachine] (the timeout). Because it takes any
&impl AxisHandle, the same call works for AxisX / AxisY / AxisZ
/ AxisC or any custom handle.
§Example
use autocore_std::motion::axis_wait::{AxisWait, WaitStatus};
Some(MyState::WaitMoveDone) => {
match AxisWait::poll(axis_z, &self.state) {
WaitStatus::Pending => {}
WaitStatus::Done => {
self.state.index = MyState::NextStep as i32;
}
WaitStatus::Error(msg) => {
log::error!("Z axis error: {}", msg);
self.state.index = MyState::Reset as i32;
}
WaitStatus::Timeout => {
log::error!("Timeout waiting for Z motion");
self.state.index = MyState::Reset as i32;
}
}
}§Pairing with a follow_up_state enum
State machines that re-use one wait state across many transitions
typically pair this with an Option<MyState> field set by the
command-issuing state. The Done arm reads + clears it:
WaitStatus::Done => {
self.state.index = self.follow_up_state
.take()
.map(|s| s as i32)
.unwrap_or(MyState::Idle as i32);
}Structs§
- Axis
Wait - Wait-for-axis-done function block. Stateless — all state lives in
the drive and the caller’s
StateMachine.
Enums§
- Wait
Status - Result of a single
AxisWait::pollcall.