mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-16 03:07:55 -06:00
ENH: Add Ellis' pattern method for flow dynamic calibration
Github: #2356 Change-Id: I05068bd47fa8381429064ea0e5ba0f38e5da17c1 (cherry picked from commit c5d54d26e32909e1785cef9ba6a07d801419fa98)
This commit is contained in:
parent
2f8f2642f6
commit
aa1c8c8fe2
18 changed files with 442 additions and 73 deletions
|
@ -15,6 +15,9 @@ wxDEFINE_EVENT(EVT_DEVICE_CHANGED, wxCommandEvent);
|
|||
wxDEFINE_EVENT(EVT_CALIBRATION_JOB_FINISHED, wxCommandEvent);
|
||||
|
||||
static const wxString NA_STR = _L("N/A");
|
||||
static const float MIN_PA_K_VALUE = 0.0;
|
||||
static const float MAX_PA_K_VALUE = 0.5;
|
||||
static const float MIN_PA_K_VALUE_STEP = 0.001;
|
||||
|
||||
bool check_preset_name_valid(const wxString& name) {
|
||||
wxString error_message;
|
||||
|
@ -46,6 +49,18 @@ std::map<int, Preset*> get_cached_selected_filament(MachineObject* obj) {
|
|||
return selected_filament_map;
|
||||
}
|
||||
|
||||
bool is_pa_params_valid(const Calib_Params& params)
|
||||
{
|
||||
if (params.start < MIN_PA_K_VALUE || params.end > MAX_PA_K_VALUE || params.step < EPSILON || params.end < params.start + params.step) {
|
||||
MessageDialog msg_dlg(nullptr,
|
||||
wxString::Format(_L("Please input valid values:\nStart value: >= %.1f\nEnd value: <= %.1f\nEnd value: > Start value\nValue step: >= %.3f)"), MIN_PA_K_VALUE, MAX_PA_K_VALUE, MIN_PA_K_VALUE_STEP),
|
||||
wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
CalibrationWizard::CalibrationWizard(wxWindow* parent, CalibMode mode, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
|
||||
: wxPanel(parent, id, pos, size, style)
|
||||
, m_mode(mode)
|
||||
|
@ -339,6 +354,18 @@ PressureAdvanceWizard::PressureAdvanceWizard(wxWindow* parent, wxWindowID id, co
|
|||
create_pages();
|
||||
}
|
||||
|
||||
void PressureAdvanceWizard::on_cali_job_finished(wxString evt_data)
|
||||
{
|
||||
int cali_stage = 0;
|
||||
CalibMode obj_cali_mode = CalibUtils::get_calib_mode_by_name(evt_data.ToStdString(), cali_stage);
|
||||
|
||||
if (obj_cali_mode == m_mode) {
|
||||
show_step(cali_step);
|
||||
}
|
||||
// change ui, hide
|
||||
static_cast<CalibrationPresetPage *>(preset_step->page)->on_cali_finished_job();
|
||||
}
|
||||
|
||||
void PressureAdvanceWizard::create_pages()
|
||||
{
|
||||
start_step = new CalibrationWizardPageStep(new CalibrationPAStartPage(m_scrolledWindow));
|
||||
|
@ -422,6 +449,7 @@ void PressureAdvanceWizard::on_device_connected(MachineObject* obj)
|
|||
CalibrationMethod method;
|
||||
int cali_stage = 0;
|
||||
CalibMode obj_cali_mode = get_obj_calibration_mode(obj, method, cali_stage);
|
||||
obj->manual_pa_cali_method = ManualPaCaliMethod(cali_stage);
|
||||
|
||||
// show cali step when obj is in pa calibration
|
||||
if (obj) {
|
||||
|
@ -431,6 +459,8 @@ void PressureAdvanceWizard::on_device_connected(MachineObject* obj)
|
|||
if (obj_cali_mode == m_mode) {
|
||||
if (!obj->cali_finished && (obj->is_in_printing() || obj->is_printing_finished())) {
|
||||
CalibrationWizard::set_cali_method(method);
|
||||
CalibrationCaliPage *cali_page = (static_cast<CalibrationCaliPage *>(cali_step->page));
|
||||
cali_page->set_pa_cali_image(cali_stage);
|
||||
show_step(cali_step);
|
||||
}
|
||||
}
|
||||
|
@ -504,11 +534,13 @@ void PressureAdvanceWizard::on_cali_start()
|
|||
return;
|
||||
}
|
||||
|
||||
if (curr_obj->get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
std::string error_message;
|
||||
wxString wx_err_string;
|
||||
if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO && curr_obj->get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
X1CCalibInfos calib_infos;
|
||||
for (auto& item : selected_filaments) {
|
||||
int nozzle_temp = -1;
|
||||
int bed_temp = -1;
|
||||
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)) {
|
||||
|
@ -517,54 +549,92 @@ void PressureAdvanceWizard::on_cali_start()
|
|||
}
|
||||
|
||||
X1CCalibInfos::X1CCalibInfo calib_info;
|
||||
calib_info.tray_id = item.first;
|
||||
calib_info.nozzle_diameter = nozzle_dia;
|
||||
calib_info.filament_id = item.second->filament_id;
|
||||
calib_info.setting_id = item.second->setting_id;
|
||||
calib_info.bed_temp = bed_temp;
|
||||
calib_info.nozzle_temp = nozzle_temp;
|
||||
calib_info.tray_id = item.first;
|
||||
calib_info.nozzle_diameter = nozzle_dia;
|
||||
calib_info.filament_id = item.second->filament_id;
|
||||
calib_info.setting_id = item.second->setting_id;
|
||||
calib_info.bed_temp = bed_temp;
|
||||
calib_info.nozzle_temp = nozzle_temp;
|
||||
calib_info.max_volumetric_speed = max_volumetric_speed;
|
||||
calib_infos.calib_datas.push_back(calib_info);
|
||||
}
|
||||
CalibUtils::calib_PA(calib_infos, 0, error_message); // mode = 0 for auto
|
||||
wx_err_string = from_u8(error_message);
|
||||
|
||||
std::string error_message;
|
||||
wxString wx_err_string;
|
||||
if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) {
|
||||
CalibUtils::calib_PA(calib_infos, 0, error_message); // mode = 0 for auto
|
||||
wx_err_string = from_u8(error_message);
|
||||
} else if (m_cali_method == CalibrationMethod::CALI_METHOD_MANUAL) {
|
||||
CalibUtils::calib_PA(calib_infos, 1, error_message); // mode = 1 for manual
|
||||
wx_err_string = from_u8(error_message);
|
||||
} else {
|
||||
assert(false);
|
||||
}
|
||||
if (!wx_err_string.empty()) {
|
||||
MessageDialog msg_dlg(nullptr, wx_err_string, wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
}
|
||||
}
|
||||
else if (curr_obj->get_printer_series() == PrinterSeries::SERIES_P1P) {
|
||||
|
||||
show_step(m_curr_step->next);
|
||||
} else if (m_cali_method == CalibrationMethod::CALI_METHOD_MANUAL) {
|
||||
if (selected_filaments.empty()) {
|
||||
BOOST_LOG_TRIVIAL(warning) << "CaliPreset: selected filaments is empty";
|
||||
return;
|
||||
}
|
||||
else {
|
||||
int nozzle_temp = -1;
|
||||
int bed_temp = -1;
|
||||
float max_volumetric_speed = -1;
|
||||
if (!get_preset_info(selected_filaments.begin()->second->config, plate_type, nozzle_temp, bed_temp, max_volumetric_speed)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "CaliPreset: get preset info error";
|
||||
return;
|
||||
}
|
||||
|
||||
CalibInfo calib_info;
|
||||
calib_info.dev_id = curr_obj->dev_id;
|
||||
calib_info.select_ams = "[" + std::to_string(selected_filaments.begin()->first) + "]";
|
||||
Preset *preset = selected_filaments.begin()->second;
|
||||
Preset * temp_filament_preset = new Preset(preset->type, preset->name + "_temp");
|
||||
temp_filament_preset->config = preset->config;
|
||||
|
||||
int nozzle_temp = -1;
|
||||
int bed_temp = -1;
|
||||
float max_volumetric_speed = -1;
|
||||
if (!get_preset_info(selected_filaments.begin()->second->config, plate_type, nozzle_temp, bed_temp, max_volumetric_speed)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "CaliPreset: get preset info error";
|
||||
return;
|
||||
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, nozzle_dia);
|
||||
calib_info.print_prest = preset_page->get_print_preset();
|
||||
calib_info.filament_prest = temp_filament_preset;
|
||||
|
||||
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);
|
||||
msg_dlg.ShowModal();
|
||||
return;
|
||||
} else {
|
||||
values[0].ToDouble(&calib_info.params.start);
|
||||
values[1].ToDouble(&calib_info.params.end);
|
||||
values[2].ToDouble(&calib_info.params.step);
|
||||
}
|
||||
calib_info.params.mode = preset_page->get_pa_cali_method();
|
||||
|
||||
if (!is_pa_params_valid(calib_info.params))
|
||||
return;
|
||||
|
||||
ManualPaCaliMethod pa_cali_method = ManualPaCaliMethod::PA_LINE;
|
||||
CalibrationCaliPage *cali_page = (static_cast<CalibrationCaliPage *>(cali_step->page));
|
||||
if (calib_info.params.mode == CalibMode::Calib_PA_Line)
|
||||
pa_cali_method = ManualPaCaliMethod::PA_LINE;
|
||||
else if (calib_info.params.mode == CalibMode::Calib_PA_Pattern)
|
||||
pa_cali_method = ManualPaCaliMethod::PA_PATTERN;
|
||||
|
||||
cali_page->set_pa_cali_image(int(pa_cali_method));
|
||||
curr_obj->manual_pa_cali_method = pa_cali_method;
|
||||
|
||||
CalibUtils::calib_generic_PA(calib_info, error_message);
|
||||
wx_err_string = from_u8(error_message);
|
||||
|
||||
if (!wx_err_string.empty()) {
|
||||
MessageDialog msg_dlg(nullptr, wx_err_string, wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
}
|
||||
|
||||
preset_page->on_cali_start_job();
|
||||
}
|
||||
|
||||
curr_obj->command_start_extrusion_cali(selected_filaments.begin()->first,
|
||||
nozzle_temp, bed_temp, max_volumetric_speed, setting_id);
|
||||
} else {
|
||||
assert(false);
|
||||
BOOST_LOG_TRIVIAL(error) << "CaliPreset: unsupported printer type or cali method";
|
||||
return;
|
||||
}
|
||||
|
||||
show_step(m_curr_step->next);
|
||||
|
||||
CalibrationCaliPage* cali_page = (static_cast<CalibrationCaliPage*>(cali_step->page));
|
||||
cali_page->clear_last_job_status();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue