diff --git a/src/logic/command_base.h b/src/logic/command_base.h index 1571d5f..1a40ead 100644 --- a/src/logic/command_base.h +++ b/src/logic/command_base.h @@ -95,7 +95,9 @@ public: /// filament presence according to known sensors (FINDA+FSensor) static void InvalidateHomingAndFilamentState(); +#ifndef UNITTEST protected: +#endif /// @returns true if the slot/tool index is within specified range (0 - config::toolCount) /// If not, it returns false and sets the error to ErrorCode::INVALID_TOOL bool CheckToolIndex(uint8_t index); diff --git a/tests/unit/logic/cut_filament/test_cut_filament.cpp b/tests/unit/logic/cut_filament/test_cut_filament.cpp index 0495199..7fbec02 100644 --- a/tests/unit/logic/cut_filament/test_cut_filament.cpp +++ b/tests/unit/logic/cut_filament/test_cut_filament.cpp @@ -28,7 +28,7 @@ void CutSlot(logic::CutFilament &cf, uint8_t startSlot, uint8_t cutSlot) { ForceReinitAllAutomata(); REQUIRE(EnsureActiveSlotIndex(startSlot, mg::FilamentLoadState::AtPulley)); - REQUIRE(VerifyEnvironmentState(mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), startSlot, false, false, ml::off, ml::off)); + REQUIRE(VerifyState(cf, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), startSlot, false, false, ml::off, ml::off, ErrorCode::OK, ProgressCode::OK)); // restart the automaton cf.Reset(cutSlot); @@ -108,6 +108,11 @@ TEST_CASE("cut_filament::state_machine_reusal", "[cut_filament]") { logic::CutFilament cf; for (uint8_t activeSlot = 0; activeSlot < config::toolCount; ++activeSlot) { InvalidSlot(cf, activeSlot, config::toolCount); + // @@TODO if the automaton end up in an INVALID_TOOL error, + // we don't get out of it by any other means than calling a Reset + // May be that's an issue/feature of all logic layer state machines. + // Generally not that important, but it would be nice to handle such a scenario gracefully + cf.error = ErrorCode::OK; } for (uint8_t startSlot = 0; startSlot < config::toolCount; ++startSlot) { @@ -120,6 +125,7 @@ TEST_CASE("cut_filament::state_machine_reusal", "[cut_filament]") { for (uint8_t cutSlot = 0; cutSlot < config::toolCount; ++cutSlot) { CutSlot(cf, startSlot, cutSlot); InvalidSlot(cf, cutSlot, config::toolCount); + cf.error = ErrorCode::OK; } } }