FIX: the single AMS failed to show
jira: [STUDIO-9445] Change-Id: I8a565f50a109355f85a66567d242998b26fa4bdc
This commit is contained in:
parent
50b2f883b3
commit
5ca6d99fd6
|
@ -1548,22 +1548,6 @@ void AmsReplaceMaterialDialog::create()
|
||||||
Fit();
|
Fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<bool> AmsReplaceMaterialDialog::GetStatus(unsigned int status)
|
|
||||||
{
|
|
||||||
std::vector<bool> listStatus;
|
|
||||||
bool current = false;
|
|
||||||
for (int i = 0; i < 16; i++) {
|
|
||||||
if (status & (1 << i)) {
|
|
||||||
current = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
current = false;
|
|
||||||
}
|
|
||||||
listStatus.push_back(current);
|
|
||||||
}
|
|
||||||
return listStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AmsReplaceMaterialDialog::update_mapping_result( std::vector<FilamentInfo> result)
|
void AmsReplaceMaterialDialog::update_mapping_result( std::vector<FilamentInfo> result)
|
||||||
{
|
{
|
||||||
m_tray_used.clear();
|
m_tray_used.clear();
|
||||||
|
@ -1591,7 +1575,7 @@ void AmsReplaceMaterialDialog::update_machine_obj(MachineObject* obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AmsRMGroup* AmsReplaceMaterialDialog::create_backup_group(wxString gname, std::map<std::string, wxColour> group_info, wxString material, std::vector<bool> status_list)
|
AmsRMGroup* AmsReplaceMaterialDialog::create_backup_group(wxString gname, std::map<std::string, wxColour> group_info, wxString material)
|
||||||
{
|
{
|
||||||
auto grp = new AmsRMGroup(m_scrollview_groups, group_info, material, gname);
|
auto grp = new AmsRMGroup(m_scrollview_groups, group_info, material, gname);
|
||||||
return grp;
|
return grp;
|
||||||
|
@ -1610,6 +1594,29 @@ void AmsReplaceMaterialDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::unordered_map<int, bool>
|
||||||
|
_GetBackupStatus(unsigned int fila_back_group)
|
||||||
|
{
|
||||||
|
std::unordered_map<int, bool> trayid_group;
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
if (fila_back_group & (1 << i))
|
||||||
|
{
|
||||||
|
trayid_group[i] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 16; j < 32; j++)/* single ams is from 128*/
|
||||||
|
{
|
||||||
|
if (fila_back_group & (1 << j))
|
||||||
|
{
|
||||||
|
trayid_group[128 + j - 16] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return trayid_group;
|
||||||
|
}
|
||||||
|
|
||||||
void AmsReplaceMaterialDialog::update_to_nozzle(int nozzle_id)
|
void AmsReplaceMaterialDialog::update_to_nozzle(int nozzle_id)
|
||||||
{
|
{
|
||||||
if (!m_obj)
|
if (!m_obj)
|
||||||
|
@ -1623,22 +1630,24 @@ void AmsReplaceMaterialDialog::update_to_nozzle(int nozzle_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// traverse the amd list
|
// traverse the amd list
|
||||||
AmsTray* tray_list[4 * 4];
|
std::unordered_map<int, AmsTray*> id2tray;// tray id to tray
|
||||||
for (auto i = 0; i < 4 * 4; i++)
|
|
||||||
{
|
|
||||||
tray_list[i] = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
for (auto ams_info : m_obj->amsList)
|
for (const auto& ams_info : m_obj->amsList)
|
||||||
{
|
{
|
||||||
int ams_id_int = atoi(ams_info.first.c_str()) * 4;
|
int ams_device_id = atoi(ams_info.first.c_str());
|
||||||
for (auto tray_info : ams_info.second->trayList)
|
if (ams_device_id < 128)
|
||||||
{
|
{
|
||||||
int tray_id_int = atoi(tray_info.first.c_str());
|
int ams_base_id = ams_device_id * 4;
|
||||||
tray_id_int = ams_id_int + tray_id_int;
|
for (auto tray_info : ams_info.second->trayList)
|
||||||
tray_list[tray_id_int] = tray_info.second;
|
{
|
||||||
|
int tray_offset = atoi(tray_info.first.c_str());
|
||||||
|
id2tray[ams_base_id + tray_offset] = tray_info.second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ams_info.second->trayList.size() == 1)/*n3f*/
|
||||||
|
{
|
||||||
|
id2tray[ams_device_id] = ams_info.second->trayList.begin()->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1650,32 +1659,35 @@ void AmsReplaceMaterialDialog::update_to_nozzle(int nozzle_id)
|
||||||
const Extder& extder = m_obj->m_extder_data.extders[nozzle_id];
|
const Extder& extder = m_obj->m_extder_data.extders[nozzle_id];
|
||||||
for (int filam : extder.filam_bak)
|
for (int filam : extder.filam_bak)
|
||||||
{
|
{
|
||||||
auto status_list = GetStatus(filam);
|
|
||||||
|
|
||||||
std::map<std::string, wxColour> group_info;
|
std::map<std::string, wxColour> group_info;
|
||||||
std::string group_material;
|
std::string group_material;
|
||||||
bool is_in_tray = false;
|
bool is_in_tray = false;
|
||||||
|
|
||||||
//get color & material
|
//get color & material
|
||||||
for (auto i = 0; i < status_list.size(); i++)
|
const auto& trayid_group = _GetBackupStatus(filam);
|
||||||
|
for (const auto& elem : trayid_group)
|
||||||
{
|
{
|
||||||
if (status_list[i] && tray_list[i] != nullptr)
|
if (elem.second)
|
||||||
{
|
{
|
||||||
auto tray_name = wxGetApp().transition_tridid(i).ToStdString();
|
AmsTray* cur_tray = id2tray[elem.first];
|
||||||
auto it = std::find(m_tray_used.begin(), m_tray_used.end(), tray_name);
|
if (cur_tray)
|
||||||
if (it != m_tray_used.end())
|
|
||||||
{
|
{
|
||||||
is_in_tray = true;
|
auto tray_name = wxGetApp().transition_tridid(elem.first, elem.first > 127).ToStdString();
|
||||||
}
|
auto it = std::find(m_tray_used.begin(), m_tray_used.end(), tray_name);
|
||||||
|
if (it != m_tray_used.end())
|
||||||
|
{
|
||||||
|
is_in_tray = true;
|
||||||
|
}
|
||||||
|
|
||||||
group_info[tray_name] = AmsTray::decode_color(tray_list[i]->color);
|
group_info[tray_name] = AmsTray::decode_color(cur_tray->color);
|
||||||
group_material = tray_list[i]->get_display_filament_type();
|
group_material = cur_tray->get_display_filament_type();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_in_tray || m_tray_used.size() <= 0)
|
if (is_in_tray || m_tray_used.size() <= 0)
|
||||||
{
|
{
|
||||||
m_groups_sizer->Add(create_backup_group(wxString::Format("%s%d", _L("Group"), group_index + 1), group_info, group_material, status_list), 0, wxALL, FromDIP(10));
|
m_groups_sizer->Add(create_backup_group(wxString::Format("%s%d", _L("Group"), group_index + 1), group_info, group_material), 0, wxALL, FromDIP(10));
|
||||||
group_index++;
|
group_index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -356,7 +356,6 @@ public:
|
||||||
void update_mapping_result(std::vector<FilamentInfo> result);
|
void update_mapping_result(std::vector<FilamentInfo> result);
|
||||||
void paintEvent(wxPaintEvent& evt);
|
void paintEvent(wxPaintEvent& evt);
|
||||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||||
std::vector<bool> GetStatus(unsigned int status);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MachineObject* m_obj{ nullptr };
|
MachineObject* m_obj{ nullptr };
|
||||||
|
@ -373,7 +372,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void create();
|
void create();
|
||||||
AmsRMGroup* create_backup_group(wxString gname, std::map<std::string, wxColour> group_info, wxString material, std::vector<bool> status_list);
|
AmsRMGroup* create_backup_group(wxString gname, std::map<std::string, wxColour> group_info, wxString material);
|
||||||
|
|
||||||
// update to nozzle
|
// update to nozzle
|
||||||
void on_nozzle_selected(wxCommandEvent& event) { update_to_nozzle(event.GetInt()); };
|
void on_nozzle_selected(wxCommandEvent& event) { update_to_nozzle(event.GetInt()); };
|
||||||
|
|
|
@ -3973,7 +3973,7 @@ void GUI_App::load_gcode(wxWindow* parent, wxString& input_file) const
|
||||||
input_file = dialog.GetPath();
|
input_file = dialog.GetPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString GUI_App::transition_tridid(int trid_id)
|
wxString GUI_App::transition_tridid(int trid_id) const
|
||||||
{
|
{
|
||||||
wxString maping_dict[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
|
wxString maping_dict[] = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
|
||||||
|
|
||||||
|
@ -3989,6 +3989,19 @@ wxString GUI_App::transition_tridid(int trid_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxString GUI_App::transition_tridid(int trid_id, bool is_n3s) const
|
||||||
|
{
|
||||||
|
if (is_n3s)
|
||||||
|
{
|
||||||
|
const char base = 'A' + (trid_id - 128);
|
||||||
|
wxString prefix("HT-");
|
||||||
|
prefix.append(base);
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
return transition_tridid(trid_id);
|
||||||
|
}
|
||||||
|
|
||||||
//BBS
|
//BBS
|
||||||
void GUI_App::request_login(bool show_user_info)
|
void GUI_App::request_login(bool show_user_info)
|
||||||
{
|
{
|
||||||
|
|
|
@ -423,7 +423,8 @@ public:
|
||||||
void import_model(wxWindow *parent, wxArrayString& input_files) const;
|
void import_model(wxWindow *parent, wxArrayString& input_files) const;
|
||||||
void load_gcode(wxWindow* parent, wxString& input_file) const;
|
void load_gcode(wxWindow* parent, wxString& input_file) const;
|
||||||
|
|
||||||
wxString transition_tridid(int trid_id);
|
wxString transition_tridid(int trid_id) const;
|
||||||
|
wxString transition_tridid(int trid_id, bool is_n3s) const;
|
||||||
void ShowUserGuide();
|
void ShowUserGuide();
|
||||||
void ShowDownNetPluginDlg(bool post_login = false);
|
void ShowDownNetPluginDlg(bool post_login = false);
|
||||||
void ShowUserLogin(bool show = true);
|
void ShowUserLogin(bool show = true);
|
||||||
|
|
Loading…
Reference in New Issue