diff --git a/src/gcodeExport.cpp b/src/gcodeExport.cpp index 2ef08a0474..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 { @@ -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); } 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");