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()
|
std::string AppConfig::get_region()
|
||||||
{
|
{
|
||||||
|
#if BBL_RELEASE_TO_PUBLIC
|
||||||
|
return this->get("region");
|
||||||
|
#else
|
||||||
std::string sel = get("iot_environment");
|
std::string sel = get("iot_environment");
|
||||||
std::string region;
|
std::string region;
|
||||||
if (sel == ENV_DEV_HOST)
|
if (sel == ENV_DEV_HOST)
|
||||||
|
@ -1004,12 +1007,15 @@ std::string AppConfig::get_region()
|
||||||
if (region.empty())
|
if (region.empty())
|
||||||
return this->get("region");
|
return this->get("region");
|
||||||
return region;
|
return region;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AppConfig::get_country_code()
|
std::string AppConfig::get_country_code()
|
||||||
{
|
{
|
||||||
std::string region = get_region();
|
std::string region = get_region();
|
||||||
|
#if !BBL_RELEASE_TO_PUBLIC
|
||||||
if (is_engineering_region()) { return region; }
|
if (is_engineering_region()) { return region; }
|
||||||
|
#endif
|
||||||
if (region == "CHN" || region == "China")
|
if (region == "CHN" || region == "China")
|
||||||
return "CN";
|
return "CN";
|
||||||
else if (region == "USA")
|
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++) {
|
for (int i = 0; i < filaments.size(); i++) {
|
||||||
FilamentInfo info;
|
FilamentInfo info;
|
||||||
info.id = filaments[i].id;
|
info.id = filaments[i].id;
|
||||||
info.tray_id = -1;
|
info.tray_id = filaments[i].id;
|
||||||
result.push_back(info);
|
result.push_back(info);
|
||||||
}
|
}
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
@ -791,6 +791,7 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
||||||
|
|
||||||
bool MachineObject::is_valid_mapping_result(std::vector<FilamentInfo>& result)
|
bool MachineObject::is_valid_mapping_result(std::vector<FilamentInfo>& result)
|
||||||
{
|
{
|
||||||
|
if (is_support_ams_mapping()) {
|
||||||
bool valid_ams_mapping_result = true;
|
bool valid_ams_mapping_result = true;
|
||||||
for (int i = 0; i < result.size(); i++) {
|
for (int i = 0; i < result.size(); i++) {
|
||||||
if (result[i].tray_id == -1) {
|
if (result[i].tray_id == -1) {
|
||||||
|
@ -799,6 +800,24 @@ bool MachineObject::is_valid_mapping_result(std::vector<FilamentInfo>& result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return valid_ams_mapping_result;
|
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 true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1105,8 +1105,22 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_)
|
||||||
sync_ams_mapping_result(m_ams_mapping_result);
|
sync_ams_mapping_result(m_ams_mapping_result);
|
||||||
BOOST_LOG_TRIVIAL(info) << "ams_mapping_array=" << ams_array;
|
BOOST_LOG_TRIVIAL(info) << "ams_mapping_array=" << ams_array;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return obj_->is_valid_mapping_result(m_ams_mapping_result);
|
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 true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SelectMachineDialog::get_ams_mapping_result(std::string &mapping_array_str)
|
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_Send_Button(false);
|
||||||
Enable_Refresh_Button(true);
|
Enable_Refresh_Button(true);
|
||||||
} else if (status == PrintDialogStatus::PrintStatusNeedUpgradingAms) {
|
} else if (status == PrintDialogStatus::PrintStatusNeedUpgradingAms) {
|
||||||
wxString msg_text = _L("Printer firmware does not support material = >ams slot mapping.");
|
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, true);
|
update_print_status_msg(msg_text, true, false);
|
||||||
Enable_Send_Button(true);
|
Enable_Send_Button(false);
|
||||||
Enable_Refresh_Button(true);
|
Enable_Refresh_Button(true);
|
||||||
} else if (status == PrintDialogStatus::PrintStatusAmsMappingSuccess){
|
} 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");
|
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_Send_Button(true);
|
||||||
Enable_Refresh_Button(true);
|
Enable_Refresh_Button(true);
|
||||||
} else if (status == PrintDialogStatus::PrintStatusAmsMappingInvalid) {
|
} else if (status == PrintDialogStatus::PrintStatusAmsMappingInvalid) {
|
||||||
|
@ -1326,7 +1340,7 @@ void SelectMachineDialog::show_status(PrintDialogStatus status)
|
||||||
Enable_Send_Button(true);
|
Enable_Send_Button(true);
|
||||||
Enable_Refresh_Button(true);
|
Enable_Refresh_Button(true);
|
||||||
} else if (status == PrintDialogStatus::PrintStatusAmsMappingByOrder) {
|
} 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);
|
update_print_status_msg(msg_text, false, false);
|
||||||
Enable_Send_Button(true);
|
Enable_Send_Button(true);
|
||||||
Enable_Refresh_Button(true);
|
Enable_Refresh_Button(true);
|
||||||
|
@ -1768,7 +1782,11 @@ void SelectMachineDialog::update_show_status()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!obj_->is_support_ams_mapping()) {
|
if (!obj_->is_support_ams_mapping()) {
|
||||||
|
if (obj_->is_valid_mapping_result(m_ams_mapping_result)) {
|
||||||
|
show_status(PrintDialogStatus::PrintStatusAmsMappingByOrder);
|
||||||
|
} else {
|
||||||
show_status(PrintDialogStatus::PrintStatusNeedUpgradingAms);
|
show_status(PrintDialogStatus::PrintStatusNeedUpgradingAms);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue