Remove unused slow down proportionally code (#6405)

* Remove unused slow down proportionally code
This commit is contained in:
Vovodroid 2024-08-25 07:40:40 +03:00 committed by GitHub
parent a7d2ae0450
commit 0c63dd4bd0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 66 deletions

View File

@ -521,62 +521,6 @@ std::vector<PerExtruderAdjustments> CoolingBuffer::parse_layer_gcode(const std::
return per_extruder_adjustments; return per_extruder_adjustments;
} }
// Slow down an extruder range proportionally down to slow_down_layer_time.
// Return the total time for the complete layer.
static inline float extruder_range_slow_down_proportional(
std::vector<PerExtruderAdjustments*>::iterator it_begin,
std::vector<PerExtruderAdjustments*>::iterator it_end,
// Elapsed time for the extruders already processed.
float elapsed_time_total0,
// Initial total elapsed time before slow down.
float elapsed_time_before_slowdown,
// Target time for the complete layer (all extruders applied).
float slow_down_layer_time)
{
// Total layer time after the slow down has been applied.
float total_after_slowdown = elapsed_time_before_slowdown;
// Now decide, whether the external perimeters shall be slowed down as well.
float max_time_nep = elapsed_time_total0;
for (auto it = it_begin; it != it_end; ++ it)
max_time_nep += (*it)->maximum_time_after_slowdown(false);
if (max_time_nep > slow_down_layer_time) {
// It is sufficient to slow down the non-external perimeter moves to reach the target layer time.
// Slow down the non-external perimeters proportionally.
float non_adjustable_time = elapsed_time_total0;
for (auto it = it_begin; it != it_end; ++ it)
non_adjustable_time += (*it)->non_adjustable_time(false);
// The following step is a linear programming task due to the minimum movement speeds of the print moves.
// Run maximum 5 iterations until a good enough approximation is reached.
for (size_t iter = 0; iter < 5; ++ iter) {
float factor = (slow_down_layer_time - non_adjustable_time) / (total_after_slowdown - non_adjustable_time);
assert(factor > 1.f);
total_after_slowdown = elapsed_time_total0;
for (auto it = it_begin; it != it_end; ++ it)
total_after_slowdown += (*it)->slow_down_proportional(factor, false);
if (total_after_slowdown > 0.95f * slow_down_layer_time)
break;
}
} else {
// Slow down everything. First slow down the non-external perimeters to maximum.
for (auto it = it_begin; it != it_end; ++ it)
(*it)->slowdown_to_minimum_feedrate(false);
// Slow down the external perimeters proportionally.
float non_adjustable_time = elapsed_time_total0;
for (auto it = it_begin; it != it_end; ++ it)
non_adjustable_time += (*it)->non_adjustable_time(true);
for (size_t iter = 0; iter < 5; ++ iter) {
float factor = (slow_down_layer_time - non_adjustable_time) / (total_after_slowdown - non_adjustable_time);
assert(factor > 1.f);
total_after_slowdown = elapsed_time_total0;
for (auto it = it_begin; it != it_end; ++ it)
total_after_slowdown += (*it)->slow_down_proportional(factor, true);
if (total_after_slowdown > 0.95f * slow_down_layer_time)
break;
}
}
return total_after_slowdown;
}
// Slow down an extruder range to slow_down_layer_time. // Slow down an extruder range to slow_down_layer_time.
// Return the total time for the complete layer. // Return the total time for the complete layer.
static inline void extruder_range_slow_down_non_proportional( static inline void extruder_range_slow_down_non_proportional(
@ -674,9 +618,8 @@ float CoolingBuffer::calculate_layer_slowdown(std::vector<PerExtruderAdjustments
adj.time_maximum = adj.maximum_time_after_slowdown(true); adj.time_maximum = adj.maximum_time_after_slowdown(true);
if (adj.cooling_slow_down_enabled && adj.lines.size() > 0) { if (adj.cooling_slow_down_enabled && adj.lines.size() > 0) {
by_slowdown_time.emplace_back(&adj); by_slowdown_time.emplace_back(&adj);
if (! m_cooling_logic_proportional) // sorts the lines, also sets adj.time_non_adjustable
// sorts the lines, also sets adj.time_non_adjustable adj.sort_lines_by_decreasing_feedrate();
adj.sort_lines_by_decreasing_feedrate();
} else } else
elapsed_time_total0 += adj.elapsed_time_total(); elapsed_time_total0 += adj.elapsed_time_total();
} }
@ -700,10 +643,7 @@ float CoolingBuffer::calculate_layer_slowdown(std::vector<PerExtruderAdjustments
for (auto it = cur_begin; it != by_slowdown_time.end(); ++ it) for (auto it = cur_begin; it != by_slowdown_time.end(); ++ it)
max_time += (*it)->time_maximum; max_time += (*it)->time_maximum;
if (max_time > slow_down_layer_time) { if (max_time > slow_down_layer_time) {
if (m_cooling_logic_proportional) extruder_range_slow_down_non_proportional(cur_begin, by_slowdown_time.end(), slow_down_layer_time - total);
extruder_range_slow_down_proportional(cur_begin, by_slowdown_time.end(), elapsed_time_total0, total, slow_down_layer_time);
else
extruder_range_slow_down_non_proportional(cur_begin, by_slowdown_time.end(), slow_down_layer_time - total);
} else { } else {
// Slow down to maximum possible. // Slow down to maximum possible.
for (auto it = cur_begin; it != by_slowdown_time.end(); ++ it) for (auto it = cur_begin; it != by_slowdown_time.end(); ++ it)

View File

@ -54,9 +54,6 @@ private:
// the PrintConfig slice of FullPrintConfig is constant, thus no thread synchronization is required. // the PrintConfig slice of FullPrintConfig is constant, thus no thread synchronization is required.
const PrintConfig &m_config; const PrintConfig &m_config;
unsigned int m_current_extruder; unsigned int m_current_extruder;
// Old logic: proportional.
bool m_cooling_logic_proportional = false;
//BBS: current fan speed //BBS: current fan speed
int m_current_fan_speed; int m_current_fan_speed;
}; };