FIX: change AMS n3s ams_id & tray_id from 512 to 128

Jira: [STUDIO-13477]
Change-Id: I3844cb59df18220a22d8ff7524216b9fff2b6632
(cherry picked from commit 8c7b66d24b1e795c3070883f3f439cf160b38037)
This commit is contained in:
hemai
2025-07-21 09:24:19 +08:00
committed by Noisyfox
parent a5c6450cc5
commit 5f1ff2f9a9
5 changed files with 85 additions and 74 deletions

View File

@@ -228,14 +228,24 @@ void MaterialItem::render(wxDC &dc)
dc.DrawText(m_material_name, wxPoint((GetSize().x - material_txt_size.x) / 2, ((float)GetSize().y * 2 / 5 - material_txt_size.y) / 2)); dc.DrawText(m_material_name, wxPoint((GetSize().x - material_txt_size.x) / 2, ((float)GetSize().y * 2 / 5 - material_txt_size.y) / 2));
auto mapping_txt_size = dc.GetTextExtent(mapping_txt);
dc.SetTextForeground(wxColour(0x26, 0x2E, 0x30)); dc.SetTextForeground(wxColour(0x26, 0x2E, 0x30));
dc.SetFont(::Label::Head_12); dc.SetFont(::Label::Head_12);
auto mapping_txt_size = wxSize(0, 0);
if (mapping_txt.size() >= 4) {
mapping_txt.insert(mapping_txt.size() / 2, "\n");
mapping_txt_size = dc.GetTextExtent(mapping_txt);
m_text_pos_y = ((float) GetSize().y * 3 / 5 - mapping_txt_size.y) / 2 + (float) GetSize().y * 2 / 5 - mapping_txt_size.y / 2;
m_text_pos_x = mapping_txt_size.x / 4;
} else {
mapping_txt_size = dc.GetTextExtent(mapping_txt);
m_text_pos_y = ((float) GetSize().y * 3 / 5 - mapping_txt_size.y) / 2 + (float) GetSize().y * 2 / 5; m_text_pos_y = ((float) GetSize().y * 3 / 5 - mapping_txt_size.y) / 2 + (float) GetSize().y * 2 / 5;
m_text_pos_x = 0;
}
if (m_match) { if (m_match) {
dc.DrawText(mapping_txt, wxPoint(GetSize().x / 2 + (GetSize().x / 2 - mapping_txt_size.x) / 2 - FromDIP(8) - FromDIP(LEFT_OFFSET), m_text_pos_y)); dc.DrawText(mapping_txt, wxPoint(GetSize().x / 2 + (GetSize().x / 2 - mapping_txt_size.x) / 2 - FromDIP(8) - FromDIP(LEFT_OFFSET) + m_text_pos_x, m_text_pos_y));
} }
} }
@@ -1162,7 +1172,6 @@ void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>&
int ams_type = ams_iter->second->type; int ams_type = ams_iter->second->type;
int nozzle_id = ams_iter->second->nozzle; int nozzle_id = ams_iter->second->nozzle;
if (ams_type >= 1 || ams_type <= 3) { // 1:ams 2:ams-lite 3:n3f
auto sizer_mapping_list = new wxBoxSizer(wxHORIZONTAL); auto sizer_mapping_list = new wxBoxSizer(wxHORIZONTAL);
auto ams_mapping_item_container = new MappingContainer(nozzle_id == 0 ? m_right_marea_panel : m_left_marea_panel, ams_iter->second->get_ams_device_name(), auto ams_mapping_item_container = new MappingContainer(nozzle_id == 0 ? m_right_marea_panel : m_left_marea_panel, ams_iter->second->get_ams_device_name(),
@@ -1182,8 +1191,11 @@ void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>&
for (tray_iter = ams_group->trayList.begin(); tray_iter != ams_group->trayList.end(); tray_iter++) { for (tray_iter = ams_group->trayList.begin(); tray_iter != ams_group->trayList.end(); tray_iter++) {
AmsTray *tray_data = tray_iter->second; AmsTray *tray_data = tray_iter->second;
TrayData td; TrayData td;
if (ams_type == AMSModel::GENERIC_AMS || ams_type == AMSModel::AMS_LITE || ams_type == AMSModel::N3F_AMS) {
td.id = ams_indx * AMS_TOTAL_COUNT + atoi(tray_data->id.c_str()); td.id = ams_indx * AMS_TOTAL_COUNT + atoi(tray_data->id.c_str());
} else if (ams_type == AMSModel::N3S_AMS) {
td.id = ams_indx + atoi(tray_data->id.c_str());
}
td.ams_id = std::stoi(ams_iter->second->id); td.ams_id = std::stoi(ams_iter->second->id);
td.slot_id = std::stoi(tray_iter->second->id); td.slot_id = std::stoi(tray_iter->second->id);
@@ -1226,8 +1238,6 @@ void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>&
left_four_slots_containers.push_back(ams_mapping_item_container); left_four_slots_containers.push_back(ams_mapping_item_container);
} }
} }
} else if (ams_type == 4) { // 4:n3s
}
} }
_add_containers(this, left_one_slot_containers, left_four_slots_containers, m_sizer_ams_basket_left); _add_containers(this, left_one_slot_containers, left_four_slots_containers, m_sizer_ams_basket_left);
@@ -2355,7 +2365,7 @@ void AmsReplaceMaterialDialog::update_to_nozzle(int nozzle_id)
AmsTray* cur_tray = id2tray[elem.first]; AmsTray* cur_tray = id2tray[elem.first];
if (cur_tray) if (cur_tray)
{ {
auto tray_name = wxGetApp().transition_tridid(elem.first, elem.first > 127).ToStdString(); auto tray_name = wxGetApp().transition_tridid(elem.first).ToStdString();
auto it = std::find(m_tray_used.begin(), m_tray_used.end(), tray_name); auto it = std::find(m_tray_used.begin(), m_tray_used.end(), tray_name);
if (it != m_tray_used.end()) if (it != m_tray_used.end())
{ {

View File

@@ -76,6 +76,7 @@ struct TrayData
class MaterialItem: public wxPanel class MaterialItem: public wxPanel
{ {
protected: protected:
int m_text_pos_x = 0;
int m_text_pos_y = -1; int m_text_pos_y = -1;
bool m_dropdown_allow_painted = true; bool m_dropdown_allow_painted = true;

View File

@@ -18,8 +18,10 @@
#include <boost/uuid/uuid.hpp> #include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp> #include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp> #include <boost/uuid/uuid_io.hpp>
#include "fast_float/fast_float.h"
#include <wx/dir.h> #include <wx/dir.h>
#include "fast_float/fast_float.h"
#include "Widgets/AMSItem.hpp"
#define CALI_DEBUG #define CALI_DEBUG
#define MINUTE_30 1800000 //ms #define MINUTE_30 1800000 //ms
@@ -1028,10 +1030,16 @@ int MachineObject::ams_filament_mapping(
bool left_nozzle_has_ams = false, right_nozzle_has_ams = false; bool left_nozzle_has_ams = false, right_nozzle_has_ams = false;
for (auto ams = amsList.begin(); ams != amsList.end(); ams++) { for (auto ams = amsList.begin(); ams != amsList.end(); ams++) {
std::string ams_id = ams->second->id; std::string ams_id = ams->second->id;
int ams_type = ams->second->type;
for (auto tray = ams->second->trayList.begin(); tray != ams->second->trayList.end(); tray++) { for (auto tray = ams->second->trayList.begin(); tray != ams->second->trayList.end(); tray++) {
int ams_id = atoi(ams->first.c_str()); int ams_id = atoi(ams->first.c_str());
int tray_id = atoi(tray->first.c_str()); int tray_id = atoi(tray->first.c_str());
int tray_index = ams_id * 4 + tray_id; int tray_index = 0;
if (ams_type == GUI::AMSModel::GENERIC_AMS || ams_type == GUI::AMSModel::AMS_LITE || ams_type == GUI::AMSModel::N3F_AMS) {
tray_index = ams_id * 4 + tray_id;
} else if (ams_type == GUI::AMSModel::N3S_AMS) {
tray_index = ams_id + tray_id;
}
// skip exclude id // skip exclude id
for (int i = 0; i < exclude_id.size(); i++) { for (int i = 0; i < exclude_id.size(); i++) {
if (tray_index == exclude_id[i]) if (tray_index == exclude_id[i])

View File

@@ -3857,24 +3857,17 @@ wxString GUI_App::transition_tridid(int trid_id) const
int id_index = trid_id / 4; int id_index = trid_id / 4;
return wxString::Format("%s", maping_dict[id_index]); return wxString::Format("%s", maping_dict[id_index]);
} }
else { else if (trid_id >= 0x80 && trid_id <= 0x87) { // n3s
int id_index = ceil(trid_id / 4);
int id_suffix = trid_id % 4 + 1;
return wxString::Format("%s%d", maping_dict[id_index], id_suffix);
}
}
wxString GUI_App::transition_tridid(int trid_id, bool is_n3s) const
{
if (is_n3s)
{
const char base = 'A' + (trid_id - 128); const char base = 'A' + (trid_id - 128);
wxString prefix("HT-"); wxString prefix("HT-");
prefix.append(base); prefix.append(base);
return prefix; return prefix;
} }
else {
return transition_tridid(trid_id); int id_index = std::clamp((int)ceil(trid_id / 4), 0, 25);
int id_suffix = trid_id % 4 + 1;
return wxString::Format("%s%d", maping_dict[id_index], id_suffix);
}
} }
//BBS //BBS

View File

@@ -444,7 +444,6 @@ public:
void load_gcode(wxWindow* parent, wxString& input_file) const; void load_gcode(wxWindow* parent, wxString& input_file) const;
wxString transition_tridid(int trid_id) const; wxString transition_tridid(int trid_id) const;
wxString transition_tridid(int trid_id, bool is_n3s) const;
void ShowUserGuide(); void ShowUserGuide();
void ShowDownNetPluginDlg(); void ShowDownNetPluginDlg();
void ShowUserLogin(bool show = true); void ShowUserLogin(bool show = true);