UnloadFilament: update unit tests + LED signalization
parent
e089be4ff8
commit
3aed994b9c
|
|
@ -17,7 +17,7 @@ void FeedToBondtech::Reset(uint8_t maxRetries) {
|
||||||
dbg_logic_P(PSTR("\nFeed to Bondtech\n\n"));
|
dbg_logic_P(PSTR("\nFeed to Bondtech\n\n"));
|
||||||
state = EngagingIdler;
|
state = EngagingIdler;
|
||||||
this->maxRetries = maxRetries;
|
this->maxRetries = maxRetries;
|
||||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0);
|
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off);
|
||||||
mi::idler.Engage(mg::globals.ActiveSlot());
|
mi::idler.Engage(mg::globals.ActiveSlot());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ bool UnloadFilament::Reset(uint8_t /*param*/) {
|
||||||
error = ErrorCode::RUNNING;
|
error = ErrorCode::RUNNING;
|
||||||
skipDisengagingIdler = false;
|
skipDisengagingIdler = false;
|
||||||
unl.Reset(maxRetries);
|
unl.Reset(maxRetries);
|
||||||
ml::leds.SetAllOff();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ void UnloadToFinda::Reset(uint8_t maxTries) {
|
||||||
state = EngagingIdler;
|
state = EngagingIdler;
|
||||||
mi::idler.PartiallyDisengage(mg::globals.ActiveSlot()); // basically prepare before the active slot - saves ~1s
|
mi::idler.PartiallyDisengage(mg::globals.ActiveSlot()); // basically prepare before the active slot - saves ~1s
|
||||||
started_ms = mt::timebase.Millis();
|
started_ms = mt::timebase.Millis();
|
||||||
|
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,7 +47,6 @@ bool UnloadToFinda::Step() {
|
||||||
if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::InSelector) {
|
if (mg::globals.FilamentLoaded() >= mg::FilamentLoadState::InSelector) {
|
||||||
state = UnloadingToFinda;
|
state = UnloadingToFinda;
|
||||||
mpu::pulley.InitAxis();
|
mpu::pulley.InitAxis();
|
||||||
ml::leds.SetMode(mg::globals.ActiveSlot(), ml::green, ml::blink0);
|
|
||||||
mi::idler.Engage(mg::globals.ActiveSlot());
|
mi::idler.Engage(mg::globals.ActiveSlot());
|
||||||
|
|
||||||
// slow move for the first few millimeters - help the printer relieve the filament while engaging the Idler fully
|
// slow move for the first few millimeters - help the printer relieve the filament while engaging the Idler fully
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ void FailingMovableUnload(hal::tmc2130::ErrorFlags ef, ErrorCode ec, config::Axi
|
||||||
// UnloadFilament starts by engaging the idler (through the UnloadToFinda state machine)
|
// UnloadFilament starts by engaging the idler (through the UnloadToFinda state machine)
|
||||||
uf.Reset(0);
|
uf.Reset(0);
|
||||||
|
|
||||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, 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::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||||
|
|
||||||
REQUIRE(WhileCondition(
|
REQUIRE(WhileCondition(
|
||||||
uf,
|
uf,
|
||||||
|
|
|
||||||
|
|
@ -328,7 +328,7 @@ void ToolChangeFailFSensor(logic::ToolChange &tc, uint8_t fromSlot, uint8_t toSl
|
||||||
// restart the automaton
|
// restart the automaton
|
||||||
tc.Reset(toSlot);
|
tc.Reset(toSlot);
|
||||||
|
|
||||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InNozzle, mi::idler.IdleSlotIndex(), fromSlot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament));
|
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InNozzle, mi::idler.IdleSlotIndex(), fromSlot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament));
|
||||||
// simulate unload to finda but fail the fsensor test
|
// simulate unload to finda but fail the fsensor test
|
||||||
REQUIRE(WhileCondition(tc, std::bind(SimulateUnloadToFINDA, _1, 500'000, 10'000), 200'000));
|
REQUIRE(WhileCondition(tc, std::bind(SimulateUnloadToFINDA, _1, 500'000, 10'000), 200'000));
|
||||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::idler.IdleSlotIndex(), fromSlot, false, false, ml::off, ml::blink0, ErrorCode::FSENSOR_DIDNT_SWITCH_OFF, ProgressCode::UnloadingFilament));
|
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::idler.IdleSlotIndex(), fromSlot, false, false, ml::off, ml::blink0, ErrorCode::FSENSOR_DIDNT_SWITCH_OFF, ProgressCode::UnloadingFilament));
|
||||||
|
|
@ -528,7 +528,7 @@ void ToolChangeFSENSOR_TOO_EARLY(logic::ToolChange &tc, uint8_t slot) {
|
||||||
|
|
||||||
// make AutoRetry
|
// make AutoRetry
|
||||||
PressButtonAndDebounce(tc, mb::Middle, true);
|
PressButtonAndDebounce(tc, mb::Middle, true);
|
||||||
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::idler.IdleSlotIndex(), slot, true, true, ml::off, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament));
|
REQUIRE(VerifyState(tc, mg::FilamentLoadState::InSelector, mi::idler.IdleSlotIndex(), slot, true, true, ml::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingFilament));
|
||||||
|
|
||||||
SimulateIdlerHoming(tc);
|
SimulateIdlerHoming(tc);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,16 +53,10 @@ void RegularUnloadFromSlot04(uint8_t slot, logic::UnloadFilament &uf, uint8_t en
|
||||||
REQUIRE(VerifyState(uf, (mg::FilamentLoadState)(mg::FilamentLoadState::InNozzle | mg::FilamentLoadState::InSelector),
|
REQUIRE(VerifyState(uf, (mg::FilamentLoadState)(mg::FilamentLoadState::InNozzle | mg::FilamentLoadState::InSelector),
|
||||||
entryIdlerSlotIndex, slot, true, true, entryGreenLED, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
entryIdlerSlotIndex, slot, true, true, entryGreenLED, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||||
|
|
||||||
// run the automaton
|
REQUIRE(WhileCondition(uf, std::bind(SimulateUnloadToFINDA, _1, 100, 2'000), 200'000));
|
||||||
// Stage 1 - unloading to FINDA
|
|
||||||
REQUIRE(WhileCondition(
|
main_loop();
|
||||||
uf,
|
uf.Step();
|
||||||
[&](uint32_t step) -> bool {
|
|
||||||
if(step == 100){ // on 100th step make FINDA trigger
|
|
||||||
hal::gpio::WritePin(FINDA_PIN, hal::gpio::Level::low);
|
|
||||||
}
|
|
||||||
return uf.TopLevelState() == ProgressCode::UnloadingToFinda; },
|
|
||||||
50000));
|
|
||||||
|
|
||||||
// we still think we have filament loaded at this stage
|
// we still think we have filament loaded at this stage
|
||||||
// idler should have been activated by the underlying automaton
|
// idler should have been activated by the underlying automaton
|
||||||
|
|
@ -100,7 +94,7 @@ TEST_CASE("unload_filament::regular_unload_from_slot_0-4", "[unload_filament]")
|
||||||
for (uint8_t slot = 0; slot < config::toolCount; ++slot) {
|
for (uint8_t slot = 0; slot < config::toolCount; ++slot) {
|
||||||
logic::UnloadFilament uf;
|
logic::UnloadFilament uf;
|
||||||
RegularUnloadFromSlot04Init(slot, uf);
|
RegularUnloadFromSlot04Init(slot, uf);
|
||||||
RegularUnloadFromSlot04(slot, uf, mi::Idler::IdleSlotIndex(), false, ml::off);
|
RegularUnloadFromSlot04(slot, uf, mi::Idler::IdleSlotIndex(), false, ml::blink0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,7 +124,7 @@ void FindaDidntTriggerCommonSetup(uint8_t slot, logic::UnloadFilament &uf) {
|
||||||
// FINDA triggered off
|
// FINDA triggered off
|
||||||
// green LED should be off
|
// green LED should be off
|
||||||
// no error so far
|
// no error so far
|
||||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InNozzle, 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::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||||
|
|
||||||
// run the automaton
|
// 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
|
// Stage 1 - unloading to FINDA - do NOT let it trigger - keep it pressed, the automaton should finish all moves with the pulley
|
||||||
|
|
@ -177,7 +171,7 @@ void FindaDidntTriggerResolveTryAgain(uint8_t slot, logic::UnloadFilament &uf) {
|
||||||
// no change in selector's position
|
// no change in selector's position
|
||||||
// FINDA still on
|
// FINDA still on
|
||||||
// red LED should blink, green LED should be off
|
// red LED should blink, green LED should be off
|
||||||
REQUIRE(VerifyState(uf, mg::FilamentLoadState::InSelector, 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::blink0, ml::off, ErrorCode::RUNNING, ProgressCode::UnloadingToFinda));
|
||||||
|
|
||||||
ClearButtons(uf);
|
ClearButtons(uf);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue