RunGoing2StageSM If current state is FindingWire Execute During function for FindingWire. If an event is active If event is event FindWireTimer Timeout Next State is Waiting4SetTarget Mark that we are taking a transition Return Get Target Stage event Else Return CurrentEvent If current state is Waiting4SetTarget Execute During function for Waiting4SetTarget. If an event is active If event is event Set Target Stage Set driving direction based on target stage Next State is Waiting4Stage Mark that we are taking a transition Consume event Else Return CurrentEvent If current state is Waiting4Stage Execute During function for Waiting4Stage. If an event is active If event is event Hall Legit Period if driving direction is forward decrement stage counter else if driving direction is forward increment stage counter Set driving direction based on target stage Next State is Debouncing Mark that we are taking a transition Consume event Else Return CurrentEvent If current state is Debouncing Execute During function for Debouncing. If an event is active If event is event Debounce Timer Timeout Set driving direction based on target stage Next State is Waiting4Stage Mark that we are taking a transition Consume event If event is event Hall Legit Period Consume event Else Return CurrentEvent DuringStateFindingWire On entry Query total align time Initialize find wire timer with total align time On exit stop drivetrain DuringStateDebouncing On entry Start debounce timer