ENH: support new auto cali method

jira: STUDIO-10798
Change-Id: I9490b050e93cd556e1d34b1e69e0508eaecec2cd
(cherry picked from commit 7a8b34525ef77d49b6549ecb290e2b1f89c69419)
This commit is contained in:
zhimin.zeng authored and Noisyfox committed 2025-10-03 23:08:47 +08:00
1 parent 49befe4306
commit 337d987ec8
14 files changed
+705 -20

No files matched your search

+70 -6
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;
+4 -4
View File
@@ -107,7 +107,7 @@ void CalibrationCaliPage::set_cali_img()
CalibMode obj_cali_mode = get_obj_calibration_mode(curr_obj, method, cali_stage);
set_pa_cali_image(cali_stage);
}
else if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) {
else if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO || m_cali_method == CalibrationMethod::CALI_METHOD_NEW_AUTO) {
if (curr_obj) {
if (curr_obj->is_multi_extruders()) {
if (m_cur_extruder_id == 0) {
@@ -213,8 +213,8 @@ void CalibrationCaliPage::update(MachineObject* obj)
return;
}
if (m_cali_mode == CalibMode::Calib_PA_Line) {
if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) {
if (m_cali_mode == CalibMode::Calib_PA_Line || m_cali_mode == CalibMode::Calib_Auto_PA_Line) {
if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO || m_cali_method == CalibrationMethod::CALI_METHOD_NEW_AUTO) {
if (get_obj_calibration_mode(obj) == m_cali_mode) {
if (obj->is_printing_finished()) {
if (obj->print_status == "FINISH") {
@@ -479,7 +479,7 @@ void CalibrationCaliPage::set_cali_method(CalibrationMethod method)
manual_steps.Add(_L("Calibration2"));
manual_steps.Add(_L("Record Factor"));
if (method == CalibrationMethod::CALI_METHOD_AUTO) {
if (method == CalibrationMethod::CALI_METHOD_AUTO || method == CalibrationMethod::CALI_METHOD_NEW_AUTO) {
m_step_panel->set_steps_string(auto_steps);
m_step_panel->set_steps(1);
}
+7 -3
View File
@@ -137,7 +137,10 @@ CalibMode get_obj_calibration_mode(const MachineObject* obj, CalibrationMethod&
}
CalibMode cali_mode = CalibUtils::get_calib_mode_by_name(obj->subtask_name, cali_stage);
if (cali_mode != CalibMode::Calib_None) {
if (cali_mode == CalibMode::Calib_PA_Line && cali_stage == 2) {
method = CalibrationMethod::CALI_METHOD_NEW_AUTO;
}
else if (cali_mode != CalibMode::Calib_None) {
method = CalibrationMethod::CALI_METHOD_MANUAL;
}
return cali_mode;
@@ -264,8 +267,9 @@ void CaliPageButton::msw_rescale()
}
FilamentComboBox::FilamentComboBox(wxWindow* parent, const wxPoint& pos, const wxSize& size)
FilamentComboBox::FilamentComboBox(wxWindow* parent, int index, const wxPoint& pos, const wxSize& size)
: wxPanel(parent, wxID_ANY, pos, size, wxTAB_TRAVERSAL)
, m_index(index)
{
SetBackgroundColour(*wxWHITE);
@@ -571,7 +575,7 @@ void CaliPageStepGuide::set_steps_string(wxArrayString steps)
CaliPagePicture::CaliPagePicture(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: wxPanel(parent, id, pos, size, style)
{
SetBackgroundColour(wxColour(0xCECECE));
SetBackgroundColour(wxColour("#CECECE"));
auto top_sizer = new wxBoxSizer(wxHORIZONTAL);
top_sizer->AddStretchSpacer();
m_img = new wxStaticBitmap(this, wxID_ANY, wxNullBitmap);
+4 -1
View File
@@ -49,6 +49,7 @@ enum CalibrationFilamentMode {
enum CalibrationMethod {
CALI_METHOD_MANUAL = 0,
CALI_METHOD_AUTO,
CALI_METHOD_NEW_AUTO,
CALI_METHOD_NONE,
};
@@ -78,13 +79,14 @@ enum class CaliPageType {
class FilamentComboBox : public wxPanel
{
public:
FilamentComboBox(wxWindow* parent, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
FilamentComboBox(wxWindow* parent, int index, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
~FilamentComboBox() {};
void set_select_mode(CalibrationFilamentMode mode);
CalibrationFilamentMode get_select_mode() { return m_mode; }
void load_tray_from_ams(int id, DynamicPrintConfig& tray);
void update_from_preset();
int get_index() { return m_index; }
int get_tray_id() { return m_tray_id; }
bool is_bbl_filament() { return m_is_bbl_filamnet; }
std::string get_tray_name() { return m_tray_name; }
@@ -102,6 +104,7 @@ public:
void HidePanel();
protected:
int m_index{0};
int m_tray_id { -1 };
std::string m_tray_name;
bool m_is_bbl_filamnet{ false };
+15 -4
View File
@@ -889,7 +889,7 @@ void CalibrationPresetPage::create_filament_list_panel(wxWindow* parent)
wxRadioButton* radio_btn = new wxRadioButton(m_filament_list_panel, wxID_ANY, "");
CheckBox* check_box = new CheckBox(m_filament_list_panel);
check_box->SetBackgroundColour(*wxWHITE);
FilamentComboBox* fcb = new FilamentComboBox(m_filament_list_panel);
FilamentComboBox* fcb = new FilamentComboBox(m_filament_list_panel, i);
fcb->SetRadioBox(radio_btn);
fcb->SetCheckBox(check_box);
fcb->set_select_mode(CalibrationFilamentMode::CALI_MODEL_SINGLE);
@@ -1022,7 +1022,7 @@ void CalibrationPresetPage::create_multi_extruder_filament_list_panel(wxWindow *
wxRadioButton *radio_btn = new wxRadioButton(m_multi_exutrder_filament_list_panel, wxID_ANY, "");
CheckBox * check_box = new CheckBox(m_multi_exutrder_filament_list_panel);
check_box->SetBackgroundColour(*wxWHITE);
FilamentComboBox *fcb = new FilamentComboBox(m_multi_exutrder_filament_list_panel);
FilamentComboBox *fcb = new FilamentComboBox(m_multi_exutrder_filament_list_panel, i + 4);
fcb->SetRadioBox(radio_btn);
fcb->SetCheckBox(check_box);
fcb->set_select_mode(CalibrationFilamentMode::CALI_MODEL_SINGLE);
@@ -1066,7 +1066,7 @@ void CalibrationPresetPage::create_multi_extruder_filament_list_panel(wxWindow *
wxRadioButton *radio_btn = new wxRadioButton(m_multi_exutrder_filament_list_panel, wxID_ANY, "");
CheckBox * check_box = new CheckBox(m_multi_exutrder_filament_list_panel);
check_box->SetBackgroundColour(*wxWHITE);
FilamentComboBox *fcb = new FilamentComboBox(m_multi_exutrder_filament_list_panel);
FilamentComboBox *fcb = new FilamentComboBox(m_multi_exutrder_filament_list_panel, i);
fcb->SetRadioBox(radio_btn);
fcb->SetCheckBox(check_box);
fcb->set_select_mode(CalibrationFilamentMode::CALI_MODEL_SINGLE);
@@ -1448,7 +1448,7 @@ bool CalibrationPresetPage::is_filament_in_blacklist(int tray_id, Preset* preset
}
}
if (devPrinterUtil::IsVirtualSlot(ams_id)) {
if (m_cali_mode == CalibMode::Calib_PA_Line && m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) {
if (m_cali_mode == CalibMode::Calib_PA_Line && (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO || m_cali_method == CalibrationMethod::CALI_METHOD_NEW_AUTO)) {
std::string filamnt_type;
preset->get_filament_type(filamnt_type);
if (filamnt_type == "TPU") {
@@ -2362,6 +2362,17 @@ void CalibrationPresetPage::select_default_compatible_filament()
check_filament_compatible();
}
int CalibrationPresetPage::get_index_by_tray_id(int tray_id)
{
std::vector<FilamentComboBox*> fcb_list = get_selected_filament_combobox();
for (auto fcb : fcb_list) {
if (fcb->get_tray_id() == tray_id) {
return fcb->get_index();
}
}
return -1;
}
std::vector<FilamentComboBox*> CalibrationPresetPage::get_selected_filament_combobox()
{
std::vector<FilamentComboBox*> fcb_list;
@@ -195,11 +195,15 @@ public:
void select_default_compatible_filament();
int get_index_by_tray_id(int tray_id);
std::vector<FilamentComboBox*> get_selected_filament_combobox();
// key is tray_id
std::map<int, Preset*> get_selected_filaments();
std::map<int, DynamicPrintConfig> get_filament_ams_list() const { return filament_ams_list; }
void get_preset_info(
float& nozzle_dia,
BedType& plate_type);
+11 -1
View File
@@ -609,6 +609,16 @@ void CaliPASaveAutoPanel::sync_cali_result_for_multi_extruder(const std::vector<
bool left_first_add_item = true;
bool right_first_add_item = true;
std::vector<PACalibResult> sorted_cali_result = cali_result;
if (m_obj && m_obj->is_support_new_auto_cali_method) {
for (auto &res : sorted_cali_result) {
if (res.ams_id == VIRTUAL_TRAY_MAIN_ID || res.ams_id == VIRTUAL_TRAY_DEPUTY_ID) {
res.tray_id = res.ams_id;
} else {
res.tray_id = res.ams_id * 4 + res.slot_id;
}
}
}
std::sort(sorted_cali_result.begin(), sorted_cali_result.end(), [](const PACalibResult &left, const PACalibResult &right) {
return left.tray_id < right.tray_id;
});
@@ -1206,7 +1216,7 @@ void CalibrationPASavePage::create_page(wxWindow* parent)
void CalibrationPASavePage::sync_cali_result(MachineObject* obj)
{
// only auto need sync cali_result
if (obj && m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) {
if (obj && (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO || m_cali_method == CalibrationMethod::CALI_METHOD_NEW_AUTO)) {
m_auto_panel->sync_cali_result(obj->pa_calib_results, obj->pa_calib_tab);
} else {
std::vector<PACalibResult> empty_result;