PFW-1432 Reduce LOC

If verification test fails, increment load fail statistic
This commit is contained in:
Guðni Már Gilbert 2022-11-19 15:16:21 +00:00 committed by DRracer
parent 03235c8aab
commit 46f4f2658d
2 changed files with 9 additions and 11 deletions

View File

@ -306,7 +306,7 @@ void MMU2::DecrementRetryAttempts() {
} }
} }
bool MMU2::FSensorCalibrationCheck() bool MMU2::VerifyFilamentEnteredPTFE()
{ {
st_synchronize(); st_synchronize();
@ -327,6 +327,7 @@ bool MMU2::FSensorCalibrationCheck()
if (fsensorState) if (fsensorState)
{ {
IncrementLoadFails();
return false; return false;
} else { } else {
// else, happy printing! :) // else, happy printing! :)
@ -339,10 +340,8 @@ bool MMU2::FSensorCalibrationCheck()
} }
void MMU2::ToolChangeCommon(uint8_t slot){ void MMU2::ToolChangeCommon(uint8_t slot){
bool calibrationCheckResult = true;
tool_change_extruder = slot; tool_change_extruder = slot;
do { for(;;) { // while not successfully fed into extruder's PTFE tube
if (!calibrationCheckResult) unload(); // TODO cut filament
for(;;) { for(;;) {
logic.ToolChange(slot); // let the MMU pull the filament out and push a new one in logic.ToolChange(slot); // let the MMU pull the filament out and push a new one in
if( manage_response(true, true) ) if( manage_response(true, true) )
@ -353,15 +352,14 @@ void MMU2::ToolChangeCommon(uint8_t slot){
// if we run out of retries, we must do something ... may be raise an error screen and allow the user to do something // if we run out of retries, we must do something ... may be raise an error screen and allow the user to do something
// but honestly - if the MMU restarts during every toolchange, // but honestly - if the MMU restarts during every toolchange,
// something else is seriously broken and stopping a print is probably our best option. // something else is seriously broken and stopping a print is probably our best option.
// IncrementLoadFails(); // this should be contained in the while condition
} }
// reset current position to whatever the planner thinks it is // reset current position to whatever the planner thinks it is
plan_set_e_position(current_position[E_AXIS]); plan_set_e_position(current_position[E_AXIS]);
calibrationCheckResult = FSensorCalibrationCheck(); if (VerifyFilamentEnteredPTFE()) break;
} while (!calibrationCheckResult); // while not successfully fed into etruder's PTFE tube else { // Prepare a retry attempt
// when we run out of feeding retries, we should call an unload + cut before trying again. unload(); // TODO cut filament
// + we need some error screen report }
}
extruder = slot; //filament change is finished extruder = slot; //filament change is finished
SpoolJoin::spooljoin.setSlot(slot); SpoolJoin::spooljoin.setSlot(slot);

View File

@ -286,7 +286,7 @@ private:
/// at any moment the test fails. Else test passes, and the E-motor retraction /// at any moment the test fails. Else test passes, and the E-motor retraction
/// is reverted. /// is reverted.
/// @returns false if test fails, true otherwise /// @returns false if test fails, true otherwise
bool FSensorCalibrationCheck(); bool VerifyFilamentEnteredPTFE();
/// Common processing of pushing filament into the extruder - shared by tool_change, load_to_nozzle and probably others /// Common processing of pushing filament into the extruder - shared by tool_change, load_to_nozzle and probably others
void ToolChangeCommon(uint8_t slot); void ToolChangeCommon(uint8_t slot);