Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions include/ExtruderPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ class ExtruderPlan
*
* \param path_idx The index into ExtruderPlan::paths which is currently being consider for temperature command insertion
* \param gcode The gcode exporter to which to write the temperature command.
* \param cumulative_path_time The time spend on this path up to this point.
* \param cumulative_path_time The time spent on this path up to this point. Inserts whose path_idx is strictly less
* than the current path_idx are considered overdue and will be fired unconditionally. Inserts whose path_idx
* equals the current path_idx are fired only once cumulative_path_time reaches their time_after_path_start.
*/
void handleInserts(const size_t path_idx, GCodeExport& gcode, const double cumulative_path_time = std::numeric_limits<double>::infinity());
void handleInserts(const size_t path_idx, GCodeExport& gcode, const double cumulative_path_time);

/*!
* Insert all remaining temp inserts into gcode, to be called at the end of an extruder plan
Expand Down
17 changes: 15 additions & 2 deletions src/ExtruderPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,21 @@ void ExtruderPlan::insertCommand(NozzleTempInsert&& insert)

void ExtruderPlan::handleInserts(const size_t path_idx, GCodeExport& gcode, const double cumulative_path_time)
{
while (! inserts_.empty() && path_idx >= inserts_.front().path_idx && inserts_.front().time_after_path_start < cumulative_path_time)
{ // handle the Insert to be inserted before this path_idx (and all inserts not handled yet)
while (! inserts_.empty())
{
const NozzleTempInsert& insert = inserts_.front();
if (insert.path_idx > path_idx)
{
// Insert is scheduled for a future path; nothing more to do for now.
break;
}
if (insert.path_idx == path_idx && insert.time_after_path_start > cumulative_path_time)
{
// Insert is scheduled for this path, but the required time within the path has not been reached yet.
break;
}
// Either the insert is overdue (insert.path_idx < path_idx) and must be fired immediately,
// or it is exactly on time (insert.path_idx == path_idx and time threshold reached).
inserts_.front().write(gcode);
inserts_.pop_front();
}
Expand Down
4 changes: 3 additions & 1 deletion src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3512,7 +3512,9 @@ void LayerPlan::writeGCode(GCodeExport& gcode)

for (size_t path_idx = 0; path_idx < paths.size(); path_idx++)
{
extruder_plan.handleInserts(path_idx, gcode);
// Fire any inserts that became overdue during the previous path, using the total
// accumulated time from that path.
extruder_plan.handleInserts(path_idx, gcode, cumulative_path_time);
cumulative_path_time = 0.; // reset to 0 for current path.

GCodePath& path = paths[path_idx];
Expand Down
Loading