FIX: Modify calibration protocol
jira: none Change-Id: Ib0fdf4fd1ab514c2db4d1731ad0d37d3dc38fce5
This commit is contained in:
parent
65c00e00fe
commit
d479d1186a
|
@ -17,6 +17,26 @@ namespace GUI {
|
|||
#define NEW_HISTORY_DIALOG_INPUT_SIZE wxSize(FromDIP(250), FromDIP(24))
|
||||
#define HISTORY_WINDOW_ITEMS_COUNT 5
|
||||
|
||||
enum CaliColumnType : int {
|
||||
Cali_Name = 0,
|
||||
Cali_Filament,
|
||||
Cali_Nozzle,
|
||||
Cali_K_Value,
|
||||
Cali_Delete,
|
||||
Cali_Edit,
|
||||
Cali_Type_Count
|
||||
};
|
||||
|
||||
int get_colume_idx(CaliColumnType type, MachineObject* obj)
|
||||
{
|
||||
if ((!obj || !obj->is_multi_extruders())
|
||||
&& (type > CaliColumnType::Cali_Nozzle)) {
|
||||
return type - 1;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static wxString get_preset_name_by_filament_id(std::string filament_id)
|
||||
{
|
||||
auto preset_bundle = wxGetApp().preset_bundle;
|
||||
|
@ -87,6 +107,16 @@ HistoryWindow::HistoryWindow(wxWindow* parent, const std::vector<PACalibResult>&
|
|||
scroll_sizer->Add(mew_btn, 0, wxLEFT, FromDIP(20));
|
||||
scroll_sizer->AddSpacer(FromDIP(15));
|
||||
|
||||
m_extruder_switch_btn = new SwitchButton(scroll_window);
|
||||
m_extruder_switch_btn->SetBackgroundColour(wxColour(0, 174, 66));
|
||||
m_extruder_switch_btn->SetMinSize(wxSize(FromDIP(120), FromDIP(24)));
|
||||
m_extruder_switch_btn->SetMaxSize(wxSize(FromDIP(120), FromDIP(24)));
|
||||
m_extruder_switch_btn->SetLabels(_L("Left"), _L("Right"));
|
||||
m_extruder_switch_btn->Bind(wxEVT_TOGGLEBUTTON, &HistoryWindow::on_switch_extruder, this);
|
||||
m_extruder_switch_btn->SetValue(false);
|
||||
scroll_sizer->Add(m_extruder_switch_btn, 0, wxCENTER | wxALL, FromDIP(10));
|
||||
scroll_sizer->AddSpacer(10);
|
||||
|
||||
wxPanel* comboBox_panel = new wxPanel(scroll_window);
|
||||
comboBox_panel->SetBackgroundColour(wxColour(238, 238, 238));
|
||||
auto comboBox_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
@ -186,6 +216,11 @@ void HistoryWindow::on_device_connected(MachineObject* obj)
|
|||
}
|
||||
m_comboBox_nozzle_dia->SetSelection(selection);
|
||||
|
||||
if (obj->is_multi_extruders())
|
||||
m_extruder_switch_btn->Show();
|
||||
else
|
||||
m_extruder_switch_btn->Hide();
|
||||
|
||||
// trigger on_select nozzle
|
||||
wxCommandEvent evt(wxEVT_COMBOBOX);
|
||||
evt.SetEventObject(m_comboBox_nozzle_dia);
|
||||
|
@ -216,7 +251,12 @@ void HistoryWindow::update(MachineObject* obj)
|
|||
void HistoryWindow::on_select_nozzle(wxCommandEvent& evt)
|
||||
{
|
||||
reqeust_history_result(curr_obj);
|
||||
}
|
||||
|
||||
void HistoryWindow::on_switch_extruder(wxCommandEvent &evt)
|
||||
{
|
||||
evt.Skip();
|
||||
reqeust_history_result(curr_obj);
|
||||
}
|
||||
|
||||
void HistoryWindow::reqeust_history_result(MachineObject* obj)
|
||||
|
@ -228,9 +268,11 @@ void HistoryWindow::reqeust_history_result(MachineObject* obj)
|
|||
sync_history_data();
|
||||
|
||||
float nozzle_value = get_nozzle_value();
|
||||
int extruder_id = get_extruder_id();
|
||||
if (nozzle_value > 0) {
|
||||
PACalibExtruderInfo cali_info;
|
||||
cali_info.nozzle_diameter = nozzle_value;
|
||||
cali_info.extruder_id = extruder_id;
|
||||
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";
|
||||
|
@ -261,15 +303,21 @@ void HistoryWindow::sync_history_data() {
|
|||
|
||||
auto title_name = new Label(m_history_data_panel, _L("Name"));
|
||||
title_name->SetFont(Label::Head_14);
|
||||
gbSizer->Add(title_name, { 0, 0 }, { 1, 1 }, wxBOTTOM, FromDIP(15));
|
||||
gbSizer->Add(title_name, {0, get_colume_idx(CaliColumnType::Cali_Name, curr_obj) }, {1, 1}, wxBOTTOM, FromDIP(15));
|
||||
|
||||
auto title_preset_name = new Label(m_history_data_panel, _L("Filament"));
|
||||
title_preset_name->SetFont(Label::Head_14);
|
||||
gbSizer->Add(title_preset_name, { 0, 1 }, { 1, 1 }, wxBOTTOM, FromDIP(15));
|
||||
gbSizer->Add(title_preset_name, { 0, get_colume_idx(CaliColumnType::Cali_Filament, curr_obj) }, { 1, 1 }, wxBOTTOM, FromDIP(15));
|
||||
|
||||
if (curr_obj && curr_obj->is_multi_extruders()) {
|
||||
auto nozzle_name = new Label(m_history_data_panel, _L("Nozzle"));
|
||||
nozzle_name->SetFont(Label::Head_14);
|
||||
gbSizer->Add(nozzle_name, {0, get_colume_idx(CaliColumnType::Cali_Nozzle, curr_obj)}, {1, 1}, wxBOTTOM, FromDIP(15));
|
||||
}
|
||||
|
||||
auto title_k = new Label(m_history_data_panel, _L("Factor K"));
|
||||
title_k->SetFont(Label::Head_14);
|
||||
gbSizer->Add(title_k, { 0, 2 }, { 1, 1 }, wxBOTTOM, FromDIP(15));
|
||||
gbSizer->Add(title_k, { 0, get_colume_idx(CaliColumnType::Cali_K_Value,curr_obj) }, { 1, 1 }, wxBOTTOM, FromDIP(15));
|
||||
|
||||
// Hide
|
||||
//auto title_n = new Label(m_history_data_panel, wxID_ANY, _L("N"));
|
||||
|
@ -278,7 +326,7 @@ void HistoryWindow::sync_history_data() {
|
|||
|
||||
auto title_action = new Label(m_history_data_panel, _L("Action"));
|
||||
title_action->SetFont(Label::Head_14);
|
||||
gbSizer->Add(title_action, { 0, 3 }, { 1, 1 });
|
||||
gbSizer->Add(title_action, {0, get_colume_idx(CaliColumnType::Cali_Delete, curr_obj)}, {1, 1});
|
||||
|
||||
auto to_lower_case = [](const std::string &str) {
|
||||
std::string lowerStr = str;
|
||||
|
@ -300,6 +348,9 @@ void HistoryWindow::sync_history_data() {
|
|||
wxString preset_name = get_preset_name_by_filament_id(result.filament_id);
|
||||
auto preset_name_value = new Label(m_history_data_panel, preset_name);
|
||||
|
||||
wxString nozzle_name = generate_nozzle_id(result.nozzle_volume_type);
|
||||
auto nozzle_name_label = new Label(m_history_data_panel, nozzle_name);
|
||||
|
||||
auto k_str = wxString::Format("%.3f", result.k_value);
|
||||
auto n_str = wxString::Format("%.3f", result.n_coef);
|
||||
auto k_value = new Label(m_history_data_panel, k_str);
|
||||
|
@ -354,12 +405,14 @@ void HistoryWindow::sync_history_data() {
|
|||
}
|
||||
});
|
||||
|
||||
gbSizer->Add(name_value, { i, 0 }, { 1, 1 }, wxBOTTOM, FromDIP(15));
|
||||
gbSizer->Add(preset_name_value, { i, 1 }, { 1, 1 }, wxBOTTOM, FromDIP(15));
|
||||
gbSizer->Add(k_value, { i, 2 }, { 1, 1 }, wxBOTTOM, FromDIP(15));
|
||||
gbSizer->Add(name_value, {i, get_colume_idx(CaliColumnType::Cali_Name, curr_obj)}, {1, 1}, wxBOTTOM, FromDIP(15));
|
||||
gbSizer->Add(preset_name_value, {i, get_colume_idx(CaliColumnType::Cali_Filament, curr_obj)}, {1, 1}, wxBOTTOM, FromDIP(15));
|
||||
if (curr_obj && curr_obj->is_multi_extruders())
|
||||
gbSizer->Add(nozzle_name_label, {i, get_colume_idx(CaliColumnType::Cali_Nozzle, curr_obj)}, {1, 1}, wxBOTTOM, FromDIP(15));
|
||||
gbSizer->Add(k_value, {i, get_colume_idx(CaliColumnType::Cali_K_Value, curr_obj)}, {1, 1}, wxBOTTOM, FromDIP(15));
|
||||
//gbSizer->Add(n_value, { i, 3 }, { 1, 1 }, wxBOTTOM, FromDIP(15));
|
||||
gbSizer->Add(delete_button, { i, 3 }, { 1, 1 }, wxBOTTOM, FromDIP(15));
|
||||
gbSizer->Add(edit_button, { i, 4 }, { 1, 1 }, wxBOTTOM, FromDIP(15));
|
||||
gbSizer->Add(delete_button, {i, get_colume_idx(CaliColumnType::Cali_Delete, curr_obj)}, {1, 1}, wxBOTTOM, FromDIP(15));
|
||||
gbSizer->Add(edit_button, {i, get_colume_idx(CaliColumnType::Cali_Edit, curr_obj)}, {1, 1}, wxBOTTOM, FromDIP(15));
|
||||
i++;
|
||||
}
|
||||
|
||||
|
@ -384,6 +437,25 @@ float HistoryWindow::get_nozzle_value()
|
|||
return nozzle_value;
|
||||
}
|
||||
|
||||
int HistoryWindow::get_extruder_id()
|
||||
{
|
||||
if (!curr_obj) {
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
if (!curr_obj->is_multi_extruders() || !m_extruder_switch_btn)
|
||||
return -1;
|
||||
|
||||
bool is_left = !m_extruder_switch_btn->GetValue();
|
||||
bool main_on_left = curr_obj->is_main_extruder_on_left();
|
||||
|
||||
if (is_left == main_on_left) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void HistoryWindow::on_click_new_button(wxCommandEvent& event)
|
||||
{
|
||||
if (curr_obj && curr_obj->get_printer_series() == PrinterSeries::SERIES_P1P && m_calib_results_history.size() >= 16) {
|
||||
|
|
|
@ -15,6 +15,7 @@ public:
|
|||
~HistoryWindow();
|
||||
void on_dpi_changed(const wxRect& suggested_rect) {}
|
||||
void on_select_nozzle(wxCommandEvent& evt);
|
||||
void on_switch_extruder(wxCommandEvent &evt);
|
||||
void reqeust_history_result(MachineObject* obj);
|
||||
void sync_history_result(MachineObject* obj);
|
||||
void on_device_connected(MachineObject* obj);
|
||||
|
@ -24,11 +25,13 @@ protected:
|
|||
void sync_history_data();
|
||||
void enbale_action_buttons(bool enable);
|
||||
float get_nozzle_value();
|
||||
int get_extruder_id();
|
||||
|
||||
void on_click_new_button(wxCommandEvent &event);
|
||||
|
||||
wxPanel* m_history_data_panel;
|
||||
ComboBox* m_comboBox_nozzle_dia;
|
||||
SwitchButton* m_extruder_switch_btn;
|
||||
Label* m_tips;
|
||||
|
||||
wxTimer* m_refresh_timer { nullptr };
|
||||
|
|
|
@ -245,6 +245,33 @@ void split_string(std::string s, std::vector<std::string>& v) {
|
|||
v.push_back(t);
|
||||
}
|
||||
|
||||
wxString generate_nozzle_id(NozzleVolumeType nozzle_type)
|
||||
{
|
||||
std::string nozzle_id;
|
||||
switch (nozzle_type) {
|
||||
case NozzleVolumeType::nvtNormal: {
|
||||
nozzle_id = L("Normal");
|
||||
break;
|
||||
}
|
||||
case NozzleVolumeType::nvtBigTraffic: {
|
||||
nozzle_id = L("BigTraffic");
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
return nozzle_id;
|
||||
}
|
||||
|
||||
NozzleVolumeType convert_to_nozzle_type(const std::string &str)
|
||||
{
|
||||
NozzleVolumeType res = NozzleVolumeType::nvtNormal;
|
||||
if (str == "Normal")
|
||||
res = NozzleVolumeType::nvtNormal;
|
||||
else if (str == "BigTraffic")
|
||||
res = NozzleVolumeType::nvtBigTraffic;
|
||||
return res;
|
||||
}
|
||||
|
||||
PrinterArch get_printer_arch_by_str(std::string arch_str)
|
||||
{
|
||||
if (arch_str == "i3") {
|
||||
|
@ -2241,7 +2268,7 @@ int MachineObject::command_start_pa_calibration(const X1CCalibInfos &pa_data, in
|
|||
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_id"] = generate_nozzle_id(pa_data.calib_datas[i].nozzle_volume_type).ToStdString();
|
||||
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);
|
||||
|
||||
|
@ -2281,7 +2308,7 @@ int MachineObject::command_set_pa_calibration(const std::vector<PACalibResult> &
|
|||
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]["nozzle_id"] = generate_nozzle_id(pa_calib_values[i].nozzle_volume_type).ToStdString();
|
||||
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;
|
||||
|
@ -2307,7 +2334,7 @@ int MachineObject::command_delete_pa_calibration(const PACalibIndexInfo& pa_cali
|
|||
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"]["nozzle_id"] = generate_nozzle_id(pa_calib.nozzle_volume_type).ToStdString();
|
||||
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);
|
||||
|
@ -2325,7 +2352,7 @@ int MachineObject::command_get_pa_calibration_tab(const PACalibExtruderInfo &cal
|
|||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
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_id"] = generate_nozzle_id(calib_info.nozzle_volume_type).ToStdString();
|
||||
j["print"]["nozzle_diameter"] = to_string_nozzle_diameter(calib_info.nozzle_diameter);
|
||||
|
||||
BOOST_LOG_TRIVIAL(trace) << "extrusion_cali_get: " << j.dump();
|
||||
|
@ -4368,10 +4395,12 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
} else if (jj["command"].get<std::string>() == "ams_filament_setting" && !key_field_only) {
|
||||
if (jj.contains("result") && jj.contains("reason")) {
|
||||
if (jj["result"].get<std::string>() == "fail") {
|
||||
if (jj.contains("err_code")) {
|
||||
auto err_code = jj["err_code"].get<int>();
|
||||
print_error = err_code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// BBS trigger ams UI update
|
||||
|
@ -4509,10 +4538,12 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
} else if (jj["command"].get<std::string>() == "extrusion_cali_set") {
|
||||
if (jj.contains("result") && jj.contains("reason")) {
|
||||
if (jj["result"].get<std::string>() == "fail") {
|
||||
if (jj.contains("err_code")) {
|
||||
auto err_code = jj["err_code"].get<int>();
|
||||
print_error = err_code;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef CALI_DEBUG
|
||||
std::string str = jj.dump();
|
||||
BOOST_LOG_TRIVIAL(info) << "extrusion_cali_set: " << str;
|
||||
|
@ -4559,10 +4590,12 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
else if (jj["command"].get<std::string>() == "extrusion_cali_sel") {
|
||||
if (jj.contains("result") && jj.contains("reason")) {
|
||||
if (jj["result"].get<std::string>() == "fail") {
|
||||
if (jj.contains("err_code")) {
|
||||
auto err_code = jj["err_code"].get<int>();
|
||||
print_error = err_code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CALI_DEBUG
|
||||
std::string str = jj.dump();
|
||||
|
@ -4615,7 +4648,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
auto err_code = jj["err_code"].get<int>();
|
||||
print_error = err_code;
|
||||
}
|
||||
is_succeed = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4643,8 +4675,8 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
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("nozzle_id")) {
|
||||
pa_calib_tab_info.nozzle_volume_type = convert_to_nozzle_type(jj["nozzle_id"].get<std::string>());
|
||||
}
|
||||
|
||||
if (jj.contains("filaments") && jj["filaments"].is_array()) {
|
||||
|
@ -4696,7 +4728,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
if (jj.contains("err_code")) {
|
||||
auto err_code = jj["err_code"].get<int>();
|
||||
print_error = err_code;
|
||||
is_succeed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4736,8 +4767,8 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
|
|||
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>());
|
||||
if (it->contains("nozzle_id")) {
|
||||
pa_calib_result.nozzle_volume_type = convert_to_nozzle_type((*it)["nozzle_id"].get<std::string>());
|
||||
} else {
|
||||
pa_calib_result.nozzle_volume_type = NozzleVolumeType::nvtNormal;
|
||||
}
|
||||
|
|
|
@ -1174,6 +1174,8 @@ public:
|
|||
|
||||
// change the opacity
|
||||
void change_the_opacity(wxColour& colour);
|
||||
|
||||
wxString generate_nozzle_id(NozzleVolumeType nozzle_type);
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif // slic3r_DeviceManager_hpp_
|
||||
|
|
Loading…
Reference in New Issue