mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-08-19 06:35:56 +08:00
ENH: calib support multi_extruder
1. backend support multi_extrude data structure 2. Compatible with third-party calibration 3. fix bug when get extruder in gocde export process Change-Id: I5dac9abdd9907a521a1ba9b480f9e05640591bc1
This commit is contained in:
parent
0924fce685
commit
21e6271e59
@ -6,13 +6,12 @@
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
float CalibPressureAdvance::find_optimal_PA_speed(const DynamicPrintConfig &config, double line_width, double layer_height, int filament_idx)
|
||||
float CalibPressureAdvance::find_optimal_PA_speed(const DynamicPrintConfig &config, double line_width, double layer_height, int extruder_id, int filament_idx)
|
||||
{
|
||||
const double general_suggested_min_speed = 100.0;
|
||||
double filament_max_volumetric_speed = config.option<ConfigOptionFloats>("filament_max_volumetric_speed")->get_at(filament_idx);
|
||||
// todo multi_extruders:
|
||||
Flow pattern_line = Flow(line_width, layer_height, config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0/*get_extruder_index(filament_idx)*/));
|
||||
auto pa_speed = std::min(std::max(general_suggested_min_speed, config.option<ConfigOptionFloatsNullable>("outer_wall_speed")->get_at(0/*get_extruder_index(filament_idx)*/)),
|
||||
Flow pattern_line = Flow(line_width, layer_height, config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(extruder_id));
|
||||
auto pa_speed = std::min(std::max(general_suggested_min_speed, config.option<ConfigOptionFloatsNullable>("outer_wall_speed")->get_at(extruder_id)),
|
||||
filament_max_volumetric_speed / pattern_line.mm3_per_mm());
|
||||
|
||||
return std::floor(pa_speed);
|
||||
|
@ -35,6 +35,7 @@ enum class CalibState {
|
||||
struct Calib_Params
|
||||
{
|
||||
Calib_Params() : mode(CalibMode::Calib_None){}
|
||||
int extruder_id = 0;
|
||||
double start, end, step;
|
||||
bool print_numbers = false;
|
||||
CalibMode mode;
|
||||
@ -50,8 +51,12 @@ class X1CCalibInfos
|
||||
public:
|
||||
struct X1CCalibInfo
|
||||
{
|
||||
int extruder_id = -1;
|
||||
int tray_id;
|
||||
int ams_id = 0;
|
||||
int slot_id = 0;
|
||||
int bed_temp;
|
||||
NozzleVolumeType nozzle_volume_type = NozzleVolumeType::nvtNormal;
|
||||
int nozzle_temp;
|
||||
float nozzle_diameter;
|
||||
std::string filament_id;
|
||||
@ -100,7 +105,11 @@ public:
|
||||
CALI_RESULT_PROBLEM = 1,
|
||||
CALI_RESULT_FAILED = 2,
|
||||
};
|
||||
int tray_id;
|
||||
int extruder_id = -1;
|
||||
NozzleVolumeType nozzle_volume_type;
|
||||
int tray_id = 0;
|
||||
int ams_id = 0;
|
||||
int slot_id = 0;
|
||||
int cali_idx = -1;
|
||||
float nozzle_diameter;
|
||||
std::string filament_id;
|
||||
@ -113,12 +122,31 @@ public:
|
||||
|
||||
struct PACalibIndexInfo
|
||||
{
|
||||
int tray_id;
|
||||
int extruder_id = -1;
|
||||
NozzleVolumeType nozzle_volume_type;
|
||||
int tray_id = 0;
|
||||
int ams_id = 0;
|
||||
int slot_id = 0;
|
||||
int cali_idx;
|
||||
float nozzle_diameter;
|
||||
std::string filament_id;
|
||||
};
|
||||
|
||||
struct PACalibExtruderInfo
|
||||
{
|
||||
int extruder_id;
|
||||
NozzleVolumeType nozzle_volume_type;
|
||||
float nozzle_diameter;
|
||||
std::string filament_id = "";
|
||||
};
|
||||
|
||||
struct PACalibTabInfo
|
||||
{
|
||||
float pa_calib_tab_nozzle_dia;
|
||||
int extruder_id;
|
||||
NozzleVolumeType nozzle_volume_type;
|
||||
};
|
||||
|
||||
class FlowRatioCalibResult
|
||||
{
|
||||
public:
|
||||
@ -144,7 +172,7 @@ struct DrawBoxOptArgs
|
||||
class CalibPressureAdvance
|
||||
{
|
||||
public:
|
||||
static float find_optimal_PA_speed(const DynamicPrintConfig &config, double line_width, double layer_height, int filament_idx = 0);
|
||||
static float find_optimal_PA_speed(const DynamicPrintConfig &config, double line_width, double layer_height, int extruder_id = 0, int filament_idx = 0);
|
||||
|
||||
protected:
|
||||
CalibPressureAdvance() = default;
|
||||
@ -251,9 +279,8 @@ public:
|
||||
Vec3d get_start_offset();
|
||||
|
||||
protected:
|
||||
// todo multi_extruders:
|
||||
double speed_first_layer() const { return m_config.option<ConfigOptionFloatsNullable>("initial_layer_speed")->get_at(0/*get_extruder_index(m_writer.extruder()->id())*/); };
|
||||
double speed_perimeter() const { return m_config.option<ConfigOptionFloatsNullable>("outer_wall_speed")->get_at(0/*get_extruder_index(m_writer.extruder()->id())*/); };
|
||||
double speed_first_layer() const { return m_config.option<ConfigOptionFloatsNullable>("initial_layer_speed")->get_at(m_params.extruder_id); };
|
||||
double speed_perimeter() const { return m_config.option<ConfigOptionFloatsNullable>("outer_wall_speed")->get_at(m_params.extruder_id); };
|
||||
double line_width_first_layer() const { return m_config.get_abs_value("initial_layer_line_width"); };
|
||||
double line_width() const { return m_config.get_abs_value("line_width"); };
|
||||
int wall_count() const { return m_config.option<ConfigOptionInt>("wall_loops")->value; };
|
||||
|
@ -2591,7 +2591,7 @@ static bool custom_gcode_sets_temperature(const std::string &gcode, const int mc
|
||||
// Do not process this piece of G-code by the time estimator, it already knows the values through another sources.
|
||||
void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print, int extruder_id)
|
||||
{
|
||||
int matched_machine_limit_idx = extruder_id * 2;
|
||||
int matched_machine_limit_idx = get_extruder_id(extruder_id) * 2;
|
||||
if (print.config().gcode_flavor.value == gcfMarlinLegacy || print.config().gcode_flavor.value == gcfMarlinFirmware) {
|
||||
file.write_format("M201 X%d Y%d Z%d E%d\n",
|
||||
int(print.config().machine_max_acceleration_x.values[matched_machine_limit_idx] + 0.5),
|
||||
|
@ -1196,7 +1196,7 @@ void ToolOrdering::reorder_extruders_for_minimum_flush_volume()
|
||||
return;
|
||||
|
||||
size_t nozzle_nums = print_config->nozzle_diameter.values.size();
|
||||
if (nozzle_nums > 1) {
|
||||
if (nozzle_nums > 1 && print_config->option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode")->value == FilamentMapMode::fmmAuto) {
|
||||
std::vector<int> filament_maps = m_print->get_filament_maps();
|
||||
|
||||
if (print_config->print_sequence != PrintSequence::ByObject) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
|
||||
|
||||
#define HISTORY_WINDOW_SIZE wxSize(FromDIP(700), FromDIP(600))
|
||||
#define EDIT_HISTORY_DIALOG_INPUT_SIZE wxSize(FromDIP(160), FromDIP(24))
|
||||
#define NEW_HISTORY_DIALOG_INPUT_SIZE wxSize(FromDIP(250), FromDIP(24))
|
||||
@ -216,20 +216,22 @@ void HistoryWindow::update(MachineObject* obj)
|
||||
void HistoryWindow::on_select_nozzle(wxCommandEvent& evt)
|
||||
{
|
||||
reqeust_history_result(curr_obj);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void HistoryWindow::reqeust_history_result(MachineObject* obj)
|
||||
{
|
||||
if (curr_obj) {
|
||||
// reset
|
||||
// reset
|
||||
curr_obj->reset_pa_cali_history_result();
|
||||
m_calib_results_history.clear();
|
||||
sync_history_data();
|
||||
|
||||
float nozzle_value = get_nozzle_value();
|
||||
if (nozzle_value > 0) {
|
||||
CalibUtils::emit_get_PA_calib_infos(nozzle_value);
|
||||
PACalibExtruderInfo cali_info;
|
||||
cali_info.nozzle_diameter = nozzle_value;
|
||||
CalibUtils::emit_get_PA_calib_infos(cali_info);
|
||||
m_tips->SetLabel(_L("Refreshing the historical Flow Dynamics Calibration records"));
|
||||
BOOST_LOG_TRIVIAL(info) << "request calib history";
|
||||
}
|
||||
@ -315,7 +317,12 @@ void HistoryWindow::sync_history_data() {
|
||||
gbSizer->SetEmptyCellSize({ 0,0 });
|
||||
m_history_data_panel->Layout();
|
||||
m_history_data_panel->Fit();
|
||||
CalibUtils::delete_PA_calib_result({ result.tray_id, result.cali_idx, result.nozzle_diameter, result.filament_id });
|
||||
PACalibIndexInfo cali_info;
|
||||
cali_info.tray_id = result.tray_id;
|
||||
cali_info.cali_idx = result.cali_idx;
|
||||
cali_info.nozzle_diameter = result.nozzle_diameter;
|
||||
cali_info.filament_id = result.filament_id;
|
||||
CalibUtils::delete_PA_calib_result(cali_info);
|
||||
});
|
||||
|
||||
auto edit_button = new Button(m_history_data_panel, _L("Edit"));
|
||||
@ -480,7 +487,7 @@ void EditCalibrationHistoryDialog::on_save(wxCommandEvent& event) {
|
||||
return;
|
||||
|
||||
m_new_result.name = m_name_value->GetTextCtrl()->GetValue().ToUTF8().data();
|
||||
|
||||
|
||||
float k = 0.0f;
|
||||
if (!CalibUtils::validate_input_k_value(m_k_value->GetTextCtrl()->GetValue(), &k)) {
|
||||
MessageDialog msg_dlg(nullptr, wxString::Format(_L("Please input a valid value (K in %.1f~%.1f)"), MIN_PA_K_VALUE, MAX_PA_K_VALUE), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
@ -632,7 +639,7 @@ NewCalibrationHistoryDialog::NewCalibrationHistoryDialog(wxWindow *parent, const
|
||||
m_comboBox_nozzle_diameter->SetSelection(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Nozzle Diameter
|
||||
flex_sizer->Add(nozzle_diameter_title);
|
||||
flex_sizer->Add(m_comboBox_nozzle_diameter);
|
||||
@ -640,7 +647,7 @@ NewCalibrationHistoryDialog::NewCalibrationHistoryDialog(wxWindow *parent, const
|
||||
Label *k_title = new Label(top_panel, _L("Factor K"));
|
||||
auto k_str = wxString::Format("%.3f", m_new_result.k_value);
|
||||
m_k_value = new TextInput(top_panel, k_str, "", "", wxDefaultPosition, NEW_HISTORY_DIALOG_INPUT_SIZE, wxTE_PROCESS_ENTER);
|
||||
|
||||
|
||||
// Factor K
|
||||
flex_sizer->Add(k_title);
|
||||
flex_sizer->Add(m_k_value);
|
||||
@ -715,7 +722,7 @@ void NewCalibrationHistoryDialog::on_ok(wxCommandEvent &event)
|
||||
m_new_result.k_value = k;
|
||||
m_new_result.tray_id = -1;
|
||||
m_new_result.cali_idx = -1;
|
||||
|
||||
|
||||
m_new_result.nozzle_diameter = nozzle_value;
|
||||
m_new_result.filament_id = filament_id;
|
||||
m_new_result.setting_id = setting_id;
|
||||
|
@ -47,7 +47,7 @@ bool is_pa_params_valid(const Calib_Params& params)
|
||||
}
|
||||
|
||||
CalibrationWizard::CalibrationWizard(wxWindow* parent, CalibMode mode, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
|
||||
: wxPanel(parent, id, pos, size, style)
|
||||
: wxPanel(parent, id, pos, size, style)
|
||||
, m_mode(mode)
|
||||
{
|
||||
SetBackgroundColour(wxColour(0xEEEEEE));
|
||||
@ -59,8 +59,8 @@ CalibrationWizard::CalibrationWizard(wxWindow* parent, CalibMode mode, wxWindowI
|
||||
m_scrolledWindow->SetBackgroundColour(*wxWHITE);
|
||||
|
||||
wxBoxSizer* padding_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
padding_sizer->Add(0, 0, 1);
|
||||
|
||||
padding_sizer->Add(0, 0, 1);
|
||||
|
||||
m_all_pages_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
padding_sizer->Add(m_all_pages_sizer, 0);
|
||||
|
||||
@ -321,7 +321,7 @@ void CalibrationWizard::back_preset_info(MachineObject *obj, bool cali_finish, b
|
||||
wxGetApp().app_config->save_printer_cali_infos(printer_cali_info, back_cali_flag);
|
||||
}
|
||||
|
||||
void CalibrationWizard::msw_rescale()
|
||||
void CalibrationWizard::msw_rescale()
|
||||
{
|
||||
for (int i = 0; i < m_page_steps.size(); i++) {
|
||||
if (m_page_steps[i]->page)
|
||||
@ -403,7 +403,7 @@ void PressureAdvanceWizard::create_pages()
|
||||
preset_step = new CalibrationWizardPageStep(new CalibrationPresetPage(m_scrolledWindow, m_mode, false));
|
||||
cali_step = new CalibrationWizardPageStep(new CalibrationCaliPage(m_scrolledWindow, m_mode));
|
||||
save_step = new CalibrationWizardPageStep(new CalibrationPASavePage(m_scrolledWindow));
|
||||
|
||||
|
||||
m_all_pages_sizer->Add(start_step->page, 1, wxEXPAND | wxALL, FromDIP(25));
|
||||
m_all_pages_sizer->Add(preset_step->page, 1, wxEXPAND | wxALL, FromDIP(25));
|
||||
m_all_pages_sizer->Add(cali_step->page, 1, wxEXPAND | wxALL, FromDIP(25));
|
||||
@ -478,7 +478,9 @@ void PressureAdvanceWizard::update(MachineObject* obj)
|
||||
if (!m_show_result_dialog) {
|
||||
if (obj->cali_version != -1 && obj->cali_version != cali_version) {
|
||||
cali_version = obj->cali_version;
|
||||
CalibUtils::emit_get_PA_calib_info(obj->nozzle_diameter, "");
|
||||
PACalibExtruderInfo cali_info;
|
||||
cali_info.nozzle_diameter = obj->nozzle_diameter;
|
||||
CalibUtils::emit_get_PA_calib_info(cali_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -621,7 +623,7 @@ void PressureAdvanceWizard::on_cali_start()
|
||||
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) + "]";
|
||||
@ -657,10 +659,10 @@ void PressureAdvanceWizard::on_cali_start()
|
||||
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;
|
||||
|
||||
|
||||
if (curr_obj->get_printer_series() != PrinterSeries::SERIES_X1 && curr_obj->pa_calib_tab.size() >= MAX_PA_HISTORY_RESULTS_NUMS) {
|
||||
MessageDialog msg_dlg(nullptr, wxString::Format(_L("This machine type can only hold 16 history results per nozzle. "
|
||||
"You can delete the existing historical results and then start calibration. "
|
||||
@ -741,7 +743,7 @@ void PressureAdvanceWizard::on_cali_save()
|
||||
auto iter = std::find_if(curr_obj->pa_calib_tab.begin(), curr_obj->pa_calib_tab.end(), [&new_pa_cali_result](const PACalibResult &item) {
|
||||
return item.name == new_pa_cali_result.name && item.filament_id == item.filament_id;
|
||||
});
|
||||
|
||||
|
||||
if (iter != curr_obj->pa_calib_tab.end()) {
|
||||
MessageDialog
|
||||
msg_dlg(nullptr,
|
||||
@ -820,7 +822,7 @@ void FlowRateWizard::create_pages()
|
||||
coarse_save_step = new CalibrationWizardPageStep(new CalibrationFlowCoarseSavePage(m_scrolledWindow));
|
||||
cali_fine_step = new CalibrationWizardPageStep(new CalibrationCaliPage(m_scrolledWindow, m_mode, CaliPageType::CALI_PAGE_FINE_CALI));
|
||||
fine_save_step = new CalibrationWizardPageStep(new CalibrationFlowFineSavePage(m_scrolledWindow));
|
||||
|
||||
|
||||
// auto
|
||||
cali_step = new CalibrationWizardPageStep(new CalibrationCaliPage(m_scrolledWindow, m_mode));
|
||||
save_step = new CalibrationWizardPageStep(new CalibrationFlowX1SavePage(m_scrolledWindow));
|
||||
@ -898,7 +900,7 @@ void FlowRateWizard::on_cali_action(wxCommandEvent& evt)
|
||||
else if (action == CaliPageActionType::CALI_ACTION_CALI) {
|
||||
if (m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) {
|
||||
on_cali_start();
|
||||
}
|
||||
}
|
||||
else if (m_cali_method == CalibrationMethod::CALI_METHOD_MANUAL) {
|
||||
CaliPresetStage stage = CaliPresetStage::CALI_MANULA_STAGE_NONE;
|
||||
float cali_value = 0.0f;
|
||||
@ -909,7 +911,7 @@ void FlowRateWizard::on_cali_action(wxCommandEvent& evt)
|
||||
m_curr_step->chain(cali_fine_step);
|
||||
}
|
||||
// automatically jump to next step when print job is sending finished.
|
||||
}
|
||||
}
|
||||
else {
|
||||
on_cali_start();
|
||||
}
|
||||
@ -1308,7 +1310,7 @@ void FlowRateWizard::cache_coarse_info(MachineObject *obj)
|
||||
|
||||
wxString out_name;
|
||||
coarse_page->get_result(&obj->cache_flow_ratio, &out_name);
|
||||
|
||||
|
||||
back_preset_info(obj, false);
|
||||
}
|
||||
|
||||
@ -1318,7 +1320,7 @@ MaxVolumetricSpeedWizard::MaxVolumetricSpeedWizard(wxWindow* parent, wxWindowID
|
||||
create_pages();
|
||||
}
|
||||
|
||||
void MaxVolumetricSpeedWizard::create_pages()
|
||||
void MaxVolumetricSpeedWizard::create_pages()
|
||||
{
|
||||
start_step = new CalibrationWizardPageStep(new CalibrationMaxVolumetricSpeedStartPage(m_scrolledWindow));
|
||||
preset_step = new CalibrationWizardPageStep(new MaxVolumetricSpeedPresetPage(m_scrolledWindow, m_mode, true));
|
||||
|
@ -1098,7 +1098,7 @@ bool MachineObject::is_valid_mapping_result(std::vector<FilamentInfo>& result, b
|
||||
else {
|
||||
auto ams_item = amsList.find(result[i].ams_id);
|
||||
if (ams_item == amsList.end()) {
|
||||
if ( (result[i].ams_id != std::to_string(VIRTUAL_TRAY_MAIN_ID)) &&
|
||||
if ( (result[i].ams_id != std::to_string(VIRTUAL_TRAY_MAIN_ID)) &&
|
||||
(result[i].ams_id != std::to_string(VIRTUAL_TRAY_DEPUTY_ID))) {
|
||||
result[i].tray_id = -1;
|
||||
valid_ams_mapping_result = false;
|
||||
@ -2236,6 +2236,10 @@ int MachineObject::command_start_pa_calibration(const X1CCalibInfos &pa_data, in
|
||||
j["print"]["filaments"][i]["filament_id"] = pa_data.calib_datas[i].filament_id;
|
||||
j["print"]["filaments"][i]["setting_id"] = pa_data.calib_datas[i].setting_id;
|
||||
j["print"]["filaments"][i]["nozzle_temp"] = pa_data.calib_datas[i].nozzle_temp;
|
||||
j["print"]["filaments"][i]["ams_id"] = pa_data.calib_datas[i].ams_id;
|
||||
j["print"]["filaments"][i]["slot_id"] = pa_data.calib_datas[i].slot_id;
|
||||
j["print"]["filaments"][i]["nozzle_volume_type"] = int(pa_data.calib_datas[i].nozzle_volume_type);
|
||||
j["print"]["filaments"][i]["nozzle_diameter"] = pa_data.calib_datas[i].nozzle_diameter;
|
||||
j["print"]["filaments"][i]["max_volumetric_speed"] = std::to_string(pa_data.calib_datas[i].max_volumetric_speed);
|
||||
|
||||
if (i > 0) filament_ids += ",";
|
||||
@ -2273,6 +2277,10 @@ int MachineObject::command_set_pa_calibration(const std::vector<PACalibResult> &
|
||||
if (pa_calib_values[i].cali_idx >= 0)
|
||||
j["print"]["filaments"][i]["cali_idx"] = pa_calib_values[i].cali_idx;
|
||||
j["print"]["filaments"][i]["tray_id"] = pa_calib_values[i].tray_id;
|
||||
j["print"]["filaments"][i]["extruder_id"] = pa_calib_values[i].extruder_id;
|
||||
j["print"]["filaments"][i]["nozzle_volume_type"] = int(pa_calib_values[i].nozzle_volume_type);
|
||||
j["print"]["filaments"][i]["ams_id"] = pa_calib_values[i].ams_id;
|
||||
j["print"]["filaments"][i]["slot_id"] = pa_calib_values[i].slot_id;
|
||||
j["print"]["filaments"][i]["filament_id"] = pa_calib_values[i].filament_id;
|
||||
j["print"]["filaments"][i]["setting_id"] = pa_calib_values[i].setting_id;
|
||||
j["print"]["filaments"][i]["name"] = pa_calib_values[i].name;
|
||||
@ -2295,6 +2303,8 @@ int MachineObject::command_delete_pa_calibration(const PACalibIndexInfo& pa_cali
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_del";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["extruder_id"] = pa_calib.extruder_id;
|
||||
j["print"]["nozzle_volume_type"] = int(pa_calib.nozzle_volume_type);
|
||||
j["print"]["filament_id"] = pa_calib.filament_id;
|
||||
j["print"]["cali_idx"] = pa_calib.cali_idx;
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(pa_calib.nozzle_diameter);
|
||||
@ -2303,15 +2313,17 @@ int MachineObject::command_delete_pa_calibration(const PACalibIndexInfo& pa_cali
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_get_pa_calibration_tab(float nozzle_diameter, const std::string &filament_id)
|
||||
int MachineObject::command_get_pa_calibration_tab(const PACalibExtruderInfo &calib_info)
|
||||
{
|
||||
reset_pa_cali_history_result();
|
||||
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_get";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["filament_id"] = filament_id;
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter);
|
||||
j["print"]["filament_id"] = calib_info.filament_id;
|
||||
j["print"]["extruder_id"] = calib_info.extruder_id;
|
||||
j["print"]["nozzle_volume_type"] = int(calib_info.nozzle_volume_type);
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(calib_info.nozzle_diameter);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_get: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
@ -2334,6 +2346,8 @@ int MachineObject::commnad_select_pa_calibration(const PACalibIndexInfo& pa_cali
|
||||
j["print"]["command"] = "extrusion_cali_sel";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["tray_id"] = pa_calib_info.tray_id;
|
||||
j["print"]["ams_id"] = pa_calib_info.ams_id;
|
||||
j["print"]["slot_id"] = pa_calib_info.slot_id;
|
||||
j["print"]["cali_idx"] = pa_calib_info.cali_idx;
|
||||
j["print"]["filament_id"] = pa_calib_info.filament_id;
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(pa_calib_info.nozzle_diameter);
|
||||
@ -4032,7 +4046,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
||||
if (!it->contains("id")) continue;
|
||||
std::string ams_id = (*it)["id"].get<std::string>();
|
||||
|
||||
int nozzle_id = 0; // Default nozzle id
|
||||
int nozzle_id = 0; // Default nozzle id
|
||||
int type_id = 1; // 0:dummy 1:ams 2:ams-lite 3:n3f 4:n3s
|
||||
|
||||
if (it->contains("nozzle")) {
|
||||
@ -4042,7 +4056,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
||||
if (it->contains("type")) {
|
||||
type_id = (*it)["type"].get<int>();
|
||||
}
|
||||
|
||||
|
||||
ams_id_set.erase(ams_id);
|
||||
Ams* curr_ams = nullptr;
|
||||
auto ams_it = amsList.find(ams_id);
|
||||
@ -4311,7 +4325,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
||||
}
|
||||
else {
|
||||
vt_slot.push_back(vslot);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (vslot.id == std::to_string(VIRTUAL_TRAY_DEPUTY_ID)) {
|
||||
auto it = std::next(vt_slot.begin(), 1);
|
||||
@ -4647,10 +4661,10 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
||||
|
||||
if (jj.contains("nozzle_diameter")) {
|
||||
if (jj["nozzle_diameter"].is_number_float()) {
|
||||
pa_calib_tab_nozzle_dia = jj["nozzle_diameter"].get<float>();
|
||||
pa_calib_tab_info.pa_calib_tab_nozzle_dia = jj["nozzle_diameter"].get<float>();
|
||||
}
|
||||
else if (jj["nozzle_diameter"].is_string()) {
|
||||
pa_calib_tab_nozzle_dia = string_to_float(jj["nozzle_diameter"].get<std::string>());
|
||||
pa_calib_tab_info.pa_calib_tab_nozzle_dia = string_to_float(jj["nozzle_diameter"].get<std::string>());
|
||||
}
|
||||
else {
|
||||
assert(false);
|
||||
@ -4660,6 +4674,14 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
||||
assert(false);
|
||||
}
|
||||
|
||||
if (jj.contains("extruder_id")) {
|
||||
pa_calib_tab_info.extruder_id = jj["extruder_id"].get<int>();
|
||||
}
|
||||
|
||||
if (jj.contains("nozzle_volume_type")) {
|
||||
pa_calib_tab_info.nozzle_volume_type = NozzleVolumeType(jj["nozzle_volume_type"].get<int>());
|
||||
}
|
||||
|
||||
if (jj.contains("filaments") && jj["filaments"].is_array()) {
|
||||
try {
|
||||
for (auto it = jj["filaments"].begin(); it != jj["filaments"].end(); it++) {
|
||||
@ -4731,6 +4753,30 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
||||
pa_calib_result.nozzle_diameter = string_to_float(jj["nozzle_diameter"].get<std::string>());
|
||||
}
|
||||
|
||||
if (it->contains("ams_id")) {
|
||||
pa_calib_result.ams_id = (*it)["ams_id"].get<int>();
|
||||
} else {
|
||||
pa_calib_result.ams_id = 0;
|
||||
}
|
||||
|
||||
if (it->contains("slot_id")) {
|
||||
pa_calib_result.slot_id = (*it)["slot_id"].get<int>();
|
||||
} else {
|
||||
pa_calib_result.slot_id = 0;
|
||||
}
|
||||
|
||||
if (it->contains("extruder_id")) {
|
||||
pa_calib_result.extruder_id = (*it)["extruder_id"].get<int>();
|
||||
} else {
|
||||
pa_calib_result.extruder_id = -1;
|
||||
}
|
||||
|
||||
if (it->contains("nozzle_volume_type")) {
|
||||
pa_calib_result.nozzle_volume_type = NozzleVolumeType((*it)["nozzle_volume_type"].get<int>());
|
||||
} else {
|
||||
pa_calib_result.nozzle_volume_type = NozzleVolumeType::nvtNormal;
|
||||
}
|
||||
|
||||
if ((*it)["k_value"].is_number_float())
|
||||
pa_calib_result.k_value = (*it)["k_value"].get<float>();
|
||||
else if ((*it)["k_value"].is_string())
|
||||
@ -4803,7 +4849,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
||||
|
||||
if (jj.contains("device")) {
|
||||
json const & device = jj["device"];
|
||||
|
||||
|
||||
if (device.contains("nozzle")) {
|
||||
json const & nozzle = device["nozzle"];
|
||||
|
||||
@ -5413,7 +5459,7 @@ AmsTray MachineObject::parse_vt_tray(json vtray)
|
||||
vt_tray.remain = -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return vt_tray;
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ public:
|
||||
return wxColour(ret[0], ret[1], ret[2], ret[3]);
|
||||
}
|
||||
|
||||
std::string id;
|
||||
std::string id;
|
||||
std::string tag_uid; // tag_uid
|
||||
std::string setting_id; // tray_info_idx
|
||||
std::string filament_setting_id; // setting_id
|
||||
@ -407,8 +407,8 @@ public:
|
||||
};
|
||||
|
||||
enum ActiveState {
|
||||
NotActive,
|
||||
Active,
|
||||
NotActive,
|
||||
Active,
|
||||
UpdateToDate
|
||||
};
|
||||
|
||||
@ -474,7 +474,7 @@ public:
|
||||
std::string product_name; // set by iot service, get /user/print
|
||||
|
||||
std::vector<int> filam_bak;
|
||||
|
||||
|
||||
|
||||
std::string bind_user_name;
|
||||
std::string bind_user_id;
|
||||
@ -660,14 +660,16 @@ public:
|
||||
ManualPaCaliMethod manual_pa_cali_method = ManualPaCaliMethod::PA_LINE;
|
||||
bool has_get_pa_calib_tab{ false };
|
||||
std::vector<PACalibResult> pa_calib_tab;
|
||||
float pa_calib_tab_nozzle_dia;
|
||||
PACalibTabInfo pa_calib_tab_info;
|
||||
bool get_pa_calib_result { false };
|
||||
std::vector<PACalibResult> pa_calib_results;
|
||||
bool get_flow_calib_result { false };
|
||||
std::vector<FlowRatioCalibResult> flow_ratio_results;
|
||||
void reset_pa_cali_history_result()
|
||||
{
|
||||
pa_calib_tab_nozzle_dia = 0.4f;
|
||||
pa_calib_tab_info.pa_calib_tab_nozzle_dia = 0.4f;
|
||||
pa_calib_tab_info.extruder_id = -1;
|
||||
pa_calib_tab_info.nozzle_volume_type = NozzleVolumeType::nvtNormal;
|
||||
has_get_pa_calib_tab = false;
|
||||
pa_calib_tab.clear();
|
||||
}
|
||||
@ -729,7 +731,7 @@ public:
|
||||
enum LiveviewLocal {
|
||||
LVL_None,
|
||||
LVL_Disable,
|
||||
LVL_Local,
|
||||
LVL_Local,
|
||||
LVL_Rtsps,
|
||||
LVL_Rtsp
|
||||
} liveview_local{ LVL_None };
|
||||
@ -841,7 +843,7 @@ public:
|
||||
RatingInfo* rating_info { nullptr };
|
||||
int request_model_result = 0;
|
||||
bool get_model_mall_result_need_retry = false;
|
||||
|
||||
|
||||
std::string obj_subtask_id; // subtask_id == 0 for sdcard
|
||||
std::string subtask_name;
|
||||
bool is_sdcard_printing();
|
||||
@ -930,7 +932,7 @@ public:
|
||||
int command_start_pa_calibration(const X1CCalibInfos& pa_data, int mode = 0); // 0: automatic mode; 1: manual mode. default: automatic mode
|
||||
int command_set_pa_calibration(const std::vector<PACalibResult>& pa_calib_values, bool is_auto_cali);
|
||||
int command_delete_pa_calibration(const PACalibIndexInfo& pa_calib);
|
||||
int command_get_pa_calibration_tab(float nozzle_diameter, const std::string &filament_id = "");
|
||||
int command_get_pa_calibration_tab(const PACalibExtruderInfo& calib_info);
|
||||
int command_get_pa_calibration_result(float nozzle_diameter);
|
||||
int commnad_select_pa_calibration(const PACalibIndexInfo& pa_calib_info);
|
||||
|
||||
|
@ -9933,7 +9933,7 @@ void Plater::_calib_pa_pattern(const Calib_Params ¶ms)
|
||||
print_config.set_key_value("outer_wall_speed",
|
||||
new ConfigOptionFloat(CalibPressureAdvance::find_optimal_PA_speed(
|
||||
wxGetApp().preset_bundle->full_config(), print_config.get_abs_value("line_width"),
|
||||
print_config.get_abs_value("layer_height"), 0)));
|
||||
print_config.get_abs_value("layer_height"), 0, 0)));
|
||||
|
||||
for (const auto opt : SuggestedConfigCalibPAPattern().nozzle_ratio_pairs) {
|
||||
print_config.set_key_value(opt.first, new ConfigOptionFloat(nozzle_diameter * opt.second / 100));
|
||||
@ -9988,7 +9988,7 @@ void Plater::_calib_pa_tower(const Calib_Params ¶ms)
|
||||
//print_config->set_key_value("inner_wall_jerk", new ConfigOptionFloat(1.0f));
|
||||
auto full_config = wxGetApp().preset_bundle->full_config();
|
||||
auto wall_speed = CalibPressureAdvance::find_optimal_PA_speed(full_config, full_config.get_abs_value("line_width"),
|
||||
full_config.get_abs_value("layer_height"), 0);
|
||||
full_config.get_abs_value("layer_height"), 0, 0);
|
||||
print_config->set_key_value("outer_wall_speed", new ConfigOptionFloat(wall_speed));
|
||||
print_config->set_key_value("inner_wall_speed", new ConfigOptionFloat(wall_speed));
|
||||
// print_config->set_key_value("wall_generator", new ConfigOptionEnum<PerimeterGeneratorType>(PerimeterGeneratorType::Classic));
|
||||
|
@ -2575,7 +2575,9 @@ void StatusPanel::update_ams(MachineObject *obj)
|
||||
|
||||
if (obj && (obj->last_cali_version != obj->cali_version)) {
|
||||
last_cali_version = obj->cali_version;
|
||||
CalibUtils::emit_get_PA_calib_info(obj->nozzle_diameter, "");
|
||||
PACalibExtruderInfo cali_info;
|
||||
cali_info.nozzle_diameter = obj->nozzle_diameter;
|
||||
CalibUtils::emit_get_PA_calib_info(cali_info);
|
||||
}
|
||||
|
||||
bool is_support_virtual_tray = obj->ams_support_virtual_tray;
|
||||
@ -3782,7 +3784,7 @@ void StatusPanel::on_ext_spool_edit(wxCommandEvent &event)
|
||||
else {
|
||||
m_filament_setting_dlg->set_color(color);
|
||||
}
|
||||
|
||||
|
||||
m_filament_setting_dlg->m_is_third = !MachineObject::is_bbl_filament(obj->vt_slot[0].tag_uid);
|
||||
if (!m_filament_setting_dlg->m_is_third) {
|
||||
sn_number = obj->vt_slot[0].uuid;
|
||||
|
@ -379,7 +379,7 @@ bool CalibUtils::get_PA_calib_results(std::vector<PACalibResult>& pa_calib_resul
|
||||
return pa_calib_results.size() > 0;
|
||||
}
|
||||
|
||||
void CalibUtils::emit_get_PA_calib_infos(float nozzle_diameter)
|
||||
void CalibUtils::emit_get_PA_calib_infos(const PACalibExtruderInfo &cali_info)
|
||||
{
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev)
|
||||
@ -389,7 +389,7 @@ void CalibUtils::emit_get_PA_calib_infos(float nozzle_diameter)
|
||||
if (obj_ == nullptr)
|
||||
return;
|
||||
|
||||
obj_->command_get_pa_calibration_tab(nozzle_diameter);
|
||||
obj_->command_get_pa_calibration_tab(cali_info);
|
||||
}
|
||||
|
||||
bool CalibUtils::get_PA_calib_tab(std::vector<PACalibResult> &pa_calib_infos)
|
||||
@ -408,7 +408,7 @@ bool CalibUtils::get_PA_calib_tab(std::vector<PACalibResult> &pa_calib_infos)
|
||||
return obj_->has_get_pa_calib_tab;
|
||||
}
|
||||
|
||||
void CalibUtils::emit_get_PA_calib_info(float nozzle_diameter, const std::string &filament_id)
|
||||
void CalibUtils::emit_get_PA_calib_info(const PACalibExtruderInfo &cali_info)
|
||||
{
|
||||
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
|
||||
if (!dev) return;
|
||||
@ -416,7 +416,7 @@ void CalibUtils::emit_get_PA_calib_info(float nozzle_diameter, const std::string
|
||||
MachineObject *obj_ = dev->get_selected_machine();
|
||||
if (obj_ == nullptr) return;
|
||||
|
||||
obj_->command_get_pa_calibration_tab(nozzle_diameter, filament_id);
|
||||
obj_->command_get_pa_calibration_tab(cali_info);
|
||||
}
|
||||
|
||||
bool CalibUtils::get_PA_calib_info(PACalibResult & pa_calib_info) {
|
||||
@ -558,8 +558,8 @@ bool CalibUtils::calib_flowrate(int pass, const CalibInfo &calib_info, wxString
|
||||
double filament_max_volumetric_speed = filament_config.option<ConfigOptionFloats>("filament_max_volumetric_speed")->get_at(0);
|
||||
double max_infill_speed = filament_max_volumetric_speed / (infill_flow.mm3_per_mm() * (pass == 1 ? 1.2 : 1));
|
||||
// todo multi_extruders:
|
||||
double internal_solid_speed = std::floor(std::min(print_config.opt_float("internal_solid_infill_speed", 0/*get_extruder_index(stoi(calib_info.filament_prest->filament_id))*/), max_infill_speed));
|
||||
double top_surface_speed = std::floor(std::min(print_config.opt_float("top_surface_speed", 0/*get_extruder_index(stoi(calib_info.filament_prest->filament_id))*/), max_infill_speed));
|
||||
double internal_solid_speed = std::floor(std::min(print_config.opt_float("internal_solid_infill_speed", calib_info.extruder_id), max_infill_speed));
|
||||
double top_surface_speed = std::floor(std::min(print_config.opt_float("top_surface_speed", calib_info.extruder_id), max_infill_speed));
|
||||
|
||||
// adjust parameters
|
||||
filament_config.set_key_value("curr_bed_type", new ConfigOptionEnum<BedType>(calib_info.bed_type));
|
||||
@ -660,7 +660,7 @@ void CalibUtils::calib_pa_pattern(const CalibInfo &calib_info, Model& model)
|
||||
print_config.set_key_value("outer_wall_speed",
|
||||
new ConfigOptionFloat(CalibPressureAdvance::find_optimal_PA_speed(
|
||||
full_config, print_config.get_abs_value("line_width"),
|
||||
print_config.get_abs_value("layer_height"), 0)));
|
||||
print_config.get_abs_value("layer_height"), calib_info.extruder_id, 0)));
|
||||
|
||||
for (const auto opt : SuggestedConfigCalibPAPattern().nozzle_ratio_pairs) {
|
||||
print_config.set_key_value(opt.first, new ConfigOptionFloat(nozzle_diameter * opt.second / 100));
|
||||
|
@ -15,6 +15,9 @@ extern const float MAX_PA_K_VALUE;
|
||||
class CalibInfo
|
||||
{
|
||||
public:
|
||||
int extruder_id = 0;
|
||||
int ams_id = 0;
|
||||
int slot_id = 0;
|
||||
Calib_Params params;
|
||||
Preset* printer_prest;
|
||||
Preset* filament_prest;
|
||||
@ -34,14 +37,14 @@ public:
|
||||
static CalibMode get_calib_mode_by_name(const std::string name, int &cali_stage);
|
||||
|
||||
static void calib_PA(const X1CCalibInfos& calib_infos, int mode, wxString& error_message);
|
||||
|
||||
|
||||
static void emit_get_PA_calib_results(float nozzle_diameter);
|
||||
static bool get_PA_calib_results(std::vector<PACalibResult> &pa_calib_results);
|
||||
|
||||
static void emit_get_PA_calib_infos(float nozzle_diameter);
|
||||
|
||||
static void emit_get_PA_calib_infos(const PACalibExtruderInfo &cali_info);
|
||||
static bool get_PA_calib_tab(std::vector<PACalibResult> &pa_calib_infos);
|
||||
|
||||
static void emit_get_PA_calib_info(float nozzle_diameter, const std::string &filament_id);
|
||||
static void emit_get_PA_calib_info(const PACalibExtruderInfo& cali_info);
|
||||
static bool get_PA_calib_info(PACalibResult &pa_calib_info);
|
||||
|
||||
static void set_PA_calib_result(const std::vector<PACalibResult>& pa_calib_values, bool is_auto_cali);
|
||||
|
Loading…
x
Reference in New Issue
Block a user