From f428075a4d64b0faf8db0c507d821f1a626c1185 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Wed, 11 May 2022 07:17:26 +0200 Subject: [PATCH] Make LoadFilament retract even when stopped with a button + fix unrelated unit test of unload to finda which got broken in PR#160 --- src/logic/load_filament.cpp | 6 +----- tests/unit/logic/unload_to_finda/test_unload_to_finda.cpp | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/logic/load_filament.cpp b/src/logic/load_filament.cpp index 17d8306..2c3b1da 100644 --- a/src/logic/load_filament.cpp +++ b/src/logic/load_filament.cpp @@ -62,14 +62,10 @@ bool LoadFilament::StepInner() { GoToErrDisengagingIdler(ErrorCode::FINDA_DIDNT_SWITCH_ON); // signal loading error break; case FeedToFinda::OK: + case FeedToFinda::Stopped: // as requested in MMU-77 - stopping an unsuccessful feed should retract as well state = ProgressCode::RetractingFromFinda; retract.Reset(); break; - case FeedToFinda::Stopped: - // the user stopped the load for whatever reason - // - we are considering the LoadFlament operation as completed - FinishedOK(); - break; } } break; diff --git a/tests/unit/logic/unload_to_finda/test_unload_to_finda.cpp b/tests/unit/logic/unload_to_finda/test_unload_to_finda.cpp index 13c9185..b68c29e 100644 --- a/tests/unit/logic/unload_to_finda/test_unload_to_finda.cpp +++ b/tests/unit/logic/unload_to_finda/test_unload_to_finda.cpp @@ -178,8 +178,8 @@ TEST_CASE("unload_to_finda::unload_repeated", "[unload_to_finda]") { // it should have instructed the selector and idler to move to slot 1 // check if the idler and selector have the right command - CHECK(mm::axes[mm::Idler].targetPos == mi::Idler::SlotPosition(0).v); - CHECK(mm::axes[mm::Selector].targetPos == ms::Selector::SlotPosition(0).v); + CHECK(mm::AxisNearestTargetPos(mm::Idler) == mi::Idler::SlotPosition(0).v); + CHECK(mm::AxisNearestTargetPos(mm::Selector) == ms::Selector::SlotPosition(0).v); CHECK(mm::axes[mm::Idler].enabled == true); // engaging idler @@ -195,7 +195,7 @@ TEST_CASE("unload_to_finda::unload_repeated", "[unload_to_finda]") { // but set FSensor correctly // In this case it is vital to correctly compute the amount of steps // to make the unload state machine restart after the 1st attempt - uint32_t unlSteps = mm::unitToSteps(config::defaultBowdenLength + config::feedToFinda + config::filamentMinLoadedToMMU); + uint32_t unlSteps = 1 + mm::unitToSteps(config::defaultBowdenLength + config::feedToFinda + config::filamentMinLoadedToMMU); REQUIRE_FALSE(WhileCondition(ff, std::bind(SimulateUnloadToFINDA, _1, 10, 150000), unlSteps)); main_loop();