From 3a0fda7d18b4299f4ef1746c17c74cf33d74b138 Mon Sep 17 00:00:00 2001 From: Ian Chua Date: Mon, 7 Sep 2026 17:28:40 +0800 Subject: [PATCH] fix: make model_id/dev_type optional instead of blocking --- .../GUI/CalibrationWizardPresetPage.cpp | 6 +++ src/slic3r/GUI/DeviceCore/DevConfigUtil.h | 17 +++++++- src/slic3r/GUI/DeviceManager.cpp | 2 + src/slic3r/GUI/GUI_App.cpp | 6 +++ src/slic3r/GUI/MultiMachine.cpp | 6 +++ src/slic3r/GUI/Plater.cpp | 22 +++++++--- src/slic3r/GUI/PrePrintChecker.cpp | 3 +- src/slic3r/GUI/PrePrintChecker.hpp | 1 + src/slic3r/GUI/SelectMachine.cpp | 40 +++++++++++++++++-- src/slic3r/GUI/SendToPrinter.cpp | 6 +++ src/slic3r/GUI/SyncAmsInfoDialog.cpp | 13 +++++- 11 files changed, 110 insertions(+), 12 deletions(-) diff --git a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp index 5267715439..6d28189c54 100644 --- a/src/slic3r/GUI/CalibrationWizardPresetPage.cpp +++ b/src/slic3r/GUI/CalibrationWizardPresetPage.cpp @@ -6,6 +6,7 @@ #include "libslic3r/Print.hpp" #include "DeviceCore/DevConfig.h" +#include "DeviceCore/DevConfigUtil.h" #include "DeviceCore/DevExtruderSystem.h" #include "DeviceCore/DevFilaBlackList.h" #include "DeviceCore/DevFilaSystem.h" @@ -1648,6 +1649,11 @@ bool CalibrationPresetPage::is_blocking_printing() auto source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); auto target_model = obj_->printer_type; + if (DevPrinterConfigUtil::is_optional_printer_model_id(source_model) || + DevPrinterConfigUtil::is_optional_printer_model_id(target_model)) { + return false; + } + if (source_model != target_model) { std::vector compatible_machine = obj_->get_compatible_machine(); vector::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model); diff --git a/src/slic3r/GUI/DeviceCore/DevConfigUtil.h b/src/slic3r/GUI/DeviceCore/DevConfigUtil.h index 2b4af44061..60808a0170 100644 --- a/src/slic3r/GUI/DeviceCore/DevConfigUtil.h +++ b/src/slic3r/GUI/DeviceCore/DevConfigUtil.h @@ -59,6 +59,21 @@ public: /*printer*/ // info static std::map get_all_model_id_with_name(); + // A printer agent may not know the physical model. Keep that case optional so + // model compatibility checks do not turn missing identity into a hard error. + static bool is_optional_printer_model_id(const std::string& model_id) + { + if (model_id.empty()) + return true; + if (model_id.size() != 9) + return false; + + static constexpr char generic_model_id[] = "orcasonar"; + return std::equal(model_id.begin(), model_id.end(), generic_model_id, + [](char lhs, char rhs) { + return static_cast(std::tolower(static_cast(lhs))) == rhs; + }); + } static std::string get_printer_type(const std::string& type_str) { return get_value_from_config(type_str, "printer_type"); } static std::string get_printer_display_name(const std::string& type_str) { return get_value_from_config(type_str, "display_name"); } static std::string get_printer_series_str(std::string type_str) { return get_value_from_config(type_str, "printer_series"); } @@ -227,4 +242,4 @@ static std::string _parse_printer_type(const std::string &type_str) return type_str; } -};// namespace Slic3r \ No newline at end of file +};// namespace Slic3r diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 6c155fe158..fc66604f7c 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -372,6 +372,8 @@ wxString MachineObject::get_printer_type_display_str() const std::string display_name = DevPrinterConfigUtil::get_printer_display_name(printer_type); if (!display_name.empty()) return display_name; + else if (printer_type == "orcasonar") + return "OrcaSonar Printer"; else return _L("Unknown"); } diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 1e9cfab5da..94b36b18f8 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -3,6 +3,7 @@ #include "libslic3r/Technologies.hpp" #include "libslic3r/Platform.hpp" #include "GUI_App.hpp" +#include "DeviceCore/DevConfigUtil.h" #include "GUI_Init.hpp" #include "GUI_ObjectList.hpp" #include "slic3r/GUI/UserManager.hpp" @@ -2393,6 +2394,11 @@ bool GUI_App::is_blocking_printing(MachineObject *obj_) PresetBundle *preset_bundle = wxGetApp().preset_bundle; std::string source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); + if (DevPrinterConfigUtil::is_optional_printer_model_id(source_model) || + DevPrinterConfigUtil::is_optional_printer_model_id(target_model)) { + return false; + } + if (source_model != target_model) { std::vector compatible_machine = obj_->get_compatible_machine(); vector::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model); diff --git a/src/slic3r/GUI/MultiMachine.cpp b/src/slic3r/GUI/MultiMachine.cpp index c0e84f40e9..19328c501f 100644 --- a/src/slic3r/GUI/MultiMachine.cpp +++ b/src/slic3r/GUI/MultiMachine.cpp @@ -3,6 +3,7 @@ #include "GUI_App.hpp" #include "MainFrame.hpp" +#include "DeviceCore/DevConfigUtil.h" namespace Slic3r { namespace GUI { @@ -114,6 +115,11 @@ bool DeviceItem::is_blocking_printing(MachineObject* obj_) PresetBundle* preset_bundle = wxGetApp().preset_bundle; source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); + if (DevPrinterConfigUtil::is_optional_printer_model_id(source_model) || + DevPrinterConfigUtil::is_optional_printer_model_id(target_model)) { + return false; + } + if (source_model != target_model) { std::vector compatible_machine = obj_->get_compatible_machine(); vector::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 6d75be8a3e..7b318c4ffe 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2010,12 +2010,14 @@ bool Sidebar::priv::sync_extruder_list(bool &only_external_material, bool is_man std::string machine_print_name = obj->get_show_printer_type(); PresetBundle *preset_bundle = wxGetApp().preset_bundle; std::string target_model_id = preset_bundle->printers.get_selected_preset().get_printer_type(preset_bundle); - Preset* machine_preset = get_printer_preset(obj); - if (!machine_preset) { + const bool optional_printer_model = DevPrinterConfigUtil::is_optional_printer_model_id(obj->printer_type); + const bool optional_target_model = DevPrinterConfigUtil::is_optional_printer_model_id(target_model_id); + Preset* machine_preset = optional_printer_model ? nullptr : get_printer_preset(obj); + if (!optional_printer_model && !optional_target_model && !machine_preset) { BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << __LINE__ << "check error: machine_preset empty"; return false; } - if (machine_print_name != target_model_id) { + if (!optional_printer_model && !optional_target_model && machine_print_name != target_model_id) { MessageDialog dlg(this->plater, _L("The currently selected machine preset is inconsistent with the connected printer type.\n" "Are you sure to continue syncing?"), _L("Sync printer information"), wxICON_WARNING | wxYES | wxNO); if (dlg.ShowModal() == wxID_NO) { @@ -2207,6 +2209,11 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj) return; } + if (DevPrinterConfigUtil::is_optional_printer_model_id(obj->printer_type)) { + clear_all_sync_status(); + return; + } + bool printer_synced = false; // 1. update printer status const Preset &cur_preset = wxGetApp().preset_bundle->printers.get_edited_preset(); @@ -20490,9 +20497,14 @@ bool Plater::is_same_printer_for_connected_and_selected(bool popup_warning) } if (!check_printer_initialized(obj, true, popup_warning)) return false; - Preset * machine_preset = get_printer_preset(obj); - if (!machine_preset) + const std::string machine_model = obj->printer_type; + PresetBundle *preset_bundle = wxGetApp().preset_bundle; + const std::string selected_model = preset_bundle ? preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle) : std::string(); + if (!DevPrinterConfigUtil::is_optional_printer_model_id(machine_model) && + !DevPrinterConfigUtil::is_optional_printer_model_id(selected_model) && + !get_printer_preset(obj)) { return false; + } if (wxGetApp().is_blocking_printing()) { if (popup_warning) { diff --git a/src/slic3r/GUI/PrePrintChecker.cpp b/src/slic3r/GUI/PrePrintChecker.cpp index 0575af23ed..7d0ae63cf1 100644 --- a/src/slic3r/GUI/PrePrintChecker.cpp +++ b/src/slic3r/GUI/PrePrintChecker.cpp @@ -63,6 +63,7 @@ std::string PrePrintChecker::get_print_status_info(PrintDialogStatus status) case PrintStatusRackReading: return "PrintStatusRackReading"; case PrintStatusRackNozzleNumUnmeetWarning: return "PrintStatusRackNozzleNumUnmeetWarning"; case PrintStatusHasUnreliableNozzleWarning: return "PrintStatusHasUnreliableNozzleWarning"; + case PrintStatusOptionalPrinterModel: return "PrintStatusOptionalPrinterModel"; case PrintStatusWarningExtFilamentNotMatch: return "PrintStatusWarningExtFilamentNotMatch"; case PrintStatusFilamentWarningNozzleHRC: return "PrintStatusFilamentWarningNozzleHRC"; case PrintStatusTPUUnsupportCaliOn: return "PrintStatusTPUUnsupportCaliOn"; @@ -104,6 +105,7 @@ wxString PrePrintChecker::get_pre_state_msg(PrintDialogStatus status) case PrintStatusNeedConsistencyUpgrading: return _L("Cannot send the print job to a printer whose firmware must be updated."); case PrintStatusBlankPlate: return _L("Cannot send a print job for an empty plate."); case PrintStatusTimelapseNoSdcard: return _L("Storage needs to be inserted to record timelapse."); + case PrintStatusOptionalPrinterModel: return _L("The selected printer model could not be identified, so compatibility with the print file configuration cannot be verified. Please verify the printer preset before sending."); case PrintStatusMixAmsAndVtSlotWarning: return _L("You have selected both external and AMS filaments for an extruder. You will need to manually switch the external filament during printing."); case PrintStatusTPUUnsupportAutoCali: return _L("TPU 90A/TPU 85A is too soft and does not support automatic Flow Dynamics calibration."); case PrintStatusWarningKvalueNotUsed: return _L("Set dynamic flow calibration to 'OFF' to enable custom dynamic flow value."); @@ -379,4 +381,3 @@ bool PrinterMsgPanel::UpdateInfos(const std::vector& infos) } }; - diff --git a/src/slic3r/GUI/PrePrintChecker.hpp b/src/slic3r/GUI/PrePrintChecker.hpp index f629b70a73..bab608348d 100644 --- a/src/slic3r/GUI/PrePrintChecker.hpp +++ b/src/slic3r/GUI/PrePrintChecker.hpp @@ -112,6 +112,7 @@ enum PrintDialogStatus : unsigned int { // Orca: a nozzle diameter that differs from the one the printer remembers is a warning, // not an error, so non-standard nozzles can still be printed with. PrintStatusNozzleDiameterMismatch, + PrintStatusOptionalPrinterModel, PrintStatusPrinterWarningEnd, // Warnings for filament diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index fa4482fcef..546649736d 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -21,6 +21,7 @@ #include "Jobs/PlaterWorker.hpp" #include "DeviceCore/DevConfig.h" +#include "DeviceCore/DevConfigUtil.h" #include "DeviceCore/DevNozzleSystem.h" #include "DeviceCore/DevNozzleRack.h" #include "DeviceCore/DevExtensionTool.h" @@ -2315,8 +2316,10 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector compatible_machine = obj_->get_compatible_machine(); vector::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model); @@ -2625,6 +2637,10 @@ bool SelectMachineDialog::is_same_printer_model() if(preset_bundle == nullptr) return result; const auto source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); const auto target_model = obj_->printer_type; + if (DevPrinterConfigUtil::is_optional_printer_model_id(source_model) || + DevPrinterConfigUtil::is_optional_printer_model_id(target_model)) { + return true; + } // Orca: ignore P1P -> P1S if (source_model != target_model) { if ((source_model == "C12" && target_model == "C11") || (source_model == "C11" && target_model == "C12") || @@ -4786,6 +4802,22 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_) return; } + bool has_optional_printer_model = DevPrinterConfigUtil::is_optional_printer_model_id(obj_->printer_type); + if (m_print_type == PrintFromType::FROM_NORMAL) { + PresetBundle* preset_bundle = wxGetApp().preset_bundle; + has_optional_printer_model = has_optional_printer_model || + (preset_bundle && DevPrinterConfigUtil::is_optional_printer_model_id( + preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle))); + } else if (m_print_type == PrintFromType::FROM_SDCARD_VIEW && !m_required_data_plate_data_list.empty()) { + has_optional_printer_model = has_optional_printer_model || + DevPrinterConfigUtil::is_optional_printer_model_id( + m_required_data_plate_data_list[m_print_plate_idx]->printer_model_id); + } + + if (has_optional_printer_model) { + show_status(PrintDialogStatus::PrintStatusOptionalPrinterModel); + } + if (is_blocking_printing(obj_)) { show_status(PrintDialogStatus::PrintStatusUnsupportedPrinter); return; diff --git a/src/slic3r/GUI/SendToPrinter.cpp b/src/slic3r/GUI/SendToPrinter.cpp index a350bd19ea..1fac389862 100644 --- a/src/slic3r/GUI/SendToPrinter.cpp +++ b/src/slic3r/GUI/SendToPrinter.cpp @@ -24,6 +24,7 @@ #include "BitmapCache.hpp" #include "DeviceCore/DevManager.h" +#include "DeviceCore/DevConfigUtil.h" #include "DeviceCore/DevStorage.h" #include "slic3r/Utils/FileTransferUtils.hpp" @@ -1350,6 +1351,11 @@ bool SendToPrinterDialog::is_blocking_printing(MachineObject* obj_) auto source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); auto target_model = obj_->printer_type; + if (DevPrinterConfigUtil::is_optional_printer_model_id(source_model) || + DevPrinterConfigUtil::is_optional_printer_model_id(target_model)) { + return false; + } + if (source_model != target_model) { std::vector compatible_machine = obj_->get_compatible_machine(); vector::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model); diff --git a/src/slic3r/GUI/SyncAmsInfoDialog.cpp b/src/slic3r/GUI/SyncAmsInfoDialog.cpp index 47931e2312..aa203f3577 100644 --- a/src/slic3r/GUI/SyncAmsInfoDialog.cpp +++ b/src/slic3r/GUI/SyncAmsInfoDialog.cpp @@ -1875,6 +1875,11 @@ bool SyncAmsInfoDialog::is_blocking_printing(MachineObject *obj_) if (m_required_data_plate_data_list.size() > 0) { source_model = m_required_data_plate_data_list[m_print_plate_idx]->printer_model_id; } } + if (DevPrinterConfigUtil::is_optional_printer_model_id(source_model) || + DevPrinterConfigUtil::is_optional_printer_model_id(target_model)) { + return false; + } + if (source_model != target_model) { std::vector compatible_machine = obj_->get_compatible_machine(); vector::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model); @@ -1931,7 +1936,13 @@ bool SyncAmsInfoDialog::is_same_printer_model() if (obj_ == nullptr) { return result; } PresetBundle *preset_bundle = wxGetApp().preset_bundle; - if (preset_bundle && preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle) != obj_->printer_type) { + const std::string source_model = preset_bundle ? preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle) : std::string(); + if (DevPrinterConfigUtil::is_optional_printer_model_id(source_model) || + DevPrinterConfigUtil::is_optional_printer_model_id(obj_->printer_type)) { + return true; + } + + if (preset_bundle && source_model != obj_->printer_type) { if ((obj_->is_support_upgrade_kit && obj_->installed_upgrade_kit) && (preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle) == "C12")) { return true; }