Add finer filament loaded states and improve unit tests
We need to know better where the filament is, a simple "filament loaded true/false" does not correspond to the reality.pull/126/head
parent
5af0125672
commit
c26cc30185
|
|
@ -20,7 +20,7 @@ void CutFilament::Reset(uint8_t param) {
|
|||
error = ErrorCode::RUNNING;
|
||||
cutSlot = param;
|
||||
|
||||
if (mg::globals.FilamentLoaded()) {
|
||||
if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::InSelector) {
|
||||
state = ProgressCode::UnloadingFilament;
|
||||
unl.Reset(cutSlot);
|
||||
} else {
|
||||
|
|
@ -67,6 +67,7 @@ bool CutFilament::StepInner() {
|
|||
if (mm::motion.QueueEmpty()) { // idler and selector finished their moves
|
||||
// move selector aside - prepare the blade into active position
|
||||
state = ProgressCode::PreparingBlade;
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::AtPulley);
|
||||
ms::selector.MoveToSlot(cutSlot + 1);
|
||||
}
|
||||
case ProgressCode::PreparingBlade:
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ void EjectFilament::Reset(uint8_t param) {
|
|||
error = ErrorCode::RUNNING;
|
||||
slot = param;
|
||||
|
||||
if (mg::globals.FilamentLoaded()) {
|
||||
if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::InSelector) {
|
||||
state = ProgressCode::UnloadingFilament;
|
||||
unl.Reset(param); //@@TODO probably act on active extruder only
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ bool FeedToBondtech::Step() {
|
|||
if (mfs::fsensor.Pressed()) {
|
||||
mm::motion.AbortPlannedMoves(); // stop pushing filament
|
||||
mi::idler.Disengage();
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::InNozzle);
|
||||
state = DisengagingIdler;
|
||||
} else if (mm::motion.StallGuard(mm::Pulley)) {
|
||||
// stall guard occurred during movement - the filament got stuck
|
||||
|
|
@ -48,7 +49,6 @@ bool FeedToBondtech::Step() {
|
|||
state = OK;
|
||||
mm::motion.Disable(mm::Pulley);
|
||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::on);
|
||||
mg::globals.SetFilamentLoaded(true);
|
||||
}
|
||||
return false;
|
||||
case OK:
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ bool FeedToFinda::Step() {
|
|||
state = PushingFilament;
|
||||
mm::motion.InitAxis(mm::Pulley);
|
||||
mm::motion.PlanMove<mm::Pulley>(config::feedToFinda, config::pulleyFeedrate);
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::InSelector);
|
||||
mui::userInput.Clear(); // remove all buffered events if any just before we wait for some input
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -23,8 +23,9 @@ bool RetractFromFinda::Step() {
|
|||
return false;
|
||||
case UnloadBackToPTFE:
|
||||
if (mm::motion.QueueEmpty()) { // all moves have been finished
|
||||
if (!mf::finda.Pressed()) { // FINDA switched off correctly
|
||||
if (!mf::finda.Pressed()) { // FINDA switched off correctly while the move was performed
|
||||
state = OK;
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::AtPulley);
|
||||
} else { // FINDA didn't switch off
|
||||
state = Failed;
|
||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ void ToolChange::Reset(uint8_t param) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (param == mg::globals.ActiveSlot() && mg::globals.FilamentLoaded()) {
|
||||
if (param == mg::globals.ActiveSlot() && mg::globals.FilamentLoaded() == mg::FilamentLoadState::InNozzle) {
|
||||
// we are already at the correct slot and the filament is loaded - nothing to do
|
||||
dbg_logic_P(PSTR("we are already at the correct slot and the filament is loaded - nothing to do\n"));
|
||||
return;
|
||||
|
|
@ -29,7 +29,7 @@ void ToolChange::Reset(uint8_t param) {
|
|||
// or we are standing at another slot ...
|
||||
plannedSlot = param;
|
||||
|
||||
if (mg::globals.FilamentLoaded()) {
|
||||
if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::InSelector) {
|
||||
dbg_logic_P(PSTR("Filament is loaded --> unload"));
|
||||
state = ProgressCode::UnloadingFilament;
|
||||
unl.Reset(mg::globals.ActiveSlot());
|
||||
|
|
@ -77,7 +77,7 @@ bool ToolChange::StepInner() {
|
|||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off);
|
||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::blink0); // signal loading error
|
||||
} else {
|
||||
mg::globals.SetFilamentLoaded(true);
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::InNozzle);
|
||||
state = ProgressCode::OK;
|
||||
error = ErrorCode::OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ bool UnloadFilament::StepInner() {
|
|||
state = ProgressCode::OK;
|
||||
error = ErrorCode::OK;
|
||||
mm::motion.Disable(mm::Pulley);
|
||||
mg::globals.SetFilamentLoaded(false); // filament unloaded
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::AtPulley); // filament unloaded
|
||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::off);
|
||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::red, ml::off);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ void UnloadToFinda::Reset(uint8_t maxTries) {
|
|||
bool UnloadToFinda::Step() {
|
||||
switch (state) {
|
||||
case EngagingIdler:
|
||||
if (mg::globals.FilamentLoaded()) {
|
||||
if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::InSelector) {
|
||||
state = UnloadingToFinda;
|
||||
mm::motion.InitAxis(mm::Pulley);
|
||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0);
|
||||
|
|
@ -34,6 +34,7 @@ bool UnloadToFinda::Step() {
|
|||
case UnloadingToFinda:
|
||||
if (mi::idler.Engaged()) {
|
||||
state = WaitingForFINDA;
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::InSelector);
|
||||
mm::motion.PlanMove<mm::Pulley>(-config::defaultBowdenLength - config::feedToFinda - config::filamentMinLoadedToMMU, config::pulleyFeedrate); // @@TODO constants
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ void Globals::SetActiveSlot(uint8_t newActiveSlot) {
|
|||
mps::FilamentLoaded::set(activeSlot);
|
||||
}
|
||||
|
||||
bool Globals::FilamentLoaded() const {
|
||||
FilamentLoadState Globals::FilamentLoaded() const {
|
||||
return filamentLoaded;
|
||||
}
|
||||
|
||||
void Globals::SetFilamentLoaded(bool newFilamentLoaded) {
|
||||
void Globals::SetFilamentLoaded(FilamentLoadState newFilamentLoaded) {
|
||||
filamentLoaded = newFilamentLoaded;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,24 @@ namespace modules {
|
|||
/// The globals namespace provides all necessary facilities related to keeping track of global state of the firmware.
|
||||
namespace globals {
|
||||
|
||||
/// Different stages of filament load.
|
||||
/// Beware:
|
||||
/// - the firmware depends on the order of these values to check for various situations.
|
||||
/// - the unit tests abuse the bitmask-like values to check for multiple situations easily
|
||||
enum FilamentLoadState : uint8_t {
|
||||
// NotLoaded = 0, ///< not loaded in the MMU at all @@TODO still need to decide whether this state is of any use to us
|
||||
AtPulley = 1, ///< loaded to mmu (idler and pulley can grab it)
|
||||
InSelector = 2, ///< loaded in selector (i.e. unsure where the filament is while doing some operation)
|
||||
InNozzle = 4, ///< loaded into printer's filament sensor/nozzle
|
||||
};
|
||||
|
||||
static_assert(
|
||||
/*(FilamentLoadState::NotLoaded < FilamentLoadState::AtPulley)
|
||||
&&*/
|
||||
(FilamentLoadState::AtPulley < FilamentLoadState::InSelector)
|
||||
&& (FilamentLoadState::InSelector < FilamentLoadState::InNozzle),
|
||||
"incorrect order of Slot Filament Load States");
|
||||
|
||||
/// Globals keep track of global state variables in the firmware.
|
||||
/// So far only Active slot and Filament loaded variables are used.
|
||||
class Globals {
|
||||
|
|
@ -23,15 +41,12 @@ public:
|
|||
void SetActiveSlot(uint8_t newActiveSlot);
|
||||
|
||||
/// @returns true if filament is considered as loaded
|
||||
/// @@TODO this may change meaning slightly as the MMU is primarily concerned
|
||||
/// about whether a piece of filament is stock up of a PTFE tube.
|
||||
/// If that's true, we cannot move the selector.
|
||||
bool FilamentLoaded() const;
|
||||
FilamentLoadState FilamentLoaded() const;
|
||||
|
||||
/// Sets the filament loaded flag value, usually after some command/operation.
|
||||
/// Also updates the EEPROM records accordingly
|
||||
/// @param newFilamentLoaded new state
|
||||
void SetFilamentLoaded(bool newFilamentLoaded);
|
||||
void SetFilamentLoaded(FilamentLoadState newFilamentLoaded);
|
||||
|
||||
/// @returns the total number of MMU errors so far
|
||||
/// Errors are stored in the EEPROM
|
||||
|
|
@ -51,7 +66,7 @@ public:
|
|||
|
||||
private:
|
||||
uint8_t activeSlot;
|
||||
bool filamentLoaded;
|
||||
FilamentLoadState filamentLoaded;
|
||||
bool stealthMode;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ void CutSlot(logic::CutFilament &cf, uint8_t cutSlot) {
|
|||
|
||||
ForceReinitAllAutomata();
|
||||
|
||||
REQUIRE(VerifyEnvironmentState(false, mi::Idler::IdleSlotIndex(), 0, false, false, ml::off, ml::off));
|
||||
REQUIRE(VerifyEnvironmentState(mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), 0, false, false, ml::off, ml::off));
|
||||
|
||||
EnsureActiveSlotIndex(cutSlot);
|
||||
|
||||
|
|
@ -33,14 +33,14 @@ void CutSlot(logic::CutFilament &cf, uint8_t cutSlot) {
|
|||
cf.Reset(cutSlot);
|
||||
|
||||
// check initial conditions
|
||||
REQUIRE(VerifyState(cf, false, mi::Idler::IdleSlotIndex(), cutSlot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::SelectingFilamentSlot));
|
||||
REQUIRE(VerifyState(cf, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), cutSlot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::SelectingFilamentSlot));
|
||||
|
||||
// now cycle at most some number of cycles (to be determined yet) and then verify, that the idler and selector reached their target positions
|
||||
// Beware - with the real positions of the selector, the number of steps needed to finish some states grows, so the ~40K steps here has a reason
|
||||
REQUIRE(WhileTopState(cf, ProgressCode::SelectingFilamentSlot, selectorMoveMaxSteps));
|
||||
|
||||
// idler and selector reached their target positions and the CF automaton will start feeding to FINDA as the next step
|
||||
REQUIRE(VerifyState(cf, false, cutSlot, cutSlot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda));
|
||||
REQUIRE(VerifyState(cf, mg::FilamentLoadState::AtPulley, cutSlot, cutSlot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda));
|
||||
|
||||
// prepare for simulated finda trigger
|
||||
REQUIRE(WhileCondition(
|
||||
|
|
@ -52,9 +52,7 @@ void CutSlot(logic::CutFilament &cf, uint8_t cutSlot) {
|
|||
return cf.TopLevelState() == ProgressCode::FeedingToFinda; }, 5000));
|
||||
|
||||
// filament fed to FINDA
|
||||
//@@TODO filament loaded flag - decide whether the filament loaded flag means really loaded into the printer or just a piece of filament
|
||||
// stuck out of the pulley to prevent movement of the selector
|
||||
REQUIRE(VerifyState(cf, /*true*/ false, cutSlot, cutSlot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToPulley));
|
||||
REQUIRE(VerifyState(cf, mg::FilamentLoadState::InSelector, cutSlot, cutSlot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToPulley));
|
||||
|
||||
// pull it back to the pulley + simulate FINDA depress
|
||||
REQUIRE(WhileCondition(
|
||||
|
|
@ -65,23 +63,23 @@ void CutSlot(logic::CutFilament &cf, uint8_t cutSlot) {
|
|||
}
|
||||
return cf.TopLevelState() == ProgressCode::UnloadingToPulley; }, 5000));
|
||||
|
||||
REQUIRE(VerifyState(cf, /*true*/ false, cutSlot, cutSlot, false, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::PreparingBlade));
|
||||
REQUIRE(VerifyState(cf, mg::FilamentLoadState::AtPulley, cutSlot, cutSlot, false, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::PreparingBlade));
|
||||
|
||||
// now move the selector aside, prepare for cutting
|
||||
REQUIRE(WhileTopState(cf, ProgressCode::PreparingBlade, 5000));
|
||||
REQUIRE(VerifyState2(cf, /*true*/ false, cutSlot, cutSlot + 1, false, true, cutSlot, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::PushingFilament));
|
||||
REQUIRE(VerifyState2(cf, mg::FilamentLoadState::AtPulley, cutSlot, cutSlot + 1, false, true, cutSlot, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::PushingFilament));
|
||||
|
||||
// pushing filament a bit for a cut
|
||||
REQUIRE(WhileTopState(cf, ProgressCode::PushingFilament, 5000));
|
||||
REQUIRE(VerifyState2(cf, /*true*/ false, cutSlot, cutSlot + 1, false, true, cutSlot, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::PerformingCut));
|
||||
REQUIRE(VerifyState2(cf, mg::FilamentLoadState::AtPulley, cutSlot, cutSlot + 1, false, true, cutSlot, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::PerformingCut));
|
||||
|
||||
// cutting
|
||||
REQUIRE(WhileTopState(cf, ProgressCode::PerformingCut, selectorMoveMaxSteps));
|
||||
REQUIRE(VerifyState2(cf, /*true*/ false, cutSlot, 0, false, true, cutSlot, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::ReturningSelector));
|
||||
REQUIRE(VerifyState2(cf, mg::FilamentLoadState::AtPulley, cutSlot, 0, false, true, cutSlot, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::ReturningSelector));
|
||||
|
||||
// moving selector to the other end of its axis
|
||||
REQUIRE(WhileTopState(cf, ProgressCode::ReturningSelector, selectorMoveMaxSteps));
|
||||
REQUIRE(VerifyState2(cf, /*true*/ false, cutSlot, ms::Selector::IdleSlotIndex(), false, true, cutSlot, ml::blink0, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
REQUIRE(VerifyState2(cf, mg::FilamentLoadState::AtPulley, cutSlot, ms::Selector::IdleSlotIndex(), false, true, cutSlot, ml::blink0, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
}
|
||||
|
||||
TEST_CASE("cut_filament::cut0", "[cut_filament]") {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ void FailingIdler(hal::tmc2130::ErrorFlags ef, ErrorCode ec) {
|
|||
// change the startup to what we need here
|
||||
EnsureActiveSlotIndex(0);
|
||||
|
||||
mg::globals.SetFilamentLoaded(true);
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::InNozzle);
|
||||
|
||||
// set FINDA ON + debounce
|
||||
SetFINDAStateAndDebounce(true);
|
||||
|
|
@ -49,12 +49,12 @@ void FailingIdler(hal::tmc2130::ErrorFlags ef, ErrorCode ec) {
|
|||
logic::UnloadFilament uf;
|
||||
|
||||
// verify startup conditions
|
||||
REQUIRE(VerifyState(uf, true, mi::Idler::IdleSlotIndex(), 0, true, false, ml::off, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), 0, true, false, ml::off, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
|
||||
// UnloadFilament starts by engaging the idler (through the UnloadToFinda state machine)
|
||||
uf.Reset(0);
|
||||
|
||||
REQUIRE(VerifyState(uf, true, mi::Idler::IdleSlotIndex(), 0, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), 0, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
|
||||
int failingStep = 5;
|
||||
REQUIRE(WhileCondition(
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
bool VerifyEnvironmentState(bool filamentLoaded, uint8_t idlerSlotIndex, uint8_t selectorSlotIndex,
|
||||
bool VerifyEnvironmentState(mg::FilamentLoadState fls, uint8_t idlerSlotIndex, uint8_t selectorSlotIndex,
|
||||
bool findaPressed, bool pulleyEnabled, ml::Mode greenLEDMode, ml::Mode redLEDMode) {
|
||||
CHECKED_ELSE(mg::globals.FilamentLoaded() == filamentLoaded) {
|
||||
CHECKED_ELSE(mg::globals.FilamentLoaded() & fls) { // beware - abusing the values as bit masks to detect multiple situations at once
|
||||
return false;
|
||||
}
|
||||
CHECKED_ELSE(mm::axes[mm::Idler].pos == mi::Idler::SlotPosition(idlerSlotIndex).v) {
|
||||
|
|
@ -45,10 +45,10 @@ bool VerifyEnvironmentState(bool filamentLoaded, uint8_t idlerSlotIndex, uint8_t
|
|||
|
||||
// LED checked at selector's index
|
||||
template<typename SM>
|
||||
bool VerifyState(SM &uf, bool filamentLoaded, uint8_t idlerSlotIndex, uint8_t selectorSlotIndex,
|
||||
bool VerifyState(SM &uf, mg::FilamentLoadState fls, uint8_t idlerSlotIndex, uint8_t selectorSlotIndex,
|
||||
bool findaPressed, bool pulleyEnabled, ml::Mode greenLEDMode, ml::Mode redLEDMode, ErrorCode err, ProgressCode topLevelProgress) {
|
||||
|
||||
VerifyEnvironmentState(filamentLoaded, idlerSlotIndex, selectorSlotIndex, findaPressed, pulleyEnabled, greenLEDMode, redLEDMode);
|
||||
VerifyEnvironmentState(fls, idlerSlotIndex, selectorSlotIndex, findaPressed, pulleyEnabled, greenLEDMode, redLEDMode);
|
||||
|
||||
CHECKED_ELSE(uf.Error() == err) {
|
||||
return false;
|
||||
|
|
@ -61,9 +61,9 @@ bool VerifyState(SM &uf, bool filamentLoaded, uint8_t idlerSlotIndex, uint8_t se
|
|||
|
||||
// LED checked at their own ledCheckIndex index
|
||||
template<typename SM>
|
||||
bool VerifyState2(SM &uf, bool filamentLoaded, uint8_t idlerSlotIndex, uint8_t selectorSlotIndex,
|
||||
bool VerifyState2(SM &uf, mg::FilamentLoadState fls, uint8_t idlerSlotIndex, uint8_t selectorSlotIndex,
|
||||
bool findaPressed, bool pulleyEnabled, uint8_t ledCheckIndex, ml::Mode greenLEDMode, ml::Mode redLEDMode, ErrorCode err, ProgressCode topLevelProgress) {
|
||||
CHECKED_ELSE(mg::globals.FilamentLoaded() == filamentLoaded) {
|
||||
CHECKED_ELSE(mg::globals.FilamentLoaded() & fls) {
|
||||
return false;
|
||||
}
|
||||
CHECKED_ELSE(mm::axes[mm::Idler].pos == mi::Idler::SlotPosition(idlerSlotIndex).v) {
|
||||
|
|
@ -117,10 +117,10 @@ template<typename SM>
|
|||
void InvalidSlot(SM &logicSM, uint8_t activeSlot, uint8_t invSlot){
|
||||
ForceReinitAllAutomata();
|
||||
|
||||
REQUIRE(VerifyEnvironmentState(false, mi::Idler::IdleSlotIndex(), 0, false, false, ml::off, ml::off));
|
||||
REQUIRE(VerifyEnvironmentState(mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), 0, false, false, ml::off, ml::off));
|
||||
|
||||
EnsureActiveSlotIndex(activeSlot);
|
||||
|
||||
logicSM.Reset(invSlot);
|
||||
REQUIRE(VerifyState(logicSM, false, mi::Idler::IdleSlotIndex(), activeSlot, false, false, ml::off, ml::off, ErrorCode::INVALID_TOOL, ProgressCode::OK));
|
||||
REQUIRE(VerifyState(logicSM, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), activeSlot, false, false, ml::off, ml::off, ErrorCode::INVALID_TOOL, ProgressCode::OK));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ void LoadFilamentCommonSetup(uint8_t slot, logic::LoadFilament &lf) {
|
|||
EnsureActiveSlotIndex(slot);
|
||||
|
||||
// verify startup conditions
|
||||
REQUIRE(VerifyState(lf, false, mi::Idler::IdleSlotIndex(), slot, false, false, ml::off, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), slot, false, false, ml::off, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
|
||||
// restart the automaton
|
||||
lf.Reset(slot);
|
||||
|
|
@ -39,11 +39,11 @@ void LoadFilamentCommonSetup(uint8_t slot, logic::LoadFilament &lf) {
|
|||
// no change in selector's position
|
||||
// FINDA off
|
||||
// green LED should blink, red off
|
||||
REQUIRE(VerifyState(lf, false, mi::Idler::IdleSlotIndex(), slot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::EngagingIdler));
|
||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), slot, false, false, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::EngagingIdler));
|
||||
|
||||
// Stage 1 - engaging idler
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::EngagingIdler, idlerEngageDisengageMaxSteps));
|
||||
REQUIRE(VerifyState(lf, false, slot, slot, false, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda));
|
||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::AtPulley, slot, slot, false, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::FeedingToFinda));
|
||||
}
|
||||
|
||||
void LoadFilamentSuccessful(uint8_t slot, logic::LoadFilament &lf) {
|
||||
|
|
@ -57,7 +57,7 @@ void LoadFilamentSuccessful(uint8_t slot, logic::LoadFilament &lf) {
|
|||
}
|
||||
return lf.TopLevelState() == ProgressCode::FeedingToFinda; },
|
||||
5000));
|
||||
REQUIRE(VerifyState(lf, false, slot, slot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::RetractingFromFinda));
|
||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, slot, slot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::RetractingFromFinda));
|
||||
|
||||
// Stage 3 - retracting from finda
|
||||
// we'll assume the finda is working correctly here
|
||||
|
|
@ -69,11 +69,11 @@ void LoadFilamentSuccessful(uint8_t slot, logic::LoadFilament &lf) {
|
|||
}
|
||||
return lf.TopLevelState() == ProgressCode::RetractingFromFinda; },
|
||||
5000));
|
||||
REQUIRE(VerifyState(lf, false, slot, slot, false, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::DisengagingIdler));
|
||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::AtPulley, slot, slot, false, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::DisengagingIdler));
|
||||
|
||||
// Stage 4 - disengaging idler
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::DisengagingIdler, idlerEngageDisengageMaxSteps));
|
||||
REQUIRE(VerifyState(lf, false, mi::Idler::IdleSlotIndex(), slot, false, false, ml::on, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), slot, false, false, ml::on, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
}
|
||||
|
||||
TEST_CASE("load_filament::regular_load_to_slot_0-4", "[load_filament]") {
|
||||
|
|
@ -88,11 +88,11 @@ void FailedLoadToFinda(uint8_t slot, logic::LoadFilament &lf) {
|
|||
// Stage 2 - feeding to finda
|
||||
// we'll assume the finda is defective here and does not trigger
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::FeedingToFinda, 5000));
|
||||
REQUIRE(VerifyState(lf, false, slot, slot, false, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRDisengagingIdler));
|
||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, slot, slot, false, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRDisengagingIdler));
|
||||
|
||||
// Stage 3 - disengaging idler in error mode
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::ERRDisengagingIdler, idlerEngageDisengageMaxSteps));
|
||||
REQUIRE(VerifyState(lf, false, mi::Idler::IdleSlotIndex(), slot, false, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRWaitingForUser));
|
||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, false, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRWaitingForUser));
|
||||
}
|
||||
|
||||
void FailedLoadToFindaResolveHelp(uint8_t slot, logic::LoadFilament &lf) {
|
||||
|
|
@ -111,12 +111,12 @@ void FailedLoadToFindaResolveHelp(uint8_t slot, logic::LoadFilament &lf) {
|
|||
lf.Step();
|
||||
}
|
||||
|
||||
REQUIRE(VerifyState(lf, false, mi::Idler::IdleSlotIndex(), slot, false, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERREngagingIdler));
|
||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, false, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERREngagingIdler));
|
||||
|
||||
// Stage 4 - engage the idler
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::ERREngagingIdler, idlerEngageDisengageMaxSteps));
|
||||
|
||||
REQUIRE(VerifyState(lf, false, slot, slot, false, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRHelpingFilament));
|
||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, slot, slot, false, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRHelpingFilament));
|
||||
}
|
||||
|
||||
void FailedLoadToFindaResolveHelpFindaTriggered(uint8_t slot, logic::LoadFilament &lf) {
|
||||
|
|
@ -130,14 +130,14 @@ void FailedLoadToFindaResolveHelpFindaTriggered(uint8_t slot, logic::LoadFilamen
|
|||
return lf.TopLevelState() == ProgressCode::ERRHelpingFilament; },
|
||||
5000));
|
||||
|
||||
REQUIRE(VerifyState(lf, false, slot, slot, true, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::FeedingToBondtech));
|
||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, slot, slot, true, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::FeedingToBondtech));
|
||||
}
|
||||
|
||||
void FailedLoadToFindaResolveHelpFindaDidntTrigger(uint8_t slot, logic::LoadFilament &lf) {
|
||||
// Stage 5 - move the pulley a bit - no FINDA change
|
||||
REQUIRE(WhileTopState(lf, ProgressCode::ERRHelpingFilament, 5000));
|
||||
|
||||
REQUIRE(VerifyState(lf, false, slot, slot, false, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRDisengagingIdler));
|
||||
REQUIRE(VerifyState(lf, mg::FilamentLoadState::InSelector, slot, slot, false, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_ON, ProgressCode::ERRDisengagingIdler));
|
||||
}
|
||||
|
||||
TEST_CASE("load_filament::failed_load_to_finda_0-4_resolve_help_second_ok", "[load_filament]") {
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ void ForceReinitAllAutomata() {
|
|||
mm::ReinitMotion();
|
||||
|
||||
// let's assume we have the filament NOT loaded and active slot 0
|
||||
mg::globals.SetFilamentLoaded(false);
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::AtPulley);
|
||||
mg::globals.SetActiveSlot(0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ void FeedingToFinda(logic::ToolChange &tc, uint8_t toSlot) {
|
|||
}
|
||||
return tc.TopLevelState() == ProgressCode::FeedingToFinda; },
|
||||
200000UL));
|
||||
REQUIRE(VerifyState(tc, false, 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));
|
||||
}
|
||||
|
||||
void FeedingToBondtech(logic::ToolChange &tc, uint8_t toSlot) {
|
||||
|
|
@ -44,7 +44,7 @@ void FeedingToBondtech(logic::ToolChange &tc, uint8_t toSlot) {
|
|||
}
|
||||
return tc.TopLevelState() == ProgressCode::FeedingToBondtech; },
|
||||
200000UL));
|
||||
REQUIRE(VerifyState(tc, true, mi::Idler::IdleSlotIndex(), toSlot, true, false, ml::on, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), toSlot, true, false, ml::on, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
}
|
||||
|
||||
void ToolChange(logic::ToolChange tc, uint8_t fromSlot, uint8_t toSlot) {
|
||||
|
|
@ -63,14 +63,14 @@ void ToolChange(logic::ToolChange tc, uint8_t fromSlot, uint8_t toSlot) {
|
|||
}
|
||||
return tc.TopLevelState() == ProgressCode::UnloadingFilament; },
|
||||
200000UL));
|
||||
REQUIRE(mg::globals.FilamentLoaded() == false);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == mg::FilamentLoadState::AtPulley);
|
||||
|
||||
FeedingToFinda(tc, toSlot);
|
||||
|
||||
FeedingToBondtech(tc, toSlot);
|
||||
|
||||
REQUIRE(tc.TopLevelState() == ProgressCode::OK);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == true);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == mg::FilamentLoadState::InNozzle);
|
||||
REQUIRE(mg::globals.ActiveSlot() == toSlot);
|
||||
}
|
||||
|
||||
|
|
@ -78,11 +78,11 @@ void NoToolChange(logic::ToolChange tc, uint8_t fromSlot, uint8_t toSlot) {
|
|||
ForceReinitAllAutomata();
|
||||
|
||||
// the filament is LOADED
|
||||
mg::globals.SetFilamentLoaded(true);
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::InNozzle);
|
||||
|
||||
EnsureActiveSlotIndex(fromSlot);
|
||||
|
||||
REQUIRE(VerifyEnvironmentState(true, mi::Idler::IdleSlotIndex(), toSlot, false, false, ml::off, ml::off));
|
||||
REQUIRE(VerifyEnvironmentState(mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), toSlot, false, false, ml::off, ml::off));
|
||||
|
||||
// restart the automaton
|
||||
tc.Reset(toSlot);
|
||||
|
|
@ -98,7 +98,7 @@ void JustLoadFilament(logic::ToolChange tc, uint8_t slot) {
|
|||
EnsureActiveSlotIndex(slot);
|
||||
|
||||
// verify filament NOT loaded
|
||||
REQUIRE(VerifyEnvironmentState(false, mi::Idler::IdleSlotIndex(), slot, false, false, ml::off, ml::off));
|
||||
REQUIRE(VerifyEnvironmentState(mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), slot, false, false, ml::off, ml::off));
|
||||
|
||||
// restart the automaton
|
||||
tc.Reset(slot);
|
||||
|
|
@ -108,7 +108,7 @@ void JustLoadFilament(logic::ToolChange tc, uint8_t slot) {
|
|||
FeedingToBondtech(tc, slot);
|
||||
|
||||
REQUIRE(tc.TopLevelState() == ProgressCode::OK);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == true);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == mg::FilamentLoadState::InNozzle);
|
||||
REQUIRE(mg::globals.ActiveSlot() == slot);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ void RegularUnloadFromSlot04Init(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// change the startup to what we need here
|
||||
EnsureActiveSlotIndex(slot);
|
||||
|
||||
mg::globals.SetFilamentLoaded(true);
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::InNozzle);
|
||||
|
||||
// set FINDA ON + debounce
|
||||
SetFINDAStateAndDebounce(true);
|
||||
|
||||
// verify startup conditions
|
||||
REQUIRE(VerifyState(uf, true, mi::Idler::IdleSlotIndex(), slot, true, false, ml::off, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), slot, true, false, ml::off, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
|
||||
// restart the automaton
|
||||
uf.Reset(slot);
|
||||
|
|
@ -47,7 +47,8 @@ void RegularUnloadFromSlot04(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// no change in selector's position
|
||||
// FINDA on
|
||||
// green LED should blink, red off
|
||||
REQUIRE(VerifyState(uf, true, mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
REQUIRE(VerifyState(uf, (mg::FilamentLoadState)(mg::FilamentLoadState::InNozzle | mg::FilamentLoadState::InSelector),
|
||||
mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
|
||||
// run the automaton
|
||||
// Stage 1 - unloading to FINDA
|
||||
|
|
@ -65,7 +66,7 @@ void RegularUnloadFromSlot04(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// no change in selector's position
|
||||
// FINDA triggered off
|
||||
// green LED should be off
|
||||
REQUIRE(VerifyState(uf, true, slot, slot, false, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::DisengagingIdler));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, slot, slot, false, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::DisengagingIdler));
|
||||
|
||||
// Stage 2 - idler was engaged, disengage it
|
||||
REQUIRE(WhileTopState(uf, ProgressCode::DisengagingIdler, idlerEngageDisengageMaxSteps));
|
||||
|
|
@ -75,7 +76,7 @@ void RegularUnloadFromSlot04(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// no change in selector's position
|
||||
// FINDA still triggered off
|
||||
// green LED should be off
|
||||
REQUIRE(VerifyState(uf, true, mi::Idler::IdleSlotIndex(), slot, false, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::AvoidingGrind));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, false, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::AvoidingGrind));
|
||||
|
||||
// Stage 3 - avoiding grind (whatever is that @@TODO)
|
||||
REQUIRE(WhileTopState(uf, ProgressCode::AvoidingGrind, 5000));
|
||||
|
|
@ -85,7 +86,7 @@ void RegularUnloadFromSlot04(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// no change in selector's position
|
||||
// FINDA still triggered off
|
||||
// green LED should be off
|
||||
REQUIRE(VerifyState(uf, true, mi::Idler::IdleSlotIndex(), slot, false, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::FinishingMoves));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, false, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::FinishingMoves));
|
||||
|
||||
// Stage 4 - finishing moves and setting global state correctly
|
||||
REQUIRE(WhileTopState(uf, ProgressCode::FinishingMoves, 5000));
|
||||
|
|
@ -95,11 +96,11 @@ void RegularUnloadFromSlot04(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// no change in selector's position
|
||||
// FINDA still triggered off
|
||||
// green LED should be OFF
|
||||
REQUIRE(VerifyState(uf, false, mi::Idler::IdleSlotIndex(), slot, false, false, ml::off, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::AtPulley, mi::Idler::IdleSlotIndex(), slot, false, false, ml::off, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
|
||||
// Stage 5 - repeated calls to TopLevelState should return "OK"
|
||||
REQUIRE(uf.TopLevelState() == ProgressCode::OK);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == false);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == mg::FilamentLoadState::AtPulley);
|
||||
REQUIRE(mf::finda.Pressed() == false);
|
||||
REQUIRE(uf.Error() == ErrorCode::OK); // no error
|
||||
}
|
||||
|
|
@ -123,10 +124,10 @@ void FindaDidntTriggerCommonSetup(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// set FINDA ON + debounce
|
||||
SetFINDAStateAndDebounce(true);
|
||||
|
||||
mg::globals.SetFilamentLoaded(true);
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::InNozzle);
|
||||
|
||||
// verify startup conditions
|
||||
REQUIRE(VerifyState(uf, true, mi::Idler::IdleSlotIndex(), slot, true, false, ml::off, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), slot, true, false, ml::off, ml::off, ErrorCode::OK, ProgressCode::OK));
|
||||
|
||||
// restart the automaton
|
||||
uf.Reset(slot);
|
||||
|
|
@ -138,7 +139,7 @@ void FindaDidntTriggerCommonSetup(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// FINDA triggered off
|
||||
// green LED should be off
|
||||
// no error so far
|
||||
REQUIRE(VerifyState(uf, true, mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
|
||||
// run the automaton
|
||||
// Stage 1 - unloading to FINDA - do NOT let it trigger - keep it pressed, the automaton should finish all moves with the pulley
|
||||
|
|
@ -150,7 +151,7 @@ void FindaDidntTriggerCommonSetup(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// no change in selector's position
|
||||
// FINDA still on
|
||||
// red LED should blink, green LED should be off
|
||||
REQUIRE(VerifyState(uf, true, slot, slot, true, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_OFF, ProgressCode::ERRDisengagingIdler));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, slot, slot, true, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_OFF, ProgressCode::ERRDisengagingIdler));
|
||||
|
||||
// Stage 2 - idler should get disengaged
|
||||
REQUIRE(WhileTopState(uf, ProgressCode::ERRDisengagingIdler, idlerEngageDisengageMaxSteps));
|
||||
|
|
@ -161,7 +162,7 @@ void FindaDidntTriggerCommonSetup(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// FINDA still on
|
||||
// red LED should blink
|
||||
// green LED should be off
|
||||
REQUIRE(VerifyState(uf, true, mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_OFF, ProgressCode::ERRWaitingForUser));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_OFF, ProgressCode::ERRWaitingForUser));
|
||||
}
|
||||
|
||||
void FindaDidntTriggerResolveHelp(uint8_t slot, logic::UnloadFilament &uf) {
|
||||
|
|
@ -186,7 +187,7 @@ void FindaDidntTriggerResolveHelp(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// no change in selector's position
|
||||
// FINDA still on
|
||||
// red LED should blink, green LED should be off
|
||||
REQUIRE(VerifyState(uf, true, mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_OFF, ProgressCode::ERREngagingIdler));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_OFF, ProgressCode::ERREngagingIdler));
|
||||
|
||||
// Stage 4 - engage the idler
|
||||
REQUIRE(WhileTopState(uf, ProgressCode::ERREngagingIdler, idlerEngageDisengageMaxSteps));
|
||||
|
|
@ -196,7 +197,7 @@ void FindaDidntTriggerResolveHelp(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// no change in selector's position
|
||||
// FINDA still on
|
||||
// red LED should blink, green LED should be off
|
||||
REQUIRE(VerifyState(uf, true, slot, slot, true, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_OFF, ProgressCode::ERRHelpingFilament));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, slot, slot, true, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_OFF, ProgressCode::ERRHelpingFilament));
|
||||
}
|
||||
|
||||
void FindaDidntTriggerResolveHelpFindaTriggered(uint8_t slot, logic::UnloadFilament &uf) {
|
||||
|
|
@ -215,7 +216,7 @@ void FindaDidntTriggerResolveHelpFindaTriggered(uint8_t slot, logic::UnloadFilam
|
|||
// no change in selector's position
|
||||
// FINDA depressed
|
||||
// red LED should blink, green LED should be off
|
||||
REQUIRE(VerifyState(uf, true, slot, slot, false, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::DisengagingIdler));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, slot, slot, false, true, ml::off, ml::blink0, ErrorCode::RUNNING, ProgressCode::DisengagingIdler));
|
||||
}
|
||||
|
||||
void FindaDidntTriggerResolveHelpFindaDidntTrigger(uint8_t slot, logic::UnloadFilament &uf) {
|
||||
|
|
@ -227,7 +228,7 @@ void FindaDidntTriggerResolveHelpFindaDidntTrigger(uint8_t slot, logic::UnloadFi
|
|||
// no change in selector's position
|
||||
// FINDA still pressed
|
||||
// red LED should blink, green LED should be off
|
||||
REQUIRE(VerifyState(uf, true, slot, slot, true, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_OFF, ProgressCode::ERRDisengagingIdler));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, slot, slot, true, true, ml::off, ml::blink0, ErrorCode::FINDA_DIDNT_SWITCH_OFF, ProgressCode::ERRDisengagingIdler));
|
||||
}
|
||||
|
||||
TEST_CASE("unload_filament::finda_didnt_trigger_resolve_help_second_ok", "[unload_filament]") {
|
||||
|
|
@ -270,7 +271,7 @@ void FindaDidntTriggerResolveTryAgain(uint8_t slot, logic::UnloadFilament &uf) {
|
|||
// no change in selector's position
|
||||
// FINDA still on
|
||||
// red LED should blink, green LED should be off
|
||||
REQUIRE(VerifyState(uf, true, mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, mi::Idler::IdleSlotIndex(), slot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||
}
|
||||
|
||||
TEST_CASE("unload_filament::finda_didnt_trigger_resolve_try_again", "[unload_filament]") {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ TEST_CASE("unload_to_finda::regular_unload", "[unload_to_finda]") {
|
|||
// we need finda ON
|
||||
SetFINDAStateAndDebounce(true);
|
||||
// and MMU "thinks" it has the filament loaded
|
||||
mg::globals.SetFilamentLoaded(true);
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::InNozzle);
|
||||
|
||||
logic::UnloadToFinda ff;
|
||||
|
||||
|
|
@ -57,6 +57,7 @@ TEST_CASE("unload_to_finda::regular_unload", "[unload_to_finda]") {
|
|||
50000));
|
||||
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::OK);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == mg::FilamentLoadState::InSelector);
|
||||
}
|
||||
|
||||
TEST_CASE("unload_to_finda::no_sense_FINDA_upon_start", "[unload_to_finda]") {
|
||||
|
|
@ -78,7 +79,7 @@ TEST_CASE("unload_to_finda::unload_without_FINDA_trigger", "[unload_to_finda]")
|
|||
// we need finda ON
|
||||
SetFINDAStateAndDebounce(true);
|
||||
// and MMU "thinks" it has the filament loaded
|
||||
mg::globals.SetFilamentLoaded(true);
|
||||
mg::globals.SetFilamentLoaded(mg::FilamentLoadState::InNozzle);
|
||||
|
||||
logic::UnloadToFinda ff;
|
||||
|
||||
|
|
@ -109,4 +110,5 @@ TEST_CASE("unload_to_finda::unload_without_FINDA_trigger", "[unload_to_finda]")
|
|||
50000));
|
||||
|
||||
REQUIRE(ff.State() == logic::UnloadToFinda::Failed);
|
||||
REQUIRE(mg::globals.FilamentLoaded() == mg::FilamentLoadState::InSelector);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue