Report Selector refused to move as FINDA_DIDNT_SWITCH_OFF

MMU-176
pull/239/head
D.R.racer 2022-11-11 16:33:43 +01:00
parent c74d418016
commit ba1bbbcf0a
4 changed files with 24 additions and 11 deletions

View File

@ -12,7 +12,7 @@
#include "../debug.h" #include "../debug.h"
namespace logic { namespace logic {
void FeedToFinda::Reset(bool feedPhaseLimited, bool haltAtEnd) { bool FeedToFinda::Reset(bool feedPhaseLimited, bool haltAtEnd) {
dbg_logic_P(PSTR("\nFeed to FINDA\n\n")); dbg_logic_P(PSTR("\nFeed to FINDA\n\n"));
state = EngagingIdler; state = EngagingIdler;
this->feedPhaseLimited = feedPhaseLimited; this->feedPhaseLimited = feedPhaseLimited;
@ -20,12 +20,15 @@ void FeedToFinda::Reset(bool feedPhaseLimited, bool haltAtEnd) {
ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off); ml::leds.SetPairButOffOthers(mg::globals.ActiveSlot(), ml::blink0, ml::off);
mi::idler.Engage(mg::globals.ActiveSlot()); mi::idler.Engage(mg::globals.ActiveSlot());
// We can't get any FINDA readings if the selector is at the wrong spot - move it accordingly if necessary // We can't get any FINDA readings if the selector is at the wrong spot - move it accordingly if necessary
ms::selector.MoveToSlot(mg::globals.ActiveSlot()); return ms::selector.MoveToSlot(mg::globals.ActiveSlot()) == ms::Selector::OperationResult::Accepted;
} }
bool FeedToFinda::Step() { bool FeedToFinda::Step() {
switch (state) { switch (state) {
case EngagingIdler: case EngagingIdler:
// A serious deadlock may occur at this spot in case of flickering FINDA.
// Therefore FeedToFinda::Reset returns false in case of Selector refusing to move.
// We don't have to check the FINDA state while the move is in progress.
if (mi::idler.Engaged() && ms::selector.Slot() == mg::globals.ActiveSlot()) { if (mi::idler.Engaged() && ms::selector.Slot() == mg::globals.ActiveSlot()) {
dbg_logic_P(PSTR("Feed to Finda --> Idler engaged")); dbg_logic_P(PSTR("Feed to Finda --> Idler engaged"));
dbg_logic_fP(PSTR("Pulley start steps %u"), mpu::pulley.CurrentPosition_mm()); dbg_logic_fP(PSTR("Pulley start steps %u"), mpu::pulley.CurrentPosition_mm());

View File

@ -33,7 +33,10 @@ struct FeedToFinda {
/// * false feed phase is unlimited, can be interrupted by any button press after blanking time /// * false feed phase is unlimited, can be interrupted by any button press after blanking time
/// Beware: the function returns immediately without actually doing anything if the FINDA is "pressed", i.e. the filament is already at the FINDA /// Beware: the function returns immediately without actually doing anything if the FINDA is "pressed", i.e. the filament is already at the FINDA
/// @param haltAtEnd true if the Pulley's motion shall be brought into a halt (which is what LoadFilament wants, but not ToolChange) /// @param haltAtEnd true if the Pulley's motion shall be brought into a halt (which is what LoadFilament wants, but not ToolChange)
void Reset(bool feedPhaseLimited, bool haltAtEnd); /// @returns
/// * true if the operation has been successfully started.
/// * false if the selector refused to move to the desired spot (which can be caused by pressed FINDA)
bool Reset(bool feedPhaseLimited, bool haltAtEnd);
/// @returns true if the state machine finished its job, false otherwise /// @returns true if the state machine finished its job, false otherwise
bool Step(); bool Step();

View File

@ -41,11 +41,15 @@ bool ToolChange::Reset(uint8_t param) {
state = ProgressCode::UnloadingFilament; state = ProgressCode::UnloadingFilament;
unl.Reset(mg::globals.ActiveSlot()); unl.Reset(mg::globals.ActiveSlot());
} else { } else {
state = ProgressCode::FeedingToFinda; if (feed.Reset(true, false)) {
error = ErrorCode::RUNNING; state = ProgressCode::FeedingToFinda;
dbg_logic_P(PSTR("Filament is not loaded --> load")); error = ErrorCode::RUNNING;
mg::globals.SetFilamentLoaded(plannedSlot, mg::FilamentLoadState::InSelector); // mg::globals.SetFilamentLoaded(plannedSlot, mg::FilamentLoadState::InSelector); // this is set in feed @@TODO
feed.Reset(true, false); dbg_logic_P(PSTR("Filament is not loaded --> load"));
} else {
// selector refused to move - FINDA problem suspected
GoToErrDisengagingIdler(ErrorCode::FINDA_DIDNT_SWITCH_OFF);
}
} }
return true; return true;
} }

View File

@ -46,9 +46,12 @@ void UnloadFilament::GoToRetractingFromFinda() {
} }
void UnloadFilament::GoToRecheckFilamentAgainstFINDA() { void UnloadFilament::GoToRecheckFilamentAgainstFINDA() {
state = ProgressCode::FeedingToFinda; if (feed.Reset(true, true)) {
error = ErrorCode::RUNNING; state = ProgressCode::FeedingToFinda;
feed.Reset(true, true); error = ErrorCode::RUNNING;
} else {
GoToErrDisengagingIdler(ErrorCode::FINDA_DIDNT_SWITCH_OFF);
}
} }
bool UnloadFilament::StepInner() { bool UnloadFilament::StepInner() {