feat(engine): per-nozzle-variant machine limits in the time estimator

The time estimator's speed/acceleration limits were indexed by time
mode only, reading slot 0 of the per-(extruder x volume-type) arrays
the multi-extruder profiles already carry (H2C 0.4: 8 entries, H2D
0.4: 10). Every move was therefore modelled with the first machine
slot's limits regardless of which nozzle variant was printing -
estimation fidelity only, since emitted feedrates/accelerations are
decided on the slicing side.

Now the estimator resolves the machine slot of the nozzle currently
mounted in the active extruder: the nozzle grouping context is handed
to the processor BEFORE the streaming replay (new member + setter -
deliberately separate from the post-stream result-field handover that
gates the richer change-time model, whose timing is unchanged), the
occupancy recorder is populated on every filament change (bookkeeping
decoupled from the gated time model; recorder writes have no time
effect), and get_machine_config_idx maps (volume type x extruder type
x extruder) to the slot via the printer's variant layout, newly
carried on the processor result. The feedrate/acceleration getters
gain a slot parameter indexing [slot*2 + mode]; jerk and the
print/travel/retract accelerations stay mode-only. Reloaded sliced
projects re-estimate with the result's saved grouping context;
imported bare g-code degrades to slot 0 - the historical read.

M201/M203 write the parsed value into EVERY slot's mode entry (a
firmware envelope change is global), which keeps per-slot reads in
lockstep with the mode-only reads they replace: the fleet emits
envelope lines before any motion, so estimates - hence the estimated
time header, M73 lines, and every other byte - are unchanged (20/20
pinned-slice byte gate bit-identical, incl. the sequential repro
sliced twice). Fidelity improves where envelope emission is off or a
migrating per-layer plan moves filaments across variants.

Tests: a stub-driven processor case proving the slot follows the
active nozzle through the exact production path (T..H.. commands,
fallback recorder bookkeeping, 4x time ratio on the slow variant),
that emitted M201/M203 reach every slot, and that a missing context
degrades to slot 0. Suites green (libslic3r 48998/169, fff_print
667/62).
This commit is contained in:
SoftFever
2026-07-12 14:48:45 +08:00
parent 582017235c
commit 3ebd68d959
5 changed files with 253 additions and 47 deletions

View File

@@ -3453,8 +3453,8 @@ void Print::update_to_config_by_nozzle_group_result(const MultiNozzleUtils::Laye
// Note: filament_map_2 keeps its apply-time (static) derivation here; the per-slot machine
// indices below key the override merge instead, so nothing on this path reads it. Its other
// consumers are the three-map write-back (which recomputes it) and the diagnostic copy in
// the g-code header; per-(extruder x volume-type) machine limits in the g-code processor
// remain a follow-up (see GCodeProcessor::get_axis_max_feedrate).
// the g-code header; the time estimator resolves per-(extruder x volume-type) machine limits
// from the live nozzle occupancy instead (see GCodeProcessor::get_machine_config_idx).
m_full_print_config = m_ori_full_print_config;
std::set<std::string> filament_keys = filament_options_with_variant;
filament_keys.insert("filament_self_index");
@@ -4257,6 +4257,10 @@ void Print::export_gcode_from_previous_file(const std::string& file, GCodeProces
GCodeProcessor::s_IsBBLPrinter = is_BBL_printer();
const Vec3d origin = this->get_plate_origin();
processor.set_xy_offset(origin(0), origin(1));
// Reloaded sliced projects re-estimate with the same nozzle-grouping slot context as the
// original export; harmless when the result carries none (slot 0).
if (result != nullptr && result->nozzle_group_result)
processor.initialize_from_context(result->nozzle_group_result);
//processor.enable_producers(true);
processor.process_file(file);