mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 15:07:31 -06:00
ENH: refine ams mapping for U0 firmware
display index of filament Change-Id: I8a97a71cd334a1536ae7bfd4a5673e9757b2e662 Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
2a84e68852
commit
2eb9aea56a
6 changed files with 93 additions and 11 deletions
|
@ -3615,7 +3615,7 @@ std::string DynamicPrintConfig::get_filament_type(int id)
|
||||||
return "Support G";
|
return "Support G";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return filament_type->get_at(id) + "-Support";
|
return filament_type->get_at(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -3624,7 +3624,7 @@ std::string DynamicPrintConfig::get_filament_type(int id)
|
||||||
else if (filament_type->get_at(id) == "PA")
|
else if (filament_type->get_at(id) == "PA")
|
||||||
return "Support G";
|
return "Support G";
|
||||||
else
|
else
|
||||||
return filament_type->get_at(id) + "-Support";
|
return filament_type->get_at(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -27,6 +27,12 @@ enum MachineBedType {
|
||||||
BED_TYPE_COUNT,
|
BED_TYPE_COUNT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum MappingResult {
|
||||||
|
MAPPING_RESULT_DEFAULT = 0,
|
||||||
|
MAPPING_RESULT_TYPE_MISMATCH = 1,
|
||||||
|
MAPPING_RESULT_EXCEED = 2
|
||||||
|
};
|
||||||
|
|
||||||
struct FilamentInfo
|
struct FilamentInfo
|
||||||
{
|
{
|
||||||
int id; // filament id = extruder id, start with 0.
|
int id; // filament id = extruder id, start with 0.
|
||||||
|
@ -36,6 +42,7 @@ struct FilamentInfo
|
||||||
float used_g;
|
float used_g;
|
||||||
int tray_id; // start with 0
|
int tray_id; // start with 0
|
||||||
float distance;
|
float distance;
|
||||||
|
int mapping_result = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BBLSliceInfo {
|
class BBLSliceInfo {
|
||||||
|
|
|
@ -148,6 +148,16 @@ bool AmsTray::is_tray_info_ready()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AmsTray::is_unset_third_filament()
|
||||||
|
{
|
||||||
|
if (this->is_bbl)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (color.empty() || type.empty())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool HMSItem::parse_hms_info(unsigned attr, unsigned code)
|
bool HMSItem::parse_hms_info(unsigned attr, unsigned code)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
@ -652,14 +662,23 @@ int MachineObject::ams_filament_mapping(std::vector<FilamentInfo> filaments, std
|
||||||
auto ams_it = amsList.find(std::to_string(ams_id));
|
auto ams_it = amsList.find(std::to_string(ams_id));
|
||||||
if (ams_it == amsList.end()) {
|
if (ams_it == amsList.end()) {
|
||||||
info.tray_id = -1;
|
info.tray_id = -1;
|
||||||
|
info.mapping_result = (int)MappingResult::MAPPING_RESULT_EXCEED;
|
||||||
} else {
|
} else {
|
||||||
info.tray_id = filaments[i].id;
|
info.tray_id = filaments[i].id;
|
||||||
|
|
||||||
int tray_id = filaments[i].id % 4;
|
int tray_id = filaments[i].id % 4;
|
||||||
auto tray_it = ams_it->second->trayList.find(std::to_string(tray_id));
|
auto tray_it = ams_it->second->trayList.find(std::to_string(tray_id));
|
||||||
if (tray_it != ams_it->second->trayList.end()) {
|
if (tray_it != ams_it->second->trayList.end()) {
|
||||||
info.color = tray_it->second->color;
|
if (!tray_it->second->is_exists || tray_it->second->is_unset_third_filament()) {
|
||||||
info.type = tray_it->second->type;
|
;
|
||||||
|
} else {
|
||||||
|
if (filaments[i].type == tray_it->second->type) {
|
||||||
|
info.color = tray_it->second->color;
|
||||||
|
info.type = tray_it->second->type;
|
||||||
|
} else {
|
||||||
|
info.tray_id = -1;
|
||||||
|
info.mapping_result = (int)MappingResult::MAPPING_RESULT_TYPE_MISMATCH;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.push_back(info);
|
result.push_back(info);
|
||||||
|
@ -835,12 +854,32 @@ bool MachineObject::is_valid_mapping_result(std::vector<FilamentInfo>& result)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MachineObject::is_mapping_exceed_filament(std::vector<FilamentInfo> & result, int &exceed_index)
|
||||||
|
{
|
||||||
|
bool is_exceed = false;
|
||||||
|
for (int i = 0; i < result.size(); i++) {
|
||||||
|
int ams_id = result[i].tray_id / 4;
|
||||||
|
if (amsList.find(std::to_string(ams_id)) == amsList.end()) {
|
||||||
|
exceed_index = result[i].tray_id;
|
||||||
|
result[i].tray_id = -1;
|
||||||
|
is_exceed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (result[i].mapping_result == MappingResult::MAPPING_RESULT_EXCEED) {
|
||||||
|
exceed_index = result[i].id;
|
||||||
|
is_exceed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return is_exceed;
|
||||||
|
}
|
||||||
|
|
||||||
void MachineObject::reset_mapping_result(std::vector<FilamentInfo>& result)
|
void MachineObject::reset_mapping_result(std::vector<FilamentInfo>& result)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < result.size(); i++) {
|
for (int i = 0; i < result.size(); i++) {
|
||||||
result[i].tray_id = -1;
|
result[i].tray_id = -1;
|
||||||
result[i].distance = 99999;
|
result[i].distance = 99999;
|
||||||
|
result[i].mapping_result = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,6 +166,7 @@ public:
|
||||||
wxColour get_color();
|
wxColour get_color();
|
||||||
|
|
||||||
bool is_tray_info_ready();
|
bool is_tray_info_ready();
|
||||||
|
bool is_unset_third_filament();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -364,6 +365,8 @@ public:
|
||||||
|
|
||||||
int ams_filament_mapping(std::vector<FilamentInfo> filaments, std::vector<FilamentInfo> &result, std::vector<int> exclude_id = std::vector<int>());
|
int ams_filament_mapping(std::vector<FilamentInfo> filaments, std::vector<FilamentInfo> &result, std::vector<int> exclude_id = std::vector<int>());
|
||||||
bool is_valid_mapping_result(std::vector<FilamentInfo>& result);
|
bool is_valid_mapping_result(std::vector<FilamentInfo>& result);
|
||||||
|
// exceed index start with 0
|
||||||
|
bool is_mapping_exceed_filament(std::vector<FilamentInfo>& result, int &exceed_index);
|
||||||
void reset_mapping_result(std::vector<FilamentInfo>& result);
|
void reset_mapping_result(std::vector<FilamentInfo>& result);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1263,7 +1263,7 @@ void SelectMachineDialog::update_print_status_msg(wxString msg, bool is_warning,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectMachineDialog::show_status(PrintDialogStatus status)
|
void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector<wxString> params)
|
||||||
{
|
{
|
||||||
if (m_print_status != status)
|
if (m_print_status != status)
|
||||||
BOOST_LOG_TRIVIAL(info) << "select_machine_dialog: show_status = " << status;
|
BOOST_LOG_TRIVIAL(info) << "select_machine_dialog: show_status = " << status;
|
||||||
|
@ -1331,7 +1331,11 @@ 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("The filament index exceeds the AMS's slot count and cannot send the print job.");
|
wxString msg_text;
|
||||||
|
if (params.size() > 0)
|
||||||
|
msg_text = wxString::Format(_L("Filament index %s exceeds the number of AMS slots. Please update the printer firmware to support AMS slot assignment."), params[0]);
|
||||||
|
else
|
||||||
|
msg_text = _L("Filament index exceeds the number of AMS slots. Please update the printer firmware to support AMS slot assignment.");
|
||||||
update_print_status_msg(msg_text, true, false);
|
update_print_status_msg(msg_text, true, false);
|
||||||
Enable_Send_Button(false);
|
Enable_Send_Button(false);
|
||||||
Enable_Refresh_Button(true);
|
Enable_Refresh_Button(true);
|
||||||
|
@ -1345,6 +1349,15 @@ void SelectMachineDialog::show_status(PrintDialogStatus status)
|
||||||
update_print_status_msg(msg_text, true, false);
|
update_print_status_msg(msg_text, true, false);
|
||||||
Enable_Send_Button(false);
|
Enable_Send_Button(false);
|
||||||
Enable_Refresh_Button(true);
|
Enable_Refresh_Button(true);
|
||||||
|
} else if (status == PrintDialogStatus::PrintStatusAmsMappingU0Invalid) {
|
||||||
|
wxString msg_text;
|
||||||
|
if (params.size() > 1)
|
||||||
|
msg_text = wxString::Format(_L("Filament index %s does not match the filament in AMS slot %s. Please update the printer firmware to support AMS slot assignment."), params[0], params[1]);
|
||||||
|
else
|
||||||
|
msg_text = _L("Filament index does not match the filament in AMS slot. Please update the printer firmware to support AMS slot assignment.");
|
||||||
|
update_print_status_msg(msg_text, true, false);
|
||||||
|
Enable_Send_Button(false);
|
||||||
|
Enable_Refresh_Button(true);
|
||||||
} else if (status == PrintDialogStatus::PrintStatusAmsMappingValid) {
|
} else if (status == PrintDialogStatus::PrintStatusAmsMappingValid) {
|
||||||
update_print_status_msg(wxEmptyString, false, false);
|
update_print_status_msg(wxEmptyString, false, false);
|
||||||
Enable_Send_Button(true);
|
Enable_Send_Button(true);
|
||||||
|
@ -1818,10 +1831,29 @@ 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)) {
|
int exceed_index = -1;
|
||||||
show_status(PrintDialogStatus::PrintStatusAmsMappingByOrder);
|
if (obj_->is_mapping_exceed_filament(m_ams_mapping_result, exceed_index)) {
|
||||||
|
std::vector<wxString> params;
|
||||||
|
params.push_back(wxString::Format("%02d", exceed_index+1));
|
||||||
|
show_status(PrintDialogStatus::PrintStatusNeedUpgradingAms, params);
|
||||||
} else {
|
} else {
|
||||||
show_status(PrintDialogStatus::PrintStatusNeedUpgradingAms);
|
if (obj_->is_valid_mapping_result(m_ams_mapping_result)) {
|
||||||
|
show_status(PrintDialogStatus::PrintStatusAmsMappingByOrder);
|
||||||
|
} else {
|
||||||
|
int mismatch_index = -1;
|
||||||
|
for (int i = 0; i < m_ams_mapping_result.size(); i++) {
|
||||||
|
if (m_ams_mapping_result[i].mapping_result == MappingResult::MAPPING_RESULT_TYPE_MISMATCH) {
|
||||||
|
mismatch_index = m_ams_mapping_result[i].id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::vector<wxString> params;
|
||||||
|
if (mismatch_index >= 0) {
|
||||||
|
params.push_back(wxString::Format("%02d", mismatch_index+1));
|
||||||
|
params.push_back(wxString::Format("%02d", mismatch_index+1));
|
||||||
|
}
|
||||||
|
show_status(PrintDialogStatus::PrintStatusAmsMappingU0Invalid, params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,6 +237,7 @@ enum PrintDialogStatus {
|
||||||
PrintStatusInPrinting,
|
PrintStatusInPrinting,
|
||||||
PrintStatusAmsMappingSuccess,
|
PrintStatusAmsMappingSuccess,
|
||||||
PrintStatusAmsMappingInvalid,
|
PrintStatusAmsMappingInvalid,
|
||||||
|
PrintStatusAmsMappingU0Invalid,
|
||||||
PrintStatusAmsMappingValid,
|
PrintStatusAmsMappingValid,
|
||||||
PrintStatusAmsMappingByOrder,
|
PrintStatusAmsMappingByOrder,
|
||||||
PrintStatusRefreshingMachineList,
|
PrintStatusRefreshingMachineList,
|
||||||
|
@ -328,7 +329,7 @@ public:
|
||||||
bool do_ams_mapping(MachineObject *obj_);
|
bool do_ams_mapping(MachineObject *obj_);
|
||||||
bool get_ams_mapping_result(std::string &mapping_array_str);
|
bool get_ams_mapping_result(std::string &mapping_array_str);
|
||||||
void prepare(int print_plate_idx);
|
void prepare(int print_plate_idx);
|
||||||
void show_status(PrintDialogStatus status);
|
void show_status(PrintDialogStatus status, std::vector<wxString> params = std::vector<wxString>());
|
||||||
PrintDialogStatus get_status() { return m_print_status; }
|
PrintDialogStatus get_status() { return m_print_status; }
|
||||||
|
|
||||||
bool Show(bool show);
|
bool Show(bool show);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue