ENH: use order mapping with U0 firmware
do not check iot environment Signed-off-by: stone.li <stone.li@bambulab.com> Change-Id: I500ec81fb9f8cdf706cac38b19bd52218ce52d1f Signed-off-by: stone.li <stone.li@bambulab.com>
This commit is contained in:
parent
2fd0238a47
commit
cfd62e4aeb
|
@ -993,6 +993,9 @@ void AppConfig::update_last_backup_dir(const std::string& dir)
|
|||
|
||||
std::string AppConfig::get_region()
|
||||
{
|
||||
#if BBL_RELEASE_TO_PUBLIC
|
||||
return this->get("region");
|
||||
#else
|
||||
std::string sel = get("iot_environment");
|
||||
std::string region;
|
||||
if (sel == ENV_DEV_HOST)
|
||||
|
@ -1004,12 +1007,15 @@ std::string AppConfig::get_region()
|
|||
if (region.empty())
|
||||
return this->get("region");
|
||||
return region;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string AppConfig::get_country_code()
|
||||
{
|
||||
std::string region = get_region();
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
if (is_engineering_region()) { return region; }
|
||||
#endif
|
||||
if (region == "CHN" || region == "China")
|
||||
return "CN";
|
||||
else if (region == "USA")
|
||||
|
|
|
@ -647,10 +647,10 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
for (int i = 0; i < filaments.size(); i++) {
|
||||
FilamentInfo info;
|
||||
info.id = filaments[i].id;
|
||||
info.tray_id = -1;
|
||||
info.tray_id = filaments[i].id;
|
||||
result.push_back(info);
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
char buffer[256];
|
||||
|
@ -791,14 +791,33 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
|||
|
||||
bool MachineObject::is_valid_mapping_result(std::vector<FilamentInfo>& result)
|
||||
{
|
||||
bool valid_ams_mapping_result = true;
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
if (result[i].tray_id == -1) {
|
||||
valid_ams_mapping_result = false;
|
||||
break;
|
||||
if (is_support_ams_mapping()) {
|
||||
bool valid_ams_mapping_result = true;
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
if (result[i].tray_id == -1) {
|
||||
valid_ams_mapping_result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return valid_ams_mapping_result;
|
||||
} else {
|
||||
bool is_valid = true;
|
||||
// invalid mapping result
|
||||
if (result.empty()) return false;
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
// invalid mapping result
|
||||
if (result[i].tray_id < 0)
|
||||
return false;
|
||||
else {
|
||||
int ams_id = result[i].tray_id / 4;
|
||||
if (amsList.find(std::to_string(ams_id)) == amsList.end()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return is_valid;
|
||||
}
|
||||
return valid_ams_mapping_result;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1105,8 +1105,22 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_)
|
|||
sync_ams_mapping_result(m_ams_mapping_result);
|
||||
BOOST_LOG_TRIVIAL(info) << "ams_mapping_array=" << ams_array;
|
||||
}
|
||||
return obj_->is_valid_mapping_result(m_ams_mapping_result);
|
||||
} else {
|
||||
// do not support ams mapping try to use order mapping
|
||||
bool is_valid = obj_->is_valid_mapping_result(m_ams_mapping_result);
|
||||
if (!is_valid) {
|
||||
// reset invalid result
|
||||
for (int i = 0; i < m_ams_mapping_result.size(); i++) {
|
||||
m_ams_mapping_result[i].tray_id = -1;
|
||||
m_ams_mapping_result[i].distance = 99999;
|
||||
}
|
||||
}
|
||||
sync_ams_mapping_result(m_ams_mapping_result);
|
||||
return is_valid;
|
||||
}
|
||||
return obj_->is_valid_mapping_result(m_ams_mapping_result);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str)
|
||||
|
@ -1292,13 +1306,13 @@ void SelectMachineDialog::show_status(PrintDialogStatus status)
|
|||
Enable_Send_Button(false);
|
||||
Enable_Refresh_Button(true);
|
||||
} else if (status == PrintDialogStatus::PrintStatusNeedUpgradingAms) {
|
||||
wxString msg_text = _L("Printer firmware does not support material = >ams slot mapping.");
|
||||
update_print_status_msg(msg_text, true, true);
|
||||
Enable_Send_Button(true);
|
||||
wxString msg_text = _L("The filament index exceeds the AMS's slot count and cannot send the print job.");
|
||||
update_print_status_msg(msg_text, true, false);
|
||||
Enable_Send_Button(false);
|
||||
Enable_Refresh_Button(true);
|
||||
} else if (status == PrintDialogStatus::PrintStatusAmsMappingSuccess){
|
||||
wxString msg_text = _L("Filaments to AMS slots mappings have been established. You can click a filament above to change its mapping AMS slot");
|
||||
update_print_status_msg(msg_text, true, false);
|
||||
update_print_status_msg(msg_text, false, false);
|
||||
Enable_Send_Button(true);
|
||||
Enable_Refresh_Button(true);
|
||||
} else if (status == PrintDialogStatus::PrintStatusAmsMappingInvalid) {
|
||||
|
@ -1326,7 +1340,7 @@ void SelectMachineDialog::show_status(PrintDialogStatus status)
|
|||
Enable_Send_Button(true);
|
||||
Enable_Refresh_Button(true);
|
||||
} else if (status == PrintDialogStatus::PrintStatusAmsMappingByOrder) {
|
||||
wxString msg_text = _L("Printer firmware does not support material = >ams slot mapping.");
|
||||
wxString msg_text = _L("The printer firmware only supports sequential mapping of filament => AMS slot.");
|
||||
update_print_status_msg(msg_text, false, false);
|
||||
Enable_Send_Button(true);
|
||||
Enable_Refresh_Button(true);
|
||||
|
@ -1768,7 +1782,11 @@ void SelectMachineDialog::update_show_status()
|
|||
}
|
||||
|
||||
if (!obj_->is_support_ams_mapping()) {
|
||||
show_status(PrintDialogStatus::PrintStatusNeedUpgradingAms);
|
||||
if (obj_->is_valid_mapping_result(m_ams_mapping_result)) {
|
||||
show_status(PrintDialogStatus::PrintStatusAmsMappingByOrder);
|
||||
} else {
|
||||
show_status(PrintDialogStatus::PrintStatusNeedUpgradingAms);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue