mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-12-31 03:40:30 -07:00
NEW:support new nozzle and extder data
jira:[new nozzle data] Change-Id: Ief37b42794ce1469163fcd8227431ec77957508e (cherry picked from commit db8ae4ccb3069347e1303de104302357bc352754)
This commit is contained in:
parent
bd3b69abf9
commit
49fdaf2f5d
7 changed files with 132 additions and 28 deletions
|
|
@ -1789,7 +1789,7 @@ void CalibrationPresetPage::init_with_machine(MachineObject* obj)
|
|||
if (obj->is_multi_extruders()) {
|
||||
for (int i = 0; i < m_comboBox_nozzle_volume_types.size(); ++i) {
|
||||
m_comboBox_nozzle_volume_types[i]->Show();
|
||||
m_comboBox_nozzle_volume_types[i]->SetSelection(0);
|
||||
m_comboBox_nozzle_volume_types[i]->SetSelection(obj->m_extder_data.extders[i].current_nozzle_flow_type);
|
||||
}
|
||||
|
||||
if (!obj->is_main_extruder_on_left() && m_main_extruder_on_left) {
|
||||
|
|
|
|||
|
|
@ -2063,6 +2063,19 @@ int MachineObject::command_set_printer_nozzle(std::string nozzle_type, float dia
|
|||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
int MachineObject::command_set_printer_nozzle2(int id, std::string nozzle_type, float diameter, int flow)
|
||||
{
|
||||
nozzle_setting_hold_count = HOLD_COUNT_MAX * 2;
|
||||
BOOST_LOG_TRIVIAL(info) << "command_set_printer_nozzle2, nozzle_type = " << nozzle_type << " diameter = " << diameter;
|
||||
json j;
|
||||
j["print"]["command"] = "set_nozzle";
|
||||
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
|
||||
j["print"]["id"] = id;
|
||||
j["print"]["type"] = "type";
|
||||
j["print"]["diameter"] = diameter;
|
||||
return this->publish_json(j.dump());
|
||||
}
|
||||
|
||||
|
||||
int MachineObject::command_set_work_light(LIGHT_EFFECT effect, int on_time, int off_time, int loops, int interval)
|
||||
{
|
||||
|
|
@ -5708,6 +5721,19 @@ void MachineObject::parse_new_info(json print)
|
|||
nozzle_obj.id = njon["id"].get<int>();
|
||||
|
||||
if (type.length() >= 4) {
|
||||
if (type.substr(0, 1) == std::string("H")) {
|
||||
nozzle_obj.tool_type = NozzleToolType::H_TOOL;
|
||||
}
|
||||
else if (type.substr(0, 1) == std::string("C")) {
|
||||
nozzle_obj.tool_type = NozzleToolType::C_TOOL;
|
||||
}
|
||||
|
||||
if (type.substr(1, 1) == std::string("S")) {
|
||||
nozzle_obj.nozzle_flow = NozzleFlowType::S_FLOW;
|
||||
} else if (type.substr(1, 1) == std::string("H")) {
|
||||
nozzle_obj.nozzle_flow = NozzleFlowType::H_FLOW;
|
||||
}
|
||||
|
||||
if (type.substr(2, 2) == std::string("00")) {
|
||||
nozzle_obj.nozzle_type = NozzleType::ntStainlessSteel;
|
||||
} else if (type.substr(2, 2) == std::string("01")) {
|
||||
|
|
@ -5785,11 +5811,13 @@ void MachineObject::parse_new_info(json print)
|
|||
if (extder_obj.nozzle_id == 0xff) {
|
||||
extder_obj.current_nozzle_type = NozzleType::ntUndefine;
|
||||
extder_obj.current_nozzle_diameter = 0.4f;
|
||||
extder_obj.current_nozzle_flow_type = NozzleFlowType::NONE_FLOWTYPE;
|
||||
} else {
|
||||
for (auto i = 0; i < m_nozzle_data.nozzles.size(); i++) {
|
||||
if (m_nozzle_data.nozzles[i].id == extder_obj.nozzle_id) {
|
||||
extder_obj.current_nozzle_type = m_nozzle_data.nozzles[i].nozzle_type;
|
||||
extder_obj.current_nozzle_diameter = m_nozzle_data.nozzles[i].diameter;
|
||||
extder_obj.current_nozzle_flow_type = m_nozzle_data.nozzles[i].nozzle_flow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5828,7 +5856,8 @@ bool MachineObject::is_nozzle_data_invalid()
|
|||
for (const auto &ext : m_extder_data.extders)
|
||||
{
|
||||
if (ext.current_nozzle_type == NozzleType::ntUndefine ||
|
||||
ext.current_nozzle_diameter <= 0.0f) {
|
||||
ext.current_nozzle_diameter <= 0.0f ||
|
||||
ext.current_nozzle_flow_type == NozzleFlowType::NONE_FLOWTYPE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,6 +146,17 @@ enum AirDuctType {
|
|||
AIR_DOOR_TYPE
|
||||
};
|
||||
|
||||
enum NozzleFlowType{
|
||||
NONE_FLOWTYPE,
|
||||
S_FLOW,
|
||||
H_FLOW
|
||||
};
|
||||
|
||||
enum NozzleToolType {
|
||||
NONE_TOOLTYPE,
|
||||
H_TOOL,
|
||||
C_TOOL
|
||||
};
|
||||
|
||||
struct AmsSlot
|
||||
{
|
||||
|
|
@ -156,6 +167,8 @@ struct AmsSlot
|
|||
struct Nozzle
|
||||
{
|
||||
int id;
|
||||
NozzleToolType tool_type; // H nozzle or Cut
|
||||
NozzleFlowType nozzle_flow; // 0-common 1-high flow
|
||||
NozzleType nozzle_type; // 0-stainless_steel 1-hardened_steel
|
||||
float diameter = {0.4f}; // 0-0.2mm 1-0.4mm 2-0.6 mm3-0.8mm
|
||||
int max_temp = 0;
|
||||
|
|
@ -174,6 +187,7 @@ struct Extder
|
|||
{
|
||||
int id; // 0-right 1-left
|
||||
|
||||
int enable_change_nozzle{0};
|
||||
int ext_has_filament{0};
|
||||
int buffer_has_filament{0};
|
||||
int nozzle_exist{0};
|
||||
|
|
@ -196,6 +210,7 @@ struct Extder
|
|||
//current nozzle
|
||||
NozzleType current_nozzle_type{NozzleType::ntUndefine}; // 0-hardened_steel 1-stainless_steel
|
||||
float current_nozzle_diameter = {0.4f}; // 0-0.2mm 1-0.4mm 2-0.6 mm3-0.8mm
|
||||
NozzleFlowType current_nozzle_flow_type{NozzleFlowType::NONE_FLOWTYPE};//0-common 1-high flow
|
||||
};
|
||||
|
||||
struct ExtderData
|
||||
|
|
@ -1010,6 +1025,7 @@ public:
|
|||
int command_pushing(std::string cmd);
|
||||
int command_clean_print_error(std::string task_id, int print_error);
|
||||
int command_set_printer_nozzle(std::string nozzle_type, float diameter);
|
||||
int command_set_printer_nozzle2(int id, std::string nozzle_type, float diameter, int flow);
|
||||
int command_get_access_code();
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -483,7 +483,13 @@ PrinterPartsDialog::PrinterPartsDialog(wxWindow* parent)
|
|||
nozzle_type->Wrap(-1);
|
||||
|
||||
ID_NOZZLE_TYPE_CHECKBOX_SINGLE = wxNewId();
|
||||
ID_NOZZLE_TYPE_CHECKBOX_LEFT = wxNewId();
|
||||
ID_NOZZLE_TYPE_CHECKBOX_RIGHT = wxNewId();
|
||||
ID_NOZZLE_DIAMETER_CHECKBOX_SINGLE = wxNewId();
|
||||
ID_NOZZLE_DIAMETER_CHECKBOX_LEFT = wxNewId();
|
||||
ID_NOZZLE_DIAMETER_CHECKBOX_RIGHT = wxNewId();
|
||||
ID_NOZZLE_FLOW_CHECKBOX_LEFT = wxNewId();
|
||||
ID_NOZZLE_FLOW_CHECKBOX_RIGHT = wxNewId();
|
||||
|
||||
nozzle_type_checkbox = new ComboBox(single_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(140), -1), 0, NULL, wxCB_READONLY);
|
||||
nozzle_type_checkbox->Append(nozzle_type_map[NozzleType::ntHardenedSteel]);
|
||||
|
|
@ -578,7 +584,7 @@ PrinterPartsDialog::PrinterPartsDialog(wxWindow* parent)
|
|||
multiple_right_nozzle_type->SetMaxSize(wxSize(FromDIP(80), -1));
|
||||
multiple_right_nozzle_type->SetForegroundColour(STATIC_TEXT_CAPTION_COL);
|
||||
|
||||
multiple_right_nozzle_type_checkbox = new ComboBox(multiple_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(140), -1), 0, NULL, wxCB_READONLY);
|
||||
multiple_right_nozzle_type_checkbox = new ComboBox(multiple_panel, ID_NOZZLE_TYPE_CHECKBOX_RIGHT, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(140), -1), 0, NULL, wxCB_READONLY);
|
||||
multiple_right_nozzle_type_checkbox->Append(_L("Stainless Steel"));
|
||||
multiple_right_nozzle_type_checkbox->Append(_L("Hardened Steel"));
|
||||
multiple_right_nozzle_type_checkbox->SetSelection(0);
|
||||
|
|
@ -634,9 +640,24 @@ PrinterPartsDialog::PrinterPartsDialog(wxWindow* parent)
|
|||
nozzle_type_checkbox->Connect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_data), NULL, this);
|
||||
nozzle_diameter_checkbox->Connect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_data), NULL, this);
|
||||
|
||||
multiple_left_nozzle_type_checkbox->Connect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_data), NULL, this);
|
||||
multiple_left_nozzle_diameter_checkbox->Connect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_data), NULL, this);
|
||||
multiple_left_nozzle_flow_checkbox->Connect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_data), NULL, this);
|
||||
|
||||
multiple_right_nozzle_type_checkbox->Connect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_data), NULL, this);
|
||||
multiple_right_nozzle_diameter_checkbox->Connect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_data), NULL, this);
|
||||
multiple_right_nozzle_flow_checkbox->Connect(wxEVT_COMBOBOX, wxCommandEventHandler(PrinterPartsDialog::set_nozzle_data), NULL, this);
|
||||
|
||||
nozzle_type_checkbox->SetId(ID_NOZZLE_TYPE_CHECKBOX_SINGLE);
|
||||
multiple_left_nozzle_type_checkbox->SetId(ID_NOZZLE_TYPE_CHECKBOX_LEFT);
|
||||
multiple_right_nozzle_type_checkbox->SetId(ID_NOZZLE_TYPE_CHECKBOX_RIGHT);
|
||||
|
||||
nozzle_diameter_checkbox->SetId(ID_NOZZLE_DIAMETER_CHECKBOX_SINGLE);
|
||||
multiple_left_nozzle_diameter_checkbox->SetId(ID_NOZZLE_DIAMETER_CHECKBOX_LEFT);
|
||||
multiple_right_nozzle_diameter_checkbox->SetId(ID_NOZZLE_DIAMETER_CHECKBOX_RIGHT);
|
||||
|
||||
multiple_left_nozzle_flow_checkbox->SetId(ID_NOZZLE_FLOW_CHECKBOX_LEFT);
|
||||
multiple_right_nozzle_flow_checkbox->SetId(ID_NOZZLE_FLOW_CHECKBOX_RIGHT);
|
||||
}
|
||||
|
||||
PrinterPartsDialog::~PrinterPartsDialog()
|
||||
|
|
|
|||
|
|
@ -22,8 +22,15 @@ class PrinterPartsDialog : public DPIDialog
|
|||
{
|
||||
protected:
|
||||
wxWindowID ID_NOZZLE_TYPE_CHECKBOX_SINGLE;
|
||||
wxWindowID ID_NOZZLE_TYPE_CHECKBOX_LEFT;
|
||||
wxWindowID ID_NOZZLE_TYPE_CHECKBOX_RIGHT;
|
||||
|
||||
wxWindowID ID_NOZZLE_DIAMETER_CHECKBOX_SINGLE;
|
||||
wxWindowID ID_NOZZLE_DIAMETER_CHECKBOX_LEFT;
|
||||
wxWindowID ID_NOZZLE_DIAMETER_CHECKBOX_RIGHT;
|
||||
|
||||
wxWindowID ID_NOZZLE_FLOW_CHECKBOX_LEFT;
|
||||
wxWindowID ID_NOZZLE_FLOW_CHECKBOX_RIGHT;
|
||||
|
||||
MachineObject* obj{ nullptr };
|
||||
|
||||
|
|
|
|||
|
|
@ -1316,7 +1316,7 @@ bool SelectMachineDialog::can_hybrid_mapping(ExtderData data) {
|
|||
for (auto it = data.extders.rbegin(); it != data.extders.rend(); it++){
|
||||
//exist field is not updated, wait add
|
||||
//if (it->exist < 3) return false;
|
||||
std::string type_str = /*it->flow_type ? "Big Traffic" :*/ "Normal";
|
||||
std::string type_str = it->current_nozzle_flow_type ? "Big Traffic" : "Normal";
|
||||
flow_type_of_machine.push_back(type_str);
|
||||
}
|
||||
//get the nozzle type of preset --> flow_types
|
||||
|
|
@ -1362,24 +1362,49 @@ bool SelectMachineDialog::is_nozzle_type_match(ExtderData data) {
|
|||
if (data.total_extder_count <= 1 || data.extders.size() <= 1 || !wxGetApp().preset_bundle)
|
||||
return false;
|
||||
|
||||
//The default two extruders are left, right, but the order of the extruders on the machine is right, left.
|
||||
std::vector<std::string>flow_type_of_machine;
|
||||
for (auto it = data.extders.begin(); it != data.extders.end(); it++) {
|
||||
std::string str_flow = /*it->flow_type ? "Big Traffic" :*/ "Normal";
|
||||
flow_type_of_machine.push_back(str_flow);
|
||||
//check nozzle used
|
||||
auto used_filaments = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_used_extruders(); // 1 based
|
||||
auto filament_maps = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_filament_maps(); // 1 based
|
||||
std::map<int, std::string> used_extruders_flow;
|
||||
std::vector<int> used_extruders; // 0 based
|
||||
for (auto f : used_filaments) {
|
||||
int filament_extruder = filament_maps[f - 1] - 1;
|
||||
if (std::find(used_extruders.begin(), used_extruders.end(), filament_extruder) == used_extruders.end()) used_extruders.emplace_back(filament_extruder);
|
||||
}
|
||||
//get the nozzle type of preset --> flow_types
|
||||
const Preset& current_printer = wxGetApp().preset_bundle->printers.get_selected_preset();
|
||||
const Preset* base_printer = wxGetApp().preset_bundle->printers.get_preset_base(current_printer);
|
||||
auto flow_data = wxGetApp().app_config->get_nozzle_volume_types_from_config(base_printer->name);
|
||||
std::vector<string> flow_types;
|
||||
boost::split(flow_types, flow_data, boost::is_any_of(","));
|
||||
|
||||
if (flow_types.size() <= 1 || flow_types.size() != flow_type_of_machine.size()) return false;
|
||||
std::sort(used_extruders.begin(), used_extruders.end());
|
||||
|
||||
auto nozzle_volume_type_opt = dynamic_cast<const ConfigOptionEnumsGeneric *>(wxGetApp().preset_bundle->project_config.option("nozzle_volume_type"));
|
||||
for (auto i = 0; i < used_extruders.size(); i++) {
|
||||
if (nozzle_volume_type_opt) {
|
||||
NozzleVolumeType nozzle_volume_type = (NozzleVolumeType) (nozzle_volume_type_opt->get_at(used_extruders[i]));
|
||||
if (nozzle_volume_type == NozzleVolumeType::nvtNormal) { used_extruders_flow[used_extruders[i]] = "Normal";}
|
||||
else {used_extruders_flow[used_extruders[i]] = "Big Traffic";}
|
||||
}
|
||||
}
|
||||
|
||||
vector<int> map_extruders = {1, 0};
|
||||
|
||||
|
||||
// The default two extruders are left, right, but the order of the extruders on the machine is right, left.
|
||||
std::vector<std::string> flow_type_of_machine;
|
||||
for (auto it = data.extders.begin(); it != data.extders.end(); it++) {
|
||||
if (it->current_nozzle_flow_type == NozzleFlowType::H_FLOW) {
|
||||
flow_type_of_machine.push_back("Big Traffic");
|
||||
} else if (it->current_nozzle_flow_type == NozzleFlowType::S_FLOW){
|
||||
flow_type_of_machine.push_back("Normal");
|
||||
}
|
||||
}
|
||||
|
||||
//Only when all preset nozzle types and machine nozzle types are exactly the same, return true.
|
||||
for (int i = 0; i < flow_types.size(); i++) {
|
||||
if (flow_types[i] != flow_type_of_machine[i]) return false;
|
||||
for (std::map<int, std::string>::iterator it = used_extruders_flow.begin(); it!= used_extruders_flow.end(); it++) {
|
||||
int target_machine_nozzle_id = map_extruders[it->first];
|
||||
|
||||
if (target_machine_nozzle_id <= flow_type_of_machine.size()) {
|
||||
if (flow_type_of_machine[target_machine_nozzle_id] != used_extruders_flow[it->first]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1579,6 +1604,11 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector<wxSt
|
|||
update_print_status_msg(msg_text, true, false);
|
||||
Enable_Send_Button(false);
|
||||
Enable_Refresh_Button(true);
|
||||
} else if (status == PrintDialogStatus::PrintStatusNozzleDataInvalid) {
|
||||
wxString msg_text = _L("Invalid nozzle information, please refresh or manually set nozzle information.");
|
||||
update_print_status_msg(msg_text, true, false);
|
||||
Enable_Send_Button(false);
|
||||
Enable_Refresh_Button(true);
|
||||
} else if (status == PrintDialogStatus::PrintStatusNozzleMatchInvalid) {
|
||||
wxString msg_text = _L("Please check whether the nozzle type of the device is the same as the preset nozzle type.");
|
||||
update_print_status_msg(msg_text, true, false);
|
||||
|
|
@ -3009,9 +3039,16 @@ void SelectMachineDialog::update_show_status()
|
|||
size_t nozzle_nums = full_config.option<ConfigOptionFloats>("nozzle_diameter")->values.size();
|
||||
|
||||
//the nozzle type of preset and machine are different
|
||||
if (nozzle_nums > 1 && !is_nozzle_type_match(obj_->m_extder_data)) {
|
||||
show_status(PrintDialogStatus::PrintStatusNozzleMatchInvalid);
|
||||
return;
|
||||
if (nozzle_nums > 1) {
|
||||
if (!obj_->is_nozzle_data_invalid()) {
|
||||
show_status(PrintDialogStatus::PrintStatusNozzleDataInvalid);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_nozzle_type_match(obj_->m_extder_data)) {
|
||||
show_status(PrintDialogStatus::PrintStatusNozzleMatchInvalid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_mapping_popup.m_supporting_mix_print && nozzle_nums == 1)
|
||||
|
|
@ -3606,13 +3643,6 @@ void SelectMachineDialog::reset_and_sync_ams_list()
|
|||
}
|
||||
}
|
||||
|
||||
/*if (extruders.size() <= 10) {
|
||||
m_sizer_ams_mapping->SetCols(extruders.size());
|
||||
}
|
||||
else {
|
||||
m_sizer_ams_mapping->SetCols(10);
|
||||
}*/
|
||||
|
||||
if (use_double_extruder)
|
||||
{
|
||||
m_filament_left_panel->Show();
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ enum PrintDialogStatus {
|
|||
PrintStatusAmsMappingU0Invalid,
|
||||
PrintStatusAmsMappingMixInvalid,
|
||||
PrintStatusNozzleMatchInvalid,
|
||||
PrintStatusNozzleDataInvalid,
|
||||
PrintStatusAmsMappingValid,
|
||||
PrintStatusAmsMappingByOrder,
|
||||
PrintStatusRefreshingMachineList,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue