Skip to content

Commit

Permalink
Fix min layer time for gradual flow
Browse files Browse the repository at this point in the history
Change ordering of back pressure compensation, gradual flow and minimum layer time gcode modification steps

Ordering before commit:
1: back pressure compensation
2: minimum layer time
3: gradual flow

Ordering after commit:
1: gradual flow
2: back pressure compensation
3: minimum layer time

CURA-11020
  • Loading branch information
casperlamboo committed Sep 19, 2023
1 parent aa60cdd commit 7f01c3a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 40 deletions.
5 changes: 5 additions & 0 deletions include/LayerPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,11 @@ class LayerPlan : public NoCopy
*/
void moveInsideCombBoundary(const coord_t distance, const std::optional<SliceLayerPart>& part = std::nullopt);

/*!
* If enabled, apply the modify plugin to the layer-plan.
*/
void applyModifyPlugin();

/*!
* Apply back-pressure compensation to this layer-plan.
* Since the total (filament) pressure in a feeder-system is not only dependent on the pressure that exists between the nozzle and the
Expand Down
1 change: 1 addition & 0 deletions src/FffGcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@ LayerPlan& FffGcodeWriter::processLayer(const SliceDataStorage& storage, LayerIn
}
}

gcode_layer.applyModifyPlugin();
gcode_layer.applyBackPressureCompensation();
return gcode_layer;
}
Expand Down
85 changes: 45 additions & 40 deletions src/LayerPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1852,46 +1852,6 @@ void LayerPlan::writeGCode(GCodeExport& gcode)
{
ExtruderPlan& extruder_plan = extruder_plans[extruder_plan_idx];

scripta::log(
"extruder_plan_0",
extruder_plan.paths,
SectionType::NA,
layer_nr,
scripta::CellVDI{ "flow", &GCodePath::flow },
scripta::CellVDI{ "width_factor", &GCodePath::width_factor },
scripta::CellVDI{ "spiralize", &GCodePath::spiralize },
scripta::CellVDI{ "speed_factor", &GCodePath::speed_factor },
scripta::CellVDI{ "speed_back_pressure_factor", &GCodePath::speed_back_pressure_factor },
scripta::CellVDI{ "retract", &GCodePath::retract },
scripta::CellVDI{ "unretract_before_last_travel_move", &GCodePath::unretract_before_last_travel_move },
scripta::CellVDI{ "perform_z_hop", &GCodePath::perform_z_hop },
scripta::CellVDI{ "perform_prime", &GCodePath::perform_prime },
scripta::CellVDI{ "fan_speed", &GCodePath::getFanSpeed },
scripta::CellVDI{ "is_travel_path", &GCodePath::isTravelPath },
scripta::CellVDI{ "extrusion_mm3_per_mm", &GCodePath::getExtrusionMM3perMM });

extruder_plan.paths = slots::instance().modify<plugins::v0::SlotID::GCODE_PATHS_MODIFY>(extruder_plan.paths, extruder_plan.extruder_nr, layer_nr);

// Since the time/material estimates _may_ have changed during the plugin modify step we recalculate it
extruder_plan.computeNaiveTimeEstimates(gcode.getPositionXY());
scripta::log(
"extruder_plan_1",
extruder_plan.paths,
SectionType::NA,
layer_nr,
scripta::CellVDI{ "flow", &GCodePath::flow },
scripta::CellVDI{ "width_factor", &GCodePath::width_factor },
scripta::CellVDI{ "spiralize", &GCodePath::spiralize },
scripta::CellVDI{ "speed_factor", &GCodePath::speed_factor },
scripta::CellVDI{ "speed_back_pressure_factor", &GCodePath::speed_back_pressure_factor },
scripta::CellVDI{ "retract", &GCodePath::retract },
scripta::CellVDI{ "unretract_before_last_travel_move", &GCodePath::unretract_before_last_travel_move },
scripta::CellVDI{ "perform_z_hop", &GCodePath::perform_z_hop },
scripta::CellVDI{ "perform_prime", &GCodePath::perform_prime },
scripta::CellVDI{ "fan_speed", &GCodePath::getFanSpeed },
scripta::CellVDI{ "is_travel_path", &GCodePath::isTravelPath },
scripta::CellVDI{ "extrusion_mm3_per_mm", &GCodePath::getExtrusionMM3perMM });

const RetractionAndWipeConfig* retraction_config
= current_mesh ? &current_mesh->retraction_wipe_config : &storage.retraction_wipe_config_per_extruder[extruder_plan.extruder_nr];
coord_t z_hop_height = retraction_config->retraction_config.zHop;
Expand Down Expand Up @@ -2402,6 +2362,51 @@ bool LayerPlan::writePathWithCoasting(
return true;
}

void LayerPlan::applyModifyPlugin()
{
for (auto& extruder_plan : extruder_plans)
{
scripta::log(
"extruder_plan_0",
extruder_plan.paths,
SectionType::NA,
layer_nr,
scripta::CellVDI{ "flow", &GCodePath::flow },
scripta::CellVDI{ "width_factor", &GCodePath::width_factor },
scripta::CellVDI{ "spiralize", &GCodePath::spiralize },
scripta::CellVDI{ "speed_factor", &GCodePath::speed_factor },
scripta::CellVDI{ "speed_back_pressure_factor", &GCodePath::speed_back_pressure_factor },
scripta::CellVDI{ "retract", &GCodePath::retract },
scripta::CellVDI{ "unretract_before_last_travel_move", &GCodePath::unretract_before_last_travel_move },
scripta::CellVDI{ "perform_z_hop", &GCodePath::perform_z_hop },
scripta::CellVDI{ "perform_prime", &GCodePath::perform_prime },
scripta::CellVDI{ "fan_speed", &GCodePath::getFanSpeed },
scripta::CellVDI{ "is_travel_path", &GCodePath::isTravelPath },
scripta::CellVDI{ "extrusion_mm3_per_mm", &GCodePath::getExtrusionMM3perMM });

extruder_plan.paths = slots::instance().modify<plugins::v0::SlotID::GCODE_PATHS_MODIFY>(extruder_plan.paths, extruder_plan.extruder_nr, layer_nr);

scripta::log(
"extruder_plan_1",
extruder_plan.paths,
SectionType::NA,
layer_nr,
scripta::CellVDI{ "flow", &GCodePath::flow },
scripta::CellVDI{ "width_factor", &GCodePath::width_factor },
scripta::CellVDI{ "spiralize", &GCodePath::spiralize },
scripta::CellVDI{ "speed_factor", &GCodePath::speed_factor },
scripta::CellVDI{ "speed_back_pressure_factor", &GCodePath::speed_back_pressure_factor },
scripta::CellVDI{ "retract", &GCodePath::retract },
scripta::CellVDI{ "unretract_before_last_travel_move", &GCodePath::unretract_before_last_travel_move },
scripta::CellVDI{ "perform_z_hop", &GCodePath::perform_z_hop },
scripta::CellVDI{ "perform_prime", &GCodePath::perform_prime },
scripta::CellVDI{ "fan_speed", &GCodePath::getFanSpeed },
scripta::CellVDI{ "is_travel_path", &GCodePath::isTravelPath },
scripta::CellVDI{ "extrusion_mm3_per_mm", &GCodePath::getExtrusionMM3perMM });

}
}

void LayerPlan::applyBackPressureCompensation()
{
for (auto& extruder_plan : extruder_plans)
Expand Down

0 comments on commit 7f01c3a

Please sign in to comment.