Tech ENABLE_EXTENDED_M73_LINES set as default
This commit is contained in:
parent
7817105abe
commit
81c78d0ecc
@ -182,9 +182,7 @@ void GCodeProcessor::TimeMachine::reset()
|
||||
max_travel_acceleration = 0.0f;
|
||||
extrude_factor_override_percentage = 1.0f;
|
||||
time = 0.0f;
|
||||
#if ENABLE_EXTENDED_M73_LINES
|
||||
stop_times = std::vector<StopTime>();
|
||||
#endif // ENABLE_EXTENDED_M73_LINES
|
||||
curr.reset();
|
||||
prev.reset();
|
||||
gcode_time.reset();
|
||||
@ -312,13 +310,11 @@ void GCodeProcessor::TimeMachine::calculate_time(size_t keep_last_n_blocks)
|
||||
layers_time[block.layer_id - 1] += block_time;
|
||||
}
|
||||
g1_times_cache.push_back({ block.g1_line_id, time });
|
||||
#if ENABLE_EXTENDED_M73_LINES
|
||||
// update times for remaining time to printer stop placeholders
|
||||
auto it_stop_time = std::lower_bound(stop_times.begin(), stop_times.end(), block.g1_line_id,
|
||||
[](const StopTime& t, unsigned int value) { return t.g1_line_id < value; });
|
||||
if (it_stop_time != stop_times.end() && it_stop_time->g1_line_id == block.g1_line_id)
|
||||
it_stop_time->elapsed_time = time;
|
||||
#endif // ENABLE_EXTENDED_M73_LINES
|
||||
}
|
||||
|
||||
if (keep_last_n_blocks)
|
||||
@ -357,16 +353,12 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
|
||||
return int(::roundf(time_in_seconds / 60.0f));
|
||||
};
|
||||
|
||||
#if ENABLE_EXTENDED_M73_LINES
|
||||
auto time_in_last_minute = [](float time_in_seconds) {
|
||||
assert(time_in_seconds <= 60.0f);
|
||||
return time_in_seconds / 60.0f;
|
||||
};
|
||||
|
||||
auto format_line_M73_main = [](const std::string& mask, int percent, int time) {
|
||||
#else
|
||||
auto format_line_M73 = [](const std::string& mask, int percent, int time) {
|
||||
#endif // ENABLE_EXTENDED_M73_LINES
|
||||
char line_M73[64];
|
||||
sprintf(line_M73, mask.c_str(),
|
||||
std::to_string(percent).c_str(),
|
||||
@ -374,7 +366,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
|
||||
return std::string(line_M73);
|
||||
};
|
||||
|
||||
#if ENABLE_EXTENDED_M73_LINES
|
||||
auto format_line_M73_stop_int = [](const std::string& mask, int time) {
|
||||
char line_M73[64];
|
||||
sprintf(line_M73, mask.c_str(), std::to_string(time).c_str());
|
||||
@ -390,13 +381,11 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
|
||||
sprintf(line_M73, mask.c_str(), format_time_float(time).c_str());
|
||||
return std::string(line_M73);
|
||||
};
|
||||
#endif // ENABLE_EXTENDED_M73_LINES
|
||||
|
||||
GCodeReader parser;
|
||||
std::string gcode_line;
|
||||
size_t g1_lines_counter = 0;
|
||||
// keeps track of last exported pair <percent, remaining time>
|
||||
#if ENABLE_EXTENDED_M73_LINES
|
||||
std::array<std::pair<int, int>, static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count)> last_exported_main;
|
||||
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
|
||||
last_exported_main[i] = { 0, time_in_minutes(machines[i].time) };
|
||||
@ -407,12 +396,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
|
||||
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
|
||||
last_exported_stop[i] = time_in_minutes(machines[i].time);
|
||||
}
|
||||
#else
|
||||
std::array<std::pair<int, int>, static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count)> last_exported;
|
||||
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
|
||||
last_exported[i] = { 0, time_in_minutes(machines[i].time) };
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_M73_LINES
|
||||
|
||||
// buffer line to export only when greater than 64K to reduce writing calls
|
||||
std::string export_line;
|
||||
@ -432,7 +415,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
|
||||
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
|
||||
const TimeMachine& machine = machines[i];
|
||||
if (machine.enabled) {
|
||||
#if ENABLE_EXTENDED_M73_LINES
|
||||
// export pair <percent, remaining time>
|
||||
ret += format_line_M73_main(machine.line_m73_main_mask.c_str(),
|
||||
(line == reserved_tag(ETags::First_Line_M73_Placeholder)) ? 0 : 100,
|
||||
@ -446,12 +428,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
|
||||
last_exported_stop[i] = to_export_stop;
|
||||
++extra_lines_count;
|
||||
}
|
||||
#else
|
||||
ret += format_line_M73(machine.line_m73_mask.c_str(),
|
||||
(line == reserved_tag(ETags::First_Line_M73_Placeholder)) ? 0 : 100,
|
||||
(line == reserved_tag(ETags::First_Line_M73_Placeholder)) ? time_in_minutes(machine.time) : 0);
|
||||
++extra_lines_count;
|
||||
#endif // ENABLE_EXTENDED_M73_LINES
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -505,7 +481,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
|
||||
while (it != machine.g1_times_cache.end() && it->id < g1_lines_counter)
|
||||
++it;
|
||||
if (it != machine.g1_times_cache.end() && it->id == g1_lines_counter) {
|
||||
#if ENABLE_EXTENDED_M73_LINES
|
||||
std::pair<int, int> to_export_main = { int(100.0f * it->elapsed_time / machine.time),
|
||||
time_in_minutes(machine.time - it->elapsed_time) };
|
||||
if (last_exported_main[i] != to_export_main) {
|
||||
@ -513,18 +488,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
|
||||
to_export_main.first, to_export_main.second);
|
||||
last_exported_main[i] = to_export_main;
|
||||
++exported_lines_count;
|
||||
#else
|
||||
float elapsed_time = it->elapsed_time;
|
||||
std::pair<int, int> to_export = { int(100.0f * elapsed_time / machine.time),
|
||||
time_in_minutes(machine.time - elapsed_time) };
|
||||
if (last_exported[i] != to_export) {
|
||||
export_line += format_line_M73(machine.line_m73_mask.c_str(),
|
||||
to_export.first, to_export.second);
|
||||
last_exported[i] = to_export;
|
||||
++exported_lines_count;
|
||||
#endif // ENABLE_EXTENDED_M73_LINES
|
||||
}
|
||||
#if ENABLE_EXTENDED_M73_LINES
|
||||
// export remaining time to next printer stop
|
||||
auto it_stop = std::upper_bound(machine.stop_times.begin(), machine.stop_times.end(), it->elapsed_time,
|
||||
[](float value, const TimeMachine::StopTime& t) { return value < t.elapsed_time; });
|
||||
@ -565,7 +529,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_M73_LINES
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -803,15 +766,10 @@ bool GCodeProcessor::contains_reserved_tags(const std::string& gcode, unsigned i
|
||||
GCodeProcessor::GCodeProcessor()
|
||||
{
|
||||
reset();
|
||||
#if ENABLE_EXTENDED_M73_LINES
|
||||
m_time_processor.machines[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Normal)].line_m73_main_mask = "M73 P%s R%s\n";
|
||||
m_time_processor.machines[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Normal)].line_m73_stop_mask = "M73 C%s\n";
|
||||
m_time_processor.machines[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Stealth)].line_m73_main_mask = "M73 Q%s S%s\n";
|
||||
m_time_processor.machines[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Stealth)].line_m73_stop_mask = "M73 D%s\n";
|
||||
#else
|
||||
m_time_processor.machines[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Normal)].line_m73_mask = "M73 P%s R%s\n";
|
||||
m_time_processor.machines[static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Stealth)].line_m73_mask = "M73 Q%s S%s\n";
|
||||
#endif // ENABLE_EXTENDED_M73_LINES
|
||||
}
|
||||
|
||||
void GCodeProcessor::apply_config(const PrintConfig& config)
|
||||
@ -2911,7 +2869,6 @@ void GCodeProcessor::store_move_vertex(EMoveType type)
|
||||
};
|
||||
m_result.moves.emplace_back(vertex);
|
||||
|
||||
#if ENABLE_EXTENDED_M73_LINES
|
||||
// stores stop time placeholders for later use
|
||||
if (type == EMoveType::Color_change || type == EMoveType::Pause_Print) {
|
||||
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
|
||||
@ -2922,7 +2879,6 @@ void GCodeProcessor::store_move_vertex(EMoveType type)
|
||||
machine.stop_times.push_back({ m_g1_line_id, 0.0f });
|
||||
}
|
||||
}
|
||||
#endif // ENABLE_EXTENDED_M73_LINES
|
||||
}
|
||||
|
||||
void GCodeProcessor::set_extrusion_role(ExtrusionRole role)
|
||||
|
@ -251,7 +251,6 @@ namespace Slic3r {
|
||||
float max_travel_acceleration; // mm/s^2
|
||||
float extrude_factor_override_percentage;
|
||||
float time; // s
|
||||
#if ENABLE_EXTENDED_M73_LINES
|
||||
struct StopTime
|
||||
{
|
||||
unsigned int g1_line_id;
|
||||
@ -260,9 +259,6 @@ namespace Slic3r {
|
||||
std::vector<StopTime> stop_times;
|
||||
std::string line_m73_main_mask;
|
||||
std::string line_m73_stop_mask;
|
||||
#else
|
||||
std::string line_m73_mask;
|
||||
#endif // ENABLE_EXTENDED_M73_LINES
|
||||
State curr;
|
||||
State prev;
|
||||
CustomGCodeTime gcode_time;
|
||||
|
@ -41,8 +41,6 @@
|
||||
//====================
|
||||
#define ENABLE_2_4_0_ALPHA0 1
|
||||
|
||||
// Enable exporting lines M73 for remaining time to next printer stop to gcode
|
||||
#define ENABLE_EXTENDED_M73_LINES (1 && ENABLE_2_4_0_ALPHA0)
|
||||
// Enable a modified version of automatic downscale on load of objects too big
|
||||
#define ENABLE_MODIFIED_DOWNSCALE_ON_LOAD_OBJECTS_TOO_BIG (1 && ENABLE_2_4_0_ALPHA0)
|
||||
// Enable scrollable legend in preview
|
||||
|
Loading…
Reference in New Issue
Block a user