FIX: Prompt user when mix ams and vtslot in an extruder

jira: none
Change-Id: I9a1d4936056fc872c75bf0454e4ca89665ece2f8
This commit is contained in:
zhimin.zeng 2024-09-30 11:41:30 +08:00 committed by lane.wei
parent d715353fa6
commit 65c00e00fe
4 changed files with 55 additions and 7 deletions

View File

@ -1147,6 +1147,23 @@ bool MachineObject::need_SD_card() const
return !is_multi_extruders();
}
int MachineObject::get_extruder_id_by_ams_id(const std::string &ams_id)
{
if (ams_id.empty())
return 0;
auto it = amsList.find(ams_id);
if (it != amsList.end())
return it->second->nozzle;
else if (stoi(ams_id) == VIRTUAL_TRAY_MAIN_ID)
return 0;
else if (stoi(ams_id) == VIRTUAL_TRAY_DEPUTY_ID)
return 1;
assert(false);
return 0;
}
bool MachineObject::is_bbl_filament(std::string tag_uid)
{
if (tag_uid.empty())

View File

@ -588,6 +588,7 @@ public:
bool is_main_extruder_on_left() const;
bool is_multi_extruders() const;
bool need_SD_card() const;
int get_extruder_id_by_ams_id(const std::string &ams_id);
/*online*/
bool online_rfid;

View File

@ -2538,6 +2538,12 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector<wxSt
Enable_Send_Button(true);
Enable_Refresh_Button(true);
}
else if (status == PrintStatusMixAmsAndVtSlotWarning) {
wxString msg_text = _L("You selected external and AMS filament at the same time in an extruder, you will need manually change external filament.");
update_print_status_msg(msg_text, true, false);
Enable_Send_Button(true);
Enable_Refresh_Button(true);
}
// m_panel_warn m_simplebook
if (status == PrintDialogStatus::PrintStatusSending) {
@ -3921,6 +3927,29 @@ void SelectMachineDialog::update_show_status()
}
}
// check ams and vt_slot mix use status
{
struct ExtruderStatus
{
bool has_ams{false};
bool has_vt_slot{false};
};
std::vector<ExtruderStatus> extruder_status(nozzle_nums);
for (const FilamentInfo &item : m_ams_mapping_result) {
int extruder_id = obj_->get_extruder_id_by_ams_id(item.ams_id);
if (DeviceManager::is_virtual_slot(stoi(item.ams_id)))
extruder_status[extruder_id].has_vt_slot = true;
else
extruder_status[extruder_id].has_ams = true;
}
for (auto extruder : extruder_status) {
if (extruder.has_ams && extruder.has_vt_slot) {
show_status(PrintDialogStatus::PrintStatusMixAmsAndVtSlotWarning);
return;
}
}
}
if (!obj_->is_support_ams_mapping()) {
int exceed_index = -1;
if (obj_->is_mapping_exceed_filament(m_ams_mapping_result, exceed_index)) {

View File

@ -331,7 +331,8 @@ enum PrintDialogStatus {
PrintStatusNotSupportedPrintAll,
PrintStatusBlankPlate,
PrintStatusUnsupportedPrinter,
PrintStatusTimelapseWarning
PrintStatusTimelapseWarning,
PrintStatusMixAmsAndVtSlotWarning
};