fix(GCodeProcessor): exclude end gcode M400 delays from M73 time estimation

End gcode contains firmware-conditional M400 waits for air purification,
timelapse capture, and sound notification that are post-print operations.
These were incorrectly included in M73 total time, inflating the estimate.

The fix detects MACHINE_END_GCODE_START tag during the streaming parse
(process_tags) and sets m_skip_end_gcode_delays=true. process_M400 then
skips timed delays (S/P params) in the end gcode scope.

BBS achieves the same effect by dropping leftover in calculate_time
(is_final=true). We skip at the source instead, which is more surgical
and leaves calculate_time behavior unchanged for all printers.

Affects all BBL printers with MACHINE_END_GCODE_START tag.
Non-BBL printers are unaffected (no tag = no skip).
This commit is contained in:
denis svinarchuk
2026-07-16 20:47:49 +01:00
parent fc705612a4
commit 403292cb63
2 changed files with 49 additions and 1 deletions

View File

@@ -1109,6 +1109,15 @@ class Print;
std::vector<ExtruderPreHeating::ExtruderUsageBlcok> m_extruder_blocks;
unsigned int m_machine_start_gcode_end_line_id{ (unsigned int) (-1) };
unsigned int m_machine_end_gcode_start_line_id{ (unsigned int) (-1) };
// End gcode M400 delays (air purification, timelapse, sound) are post-print
// by definition. M73 should report print completion time, not post-print time.
// m_skip_end_gcode_delays is set when MACHINE_END_GCODE_START tag is encountered
// during the streaming parse (process_tags), telling process_M400 to skip timed
// delays in the end gcode scope.
// Reference to BBS: BambuStudio/src/libslic3r/GCode/GCodeProcessor.cpp —
// BBS drops leftover in calculate_time(is_final=true), achieving the same effect.
bool m_support_air_filtration{ false };
bool m_skip_end_gcode_delays{ false };
// Tracks, during the stream, which filament sits in each physical nozzle and which nozzle each
// extruder currently carries. Written by both branches of the two-arg process_filament_change
// (the fallback branch does occupancy bookkeeping only); read by the richer change-time model