Force Tool Change to load the filament if same slot but not loaded
MMU-63pull/110/head
parent
6f3540a14d
commit
5a53acd802
|
|
@ -17,9 +17,13 @@ void ToolChange::Reset(uint8_t param) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param == mg::globals.ActiveSlot())
|
if (param == mg::globals.ActiveSlot() && mg::globals.FilamentLoaded()) {
|
||||||
|
// we are already at the correct slot and the filament is loaded - nothing to do
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// we are either already at the correct slot, just the filament is not loaded - load the filament directly
|
||||||
|
// or we are standing at another slot ...
|
||||||
plannedSlot = param;
|
plannedSlot = param;
|
||||||
|
|
||||||
if (mg::globals.FilamentLoaded()) {
|
if (mg::globals.FilamentLoaded()) {
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,13 @@ void ToolChange(logic::ToolChange tc, uint8_t fromSlot, uint8_t toSlot) {
|
||||||
void NoToolChange(logic::ToolChange tc, uint8_t fromSlot, uint8_t toSlot) {
|
void NoToolChange(logic::ToolChange tc, uint8_t fromSlot, uint8_t toSlot) {
|
||||||
ForceReinitAllAutomata();
|
ForceReinitAllAutomata();
|
||||||
|
|
||||||
|
// the filament is LOADED
|
||||||
|
mg::globals.SetFilamentLoaded(true);
|
||||||
|
|
||||||
EnsureActiveSlotIndex(fromSlot);
|
EnsureActiveSlotIndex(fromSlot);
|
||||||
|
|
||||||
|
REQUIRE(VerifyEnvironmentState(true, mi::Idler::IdleSlotIndex(), toSlot, false, ml::off, ml::off));
|
||||||
|
|
||||||
// restart the automaton
|
// restart the automaton
|
||||||
tc.Reset(toSlot);
|
tc.Reset(toSlot);
|
||||||
|
|
||||||
|
|
@ -66,6 +71,31 @@ void NoToolChange(logic::ToolChange tc, uint8_t fromSlot, uint8_t toSlot) {
|
||||||
REQUIRE(tc.Error() == ErrorCode::OK);
|
REQUIRE(tc.Error() == ErrorCode::OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JustLoadFilament(logic::ToolChange tc, uint8_t slot) {
|
||||||
|
ForceReinitAllAutomata();
|
||||||
|
|
||||||
|
EnsureActiveSlotIndex(slot);
|
||||||
|
|
||||||
|
// verify filament NOT loaded
|
||||||
|
REQUIRE(VerifyEnvironmentState(false, mi::Idler::IdleSlotIndex(), slot, false, ml::off, ml::off));
|
||||||
|
|
||||||
|
// restart the automaton
|
||||||
|
tc.Reset(slot);
|
||||||
|
|
||||||
|
REQUIRE(WhileCondition(
|
||||||
|
tc,
|
||||||
|
[&](int step) -> bool {
|
||||||
|
if(step == 1000){ // on 1000th step make FINDA trigger
|
||||||
|
hal::adc::SetADC(config::findaADCIndex, 900);
|
||||||
|
}
|
||||||
|
return tc.TopLevelState() == ProgressCode::LoadingFilament; },
|
||||||
|
200000UL));
|
||||||
|
|
||||||
|
REQUIRE(tc.TopLevelState() == ProgressCode::OK);
|
||||||
|
REQUIRE(mg::globals.FilamentLoaded() == true);
|
||||||
|
REQUIRE(mg::globals.ActiveSlot() == slot);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("tool_change::test0", "[tool_change]") {
|
TEST_CASE("tool_change::test0", "[tool_change]") {
|
||||||
for (uint8_t fromSlot = 0; fromSlot < config::toolCount; ++fromSlot) {
|
for (uint8_t fromSlot = 0; fromSlot < config::toolCount; ++fromSlot) {
|
||||||
for (uint8_t toSlot = 0; toSlot < config::toolCount; ++toSlot) {
|
for (uint8_t toSlot = 0; toSlot < config::toolCount; ++toSlot) {
|
||||||
|
|
@ -101,3 +131,10 @@ TEST_CASE("tool_change::state_machine_reusal", "[tool_change]") {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("tool_change::same_slot_just_unloaded_filament", "[tool_change]") {
|
||||||
|
for (uint8_t toSlot = 0; toSlot < config::toolCount; ++toSlot) {
|
||||||
|
logic::ToolChange tc;
|
||||||
|
JustLoadFilament(tc, toSlot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue