ENH: support saving PA calibration results for P series
Jira: none Change-Id: I9402b8bcce7b48a63d0e97e0708080701d065e7a
This commit is contained in:
parent
dd17c5deb8
commit
510bc20696
|
@ -455,7 +455,7 @@ void AMSMaterialsSetting::on_select_reset(wxCommandEvent& event) {
|
|||
}
|
||||
|
||||
// set k / n value
|
||||
if (obj->get_printer_series() != PrinterSeries::SERIES_X1) {
|
||||
if (obj->cali_version <= -1 && obj->get_printer_series() == PrinterSeries::SERIES_P1P) {
|
||||
// set extrusion cali ratio
|
||||
int cali_tray_id = ams_id * 4 + tray_id;
|
||||
|
||||
|
@ -573,7 +573,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
|||
wxString k_text = m_input_k_val->GetTextCtrl()->GetValue();
|
||||
wxString n_text = m_input_n_val->GetTextCtrl()->GetValue();
|
||||
|
||||
if ((obj->get_printer_series() != PrinterSeries::SERIES_X1) && !ExtrusionCalibration::check_k_validation(k_text)) {
|
||||
if (obj->cali_version <= -1 && (obj->get_printer_series() != PrinterSeries::SERIES_X1) && !ExtrusionCalibration::check_k_validation(k_text)) {
|
||||
wxString k_tips = _L("Please input a valid value (K in 0~0.3)");
|
||||
wxString kn_tips = _L("Please input a valid value (K in 0~0.3, N in 0.6~2.0)");
|
||||
MessageDialog msg_dlg(nullptr, k_tips, wxEmptyString, wxICON_WARNING | wxOK);
|
||||
|
@ -598,7 +598,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
|||
;
|
||||
}
|
||||
|
||||
if (obj->get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
if (obj->cali_version >= 0) {
|
||||
PACalibIndexInfo select_index_info;
|
||||
select_index_info.tray_id = tray_id;
|
||||
select_index_info.nozzle_diameter = obj->nozzle_diameter;
|
||||
|
@ -637,7 +637,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
|||
;
|
||||
}
|
||||
|
||||
if (obj->get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
if (obj->cali_version >= -1) {
|
||||
PACalibIndexInfo select_index_info;
|
||||
select_index_info.tray_id = cali_tray_id;
|
||||
select_index_info.nozzle_diameter = obj->nozzle_diameter;
|
||||
|
@ -740,7 +740,7 @@ void AMSMaterialsSetting::update_widgets()
|
|||
else
|
||||
m_panel_normal->Hide();
|
||||
m_panel_kn->Show();
|
||||
} else if (obj && (obj->ams_support_virtual_tray || (obj->get_printer_series() == PrinterSeries::SERIES_X1))) {
|
||||
} else if (obj && (obj->ams_support_virtual_tray || obj->cali_version >= 0)) {
|
||||
m_panel_normal->Show();
|
||||
m_panel_kn->Show();
|
||||
} else {
|
||||
|
@ -895,7 +895,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
|||
m_readonly_filament->Hide();
|
||||
}
|
||||
|
||||
if (obj->get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
if (obj->cali_version >= 0) {
|
||||
m_title_pa_profile->Show();
|
||||
m_comboBox_cali_result->Show();
|
||||
m_input_k_val->Disable();
|
||||
|
@ -1064,7 +1064,7 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
|
|||
m_pa_profile_items.clear();
|
||||
m_comboBox_cali_result->SetValue(wxEmptyString);
|
||||
|
||||
if (obj->get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
if (obj->cali_version >= 0) {
|
||||
m_input_k_val->GetTextCtrl()->SetValue(wxEmptyString);
|
||||
std::vector<PACalibResult> cali_history = this->obj->pa_calib_tab;
|
||||
for (auto cali_item : cali_history) {
|
||||
|
|
|
@ -455,16 +455,9 @@ PACalibResult EditCalibrationHistoryDialog::get_result() {
|
|||
|
||||
void EditCalibrationHistoryDialog::on_save(wxCommandEvent& event) {
|
||||
wxString name = m_name_value->GetTextCtrl()->GetValue();
|
||||
if (name.IsEmpty()) {
|
||||
MessageDialog msg_dlg(nullptr, _L("The name cannot be empty."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
if (!CalibUtils::validate_input_name(name))
|
||||
return;
|
||||
}
|
||||
if (name.Length() > 40) {
|
||||
MessageDialog msg_dlg(nullptr, _L("The name cannot exceed 40 characters."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
return;
|
||||
}
|
||||
|
||||
m_new_result.name = m_name_value->GetTextCtrl()->GetValue().ToUTF8().data();
|
||||
|
||||
float k = 0.0f;
|
||||
|
@ -670,16 +663,8 @@ NewCalibrationHistoryDialog::NewCalibrationHistoryDialog(wxWindow *parent, const
|
|||
void NewCalibrationHistoryDialog::on_ok(wxCommandEvent &event)
|
||||
{
|
||||
wxString name = m_name_value->GetTextCtrl()->GetValue();
|
||||
if (name.IsEmpty()) {
|
||||
MessageDialog msg_dlg(nullptr, _L("The name cannot be empty."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
if (!CalibUtils::validate_input_name(name))
|
||||
return;
|
||||
}
|
||||
if (name.Length() > 40) {
|
||||
MessageDialog msg_dlg(nullptr, _L("The name cannot exceed 40 characters."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
return;
|
||||
}
|
||||
|
||||
float k = 0.0f;
|
||||
if (!CalibUtils::validate_input_k_value(m_k_value->GetTextCtrl()->GetValue(), &k)) {
|
||||
|
|
|
@ -19,21 +19,6 @@ static const float MIN_PA_K_VALUE = 0.0;
|
|||
static const float MAX_PA_K_VALUE = 0.3;
|
||||
static const float MIN_PA_K_VALUE_STEP = 0.001;
|
||||
|
||||
bool check_preset_name_valid(const wxString& name) {
|
||||
wxString error_message;
|
||||
if (name.IsEmpty()) {
|
||||
error_message = _L("Please enter the name you want to save to printer.");
|
||||
} else if (name.Length() > 40) {
|
||||
error_message = _L("The name cannot exceed 40 characters.");
|
||||
}
|
||||
if (!error_message.IsEmpty()) {
|
||||
MessageDialog error_msg_dlg(nullptr, error_message, wxEmptyString, wxICON_WARNING | wxOK);
|
||||
error_msg_dlg.ShowModal();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::map<int, Preset*> get_cached_selected_filament(MachineObject* obj) {
|
||||
std::map<int, Preset*> selected_filament_map;
|
||||
if (!obj) return selected_filament_map;
|
||||
|
@ -722,34 +707,44 @@ void PressureAdvanceWizard::on_cali_save()
|
|||
msg_dlg.ShowModal();
|
||||
}
|
||||
else if (curr_obj->get_printer_series() == PrinterSeries::SERIES_P1P) {
|
||||
auto save_page = static_cast<CalibrationPASavePage*>(save_step->page);
|
||||
float new_k_value = 0.0f;
|
||||
float new_n_value = 0.0f;
|
||||
if (!save_page->get_p1p_result(&new_k_value, &new_n_value)) {
|
||||
return;
|
||||
}
|
||||
if (curr_obj->cali_version >= 0) {
|
||||
PACalibResult new_pa_cali_result;
|
||||
auto save_page = static_cast<CalibrationPASavePage *>(save_step->page);
|
||||
if (!save_page->get_manual_result(new_pa_cali_result)) {
|
||||
return;
|
||||
}
|
||||
CalibUtils::set_PA_calib_result({new_pa_cali_result}, false);
|
||||
} else {
|
||||
auto save_page = static_cast<CalibrationPASavePage *>(save_step->page);
|
||||
float new_k_value = 0.0f;
|
||||
float new_n_value = 0.0f;
|
||||
if (!save_page->get_p1p_result(&new_k_value, &new_n_value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
float nozzle_dia = 0.4;
|
||||
BedType plate_type = BedType::btDefault;
|
||||
CalibrationPresetPage* preset_page = (static_cast<CalibrationPresetPage*>(preset_step->page));
|
||||
preset_page->get_preset_info(nozzle_dia, plate_type);
|
||||
std::map<int, Preset*> selected_filaments = get_cached_selected_filament(curr_obj);
|
||||
if (selected_filaments.empty()) {
|
||||
BOOST_LOG_TRIVIAL(error) << "CaliPreset: get selected filaments error";
|
||||
return;
|
||||
}
|
||||
int tray_id = selected_filaments.begin()->first;
|
||||
std::string setting_id = selected_filaments.begin()->second->setting_id;
|
||||
float nozzle_dia = 0.4;
|
||||
BedType plate_type = BedType::btDefault;
|
||||
CalibrationPresetPage *preset_page = (static_cast<CalibrationPresetPage *>(preset_step->page));
|
||||
preset_page->get_preset_info(nozzle_dia, plate_type);
|
||||
std::map<int, Preset *> selected_filaments = get_cached_selected_filament(curr_obj);
|
||||
if (selected_filaments.empty()) {
|
||||
BOOST_LOG_TRIVIAL(error) << "CaliPreset: get selected filaments error";
|
||||
return;
|
||||
}
|
||||
int tray_id = selected_filaments.begin()->first;
|
||||
std::string setting_id = selected_filaments.begin()->second->setting_id;
|
||||
|
||||
int nozzle_temp = -1;
|
||||
int bed_temp = -1;
|
||||
float max_volumetric_speed = -1;
|
||||
if (!get_preset_info(selected_filaments.begin()->second->config, plate_type, nozzle_temp, bed_temp, max_volumetric_speed)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "CaliPreset: get preset info error";
|
||||
return;
|
||||
}
|
||||
int nozzle_temp = -1;
|
||||
int bed_temp = -1;
|
||||
float max_volumetric_speed = -1;
|
||||
if (!get_preset_info(selected_filaments.begin()->second->config, plate_type, nozzle_temp, bed_temp, max_volumetric_speed)) {
|
||||
BOOST_LOG_TRIVIAL(error) << "CaliPreset: get preset info error";
|
||||
return;
|
||||
}
|
||||
|
||||
curr_obj->command_extrusion_cali_set(tray_id, setting_id, "", new_k_value, new_n_value, bed_temp, nozzle_temp, max_volumetric_speed);
|
||||
curr_obj->command_extrusion_cali_set(tray_id, setting_id, "", new_k_value, new_n_value, bed_temp, nozzle_temp, max_volumetric_speed);
|
||||
|
||||
}
|
||||
|
||||
MessageDialog msg_dlg(nullptr, _L("Flow Dynamics Calibration result has been saved to the printer"), wxEmptyString, wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
|
@ -1128,7 +1123,7 @@ void FlowRateWizard::on_cali_save()
|
|||
return;
|
||||
}
|
||||
|
||||
if (!check_preset_name_valid(new_preset_name))
|
||||
if (!CalibUtils::validate_input_name(new_preset_name))
|
||||
return;
|
||||
|
||||
std::string old_preset_name;
|
||||
|
@ -1415,7 +1410,7 @@ void MaxVolumetricSpeedWizard::on_cali_save()
|
|||
return;
|
||||
}
|
||||
|
||||
if (!check_preset_name_valid(new_preset_name))
|
||||
if (!CalibUtils::validate_input_name(new_preset_name))
|
||||
return;
|
||||
|
||||
std::map<std::string, ConfigOption *> key_value_map;
|
||||
|
|
|
@ -552,16 +552,8 @@ bool CaliPASaveManualPanel::get_result(PACalibResult& out_result) {
|
|||
}
|
||||
|
||||
wxString name = m_save_name_input->GetTextCtrl()->GetValue();
|
||||
if (name.IsEmpty()) {
|
||||
MessageDialog msg_dlg(nullptr, _L("Please enter the name you want to save to printer."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
if (!CalibUtils::validate_input_name(name))
|
||||
return false;
|
||||
}
|
||||
else if (name.Length() > 40) {
|
||||
MessageDialog msg_dlg(nullptr, _L("The name cannot exceed 40 characters."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
return false;
|
||||
}
|
||||
|
||||
out_result.k_value = k;
|
||||
out_result.name = into_u8(name);
|
||||
|
@ -873,11 +865,11 @@ void CalibrationPASavePage::show_panels(CalibrationMethod method, const PrinterS
|
|||
}
|
||||
m_p1p_panel->Show(false);
|
||||
}
|
||||
else if (printer_ser == PrinterSeries::SERIES_P1P) {
|
||||
else if (curr_obj->cali_version >= 0) {
|
||||
m_auto_panel->Show(false);
|
||||
m_manual_panel->Show(false);
|
||||
m_p1p_panel->set_pa_cali_method(curr_obj->manual_pa_cali_method);
|
||||
m_p1p_panel->Show();
|
||||
m_manual_panel->set_pa_cali_method(curr_obj->manual_pa_cali_method);
|
||||
m_manual_panel->Show();
|
||||
m_p1p_panel->Show(false);
|
||||
} else {
|
||||
m_auto_panel->Show(false);
|
||||
m_manual_panel->Show(false);
|
||||
|
|
|
@ -161,19 +161,24 @@ void CalibrationPAStartPage::on_device_connected(MachineObject* obj)
|
|||
m_action_panel->bind_button(CaliPageActionType::CALI_ACTION_MANUAL_CALI, false);
|
||||
m_action_panel->bind_button(CaliPageActionType::CALI_ACTION_AUTO_CALI, false);
|
||||
}
|
||||
|
||||
// is support auto cali
|
||||
bool is_support_pa_auto = (obj->home_flag >> 16 & 1) == 1;
|
||||
if (!is_support_pa_auto) {
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_AUTO_CALI, false);
|
||||
}
|
||||
}
|
||||
else if (obj->get_printer_series() == PrinterSeries::SERIES_P1P || obj->get_printer_arch() == PrinterArch::ARCH_I3) {
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_MANAGE_RESULT, false);
|
||||
if (obj->cali_version >= 0) {
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_MANAGE_RESULT, true);
|
||||
m_action_panel->bind_button(CaliPageActionType::CALI_ACTION_MANAGE_RESULT, false);
|
||||
}
|
||||
else
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_MANAGE_RESULT, false);
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_AUTO_CALI, false);
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_MANUAL_CALI, true);
|
||||
m_action_panel->bind_button(CaliPageActionType::CALI_ACTION_MANUAL_CALI, false);
|
||||
}
|
||||
|
||||
//is support auto cali
|
||||
bool is_support_pa_auto = (obj->home_flag >> 16 & 1) == 1;
|
||||
if (!is_support_pa_auto) {
|
||||
m_action_panel->show_button(CaliPageActionType::CALI_ACTION_AUTO_CALI, false);
|
||||
}
|
||||
}
|
||||
|
||||
void CalibrationPAStartPage::msw_rescale()
|
||||
|
|
|
@ -2132,50 +2132,45 @@ int MachineObject::command_start_pa_calibration(const X1CCalibInfos &pa_data, in
|
|||
CNumericLocalesSetter locales_setter;
|
||||
|
||||
pa_calib_results.clear();
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(pa_data.calib_datas[0].nozzle_diameter);
|
||||
j["print"]["mode"] = mode;
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(pa_data.calib_datas[0].nozzle_diameter);
|
||||
j["print"]["mode"] = mode;
|
||||
|
||||
std::string filament_ids;
|
||||
for (int i = 0; i < pa_data.calib_datas.size(); ++i) {
|
||||
j["print"]["filaments"][i]["tray_id"] = pa_data.calib_datas[i].tray_id;
|
||||
j["print"]["filaments"][i]["bed_temp"] = pa_data.calib_datas[i].bed_temp;
|
||||
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]["max_volumetric_speed"] = std::to_string(pa_data.calib_datas[i].max_volumetric_speed);
|
||||
std::string filament_ids;
|
||||
for (int i = 0; i < pa_data.calib_datas.size(); ++i) {
|
||||
j["print"]["filaments"][i]["tray_id"] = pa_data.calib_datas[i].tray_id;
|
||||
j["print"]["filaments"][i]["bed_temp"] = pa_data.calib_datas[i].bed_temp;
|
||||
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]["max_volumetric_speed"] = std::to_string(pa_data.calib_datas[i].max_volumetric_speed);
|
||||
|
||||
if (i > 0)
|
||||
filament_ids += ",";
|
||||
filament_ids += pa_data.calib_datas[i].filament_id;
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali: " << j.dump();
|
||||
|
||||
try {
|
||||
json js;
|
||||
js["cali_type"] = "cali_pa_auto";
|
||||
js["nozzle_diameter"] = pa_data.calib_datas[0].nozzle_diameter;
|
||||
js["filament_id"] = filament_ids;
|
||||
js["printer_type"] = this->printer_type;
|
||||
NetworkAgent *agent = GUI::wxGetApp().getAgent();
|
||||
if (agent)
|
||||
agent->track_event("cali", js.dump());
|
||||
} catch (...) {}
|
||||
|
||||
return this->publish_json(j.dump());
|
||||
if (i > 0) filament_ids += ",";
|
||||
filament_ids += pa_data.calib_datas[i].filament_id;
|
||||
}
|
||||
return -1;
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali: " << j.dump();
|
||||
|
||||
try {
|
||||
json js;
|
||||
js["cali_type"] = "cali_pa_auto";
|
||||
js["nozzle_diameter"] = pa_data.calib_datas[0].nozzle_diameter;
|
||||
js["filament_id"] = filament_ids;
|
||||
js["printer_type"] = this->printer_type;
|
||||
NetworkAgent *agent = GUI::wxGetApp().getAgent();
|
||||
if (agent) agent->track_event("cali", js.dump());
|
||||
} catch (...) {}
|
||||
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_set_pa_calibration(const std::vector<PACalibResult> &pa_calib_values, bool is_auto_cali)
|
||||
{
|
||||
CNumericLocalesSetter locales_setter;
|
||||
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1 && pa_calib_values.size() > 0) {
|
||||
if (pa_calib_values.size() > 0) {
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_set";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
|
@ -2206,73 +2201,61 @@ int MachineObject::command_set_pa_calibration(const std::vector<PACalibResult> &
|
|||
|
||||
int MachineObject::command_delete_pa_calibration(const PACalibIndexInfo& pa_calib)
|
||||
{
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_del";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
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);
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_del";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
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);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_del: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
return -1;
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_del: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_get_pa_calibration_tab(float nozzle_diameter, const std::string &filament_id)
|
||||
{
|
||||
reset_pa_cali_history_result();
|
||||
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
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);
|
||||
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);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_get: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
return -1;
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_get: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_get_pa_calibration_result(float nozzle_diameter)
|
||||
{
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_get_result";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter);
|
||||
json j;
|
||||
j["print"]["command"] = "extrusion_cali_get_result";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_get_result: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
return -1;
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_get_result: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::commnad_select_pa_calibration(const PACalibIndexInfo& pa_calib_info)
|
||||
{
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
json j;
|
||||
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"]["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);
|
||||
json j;
|
||||
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"]["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);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_sel: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
return -1;
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_sel: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_start_flow_ratio_calibration(const X1CCalibInfos& calib_data)
|
||||
{
|
||||
CNumericLocalesSetter locales_setter;
|
||||
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1 && calib_data.calib_datas.size() > 0) {
|
||||
if (calib_data.calib_datas.size() > 0) {
|
||||
json j;
|
||||
j["print"]["command"] = "flowrate_cali";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
|
@ -2312,16 +2295,13 @@ int MachineObject::command_start_flow_ratio_calibration(const X1CCalibInfos& cal
|
|||
|
||||
int MachineObject::command_get_flow_ratio_calibration_result(float nozzle_diameter)
|
||||
{
|
||||
if (get_printer_series() == PrinterSeries::SERIES_X1) {
|
||||
json j;
|
||||
j["print"]["command"] = "flowrate_get_result";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter);
|
||||
json j;
|
||||
j["print"]["command"] = "flowrate_get_result";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(nozzle_diameter);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "flowrate_get_result: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
return -1;
|
||||
BOOST_LOG_TRIVIAL(trace) << "flowrate_get_result: " << j.dump();
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_ipcam_record(bool on_off)
|
||||
|
@ -3802,6 +3782,9 @@ int MachineObject::parse_json(std::string payload)
|
|||
if (jj.contains("cali_version")) {
|
||||
cali_version = jj["cali_version"].get<int>();
|
||||
}
|
||||
else {
|
||||
cali_version = -1;
|
||||
}
|
||||
std::string str = jj.dump();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -2458,7 +2458,7 @@ void StatusPanel::update_ams(MachineObject *obj)
|
|||
}
|
||||
if (m_filament_setting_dlg) { m_filament_setting_dlg->obj = obj; }
|
||||
|
||||
if ( (obj->get_printer_series() == PrinterSeries::SERIES_X1) && last_cali_version != obj->cali_version) {
|
||||
if (obj->cali_version != -1 && last_cali_version != obj->cali_version) {
|
||||
last_cali_version = obj->cali_version;
|
||||
CalibUtils::emit_get_PA_calib_info(obj->nozzle_diameter, "");
|
||||
}
|
||||
|
|
|
@ -191,6 +191,24 @@ CalibMode CalibUtils::get_calib_mode_by_name(const std::string name, int& cali_s
|
|||
return CalibMode::Calib_None;
|
||||
}
|
||||
|
||||
bool CalibUtils::validate_input_name(wxString name)
|
||||
{
|
||||
if (name.Length() > 40) {
|
||||
MessageDialog msg_dlg(nullptr, _L("The name cannot exceed 40 characters."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
return false;
|
||||
}
|
||||
|
||||
name.erase(std::remove(name.begin(), name.end(), L' '), name.end());
|
||||
if (name.IsEmpty()) {
|
||||
MessageDialog msg_dlg(nullptr, _L("The name cannot be empty."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CalibUtils::validate_input_k_value(wxString k_text, float* output_value)
|
||||
{
|
||||
float default_k = 0.0f;
|
||||
|
|
|
@ -62,6 +62,7 @@ public:
|
|||
static int get_selected_calib_idx(const std::vector<PACalibResult> &pa_calib_values, int cali_idx);
|
||||
static bool get_pa_k_n_value_by_cali_idx(const MachineObject* obj, int cali_idx, float& out_k, float& out_n);
|
||||
|
||||
static bool validate_input_name(wxString name);
|
||||
static bool validate_input_k_value(wxString k_text, float* output_value);
|
||||
static bool validate_input_flow_ratio(wxString flow_ratio, float* output_value);
|
||||
|
||||
|
|
Loading…
Reference in New Issue