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/242/head
parent
eba2c298d1
commit
264688736f
|
|
@ -43,10 +43,10 @@ bool ToolChange::Reset(uint8_t param) {
|
||||||
unl.Reset(mg::globals.ActiveSlot());
|
unl.Reset(mg::globals.ActiveSlot());
|
||||||
} else {
|
} else {
|
||||||
unloadAlreadyFinished = true;
|
unloadAlreadyFinished = true;
|
||||||
|
mg::globals.SetFilamentLoaded(plannedSlot, mg::FilamentLoadState::InSelector); // activate the correct slot, feed uses that
|
||||||
if (feed.Reset(true, false)) {
|
if (feed.Reset(true, false)) {
|
||||||
state = ProgressCode::FeedingToFinda;
|
state = ProgressCode::FeedingToFinda;
|
||||||
error = ErrorCode::RUNNING;
|
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"));
|
dbg_logic_P(PSTR("Filament is not loaded --> load"));
|
||||||
} else {
|
} else {
|
||||||
// selector refused to move - FINDA problem suspected
|
// selector refused to move - FINDA problem suspected
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,9 @@ public:
|
||||||
|
|
||||||
inline config::Axis Axis() const { return axis; }
|
inline config::Axis Axis() const { return axis; }
|
||||||
|
|
||||||
|
#ifndef UNITTEST
|
||||||
protected:
|
protected:
|
||||||
|
#endif
|
||||||
/// internal state of the automaton
|
/// internal state of the automaton
|
||||||
uint8_t state;
|
uint8_t state;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,7 @@ bool FeedingToFindaStep(logic::CommandBase &tc, uint32_t step, uint32_t triggerA
|
||||||
return tc.TopLevelState() == ProgressCode::FeedingToFinda;
|
return tc.TopLevelState() == ProgressCode::FeedingToFinda;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedingToFinda(logic::ToolChange &tc, uint8_t toSlot, uint32_t triggerAt = 1000) {
|
void FeedingToFinda(logic::ToolChange &tc, uint8_t toSlot, uint32_t triggerAt = 1000) { // feeding to finda
|
||||||
// feeding to finda
|
|
||||||
REQUIRE(WhileCondition(tc, std::bind(FeedingToFindaStep, std::ref(tc), _1, triggerAt), 200'000UL));
|
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));
|
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) {
|
void JustLoadFilament(logic::ToolChange &tc, uint8_t slot) {
|
||||||
ForceReinitAllAutomata();
|
for (uint8_t startSelectorSlot = 0; startSelectorSlot < config::toolCount; ++startSelectorSlot) {
|
||||||
|
ForceReinitAllAutomata();
|
||||||
|
// make sure all the modules are ready
|
||||||
|
// MMU-196: Move selector to a "random" slot
|
||||||
|
REQUIRE(EnsureActiveSlotIndex(startSelectorSlot, mg::FilamentLoadState::AtPulley));
|
||||||
|
|
||||||
REQUIRE(EnsureActiveSlotIndex(slot, mg::FilamentLoadState::AtPulley));
|
// verify filament NOT loaded
|
||||||
|
REQUIRE(VerifyEnvironmentState(mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), startSelectorSlot, false, false, ml::off, ml::off));
|
||||||
|
|
||||||
// verify filament NOT loaded
|
// restart the automaton
|
||||||
REQUIRE(VerifyEnvironmentState(mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), slot, false, false, ml::off, ml::off));
|
tc.Reset(slot);
|
||||||
|
|
||||||
// restart the automaton
|
REQUIRE(ms::selector.plannedSlot == slot); // MMU-196 - make sure the selector is about to move to the desired slot
|
||||||
tc.Reset(slot);
|
|
||||||
|
|
||||||
FeedingToFinda(tc, slot);
|
FeedingToFinda(tc, slot);
|
||||||
|
|
||||||
FeedingToBondtech(tc, slot);
|
FeedingToBondtech(tc, slot);
|
||||||
|
|
||||||
CheckFinishedCorrectly(tc, slot);
|
CheckFinishedCorrectly(tc, slot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("tool_change::test0", "[tool_change]") {
|
TEST_CASE("tool_change::test0", "[tool_change]") {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue