Make sure ToolChange moves Selector to desired slot

and verify correct behaviour in unit tests - especially when Selector's start position is at a different slot.
pull/243/head
D.R.racer 2022-11-18 08:49:26 +01:00 committed by DRracer
parent 2f6e364ad0
commit c8c39f7b69
3 changed files with 18 additions and 12 deletions

View File

@ -43,10 +43,10 @@ bool ToolChange::Reset(uint8_t param) {
unl.Reset(mg::globals.ActiveSlot());
} else {
unloadAlreadyFinished = true;
mg::globals.SetFilamentLoaded(plannedSlot, mg::FilamentLoadState::InSelector); // activate the correct slot, feed uses that
if (feed.Reset(true, false)) {
state = ProgressCode::FeedingToFinda;
error = ErrorCode::RUNNING;
// mg::globals.SetFilamentLoaded(plannedSlot, mg::FilamentLoadState::InSelector); // this is set in feed @@TODO
dbg_logic_P(PSTR("Filament is not loaded --> load"));
} else {
// selector refused to move - FINDA problem suspected

View File

@ -68,7 +68,9 @@ public:
inline config::Axis Axis() const { return axis; }
#ifndef UNITTEST
protected:
#endif
/// internal state of the automaton
uint8_t state;

View File

@ -38,8 +38,7 @@ bool FeedingToFindaStep(logic::CommandBase &tc, uint32_t step, uint32_t triggerA
return tc.TopLevelState() == ProgressCode::FeedingToFinda;
}
void FeedingToFinda(logic::ToolChange &tc, uint8_t toSlot, uint32_t triggerAt = 1000) {
// feeding to finda
void FeedingToFinda(logic::ToolChange &tc, uint8_t toSlot, uint32_t triggerAt = 1000) { // feeding to finda
REQUIRE(WhileCondition(tc, std::bind(FeedingToFindaStep, std::ref(tc), _1, triggerAt), 200'000UL));
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, toSlot, toSlot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToBondtech));
}
@ -115,21 +114,26 @@ void NoToolChange(logic::ToolChange &tc, uint8_t fromSlot, uint8_t toSlot) {
}
void JustLoadFilament(logic::ToolChange &tc, uint8_t slot) {
for (uint8_t startSelectorSlot = 0; startSelectorSlot < config::toolCount; ++startSelectorSlot) {
ForceReinitAllAutomata();
REQUIRE(EnsureActiveSlotIndex(slot, mg::FilamentLoadState::AtPulley));
// make sure all the modules are ready
// MMU-196: Move selector to a "random" slot
REQUIRE(EnsureActiveSlotIndex(startSelectorSlot, mg::FilamentLoadState::AtPulley));
// verify filament NOT loaded
REQUIRE(VerifyEnvironmentState(mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), slot, false, false, ml::off, ml::off));
REQUIRE(VerifyEnvironmentState(mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), startSelectorSlot, false, false, ml::off, ml::off));
// restart the automaton
tc.Reset(slot);
REQUIRE(ms::selector.plannedSlot == slot); // MMU-196 - make sure the selector is about to move to the desired slot
FeedingToFinda(tc, slot);
FeedingToBondtech(tc, slot);
CheckFinishedCorrectly(tc, slot);
}
}
TEST_CASE("tool_change::test0", "[tool_change]") {