mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-12-24 00:28:38 -07:00
ENH: support new auto cali method
jira: STUDIO-10798 Change-Id: I9490b050e93cd556e1d34b1e69e0508eaecec2cd (cherry picked from commit 7a8b34525ef77d49b6549ecb290e2b1f89c69419)
This commit is contained in:
parent
49befe4306
commit
337d987ec8
14 changed files with 705 additions and 20 deletions
BIN
resources/calib/pressure_advance/auto_pa_line_dual.3mf
Normal file
BIN
resources/calib/pressure_advance/auto_pa_line_dual.3mf
Normal file
Binary file not shown.
BIN
resources/calib/pressure_advance/auto_pa_line_single.3mf
Normal file
BIN
resources/calib/pressure_advance/auto_pa_line_single.3mf
Normal file
Binary file not shown.
|
|
@ -58,6 +58,183 @@ const char *PresetBundle::ORCA_DEFAULT_PRINTER_VARIANT = "0.4";
|
|||
const char *PresetBundle::ORCA_DEFAULT_FILAMENT = "Generic PLA @System";
|
||||
const char *PresetBundle::ORCA_FILAMENT_LIBRARY = "OrcaFilamentLibrary";
|
||||
|
||||
DynamicPrintConfig PresetBundle::construct_full_config(
|
||||
Preset& in_printer_preset,
|
||||
Preset& in_print_preset,
|
||||
const DynamicPrintConfig& project_config,
|
||||
std::vector<Preset>& in_filament_presets,
|
||||
bool apply_extruder,
|
||||
std::optional<std::vector<int>> filament_maps_new)
|
||||
{
|
||||
DynamicPrintConfig &printer_config = in_printer_preset.config;
|
||||
DynamicPrintConfig &print_config = in_print_preset.config;
|
||||
|
||||
DynamicPrintConfig out;
|
||||
out.apply(FullPrintConfig::defaults());
|
||||
out.apply(printer_config);
|
||||
out.apply(print_config);
|
||||
out.apply(project_config);
|
||||
out.apply(in_filament_presets[0].config);
|
||||
|
||||
size_t num_filaments = in_filament_presets.size();
|
||||
|
||||
std::vector<int> filament_maps = out.option<ConfigOptionInts>("filament_map")->values;
|
||||
if (filament_maps_new.has_value())
|
||||
filament_maps = *filament_maps_new;
|
||||
// in some middle state, they may be different
|
||||
if (filament_maps.size() != num_filaments) {
|
||||
filament_maps.resize(num_filaments, 1);
|
||||
}
|
||||
|
||||
auto *extruder_diameter = dynamic_cast<const ConfigOptionFloatsNullable *>(out.option("nozzle_diameter"));
|
||||
// Collect the "compatible_printers_condition" and "inherits" values over all presets (print, filaments, printers) into a single vector.
|
||||
std::vector<std::string> compatible_printers_condition;
|
||||
std::vector<std::string> compatible_prints_condition;
|
||||
std::vector<std::string> inherits;
|
||||
std::vector<std::string> filament_ids;
|
||||
std::vector<std::string> print_compatible_printers;
|
||||
// BBS: add logic for settings check between different system presets
|
||||
std::vector<std::string> different_settings;
|
||||
std::string different_print_settings, different_printer_settings;
|
||||
compatible_printers_condition.emplace_back(in_print_preset.compatible_printers_condition());
|
||||
|
||||
const ConfigOptionStrings *compatible_printers = print_config.option<ConfigOptionStrings>("compatible_printers", false);
|
||||
if (compatible_printers) print_compatible_printers = compatible_printers->values;
|
||||
// BBS: add logic for settings check between different system presets
|
||||
std::string print_inherits = in_print_preset.inherits();
|
||||
inherits.emplace_back(print_inherits);
|
||||
|
||||
// BBS: update printer config related with variants
|
||||
if (apply_extruder) {
|
||||
out.update_values_to_printer_extruders(out, printer_options_with_variant_1, "printer_extruder_id", "printer_extruder_variant");
|
||||
out.update_values_to_printer_extruders(out, printer_options_with_variant_2, "printer_extruder_id", "printer_extruder_variant", 2);
|
||||
// update print config related with variants
|
||||
out.update_values_to_printer_extruders(out, print_options_with_variant, "print_extruder_id", "print_extruder_variant");
|
||||
}
|
||||
|
||||
if (num_filaments <= 1) {
|
||||
// BBS: update filament config related with variants
|
||||
DynamicPrintConfig filament_config = in_filament_presets[0].config;
|
||||
if (apply_extruder) filament_config.update_values_to_printer_extruders(out, filament_options_with_variant, "", "filament_extruder_variant", 1, filament_maps[0]);
|
||||
out.apply(filament_config);
|
||||
compatible_printers_condition.emplace_back(in_filament_presets[0].compatible_printers_condition());
|
||||
compatible_prints_condition.emplace_back(in_filament_presets[0].compatible_prints_condition());
|
||||
std::string filament_inherits = in_filament_presets[0].inherits();
|
||||
inherits.emplace_back(filament_inherits);
|
||||
filament_ids.emplace_back(in_filament_presets[0].filament_id);
|
||||
|
||||
std::vector<int> &filament_self_indice = out.option<ConfigOptionInts>("filament_self_index", true)->values;
|
||||
int index_size = out.option<ConfigOptionStrings>("filament_extruder_variant")->size();
|
||||
filament_self_indice.resize(index_size, 1);
|
||||
} else {
|
||||
std::vector<const DynamicPrintConfig *> filament_configs;
|
||||
std::vector<const Preset *> filament_presets;
|
||||
for (const Preset & preset : in_filament_presets) {
|
||||
filament_presets.emplace_back(&preset);
|
||||
filament_configs.emplace_back(&(preset.config));
|
||||
}
|
||||
|
||||
std::vector<DynamicPrintConfig> filament_temp_configs;
|
||||
filament_temp_configs.resize(num_filaments);
|
||||
for (size_t i = 0; i < num_filaments; ++i) {
|
||||
filament_temp_configs[i] = *(filament_configs[i]);
|
||||
if (apply_extruder)
|
||||
filament_temp_configs[i].update_values_to_printer_extruders(out, filament_options_with_variant, "", "filament_extruder_variant", 1, filament_maps[i]);
|
||||
}
|
||||
|
||||
// loop through options and apply them to the resulting config.
|
||||
std::vector<int> filament_variant_count(num_filaments, 1);
|
||||
for (const t_config_option_key &key : in_filament_presets[0].config.keys()) {
|
||||
if (key == "compatible_prints" || key == "compatible_printers") continue;
|
||||
// Get a destination option.
|
||||
ConfigOption *opt_dst = out.option(key, false);
|
||||
if (opt_dst->is_scalar()) {
|
||||
// Get an option, do not create if it does not exist.
|
||||
const ConfigOption *opt_src = filament_temp_configs.front().option(key);
|
||||
if (opt_src != nullptr) opt_dst->set(opt_src);
|
||||
} else {
|
||||
// BBS
|
||||
ConfigOptionVectorBase *opt_vec_dst = static_cast<ConfigOptionVectorBase *>(opt_dst);
|
||||
{
|
||||
if (apply_extruder) {
|
||||
std::vector<const ConfigOption *> filament_opts(num_filaments, nullptr);
|
||||
// Setting a vector value from all filament_configs.
|
||||
for (size_t i = 0; i < filament_opts.size(); ++i) filament_opts[i] = filament_temp_configs[i].option(key);
|
||||
opt_vec_dst->set(filament_opts);
|
||||
} else {
|
||||
for (size_t i = 0; i < num_filaments; ++i) {
|
||||
const ConfigOptionVectorBase *filament_option = static_cast<const ConfigOptionVectorBase *>(filament_temp_configs[i].option(key));
|
||||
if (i == 0)
|
||||
opt_vec_dst->set(filament_option);
|
||||
else
|
||||
opt_vec_dst->append(filament_option);
|
||||
|
||||
if (key == "filament_extruder_variant") filament_variant_count[i] = filament_option->size();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!apply_extruder) {
|
||||
// append filament_self_index
|
||||
std::vector<int> &filament_self_indice = out.option<ConfigOptionInts>("filament_self_index", true)->values;
|
||||
int index_size = out.option<ConfigOptionStrings>("filament_extruder_variant")->size();
|
||||
filament_self_indice.resize(index_size, 1);
|
||||
int k = 0;
|
||||
for (size_t i = 0; i < num_filaments; i++) {
|
||||
for (size_t j = 0; j < filament_variant_count[i]; j++) { filament_self_indice[k++] = i + 1; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// These value types clash between the print and filament profiles. They should be renamed.
|
||||
out.erase("compatible_prints");
|
||||
out.erase("compatible_prints_condition");
|
||||
out.erase("compatible_printers");
|
||||
out.erase("compatible_printers_condition");
|
||||
out.erase("inherits");
|
||||
// BBS: add logic for settings check between different system presets
|
||||
out.erase("different_settings_to_system");
|
||||
|
||||
static const char *keys[] = {"support_filament", "support_interface_filament"};
|
||||
for (size_t i = 0; i < sizeof(keys) / sizeof(keys[0]); ++i) {
|
||||
std::string key = std::string(keys[i]);
|
||||
auto *opt = dynamic_cast<ConfigOptionInt *>(out.option(key, false));
|
||||
assert(opt != nullptr);
|
||||
opt->value = boost::algorithm::clamp<int>(opt->value, 0, int(num_filaments));
|
||||
}
|
||||
|
||||
std::vector<std::string> filamnet_preset_names;
|
||||
for (auto preset : in_filament_presets) {
|
||||
filamnet_preset_names.emplace_back(preset.name);
|
||||
}
|
||||
out.option<ConfigOptionString>("print_settings_id", true)->value = in_print_preset.name;
|
||||
out.option<ConfigOptionStrings>("filament_settings_id", true)->values = filamnet_preset_names;
|
||||
out.option<ConfigOptionString>("printer_settings_id", true)->value = in_printer_preset.name;
|
||||
out.option<ConfigOptionStrings>("filament_ids", true)->values = filament_ids;
|
||||
out.option<ConfigOptionInts>("filament_map", true)->values = filament_maps;
|
||||
|
||||
auto add_if_some_non_empty = [&out](std::vector<std::string> &&values, const std::string &key) {
|
||||
bool nonempty = false;
|
||||
for (const std::string &v : values)
|
||||
if (!v.empty()) {
|
||||
nonempty = true;
|
||||
break;
|
||||
}
|
||||
if (nonempty) out.set_key_value(key, new ConfigOptionStrings(std::move(values)));
|
||||
};
|
||||
add_if_some_non_empty(std::move(compatible_printers_condition), "compatible_machine_expression_group");
|
||||
add_if_some_non_empty(std::move(compatible_prints_condition), "compatible_process_expression_group");
|
||||
add_if_some_non_empty(std::move(inherits), "inherits_group");
|
||||
// BBS: add logic for settings check between different system presets
|
||||
//add_if_some_non_empty(std::move(different_settings), "different_settings_to_system");
|
||||
add_if_some_non_empty(std::move(print_compatible_printers), "print_compatible_printers");
|
||||
|
||||
out.option<ConfigOptionEnumGeneric>("printer_technology", true)->value = ptFFF;
|
||||
return out;
|
||||
}
|
||||
|
||||
PresetBundle::PresetBundle()
|
||||
: prints(Preset::TYPE_PRINT, Preset::print_options(), static_cast<const PrintRegionConfig &>(FullPrintConfig::defaults()))
|
||||
, filaments(Preset::TYPE_FILAMENT, Preset::filament_options(), static_cast<const PrintRegionConfig &>(FullPrintConfig::defaults()), "Default Filament")
|
||||
|
|
|
|||
|
|
@ -75,6 +75,12 @@ struct FilamentBaseInfo
|
|||
class PresetBundle
|
||||
{
|
||||
public:
|
||||
static DynamicPrintConfig construct_full_config(Preset &in_printer_preset,
|
||||
Preset &in_print_preset,
|
||||
const DynamicPrintConfig &project_config,
|
||||
std::vector<Preset> &in_filament_presets,
|
||||
bool apply_extruder,
|
||||
std::optional<std::vector<int>> filament_maps_new);
|
||||
PresetBundle();
|
||||
PresetBundle(const PresetBundle &rhs);
|
||||
PresetBundle& operator=(const PresetBundle &rhs);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ enum class CalibMode : int {
|
|||
Calib_PA_Line,
|
||||
Calib_PA_Pattern,
|
||||
Calib_PA_Tower,
|
||||
Calib_Auto_PA_Line,
|
||||
Calib_Flow_Rate,
|
||||
Calib_Temp_Tower,
|
||||
Calib_Vol_speed_Tower,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 };
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include "slic3r/GUI/Jobs/BoostThreadWorker.hpp"
|
||||
#include "slic3r/GUI/Jobs/PlaterWorker.hpp"
|
||||
#include "../GUI/MsgDialog.hpp"
|
||||
#include "libslic3r/FlushVolCalc.hpp"
|
||||
|
||||
#include "../GUI/DeviceCore/DevConfig.h"
|
||||
#include "../GUI/DeviceCore/DevExtruderSystem.h"
|
||||
|
|
@ -118,6 +119,8 @@ std::string get_calib_mode_name(CalibMode cali_mode, int stage)
|
|||
switch(cali_mode) {
|
||||
case CalibMode::Calib_PA_Line:
|
||||
return "pa_line_calib_mode";
|
||||
case CalibMode::Calib_Auto_PA_Line:
|
||||
return "auto_pa_line_calib_mode";
|
||||
case CalibMode::Calib_PA_Pattern:
|
||||
return "pa_pattern_calib_mode";
|
||||
case CalibMode::Calib_Flow_Rate:
|
||||
|
|
@ -283,6 +286,7 @@ static void init_multi_extruder_params_for_cali(DynamicPrintConfig& config, cons
|
|||
for (size_t index = 0; index < extruder_count; ++index) {
|
||||
if (physical_extruder_maps[index] == extruder_id)
|
||||
{
|
||||
nozzle_volume_types[index] = (int) calib_info.nozzle_volume_type;
|
||||
extruder_id = index + 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -311,6 +315,10 @@ CalibMode CalibUtils::get_calib_mode_by_name(const std::string name, int& cali_s
|
|||
cali_stage = 1;
|
||||
return CalibMode::Calib_PA_Line;
|
||||
}
|
||||
else if (name == "auto_pa_line_calib_mode") {
|
||||
cali_stage = 2;
|
||||
return CalibMode::Calib_PA_Line;
|
||||
}
|
||||
else if (name == "flow_rate_coarse_calib_mode") {
|
||||
cali_stage = 1;
|
||||
return CalibMode::Calib_Flow_Rate;
|
||||
|
|
@ -788,6 +796,211 @@ void CalibUtils::calib_pa_pattern(const CalibInfo &calib_info, Model& model)
|
|||
model.calib_pa_pattern = std::make_unique<CalibPressureAdvancePattern>(pa_pattern);
|
||||
}
|
||||
|
||||
void CalibUtils::set_for_auto_pa_model_and_config(const std::vector<CalibInfo> &calib_infos, DynamicPrintConfig &full_config, Model &model)
|
||||
{
|
||||
DynamicPrintConfig print_config = calib_infos[0].print_prest->config;
|
||||
|
||||
float nozzle_diameter = full_config.option<ConfigOptionFloatsNullable>("nozzle_diameter")->get_at(0);
|
||||
int extruder_count = full_config.option<ConfigOptionFloatsNullable>("nozzle_diameter")->values.size();
|
||||
|
||||
for (const auto opt : SuggestedConfigCalibPAPattern().float_pairs) { print_config.set_key_value(opt.first, new ConfigOptionFloat(opt.second)); }
|
||||
|
||||
std::vector<CalibInfo> sorted_calib_infos = calib_infos;
|
||||
std::sort(sorted_calib_infos.begin(), sorted_calib_infos.end(), [](const CalibInfo &left_item, const CalibInfo &right_item) {
|
||||
return left_item.index < right_item.index;
|
||||
});
|
||||
|
||||
for (const CalibInfo &calib_info : calib_infos) {
|
||||
int index = get_index_for_extruder_parameter(print_config, "outer_wall_speed", calib_info.extruder_id, calib_info.extruder_type, calib_info.nozzle_volume_type);
|
||||
float wall_speed = CalibPressureAdvance::find_optimal_PA_speed(full_config, print_config.get_abs_value("line_width"), print_config.get_abs_value("layer_height"),
|
||||
calib_info.extruder_id, 0);
|
||||
|
||||
ConfigOptionFloatsNullable *wall_speed_speed_opt = print_config.option<ConfigOptionFloatsNullable>("outer_wall_speed");
|
||||
std::vector<double> new_speeds = wall_speed_speed_opt->values;
|
||||
new_speeds[index] = wall_speed;
|
||||
ModelObject* object = model.objects[calib_info.index];
|
||||
object->config.set_key_value("outer_wall_speed", new ConfigOptionFloatsNullable(new_speeds));
|
||||
}
|
||||
|
||||
for (const auto opt : SuggestedConfigCalibPAPattern().nozzle_ratio_pairs) {
|
||||
print_config.set_key_value(opt.first, new ConfigOptionFloat(nozzle_diameter * opt.second / 100));
|
||||
}
|
||||
|
||||
for (const auto opt : SuggestedConfigCalibPAPattern().int_pairs) { print_config.set_key_value(opt.first, new ConfigOptionInt(opt.second)); }
|
||||
|
||||
print_config.set_key_value(SuggestedConfigCalibPAPattern().brim_pair.first, new ConfigOptionEnum<BrimType>(SuggestedConfigCalibPAPattern().brim_pair.second));
|
||||
|
||||
auto* _wall_generator = print_config.option<ConfigOptionEnum<PerimeterGeneratorType>>("wall_generator");
|
||||
_wall_generator->value = PerimeterGeneratorType::Arachne;
|
||||
|
||||
print_config.option<ConfigOptionBool>("enable_prime_tower")->value = false;
|
||||
|
||||
auto get_new_filament_id = [&sorted_calib_infos](int index) -> int {
|
||||
for (size_t i = 0; i < sorted_calib_infos.size(); ++i) {
|
||||
if (index == sorted_calib_infos[i].index) {
|
||||
return (int) (i + 1); // 1 base filament_id
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
// set printable and reset filament_id
|
||||
for (size_t i = 0; i < model.objects.size(); ++i) {
|
||||
auto iter = std::find_if(calib_infos.begin(), calib_infos.end(), [i](const CalibInfo &item) { return item.index == i; });
|
||||
|
||||
if (iter == calib_infos.end()) {
|
||||
model.objects[i]->printable = false;
|
||||
} else {
|
||||
ModelObject *object = model.objects[i];
|
||||
object->config.set_key_value("extruder", new ConfigOptionInt(get_new_filament_id(iter->index)));
|
||||
for (auto *volume : object->volumes) {
|
||||
if (volume->config.has("extruder")) volume->config.erase("extruder");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DynamicPrintConfig full_config;
|
||||
full_config.apply(print_config);
|
||||
full_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode", true)->value = FilamentMapMode::fmmManual;
|
||||
|
||||
// nozzle volume type
|
||||
std::vector<int>& nozzle_volume_types = full_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type", true)->values;
|
||||
nozzle_volume_types.resize(extruder_count, NozzleVolumeType::nvtStandard);
|
||||
int filament_nums = calib_infos.size();
|
||||
std::vector<int> physical_extruder_maps = dynamic_cast<ConfigOptionInts *>(full_config.option("physical_extruder_map", true))->values;
|
||||
for (size_t filament_index = 0; filament_index < calib_infos.size(); ++filament_index) {
|
||||
CalibInfo calib_info = calib_infos[filament_index];
|
||||
int extruder_id = calib_info.extruder_id;
|
||||
for (size_t index = 0; index < extruder_count; ++index) {
|
||||
if (physical_extruder_maps[index] == extruder_id) {
|
||||
extruder_id = index;
|
||||
}
|
||||
}
|
||||
nozzle_volume_types[extruder_id] = (int)calib_info.nozzle_volume_type;
|
||||
}
|
||||
|
||||
// filament map transform to 1 base
|
||||
std::vector<int> &filament_maps = full_config.option<ConfigOptionInts>("filament_map", true)->values;
|
||||
std::transform(filament_maps.begin(), filament_maps.end(), filament_maps.begin(), [](int value) { return value + 1; });
|
||||
|
||||
std::vector<std::string> &filament_colors = full_config.option<ConfigOptionStrings>("filament_colour")->values;
|
||||
filament_colors.resize(sorted_calib_infos.size(), "#000000");
|
||||
for (size_t i = 0; i < sorted_calib_infos.size(); ++i) {
|
||||
filament_colors[i] = sorted_calib_infos[i].filament_color;
|
||||
}
|
||||
|
||||
// Add flush volume matrix
|
||||
std::vector<double> flush_matrix_vec;
|
||||
for (int e_idx = 0; e_idx < extruder_count; ++e_idx) {
|
||||
const std::vector<int> &min_flush_volumes = get_min_flush_volumes(full_config, e_idx);
|
||||
for (size_t from_idx = 0; from_idx < filament_nums; ++from_idx) {
|
||||
for (size_t to_idx = 0; to_idx < filament_nums; ++to_idx) {
|
||||
if (from_idx == to_idx) {
|
||||
flush_matrix_vec.emplace_back(0);
|
||||
}
|
||||
else {
|
||||
Slic3r::FlushVolCalculator calculator(min_flush_volumes[from_idx], Slic3r::g_max_flush_volume, extruder_count > 1, NozzleVolumeType(nozzle_volume_types[e_idx]));
|
||||
wxColour from = wxColour(filament_colors[from_idx]);
|
||||
wxColour to = wxColour(filament_colors[to_idx]);
|
||||
int volume = calculator.calc_flush_vol(from.Alpha(), from.Red(), from.Green(), from.Blue(), to.Alpha(), to.Red(), to.Green(), to.Blue());
|
||||
flush_matrix_vec.emplace_back(double(volume));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
std::vector<double> &config_matrix = full_config.option<ConfigOptionFloats>("flush_volumes_matrix")->values;
|
||||
set_flush_volumes_matrix(config_matrix, flush_matrix_vec, -1, extruder_count);
|
||||
}
|
||||
|
||||
bool CalibUtils::calib_generic_auto_pa_cali(const std::vector<CalibInfo> &calib_infos, wxString &error_message)
|
||||
{
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) {
|
||||
error_message = _L("Need select printer");
|
||||
return false;
|
||||
}
|
||||
|
||||
MachineObject *obj_ = dev->get_selected_machine();
|
||||
if (obj_ == nullptr) {
|
||||
error_message = _L("Need select printer");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!check_printable_status_before_cali(obj_, calib_infos, error_message))
|
||||
return false;
|
||||
|
||||
const Calib_Params ¶ms = calib_infos[0].params;
|
||||
if (params.mode != CalibMode::Calib_Auto_PA_Line)
|
||||
return false;
|
||||
|
||||
Model model;
|
||||
std::string input_file;
|
||||
if (obj_->is_multi_extruders())
|
||||
input_file = Slic3r::resources_dir() + "/calib/pressure_advance/auto_pa_line_dual.3mf";
|
||||
else
|
||||
input_file = Slic3r::resources_dir() + "/calib/pressure_advance/auto_pa_line_single.3mf";
|
||||
|
||||
read_model_from_file(input_file, model);
|
||||
|
||||
DynamicPrintConfig print_config = calib_infos[0].print_prest->config;
|
||||
DynamicPrintConfig filament_config = calib_infos[0].filament_prest->config;
|
||||
DynamicPrintConfig printer_config = calib_infos[0].printer_prest->config;
|
||||
|
||||
Preset printer_preset = *calib_infos[0].printer_prest;
|
||||
Preset print_preset = *calib_infos[0].print_prest;
|
||||
std::vector<Preset> filament_presets;
|
||||
std::vector<int> filament_map;
|
||||
filament_map.resize(calib_infos.size());
|
||||
std::vector<int> physical_extruder_maps = dynamic_cast<ConfigOptionInts *>(printer_config.option("physical_extruder_map", true))->values;
|
||||
for (size_t i = 0; i < calib_infos.size(); ++i) {
|
||||
CalibInfo calib_info = calib_infos[i];
|
||||
calib_info.filament_prest->config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(calib_info.bed_type));
|
||||
filament_presets.emplace_back(*calib_info.filament_prest);
|
||||
for (size_t index = 0; index < physical_extruder_maps.size(); ++index) {
|
||||
if (physical_extruder_maps[index] == calib_info.extruder_id) {
|
||||
filament_map[i] = index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PresetBundle *preset_bundle = wxGetApp().preset_bundle;
|
||||
DynamicPrintConfig full_config = PresetBundle::construct_full_config(printer_preset, print_preset, preset_bundle->project_config, filament_presets, false, filament_map);
|
||||
|
||||
set_for_auto_pa_model_and_config(calib_infos, full_config, model);
|
||||
if (!process_and_store_3mf(&model, full_config, params, error_message))
|
||||
return false;
|
||||
|
||||
try {
|
||||
json js;
|
||||
if (params.mode == CalibMode::Calib_PA_Line)
|
||||
js["cali_type"] = "cali_pa_line";
|
||||
else if (params.mode == CalibMode::Calib_PA_Pattern)
|
||||
js["cali_type"] = "cali_pa_pattern";
|
||||
else if (params.mode == CalibMode::Calib_Auto_PA_Line)
|
||||
js["cali_type"] = "cali_auto_pa_line";
|
||||
|
||||
const ConfigOptionFloatsNullable *nozzle_diameter_config = printer_config.option<ConfigOptionFloatsNullable>("nozzle_diameter");
|
||||
assert(nozzle_diameter_config->values.size() > 0);
|
||||
float nozzle_diameter = nozzle_diameter_config->values[0];
|
||||
|
||||
js["nozzle_diameter"] = nozzle_diameter;
|
||||
std::string filament_ids;
|
||||
for (const auto calib_info : calib_infos) {
|
||||
filament_ids += calib_info.filament_prest->filament_id;
|
||||
filament_ids += " ";
|
||||
}
|
||||
js["filament_id"] = filament_ids;
|
||||
js["printer_type"] = obj_->printer_type;
|
||||
NetworkAgent *agent = GUI::wxGetApp().getAgent();
|
||||
if (agent)
|
||||
agent->track_event("cali", js.dump());
|
||||
} catch (...) {}
|
||||
|
||||
send_to_print(calib_infos, error_message);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalibUtils::calib_generic_PA(const CalibInfo &calib_info, wxString &error_message)
|
||||
{
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
|
|
@ -1193,6 +1406,74 @@ bool CalibUtils::check_printable_status_before_cali(const MachineObject *obj, co
|
|||
return true;
|
||||
}
|
||||
|
||||
bool CalibUtils::check_printable_status_before_cali(const MachineObject *obj, const std::vector<CalibInfo> &cali_infos, wxString &error_message)
|
||||
{
|
||||
if (!obj) {
|
||||
error_message = _L("Need select printer");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cali_infos.empty())
|
||||
return true;
|
||||
|
||||
float cali_diameter = cali_infos[0].nozzle_diameter;
|
||||
int extruder_id = cali_infos[0].extruder_id;
|
||||
for (const auto &cali_info : cali_infos) {
|
||||
if (cali_infos[0].params.mode == CalibMode::Calib_Auto_PA_Line && !is_support_auto_pa_cali(cali_info.filament_prest->filament_id)) {
|
||||
error_message = _L("TPU 90A/TPU 85A is too soft and does not support automatic Flow Dynamics calibration.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_approx(cali_diameter, cali_info.nozzle_diameter)) {
|
||||
error_message = _L("Automatic calibration only supports cases where the left and right nozzle diameters are identical.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (extruder_id >= obj->m_extder_data.extders.size()) {
|
||||
error_message = _L("The number of printer extruders and the printer selected for calibration does not match.");
|
||||
return false;
|
||||
}
|
||||
|
||||
float diameter = obj->m_extder_data.extders[extruder_id].current_nozzle_diameter;
|
||||
bool is_multi_extruder = obj->is_multi_extruders();
|
||||
std::vector<NozzleFlowType> nozzle_volume_types;
|
||||
if (is_multi_extruder) {
|
||||
for (const Extder &extruder : obj->m_extder_data.extders) { nozzle_volume_types.emplace_back(extruder.current_nozzle_flow_type); }
|
||||
}
|
||||
|
||||
for (const auto &cali_info : cali_infos) {
|
||||
wxString name = _L("left");
|
||||
if (cali_info.extruder_id == 0) { name = _L("right"); }
|
||||
|
||||
if (!is_approx(cali_info.nozzle_diameter, diameter)) {
|
||||
if (is_multi_extruder)
|
||||
error_message = wxString::Format(_L("The currently selected nozzle diameter of %s extruder does not match the actual nozzle diameter.\n"
|
||||
"Please click the Sync button above and restart the calibration."),
|
||||
name);
|
||||
else
|
||||
error_message = _L("The nozzle diameter does not match the actual printer nozzle diameter.\n"
|
||||
"Please click the Sync button above and restart the calibration.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_multi_extruder) {
|
||||
if (nozzle_volume_types[cali_info.extruder_id] == NozzleFlowType::NONE_FLOWTYPE) {
|
||||
error_message = wxString::Format(_L("Printer %s nozzle information has not been set. Please configure it before proceeding with the calibration."), name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NozzleVolumeType(nozzle_volume_types[cali_info.extruder_id] - 1) != cali_info.nozzle_volume_type) {
|
||||
error_message = wxString::Format(_L("The currently selected nozzle type of %s extruder does not match the actual printer nozzle type.\n"
|
||||
"Please click the Sync button above and restart the calibration."),
|
||||
name);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalibUtils::check_printable_status_before_cali(const MachineObject* obj, const CalibInfo& cali_info, wxString& error_message)
|
||||
{
|
||||
if (!obj) {
|
||||
|
|
@ -1296,7 +1577,7 @@ bool CalibUtils::process_and_store_3mf(Model *model, const DynamicPrintConfig &f
|
|||
|
||||
BuildVolume build_volume(bedfs, print_height, extruder_areas, extruder_heights);
|
||||
unsigned int count = model->update_print_volume_state(build_volume);
|
||||
if (count == 0) {
|
||||
if (count == 0 && params.mode != CalibMode::Calib_Auto_PA_Line) {
|
||||
error_message = _L("Unable to calibrate: maybe because the set calibration value range is too large, or the step is too small");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1546,5 +1827,121 @@ void CalibUtils::send_to_print(const CalibInfo &calib_info, wxString &error_mess
|
|||
replace_job(*print_worker, std::move(print_job));
|
||||
}
|
||||
|
||||
void CalibUtils::send_to_print(const std::vector<CalibInfo> &calib_infos, wxString &error_message, int flow_ratio_mode)
|
||||
{
|
||||
std::string dev_id = calib_infos[0].dev_id;
|
||||
std::shared_ptr<ProgressIndicator> process_bar = calib_infos[0].process_bar;
|
||||
BedType bed_type = calib_infos[0].bed_type;
|
||||
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) {
|
||||
error_message = _L("Need select printer");
|
||||
return;
|
||||
}
|
||||
|
||||
MachineObject *obj_ = dev->get_selected_machine();
|
||||
if (obj_ == nullptr) {
|
||||
error_message = _L("Need select printer");
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj_->is_in_upgrading()) {
|
||||
error_message = _L("Cannot send the print job when the printer is updating firmware");
|
||||
return;
|
||||
} else if (obj_->is_system_printing()) {
|
||||
error_message = _L("The printer is executing instructions. Please restart printing after it ends");
|
||||
return;
|
||||
} else if (obj_->is_in_printing()) {
|
||||
error_message = _L("The printer is busy on other print job");
|
||||
return;
|
||||
}
|
||||
|
||||
else if (!obj_->is_support_print_without_sd && (obj_->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD)) {
|
||||
error_message = _L("Storage needs to be inserted before printing.");
|
||||
return;
|
||||
}
|
||||
if (obj_->is_lan_mode_printer()) {
|
||||
if (obj_->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD) {
|
||||
error_message = _L("Storage needs to be inserted before printing via LAN.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
auto print_job = std::make_shared<PrintJob>(dev_id);
|
||||
print_job->m_dev_ip = obj_->dev_ip;
|
||||
print_job->m_ftp_folder = obj_->get_ftp_folder();
|
||||
print_job->m_access_code = obj_->get_access_code();
|
||||
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
print_job->m_local_use_ssl_for_ftp = wxGetApp().app_config->get("enable_ssl_for_ftp") == "true" ? true : false;
|
||||
print_job->m_local_use_ssl_for_mqtt = wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false;
|
||||
#else
|
||||
print_job->m_local_use_ssl_for_ftp = obj_->local_use_ssl_for_ftp;
|
||||
print_job->m_local_use_ssl_for_mqtt = obj_->local_use_ssl_for_mqtt;
|
||||
#endif
|
||||
|
||||
print_job->connection_type = obj_->connection_type();
|
||||
print_job->cloud_print_only = obj_->is_support_cloud_print_only;
|
||||
|
||||
PrintPrepareData job_data;
|
||||
job_data.is_from_plater = false;
|
||||
job_data.plate_idx = 0;
|
||||
job_data._3mf_config_path = config_3mf_path;
|
||||
job_data._3mf_path = path;
|
||||
job_data._temp_path = temp_dir;
|
||||
|
||||
PlateListData plate_data;
|
||||
plate_data.is_valid = true;
|
||||
plate_data.plate_count = 1;
|
||||
plate_data.cur_plate_index = 0;
|
||||
plate_data.bed_type = bed_type;
|
||||
|
||||
print_job->job_data = job_data;
|
||||
print_job->plate_data = plate_data;
|
||||
print_job->m_print_type = "from_normal";
|
||||
|
||||
// set AMS mapping
|
||||
std::string select_ams = "[";
|
||||
std::string new_select_ams = "[";
|
||||
for (size_t i = 0; i < calib_infos.size(); ++i) {
|
||||
select_ams += calib_infos[i].select_ams;
|
||||
new_select_ams += "{\"ams_id\":" + std::to_string(calib_infos[i].ams_id) + ", \"slot_id\":" + std::to_string(calib_infos[i].slot_id) + "}";
|
||||
if (i != calib_infos.size() - 1) {
|
||||
select_ams += ",";
|
||||
new_select_ams += ",";
|
||||
}
|
||||
}
|
||||
select_ams += "]";
|
||||
new_select_ams += "]";
|
||||
print_job->task_ams_mapping = select_ams;
|
||||
print_job->task_ams_mapping_info = "";
|
||||
print_job->task_ams_mapping2 = new_select_ams;
|
||||
|
||||
if (calib_infos.size() == 1 && (calib_infos[0].select_ams == VIRTUAL_AMS_MAIN_ID_STR || calib_infos[0].select_ams == VIRTUAL_AMS_DEPUTY_ID_STR)) {
|
||||
print_job->task_use_ams = false;
|
||||
}
|
||||
else {
|
||||
print_job->task_use_ams = true;
|
||||
}
|
||||
|
||||
CalibMode cali_mode = calib_infos[0].params.mode;
|
||||
print_job->m_project_name = get_calib_mode_name(cali_mode, flow_ratio_mode);
|
||||
print_job->set_calibration_task(true);
|
||||
|
||||
print_job->has_sdcard = obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL;
|
||||
print_job->set_print_config(MachineBedTypeString[bed_type], true, true, false, false, true, 0, 1, 0);
|
||||
print_job->set_print_job_finished_event(wxGetApp().plater()->get_send_calibration_finished_event(), print_job->m_project_name);
|
||||
|
||||
{ // after send: record the print job
|
||||
json j;
|
||||
j["print"]["ams_mapping"] = print_job->task_ams_mapping;
|
||||
j["print"]["ams_mapping_2"] = print_job->task_ams_mapping2;
|
||||
j["print"]["project_name"] = print_job->m_project_name;
|
||||
j["print"]["is_cali_task"] = print_job->m_is_calibration_task;
|
||||
BOOST_LOG_TRIVIAL(info) << "send_cali_job - after send: " << j.dump();
|
||||
}
|
||||
|
||||
replace_job(*print_worker, std::move(print_job));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,11 @@ extern const float MAX_PA_K_VALUE;
|
|||
class CalibInfo
|
||||
{
|
||||
public:
|
||||
int index = -1;
|
||||
int extruder_id = 0;
|
||||
int ams_id = 0;
|
||||
int slot_id = 0;
|
||||
float nozzle_diameter;
|
||||
ExtruderType extruder_type{ExtruderType::etDirectDrive};
|
||||
NozzleVolumeType nozzle_volume_type;
|
||||
Calib_Params params;
|
||||
|
|
@ -26,6 +28,7 @@ public:
|
|||
Preset* filament_prest;
|
||||
Preset* print_prest;
|
||||
BedType bed_type;
|
||||
std::string filament_color;
|
||||
std::string dev_id;
|
||||
std::string select_ams;
|
||||
std::shared_ptr<ProgressIndicator> process_bar;
|
||||
|
|
@ -58,6 +61,9 @@ public:
|
|||
|
||||
static void calib_pa_pattern(const CalibInfo &calib_info, Model &model);
|
||||
|
||||
static void set_for_auto_pa_model_and_config(const std::vector<CalibInfo> &calib_info, DynamicPrintConfig &full_config, Model &model);
|
||||
|
||||
static bool calib_generic_auto_pa_cali(const std::vector<CalibInfo> &calib_info, wxString & error_message);
|
||||
static bool calib_generic_PA(const CalibInfo &calib_info, wxString &error_message);
|
||||
static void calib_temptue(const CalibInfo &calib_info, wxString &error_message);
|
||||
static void calib_max_vol_speed(const CalibInfo &calib_info, wxString &error_message);
|
||||
|
|
@ -76,10 +82,12 @@ public:
|
|||
|
||||
static bool check_printable_status_before_cali(const MachineObject *obj, const X1CCalibInfos &cali_infos, wxString &error_message);
|
||||
static bool check_printable_status_before_cali(const MachineObject *obj, const CalibInfo &cali_info, wxString &error_message);
|
||||
static bool check_printable_status_before_cali(const MachineObject *obj, const std::vector<CalibInfo> &cali_infos, wxString &error_message);
|
||||
|
||||
private:
|
||||
static bool process_and_store_3mf(Model* model, const DynamicPrintConfig& full_config, const Calib_Params& params, wxString& error_message);
|
||||
static void send_to_print(const CalibInfo &calib_info, wxString& error_message, int flow_ratio_mode = 0); // 0: none 1: coarse 2: fine
|
||||
static void send_to_print(const std::vector<CalibInfo> &calib_infos, wxString &error_message, int flow_ratio_mode = 0); // 0: none 1: coarse 2: fine
|
||||
};
|
||||
|
||||
extern void get_tray_ams_and_slot_id(MachineObject* obj, int in_tray_id, int &ams_id, int &slot_id, int &tray_id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue