From 5b5489cc95803d1dadc0f6a1246ca39710e9196c Mon Sep 17 00:00:00 2001 From: "xin.zhang" Date: Fri, 9 May 2025 19:48:26 +0800 Subject: [PATCH] ENH: support filament soften check jira: [STUDIO-11922] Change-Id: I819c47e847ca30120c9fffeab3e9e1955b7f6beb --- src/slic3r/GUI/DeviceManager.cpp | 8 +++- src/slic3r/GUI/DeviceManager.hpp | 3 ++ src/slic3r/GUI/PrePrintChecker.cpp | 1 - src/slic3r/GUI/PrePrintChecker.hpp | 1 + src/slic3r/GUI/SelectMachine.cpp | 71 +++++++++++++++++++++++++----- 5 files changed, 70 insertions(+), 14 deletions(-) diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 655394de1..95ab8e7e2 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -921,6 +921,10 @@ AmsTray *MachineObject::get_ams_tray(std::string ams_id, std::string tray_id) return nullptr; } +std::string MachineObject::get_filament_id(std::string ams_id, std::string tray_id) const { + return this->get_tray(ams_id, tray_id).setting_id; +} + void MachineObject::_parse_ams_status(int ams_status) { ams_status_sub = ams_status & 0xFF; @@ -6137,7 +6141,7 @@ bool MachineObject::contains_tray(const std::string &ams_id, const std::string & } } else { for (const auto& tray : vt_slot) { - if (tray.id == tray_id) { return true; } + if (tray.id == ams_id) { return true; } } } @@ -6155,7 +6159,7 @@ AmsTray MachineObject::get_tray(const std::string &ams_id, const std::string &tr } else { for (const auto &tray : vt_slot) { - if (tray.id == tray_id) { return tray; } + if (tray.id == ams_id) { return tray; } } } diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index e739f0d98..9cf8552d5 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -764,6 +764,9 @@ public: Ams* get_curr_Ams(); AmsTray* get_curr_tray(); AmsTray *get_ams_tray(std::string ams_id, std::string tray_id); + + std::string get_filament_id(std::string ams_id, std::string tray_id) const; + // parse amsStatusMain and ams_status_sub void _parse_ams_status(int ams_status); bool has_ams() { return ams_exist_bits != 0; } diff --git a/src/slic3r/GUI/PrePrintChecker.cpp b/src/slic3r/GUI/PrePrintChecker.cpp index b22358e36..62ff0ffe6 100644 --- a/src/slic3r/GUI/PrePrintChecker.cpp +++ b/src/slic3r/GUI/PrePrintChecker.cpp @@ -82,7 +82,6 @@ wxString PrePrintChecker::get_pre_state_msg(PrintDialogStatus status) case PrintStatusNotSupportedPrintAll: return _L("This printer does not support printing all plates"); case PrintStatusWarningTpuRightColdPulling: return _L("Please cold pull before printing TPU to avoid clogging. You may use cold pull maintenance on the printer."); case PrintStatusFilamentHighChamberTempCloseDoor: return _L("High chamber temperature is required. Please close the door."); - case PrintStatusFilamentHighChamberTempSoft: return _L("The filament on the extruder may soften. Please unload."); } return wxEmptyString; } diff --git a/src/slic3r/GUI/PrePrintChecker.hpp b/src/slic3r/GUI/PrePrintChecker.hpp index 45b34c50b..263496cd2 100644 --- a/src/slic3r/GUI/PrePrintChecker.hpp +++ b/src/slic3r/GUI/PrePrintChecker.hpp @@ -89,6 +89,7 @@ enum PrintDialogStatus : unsigned int { PrintStatusHasFilamentInBlackListWarning, PrintStatusFilamentHighChamberTempCloseDoor, PrintStatusFilamentHighChamberTempSoft, + PrintStatusUnknownFilamentHighChamberTempSoft, PrintStatusFilamentWarningEnd, PrintStatusWarningEnd,//->end error<- diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index ed0628388..18c140f8a 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -1732,7 +1732,7 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector& extruders, int total_ext_num) +{ + assert(!extruders.empty()); + if (total_ext_num == 1) + { + return _L("extruder"); + } + else if (total_ext_num == 2) + { + if (extruders.size() == 2) + { + return _L("both extruders"); + } + else if (extruders.size() == 1) + { + auto iter = extruders.begin(); + if (*iter == MAIN_NOZZLE_ID) + { + return _L("right extruder"); + } + else + { + return _L("left extruder"); + } + } + } + + return wxEmptyString; +} + void SelectMachineDialog::update_show_status(MachineObject* obj_) { m_pre_print_checker.clear(); @@ -3496,6 +3526,8 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_) } /*Check high temperture slicing*/ + std::unordered_set known_fila_soften_extruders; + std::unordered_set unknown_fila_soften_extruders; auto preset_full_config = wxGetApp().preset_bundle->full_config(); auto chamber_temperatures = preset_full_config.option("chamber_temperatures"); for (const FilamentInfo& item : m_ams_mapping_result) @@ -3513,16 +3545,19 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_) } // check vitrification - if (obj_->is_filament_at_extruder()) - { - AmsTray* tray = obj_->get_curr_tray(); - if (tray) - { - auto filament_info = wxGetApp().preset_bundle->get_filament_by_filament_id(tray->setting_id); - if (filament_info && (filament_info->temperature_vitrification - chamber_temp <= 5)) - { - show_status(PrintDialogStatus::PrintStatusFilamentHighChamberTempSoft); - return; + for (const auto& extder : obj_->m_extder_data.extders) { + if (extder.ext_has_filament) { + const auto& fila_id = obj_->get_filament_id(extder.snow.ams_id, extder.snow.slot_id); + auto filament_info = wxGetApp().preset_bundle->get_filament_by_filament_id(fila_id); + if (filament_info ) { + if (filament_info->temperature_vitrification - chamber_temp <= 5) { + known_fila_soften_extruders.insert(extder.id); + } + } else { + // the minimum temperature_vitrification of the known filaments is 43 degrees + if (43 - chamber_temp <= 5) { + unknown_fila_soften_extruders.insert(extder.id); + } } } } @@ -3530,6 +3565,20 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_) catch (std::exception&) { assert(0); } } + if (!known_fila_soften_extruders.empty()) { + const wxString& msg = wxString::Format(_L("The filament on %s may soften. Please unload."), + _get_ext_loc_str(known_fila_soften_extruders, obj_->m_extder_data.total_extder_count)); + show_status(PrintDialogStatus::PrintStatusFilamentHighChamberTempSoft, std::vector {msg}); + return; + } + + if (!unknown_fila_soften_extruders.empty()) { + const wxString& msg = wxString::Format(_L("The filament on %s is unknown and may soften. Please set filament."), + _get_ext_loc_str(unknown_fila_soften_extruders, obj_->m_extder_data.total_extder_count)); + show_status(PrintDialogStatus::PrintStatusUnknownFilamentHighChamberTempSoft, std::vector {msg}); + return; + } + /** normal check **/ show_status(PrintDialogStatus::PrintStatusReadyToGo); }