ENH: support new auto cali method

jira: STUDIO-10798
Change-Id: I9490b050e93cd556e1d34b1e69e0508eaecec2cd
(cherry picked from commit 7a8b34525ef77d49b6549ecb290e2b1f89c69419)
This commit is contained in:
zhimin.zeng
2025-04-23 14:16:34 +08:00
committed by Noisyfox
parent 49befe4306
commit 337d987ec8
14 changed files with 705 additions and 20 deletions

View File

@@ -563,9 +563,14 @@ void PressureAdvanceWizard::on_cali_action(wxCommandEvent& evt)
show_step(m_curr_step->next);
}
else if (action == CaliPageActionType::CALI_ACTION_AUTO_CALI) {
if (curr_obj && curr_obj->is_support_new_auto_cali_method) {
set_cali_method(CalibrationMethod::CALI_METHOD_NEW_AUTO);
}
else {
set_cali_method(CalibrationMethod::CALI_METHOD_AUTO);
}
CalibrationFilamentMode fila_mode = get_cali_filament_mode(curr_obj, m_mode);
preset_step->page->set_cali_filament_mode(fila_mode);
set_cali_method(CalibrationMethod::CALI_METHOD_AUTO);
preset_step->page->on_device_connected(curr_obj);
show_step(m_curr_step->next);
}
@@ -756,7 +761,7 @@ void PressureAdvanceWizard::on_cali_start()
calib_info.extruder_id = preset_page->get_extruder_id(calib_info.ams_id);
calib_info.extruder_type = preset_page->get_extruder_type(calib_info.extruder_id);
calib_info.nozzle_volume_type = preset_page->get_nozzle_volume_type(calib_info.extruder_id);
calib_info.select_ams = "[" + std::to_string(selected_tray_id) + "]";
calib_info.select_ams = std::to_string(selected_tray_id);
Preset *preset = selected_filaments.begin()->second;
Preset * temp_filament_preset = new Preset(preset->type, preset->name + "_temp");
temp_filament_preset->config = preset->config;
@@ -769,6 +774,9 @@ void PressureAdvanceWizard::on_cali_start()
calib_info.print_prest = preset_page->get_print_preset();
calib_info.filament_prest = temp_filament_preset;
std::map<int, DynamicPrintConfig> filament_list = preset_page->get_filament_ams_list();
calib_info.filament_color = filament_list[selected_tray_id].opt_string("filament_colour", 0u);
wxArrayString values = preset_page->get_custom_range_values();
if (values.size() != 3) {
MessageDialog msg_dlg(nullptr, _L("The input value size must be 3."), wxEmptyString, wxICON_WARNING | wxOK);
@@ -815,6 +823,57 @@ void PressureAdvanceWizard::on_cali_start()
preset_page->on_cali_start_job();
}
} else if (m_cali_method == CalibrationMethod::CALI_METHOD_NEW_AUTO) {
if (selected_filaments.empty()) {
BOOST_LOG_TRIVIAL(warning) << "CaliPreset: selected filaments is empty";
return;
}
std::vector<CalibInfo> calib_infos;
for (auto &item : selected_filaments) {
int nozzle_temp = -1;
int bed_temp = -1;
float max_volumetric_speed = -1;
if (!get_preset_info(item.second->config, plate_type, nozzle_temp, bed_temp, max_volumetric_speed)) {
BOOST_LOG_TRIVIAL(error) << "CaliPreset: get preset info error";
continue;
}
int selected_tray_id = 0;
CalibInfo calib_info;
calib_info.dev_id = curr_obj->dev_id;
get_tray_ams_and_slot_id(curr_obj, item.first, calib_info.ams_id, calib_info.slot_id, selected_tray_id);
calib_info.index = preset_page->get_index_by_tray_id(selected_tray_id);
calib_info.extruder_id = preset_page->get_extruder_id(calib_info.ams_id);
calib_info.nozzle_diameter = preset_page->get_nozzle_diameter(calib_info.extruder_id);
calib_info.extruder_type = preset_page->get_extruder_type(calib_info.extruder_id);
calib_info.nozzle_volume_type = preset_page->get_nozzle_volume_type(calib_info.extruder_id);
calib_info.select_ams = std::to_string(selected_tray_id);
Preset *preset = item.second;
Preset *temp_filament_preset = new Preset(preset->type, preset->name + "_temp");
temp_filament_preset->config = preset->config;
calib_info.bed_type = plate_type;
calib_info.process_bar = preset_page->get_sending_progress_bar();
calib_info.printer_prest = preset_page->get_printer_preset(curr_obj, preset_page->get_nozzle_diameter(calib_info.extruder_id));
calib_info.print_prest = preset_page->get_print_preset();
calib_info.filament_prest = temp_filament_preset;
std::map<int, DynamicPrintConfig> filament_list = preset_page->get_filament_ams_list();
calib_info.filament_color = filament_list[selected_tray_id].opt_string("filament_colour", 0u);
calib_info.params.mode = CalibMode::Calib_Auto_PA_Line;
calib_infos.emplace_back(calib_info);
}
if (!CalibUtils::calib_generic_auto_pa_cali(calib_infos, wx_err_string)) {
if (!wx_err_string.empty()) {
MessageDialog msg_dlg(nullptr, wx_err_string, wxEmptyString, wxICON_WARNING | wxOK);
msg_dlg.ShowModal();
}
return;
}
preset_page->on_cali_start_job();
} else {
assert(false);
BOOST_LOG_TRIVIAL(error) << "CaliPreset: unsupported printer type or cali method";
@@ -902,7 +961,7 @@ void PressureAdvanceWizard::on_cali_save()
}
if (curr_obj->get_printer_series() == PrinterSeries::SERIES_X1) {
if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) {
if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO || m_cali_method == CalibrationMethod::CALI_METHOD_NEW_AUTO) {
std::vector<PACalibResult> new_pa_cali_results;
auto save_page = static_cast<CalibrationPASavePage*>(save_step->page);
if (!save_page->get_auto_result(new_pa_cali_results)) {
@@ -1228,7 +1287,7 @@ void FlowRateWizard::on_cali_start(CaliPresetStage stage, float cali_value, Flow
if (!selected_filaments.empty()) {
int selected_tray_id = 0;
get_tray_ams_and_slot_id(curr_obj, selected_filaments.begin()->first, calib_info.ams_id, calib_info.slot_id, selected_tray_id);
calib_info.select_ams = "[" + std::to_string(selected_tray_id) + "]";
calib_info.select_ams = std::to_string(selected_tray_id);
calib_info.extruder_id = preset_page->get_extruder_id(calib_info.ams_id);
calib_info.extruder_type = preset_page->get_extruder_type(calib_info.extruder_id);
calib_info.nozzle_volume_type = preset_page->get_nozzle_volume_type(calib_info.extruder_id);
@@ -1265,6 +1324,9 @@ void FlowRateWizard::on_cali_start(CaliPresetStage stage, float cali_value, Flow
}
calib_info.filament_prest = temp_filament_preset;
std::map<int, DynamicPrintConfig> filament_list = preset_page->get_filament_ams_list();
calib_info.filament_color = filament_list[selected_tray_id].opt_string("filament_colour", 0u);
if (cali_stage > 0) {
if (!CalibUtils::calib_flowrate(cali_stage, calib_info, wx_err_string)) {
if (!wx_err_string.empty()) {
@@ -1464,7 +1526,7 @@ std::map<std::string, ConfigIndexValue> FlowRateWizard::generate_index_key_value
void FlowRateWizard::set_cali_method(CalibrationMethod method)
{
m_cali_method = method;
if (method == CalibrationMethod::CALI_METHOD_AUTO) {
if (method == CalibrationMethod::CALI_METHOD_AUTO || method == CalibrationMethod::CALI_METHOD_NEW_AUTO) {
m_page_steps.clear();
m_page_steps.push_back(start_step);
m_page_steps.push_back(preset_step);
@@ -1639,11 +1701,13 @@ void MaxVolumetricSpeedWizard::on_cali_start()
if (!selected_filaments.empty()) {
int selected_tray_id = 0;
get_tray_ams_and_slot_id(curr_obj, selected_filaments.begin()->first, calib_info.ams_id, calib_info.slot_id, selected_tray_id);
calib_info.select_ams = "[" + std::to_string(selected_tray_id) + "]";
calib_info.select_ams = std::to_string(selected_tray_id);
calib_info.extruder_id = preset_page->get_extruder_id(calib_info.ams_id);
calib_info.extruder_type = preset_page->get_extruder_type(calib_info.extruder_id);
calib_info.nozzle_volume_type = preset_page->get_nozzle_volume_type(calib_info.extruder_id);
calib_info.filament_prest = selected_filaments.begin()->second;
std::map<int, DynamicPrintConfig> filament_list = preset_page->get_filament_ams_list();
calib_info.filament_color = filament_list[selected_tray_id].opt_string("filament_colour", 0u);
}
calib_info.bed_type = plate_type;