mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-30 20:21:12 -06:00 
			
		
		
		
	GCodeProcessor -> Fixed time estimate for stealth mode
This commit is contained in:
		
							parent
							
								
									dea641183c
								
							
						
					
					
						commit
						5882c121cc
					
				
					 4 changed files with 40 additions and 6 deletions
				
			
		|  | @ -159,6 +159,7 @@ void GCodeProcessor::TimeMachine::reset() | |||
| { | ||||
|     enabled = false; | ||||
|     acceleration = 0.0f; | ||||
|     max_acceleration = 0.0f; | ||||
|     extrude_factor_override_percentage = 1.0f; | ||||
|     time = 0.0f; | ||||
|     curr.reset(); | ||||
|  | @ -289,6 +290,7 @@ void GCodeProcessor::TimeProcessor::reset() | |||
| { | ||||
|     extruder_unloaded = true; | ||||
|     export_remaining_time_enabled = false; | ||||
|     machine_envelope_processing_enabled = false; | ||||
|     machine_limits = MachineEnvelopeConfig(); | ||||
|     filament_load_times = std::vector<float>(); | ||||
|     filament_unload_times = std::vector<float>(); | ||||
|  | @ -484,6 +486,7 @@ void GCodeProcessor::apply_config(const PrintConfig& config) | |||
| 
 | ||||
|     for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) { | ||||
|         float max_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_extruding, i); | ||||
|         m_time_processor.machines[i].max_acceleration = max_acceleration; | ||||
|         m_time_processor.machines[i].acceleration = (max_acceleration > 0.0f) ? max_acceleration : DEFAULT_ACCELERATION; | ||||
|     } | ||||
| 
 | ||||
|  | @ -628,6 +631,7 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config) | |||
| 
 | ||||
|     for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) { | ||||
|         float max_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_extruding, i); | ||||
|         m_time_processor.machines[i].max_acceleration = max_acceleration; | ||||
|         m_time_processor.machines[i].acceleration = (max_acceleration > 0.0f) ? max_acceleration : DEFAULT_ACCELERATION; | ||||
|     } | ||||
| } | ||||
|  | @ -1304,6 +1308,9 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line) | |||
|         return type; | ||||
|     }; | ||||
| 
 | ||||
|     // enable processing of lines M201/M203/M204/M205
 | ||||
|     m_time_processor.machine_envelope_processing_enabled = true; | ||||
| 
 | ||||
|     // updates axes positions from line
 | ||||
|     for (unsigned char a = X; a <= E; ++a) { | ||||
|         m_end_position[a] = absolute_position((Axis)a, line); | ||||
|  | @ -1664,6 +1671,9 @@ 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 != gcfRepRap && m_units == EUnits::Inches) ? INCHES_TO_MM : 1.0f; | ||||
| 
 | ||||
|  | @ -1684,6 +1694,9 @@ void GCodeProcessor::process_M201(const GCodeReader::GCodeLine& line) | |||
| 
 | ||||
| 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; | ||||
|  | @ -1709,6 +1722,9 @@ void GCodeProcessor::process_M203(const GCodeReader::GCodeLine& line) | |||
| 
 | ||||
| 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>(ETimeMode::Count); ++i) { | ||||
|         if (line.has_value('S', value)) { | ||||
|  | @ -1736,6 +1752,9 @@ 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>(ETimeMode::Count); ++i) { | ||||
|         if (line.has_x()) { | ||||
|             float max_jerk = line.x(); | ||||
|  | @ -1968,8 +1987,9 @@ void GCodeProcessor::set_acceleration(ETimeMode mode, float value) | |||
| { | ||||
|     size_t id = static_cast<size_t>(mode); | ||||
|     if (id < m_time_processor.machines.size()) { | ||||
|         float max_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_extruding, id); | ||||
|         m_time_processor.machines[id].acceleration = (max_acceleration == 0.0f) ? value : std::min(value, max_acceleration); | ||||
|         m_time_processor.machines[id].acceleration = (m_time_processor.machines[id].max_acceleration == 0.0f) ? value : | ||||
|             // Clamp the acceleration with the maximum.
 | ||||
|             std::min(value, m_time_processor.machines[id].max_acceleration); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -182,6 +182,8 @@ namespace Slic3r { | |||
| 
 | ||||
|             bool enabled; | ||||
|             float acceleration; // mm/s^2
 | ||||
|             // hard limit for the acceleration, to which the firmware will clamp.
 | ||||
|             float max_acceleration; // mm/s^2
 | ||||
|             float extrude_factor_override_percentage; | ||||
|             float time; // s
 | ||||
|             std::string line_m73_mask; | ||||
|  | @ -216,7 +218,10 @@ namespace Slic3r { | |||
|             // This is currently only really used by the MK3 MMU2:
 | ||||
|             // extruder_unloaded = true means no filament is loaded yet, all the filaments are parked in the MK3 MMU2 unit.
 | ||||
|             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()
 | ||||
|             bool machine_envelope_processing_enabled; | ||||
|             MachineEnvelopeConfig machine_limits; | ||||
|             // Additional load / unload times for a filament exchange sequence.
 | ||||
|             std::vector<float> filament_load_times; | ||||
|  | @ -328,6 +333,7 @@ namespace Slic3r { | |||
|         bool is_stealth_time_estimator_enabled() const { | ||||
|             return m_time_processor.machines[static_cast<size_t>(ETimeMode::Stealth)].enabled; | ||||
|         } | ||||
|         void enable_machine_envelope_processing(bool enabled) { m_time_processor.machine_envelope_processing_enabled = enabled; } | ||||
|         void enable_producers(bool enabled) { m_producers_enabled = enabled; } | ||||
|         void reset(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -9,7 +9,7 @@ | |||
| #include "GUI_App.hpp" | ||||
| #include "MainFrame.hpp" | ||||
| #include "Plater.hpp" | ||||
| #include "PresetBundle.hpp" | ||||
| #include "libslic3r/PresetBundle.hpp" | ||||
| #include "Camera.hpp" | ||||
| #include "I18N.hpp" | ||||
| #include "GUI_Utils.hpp" | ||||
|  | @ -1498,7 +1498,7 @@ void GCodeViewer::render_legend() const | |||
|                 imgui.text(time); | ||||
|                 ImGui::SameLine(offsets[1]); | ||||
|                 pos = ImGui::GetCursorScreenPos(); | ||||
|                 float width = percent_bar_size * percent / max_percent; | ||||
|                 float width = std::max(1.0f, percent_bar_size * percent / max_percent); | ||||
|                 draw_list->AddRectFilled({ pos.x, pos.y + 2.0f }, { pos.x + width, pos.y + icon_size - 2.0f }, | ||||
|                     ImGui::GetColorU32(ImGuiWrapper::COL_ORANGE_LIGHT)); | ||||
|                 ImGui::Dummy({ percent_bar_size, icon_size }); | ||||
|  | @ -1649,7 +1649,15 @@ void GCodeViewer::render_legend() const | |||
|         imgui.text(short_time(get_time_dhms(time_mode.time))); | ||||
| 
 | ||||
|         auto show_mode_button = [this, &imgui](const std::string& label, PrintEstimatedTimeStatistics::ETimeMode mode) { | ||||
|             if (m_time_statistics.modes[static_cast<size_t>(mode)].roles_times.size() > 0) { | ||||
|             bool show = false; | ||||
|             for (size_t i = 0; i < m_time_statistics.modes.size(); ++i) { | ||||
|                 if (i != static_cast<size_t>(mode) && | ||||
|                     short_time(get_time_dhms(m_time_statistics.modes[static_cast<size_t>(mode)].time)) != short_time(get_time_dhms(m_time_statistics.modes[i].time))) { | ||||
|                     show = true; | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
|             if (show && m_time_statistics.modes[static_cast<size_t>(mode)].roles_times.size() > 0) { | ||||
|                 ImGui::SameLine(0.0f, 10.0f); | ||||
|                 if (imgui.button(label)) { | ||||
|                     m_time_estimate_mode = mode; | ||||
|  |  | |||
|  | @ -4577,8 +4577,8 @@ void Plater::load_gcode(const wxString& filename) | |||
| 
 | ||||
|     // process gcode
 | ||||
|     GCodeProcessor processor; | ||||
| //    processor.apply_config(config);
 | ||||
|     processor.enable_producers(true); | ||||
|     processor.enable_machine_envelope_processing(true); | ||||
|     processor.process_file(filename.ToUTF8().data()); | ||||
|     p->gcode_result = std::move(processor.extract_result()); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 enricoturri1966
						enricoturri1966