GCodeViewer - Fixed visualization of time estimates for silent mode

This commit is contained in:
enricoturri1966 2020-12-17 11:41:41 +01:00
parent 64e68f418b
commit b8fc1d3173
3 changed files with 69 additions and 67 deletions

View file

@ -724,6 +724,9 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
m_time_processor.machines[i].acceleration = (max_acceleration > 0.0f) ? max_acceleration : DEFAULT_ACCELERATION;
}
if (m_time_processor.machine_limits.machine_max_acceleration_x.values.size() > 1)
enable_stealth_time_estimator(true);
#if ENABLE_VOLUMETRIC_EXTRUSION_PROCESSING
const ConfigOptionBool* use_volumetric_e = config.option<ConfigOptionBool>("use_volumetric_e");
if (use_volumetric_e != nullptr)
@ -2140,13 +2143,12 @@ void GCodeProcessor::process_M135(const GCodeReader::GCodeLine& line)
void GCodeProcessor::process_M201(const GCodeReader::GCodeLine& line)
{
if (!m_time_processor.machine_envelope_processing_enabled)
return;
// see http://reprap.org/wiki/G-code#M201:_Set_max_printing_acceleration
float factor = ((m_flavor != gcfRepRapSprinter && m_flavor != gcfRepRapFirmware) && m_units == EUnits::Inches) ? INCHES_TO_MM : 1.0f;
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedTimeStatistics::ETimeMode::Count); ++i) {
if (static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i) == PrintEstimatedTimeStatistics::ETimeMode::Normal ||
m_time_processor.machine_envelope_processing_enabled) {
if (line.has_x())
set_option_value(m_time_processor.machine_limits.machine_max_acceleration_x, i, line.x() * factor);
@ -2159,13 +2161,11 @@ void GCodeProcessor::process_M201(const GCodeReader::GCodeLine& line)
if (line.has_e())
set_option_value(m_time_processor.machine_limits.machine_max_acceleration_e, i, line.e() * factor);
}
}
}
void GCodeProcessor::process_M203(const GCodeReader::GCodeLine& line)
{
if (!m_time_processor.machine_envelope_processing_enabled)
return;
// see http://reprap.org/wiki/G-code#M203:_Set_maximum_feedrate
if (m_flavor == gcfRepetier)
return;
@ -2175,6 +2175,8 @@ void GCodeProcessor::process_M203(const GCodeReader::GCodeLine& line)
float factor = (m_flavor == gcfMarlin || m_flavor == gcfSmoothie) ? 1.0f : MMMIN_TO_MMSEC;
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedTimeStatistics::ETimeMode::Count); ++i) {
if (static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i) == PrintEstimatedTimeStatistics::ETimeMode::Normal ||
m_time_processor.machine_envelope_processing_enabled) {
if (line.has_x())
set_option_value(m_time_processor.machine_limits.machine_max_feedrate_x, i, line.x() * factor);
@ -2187,15 +2189,15 @@ void GCodeProcessor::process_M203(const GCodeReader::GCodeLine& line)
if (line.has_e())
set_option_value(m_time_processor.machine_limits.machine_max_feedrate_e, i, line.e() * factor);
}
}
}
void GCodeProcessor::process_M204(const GCodeReader::GCodeLine& line)
{
if (!m_time_processor.machine_envelope_processing_enabled)
return;
float value;
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedTimeStatistics::ETimeMode::Count); ++i) {
if (static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i) == PrintEstimatedTimeStatistics::ETimeMode::Normal ||
m_time_processor.machine_envelope_processing_enabled) {
if (line.has_value('S', value)) {
// Legacy acceleration format. This format is used by the legacy Marlin, MK2 or MK3 firmware,
// and it is also generated by Slic3r to control acceleration per extrusion type
@ -2217,14 +2219,14 @@ void GCodeProcessor::process_M204(const GCodeReader::GCodeLine& line)
}
}
}
}
}
void GCodeProcessor::process_M205(const GCodeReader::GCodeLine& line)
{
if (!m_time_processor.machine_envelope_processing_enabled)
return;
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedTimeStatistics::ETimeMode::Count); ++i) {
if (static_cast<PrintEstimatedTimeStatistics::ETimeMode>(i) == PrintEstimatedTimeStatistics::ETimeMode::Normal ||
m_time_processor.machine_envelope_processing_enabled) {
if (line.has_x()) {
float max_jerk = line.x();
set_option_value(m_time_processor.machine_limits.machine_max_jerk_x, i, max_jerk);
@ -2247,6 +2249,7 @@ void GCodeProcessor::process_M205(const GCodeReader::GCodeLine& line)
if (line.has_value('T', value))
set_option_value(m_time_processor.machine_limits.machine_min_travel_rate, i, value);
}
}
}
void GCodeProcessor::process_M221(const GCodeReader::GCodeLine& line)

View file

@ -242,7 +242,7 @@ namespace Slic3r {
bool extruder_unloaded;
// whether or not to export post-process the gcode to export lines M73 in it
bool export_remaining_time_enabled;
// allow to skip the lines M201/M203/M204/M205 generated by GCode::print_machine_envelope()
// allow to skip the lines M201/M203/M204/M205 generated by GCode::print_machine_envelope() for non-Normal time estimate mode
bool machine_envelope_processing_enabled;
MachineEnvelopeConfig machine_limits;
// Additional load / unload times for a filament exchange sequence.

View file

@ -4857,7 +4857,6 @@ void Plater::load_gcode(const wxString& filename)
// process gcode
GCodeProcessor processor;
processor.enable_producers(true);
processor.enable_machine_envelope_processing(true);
processor.process_file(filename.ToUTF8().data(), false);
p->gcode_result = std::move(processor.extract_result());