diff --git a/rugnux/RugnuxPasses.cpp b/rugnux/RugnuxPasses.cpp index 787290c16..2dae6e2b3 100644 --- a/rugnux/RugnuxPasses.cpp +++ b/rugnux/RugnuxPasses.cpp @@ -557,33 +557,46 @@ ProcessResult Rugnux::RunAllPasses(RugnuxObserver *observer) { // before it writes - and a refit, which integrates and only follows a move off the stored // angles, first calls the output pass off and waits for it to end, so two integrations never // share the card. + // + // Except where pass 1's fit is a step or more off the stored angles (STEP_BOUND in + // PostRefine.cpp): there the walk moves off them and refits as a rule, which calls the output + // pass off and throws it away, so the walk runs first, on its own, and the refined passes + // after it. Either way the run ends where the sequential walk leaves it. + constexpr double ROTATION_SCALE_STEP = 0.01; if (!cancelled_ && gonio_snapshot && pass1.post_refine && !config_.rotation_scale) { const auto check = std::make_shared(); - const auto output = std::make_shared(*this); - output->rotation_scale_check_ = check; - output->cancelled_ = cancelled_.Own(); - CancelFlag output_cancel = output->cancelled_; - std::future walk_done = std::async(std::launch::async, [&] { - return WalkRotationScaleBeside(pass1, *check, output_cancel); - }); + RotationScaleWalk walk; + if (std::fabs(pass1.post_refine->rotation_scale - 1.0) >= ROTATION_SCALE_STEP) { + check->Set(check->output_indexed); + check->Set(check->output_ended); + walk = WalkRotationScaleBeside(pass1, *check, CancelFlag()); + } else { + const auto output = std::make_shared(*this); + output->rotation_scale_check_ = check; + output->cancelled_ = cancelled_.Own(); + CancelFlag output_cancel = output->cancelled_; + std::future walk_done = std::async(std::launch::async, [&] { + return WalkRotationScaleBeside(pass1, *check, output_cancel); + }); - std::optional result; - std::exception_ptr output_error; - try { - result = output->RefinedPasses(observer, pass1, start); - } catch (...) { - output_error = std::current_exception(); - } - check->Set(check->output_indexed); - check->Set(check->output_ended); - const RotationScaleWalk walk = walk_done.get(); - if (!check->overturns) { - if (output_error) - std::rethrow_exception(output_error); - return *result; + std::optional result; + std::exception_ptr output_error; + try { + result = output->RefinedPasses(observer, pass1, start); + } catch (...) { + output_error = std::current_exception(); + } + check->Set(check->output_indexed); + check->Set(check->output_ended); + walk = walk_done.get(); + if (!check->overturns) { + if (output_error) + std::rethrow_exception(output_error); + return *result; + } } - // Overturned: the refined passes run again, on the run itself. + // Overturned, or the walk ran first: the refined passes run on the run itself. start.scale_walk = {check->passes, check->text}; if (walk.scale != 1.0f) { step("Rotation-scale check"); @@ -596,7 +609,7 @@ ProcessResult Rugnux::RunAllPasses(RugnuxObserver *observer) { "integrates at the corrected angles; the fault is in the hardware and should " "be fixed there", walk.scale, 100.0 * (walk.scale - 1.0), walk.scale > 1.0f ? "further" : "less far"); - } else + } else if (check->overturns) logger.Info("Two-pass: the rotation-scale walk changed the spot finding the refined passes " "start from, so they run again after it"); }