Add ClearButtons into unit tests
parent
7e759fdb51
commit
18891dbeaf
|
|
@ -152,3 +152,12 @@ void PressButtonAndDebounce(SM &sm, uint8_t btnIndex){
|
||||||
sm.Step(); // Inner
|
sm.Step(); // Inner
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename SM>
|
||||||
|
void ClearButtons(SM &sm){
|
||||||
|
hal::adc::SetADC(config::buttonsADCIndex, config::buttonADCMaxValue);
|
||||||
|
while (mb::buttons.AnyButtonPressed()) {
|
||||||
|
main_loop();
|
||||||
|
sm.Step(); // Inner
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,8 @@ void FailedLoadToFindaResolveHelp(uint8_t slot, logic::LoadFilament &lf) {
|
||||||
REQUIRE(WhileTopState(lf, ProgressCode::ERREngagingIdler, idlerEngageDisengageMaxSteps));
|
REQUIRE(WhileTopState(lf, ProgressCode::ERREngagingIdler, idlerEngageDisengageMaxSteps));
|
||||||
|
|
||||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, slot, slot, false, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::ERRHelpingFilament));
|
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, slot, slot, false, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::ERRHelpingFilament));
|
||||||
|
|
||||||
|
ClearButtons(lf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FailedLoadToFindaResolveHelpFindaTriggered(uint8_t slot, logic::LoadFilament &lf) {
|
void FailedLoadToFindaResolveHelpFindaTriggered(uint8_t slot, logic::LoadFilament &lf) {
|
||||||
|
|
@ -143,6 +145,8 @@ void FailedLoadToFindaResolveManual(uint8_t slot, logic::LoadFilament &lf) {
|
||||||
// pulling filament back
|
// pulling filament back
|
||||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, slot, slot, true, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::RetractingFromFinda));
|
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, slot, slot, true, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::RetractingFromFinda));
|
||||||
|
|
||||||
|
ClearButtons(lf);
|
||||||
|
|
||||||
// Stage 3 - retracting from finda
|
// Stage 3 - retracting from finda
|
||||||
// we'll assume the finda is working correctly here
|
// we'll assume the finda is working correctly here
|
||||||
REQUIRE(WhileCondition(
|
REQUIRE(WhileCondition(
|
||||||
|
|
@ -182,6 +186,8 @@ void FailedLoadToFindaResolveManualNoFINDA(uint8_t slot, logic::LoadFilament &lf
|
||||||
|
|
||||||
SimulateIdlerHoming();
|
SimulateIdlerHoming();
|
||||||
|
|
||||||
|
ClearButtons(lf);
|
||||||
|
|
||||||
// pulling filament back
|
// pulling filament back
|
||||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, false, false, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRWaitingForUser));
|
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, false, false, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRWaitingForUser));
|
||||||
}
|
}
|
||||||
|
|
@ -191,6 +197,8 @@ void FailedLoadToFindaResolveTryAgain(uint8_t slot, logic::LoadFilament &lf) {
|
||||||
|
|
||||||
// the state machine should have restarted
|
// the state machine should have restarted
|
||||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda));
|
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda));
|
||||||
|
ClearButtons(lf);
|
||||||
|
|
||||||
LoadFilamentSuccessful(slot, lf);
|
LoadFilamentSuccessful(slot, lf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,7 @@ void ToolChangeFailLoadToFindaLeftBtn(logic::ToolChange &tc, uint8_t toSlot) {
|
||||||
PressButtonAndDebounce(tc, mb::Left);
|
PressButtonAndDebounce(tc, mb::Left);
|
||||||
|
|
||||||
REQUIRE(WhileTopState(tc, ProgressCode::ERREngagingIdler, 5000UL));
|
REQUIRE(WhileTopState(tc, ProgressCode::ERREngagingIdler, 5000UL));
|
||||||
|
ClearButtons(tc);
|
||||||
|
|
||||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, toSlot, toSlot, false, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::ERRHelpingFilament));
|
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, toSlot, toSlot, false, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::ERRHelpingFilament));
|
||||||
|
|
||||||
|
|
@ -225,6 +226,8 @@ void ToolChangeFailLoadToFindaMiddleBtn(logic::ToolChange &tc, uint8_t toSlot) {
|
||||||
200000UL));
|
200000UL));
|
||||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), toSlot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda));
|
REQUIRE(VerifyState(tc, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), toSlot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda));
|
||||||
|
|
||||||
|
ClearButtons(tc);
|
||||||
|
|
||||||
// retry the whole operation
|
// retry the whole operation
|
||||||
// beware - the FeedToFinda state machine will leverage the already engaged Idler,
|
// beware - the FeedToFinda state machine will leverage the already engaged Idler,
|
||||||
// so the necessary number of steps to reach the FINDA is quite low (~200 was lowest once tested)
|
// so the necessary number of steps to reach the FINDA is quite low (~200 was lowest once tested)
|
||||||
|
|
@ -243,6 +246,8 @@ void ToolChangeFailLoadToFindaRightBtnFINDA_FSensor(logic::ToolChange &tc, uint8
|
||||||
PressButtonAndDebounce(tc, mb::Right);
|
PressButtonAndDebounce(tc, mb::Right);
|
||||||
|
|
||||||
CheckFinishedCorrectly(tc, toSlot);
|
CheckFinishedCorrectly(tc, toSlot);
|
||||||
|
|
||||||
|
ClearButtons(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolChangeFailLoadToFindaRightBtnFINDA(logic::ToolChange &tc, uint8_t toSlot) {
|
void ToolChangeFailLoadToFindaRightBtnFINDA(logic::ToolChange &tc, uint8_t toSlot) {
|
||||||
|
|
@ -251,6 +256,8 @@ void ToolChangeFailLoadToFindaRightBtnFINDA(logic::ToolChange &tc, uint8_t toSlo
|
||||||
PressButtonAndDebounce(tc, mb::Right);
|
PressButtonAndDebounce(tc, mb::Right);
|
||||||
|
|
||||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), toSlot, true, false, ml::off, ml::blink0, ErrorCode::FSENSOR_DIDNT_SWITCH_ON, ProgressCode::ERRWaitingForUser));
|
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), toSlot, true, false, ml::off, ml::blink0, ErrorCode::FSENSOR_DIDNT_SWITCH_ON, ProgressCode::ERRWaitingForUser));
|
||||||
|
|
||||||
|
ClearButtons(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolChangeFailLoadToFindaRightBtn(logic::ToolChange &tc, uint8_t toSlot) {
|
void ToolChangeFailLoadToFindaRightBtn(logic::ToolChange &tc, uint8_t toSlot) {
|
||||||
|
|
@ -258,6 +265,8 @@ void ToolChangeFailLoadToFindaRightBtn(logic::ToolChange &tc, uint8_t toSlot) {
|
||||||
PressButtonAndDebounce(tc, mb::Right);
|
PressButtonAndDebounce(tc, mb::Right);
|
||||||
|
|
||||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), toSlot, false, false, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRWaitingForUser));
|
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), toSlot, false, false, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRWaitingForUser));
|
||||||
|
|
||||||
|
ClearButtons(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("tool_change::load_fail_FINDA_resolve_btnL", "[tool_change]") {
|
TEST_CASE("tool_change::load_fail_FINDA_resolve_btnL", "[tool_change]") {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue