From fdffc4f77e126d10b62836c9d138b75089f0e0ad Mon Sep 17 00:00:00 2001 From: "c.lamboo" Date: Mon, 13 Nov 2023 10:47:07 +0100 Subject: [PATCH 1/3] Add extruder start/end gcode duration settings CURA-11099 --- src/gcodeExport.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gcodeExport.cpp b/src/gcodeExport.cpp index 2ef08a0474..a3efbe2a52 100644 --- a/src/gcodeExport.cpp +++ b/src/gcodeExport.cpp @@ -1254,8 +1254,8 @@ void GCodeExport::startExtruder(const size_t new_extruder) assert(getCurrentExtrudedVolume() == 0.0 && "Just after an extruder switch we haven't extruded anything yet!"); resetExtrusionValue(); // zero the E value on the new extruder, just to be sure - const std::string start_code = Application::getInstance().current_slice->scene.extruders[new_extruder].settings.get("machine_extruder_start_code"); - + const auto extruder_settings = Application::getInstance().current_slice->scene.extruders[new_extruder].settings; + const auto start_code = extruder_settings.get("machine_extruder_start_code"); if (! start_code.empty()) { if (relative_extrusion) @@ -1271,6 +1271,9 @@ void GCodeExport::startExtruder(const size_t new_extruder) } } + const auto start_code_duration = extruder_settings.get("machine_extruder_start_code_duration"); + estimateCalculator.addTime(start_code_duration); + Application::getInstance().communication->setExtruderForSend(Application::getInstance().current_slice->scene.extruders[new_extruder]); Application::getInstance().communication->sendCurrentPosition(getPositionXY()); @@ -1302,7 +1305,7 @@ void GCodeExport::switchExtruder(size_t new_extruder, const RetractionConfig& re resetExtrusionValue(); // zero the E value on the old extruder, so that the current_e_value is registered on the old extruder - const std::string end_code = old_extruder_settings.get("machine_extruder_end_code"); + const auto end_code = old_extruder_settings.get("machine_extruder_end_code"); if (! end_code.empty()) { @@ -1319,6 +1322,9 @@ void GCodeExport::switchExtruder(size_t new_extruder, const RetractionConfig& re } } + const auto end_code_duration = old_extruder_settings.get("machine_extruder_end_code_duration"); + estimateCalculator.addTime(end_code_duration); + startExtruder(new_extruder); } From df83ec631562e80e443a22fba26bab4fd151efa2 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Mon, 13 Nov 2023 09:47:52 +0000 Subject: [PATCH 2/3] Applied clang-format. --- src/gcodeExport.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gcodeExport.cpp b/src/gcodeExport.cpp index a3efbe2a52..629f7b824b 100644 --- a/src/gcodeExport.cpp +++ b/src/gcodeExport.cpp @@ -3,6 +3,13 @@ #include "gcodeExport.h" +#include +#include +#include +#include + +#include + #include "Application.h" //To send layer view data. #include "ExtruderTrain.h" #include "PrintFeature.h" @@ -14,13 +21,6 @@ #include "utils/Date.h" #include "utils/string.h" // MMtoStream, PrecisionedDouble -#include - -#include -#include -#include -#include - namespace cura { From a875046e28fb18b3c87f59f4d6260e5cfe129e53 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Tue, 14 Nov 2023 15:45:51 +0100 Subject: [PATCH 3/3] Fix unit-tests. There's still a failure happening _sometimes_ (sigh) but that isn't related to the current ticket as far as I can see. part of CURA-11099 --- tests/GCodeExportTest.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/GCodeExportTest.cpp b/tests/GCodeExportTest.cpp index 3fb07c9be9..0fd1bdba28 100644 --- a/tests/GCodeExportTest.cpp +++ b/tests/GCodeExportTest.cpp @@ -459,14 +459,21 @@ TEST_F(GCodeExportTest, SwitchExtruderSimple) scene.extruders.emplace_back(0, nullptr); ExtruderTrain& train1 = scene.extruders.back(); + train1.settings.add("machine_extruder_start_code", ";FIRST EXTRUDER START G-CODE!"); train1.settings.add("machine_extruder_end_code", ";FIRST EXTRUDER END G-CODE!"); + train1.settings.add("machine_extruder_start_code_duration", "0.0"); + train1.settings.add("machine_extruder_end_code_duration", "0.0"); train1.settings.add("machine_firmware_retract", "True"); train1.settings.add("retraction_enable", "True"); + scene.extruders.emplace_back(1, nullptr); ExtruderTrain& train2 = scene.extruders.back(); + train2.settings.add("machine_extruder_start_code", ";SECOND EXTRUDER START G-CODE!"); train2.settings.add("machine_extruder_end_code", ";SECOND EXTRUDER END G-CODE!"); + train2.settings.add("machine_extruder_start_code_duration", "0.0"); + train2.settings.add("machine_extruder_end_code_duration", "0.0"); train2.settings.add("machine_firmware_retract", "True"); train2.settings.add("retraction_enable", "True");