diff --git a/resources/config.json b/resources/config.json index 2385e397b6..14dcfdd56f 100644 --- a/resources/config.json +++ b/resources/config.json @@ -22,33 +22,36 @@ "bed_temperature_limit": 100, "model_id": "C11", "printer_type": "C11", - "ftp_folder" : "sdcard/", + "compatible_machine": [ "BL-P001", "BL-P002"], + "ftp_folder": "sdcard/", "printer_thumbnail_image": "printer_thumbnail_p1p" }, { "display_name": "Bambu Lab X1", "func": { - "FUNC_VIRTUAL_TYAY" : true, - "FUNC_EXTRUSION_CALI": false, - "FUNC_LOCAL_TUNNEL": false + "FUNC_VIRTUAL_TYAY": true, + "FUNC_EXTRUSION_CALI": false, + "FUNC_LOCAL_TUNNEL": false }, "model_id": "BL-P002", - "camera_resolution":["720p","1080p"], + "compatible_machine": [ "BL-P001", "C11"], + "camera_resolution": [ "720p", "1080p" ], "printer_type": "3DPrinter-X1", "printer_thumbnail_image": "printer_thumbnail" - }, - { - "display_name": "Bambu Lab X1 Carbon", - "func": { - "FUNC_VIRTUAL_TYAY" : true, - "FUNC_EXTRUSION_CALI": false, - "FUNC_LOCAL_TUNNEL": false - }, - "model_id": "BL-P001", - "camera_resolution":["720p","1080p"], - "printer_type": "3DPrinter-X1-Carbon", - "printer_thumbnail_image": "printer_thumbnail" - } + }, + { + "display_name": "Bambu Lab X1 Carbon", + "func": { + "FUNC_VIRTUAL_TYAY": true, + "FUNC_EXTRUSION_CALI": false, + "FUNC_LOCAL_TUNNEL": false + }, + "model_id": "BL-P001", + "compatible_machine": [ "BL-P002", "C11"], + "camera_resolution": [ "720p", "1080p" ], + "printer_type": "3DPrinter-X1-Carbon", + "printer_thumbnail_image": "printer_thumbnail" + } ] } diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 5d3c754c67..9a068f2251 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -2362,6 +2362,11 @@ void MachineObject::set_print_state(std::string status) print_status = status; } +std::vector MachineObject::get_compatible_machine() +{ + return DeviceManager::get_compatible_machine(printer_type); +} + int MachineObject::connect(bool is_anonymous, bool use_openssl) { if (dev_ip.empty()) return -1; @@ -5039,4 +5044,20 @@ std::string DeviceManager::load_gcode(std::string type_str, std::string gcode_fi return ""; } +std::vector DeviceManager::get_compatible_machine(std::string type_str) +{ + std::vector compatible_machine; + if (DeviceManager::function_table.contains("printers")) { + for (auto printer : DeviceManager::function_table["printers"]) { + if (printer.contains("model_id") && printer["model_id"].get() == type_str) { + if (printer.contains("compatible_machine")) { + for (auto res : printer["compatible_machine"]) + compatible_machine.emplace_back(res.get()); + } + } + } + } + return compatible_machine; +} + } // namespace Slic3r diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 651f3e0a7f..87520a8639 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -910,6 +910,7 @@ public: static bool is_in_printing_status(std::string status); void set_print_state(std::string status); + std::vector get_compatible_machine(); bool is_connected(); bool is_connecting(); @@ -1005,6 +1006,7 @@ public: static bool load_filaments_blacklist_config(std::string config_file); static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info); static std::string load_gcode(std::string type_str, std::string gcode_file); + static std::vector get_compatible_machine(std::string type_str); }; } // namespace Slic3r diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index e6e93b32c5..b642508197 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -92,6 +92,8 @@ std::string get_print_status_info(PrintDialogStatus status) return "PrintStatusLanModeNoSdcard"; case PrintStatusNoSdcard: return "PrintStatusNoSdcard"; + case PrintStatusUnsupportedPrinter: + return "PrintStatusUnsupportedPrinter"; case PrintStatusTimelapseNoSdcard: return "PrintStatusTimelapseNoSdcard"; case PrintStatusNotSupportedPrintAll: @@ -2129,7 +2131,12 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vectorEndModal(wxID_CANCEL); } +bool SelectMachineDialog::is_blocking_printing() +{ + DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); + if (!dev) return true; + + MachineObject* obj_ = dev->get_selected_machine(); + if (obj_ == nullptr) return true; + + PresetBundle* preset_bundle = wxGetApp().preset_bundle; + auto source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); + auto target_model = obj_->printer_type; + + if (source_model != target_model) { + std::vector compatible_machine = dev->get_compatible_machine(target_model); + vector::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model); + if (it == compatible_machine.end()) { + return true; + } + } + + return false; +} + bool SelectMachineDialog::is_same_printer_model() { bool result = true; @@ -3106,7 +3136,11 @@ void SelectMachineDialog::update_show_status() } } - if (obj_->is_in_upgrading()) { + if (is_blocking_printing()) { + show_status(PrintDialogStatus::PrintStatusUnsupportedPrinter); + return; + } + else if (obj_->is_in_upgrading()) { show_status(PrintDialogStatus::PrintStatusInUpgrading); return; } diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index 4a90ebc2ee..e68a8bfe28 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -271,7 +271,8 @@ enum PrintDialogStatus { PrintStatusNeedConsistencyUpgrading, PrintStatusNotSupportedSendToSDCard, PrintStatusNotSupportedPrintAll, - PrintStatusBlankPlate + PrintStatusBlankPlate, + PrintStatusUnsupportedPrinter }; std::string get_print_status_info(PrintDialogStatus status); @@ -442,6 +443,7 @@ public: void set_flow_calibration_state(bool state); bool is_show_timelapse(); bool is_same_printer_model(); + bool is_blocking_printing(); bool has_tips(MachineObject* obj); bool is_timeout(); int update_print_required_data(Slic3r::DynamicPrintConfig config, Slic3r::Model model, Slic3r::PlateDataPtrs plate_data_list, std::string file_name);