ENH: support dynamic size ams panel list in upgrade panel
jira: none adjust accessories display text Change-Id: I1de6872325b17bd5cfb11e750608d5f420055ee4
This commit is contained in:
parent
14103e6d6e
commit
6ba1518c24
|
@ -1338,12 +1338,11 @@ wxString MachineObject::get_upgrade_result_str(int err_code)
|
||||||
|
|
||||||
std::map<int, MachineObject::ModuleVersionInfo> MachineObject::get_ams_version()
|
std::map<int, MachineObject::ModuleVersionInfo> MachineObject::get_ams_version()
|
||||||
{
|
{
|
||||||
std::vector<std::string> ams_type = {"ams", "n3f", "n3s"};
|
std::vector<std::string> multi_tray_ams_type = {"ams", "n3f"};
|
||||||
|
|
||||||
std::map<int, ModuleVersionInfo> result;
|
std::map<int, ModuleVersionInfo> result;
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
std::string ams_id;
|
std::string ams_id;
|
||||||
for (auto type : ams_type )
|
for (auto type : multi_tray_ams_type)
|
||||||
{
|
{
|
||||||
ams_id = type + "/" + std::to_string(i);
|
ams_id = type + "/" + std::to_string(i);
|
||||||
auto it = module_vers.find(ams_id);
|
auto it = module_vers.find(ams_id);
|
||||||
|
@ -1352,6 +1351,17 @@ std::map<int, MachineObject::ModuleVersionInfo> 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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,17 @@ namespace GUI {
|
||||||
static const wxColour TEXT_NORMAL_CLR = wxColour(0, 174, 66);
|
static const wxColour TEXT_NORMAL_CLR = wxColour(0, 174, 66);
|
||||||
static const wxColour TEXT_FAILED_CLR = wxColour(255, 111, 0);
|
static const wxColour TEXT_FAILED_CLR = wxColour(255, 111, 0);
|
||||||
|
|
||||||
|
static const std::unordered_map<wxString, wxString> 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
|
enum FIRMWARE_STASUS
|
||||||
{
|
{
|
||||||
UNKOWN,
|
UNKOWN,
|
||||||
|
@ -136,16 +147,16 @@ MachineInfoPanel::MachineInfoPanel(wxWindow* parent, wxWindowID id, const wxPoin
|
||||||
m_ams_info_sizer->SetFlexibleDirection(wxHORIZONTAL);
|
m_ams_info_sizer->SetFlexibleDirection(wxHORIZONTAL);
|
||||||
m_ams_info_sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_ALL);
|
m_ams_info_sizer->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_ALL);
|
||||||
|
|
||||||
for (auto i = 0; i < 4; i++) {
|
//for (auto i = 0; i < 4; i++) {
|
||||||
auto amspanel = new AmsPanel(this, wxID_ANY);
|
// auto amspanel = new AmsPanel(this, wxID_ANY);
|
||||||
m_ams_info_sizer->Add(amspanel, 1, wxEXPAND, 5);
|
// m_ams_info_sizer->Add(amspanel, 1, wxEXPAND, 5);
|
||||||
amspanel->Hide();
|
// amspanel->Hide();
|
||||||
|
|
||||||
/*AmsPanelItem item = AmsPanelItem();
|
// /*AmsPanelItem item = AmsPanelItem();
|
||||||
item.id = i;
|
// item.id = i;
|
||||||
item.item = amspanel;*/
|
// item.item = amspanel;*/
|
||||||
m_amspanel_list.Add(amspanel);
|
// m_amspanel_list.Add(amspanel);
|
||||||
}
|
//}
|
||||||
|
|
||||||
m_ams_content_sizer->Add(m_ams_info_sizer, 0, wxEXPAND, 0);
|
m_ams_content_sizer->Add(m_ams_info_sizer, 0, wxEXPAND, 0);
|
||||||
m_ams_sizer->Add(m_ams_content_sizer, 1, 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);
|
show_ams(true);
|
||||||
std::map<int, MachineObject::ModuleVersionInfo> ver_list = obj->get_ams_version();
|
std::map<int, MachineObject::ModuleVersionInfo> 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++) {
|
for (auto i = 0; i < m_amspanel_list.GetCount(); i++) {
|
||||||
AmsPanel* amspanel = m_amspanel_list[i];
|
AmsPanel* amspanel = m_amspanel_list[i];
|
||||||
amspanel->Hide();
|
amspanel->Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
auto ams_index = 0;
|
auto ams_index = 0;
|
||||||
for (std::map<std::string, Ams*>::iterator iter = obj->amsList.begin(); iter != obj->amsList.end(); iter++) {
|
for (std::map<std::string, Ams*>::iterator iter = obj->amsList.begin(); iter != obj->amsList.end(); iter++) {
|
||||||
wxString ams_name;
|
wxString ams_name;
|
||||||
|
@ -694,6 +719,7 @@ void MachineInfoPanel::update_ams_ext(MachineObject *obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ams_id = std::stoi(iter->second->id);
|
auto ams_id = std::stoi(iter->second->id);
|
||||||
|
ams_id -= ams_id >= 128 ? 128 : 0;
|
||||||
|
|
||||||
size_t pos = it->second.name.find('/');
|
size_t pos = it->second.name.find('/');
|
||||||
wxString ams_device_name = "AMS-%s";
|
wxString ams_device_name = "AMS-%s";
|
||||||
|
@ -701,6 +727,8 @@ void MachineInfoPanel::update_ams_ext(MachineObject *obj)
|
||||||
if (pos != std::string::npos) {
|
if (pos != std::string::npos) {
|
||||||
wxString result = it->second.name.substr(0, pos);
|
wxString result = it->second.name.substr(0, pos);
|
||||||
result.MakeUpper();
|
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";
|
ams_device_name = result + "-%s";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue