OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::anonymous_namespace{ElegooGCodeProcessorHelper.cpp} Namespace Reference

Functions

bool equals_case_insensitive (std::string_view lhs, std::string_view rhs)
float get_clamped_param (const GCodeReader::GCodeLine &line, char axis, float default_value, float min_value, float max_value)
float extrusion_time (float e_length, float feedrate)
float retract_time (float e_length)
float s819_time (float e_length, float feedrate)
float estimate_M6211_time_for_centauri_carbon (const GCodeReader::GCodeLine &line, float length, double current_x, double current_y)
float estimate_M6211_time_for_centauri_carbon_2 (const GCodeReader::GCodeLine &line, float length, float new_extruder_temp)
float estimate_M6211_time (const GCodeReader::GCodeLine &line, std::string_view printer_model, float length, float new_extruder_temp, double current_x, double current_y)

Function Documentation

◆ equals_case_insensitive()

bool Slic3r::anonymous_namespace{ElegooGCodeProcessorHelper.cpp}::equals_case_insensitive ( std::string_view lhs,
std::string_view rhs )
17{
18 return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin(), [](unsigned char l, unsigned char r) {
19 return std::tolower(l) == std::tolower(r);
20 });
21}

References equals_case_insensitive().

Referenced by equals_case_insensitive(), and estimate_M6211_time().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ estimate_M6211_time()

float Slic3r::anonymous_namespace{ElegooGCodeProcessorHelper.cpp}::estimate_M6211_time ( const GCodeReader::GCodeLine & line,
std::string_view printer_model,
float length,
float new_extruder_temp,
double current_x,
double current_y )
127{
128 if (equals_case_insensitive(printer_model, "Elegoo Centauri Carbon") || equals_case_insensitive(printer_model, "Elegoo Centauri")) {
129 return estimate_M6211_time_for_centauri_carbon(line, length, current_x, current_y);
130 } else if (equals_case_insensitive(printer_model, "Elegoo Centauri Carbon 2") ||
131 equals_case_insensitive(printer_model, "Elegoo Centauri 2")) {
132 return estimate_M6211_time_for_centauri_carbon_2(line, length, new_extruder_temp);
133 }
134 return 0.0f;
135}
float estimate_M6211_time_for_centauri_carbon(const GCodeReader::GCodeLine &line, float length, double current_x, double current_y)
Definition ElegooGCodeProcessorHelper.cpp:51
bool equals_case_insensitive(std::string_view lhs, std::string_view rhs)
Definition ElegooGCodeProcessorHelper.cpp:16
float estimate_M6211_time_for_centauri_carbon_2(const GCodeReader::GCodeLine &line, float length, float new_extruder_temp)
Definition ElegooGCodeProcessorHelper.cpp:89
double length(const Points &pts)
Definition MultiPoint.hpp:181

References equals_case_insensitive(), estimate_M6211_time(), estimate_M6211_time_for_centauri_carbon(), estimate_M6211_time_for_centauri_carbon_2(), and Slic3r::length().

Referenced by estimate_M6211_time().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ estimate_M6211_time_for_centauri_carbon()

float Slic3r::anonymous_namespace{ElegooGCodeProcessorHelper.cpp}::estimate_M6211_time_for_centauri_carbon ( const GCodeReader::GCodeLine & line,
float length,
double current_x,
double current_y )
53{
54 static constexpr float max_segment_length = 73.0f;
55 static constexpr float wipe_after_flush_time = 2.8f;
56 static constexpr float main_feedrate = 500.0f;
57 static constexpr float tail_feedrate = 400.0f;
58 static constexpr float travel_feedrate = 5000.0f;
59 static constexpr double parking_x = 256.0;
60 static constexpr double parking_y = 0.0;
61
62 const float flush_length = std::clamp(length, 10.0f, 1000.0f);
63 const float cool_time = get_clamped_param(line, 'P', 5000.0f, 0.0f, 20000.0f) * 0.001f;
64 const float travel_time = static_cast<float>(std::abs(current_y - parking_y) + std::abs(current_x - parking_x)) /
65 travel_feedrate * 60.0f;
66
67 // Initial time, including: material change, heating, etc.
68 float m6211_time = 18.2f + travel_time;
69
70 float remaining_flush_length = std::max(flush_length, 0.0f);
71 while (remaining_flush_length > 0.0f) {
72 const float segment_length = std::min(remaining_flush_length, max_segment_length);
73 remaining_flush_length -= segment_length;
74 if (segment_length >= max_segment_length) {
75 // Full segment: 3-phase extrusion (30+35+10=75mm) + retract
76 m6211_time += extrusion_time(30.0f, main_feedrate) + extrusion_time(35.0f, main_feedrate) +
77 extrusion_time(10.0f, tail_feedrate) + extrusion_time(2.0f, tail_feedrate) + cool_time +
78 wipe_after_flush_time;
79 } else {
80 // Partial last segment: simple extrude at F500 + retract at F400
81 m6211_time += extrusion_time(segment_length, main_feedrate) + extrusion_time(2.0f, tail_feedrate) + cool_time +
82 wipe_after_flush_time;
83 }
84 }
85
86 return m6211_time;
87}
float get_clamped_param(const GCodeReader::GCodeLine &line, char axis, float default_value, float min_value, float max_value)
Definition ElegooGCodeProcessorHelper.cpp:23
float extrusion_time(float e_length, float feedrate)
Definition ElegooGCodeProcessorHelper.cpp:30
static coordf_t segment_length(const Polygon &poly, size_t seg1, const Point &p1, size_t seg2, const Point &p2)
Definition FillRectilinear.cpp:64

