Unit test ErrDisengageIdler: make sure it never sets error while disengaging
parent
4e44447762
commit
3c3e625f39
|
|
@ -113,7 +113,8 @@ void FailedLoadToFinda(uint8_t slot, logic::LoadFilament &lf) {
|
||||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, slot, slot, false, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::ERRDisengagingIdler));
|
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, slot, slot, false, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::ERRDisengagingIdler));
|
||||||
|
|
||||||
// Stage 3 - disengaging idler in error mode
|
// Stage 3 - disengaging idler in error mode
|
||||||
REQUIRE(WhileTopState(lf, ProgressCode::ERRDisengagingIdler, idlerEngageDisengageMaxSteps));
|
SimulateErrDisengagingIdler(lf, ErrorCode::FINDA_DIDNT_SWITCH_ON);
|
||||||
|
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include "catch2/catch.hpp"
|
||||||
#include "main_loop_stub.h"
|
#include "main_loop_stub.h"
|
||||||
#include "homing.h"
|
#include "homing.h"
|
||||||
|
|
||||||
|
|
@ -162,3 +163,17 @@ void SetFSensorStateAndDebounce(bool press) {
|
||||||
main_loop();
|
main_loop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimulateErrDisengagingIdler(logic::CommandBase &cb, ErrorCode deferredEC) {
|
||||||
|
REQUIRE(WhileCondition(
|
||||||
|
cb, [&](uint32_t) {
|
||||||
|
if (cb.TopLevelState() == ProgressCode::ERRDisengagingIdler) {
|
||||||
|
REQUIRE(cb.Error() == ErrorCode::RUNNING); // ensure the error gets never set while disengaging the idler
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
REQUIRE(cb.Error() == deferredEC);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
idlerEngageDisengageMaxSteps));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,3 +41,5 @@ static constexpr uint32_t idlerEngageDisengageMaxSteps = 40000UL;
|
||||||
static constexpr uint32_t selectorMoveMaxSteps = 40000UL;
|
static constexpr uint32_t selectorMoveMaxSteps = 40000UL;
|
||||||
|
|
||||||
void HomeIdlerAndSelector();
|
void HomeIdlerAndSelector();
|
||||||
|
|
||||||
|
void SimulateErrDisengagingIdler(logic::CommandBase &cb, ErrorCode deferredEC);
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,8 @@ void ToolChangeFailLoadToFinda(logic::ToolChange &tc, uint8_t fromSlot, uint8_t
|
||||||
|
|
||||||
// should end up in error disengage idler
|
// should end up in error disengage idler
|
||||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, toSlot, toSlot, false, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::ERRDisengagingIdler));
|
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, toSlot, toSlot, false, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::ERRDisengagingIdler));
|
||||||
REQUIRE(WhileTopState(tc, ProgressCode::ERRDisengagingIdler, 5000));
|
|
||||||
|
SimulateErrDisengagingIdler(tc, ErrorCode::FINDA_DIDNT_SWITCH_ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolChangeFailLoadToFindaLeftBtn(logic::ToolChange &tc, uint8_t toSlot) {
|
void ToolChangeFailLoadToFindaLeftBtn(logic::ToolChange &tc, uint8_t toSlot) {
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ void FindaDidntTriggerCommonSetup(uint8_t slot, logic::UnloadFilament &uf) {
|
||||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, slot, slot, true, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::ERRDisengagingIdler));
|
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, slot, slot, true, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::ERRDisengagingIdler));
|
||||||
|
|
||||||
// Stage 2 - idler should get disengaged
|
// Stage 2 - idler should get disengaged
|
||||||
REQUIRE(WhileTopState(uf, ProgressCode::ERRDisengagingIdler, idlerEngageDisengageMaxSteps));
|
SimulateErrDisengagingIdler(uf, ErrorCode::FINDA_DIDNT_SWITCH_OFF);
|
||||||
|
|
||||||
// we still think we have filament loaded at this stage
|
// we still think we have filament loaded at this stage
|
||||||
// idler should have been disengaged
|
// idler should have been disengaged
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue