FIX: Prevent sending print when nozzle type dismatch

jira: none

Change-Id: I0278fd9bc22a9d9fd44b4d776f54de5fc07db6d0
This commit is contained in:
hang.xu 2024-09-05 17:06:01 +08:00 committed by lane.wei
parent c96102043b
commit d1aac2513e
2 changed files with 40 additions and 0 deletions

View File

@ -2176,6 +2176,32 @@ void SelectMachineDialog::auto_supply_with_ext(std::vector<AmsTray> slots) {
}
}
bool SelectMachineDialog::is_nozzle_type_match(NozzleData data) {
if (data.total_nozzle_count <= 1 || data.nozzles.size() <= 1 || !wxGetApp().preset_bundle)
return false;
//The default two extruders are left, right, but the order of the extruders on the machine is right, left.
std::vector<std::string>flow_type_of_machine;
for (auto it = data.nozzles.rbegin(); it != data.nozzles.rend(); it++) {
std::string str_flow = it->flow_type ? "Big Traffic" : "Normal";
flow_type_of_machine.push_back(str_flow);
}
//get the nozzle type of preset --> flow_types
const Preset& current_printer = wxGetApp().preset_bundle->printers.get_selected_preset();
const Preset* base_printer = wxGetApp().preset_bundle->printers.get_preset_base(current_printer);
auto flow_data = wxGetApp().app_config->get_nozzle_volume_types_from_config(base_printer->name);
std::vector<string> flow_types;
boost::split(flow_types, flow_data, boost::is_any_of(","));
if (flow_types.size() <= 1 || flow_types.size() != flow_type_of_machine.size()) return false;
//Only when all preset nozzle types and machine nozzle types are exactly the same, return true.
for (int i = 0; i < flow_types.size(); i++) {
if (flow_types[i] != flow_type_of_machine[i]) return false;
}
return true;
}
void SelectMachineDialog::prepare(int print_plate_idx)
{
m_print_plate_idx = print_plate_idx;
@ -2371,6 +2397,11 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector<wxSt
update_print_status_msg(msg_text, true, false);
Enable_Send_Button(false);
Enable_Refresh_Button(true);
} else if (status == PrintDialogStatus::PrintStatusNozzleMatchInvalid) {
wxString msg_text = _L("Please check whether the nozzle type of the device is the same as the preset nozzle type.");
update_print_status_msg(msg_text, true, false);
Enable_Send_Button(false);
Enable_Refresh_Button(true);
} else if (status == PrintDialogStatus::PrintStatusAmsMappingU0Invalid) {
wxString msg_text;
if (params.size() > 1)
@ -3843,6 +3874,13 @@ void SelectMachineDialog::update_show_status()
const auto& full_config = wxGetApp().preset_bundle->full_config();
size_t nozzle_nums = full_config.option<ConfigOptionFloatsNullable>("nozzle_diameter")->values.size();
//the nozzle type of preset and machine are different
if (nozzle_nums > 1 && !is_nozzle_type_match(obj_->m_nozzle_data)) {
show_status(PrintDialogStatus::PrintStatusNozzleMatchInvalid);
return;
}
if (!m_mapping_popup.m_supporting_mix_print && nozzle_nums == 1)
{
bool useAms = false;

View File

@ -315,6 +315,7 @@ enum PrintDialogStatus {
PrintStatusAmsMappingInvalid,
PrintStatusAmsMappingU0Invalid,
PrintStatusAmsMappingMixInvalid,
PrintStatusNozzleMatchInvalid,
PrintStatusAmsMappingValid,
PrintStatusAmsMappingByOrder,
PrintStatusRefreshingMachineList,
@ -542,6 +543,7 @@ public:
bool get_ams_mapping_result(std::string& mapping_array_str, std::string& mapping_array_str2, std::string& ams_mapping_info);
bool can_hybrid_mapping(NozzleData data);
void auto_supply_with_ext(std::vector<AmsTray> slots);
bool is_nozzle_type_match(NozzleData data);
PrintFromType get_print_type() {return m_print_type;};
wxString format_steel_name(std::string name);