References estimate_M6211_time_for_centauri_carbon(), extrusion_time(), get_clamped_param(), Slic3r::length(), and Slic3r::segment_length().

Referenced by estimate_M6211_time(), and estimate_M6211_time_for_centauri_carbon().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ estimate_M6211_time_for_centauri_carbon_2()

float Slic3r::anonymous_namespace{ElegooGCodeProcessorHelper.cpp}::estimate_M6211_time_for_centauri_carbon_2 ( const GCodeReader::GCodeLine & line,
float length,
float new_extruder_temp )
90{
91 const float flush_length = std::clamp(length, 10.0f, 1000.0f);
92 const float flush_length_single = get_clamped_param(line, 'K', 75.0f, 10.0f, 300.0f);
93 const float old_filament_e_feedrate = get_clamped_param(line, 'M', 300.0f, 10.0f, 600.0f);
94 const float new_filament_e_feedrate = get_clamped_param(line, 'N', 300.0f, 10.0f, 600.0f);
95 const float cool_time = get_clamped_param(line, 'P', 3000.0f, 0.0f, 20000.0f) * 0.001f;
96
97 // The flush length of the old material, unit: mm
98 static constexpr float e_flush_dist = 15.0f;
99 // Wipe time after flush, in seconds
100 static constexpr float wipe_after_flush_time = 5.0f;
101
102 const float flush_length_after_start = std::max(flush_length - e_flush_dist, 0.0f);
103 const int flush_times = std::max(1, static_cast<int>(std::ceil(flush_length_after_start / flush_length_single)));
104 const float flush_length_actual = flush_length_single;
105
106 // Initial time, including: material change, heating, moving, etc.
107 float m6211_time = 31.0f;
108 m6211_time += extrusion_time(std::min(e_flush_dist, flush_length), old_filament_e_feedrate);
109
110 const int intermediate_flush_times = flush_times - 1;
111 const float intermediate_flush_time = s819_time(flush_length_actual, new_filament_e_feedrate) + retract_time(6.0f) + cool_time +
112 wipe_after_flush_time;
113 m6211_time += static_cast<float>(intermediate_flush_times) * intermediate_flush_time;
114 m6211_time += s819_time(flush_length_actual, new_filament_e_feedrate * 0.8f) + retract_time(4.0f) + cool_time + wipe_after_flush_time;
115
116 static constexpr float cooling_rate = 1.36f;
117 const float r_temp = get_clamped_param(line, 'R', new_extruder_temp + 20.0f, 185.0f, 350.0f);
118 const float s_temp = get_clamped_param(line, 'S', 250.0f, 185.0f, 350.0f);
119
120 if (s_temp < r_temp)
121 m6211_time += (r_temp - s_temp) / cooling_rate;
122
123 return m6211_time;
124}
float s819_time(float e_length, float feedrate)
Definition ElegooGCodeProcessorHelper.cpp:41
float retract_time(float e_length)
Definition ElegooGCodeProcessorHelper.cpp:35

References estimate_M6211_time_for_centauri_carbon_2(), extrusion_time(), get_clamped_param(), Slic3r::length(), retract_time(), and s819_time().

Referenced by estimate_M6211_time(), and estimate_M6211_time_for_centauri_carbon_2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extrusion_time()

float Slic3r::anonymous_namespace{ElegooGCodeProcessorHelper.cpp}::extrusion_time ( float e_length,
float feedrate )
31{
32 return feedrate > 0.0f && e_length > 0.0f ? e_length / feedrate * 60.0f : 0.0f;
33}

References extrusion_time().

Referenced by estimate_M6211_time_for_centauri_carbon(), estimate_M6211_time_for_centauri_carbon_2(), extrusion_time(), retract_time(), and s819_time().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_clamped_param()

float Slic3r::anonymous_namespace{ElegooGCodeProcessorHelper.cpp}::get_clamped_param ( const GCodeReader::GCodeLine & line,
char axis,
float default_value,
float min_value,
float max_value )
24{
25 float value = default_value;
26 line.has_value(axis, value);
27 return std::clamp(value, min_value, max_value);
28}
bool has_value(char axis, float &value) const
Definition GCodeReader.cpp:316

References get_clamped_param(), and Slic3r::GCodeReader::GCodeLine::has_value().

Referenced by estimate_M6211_time_for_centauri_carbon(), estimate_M6211_time_for_centauri_carbon_2(), and get_clamped_param().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ retract_time()

float Slic3r::anonymous_namespace{ElegooGCodeProcessorHelper.cpp}::retract_time ( float e_length)
36{
37 static constexpr float retract_feedrate = 1800.0f;
38 return extrusion_time(std::max(e_length, 0.0f), retract_feedrate);
39}

References extrusion_time(), and retract_time().

Referenced by estimate_M6211_time_for_centauri_carbon_2(), and retract_time().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ s819_time()

float Slic3r::anonymous_namespace{ElegooGCodeProcessorHelper.cpp}::s819_time ( float e_length,
float feedrate )
42{
43 static constexpr float s819_tail_flush_length = 10.0f;
44 static constexpr float s819_tail_feedrate = 400.0f;
45
46 const float tail_length = std::min(std::max(e_length, 0.0f), s819_tail_flush_length);
47 const float main_length = std::max(e_length - tail_length, 0.0f);
48 return extrusion_time(main_length, feedrate) + extrusion_time(tail_length, s819_tail_feedrate);
49}

References extrusion_time(), and s819_time().

Referenced by estimate_M6211_time_for_centauri_carbon_2(), and s819_time().

Here is the call graph for this function:
Here is the caller graph for this function: