diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index dbe6f883e..4d4dfd4d5 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1338,12 +1338,11 @@ wxString MachineObject::get_upgrade_result_str(int err_code) std::map MachineObject::get_ams_version() { - std::vector ams_type = {"ams", "n3f", "n3s"}; - + std::vector multi_tray_ams_type = {"ams", "n3f"}; std::map result; for (int i = 0; i < 8; i++) { std::string ams_id; - for (auto type : ams_type ) + for (auto type : multi_tray_ams_type) { ams_id = type + "/" + std::to_string(i); auto it = module_vers.find(ams_id); @@ -1352,6 +1351,17 @@ std::map MachineObject::get_ams_version() } } } + + std::string single_tray_ams_type = "n3s"; + int n3s_start_id = 128; + for (int i = n3s_start_id; i < n3s_start_id + 8; i++) { + std::string ams_id; + ams_id = single_tray_ams_type + "/" + std::to_string(i); + auto it = module_vers.find(ams_id); + if (it != module_vers.end()) { + result.emplace(std::pair(i, it->second)); + } + } return result; } diff --git a/src/slic3r/GUI/UpgradePanel.cpp b/src/slic3r/GUI/UpgradePanel.cpp index 04e3417f1..158afe406 100644 --- a/src/slic3r/GUI/UpgradePanel.cpp +++ b/src/slic3r/GUI/UpgradePanel.cpp @@ -12,6 +12,17 @@ namespace GUI { static const wxColour TEXT_NORMAL_CLR = wxColour(0, 174, 66); static const wxColour TEXT_FAILED_CLR = wxColour(255, 111, 0); +static const std::unordered_map ACCESSORY_DISPLAY_STR = { + {"N3F", "AMS 2 PRO"}, + {"N3S", "AMS HT"}, + {"O2L_PC", "Air Pump"}, + {"O2L_10B", "Laser 10w"}, + {"O2L_40B", "Laser 40w"}, + {"O2L_PCM", "Cutting Module"}, + {"O2L_ACM", "Active Cutting Module"}, + {"O2L_UCM", "Ultrasonic Cutting Module"}, +}; + enum FIRMWARE_STASUS { UNKOWN, @@ -136,16 +147,16 @@ MachineInfoPanel::MachineInfoPanel(wxWindow* parent, wxWindowID id, const wxPoin m_ams_info_sizer->SetFlexibleDirection(wxHORIZONTAL); m_ams_info_sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_ALL); - for (auto i = 0; i < 4; i++) { - auto amspanel = new AmsPanel(this, wxID_ANY); - m_ams_info_sizer->Add(amspanel, 1, wxEXPAND, 5); - amspanel->Hide(); + //for (auto i = 0; i < 4; i++) { + // auto amspanel = new AmsPanel(this, wxID_ANY); + // m_ams_info_sizer->Add(amspanel, 1, wxEXPAND, 5); + // amspanel->Hide(); - /*AmsPanelItem item = AmsPanelItem(); - item.id = i; - item.item = amspanel;*/ - m_amspanel_list.Add(amspanel); - } + // /*AmsPanelItem item = AmsPanelItem(); + // item.id = i; + // item.item = amspanel;*/ + // m_amspanel_list.Add(amspanel); + //} m_ams_content_sizer->Add(m_ams_info_sizer, 0, wxEXPAND, 0); m_ams_sizer->Add(m_ams_content_sizer, 1, wxEXPAND, 0); @@ -670,14 +681,28 @@ void MachineInfoPanel::update_ams_ext(MachineObject *obj) show_ams(true); std::map ver_list = obj->get_ams_version(); - AmsPanelHash::iterator iter = m_amspanel_list.begin(); + if (obj->amsList.size() != m_amspanel_list.size()) { + int add_count = obj->amsList.size() - m_amspanel_list.size(); + if (add_count > 0) { + for (int i = 0; i < add_count; i++) { + auto amspanel = new AmsPanel(this, wxID_ANY); + m_ams_info_sizer->Add(amspanel, 1, wxEXPAND, 5); + m_amspanel_list.Add(amspanel); + } + } + if (add_count < 0) { + for (int i = 0; i < -add_count; i++) { + m_amspanel_list.back()->Destroy(); + m_amspanel_list.pop_back(); + } + } + } for (auto i = 0; i < m_amspanel_list.GetCount(); i++) { AmsPanel* amspanel = m_amspanel_list[i]; amspanel->Hide(); } - auto ams_index = 0; for (std::map::iterator iter = obj->amsList.begin(); iter != obj->amsList.end(); iter++) { wxString ams_name; @@ -694,6 +719,7 @@ void MachineInfoPanel::update_ams_ext(MachineObject *obj) } auto ams_id = std::stoi(iter->second->id); + ams_id -= ams_id >= 128 ? 128 : 0; size_t pos = it->second.name.find('/'); wxString ams_device_name = "AMS-%s"; @@ -701,6 +727,8 @@ void MachineInfoPanel::update_ams_ext(MachineObject *obj) if (pos != std::string::npos) { wxString result = it->second.name.substr(0, pos); result.MakeUpper(); + if (auto str_it = ACCESSORY_DISPLAY_STR.find(result); str_it != ACCESSORY_DISPLAY_STR.end()) + result = str_it->second; ams_device_name = result + "-%s"; }