FIX: modify for virtual slot when multi_extruder

jira: none
Change-Id: Ic7284018ecb44e24536788b05dba572b96460e66
This commit is contained in:
zhimin.zeng 2024-08-26 15:16:15 +08:00 committed by lane.wei
parent fb72d19a44
commit 52e890fba1
4 changed files with 62 additions and 28 deletions

View File

@ -679,9 +679,14 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
; ;
} }
auto vt_tray = ams_id;
if (!obj->is_enable_np) {
vt_tray = VIRTUAL_TRAY_DEPUTY_ID;
}
if (obj->cali_version >= 0) { if (obj->cali_version >= 0) {
PACalibIndexInfo select_index_info; PACalibIndexInfo select_index_info;
select_index_info.tray_id = slot_id; select_index_info.tray_id = vt_tray;
select_index_info.nozzle_diameter = obj->m_nozzle_data.nozzles[0].diameter; select_index_info.nozzle_diameter = obj->m_nozzle_data.nozzles[0].diameter;
auto cali_select_id = m_comboBox_cali_result->GetSelection(); auto cali_select_id = m_comboBox_cali_result->GetSelection();
@ -697,7 +702,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
CalibUtils::select_PA_calib_result(select_index_info); CalibUtils::select_PA_calib_result(select_index_info);
} }
else { else {
obj->command_extrusion_cali_set(VIRTUAL_TRAY_MAIN_ID, "", "", k, n); obj->command_extrusion_cali_set(vt_tray, "", "", k, n);
} }
} }
else { else {
@ -1186,7 +1191,7 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
} }
m_comboBox_cali_result->Set(items); m_comboBox_cali_result->Set(items);
if (ams_id == VIRTUAL_TRAY_DEPUTY_ID) { if (ams_id == VIRTUAL_TRAY_MAIN_ID) {
cali_select_idx = CalibUtils::get_selected_calib_idx(m_pa_profile_items,this->obj->vt_slot[0].cali_idx); cali_select_idx = CalibUtils::get_selected_calib_idx(m_pa_profile_items,this->obj->vt_slot[0].cali_idx);
if (cali_select_idx >= 0) { if (cali_select_idx >= 0) {
m_comboBox_cali_result->SetSelection(cali_select_idx); m_comboBox_cali_result->SetSelection(cali_select_idx);

View File

@ -19,12 +19,6 @@ static const wxString NA_STR = _L("N/A");
static const float MIN_PA_K_VALUE_STEP = 0.001; static const float MIN_PA_K_VALUE_STEP = 0.001;
static const int MAX_PA_HISTORY_RESULTS_NUMS = 16; static const int MAX_PA_HISTORY_RESULTS_NUMS = 16;
void get_ams_id_and_slot_id(int tray_id, int& ams_id, int& slot_id)
{
ams_id = tray_id / 4;
slot_id = tray_id % 4;
}
std::map<int, Preset*> get_cached_selected_filament(MachineObject* obj) { std::map<int, Preset*> get_cached_selected_filament(MachineObject* obj) {
std::map<int, Preset*> selected_filament_map; std::map<int, Preset*> selected_filament_map;
if (!obj) return selected_filament_map; if (!obj) return selected_filament_map;
@ -110,6 +104,26 @@ CalibrationWizard::~CalibrationWizard()
; ;
} }
void CalibrationWizard::get_tray_ams_and_slot_id(int in_tray_id, int &ams_id, int &slot_id, int &tray_id)
{
assert(curr_obj);
if (!curr_obj)
return;
if (in_tray_id == VIRTUAL_TRAY_MAIN_ID || in_tray_id == VIRTUAL_TRAY_DEPUTY_ID) {
ams_id = in_tray_id;
slot_id = 0;
tray_id = ams_id;
if (!curr_obj->is_enable_np)
tray_id = VIRTUAL_TRAY_DEPUTY_ID;
}
else {
ams_id = in_tray_id / 4;
slot_id = in_tray_id % 4;
tray_id = in_tray_id;
}
}
void CalibrationWizard::on_cali_job_finished(wxCommandEvent& event) void CalibrationWizard::on_cali_job_finished(wxCommandEvent& event)
{ {
this->on_cali_job_finished(event.GetString()); this->on_cali_job_finished(event.GetString());
@ -598,11 +612,10 @@ void PressureAdvanceWizard::on_cali_start()
} }
X1CCalibInfos::X1CCalibInfo calib_info; X1CCalibInfos::X1CCalibInfo calib_info;
get_ams_id_and_slot_id(item.first, calib_info.ams_id, calib_info.slot_id); get_tray_ams_and_slot_id(item.first, calib_info.ams_id, calib_info.slot_id, calib_info.tray_id);
calib_info.extruder_id = preset_page->get_extruder_id(calib_info.ams_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.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.nozzle_volume_type = preset_page->get_nozzle_volume_type(calib_info.extruder_id);
calib_info.tray_id = item.first;
calib_info.nozzle_diameter = nozzle_dia; calib_info.nozzle_diameter = nozzle_dia;
calib_info.filament_id = item.second->filament_id; calib_info.filament_id = item.second->filament_id;
calib_info.setting_id = item.second->setting_id; calib_info.setting_id = item.second->setting_id;
@ -634,13 +647,14 @@ void PressureAdvanceWizard::on_cali_start()
return; return;
} }
int selected_tray_id = 0;
CalibInfo calib_info; CalibInfo calib_info;
calib_info.dev_id = curr_obj->dev_id; calib_info.dev_id = curr_obj->dev_id;
get_ams_id_and_slot_id(selected_filaments.begin()->first, calib_info.ams_id, calib_info.slot_id); get_tray_ams_and_slot_id(selected_filaments.begin()->first, calib_info.ams_id, calib_info.slot_id, selected_tray_id);
calib_info.extruder_id = preset_page->get_extruder_id(calib_info.ams_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.extruder_type = preset_page->get_extruder_type(calib_info.extruder_id);
calib_info.extruder_id = preset_page->get_nozzle_volume_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_filaments.begin()->first) + "]"; calib_info.select_ams = "[" + std::to_string(selected_tray_id) + "]";
Preset *preset = selected_filaments.begin()->second; Preset *preset = selected_filaments.begin()->second;
Preset * temp_filament_preset = new Preset(preset->type, preset->name + "_temp"); Preset * temp_filament_preset = new Preset(preset->type, preset->name + "_temp");
temp_filament_preset->config = preset->config; temp_filament_preset->config = preset->config;
@ -1006,10 +1020,10 @@ void FlowRateWizard::on_cali_start(CaliPresetStage stage, float cali_value, Flow
X1CCalibInfos::X1CCalibInfo calib_info; X1CCalibInfos::X1CCalibInfo calib_info;
calib_info.tray_id = item.first; calib_info.tray_id = item.first;
get_ams_id_and_slot_id(item.first, calib_info.ams_id, calib_info.slot_id); get_tray_ams_and_slot_id(item.first, calib_info.ams_id, calib_info.slot_id, calib_info.tray_id);
calib_info.extruder_id = preset_page->get_extruder_id(calib_info.ams_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.extruder_type = preset_page->get_extruder_type(calib_info.extruder_id);
calib_info.extruder_id = preset_page->get_nozzle_volume_type(calib_info.extruder_id); calib_info.nozzle_volume_type = preset_page->get_nozzle_volume_type(calib_info.extruder_id);
calib_info.nozzle_diameter = nozzle_dia; calib_info.nozzle_diameter = nozzle_dia;
calib_info.filament_id = item.second->filament_id; calib_info.filament_id = item.second->filament_id;
calib_info.setting_id = item.second->setting_id; calib_info.setting_id = item.second->setting_id;
@ -1060,8 +1074,9 @@ void FlowRateWizard::on_cali_start(CaliPresetStage stage, float cali_value, Flow
} }
if (!selected_filaments.empty()) { if (!selected_filaments.empty()) {
calib_info.select_ams = "[" + std::to_string(selected_filaments.begin()->first) + "]"; int selected_tray_id = 0;
get_ams_id_and_slot_id(selected_filaments.begin()->first, calib_info.ams_id, calib_info.slot_id); get_tray_ams_and_slot_id(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.extruder_id = preset_page->get_extruder_id(calib_info.ams_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.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.nozzle_volume_type = preset_page->get_nozzle_volume_type(calib_info.extruder_id);
@ -1440,7 +1455,12 @@ void MaxVolumetricSpeedWizard::on_cali_start()
calib_info.params = params; calib_info.params = params;
calib_info.dev_id = curr_obj->dev_id; calib_info.dev_id = curr_obj->dev_id;
if (!selected_filaments.empty()) { if (!selected_filaments.empty()) {
calib_info.select_ams = "[" + std::to_string(selected_filaments.begin()->first) + "]"; int selected_tray_id = 0;
get_tray_ams_and_slot_id(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.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; calib_info.filament_prest = selected_filaments.begin()->second;
} }

View File

@ -19,7 +19,7 @@ public:
CalibrationWizardPageStep(CalibrationWizardPage* data) { CalibrationWizardPageStep(CalibrationWizardPage* data) {
page = data; page = data;
} }
CalibrationWizardPageStep* prev { nullptr }; CalibrationWizardPageStep* prev { nullptr };
CalibrationWizardPageStep* next { nullptr }; CalibrationWizardPageStep* next { nullptr };
CalibrationWizardPage* page { nullptr }; CalibrationWizardPage* page { nullptr };
@ -57,7 +57,7 @@ public:
} }
virtual void set_cali_method(CalibrationMethod method); virtual void set_cali_method(CalibrationMethod method);
CalibMode get_calibration_mode() { return m_mode; } CalibMode get_calibration_mode() { return m_mode; }
bool save_preset(const std::string &old_preset_name, const std::string &new_preset_name, const std::map<std::string, ConfigOption *> &key_values, wxString& message); bool save_preset(const std::string &old_preset_name, const std::string &new_preset_name, const std::map<std::string, ConfigOption *> &key_values, wxString& message);
@ -71,6 +71,7 @@ public:
protected: protected:
void on_cali_go_home(); void on_cali_go_home();
void get_tray_ams_and_slot_id(int in_tray_id, int &ams_id, int &slot_id, int &tray_id);
protected: protected:
/* wx widgets*/ /* wx widgets*/
@ -89,7 +90,7 @@ protected:
CalibrationWizardPageStep* preset_step { nullptr }; CalibrationWizardPageStep* preset_step { nullptr };
CalibrationWizardPageStep* cali_step { nullptr }; CalibrationWizardPageStep* cali_step { nullptr };
CalibrationWizardPageStep* save_step { nullptr }; CalibrationWizardPageStep* save_step { nullptr };
CalibrationWizardPageStep* cali_coarse_step { nullptr }; CalibrationWizardPageStep* cali_coarse_step { nullptr };
CalibrationWizardPageStep* coarse_save_step { nullptr }; CalibrationWizardPageStep* coarse_save_step { nullptr };
CalibrationWizardPageStep* cali_fine_step { nullptr }; CalibrationWizardPageStep* cali_fine_step { nullptr };

View File

@ -752,12 +752,20 @@ void CalibrationPresetPage::create_filament_list_panel(wxWindow* parent)
NozzleVolumeType CalibrationPresetPage::get_nozzle_volume_type(int extruder_id) const NozzleVolumeType CalibrationPresetPage::get_nozzle_volume_type(int extruder_id) const
{ {
return NozzleVolumeType(m_comboBox_nozzle_volume_types[extruder_id]->GetSelection()); if (m_comboBox_nozzle_volume_types.size() > extruder_id)
return NozzleVolumeType(m_comboBox_nozzle_volume_types[extruder_id]->GetSelection());
else {
return NozzleVolumeType::nvtNormal;
}
} }
ExtruderType CalibrationPresetPage::get_extruder_type(int extruder_id) const ExtruderType CalibrationPresetPage::get_extruder_type(int extruder_id) const
{ {
return ExtruderType(m_extrder_types[extruder_id]); if (m_extrder_types.size() > extruder_id)
return ExtruderType(m_extrder_types[extruder_id]);
else {
return ExtruderType::etDirectDrive;
}
} }
void CalibrationPresetPage::create_multi_extruder_filament_list_panel(wxWindow *parent) void CalibrationPresetPage::create_multi_extruder_filament_list_panel(wxWindow *parent)
@ -2387,17 +2395,17 @@ void CalibrationPresetPage::update_filament_combobox(std::string ams_id)
empty_config.set_key_value("filament_colour", new ConfigOptionStrings{ "" }); empty_config.set_key_value("filament_colour", new ConfigOptionStrings{ "" });
empty_config.set_key_value("filament_exist", new ConfigOptionBools{ false }); empty_config.set_key_value("filament_exist", new ConfigOptionBools{ false });
/* update virtual tray combo box*/ // update virtual tray combo box
m_virtual_tray_comboBox->update_from_preset(); m_virtual_tray_comboBox->update_from_preset();
auto it = std::find_if(filament_ams_list.begin(), filament_ams_list.end(), [](auto& entry) { auto it = std::find_if(filament_ams_list.begin(), filament_ams_list.end(), [](auto& entry) {
return entry.first == VIRTUAL_TRAY_DEPUTY_ID; return entry.first == VIRTUAL_TRAY_MAIN_ID;
}); });
if (it != filament_ams_list.end()) { if (it != filament_ams_list.end()) {
m_virtual_tray_comboBox->load_tray_from_ams(VIRTUAL_TRAY_DEPUTY_ID, it->second); m_virtual_tray_comboBox->load_tray_from_ams(VIRTUAL_TRAY_MAIN_ID, it->second);
} }
else { else {
m_virtual_tray_comboBox->load_tray_from_ams(VIRTUAL_TRAY_DEPUTY_ID, empty_config); m_virtual_tray_comboBox->load_tray_from_ams(VIRTUAL_TRAY_MAIN_ID, empty_config);
} }
if (filament_ams_list.empty()) if (filament_ams_list.empty())