ENH: clean codes about device

JIRA: [STUDIO-13609]
Change-Id: I591de7033360b9570600006cfbce2148a8d031d5
(cherry picked from commit e9c774be8f4c89b8dafa14ef56913612fb68bd0c)
This commit is contained in:
xin.zhang
2025-10-02 09:30:48 +08:00
committed by Noisyfox
parent e17c8bfb80
commit 4a787f6ff8
115 changed files with 7238 additions and 5492 deletions
+43
View File
@@ -1,4 +1,47 @@
src/libslic3r/PresetBundle.cpp src/libslic3r/PresetBundle.cpp
src/slic3r/GUI/DeviceCore/DevBed.cpp
src/slic3r/GUI/DeviceCore/DevBed.h
src/slic3r/GUI/DeviceCore/DevConfig.h
src/slic3r/GUI/DeviceCore/DevConfig.cpp
src/slic3r/GUI/DeviceCore/DevConfigUtil.h
src/slic3r/GUI/DeviceCore/DevConfigUtil.cpp
src/slic3r/GUI/DeviceCore/DevCtrl.h
src/slic3r/GUI/DeviceCore/DevCtrl.cpp
src/slic3r/GUI/DeviceCore/DevDefs.h
src/slic3r/GUI/DeviceCore/DevExtruderSystem.h
src/slic3r/GUI/DeviceCore/DevExtruderSystem.cpp
src/slic3r/GUI/DeviceCore/DevExtruderSystemCtrl.cpp
src/slic3r/GUI/DeviceCore/DevFan.cpp
src/slic3r/GUI/DeviceCore/DevFan.h
src/slic3r/GUI/DeviceCore/DevFilaAmsSetting.h
src/slic3r/GUI/DeviceCore/DevFilaAmsSetting.cpp
src/slic3r/GUI/DeviceCore/DevFilaBlackList.h
src/slic3r/GUI/DeviceCore/DevFilaBlackList.cpp
src/slic3r/GUI/DeviceCore/DevFilaSystem.h
src/slic3r/GUI/DeviceCore/DevFilaSystem.cpp
src/slic3r/GUI/DeviceCore/DevFirmware.h
src/slic3r/GUI/DeviceCore/DevFirmware.cpp
src/slic3r/GUI/DeviceCore/DevPrintOptions.h
src/slic3r/GUI/DeviceCore/DevPrintOptions.cpp
src/slic3r/GUI/DeviceCore/DevPrintTaskInfo.h
src/slic3r/GUI/DeviceCore/DevPrintTaskInfo.cpp
src/slic3r/GUI/DeviceCore/DevHMS.h
src/slic3r/GUI/DeviceCore/DevHMS.cpp
src/slic3r/GUI/DeviceCore/DevStorage.h
src/slic3r/GUI/DeviceCore/DevStorage.cpp
src/slic3r/GUI/DeviceCore/DevInfo.h
src/slic3r/GUI/DeviceCore/DevInfo.cpp
src/slic3r/GUI/DeviceCore/DevLamp.h
src/slic3r/GUI/DeviceCore/DevLamp.cpp
src/slic3r/GUI/DeviceCore/DevLampCtrl.cpp
src/slic3r/GUI/DeviceCore/DevManager.h
src/slic3r/GUI/DeviceCore/DevManager.cpp
src/slic3r/GUI/DeviceCore/DevMapping.h
src/slic3r/GUI/DeviceCore/DevMapping.cpp
src/slic3r/GUI/DeviceCore/DevNozzleSystem.h
src/slic3r/GUI/DeviceCore/DevNozzleSystem.cpp
src/slic3r/GUI/DeviceCore/DevUtil.h
src/slic3r/GUI/DeviceCore/DevUtil.cpp
src/slic3r/GUI/DeviceTab/uiAmsHumidityPopup.h src/slic3r/GUI/DeviceTab/uiAmsHumidityPopup.h
src/slic3r/GUI/DeviceTab/uiAmsHumidityPopup.cpp src/slic3r/GUI/DeviceTab/uiAmsHumidityPopup.cpp
src/slic3r/GUI/DeviceTab/uiDeviceUpdateVersion.h src/slic3r/GUI/DeviceTab/uiDeviceUpdateVersion.h
+1
View File
@@ -95,6 +95,7 @@ set(lisbslic3r_sources
ClipperZUtils.hpp ClipperZUtils.hpp
Color.cpp Color.cpp
Color.hpp Color.hpp
CommonDefs.hpp
Config.cpp Config.cpp
Config.hpp Config.hpp
CustomGCode.cpp CustomGCode.cpp
+21
View File
@@ -0,0 +1,21 @@
#pragma once
// CommonDefs.hpp
// ---------------
// This header provides common definitions and enumerations shared across multiple libraries.
// It is intended for use in projects that require consistent type definitions, such as nozzle types.
// The contents of this file are designed to be reusable and maintainable for cross-library integration.
namespace Slic3r
{
// BBS
enum NozzleType
{
ntUndefine = 0,
ntHardenedSteel,
ntStainlessSteel,
ntTungstenCarbide,
ntBrass,
ntCount
};
}
+1 -10
View File
@@ -17,6 +17,7 @@
#define slic3r_PrintConfig_hpp_ #define slic3r_PrintConfig_hpp_
#include "libslic3r.h" #include "libslic3r.h"
#include "CommonDefs.hpp"
#include "Config.hpp" #include "Config.hpp"
#include "Polygon.hpp" #include "Polygon.hpp"
#include <boost/preprocessor/facilities/empty.hpp> #include <boost/preprocessor/facilities/empty.hpp>
@@ -309,16 +310,6 @@ enum LayerSeq {
flsCustomize flsCustomize
}; };
// BBS
enum NozzleType {
ntUndefine = 0,
ntHardenedSteel,
ntStainlessSteel,
ntTungstenCarbide,
ntBrass,
ntCount
};
static std::unordered_map<NozzleType, std::string>NozzleTypeEumnToStr = { static std::unordered_map<NozzleType, std::string>NozzleTypeEumnToStr = {
{NozzleType::ntUndefine, "undefine"}, {NozzleType::ntUndefine, "undefine"},
{NozzleType::ntHardenedSteel, "hardened_steel"}, {NozzleType::ntHardenedSteel, "hardened_steel"},
+1
View File
@@ -614,6 +614,7 @@ set(SLIC3R_GUI_SOURCES
Utils/WxFontUtils.hpp Utils/WxFontUtils.hpp
) )
add_subdirectory(GUI/DeviceCore)
add_subdirectory(GUI/DeviceTab) add_subdirectory(GUI/DeviceTab)
if (WIN32) if (WIN32)
+34 -33
View File
@@ -11,6 +11,15 @@
#include "../Utils/ColorSpaceConvert.hpp" #include "../Utils/ColorSpaceConvert.hpp"
#include "EncodedFilament.hpp" #include "EncodedFilament.hpp"
#include "DeviceCore/DevConfig.h"
#include "DeviceCore/DevExtruderSystem.h"
#include "DeviceCore/DevFilaBlackList.h"
#include "DeviceCore/DevFilaSystem.h"
#define FILAMENT_MAX_TEMP 300
#define FILAMENT_MIN_TEMP 120
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
wxDEFINE_EVENT(EVT_SELECTED_COLOR, wxCommandEvent); wxDEFINE_EVENT(EVT_SELECTED_COLOR, wxCommandEvent);
@@ -534,7 +543,7 @@ void AMSMaterialsSetting::on_select_reset(wxCommandEvent& event) {
select_index_info.tray_id = tray_id; select_index_info.tray_id = tray_id;
select_index_info.ams_id = ams_id; select_index_info.ams_id = ams_id;
select_index_info.slot_id = slot_id; select_index_info.slot_id = slot_id;
select_index_info.nozzle_diameter = obj->m_extder_data.extders[0].current_nozzle_diameter; select_index_info.nozzle_diameter = obj->GetExtderSystem()->GetNozzleDiameter(0);
select_index_info.cali_idx = -1; select_index_info.cali_idx = -1;
select_index_info.filament_id = selected_ams_id; select_index_info.filament_id = selected_ams_id;
CalibUtils::select_PA_calib_result(select_index_info); CalibUtils::select_PA_calib_result(select_index_info);
@@ -571,7 +580,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
if (vendor && (vendor->values.size() > 0)) { if (vendor && (vendor->values.size() > 0)) {
std::string vendor_name = vendor->values[0]; std::string vendor_name = vendor->values[0];
DeviceManager::check_filaments_in_blacklist(obj->printer_type, vendor_name, filamnt_type, it->filament_id, ams_id, slot_id, it->name, in_blacklist, action, info); DevFilaBlacklist::check_filaments_in_blacklist(obj->printer_type, vendor_name, filamnt_type, it->filament_id, ams_id, slot_id, it->name, in_blacklist, action, info);
} }
if (in_blacklist) { if (in_blacklist) {
@@ -659,7 +668,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
select_index_info.tray_id = vt_tray; select_index_info.tray_id = vt_tray;
select_index_info.ams_id = ams_id; select_index_info.ams_id = ams_id;
select_index_info.slot_id = 0; select_index_info.slot_id = 0;
select_index_info.nozzle_diameter = obj->m_extder_data.extders[0].current_nozzle_diameter; select_index_info.nozzle_diameter = obj->GetExtderSystem()->GetNozzleDiameter(0);
auto cali_select_id = m_comboBox_cali_result->GetSelection(); auto cali_select_id = m_comboBox_cali_result->GetSelection();
if (m_pa_profile_items.size() > 0 && cali_select_id >= 0) { if (m_pa_profile_items.size() > 0 && cali_select_id >= 0) {
@@ -700,7 +709,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
select_index_info.tray_id = cali_tray_id; select_index_info.tray_id = cali_tray_id;
select_index_info.ams_id = ams_id; select_index_info.ams_id = ams_id;
select_index_info.slot_id = slot_id; select_index_info.slot_id = slot_id;
select_index_info.nozzle_diameter = obj->m_extder_data.extders[0].current_nozzle_diameter; select_index_info.nozzle_diameter = obj->GetExtderSystem()->GetNozzleDiameter(0);
auto cali_select_id = m_comboBox_cali_result->GetSelection(); auto cali_select_id = m_comboBox_cali_result->GetSelection();
if (m_pa_profile_items.size() > 0 && cali_select_id > 0) { if (m_pa_profile_items.size() > 0 && cali_select_id > 0) {
@@ -784,14 +793,7 @@ void AMSMaterialsSetting::on_clr_picker(wxMouseEvent &event)
} }
std::vector<wxColour> ams_colors; std::vector<wxColour> ams_colors;
for (auto ams_it = obj->amsList.begin(); ams_it != obj->amsList.end(); ++ams_it) { obj->GetFilaSystem()->CollectAmsColors(ams_colors);
for (auto tray_id = ams_it->second->trayList.begin(); tray_id != ams_it->second->trayList.end(); ++tray_id) {
std::vector<wxColour>::iterator iter = find(ams_colors.begin(), ams_colors.end(), AmsTray::decode_color(tray_id->second->color));
if (iter == ams_colors.end()) {
ams_colors.push_back(AmsTray::decode_color(tray_id->second->color));
}
}
}
wxPoint img_pos = m_clr_picker->ClientToScreen(wxPoint(0, 0)); wxPoint img_pos = m_clr_picker->ClientToScreen(wxPoint(0, 0));
wxPoint popup_pos(img_pos.x - m_color_picker_popup.GetSize().x - FromDIP(95), img_pos.y - FromDIP(65)); wxPoint popup_pos(img_pos.x - m_color_picker_popup.GetSize().x - FromDIP(95), img_pos.y - FromDIP(65));
@@ -882,9 +884,9 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
std::set<std::string> filament_id_set; std::set<std::string> filament_id_set;
PresetBundle * preset_bundle = wxGetApp().preset_bundle; PresetBundle * preset_bundle = wxGetApp().preset_bundle;
std::ostringstream stream; std::ostringstream stream;
stream << std::fixed << std::setprecision(1) << obj->m_extder_data.extders[0].current_nozzle_diameter; stream << std::fixed << std::setprecision(1) << obj->GetExtderSystem()->GetNozzleDiameter(0);
std::string nozzle_diameter_str = stream.str(); std::string nozzle_diameter_str = stream.str();
std::set<std::string> printer_names = preset_bundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(obj->printer_type), nozzle_diameter_str); std::set<std::string> printer_names = preset_bundle->get_printer_names_by_printer_type_and_nozzle(DevPrinterConfigUtil::get_printer_display_name(obj->printer_type), nozzle_diameter_str);
if (preset_bundle) { if (preset_bundle) {
BOOST_LOG_TRIVIAL(trace) << "system_preset_bundle filament number=" << preset_bundle->filaments.size(); BOOST_LOG_TRIVIAL(trace) << "system_preset_bundle filament number=" << preset_bundle->filaments.size();
@@ -1121,9 +1123,9 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
if (preset_bundle) { if (preset_bundle) {
std::ostringstream stream; std::ostringstream stream;
if (obj) if (obj)
stream << std::fixed << std::setprecision(1) << obj->m_extder_data.extders[0].current_nozzle_diameter; stream << std::fixed << std::setprecision(1) << obj->GetExtderSystem()->GetNozzleDiameter(0);
std::string nozzle_diameter_str = stream.str(); std::string nozzle_diameter_str = stream.str();
std::set<std::string> printer_names = preset_bundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(obj->printer_type), std::set<std::string> printer_names = preset_bundle->get_printer_names_by_printer_type_and_nozzle(DevPrinterConfigUtil::get_printer_display_name(obj->printer_type),
nozzle_diameter_str); nozzle_diameter_str);
for (auto it = preset_bundle->filaments.begin(); it != preset_bundle->filaments.end(); it++) { for (auto it = preset_bundle->filaments.begin(); it != preset_bundle->filaments.end(); it++) {
if (!m_comboBox_filament->GetValue().IsEmpty()) { if (!m_comboBox_filament->GetValue().IsEmpty()) {
@@ -1242,13 +1244,13 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
}; };
int extruder_id = obj->get_extruder_id_by_ams_id(std::to_string(ams_id)); int extruder_id = obj->get_extruder_id_by_ams_id(std::to_string(ams_id));
if (obj->is_nozzle_flow_type_supported() && (obj->get_nozzle_flow_type(extruder_id) == NozzleFlowType::NONE_FLOWTYPE)) if (obj->is_nozzle_flow_type_supported() && (obj->GetExtderSystem()->GetNozzleFlowType(extruder_id) == NozzleFlowType::NONE_FLOWTYPE))
{ {
MessageDialog dlg(nullptr, _L("The nozzle flow is not set. Please set the nozzle flow rate before editing the filament.\n'Device -> Print parts'"), _L("Warning"), wxICON_WARNING | wxOK); MessageDialog dlg(nullptr, _L("The nozzle flow is not set. Please set the nozzle flow rate before editing the filament.\n'Device -> Print parts'"), _L("Warning"), wxICON_WARNING | wxOK);
dlg.ShowModal(); dlg.ShowModal();
} }
NozzleFlowType nozzle_flow_type = obj->get_nozzle_flow_type(extruder_id); NozzleFlowType nozzle_flow_type = obj->GetExtderSystem()->GetNozzleFlowType(extruder_id);
NozzleVolumeType nozzle_volume_type = NozzleVolumeType::nvtStandard; NozzleVolumeType nozzle_volume_type = NozzleVolumeType::nvtStandard;
if (nozzle_flow_type != NozzleFlowType::NONE_FLOWTYPE) if (nozzle_flow_type != NozzleFlowType::NONE_FLOWTYPE)
{ {
@@ -1260,7 +1262,7 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
PACalibResult default_item; PACalibResult default_item;
default_item.cali_idx = -1; default_item.cali_idx = -1;
default_item.filament_id = ams_filament_id; default_item.filament_id = ams_filament_id;
if (obj->is_support_auto_flow_calibration) { if (obj->GetConfig()->SupportCalibrationPA_FlowAuto()) {
default_item.k_value = -1; default_item.k_value = -1;
default_item.n_coef = -1; default_item.n_coef = -1;
} }
@@ -1302,21 +1304,20 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
} }
else { else {
if (from_printer && (*from_printer == 1)) { if (from_printer && (*from_printer == 1)) {
if (this->obj->amsList.find(std::to_string(ams_id)) != this->obj->amsList.end()) { DevAmsTray* selected_tray = this->obj->GetFilaSystem()->GetAmsTray(std::to_string(ams_id), std::to_string(slot_id));
Ams* selected_ams = this->obj->amsList[std::to_string(ams_id)]; if (!selected_tray)
if (!selected_ams) {
return; return;
AmsTray* selected_tray = selected_ams->trayList[std::to_string(slot_id)];
if (!selected_tray)
return;
cali_select_idx = CalibUtils::get_selected_calib_idx(m_pa_profile_items, selected_tray->cali_idx);
if (cali_select_idx < 0) {
BOOST_LOG_TRIVIAL(info) << "extrusion_cali_status_error: cannot find pa profile, ams_id = " << ams_id
<< ", slot_id = " << slot_id << ", cali_idx = " << selected_tray->cali_idx;
cali_select_idx = 0;
}
m_comboBox_cali_result->SetSelection(cali_select_idx);
} }
cali_select_idx = CalibUtils::get_selected_calib_idx(m_pa_profile_items, selected_tray->cali_idx);
if (cali_select_idx < 0)
{
BOOST_LOG_TRIVIAL(info) << "extrusion_cali_status_error: cannot find pa profile, ams_id = " << ams_id
<< ", slot_id = " << slot_id << ", cali_idx = " << selected_tray->cali_idx;
cali_select_idx = 0;
}
m_comboBox_cali_result->SetSelection(cali_select_idx);
} }
else { else {
int index = get_cali_index(m_comboBox_filament->GetLabel().ToStdString()); int index = get_cali_index(m_comboBox_filament->GetLabel().ToStdString());
+62 -55
View File
@@ -23,6 +23,8 @@
#include "BitmapCache.hpp" #include "BitmapCache.hpp"
#include "BindDialog.hpp" #include "BindDialog.hpp"
#include "DeviceCore/DevFilaSystem.h"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
#define MATERIAL_ITEM_SIZE wxSize(FromDIP(65), FromDIP(50)) #define MATERIAL_ITEM_SIZE wxSize(FromDIP(65), FromDIP(50))
#define MATERIAL_REC_WHEEL_SIZE wxSize(FromDIP(17), FromDIP(16)) #define MATERIAL_REC_WHEEL_SIZE wxSize(FromDIP(17), FromDIP(16))
@@ -1038,12 +1040,12 @@ void AmsMapingPopup::update_items_check_state(const std::vector<FilamentInfo>& a
void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>& ams_mapping_result) void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>& ams_mapping_result)
{ {
//BOOST_LOG_TRIVIAL(info) << "ams_mapping nozzle count " << obj->m_extder_data.nozzle.size(); //BOOST_LOG_TRIVIAL(info) << "ams_mapping nozzle count " << obj->get_extder_system()->nozzle.size();
BOOST_LOG_TRIVIAL(info) << "ams_mapping total count " << obj->amsList.size(); BOOST_LOG_TRIVIAL(info) << "ams_mapping total count " << obj->GetFilaSystem()->GetAmsCount();
if (!obj) {return;} if (!obj) {return;}
m_ams_remain_detect_flag = obj->ams_calibrate_remain_flag; m_ams_remain_detect_flag = obj->GetFilaSystem()->IsDetectRemainEnabled();
for (auto& ams_container : m_amsmapping_container_list) { for (auto& ams_container : m_amsmapping_container_list) {
ams_container->Destroy(); ams_container->Destroy();
@@ -1068,7 +1070,7 @@ void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>&
//const auto& full_config = wxGetApp().preset_bundle->full_config(); //const auto& full_config = wxGetApp().preset_bundle->full_config();
//size_t nozzle_nums = full_config.option<ConfigOptionFloats>("nozzle_diameter")->values.size(); //size_t nozzle_nums = full_config.option<ConfigOptionFloats>("nozzle_diameter")->values.size();
size_t nozzle_nums = obj->m_extder_data.total_extder_count; size_t nozzle_nums = obj->GetExtderSystem()->GetTotalExtderCount();
if (nozzle_nums == 1) { if (nozzle_nums == 1) {
m_left_marea_panel->Hide(); m_left_marea_panel->Hide();
@@ -1121,7 +1123,7 @@ void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>&
for (int i = 0; i < obj->vt_slot.size(); i++) { for (int i = 0; i < obj->vt_slot.size(); i++) {
AmsTray* tray_data = &obj->vt_slot[i]; DevAmsTray* tray_data = &obj->vt_slot[i];
TrayData td; TrayData td;
td.id = std::stoi(tray_data->id); td.id = std::stoi(tray_data->id);
@@ -1141,12 +1143,12 @@ void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>&
else { else {
td.type = NORMAL; td.type = NORMAL;
td.remain = tray_data->remain; td.remain = tray_data->remain;
td.colour = AmsTray::decode_color(tray_data->color); td.colour = DevAmsTray::decode_color(tray_data->color);
td.name = tray_data->get_display_filament_type(); td.name = tray_data->get_display_filament_type();
td.filament_type = tray_data->get_filament_type(); td.filament_type = tray_data->get_filament_type();
td.ctype = tray_data->ctype; td.ctype = tray_data->ctype;
for (auto col : tray_data->cols) { for (auto col : tray_data->cols) {
td.material_cols.push_back(AmsTray::decode_color(col)); td.material_cols.push_back(DevAmsTray::decode_color(col));
} }
} }
@@ -1167,15 +1169,16 @@ void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>&
std::list<MappingContainer *> right_one_slot_containers; std::list<MappingContainer *> right_one_slot_containers;
std::vector<MappingContainer *> left_four_slots_containers; std::vector<MappingContainer *> left_four_slots_containers;
std::vector<MappingContainer *> right_four_slot_containers; std::vector<MappingContainer *> right_four_slot_containers;
for (std::map<std::string, Ams *>::iterator ams_iter = obj->amsList.begin(); ams_iter != obj->amsList.end(); ams_iter++) {
const auto& ams_list = obj->GetFilaSystem()->GetAmsList();
for (auto ams_iter = ams_list.begin(); ams_iter != ams_list.end(); ams_iter++) {
int ams_indx = atoi(ams_iter->first.c_str()); int ams_indx = atoi(ams_iter->first.c_str());
int ams_type = ams_iter->second->type; int nozzle_id = ams_iter->second->GetExtruderId();
int nozzle_id = ams_iter->second->nozzle;
auto sizer_mapping_list = new wxBoxSizer(wxHORIZONTAL); auto sizer_mapping_list = new wxBoxSizer(wxHORIZONTAL);
auto ams_mapping_item_container = new MappingContainer(nozzle_id == 0 ? m_right_marea_panel : m_left_marea_panel, ams_iter->second->get_ams_device_name(), auto ams_mapping_item_container = new MappingContainer(nozzle_id == 0 ? m_right_marea_panel : m_left_marea_panel, ams_iter->second->GetDisplayName(),
ams_iter->second->trayList.size()); ams_iter->second->GetSlotCount());
ams_mapping_item_container->SetName(nozzle_id == 0 ? m_right_marea_panel->GetName() : m_left_marea_panel->GetName()); ams_mapping_item_container->SetName(nozzle_id == 0 ? m_right_marea_panel->GetName() : m_left_marea_panel->GetName());
ams_mapping_item_container->SetSizer(sizer_mapping_list); ams_mapping_item_container->SetSizer(sizer_mapping_list);
ams_mapping_item_container->Layout(); ams_mapping_item_container->Layout();
@@ -1184,19 +1187,20 @@ void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>&
BOOST_LOG_TRIVIAL(trace) << "ams_mapping ams id " << ams_iter->first.c_str(); BOOST_LOG_TRIVIAL(trace) << "ams_mapping ams id " << ams_iter->first.c_str();
Ams * ams_group = ams_iter->second; DevAms* ams_group = ams_iter->second;
auto ams_type = ams_group->GetAmsType();
std::vector<TrayData> tray_datas; std::vector<TrayData> tray_datas;
std::map<std::string, AmsTray *>::iterator tray_iter; std::map<std::string, DevAmsTray *>::const_iterator tray_iter;
for (tray_iter = ams_group->GetTrays().cbegin(); tray_iter != ams_group->GetTrays().cend(); tray_iter++)
for (tray_iter = ams_group->trayList.begin(); tray_iter != ams_group->trayList.end(); tray_iter++) { {
AmsTray *tray_data = tray_iter->second; DevAmsTray *tray_data = tray_iter->second;
TrayData td; TrayData td;
if (ams_type == AMSModel::GENERIC_AMS || ams_type == AMSModel::AMS_LITE || ams_type == AMSModel::N3F_AMS) { if (ams_type == AMSModel::GENERIC_AMS || ams_type == AMSModel::AMS_LITE || ams_type == AMSModel::N3F_AMS) {
td.id = ams_indx * AMS_TOTAL_COUNT + atoi(tray_data->id.c_str()); td.id = ams_indx * AMS_TOTAL_COUNT + atoi(tray_data->id.c_str());
} else if (ams_type == AMSModel::N3S_AMS) { } else if (ams_type == AMSModel::N3S_AMS) {
td.id = ams_indx + atoi(tray_data->id.c_str()); td.id = ams_indx + atoi(tray_data->id.c_str());
} }
td.ams_id = std::stoi(ams_iter->second->id); td.ams_id = std::stoi(ams_iter->second->GetAmsId());
td.slot_id = std::stoi(tray_iter->second->id); td.slot_id = std::stoi(tray_iter->second->id);
if (!tray_data->is_exists) { if (!tray_data->is_exists) {
@@ -1207,11 +1211,11 @@ void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>&
} else { } else {
td.type = NORMAL; td.type = NORMAL;
td.remain = tray_data->remain; td.remain = tray_data->remain;
td.colour = AmsTray::decode_color(tray_data->color); td.colour = DevAmsTray::decode_color(tray_data->color);
td.name = tray_data->get_display_filament_type(); td.name = tray_data->get_display_filament_type();
td.filament_type = tray_data->get_filament_type(); td.filament_type = tray_data->get_filament_type();
td.ctype = tray_data->ctype; td.ctype = tray_data->ctype;
for (auto col : tray_data->cols) { td.material_cols.push_back(AmsTray::decode_color(col)); } for (auto col : tray_data->cols) { td.material_cols.push_back(DevAmsTray::decode_color(col)); }
} }
} }
@@ -1219,7 +1223,7 @@ void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>&
} }
ams_mapping_item_container->Show(); ams_mapping_item_container->Show();
add_ams_mapping(tray_datas, obj->ams_calibrate_remain_flag, ams_mapping_item_container, sizer_mapping_list); add_ams_mapping(tray_datas, obj->GetFilaSystem()->IsDetectRemainEnabled(), ams_mapping_item_container, sizer_mapping_list);
m_amsmapping_container_sizer_list.push_back(sizer_mapping_list); m_amsmapping_container_sizer_list.push_back(sizer_mapping_list);
m_amsmapping_container_list.push_back(ams_mapping_item_container); m_amsmapping_container_list.push_back(ams_mapping_item_container);
@@ -1253,22 +1257,22 @@ void AmsMapingPopup::update(MachineObject* obj, const std::vector<FilamentInfo>&
Refresh(); Refresh();
} }
std::vector<TrayData> AmsMapingPopup::parse_ams_mapping(std::map<std::string, Ams*> amsList) std::vector<TrayData> AmsMapingPopup::parse_ams_mapping(std::map<std::string, DevAms*> amsList)
{ {
std::vector<TrayData> m_tray_data; std::vector<TrayData> m_tray_data;
std::map<std::string, Ams *>::iterator ams_iter; std::map<std::string, DevAms *>::iterator ams_iter;
for (ams_iter = amsList.begin(); ams_iter != amsList.end(); ams_iter++) { for (ams_iter = amsList.begin(); ams_iter != amsList.end(); ams_iter++) {
BOOST_LOG_TRIVIAL(trace) << "ams_mapping ams id " << ams_iter->first.c_str(); BOOST_LOG_TRIVIAL(trace) << "ams_mapping ams id " << ams_iter->first.c_str();
auto ams_indx = atoi(ams_iter->first.c_str()); auto ams_indx = atoi(ams_iter->first.c_str());
Ams* ams_group = ams_iter->second; DevAms* ams_group = ams_iter->second;
std::vector<TrayData> tray_datas; std::vector<TrayData> tray_datas;
std::map<std::string, AmsTray*>::iterator tray_iter; std::map<std::string, DevAmsTray*>::const_iterator tray_iter;
for (tray_iter = ams_group->trayList.begin(); tray_iter != ams_group->trayList.end(); tray_iter++) { for (tray_iter = ams_group->GetTrays().cbegin(); tray_iter != ams_group->GetTrays().cend(); tray_iter++) {
AmsTray* tray_data = tray_iter->second; DevAmsTray* tray_data = tray_iter->second;
TrayData td; TrayData td;
td.id = ams_indx * AMS_TOTAL_COUNT + atoi(tray_data->id.c_str()); td.id = ams_indx * AMS_TOTAL_COUNT + atoi(tray_data->id.c_str());
@@ -1283,7 +1287,7 @@ std::vector<TrayData> AmsMapingPopup::parse_ams_mapping(std::map<std::string, Am
else { else {
td.type = NORMAL; td.type = NORMAL;
td.remain = tray_data->remain; td.remain = tray_data->remain;
td.colour = AmsTray::decode_color(tray_data->color); td.colour = DevAmsTray::decode_color(tray_data->color);
td.name = tray_data->get_display_filament_type(); td.name = tray_data->get_display_filament_type();
td.filament_type = tray_data->get_filament_type(); td.filament_type = tray_data->get_filament_type();
} }
@@ -2258,7 +2262,7 @@ void AmsReplaceMaterialDialog::update_machine_obj(MachineObject* obj)
if (obj) if (obj)
{ {
m_obj = obj; m_obj = obj;
if (obj->m_extder_data.total_extder_count > 1) if (obj->GetExtderSystem()->GetTotalExtderCount() > 1)
{ {
m_nozzle_btn_panel->updateState("right"); m_nozzle_btn_panel->updateState("right");
m_nozzle_btn_panel->Show(); m_nozzle_btn_panel->Show();
@@ -2268,7 +2272,7 @@ void AmsReplaceMaterialDialog::update_machine_obj(MachineObject* obj)
m_nozzle_btn_panel->Hide(); m_nozzle_btn_panel->Hide();
} }
update_to_nozzle(MAIN_NOZZLE_ID); update_to_nozzle(MAIN_EXTRUDER_ID);
} }
} }
@@ -2321,7 +2325,7 @@ void AmsReplaceMaterialDialog::update_to_nozzle(int nozzle_id)
return; return;
} }
if (m_obj->m_extder_data.extders.size() < nozzle_id) if (m_obj->GetExtderSystem()->GetTotalExtderCount() < nozzle_id)
{ {
return; return;
} }
@@ -2329,38 +2333,40 @@ void AmsReplaceMaterialDialog::update_to_nozzle(int nozzle_id)
//update group //update group
int group_index = 0; int group_index = 0;
m_groups_sizer->Clear(true); m_groups_sizer->Clear(true);
if (m_obj->is_support_filament_backup && m_obj->ams_auto_switch_filament_flag) if (m_obj->is_support_filament_backup && m_obj->GetFilaSystem()->IsAutoRefillEnabled())
{ {
// traverse the amd list // traverse the amd list
std::unordered_map<int, AmsTray*> id2tray;// tray id to tray std::unordered_map<int, DevAmsTray*> id2tray;// tray id to tray
try try
{ {
for (const auto& ams_info : m_obj->amsList) for (const auto& ams_info : m_obj->GetFilaSystem()->GetAmsList())
{ {
int ams_device_id = atoi(ams_info.first.c_str()); int ams_device_id = atoi(ams_info.first.c_str());
if (ams_device_id < 128) if (ams_device_id < 128)
{ {
int ams_base_id = ams_device_id * 4; int ams_base_id = ams_device_id * 4;
for (auto tray_info : ams_info.second->trayList) for (auto tray_info : ams_info.second->GetTrays())
{ {
int tray_offset = atoi(tray_info.first.c_str()); int tray_offset = atoi(tray_info.first.c_str());
id2tray[ams_base_id + tray_offset] = tray_info.second; id2tray[ams_base_id + tray_offset] = tray_info.second;
} }
} }
else if (ams_info.second->trayList.size() == 1)/*n3f*/ else if (ams_info.second->GetTrays().size() == 1)/*n3f*/
{ {
id2tray[ams_device_id] = ams_info.second->trayList.begin()->second; id2tray[ams_device_id] = ams_info.second->GetTrays().begin()->second;
} }
} }
} }
catch (...) {} catch (...) {}
const Extder& extder = m_obj->m_extder_data.extders[nozzle_id]; const auto& extder = m_obj->GetExtderSystem()->GetExtderById(nozzle_id);
for (int filam : extder.filam_bak) if (extder)
{ {
std::map<std::string, wxColour> group_info; for (int filam : extder->GetFilamBackup())
std::string group_material; {
bool is_in_tray = false; std::map<std::string, wxColour> group_info;
std::string group_material;
bool is_in_tray = false;
//get color & material //get color & material
const auto& trayid_group = _GetBackupStatus(filam); const auto& trayid_group = _GetBackupStatus(filam);
@@ -2368,7 +2374,7 @@ void AmsReplaceMaterialDialog::update_to_nozzle(int nozzle_id)
{ {
if (elem.second) if (elem.second)
{ {
AmsTray* cur_tray = id2tray[elem.first]; DevAmsTray* cur_tray = id2tray[elem.first];
if (cur_tray) if (cur_tray)
{ {
auto tray_name = wxGetApp().transition_tridid(elem.first).ToStdString(); auto tray_name = wxGetApp().transition_tridid(elem.first).ToStdString();
@@ -2378,21 +2384,22 @@ void AmsReplaceMaterialDialog::update_to_nozzle(int nozzle_id)
is_in_tray = true; is_in_tray = true;
} }
group_info[tray_name] = AmsTray::decode_color(cur_tray->color); group_info[tray_name] = DevAmsTray::decode_color(cur_tray->color);
group_material = cur_tray->get_display_filament_type(); group_material = cur_tray->get_display_filament_type();
}
} }
} }
}
if (group_info.size() < 2) /* do not show refill if there is one tray*/ if (group_info.size() < 2) /* do not show refill if there is one tray*/
{ {
continue; continue;
} }
if (is_in_tray || m_tray_used.size() <= 0) if (is_in_tray || m_tray_used.size() <= 0)
{ {
m_groups_sizer->Add(create_backup_group(wxString::Format("%s%d", _L("Group"), group_index + 1), group_info, group_material), 0, wxALL, FromDIP(10)); m_groups_sizer->Add(create_backup_group(wxString::Format("%s%d", _L("Group"), group_index + 1), group_info, group_material), 0, wxALL, FromDIP(10));
group_index++; group_index++;
}
} }
} }
} }
@@ -2430,7 +2437,7 @@ void AmsReplaceMaterialDialog::update_to_nozzle(int nozzle_id)
{ {
label_txt->SetLabel(_L("The printer does not currently support auto refill.")); label_txt->SetLabel(_L("The printer does not currently support auto refill."));
} }
else if (!m_obj->ams_auto_switch_filament_flag) else if (!m_obj->GetFilaSystem()->IsAutoRefillEnabled())
{ {
label_txt->SetLabelText(_L("AMS filament backup is not enabled, please enable it in the AMS settings.")); label_txt->SetLabelText(_L("AMS filament backup is not enabled, please enable it in the AMS settings."));
} }
+1 -1
View File
@@ -278,7 +278,7 @@ public:
void paintEvent(wxPaintEvent &evt); void paintEvent(wxPaintEvent &evt);
void set_parent_item(MaterialItem* item) {m_parent_item = item;}; void set_parent_item(MaterialItem* item) {m_parent_item = item;};
void set_show_type(ShowType type) { m_show_type = type; }; void set_show_type(ShowType type) { m_show_type = type; };
std::vector<TrayData> parse_ams_mapping(std::map<std::string, Ams*> amsList); std::vector<TrayData> parse_ams_mapping(std::map<std::string, DevAms*> amsList);
using ResetCallback = std::function<void(const std::string&)>; using ResetCallback = std::function<void(const std::string&)>;
void reset_ams_info(); void reset_ams_info();
+11 -6
View File
@@ -10,6 +10,8 @@
#include "Widgets/Label.hpp" #include "Widgets/Label.hpp"
#include "format.hpp" #include "format.hpp"
#include "DeviceCore/DevFilaSystem.h"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@@ -139,16 +141,19 @@ void TrayListModel::update(MachineObject* obj)
m_saturabilityColValues.clear(); m_saturabilityColValues.clear();
m_transmittanceColValues.clear(); m_transmittanceColValues.clear();
std::map<std::string, Ams*>::iterator ams_it; std::map<std::string, DevAms*>::iterator ams_it;
std::map<std::string, AmsTray*>::iterator tray_it; std::map<std::string, DevAmsTray*>::const_iterator tray_it;
int tray_index = 0; int tray_index = 0;
for (ams_it = obj->amsList.begin(); ams_it != obj->amsList.end(); ams_it++) {
const auto& ams_list = obj->GetFilaSystem()->GetAmsList();
for (auto ams_it = ams_list.begin(); ams_it != ams_list.end(); ams_it++)
{
if (ams_it->second) { if (ams_it->second) {
for (tray_it = ams_it->second->trayList.begin(); tray_it != ams_it->second->trayList.end(); tray_it++) { for (tray_it = ams_it->second->GetTrays().cbegin(); tray_it != ams_it->second->GetTrays().cend(); tray_it++) {
AmsTray* tray = tray_it->second; DevAmsTray* tray = tray_it->second;
if (tray) { if (tray) {
tray_index++; tray_index++;
wxString title_text = wxString::Format("tray %s(ams %s)", tray->id, ams_it->second->id); wxString title_text = wxString::Format("tray %s(ams %s)", tray->id, ams_it->second->GetAmsId());
m_titleColValues.push_back(title_text); m_titleColValues.push_back(title_text);
wxString color_text = wxString::Format("%s", tray->wx_color.GetAsString()); wxString color_text = wxString::Format("%s", tray->wx_color.GetAsString());
m_colorColValues.push_back(color_text); m_colorColValues.push_back(color_text);
+11 -8
View File
@@ -18,6 +18,8 @@
#include "Jobs/PlaterWorker.hpp" #include "Jobs/PlaterWorker.hpp"
#include "Widgets/WebView.hpp" #include "Widgets/WebView.hpp"
#include "DeviceCore/DevManager.h"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@@ -847,7 +849,7 @@ PingCodeBindDialog::~PingCodeBindDialog() {
EndModal(wxID_OK); EndModal(wxID_OK);
MessageDialog msg_wingow(nullptr, _L("Log in successful."), "", wxAPPLY | wxOK); MessageDialog msg_wingow(nullptr, _L("Log in successful."), "", wxAPPLY | wxOK);
msg_wingow.ShowModal(); msg_wingow.ShowModal();
if(m_machine_info) wxGetApp().on_start_subscribe_again(m_machine_info->dev_id); if(m_machine_info) wxGetApp().on_start_subscribe_again(m_machine_info->get_dev_id());
} }
void BindMachineDialog::on_bind_printer(wxCommandEvent &event) void BindMachineDialog::on_bind_printer(wxCommandEvent &event)
@@ -863,7 +865,7 @@ PingCodeBindDialog::~PingCodeBindDialog() {
if (m_machine_info == nullptr || m_machine_info == NULL) return; if (m_machine_info == nullptr || m_machine_info == NULL) return;
//check dev_id //check dev_id
if (m_machine_info->dev_id.empty()) return; if (m_machine_info->get_dev_id().empty()) return;
// update ota version // update ota version
NetworkAgent* agent = wxGetApp().getAgent(); NetworkAgent* agent = wxGetApp().getAgent();
@@ -871,7 +873,8 @@ PingCodeBindDialog::~PingCodeBindDialog() {
agent->track_update_property("dev_ota_version", m_machine_info->get_ota_version()); agent->track_update_property("dev_ota_version", m_machine_info->get_ota_version());
m_simplebook->SetSelection(0); m_simplebook->SetSelection(0);
auto m_bind_job = std::make_unique<BindJob>(m_machine_info->dev_id, m_machine_info->dev_ip, m_machine_info->bind_sec_link, m_machine_info->bind_ssdp_version); auto m_bind_job = std::make_unique<BindJob>(
m_machine_info->get_dev_id(), m_machine_info->get_dev_ip(), m_machine_info->bind_sec_link, m_machine_info->bind_ssdp_version);
if (m_machine_info && (m_machine_info->get_printer_series() == PrinterSeries::SERIES_X1)) { if (m_machine_info && (m_machine_info->get_printer_series() == PrinterSeries::SERIES_X1)) {
m_bind_job->set_improved(false); m_bind_job->set_improved(false);
@@ -921,7 +924,7 @@ void BindMachineDialog::on_show(wxShowEvent &event)
m_printer_img->Refresh(); m_printer_img->Refresh();
m_printer_img->Show(); m_printer_img->Show();
m_printer_name->SetLabelText(from_u8(m_machine_info->dev_name)); m_printer_name->SetLabelText(from_u8(m_machine_info->get_dev_name()));
if (wxGetApp().is_user_login()) { if (wxGetApp().is_user_login()) {
wxString username_text = from_u8(wxGetApp().getAgent()->get_user_nickanme()); wxString username_text = from_u8(wxGetApp().getAgent()->get_user_nickanme());
@@ -1099,16 +1102,16 @@ void UnBindMachineDialog::on_unbind_printer(wxCommandEvent &event)
} }
m_machine_info->set_access_code(""); m_machine_info->set_access_code("");
int result = wxGetApp().request_user_unbind(m_machine_info->dev_id); int result = wxGetApp().request_user_unbind(m_machine_info->get_dev_id());
if (result == 0) { if (result == 0) {
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return; if (!dev) return;
// clean local machine access code info // clean local machine access code info
MachineObject* obj = dev->get_local_machine(m_machine_info->dev_id); MachineObject* obj = dev->get_local_machine(m_machine_info->get_dev_id());
if (obj) { if (obj) {
obj->set_access_code(""); obj->set_access_code("");
} }
dev->erase_user_machine(m_machine_info->dev_id); dev->erase_user_machine(m_machine_info->get_dev_id());
m_status_text->SetLabelText(_L("Log out successful.")); m_status_text->SetLabelText(_L("Log out successful."));
m_button_cancel->SetLabel(_L("Close")); m_button_cancel->SetLabel(_L("Close"));
@@ -1138,7 +1141,7 @@ void UnBindMachineDialog::on_show(wxShowEvent &event)
m_printer_img->Refresh(); m_printer_img->Refresh();
m_printer_img->Show(); m_printer_img->Show();
m_printer_name->SetLabelText(from_u8(m_machine_info->dev_name)); m_printer_name->SetLabelText(from_u8(m_machine_info->get_dev_name()));
if (wxGetApp().is_user_login()) { if (wxGetApp().is_user_login()) {
+7 -4
View File
@@ -9,6 +9,9 @@
#include "slic3r/Utils/CalibUtils.hpp" #include "slic3r/Utils/CalibUtils.hpp"
#include <wx/gbsizer.h> #include <wx/gbsizer.h>
#include "DeviceCore/DevExtruderSystem.h"
#include "DeviceCore/DevManager.h"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@@ -225,7 +228,7 @@ void HistoryWindow::on_device_connected(MachineObject* obj)
int selection = 1; int selection = 1;
for (int i = 0; i < nozzle_diameter_list.size(); i++) { for (int i = 0; i < nozzle_diameter_list.size(); i++) {
m_comboBox_nozzle_dia->AppendString(wxString::Format("%1.1f mm", nozzle_diameter_list[i])); m_comboBox_nozzle_dia->AppendString(wxString::Format("%1.1f mm", nozzle_diameter_list[i]));
if (abs(curr_obj->m_extder_data.extders[0].current_nozzle_diameter - nozzle_diameter_list[i]) < 1e-3) { if (abs(curr_obj->GetExtderSystem()->GetNozzleDiameter(0) - nozzle_diameter_list[i]) < 1e-3) {
selection = i; selection = i;
} }
} }
@@ -645,7 +648,7 @@ wxArrayString NewCalibrationHistoryDialog::get_all_filaments(const MachineObject
std::set<std::string> filament_id_set; std::set<std::string> filament_id_set;
std::set<std::string> printer_names; std::set<std::string> printer_names;
std::ostringstream stream; std::ostringstream stream;
stream << std::fixed << std::setprecision(1) << obj->m_extder_data.extders[0].current_nozzle_diameter; stream << std::fixed << std::setprecision(1) << obj->GetExtderSystem()->GetNozzleDiameter(0);
std::string nozzle_diameter_str = stream.str(); std::string nozzle_diameter_str = stream.str();
for (auto printer_it = preset_bundle->printers.begin(); printer_it != preset_bundle->printers.end(); printer_it++) { for (auto printer_it = preset_bundle->printers.begin(); printer_it != preset_bundle->printers.end(); printer_it++) {
@@ -659,7 +662,7 @@ wxArrayString NewCalibrationHistoryDialog::get_all_filaments(const MachineObject
continue; continue;
// use printer_model as printer type // use printer_model as printer type
if (printer_model_str->value != MachineObject::get_preset_printer_model_name(obj->printer_type)) if (printer_model_str->value != DevPrinterConfigUtil::get_printer_display_name(obj->printer_type))
continue; continue;
if (printer_it->name.find(nozzle_diameter_str) != std::string::npos) if (printer_it->name.find(nozzle_diameter_str) != std::string::npos)
@@ -789,7 +792,7 @@ NewCalibrationHistoryDialog::NewCalibrationHistoryDialog(wxWindow *parent, const
static std::array<float, 4> nozzle_diameter_list = {0.2f, 0.4f, 0.6f, 0.8f}; static std::array<float, 4> nozzle_diameter_list = {0.2f, 0.4f, 0.6f, 0.8f};
for (int i = 0; i < nozzle_diameter_list.size(); i++) { for (int i = 0; i < nozzle_diameter_list.size(); i++) {
m_comboBox_nozzle_diameter->AppendString(wxString::Format("%1.1f mm", nozzle_diameter_list[i])); m_comboBox_nozzle_diameter->AppendString(wxString::Format("%1.1f mm", nozzle_diameter_list[i]));
if (abs(obj->m_extder_data.extders[0].current_nozzle_diameter - nozzle_diameter_list[i]) < 1e-3) { if (abs(obj->GetExtderSystem()->GetNozzleDiameter(0) - nozzle_diameter_list[i]) < 1e-3) {
m_comboBox_nozzle_diameter->SetSelection(i); m_comboBox_nozzle_diameter->SetSelection(i);
} }
} }
+8 -8
View File
@@ -11,6 +11,8 @@
#include "Widgets/RoundedRectangle.hpp" #include "Widgets/RoundedRectangle.hpp"
#include "Widgets/StaticBox.hpp" #include "Widgets/StaticBox.hpp"
#include "DeviceCore/DevConfig.h"
static wxColour FG_COLOR = wxColour(0x32, 0x3A, 0x3D); static wxColour FG_COLOR = wxColour(0x32, 0x3A, 0x3D);
static wxColour BG_COLOR = wxColour(0xF8, 0xF8, 0xF8); static wxColour BG_COLOR = wxColour(0xF8, 0xF8, 0xF8);
@@ -214,7 +216,8 @@ wxWindow* CalibrationDialog::create_check_option(wxString title, wxWindow* paren
void CalibrationDialog::update_cali(MachineObject *obj) void CalibrationDialog::update_cali(MachineObject *obj)
{ {
if (!obj) return; if (!obj) return;
if (obj->is_support_ai_monitoring && obj->is_support_lidar_calibration) { if (obj->GetConfig()->SupportAIMonitor() && obj->GetConfig()->SupportCalibrationLidar())
{
select_xcam_cali->Show(); select_xcam_cali->Show();
} else { } else {
select_xcam_cali->Hide(); select_xcam_cali->Hide();
@@ -235,19 +238,16 @@ void CalibrationDialog::update_cali(MachineObject *obj)
m_checkbox_list["motor_noise"]->SetValue(false); m_checkbox_list["motor_noise"]->SetValue(false);
} }
if (obj->is_support_nozzle_offset_cali) { if (obj->GetConfig()->SupportCalibrationNozzleOffset()) {
select_nozzle_cali->Show(); select_nozzle_cali->Show();
} else { } else {
select_nozzle_cali->Hide(); select_nozzle_cali->Hide();
m_checkbox_list["nozzle_cali"]->SetValue(false); m_checkbox_list["nozzle_cali"]->SetValue(false);
} }
if (obj->is_support_high_tempbed_cali) if (obj->GetConfig()->SupportCalibrationHighTempBed()) {
{
select_heatbed_cali->Show(); select_heatbed_cali->Show();
} } else {
else
{
select_heatbed_cali->Hide(); select_heatbed_cali->Hide();
m_checkbox_list["bed_cali"]->SetValue(false); m_checkbox_list["bed_cali"]->SetValue(false);
} }
@@ -277,7 +277,7 @@ void CalibrationDialog::update_cali(MachineObject *obj)
// change items if stage_list_info changed // change items if stage_list_info changed
m_calibration_flow->DeleteAllItems(); m_calibration_flow->DeleteAllItems();
for (int i = 0; i < obj->stage_list_info.size(); i++) { for (int i = 0; i < obj->stage_list_info.size(); i++) {
m_calibration_flow->AppendItem(get_stage_string(obj->stage_list_info[i])); m_calibration_flow->AppendItem(Slic3r::get_stage_string(obj->stage_list_info[i]));
} }
} }
int index = obj->get_curr_stage_idx(); int index = obj->get_curr_stage_idx();
+8 -6
View File
@@ -7,6 +7,8 @@
#include "SelectMachine.hpp" #include "SelectMachine.hpp"
#include "SelectMachinePop.hpp" #include "SelectMachinePop.hpp"
#include "DeviceCore/DevManager.h"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
#define REFRESH_INTERVAL 1000 #define REFRESH_INTERVAL 1000
@@ -112,7 +114,7 @@ void MObjectPanel::doRender(wxDC& dc)
dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900)); dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900));
wxString dev_name = ""; wxString dev_name = "";
if (m_info) { if (m_info) {
dev_name = from_u8(m_info->dev_name); dev_name = from_u8(m_info->get_dev_name());
if (m_state == PrinterState::IN_LAN) { if (m_state == PrinterState::IN_LAN) {
dev_name += _L("(LAN)"); dev_name += _L("(LAN)");
@@ -170,13 +172,13 @@ void MObjectPanel::on_mouse_left_up(wxMouseEvent& evt)
if (m_info->has_access_right() && m_info->is_avaliable()) { if (m_info->has_access_right() && m_info->is_avaliable()) {
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return; if (!dev) return;
dev->set_selected_machine(m_info->dev_id); dev->set_selected_machine(m_info->get_dev_id());
} }
} }
else { else {
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return; if (!dev) return;
dev->set_selected_machine(m_info->dev_id); dev->set_selected_machine(m_info->get_dev_id());
} }
wxCommandEvent event(EVT_DISSMISS_MACHINE_LIST); wxCommandEvent event(EVT_DISSMISS_MACHINE_LIST);
event.SetEventObject(this->GetParent()->GetParent()); event.SetEventObject(this->GetParent()->GetParent());
@@ -335,7 +337,7 @@ void SelectMObjectPopup::update_user_devices()
std::sort(user_machine_list.begin(), user_machine_list.end(), [&](auto& a, auto& b) { std::sort(user_machine_list.begin(), user_machine_list.end(), [&](auto& a, auto& b) {
if (a.second && b.second) { if (a.second && b.second) {
return a.second->dev_name.compare(b.second->dev_name) < 0; return a.second->get_dev_name().compare(b.second->get_dev_name()) < 0;
} }
return false; return false;
}); });
@@ -538,7 +540,7 @@ void CalibrationPanel::update_all() {
obj = dev->get_selected_machine(); obj = dev->get_selected_machine();
// check valid machine // check valid machine
if (obj && dev->get_my_machine(obj->dev_id) == nullptr) { if (obj && dev->get_my_machine(obj->get_dev_id()) == nullptr) {
dev->set_selected_machine(""); dev->set_selected_machine("");
if (m_agent) m_agent->set_user_selected_machine(""); if (m_agent) m_agent->set_user_selected_machine("");
show_status((int) MONITOR_NO_PRINTER); show_status((int) MONITOR_NO_PRINTER);
@@ -642,7 +644,7 @@ bool CalibrationPanel::Show(bool show) {
dev->load_last_machine(); dev->load_last_machine();
obj = dev->get_selected_machine(); obj = dev->get_selected_machine();
if (obj) if (obj)
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj); GUI::wxGetApp().sidebar().load_ams_list(obj->get_dev_id(), obj);
} }
else { else {
obj->reset_update_time(); obj->reset_update_time();
+8 -8
View File
@@ -184,7 +184,7 @@ void CalibrationWizard::on_device_connected(MachineObject* obj)
recover_preset_info(obj); recover_preset_info(obj);
BOOST_LOG_TRIVIAL(info) << "on_device_connected - machine object status:" BOOST_LOG_TRIVIAL(info) << "on_device_connected - machine object status:"
<< " dev_id = " << obj->dev_id << " dev_id = " << obj->get_dev_id()
<< ", print_type = " << obj->printer_type << ", print_type = " << obj->printer_type
<< ", printer_status = " << obj->print_status << ", printer_status = " << obj->print_status
<< ", cali_finished = " << obj->cali_finished << ", cali_finished = " << obj->cali_finished
@@ -417,8 +417,8 @@ void CalibrationWizard::recover_preset_info(MachineObject *obj)
{ {
std::vector<PrinterCaliInfo> back_infos = wxGetApp().app_config->get_printer_cali_infos(); std::vector<PrinterCaliInfo> back_infos = wxGetApp().app_config->get_printer_cali_infos();
for (const auto& back_info : back_infos) { for (const auto& back_info : back_infos) {
if (obj && (obj->dev_id == back_info.dev_id) ) { if (obj && (obj->get_dev_id() == back_info.dev_id) ) {
obj->dev_id = back_info.dev_id; obj->set_dev_id(back_info.dev_id);
obj->cali_finished = back_info.cali_finished; obj->cali_finished = back_info.cali_finished;
obj->cache_flow_ratio = back_info.cache_flow_ratio; obj->cache_flow_ratio = back_info.cache_flow_ratio;
obj->selected_cali_preset = back_info.selected_presets; obj->selected_cali_preset = back_info.selected_presets;
@@ -433,7 +433,7 @@ void CalibrationWizard::back_preset_info(MachineObject *obj, bool cali_finish, b
return; return;
PrinterCaliInfo printer_cali_info; PrinterCaliInfo printer_cali_info;
printer_cali_info.dev_id = obj->dev_id; printer_cali_info.dev_id = obj->get_dev_id();
printer_cali_info.cali_finished = cali_finish; printer_cali_info.cali_finished = cali_finish;
printer_cali_info.cache_flow_ratio = obj->cache_flow_ratio; printer_cali_info.cache_flow_ratio = obj->cache_flow_ratio;
printer_cali_info.selected_presets = obj->selected_cali_preset; printer_cali_info.selected_presets = obj->selected_cali_preset;
@@ -599,7 +599,7 @@ void PressureAdvanceWizard::update(MachineObject* obj)
if (obj->cali_version != -1 && obj->cali_version != cali_version) { if (obj->cali_version != -1 && obj->cali_version != cali_version) {
cali_version = obj->cali_version; cali_version = obj->cali_version;
PACalibExtruderInfo cali_info; PACalibExtruderInfo cali_info;
cali_info.nozzle_diameter = obj->m_extder_data.extders[0].current_nozzle_diameter; cali_info.nozzle_diameter = obj->GetExtderSystem()->GetNozzleDiameter(0);
cali_info.use_extruder_id = false; cali_info.use_extruder_id = false;
cali_info.use_nozzle_volume_type = false; cali_info.use_nozzle_volume_type = false;
CalibUtils::emit_get_PA_calib_infos(cali_info); CalibUtils::emit_get_PA_calib_infos(cali_info);
@@ -751,7 +751,7 @@ void PressureAdvanceWizard::on_cali_start()
int selected_tray_id = 0; 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->get_dev_id();
get_tray_ams_and_slot_id(curr_obj, selected_filaments.begin()->first, calib_info.ams_id, calib_info.slot_id, selected_tray_id); get_tray_ams_and_slot_id(curr_obj, 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);
@@ -1205,7 +1205,7 @@ void FlowRateWizard::on_cali_start(CaliPresetStage stage, float cali_value, Flow
else if (m_cali_method == CalibrationMethod::CALI_METHOD_MANUAL) { else if (m_cali_method == CalibrationMethod::CALI_METHOD_MANUAL) {
CalibrationFlowCoarseSavePage* coarse_page = (static_cast<CalibrationFlowCoarseSavePage*>(coarse_save_step->page)); CalibrationFlowCoarseSavePage* coarse_page = (static_cast<CalibrationFlowCoarseSavePage*>(coarse_save_step->page));
CalibInfo calib_info; CalibInfo calib_info;
calib_info.dev_id = curr_obj->dev_id; calib_info.dev_id = curr_obj->get_dev_id();
Preset* temp_filament_preset = nullptr; Preset* temp_filament_preset = nullptr;
int cali_stage = -1; int cali_stage = -1;
wxString wx_err_string; wxString wx_err_string;
@@ -1635,7 +1635,7 @@ void MaxVolumetricSpeedWizard::on_cali_start()
CalibInfo calib_info; CalibInfo calib_info;
calib_info.params = params; calib_info.params = params;
calib_info.dev_id = curr_obj->dev_id; calib_info.dev_id = curr_obj->get_dev_id();
if (!selected_filaments.empty()) { if (!selected_filaments.empty()) {
int selected_tray_id = 0; int selected_tray_id = 0;
get_tray_ams_and_slot_id(curr_obj, selected_filaments.begin()->first, calib_info.ams_id, calib_info.slot_id, selected_tray_id); get_tray_ams_and_slot_id(curr_obj, selected_filaments.begin()->first, calib_info.ams_id, calib_info.slot_id, selected_tray_id);
+7 -5
View File
@@ -3,6 +3,8 @@
#include "I18N.hpp" #include "I18N.hpp"
#include "Widgets/Label.hpp" #include "Widgets/Label.hpp"
#include "DeviceCore/DevManager.h"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
static const wxString NA_STR = _L("N/A"); static const wxString NA_STR = _L("N/A");
@@ -167,7 +169,7 @@ void CalibrationCaliPage::update(MachineObject* obj)
if (obj) { if (obj) {
if (obj->print_status != "RUNNING") { if (obj->print_status != "RUNNING") {
BOOST_LOG_TRIVIAL(info) << "on_show_cali_page - machine object status:" BOOST_LOG_TRIVIAL(info) << "on_show_cali_page - machine object status:"
<< " dev_id = " << obj->dev_id << " dev_id = " << obj->get_dev_id()
<< ", print_type = " << obj->printer_type << ", print_type = " << obj->printer_type
<< ", printer_status = " << obj->print_status << ", printer_status = " << obj->print_status
<< ", is_connected = " << obj->is_connected() << ", is_connected = " << obj->is_connected()
@@ -190,8 +192,8 @@ void CalibrationCaliPage::update(MachineObject* obj)
// enable calibration when finished // enable calibration when finished
bool enable_cali = false; bool enable_cali = false;
if (obj) { if (obj) {
if (obj->m_extder_data.current_extder_id != m_cur_extruder_id) { if (obj->GetExtderSystem()->GetCurrentExtderId() != m_cur_extruder_id) {
m_cur_extruder_id = obj->m_extder_data.current_extder_id; m_cur_extruder_id = obj->GetExtderSystem()->GetCurrentExtderId();
set_cali_img(); set_cali_img();
} }
@@ -521,8 +523,8 @@ float CalibrationCaliPage::get_selected_calibration_nozzle_dia(MachineObject* ob
return obj->cali_selected_nozzle_dia; return obj->cali_selected_nozzle_dia;
// return default nozzle if nozzle diameter is set // return default nozzle if nozzle diameter is set
if (obj->m_extder_data.extders[0].current_nozzle_diameter > 1e-3 && obj->m_extder_data.extders[0].current_nozzle_diameter < 10.0f) if (obj->GetExtderSystem()->GetNozzleDiameter(0) > 1e-3 && obj->GetExtderSystem()->GetNozzleDiameter(0) < 10.0f)
return obj->m_extder_data.extders[0].current_nozzle_diameter; return obj->GetExtderSystem()->GetNozzleDiameter(0);
// return 0.4 by default // return 0.4 by default
return 0.4; return 0.4;
+3 -1
View File
@@ -3,6 +3,8 @@
#include "Widgets/Label.hpp" #include "Widgets/Label.hpp"
#include "MsgDialog.hpp" #include "MsgDialog.hpp"
#include "DeviceCore/DevFilaSystem.h"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
wxDEFINE_EVENT(EVT_CALI_ACTION, wxCommandEvent); wxDEFINE_EVENT(EVT_CALI_ACTION, wxCommandEvent);
@@ -310,7 +312,7 @@ void FilamentComboBox::load_tray_from_ams(int id, DynamicPrintConfig& tray)
m_tray_id = id; m_tray_id = id;
m_tray_name = m_comboBox->get_tray_name(); m_tray_name = m_comboBox->get_tray_name();
m_is_bbl_filamnet = MachineObject::is_bbl_filament(m_comboBox->get_tag_uid()); m_is_bbl_filamnet = DevFilaSystem::IsBBL_Filament(m_comboBox->get_tag_uid());
Enable(m_comboBox->is_tray_exist()); Enable(m_comboBox->is_tray_exist());
if (m_comboBox->is_tray_exist()) { if (m_comboBox->is_tray_exist()) {
+51 -47
View File
@@ -5,6 +5,13 @@
#include "MsgDialog.hpp" #include "MsgDialog.hpp"
#include "libslic3r/Print.hpp" #include "libslic3r/Print.hpp"
#include "DeviceCore/DevConfig.h"
#include "DeviceCore/DevExtruderSystem.h"
#include "DeviceCore/DevFilaBlackList.h"
#include "DeviceCore/DevFilaSystem.h"
#include "DeviceCore/DevManager.h"
#include "DeviceCore/DevStorage.h"
#define CALIBRATION_LABEL_SIZE wxSize(FromDIP(150), FromDIP(24)) #define CALIBRATION_LABEL_SIZE wxSize(FromDIP(150), FromDIP(24))
#define SYNC_BUTTON_SIZE (wxSize(FromDIP(50), FromDIP(50))) #define SYNC_BUTTON_SIZE (wxSize(FromDIP(50), FromDIP(50)))
#define CALIBRATION_TEXT_INPUT_Y_SIZE FromDIP(20) #define CALIBRATION_TEXT_INPUT_Y_SIZE FromDIP(20)
@@ -16,11 +23,6 @@ namespace Slic3r { namespace GUI {
static int PA_LINE = 0; static int PA_LINE = 0;
static int PA_PATTERN = 1; static int PA_PATTERN = 1;
static bool is_virtual_slot(int ams_id)
{
return ams_id == VIRTUAL_TRAY_MAIN_ID || ams_id == VIRTUAL_TRAY_DEPUTY_ID;
}
CaliPresetCaliStagePanel::CaliPresetCaliStagePanel( CaliPresetCaliStagePanel::CaliPresetCaliStagePanel(
wxWindow* parent, wxWindow* parent,
wxWindowID id, wxWindowID id,
@@ -578,7 +580,7 @@ void CalibrationPresetPage::create_selection_panel(wxWindow* parent)
return; return;
} }
BOOST_LOG_TRIVIAL(info) << "CalibrationPresetPage: sync_nozzle_info - machine object status:" BOOST_LOG_TRIVIAL(info) << "CalibrationPresetPage: sync_nozzle_info - machine object status:"
<< " dev_id = " << curr_obj->dev_id << " dev_id = " << curr_obj->get_dev_id()
<< ", print_type = " << curr_obj->printer_type << ", print_type = " << curr_obj->printer_type
<< ", printer_status = " << curr_obj->print_status << ", printer_status = " << curr_obj->print_status
<< ", cali_finished = " << curr_obj->cali_finished << ", cali_finished = " << curr_obj->cali_finished
@@ -596,10 +598,10 @@ void CalibrationPresetPage::create_selection_panel(wxWindow* parent)
<< ", name = " << preset_info.name; << ", name = " << preset_info.name;
} }
for (auto extruder : curr_obj->m_extder_data.extders) { for (const auto& extruder : curr_obj->GetExtderSystem()->GetExtruders()) {
if (extruder.current_nozzle_type == NozzleType::ntUndefine) { if (extruder.GetNozzleType() == NozzleType::ntUndefine) {
wxString name = _L("left"); wxString name = _L("left");
if (extruder.id == 0) { name = _L("right"); } if (extruder.GetExtId() == 0) { name = _L("right"); }
wxString msg = wxString::Format(_L("Printer %s nozzle information has not been set. Please configure it before proceeding with the calibration."), name); wxString msg = wxString::Format(_L("Printer %s nozzle information has not been set. Please configure it before proceeding with the calibration."), name);
MessageDialog msg_dlg(nullptr, msg, wxEmptyString, wxICON_WARNING | wxOK); MessageDialog msg_dlg(nullptr, msg, wxEmptyString, wxICON_WARNING | wxOK);
msg_dlg.ShowModal(); msg_dlg.ShowModal();
@@ -1462,7 +1464,7 @@ bool CalibrationPresetPage::is_filament_in_blacklist(int tray_id, Preset* preset
auto vendor = dynamic_cast<ConfigOptionStrings*> (preset->config.option("filament_vendor")); auto vendor = dynamic_cast<ConfigOptionStrings*> (preset->config.option("filament_vendor"));
if (vendor && (vendor->values.size() > 0)) { if (vendor && (vendor->values.size() > 0)) {
std::string vendor_name = vendor->values[0]; std::string vendor_name = vendor->values[0];
DeviceManager::check_filaments_in_blacklist(curr_obj->printer_type, vendor_name, filamnt_type, preset->filament_id, ams_id, slot_id, "", in_blacklist, action, info); DevFilaBlacklist::check_filaments_in_blacklist(curr_obj->printer_type, vendor_name, filamnt_type, preset->filament_id, ams_id, slot_id, "", in_blacklist, action, info);
} }
if (in_blacklist) { if (in_blacklist) {
@@ -1479,7 +1481,7 @@ bool CalibrationPresetPage::is_filament_in_blacklist(int tray_id, Preset* preset
return true; return true;
} }
} }
if (is_virtual_slot(ams_id)) { if (devPrinterUtil::IsVirtualSlot(ams_id)) {
if (m_cali_mode == CalibMode::Calib_PA_Line && m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) { if (m_cali_mode == CalibMode::Calib_PA_Line && m_cali_method == CalibrationMethod::CALI_METHOD_AUTO) {
std::string filamnt_type; std::string filamnt_type;
preset->get_filament_type(filamnt_type); preset->get_filament_type(filamnt_type);
@@ -1606,7 +1608,7 @@ bool CalibrationPresetPage::is_blocking_printing()
auto target_model = obj_->printer_type; auto target_model = obj_->printer_type;
if (source_model != target_model) { if (source_model != target_model) {
std::vector<std::string> compatible_machine = dev->get_compatible_machine(target_model); std::vector<std::string> compatible_machine = obj_->get_compatible_machine();
vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model); vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model);
if (it == compatible_machine.end()) { if (it == compatible_machine.end()) {
return true; return true;
@@ -1652,9 +1654,9 @@ void CalibrationPresetPage::update_sync_button_status()
if (curr_obj->is_multi_extruders()) { if (curr_obj->is_multi_extruders()) {
std::vector<CaliNozzleInfo> machine_obj_nozzle_infos; std::vector<CaliNozzleInfo> machine_obj_nozzle_infos;
machine_obj_nozzle_infos.resize(2); machine_obj_nozzle_infos.resize(2);
for (Extder extruder : curr_obj->m_extder_data.extders) { for (const DevExtder& extruder : curr_obj->GetExtderSystem()->GetExtruders()) {
machine_obj_nozzle_infos[extruder.id].nozzle_diameter = extruder.current_nozzle_diameter; machine_obj_nozzle_infos[extruder.GetExtId()].nozzle_diameter = extruder.GetNozzleDiameter();
machine_obj_nozzle_infos[extruder.id].nozzle_volume_type = int(extruder.current_nozzle_flow_type) - 1; machine_obj_nozzle_infos[extruder.GetExtId()].nozzle_volume_type = int(extruder.GetNozzleFlowType()) - 1;
} }
std::vector<CaliNozzleInfo> cali_nozzle_infos; std::vector<CaliNozzleInfo> cali_nozzle_infos;
@@ -1672,7 +1674,7 @@ void CalibrationPresetPage::update_sync_button_status()
} }
} }
else { else {
if (abs(curr_obj->m_extder_data.extders[0].current_nozzle_diameter - get_nozzle_diameter(0)) < EPSILON) { if (abs(curr_obj->GetExtderSystem()->GetNozzleDiameter(0) - get_nozzle_diameter(0)) < EPSILON) {
set_status(true); set_status(true);
} }
else { else {
@@ -1754,17 +1756,17 @@ void CalibrationPresetPage::update_show_status()
// check sdcard when if lan mode printer // check sdcard when if lan mode printer
if (obj_->is_lan_mode_printer()) { if (obj_->is_lan_mode_printer()) {
if (obj_->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD) { if (obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::NO_SDCARD) {
show_status(CaliPresetPageStatus::CaliPresetStatusLanModeNoSdcard); show_status(CaliPresetPageStatus::CaliPresetStatusLanModeNoSdcard);
return; return;
} } else if (obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::HAS_SDCARD_ABNORMAL ||
else if (obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_ABNORMAL obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::HAS_SDCARD_READONLY) {
|| obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_READONLY) {
show_status(CaliPresetPageStatus::CaliPresetStatusLanModeSDcardNotAvailable); show_status(CaliPresetPageStatus::CaliPresetStatusLanModeSDcardNotAvailable);
return; return;
} }
} }
else if (!obj_->is_support_print_without_sd && (obj_->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD)) { else if (!obj_->GetConfig()->SupportPrintWithoutSD() && (obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::NO_SDCARD))
{
show_status(CaliPresetPageStatus::CaliPresetStatusNoSdcard); show_status(CaliPresetPageStatus::CaliPresetStatusNoSdcard);
return; return;
} }
@@ -2065,7 +2067,7 @@ void CalibrationPresetPage::init_with_machine(MachineObject* obj)
auto get_nozzle_diameter_list_index = [&obj](int extruder_id) -> int { auto get_nozzle_diameter_list_index = [&obj](int extruder_id) -> int {
for (int i = 0; i < NOZZLE_LIST_COUNT; i++) { for (int i = 0; i < NOZZLE_LIST_COUNT; i++) {
if (abs(obj->m_extder_data.extders[extruder_id].current_nozzle_diameter - nozzle_diameter_list[i]) < 1e-3) { if (abs(obj->GetExtderSystem()->GetNozzleDiameter(extruder_id) - nozzle_diameter_list[i]) < 1e-3) {
return i; return i;
} }
} }
@@ -2077,7 +2079,7 @@ void CalibrationPresetPage::init_with_machine(MachineObject* obj)
// set nozzle value from machine // set nozzle value from machine
bool nozzle_is_set = false; bool nozzle_is_set = false;
for (int i = 0; i < NOZZLE_LIST_COUNT; i++) { for (int i = 0; i < NOZZLE_LIST_COUNT; i++) {
if (abs(obj->m_extder_data.extders[0].current_nozzle_diameter - nozzle_diameter_list[i]) < 1e-3) { if (abs(obj->GetExtderSystem()->GetNozzleDiameter(0) - nozzle_diameter_list[i]) < 1e-3) {
if (m_comboBox_nozzle_dia->GetCount() > i) { if (m_comboBox_nozzle_dia->GetCount() > i) {
m_comboBox_nozzle_dia->SetSelection(i); m_comboBox_nozzle_dia->SetSelection(i);
nozzle_is_set = true; nozzle_is_set = true;
@@ -2098,7 +2100,7 @@ void CalibrationPresetPage::init_with_machine(MachineObject* obj)
} }
if (obj->is_multi_extruders()) { if (obj->is_multi_extruders()) {
for (size_t i = 0; i < obj->m_extder_data.extders.size(); ++i) { for (size_t i = 0; i < obj->GetExtderSystem()->GetTotalExtderCount(); ++i) {
if (i == LEFT_EXTRUDER_ID) { if (i == LEFT_EXTRUDER_ID) {
int index = get_nozzle_diameter_list_index(LEFT_EXTRUDER_ID); int index = get_nozzle_diameter_list_index(LEFT_EXTRUDER_ID);
if ((index != -1) && m_left_comboBox_nozzle_dia->GetCount() > index) { if ((index != -1) && m_left_comboBox_nozzle_dia->GetCount() > index) {
@@ -2114,8 +2116,8 @@ void CalibrationPresetPage::init_with_machine(MachineObject* obj)
m_left_comboBox_nozzle_dia->SetSelection(NOZZLE_LIST_DEFAULT); m_left_comboBox_nozzle_dia->SetSelection(NOZZLE_LIST_DEFAULT);
} }
if (obj->m_extder_data.extders[i].current_nozzle_flow_type != NozzleFlowType::NONE_FLOWTYPE) { if (obj->GetExtderSystem()->GetNozzleFlowType(i) != NozzleFlowType::NONE_FLOWTYPE) {
m_left_comboBox_nozzle_volume->SetSelection(obj->m_extder_data.extders[i].current_nozzle_flow_type - 1); m_left_comboBox_nozzle_volume->SetSelection(obj->GetExtderSystem()->GetNozzleFlowType(i) - 1);
} else { } else {
m_left_comboBox_nozzle_volume->SetSelection(0); m_left_comboBox_nozzle_volume->SetSelection(0);
} }
@@ -2134,8 +2136,8 @@ void CalibrationPresetPage::init_with_machine(MachineObject* obj)
m_right_comboBox_nozzle_dia->SetSelection(NOZZLE_LIST_DEFAULT); m_right_comboBox_nozzle_dia->SetSelection(NOZZLE_LIST_DEFAULT);
} }
if (obj->m_extder_data.extders[i].current_nozzle_flow_type != NozzleFlowType::NONE_FLOWTYPE) { if (obj->GetExtderSystem()->GetNozzleFlowType(i) != NozzleFlowType::NONE_FLOWTYPE) {
m_right_comboBox_nozzle_volume->SetSelection(obj->m_extder_data.extders[i].current_nozzle_flow_type - 1); m_right_comboBox_nozzle_volume->SetSelection(obj->GetExtderSystem()->GetNozzleFlowType(i) - 1);
} else { } else {
m_right_comboBox_nozzle_volume->SetSelection(0); m_right_comboBox_nozzle_volume->SetSelection(0);
} }
@@ -2199,12 +2201,12 @@ void CalibrationPresetPage::sync_ams_info(MachineObject* obj)
// sync filament_ams_list from obj ams list // sync filament_ams_list from obj ams list
filament_ams_list.clear(); filament_ams_list.clear();
for (auto& ams_item : obj->amsList) { for (auto& ams_item : obj->GetFilaSystem()->GetAmsList()) {
for (auto& tray_item: ams_item.second->trayList) { for (auto& tray_item: ams_item.second->GetTrays()) {
int tray_id = -1; int tray_id = -1;
if (!tray_item.second->id.empty()) { if (!tray_item.second->id.empty()) {
try { try {
tray_id = stoi(tray_item.second->id) + stoi(ams_item.second->id) * 4; tray_id = stoi(tray_item.second->id) + stoi(ams_item.second->GetAmsId()) * 4;
} }
catch (...) { catch (...) {
; ;
@@ -2228,16 +2230,16 @@ void CalibrationPresetPage::sync_ams_info(MachineObject* obj)
// update filament from panel, display only obj has ams // update filament from panel, display only obj has ams
// update multi ams panel, display only obj has multi ams // update multi ams panel, display only obj has multi ams
if (obj->has_ams()) { if (obj->HasAms()) {
if (obj->is_multi_extruders()) { if (obj->is_multi_extruders()) {
bool main_done = false; bool main_done = false;
bool deputy_done = false; bool deputy_done = false;
for (auto &ams_item : obj->amsList) { for (auto &ams_item : obj->GetFilaSystem()->GetAmsList()) {
if (ams_item.second->nozzle == 0 && !main_done) { if (ams_item.second->GetExtruderId() == 0 && !main_done) {
update_multi_extruder_filament_combobox(ams_item.second->id, ams_item.second->nozzle); update_multi_extruder_filament_combobox(ams_item.second->GetAmsId(), ams_item.second->GetExtruderId());
main_done = true; main_done = true;
} else if (ams_item.second->nozzle == 1 && !deputy_done) { } else if (ams_item.second->GetExtruderId() == 1 && !deputy_done) {
update_multi_extruder_filament_combobox(ams_item.second->id, ams_item.second->nozzle); update_multi_extruder_filament_combobox(ams_item.second->GetAmsId(), ams_item.second->GetExtruderId());
deputy_done = true; deputy_done = true;
} }
} }
@@ -2249,11 +2251,11 @@ void CalibrationPresetPage::sync_ams_info(MachineObject* obj)
update_multi_extruder_filament_combobox(std::to_string(VIRTUAL_TRAY_DEPUTY_ID), 1); update_multi_extruder_filament_combobox(std::to_string(VIRTUAL_TRAY_DEPUTY_ID), 1);
} }
else { else {
if (obj->amsList.size() > 1) { if (obj->GetFilaSystem()->GetAmsList().size() > 1) {
on_switch_ams(obj->amsList.begin()->first); on_switch_ams(obj->GetFilaSystem()->GetAmsList().begin()->first);
} else { } else {
if (!obj->amsList.empty()) if (!obj->GetFilaSystem()->GetAmsList().empty())
update_filament_combobox(obj->amsList.begin()->first); update_filament_combobox(obj->GetFilaSystem()->GetAmsList().begin()->first);
} }
} }
} }
@@ -2270,11 +2272,13 @@ void CalibrationPresetPage::sync_ams_info(MachineObject* obj)
std::vector<AMSinfo> ams_info; std::vector<AMSinfo> ams_info;
std::vector<AMSinfo> main_ams_info; std::vector<AMSinfo> main_ams_info;
std::vector<AMSinfo> deputy_ams_info; std::vector<AMSinfo> deputy_ams_info;
for (auto ams = obj->amsList.begin(); ams != obj->amsList.end(); ams++) {
const auto& ams_list = obj->GetFilaSystem()->GetAmsList();
for (auto ams = ams_list.begin(); ams != ams_list.end(); ams++) {
AMSinfo info; AMSinfo info;
info.ams_id = ams->first; info.ams_id = ams->first;
if (ams->second->is_exists if (ams->second->IsExist()
&& info.parse_ams_info(obj, ams->second, obj->ams_calibrate_remain_flag, obj->is_support_ams_humidity)) { && info.parse_ams_info(obj, ams->second, obj->GetFilaSystem()->IsDetectRemainEnabled(), obj->is_support_ams_humidity)) {
ams_info.push_back(info); ams_info.push_back(info);
if (info.nozzle_id == 0) { if (info.nozzle_id == 0) {
main_ams_info.push_back(info); main_ams_info.push_back(info);
@@ -2319,7 +2323,7 @@ void CalibrationPresetPage::sync_ams_info(MachineObject* obj)
// update vt slot preview list // update vt slot preview list
{ {
for (const AmsTray& vt_tray : obj->vt_slot) { for (const DevAmsTray& vt_tray : obj->vt_slot) {
if (vt_tray.id == std::to_string(VIRTUAL_TRAY_MAIN_ID)) { if (vt_tray.id == std::to_string(VIRTUAL_TRAY_MAIN_ID)) {
AMSinfo info; AMSinfo info;
info.parse_ext_info(obj, vt_tray); info.parse_ext_info(obj, vt_tray);
@@ -2360,7 +2364,7 @@ void CalibrationPresetPage::sync_ams_info(MachineObject* obj)
} }
} }
for (const AmsTray &vt_tray : obj->vt_slot) { for (const DevAmsTray &vt_tray : obj->vt_slot) {
if (vt_tray.id == std::to_string(VIRTUAL_TRAY_MAIN_ID)) { if (vt_tray.id == std::to_string(VIRTUAL_TRAY_MAIN_ID)) {
AMSinfo info; AMSinfo info;
info.parse_ext_info(obj, vt_tray); info.parse_ext_info(obj, vt_tray);
@@ -2392,7 +2396,7 @@ void CalibrationPresetPage::select_default_compatible_filament()
if (ams_id.empty()) if (ams_id.empty())
return; return;
if (!is_virtual_slot(stoi(ams_id))) { if (!devPrinterUtil::IsVirtualSlot(ams_id)) {
std::map<int, Preset *> selected_filament; std::map<int, Preset *> selected_filament;
for (size_t i = 0; i < 4; ++i) { for (size_t i = 0; i < 4; ++i) {
auto &fcb = m_filament_comboBox_list[i]; auto &fcb = m_filament_comboBox_list[i];
+4 -1
View File
@@ -10,6 +10,9 @@
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include <slic3r/GUI/StatusPanel.hpp> #include <slic3r/GUI/StatusPanel.hpp>
#include "DeviceCore/DevManager.h"
#include "DeviceCore/DevStorage.h"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@@ -214,7 +217,7 @@ void CameraPopup::set_custom_cam_button_state(bool state)
void CameraPopup::on_switch_recording(wxCommandEvent& event) void CameraPopup::on_switch_recording(wxCommandEvent& event)
{ {
if (!m_obj) return; if (!m_obj) return;
if (m_obj->sdcard_state != MachineObject::SdcardState::HAS_SDCARD_NORMAL) { if (m_obj->GetStorage()->get_sdcard_state() != DevStorage::SdcardState::HAS_SDCARD_NORMAL) {
sdcard_absent_hint(); sdcard_absent_hint();
return; return;
} }
+4 -2
View File
@@ -4,6 +4,8 @@
#include <slic3r/GUI/Widgets/Label.hpp> #include <slic3r/GUI/Widgets/Label.hpp>
#include "libslic3r/AppConfig.hpp" #include "libslic3r/AppConfig.hpp"
#include "DeviceCore/DevManager.h"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
ConnectPrinterDialog::ConnectPrinterDialog(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, long style) ConnectPrinterDialog::ConnectPrinterDialog(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, long style)
: DPIDialog(parent, id, _L("Connect Printer (LAN)"), pos, size, style) : DPIDialog(parent, id, _L("Connect Printer (LAN)"), pos, size, style)
@@ -118,7 +120,7 @@ void ConnectPrinterDialog::init_bitmap()
std::string language = config->get("language"); std::string language = config->get("language");
if (m_obj) { if (m_obj) {
std::string img_str = DeviceManager::get_printer_diagram_img(m_obj->printer_type); std::string img_str = DevPrinterConfigUtil::get_printer_connect_help_img(m_obj->printer_type);
if(img_str.empty()){img_str = "input_access_code_x1"; } if(img_str.empty()){img_str = "input_access_code_x1"; }
if (language == "zh_CN") { if (language == "zh_CN") {
@@ -181,7 +183,7 @@ void ConnectPrinterDialog::on_button_confirm(wxCommandEvent &event)
if (m_obj) { if (m_obj) {
m_obj->set_user_access_code(code.ToStdString()); m_obj->set_user_access_code(code.ToStdString());
if (m_need_connect) { if (m_need_connect) {
wxGetApp().getDeviceManager()->set_selected_machine(m_obj->dev_id); wxGetApp().getDeviceManager()->set_selected_machine(m_obj->get_dev_id());
} }
} }
EndModal(wxID_OK); EndModal(wxID_OK);
+52
View File
@@ -0,0 +1,52 @@
# GUI/DeviceCore
# usage -- none GUI structure about device
# date -- 2025.07.14
# status -- Building
list(APPEND SLIC3R_GUI_SOURCES
GUI/DeviceCore/DevBed.cpp
GUI/DeviceCore/DevBed.h
GUI/DeviceCore/DevConfig.h
GUI/DeviceCore/DevConfig.cpp
GUI/DeviceCore/DevConfigUtil.h
GUI/DeviceCore/DevConfigUtil.cpp
GUI/DeviceCore/DevCtrl.h
GUI/DeviceCore/DevCtrl.cpp
GUI/DeviceCore/DevDefs.h
GUI/DeviceCore/DevExtruderSystem.h
GUI/DeviceCore/DevExtruderSystem.cpp
GUI/DeviceCore/DevExtruderSystemCtrl.cpp
GUI/DeviceCore/DevFan.cpp
GUI/DeviceCore/DevFan.h
GUI/DeviceCore/DevFilaAmsSetting.h
GUI/DeviceCore/DevFilaAmsSetting.cpp
GUI/DeviceCore/DevFilaBlackList.h
GUI/DeviceCore/DevFilaBlackList.cpp
GUI/DeviceCore/DevFilaSystem.h
GUI/DeviceCore/DevFilaSystem.cpp
GUI/DeviceCore/DevFirmware.h
GUI/DeviceCore/DevFirmware.cpp
GUI/DeviceCore/DevPrintOptions.h
GUI/DeviceCore/DevPrintOptions.cpp
GUI/DeviceCore/DevPrintTaskInfo.h
GUI/DeviceCore/DevPrintTaskInfo.cpp
GUI/DeviceCore/DevHMS.h
GUI/DeviceCore/DevHMS.cpp
GUI/DeviceCore/DevStorage.h
GUI/DeviceCore/DevStorage.cpp
GUI/DeviceCore/DevInfo.h
GUI/DeviceCore/DevInfo.cpp
GUI/DeviceCore/DevLamp.h
GUI/DeviceCore/DevLamp.cpp
GUI/DeviceCore/DevLampCtrl.cpp
GUI/DeviceCore/DevManager.h
GUI/DeviceCore/DevManager.cpp
GUI/DeviceCore/DevMapping.h
GUI/DeviceCore/DevMapping.cpp
GUI/DeviceCore/DevNozzleSystem.h
GUI/DeviceCore/DevNozzleSystem.cpp
GUI/DeviceCore/DevUtil.h
GUI/DeviceCore/DevUtil.cpp
)
set(SLIC3R_GUI_SOURCES ${SLIC3R_GUI_SOURCES} PARENT_SCOPE)
+25
View File
@@ -0,0 +1,25 @@
#include "DevBed.h"
#include "slic3r/GUI/DeviceManager.hpp"
namespace Slic3r {
void DevBed::ParseV1_0(const json &print_json, DevBed *system)
{
if (print_json.contains("bed_temper")) {
if (print_json["bed_temper"].is_number()) { system->bed_temp = print_json["bed_temper"].get<float>(); }
}
if (print_json.contains("bed_target_temper")) {
if (print_json["bed_target_temper"].is_number()) { system->bed_temp_target = print_json["bed_target_temper"].get<float>(); }
}
}
void DevBed::ParseV2_0(const json &print_json, DevBed *system)
{
if (print_json.contains("bed_temp") && print_json["bed_temp"].is_number()) {
int bed_temp_bits = print_json["bed_temp"].get<int>();
system->bed_temp = system->m_owner->get_flag_bits(bed_temp_bits, 0, 16);
system->bed_temp_target = system->m_owner->get_flag_bits(bed_temp_bits, 16, 16);
}
}
} // namespace Slic3r
+30
View File
@@ -0,0 +1,30 @@
#pragma once
#include <nlohmann/json.hpp>
#include "slic3r/Utils/json_diff.hpp"
namespace Slic3r {
class MachineObject;
class DevBed
{
public:
DevBed(MachineObject *obj) : m_owner(obj), bed_temp(0.0f), bed_temp_target(0.0f) {}
float GetBedTemp() { return bed_temp; };
float GetBedTempTarget() { return bed_temp_target; };
public:
static void ParseV1_0(const json &print_json, DevBed *system);
static void ParseV2_0(const json &print_json, DevBed *system);
private:
float bed_temp;
float bed_temp_target;
MachineObject* m_owner = nullptr;
};
} // namespace Slic3r
+54
View File
@@ -0,0 +1,54 @@
#include <nlohmann/json.hpp>
#include "DevConfig.h"
#include "DevUtil.h"
using namespace nlohmann;
namespace Slic3r
{
void DevConfig::ParseConfig(const json& print_json)
{
ParseChamberConfig(print_json);
ParsePrintOptionsConfig(print_json);
ParseCalibrationConfig(print_json);
}
void DevConfig::ParseChamberConfig(const json& print_json)
{
DevJsonValParser::ParseVal(print_json, "support_chamber_temp_edit", m_support_chamber_edit);
if (m_support_chamber_edit)
{
if (print_json.contains("support_chamber_temp_edit_range"))
{
const auto &support_champer_range = print_json["support_chamber_temp_edit_range"];
if (support_champer_range.is_array() && support_champer_range.size() > 1) {
m_chamber_temp_edit_min = support_champer_range[0];
m_chamber_temp_edit_max = support_champer_range[1];
}
}
DevJsonValParser::ParseVal(print_json, "support_chamber_temp_switch_heating", m_chamber_temp_switch_heat);
}
}
void DevConfig::ParsePrintOptionsConfig(const json& print_json)
{
DevJsonValParser::ParseVal(print_json, "support_first_layer_inspect", m_support_first_layer_inspect);
DevJsonValParser::ParseVal(print_json, "support_save_remote_print_file_to_storage", m_support_save_remote_print_file_to_storage);
DevJsonValParser::ParseVal(print_json, "support_ai_monitoring", m_support_ai_monitor);
DevJsonValParser::ParseVal(print_json, "support_print_without_sd", m_support_print_without_sd);
DevJsonValParser::ParseVal(print_json, "support_print_all", m_support_print_all);
}
void DevConfig::ParseCalibrationConfig(const json& print_json)
{
DevJsonValParser::ParseVal(print_json, "support_lidar_calibration", m_support_calibration_lidar);
DevJsonValParser::ParseVal(print_json, "support_nozzle_offset_calibration", m_support_calibration_nozzle_offset);
DevJsonValParser::ParseVal(print_json, "support_high_tempbed_calibration", m_support_calibration_high_temp_bed);
DevJsonValParser::ParseVal(print_json, "support_pa_calibration_auto", m_support_calibration_pa_flow_auto);
}
}
+77
View File
@@ -0,0 +1,77 @@
#pragma once
#include "libslic3r/CommonDefs.hpp"
#include "slic3r/Utils/json_diff.hpp"
#include <wx/string.h>
namespace Slic3r
{
//Previous definitions
class MachineObject;
class DevConfig
{
public:
DevConfig(MachineObject* obj) : m_obj(obj) {};
~DevConfig() = default;
public:
// chamber
bool SupportChamberEdit() const { return m_support_chamber_edit; }
int GetChamberTempEditMin() const { return m_chamber_temp_edit_min; }
int GetChamberTempEditMax() const { return m_chamber_temp_edit_max; }
int GetChamberTempSwitchHeat() const { return m_chamber_temp_switch_heat; }
// print options
bool SupportFirstLayerInspect() const { return m_support_first_layer_inspect; }
bool SupportSaveRemotePrintFileToStorage() const { return m_support_save_remote_print_file_to_storage; }
bool SupportAIMonitor() const { return m_support_ai_monitor; }
bool SupportPrintWithoutSD() const { return m_support_print_without_sd; }
bool SupportPrintAllPlates() const { return m_support_print_all; }
// calibration options
bool SupportCalibrationLidar() const { return m_support_calibration_lidar; }
bool SupportCalibrationNozzleOffset() const { return m_support_calibration_nozzle_offset; }
bool SupportCalibrationHighTempBed() const { return m_support_calibration_high_temp_bed; }
bool SupportCalibrationPA_FlowAuto() const { return m_support_calibration_pa_flow_auto; }
public:
/*Setters*/
void ParseConfig(const json& print_json);
void ParseChamberConfig(const json& print_json); // chamber
void ParsePrintOptionsConfig(const json& print_json); // print options
void ParseCalibrationConfig(const json& print_json); //cali
private:
MachineObject* m_obj;
/*configure vals*/
// chamber
bool m_support_chamber_edit = false;
int m_chamber_temp_edit_min = 0;
int m_chamber_temp_edit_max = 60;
int m_chamber_temp_switch_heat = LONG_MAX; /* the min temp to start heating, default to LONG_MAX */
// print options
bool m_support_first_layer_inspect = false;
bool m_support_save_remote_print_file_to_storage = false;
bool m_support_ai_monitor = false;
bool m_support_print_without_sd = false;
bool m_support_print_all = false;
// calibration options
bool m_support_calibration_lidar = false;
bool m_support_calibration_nozzle_offset = false;
bool m_support_calibration_high_temp_bed = false; // High-temperature Heatbed Calibration
bool m_support_calibration_pa_flow_auto = false;// PA flow calibration. used in SendPrint
};
};
+167
View File
@@ -0,0 +1,167 @@
#include "DevConfigUtil.h"
#include <wx/dir.h>
using namespace nlohmann;
namespace Slic3r
{
std::string DevPrinterConfigUtil::m_resource_file_path = "";
std::map<std::string, std::string> DevPrinterConfigUtil::get_all_model_id_with_name()
{
{
std::map<std::string, std::string> models;
wxDir dir(m_resource_file_path + "/printers/");
if (!dir.IsOpened())
{
return models;
}
wxString filename;
std::vector<wxString> m_files;
bool hasFile = dir.GetFirst(&filename, wxEmptyString, wxDIR_FILES);
while (hasFile)
{
m_files.push_back(filename);
hasFile = dir.GetNext(&filename);
}
for (wxString file : m_files)
{
if (!file.Lower().ends_with(".json")) continue;
std::string config_file = m_resource_file_path + "/printers/" + file.ToStdString();
boost::nowide::ifstream json_file(config_file.c_str());
try
{
json jj;
if (json_file.is_open())
{
json_file >> jj;
if (jj.contains("00.00.00.00"))
{
json const& printer = jj["00.00.00.00"];
std::string model_id;
std::string display_name;
if (printer.contains("model_id")) { model_id = printer["model_id"].get<std::string>(); }
if (printer.contains("display_name")) { display_name = printer["display_name"].get<std::string>(); }
models[display_name] = model_id;
}
}
}
catch (...) {}
}
return models;
}
}
PrinterArch DevPrinterConfigUtil::get_printer_arch(std::string type_str)
{
const std::string& arch_str = get_value_from_config<std::string>(type_str, "printer_arch");
if (arch_str == "i3")
{
return PrinterArch::ARCH_I3;
}
else if (arch_str == "core_xy")
{
return PrinterArch::ARCH_CORE_XY;
}
return PrinterArch::ARCH_CORE_XY;
}
std::string DevPrinterConfigUtil::get_printer_ext_img(const std::string& type_str, int pos)
{
const auto& vec = get_value_from_config<std::vector<std::string>>(type_str, "printer_ext_image");
return (vec.size() > pos) ? vec[pos] : std::string();
};
std::string DevPrinterConfigUtil::get_fan_text(const std::string& type_str, const std::string& key)
{
std::vector<std::string> filaments;
std::string config_file = m_resource_file_path + "/printers/" + type_str + ".json";
boost::nowide::ifstream json_file(config_file.c_str());
try
{
json jj;
if (json_file.is_open())
{
json_file >> jj;
if (jj.contains("00.00.00.00"))
{
json const& printer = jj["00.00.00.00"];
if (printer.contains("fan") && printer["fan"].contains(key))
{
return printer["fan"][key].get<std::string>();
}
}
}
}
catch (...) {}
return std::string();
}
std::map<std::string, std::vector<std::string>> DevPrinterConfigUtil::get_all_subseries(std::string type_str)
{
std::map<std::string, std::vector<std::string>> subseries;
std::vector<wxString> m_files;
wxDir dir(m_resource_file_path + "/printers/");
if (!dir.IsOpened()) { return subseries; }
wxString filename;
bool hasFile = dir.GetFirst(&filename, "*.json", wxDIR_FILES);
while (hasFile)
{
m_files.push_back(filename);
hasFile = dir.GetNext(&filename);
}
for (wxString file : m_files)
{
std::string config_file = m_resource_file_path + "/printers/" + file.ToStdString();
boost::nowide::ifstream json_file(config_file.c_str());
try
{
json jj;
if (json_file.is_open())
{
json_file >> jj;
if (jj.contains("00.00.00.00"))
{
json const& printer = jj["00.00.00.00"];
if (printer.contains("subseries"))
{
std::vector<std::string> subs;
std::string model_id = printer["model_id"].get<std::string>();
if (model_id == type_str || type_str.empty())
{
for (auto res : printer["subseries"])
{
subs.emplace_back(res.get<std::string>());
}
}
subseries.insert(make_pair(model_id, subs));
}
}
}
}
catch (...) {}
}
return subseries;
}
};
+174
View File
@@ -0,0 +1,174 @@
/**
* @file DevConfigUtil.h
* @brief Parses configuration files and provides access to printer options.
*
* This class loads a configuration file and allows querying options by key.
* The configuration file format is expected to be key-value pairs (e.g., INI or simple text).
*/
#pragma once
#include <string>
#include <map>
#include <vector>
#include <boost/nowide/fstream.hpp>
#include <nlohmann/json.hpp>
#include <wx/string.h>
#include "slic3r/GUI/DeviceCore/DevDefs.h"
namespace Slic3r
{
class dePrinterConfigFactory
{
public:
dePrinterConfigFactory() = default;
~dePrinterConfigFactory() = default;
};
class DevPrinterConfigUtil
{
public:
DevPrinterConfigUtil() = default;
~DevPrinterConfigUtil() = default;
public:
static void InitFilePath(const std::string& res_file_path) { m_resource_file_path = res_file_path; };
/*printer*/
// info
static std::map<std::string, std::string> get_all_model_id_with_name();
static std::string get_printer_type(const std::string& type_str) { return get_value_from_config<std::string>(type_str, "printer_type"); }
static std::string get_printer_display_name(const std::string& type_str) { return get_value_from_config<std::string>(type_str, "display_name"); }
static std::string get_printer_series_str(std::string type_str) { return get_value_from_config<std::string>(type_str, "printer_series"); }
static PrinterArch get_printer_arch(std::string type_str);
// images
static std::string get_printer_thumbnail_img(const std::string& type_str) { return get_value_from_config<std::string>(type_str, "printer_thumbnail_image"); }
static std::string get_printer_connect_help_img(const std::string& type_str) { return get_value_from_config<std::string>(type_str, "printer_connect_help_image"); }
static std::string get_printer_auto_pa_cali_image(const std::string& type_str) { return get_value_from_config<std::string>(type_str, "auto_pa_cali_thumbnail_image"); }
/*media*/
static std::string get_ftp_folder(std::string type_str) { return get_value_from_config<std::string>(type_str, "ftp_folder"); }
static std::vector<std::string> get_resolution_supported(std::string type_str) { return get_value_from_config<std::vector<std::string>>(type_str, "camera_resolution"); }
static std::vector<std::string> get_compatible_machine(std::string type_str) { return get_value_from_config<std::vector<std::string>>(type_str, "compatible_machine"); }
static std::map<std::string, std::vector<std::string>> get_all_subseries(std::string type_str = "");
/*ams*/
static std::string get_printer_use_ams_type(std::string type_str) { return get_value_from_config<std::string>(type_str, "use_ams_type"); }
static std::string get_printer_ams_img(const std::string& type_str) { return get_value_from_config<std::string>(type_str, "printer_use_ams_image"); }
static std::string get_printer_ext_img(const std::string& type_str, int pos);//printer_ext_image
/*fan*/
static std::string get_fan_text(const std::string& type_str, const std::string& key);
/*extruder*/
static bool get_printer_can_set_nozzle(std::string type_str) { return get_value_from_config<bool>(type_str, "enable_set_nozzle_info"); }// can set nozzle from studio
/*calibration*/
static std::vector<std::string> get_unsupport_auto_cali_filaments(std::string type_str) { return get_value_from_config<std::vector<std::string>>(type_str, "auto_cali_not_support_filaments"); }
/*detection*/
static bool support_wrapping_detection(const std::string& type_str) { return get_value_from_config<bool>(type_str, "support_wrapping_deteciton"); }
public:
template<typename T>
static T get_value_from_config(const std::string& type_str, const std::string& item)
{
std::string config_file = m_resource_file_path + "/printers/" + type_str + ".json";
boost::nowide::ifstream json_file(config_file.c_str());
try
{
nlohmann::json jj;
if (json_file.is_open())
{
json_file >> jj;
if (jj.contains("00.00.00.00"))
{
nlohmann::json const& printer = jj["00.00.00.00"];
if (printer.contains(item))
{
return printer[item].get<T>();
}
}
}
}
catch (...) { assert(0 && "get_value_from_config failed"); BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " failed"; }// there are file errors
return T();
};
static nlohmann::json get_json_from_config(const std::string& type_str, const std::string& key1, const std::string& key2 = std::string())
{
std::string config_file = m_resource_file_path + "/printers/" + type_str + ".json";
boost::nowide::ifstream json_file(config_file.c_str());
try
{
nlohmann::json jj;
if (json_file.is_open())
{
json_file >> jj;
if (jj.contains("00.00.00.00"))
{
nlohmann::json const& printer = jj["00.00.00.00"];
if (printer.contains(key1))
{
nlohmann::json const& key1_item = printer[key1];
if (key2.empty())
{
return key1_item;
}
if (key1_item.contains(key2))
{
return key1_item[key2];
}
}
}
}
}
catch (...) { assert(0 && "get_json_from_config failed"); BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " failed"; }// there are file errors
return nlohmann::json();
}
private:
static std::string m_resource_file_path; // Path to the configuration file
};
/*special transform*/
static std::string _parse_printer_type(const std::string& type_str)
{
if (type_str.compare("3DPrinter-X1") == 0)
{
return "BL-P002";
}
else if (type_str.compare("3DPrinter-X1-Carbon") == 0)
{
return "BL-P001";
}
else if (type_str.compare("BL-P001") == 0)
{
return type_str;
}
else if (type_str.compare("BL-P002") == 0)
{
return type_str;
}
else
{
std::string result = DevPrinterConfigUtil::get_printer_type(type_str);
if (!result.empty())
{
return result;
}
}
assert(0 && __FUNCTION__);
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " Unsupported printer type: " << type_str;
return type_str;
}
};// namespace Slic3r
+26
View File
@@ -0,0 +1,26 @@
#include <nlohmann/json.hpp>
#include "DevCtrl.h"
// TODO: remove this include
#include "DevUtil.h"
#include "slic3r/GUI/DeviceManager.hpp"
using namespace nlohmann;
namespace Slic3r
{
int DevCtrl::command_select_extruder(int id)
{
json j;
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["command"] = "select_extruder";
j["print"]["extruder_index"] = id;
int rtn = m_obj->publish_json(j, 1);
if (rtn == 0)
{
m_obj->targ_nozzle_id_from_pc = id;
}
return rtn;
}
}
+26
View File
@@ -0,0 +1,26 @@
#pragma once
#include "libslic3r/CommonDefs.hpp"
#include "slic3r/Utils/json_diff.hpp"
#include <wx/string.h>
namespace Slic3r
{
//Previous definitions
class MachineObject;
class DevCtrl
{
MachineObject* m_obj;
public:
DevCtrl(MachineObject* obj) : m_obj(obj) {};
~DevCtrl() = default;
public:
/*extruder system*/
int command_select_extruder(int id);
};
};
+99
View File
@@ -0,0 +1,99 @@
/**
* @file DevDefs.h
* @brief Common definitions, macros, and constants for printer modules.
* Enhance building and including.
*
* This file provides shared macros, constants, and enumerations for all printer-related
* modules, including printer types, status, binding states, connection types, and error codes.
* It is intended to be included wherever printer-specific definitions are required.
*/
#pragma once
#include <string>
enum PrinterArch
{
ARCH_CORE_XY,
ARCH_I3,
};
enum PrinterSeries
{
SERIES_X1 = 0,
SERIES_P1P,
SERIES_UNKNOWN,
};
namespace Slic3r
{
/*AMS*/
enum AmsStatusMain
{
AMS_STATUS_MAIN_IDLE = 0x00,
AMS_STATUS_MAIN_FILAMENT_CHANGE = 0x01,
AMS_STATUS_MAIN_RFID_IDENTIFYING = 0x02,
AMS_STATUS_MAIN_ASSIST = 0x03,
AMS_STATUS_MAIN_CALIBRATION = 0x04,
AMS_STATUS_MAIN_SELF_CHECK = 0x10,
AMS_STATUS_MAIN_DEBUG = 0x20,
AMS_STATUS_MAIN_UNKNOWN = 0xFF,
};
// Slots and Tray
#define VIRTUAL_TRAY_MAIN_ID 255
#define VIRTUAL_TRAY_DEPUTY_ID 254
#define VIRTUAL_AMS_MAIN_ID_STR "255"
#define VIRTUAL_AMS_DEPUTY_ID_STR "254"
#define INVALID_AMS_TEMPERATURE std::numeric_limits<float>::min()
/* Extruder*/
#define MAIN_EXTRUDER_ID 0
#define DEPUTY_EXTRUDER_ID 1
#define UNIQUE_EXTRUDER_ID MAIN_EXTRUDER_ID
#define INVALID_EXTRUDER_ID -1
/* Nozzle*/
enum NozzleFlowType
{
NONE_FLOWTYPE,
S_FLOW,
H_FLOW
};
/*Print speed*/
enum DevPrintingSpeedLevel
{
SPEED_LEVEL_INVALID = 0,
SPEED_LEVEL_SILENCE = 1,
SPEED_LEVEL_NORMAL = 2,
SPEED_LEVEL_RAPID = 3,
SPEED_LEVEL_RAMPAGE = 4,
SPEED_LEVEL_COUNT
};
/*Upgrade*/
enum class DevFirmwareUpgradingState : int
{
DC = -1,
UpgradingUnavaliable = 0,
UpgradingAvaliable = 1,
UpgradingInProgress = 2,
UpgradingFinished = 3
};
class devPrinterUtil
{
public:
devPrinterUtil() = delete;
~devPrinterUtil() = delete;
public:
static bool IsVirtualSlot(int ams_id) { return (ams_id == VIRTUAL_TRAY_MAIN_ID || ams_id == VIRTUAL_TRAY_DEPUTY_ID);}
static bool IsVirtualSlot(const std::string& ams_id) { return (ams_id == VIRTUAL_AMS_MAIN_ID_STR || ams_id == VIRTUAL_AMS_DEPUTY_ID_STR); }
};
};// namespace Slic3r
@@ -0,0 +1,287 @@
#include <nlohmann/json.hpp>
#include "DevExtruderSystem.h"
#include "DevNozzleSystem.h"
// TODO: remove this include
#include "slic3r/GUI/DeviceManager.hpp"
#include "slic3r/GUI/I18N.hpp"
#include "DevUtil.h"
using namespace nlohmann;
namespace Slic3r
{
wxString DevExtder::GetDisplayLoc() const
{
if (system->GetTotalExtderCount() == 2)
{
if (m_ext_id == MAIN_EXTRUDER_ID)
{
return _L("right");
}
else
{
return _L("left");
}
}
return wxEmptyString;
}
wxString DevExtder::GetDisplayName() const
{
if (system->GetTotalExtderCount() == 2)
{
if (m_ext_id == MAIN_EXTRUDER_ID)
{
return _L("right extruder");
}
else
{
return _L("left extruder");
}
}
return _L("extruder");
}
NozzleType DevExtder::GetNozzleType() const
{
return system->Owner()->GetNozzleSystem()->GetNozzle(m_current_nozzle_id).m_nozzle_type;
}
NozzleFlowType DevExtder::GetNozzleFlowType() const
{
return system->Owner()->GetNozzleSystem()->GetNozzle(m_current_nozzle_id).m_nozzle_flow;
}
float DevExtder::GetNozzleDiameter() const
{
return system->Owner()->GetNozzleSystem()->GetNozzle(m_current_nozzle_id).m_diameter;
}
DevExtderSystem::DevExtderSystem(MachineObject* obj)
: m_owner(obj)
{
// default to have one extruder
m_total_extder_count = 1;
DevExtder ext(this, MAIN_EXTRUDER_ID);
m_extders.emplace_back(ext);
}
bool DevExtderSystem::CanQuitSwitching() const
{
if (!IsSwitchingFailed())
{
return false;
}
return !m_owner->is_in_printing() && !m_owner->is_in_printing_pause();
}
std::optional<DevExtder> DevExtderSystem::GetCurrentExtder() const
{
return GetExtderById(m_current_extder_id);
}
std::optional<DevExtder> DevExtderSystem::GetLoadingExtder() const
{
if (m_current_loading_extder_id != INVALID_EXTRUDER_ID)
{
return GetExtderById(m_current_loading_extder_id);
}
return std::nullopt;
}
std::optional<DevExtder> DevExtderSystem::GetExtderById(int extder_id) const
{
if (extder_id >= m_extders.size())
{
assert(false && "Invalid extruder ID");
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "No extruder found for " << extder_id;
return std::nullopt;
}
return m_extders[extder_id];
}
std::string DevExtderSystem::GetCurrentAmsId() const
{
auto cur_extder = GetCurrentExtder();
return cur_extder ? cur_extder->GetSlotNow().ams_id : DevAmsSlotInfo().ams_id;
}
std::string DevExtderSystem::GetCurrentSlotId() const
{
auto cur_extder = GetCurrentExtder();
return cur_extder ? GetCurrentExtder()->GetSlotNow().slot_id : DevAmsSlotInfo().slot_id;
}
std::string DevExtderSystem::GetTargetAmsId() const
{
auto cur_extder = GetCurrentExtder();
return cur_extder ? GetCurrentExtder()->GetSlotTarget().ams_id : DevAmsSlotInfo().ams_id;
}
std::string DevExtderSystem::GetTargetSlotId() const
{
auto cur_extder = GetCurrentExtder();
return cur_extder ? GetCurrentExtder()->GetSlotTarget().slot_id : DevAmsSlotInfo().slot_id;
}
bool DevExtderSystem::HasFilamentBackup() const
{
for (const auto& ext : m_extders)
{
if (ext.HasFilamBackup())
{
return true;
}
}
return false;
}
void ExtderSystemParser::ParseV1_0(const nlohmann::json& print_json, DevExtderSystem* system)
{
if (system->GetTotalExtderCount() != 1)
{
return;
}
if (print_json.contains("nozzle_temper") && print_json["nozzle_temper"].is_number())
{
system->m_extders[MAIN_EXTRUDER_ID].m_cur_temp = print_json["nozzle_temper"].get<float>();
}
if (print_json.contains("nozzle_target_temper") && print_json["nozzle_target_temper"].is_number())
{
system->m_extders[MAIN_EXTRUDER_ID].m_target_temp = print_json["nozzle_target_temper"].get<float>();
}
if (print_json.contains("ams") && print_json["ams"].contains("tray_tar"))
{
const std::string& tray_tar = print_json["ams"]["tray_tar"].get<std::string>();
if (!tray_tar.empty())
{
int tray_tar_int = atoi(tray_tar.c_str());
if (tray_tar_int == VIRTUAL_TRAY_MAIN_ID || tray_tar_int == VIRTUAL_TRAY_DEPUTY_ID)
{
system->m_extders[MAIN_EXTRUDER_ID].m_star.ams_id = std::to_string(VIRTUAL_TRAY_MAIN_ID);
system->m_extders[MAIN_EXTRUDER_ID].m_star.slot_id = "0";
}
else
{
if (tray_tar_int >= 0x80 && tray_tar_int <= 0x87)
{
system->m_extders[MAIN_EXTRUDER_ID].m_star.ams_id = std::to_string(tray_tar_int);
}
else
{
system->m_extders[MAIN_EXTRUDER_ID].m_star.ams_id = std::to_string(tray_tar_int >> 2);
}
system->m_extders[MAIN_EXTRUDER_ID].m_star.slot_id = std::to_string(tray_tar_int & 0x3);
}
}
}
if (print_json.contains("ams") && print_json["ams"].contains("tray_now"))
{
const std::string& tray_now = print_json["ams"]["tray_now"].get<std::string>();
if (!tray_now.empty())
{
int tray_now_int = atoi(tray_now.c_str());
if (tray_now_int == VIRTUAL_TRAY_MAIN_ID || tray_now_int == VIRTUAL_TRAY_DEPUTY_ID)
{
system->m_extders[MAIN_EXTRUDER_ID].m_snow.ams_id = std::to_string(VIRTUAL_TRAY_MAIN_ID);
system->m_extders[MAIN_EXTRUDER_ID].m_snow.slot_id = "0";
}
else
{
if (tray_now_int >= 0x80 && tray_now_int <= 0x87)
{
system->m_extders[MAIN_EXTRUDER_ID].m_snow.ams_id = std::to_string(tray_now_int);
}
else
{
system->m_extders[MAIN_EXTRUDER_ID].m_snow.ams_id = std::to_string(tray_now_int >> 2);
}
system->m_extders[MAIN_EXTRUDER_ID].m_snow.slot_id = std::to_string(tray_now_int & 0x3);
}
}
}
system->m_current_busy_for_loading = false;
system->m_current_loading_extder_id = INVALID_EXTRUDER_ID;
if (!system->m_extders[MAIN_EXTRUDER_ID].m_star.ams_id.empty())
{
system->m_current_busy_for_loading = (system->m_extders[MAIN_EXTRUDER_ID].m_snow == system->m_extders[MAIN_EXTRUDER_ID].m_star);
if (system->m_current_busy_for_loading)
{
system->m_current_loading_extder_id = MAIN_EXTRUDER_ID;
}
}
}
void ExtderSystemParser::ParseV2_0(const nlohmann::json& extruder_json, DevExtderSystem* system)
{
system->m_total_extder_count = DevUtil::get_flag_bits(extruder_json["state"].get<int>(), 0, 4);
if (system->m_current_extder_id != DevUtil::get_flag_bits(extruder_json["state"].get<int>(), 4, 4))
{
system->Owner()->targ_nozzle_id_from_pc = INVALID_EXTRUDER_ID;
system->m_current_extder_id = DevUtil::get_flag_bits(extruder_json["state"].get<int>(), 4, 4);
}
else if (system->m_switch_extder_state == ES_SWITCHING_FAILED)
{
system->Owner()->targ_nozzle_id_from_pc = INVALID_EXTRUDER_ID;
}
system->m_target_extder_id = DevUtil::get_flag_bits(extruder_json["state"].get<int>(), 8, 4);
system->m_switch_extder_state = (DevExtderSwitchState)DevUtil::get_flag_bits(extruder_json["state"].get<int>(), 12, 3);
system->m_current_loading_extder_id = DevUtil::get_flag_bits(extruder_json["state"].get<int>(), 15, 4);
system->m_current_busy_for_loading = DevUtil::get_flag_bits(extruder_json["state"].get<int>(), 19);
system->m_extders.clear();
for (auto it = extruder_json["info"].begin(); it != extruder_json["info"].cend(); it++)
{
DevExtder extder_obj(system);
const auto& njon = it.value();
extder_obj.SetExtId(njon["id"].get<int>());
extder_obj.m_filam_bak.clear();
const json& filam_bak_items = njon["filam_bak"];
for (const auto& filam_bak_item : filam_bak_items)
{
const auto& filam_bak_val = filam_bak_item.get<int>();
extder_obj.m_filam_bak.emplace_back(filam_bak_val);
}
extder_obj.m_ext_has_filament = (DevUtil::get_flag_bits(njon["info"].get<int>(), 1) != 0);
extder_obj.m_buffer_has_filament = (DevUtil::get_flag_bits(njon["info"].get<int>(), 2) != 0);
extder_obj.m_has_nozzle = (DevUtil::get_flag_bits(njon["info"].get<int>(), 3) != 0);
extder_obj.m_cur_temp = DevUtil::get_flag_bits(njon["temp"].get<int>(), 0, 16);
extder_obj.m_target_temp = DevUtil::get_flag_bits(njon["temp"].get<int>(), 16, 16);
extder_obj.m_spre.slot_id = std::to_string(DevUtil::get_flag_bits(njon["spre"].get<int>(), 0, 8));
extder_obj.m_spre.ams_id = std::to_string(DevUtil::get_flag_bits(njon["spre"].get<int>(), 8, 8));
extder_obj.m_snow.slot_id = std::to_string(DevUtil::get_flag_bits(njon["snow"].get<int>(), 0, 8));
extder_obj.m_snow.ams_id = std::to_string(DevUtil::get_flag_bits(njon["snow"].get<int>(), 8, 8));
extder_obj.m_star.slot_id = std::to_string(DevUtil::get_flag_bits(njon["star"].get<int>(), 0, 8));
extder_obj.m_star.ams_id = std::to_string(DevUtil::get_flag_bits(njon["star"].get<int>(), 8, 8));
extder_obj.m_ams_stat = DevUtil::get_flag_bits(njon["stat"].get<int>(), 0, 16);
extder_obj.m_rfid_stat = DevUtil::get_flag_bits(njon["stat"].get<int>(), 16, 16);
//current nozzle info
extder_obj.m_current_nozzle_id = njon["hnow"].get<int>();
system->m_extders.push_back(extder_obj);
}
}
}
@@ -0,0 +1,189 @@
#pragma once
#include "libslic3r/CommonDefs.hpp"
#include "slic3r/Utils/json_diff.hpp"
#include <wx/string.h>
#include "DevDefs.h"
namespace Slic3r
{
//Previous definitions
class MachineObject;
class DevExtderSystem;
struct DevAmsSlotInfo
{
std::string ams_id;
std::string slot_id;
public:
bool operator==(const DevAmsSlotInfo& other) const { return ams_id == other.ams_id && slot_id == other.slot_id;}
};
enum DevExtderSwitchState
{
ES_IDLE = 0,
ES_BUSY,
ES_SWITCHING,
ES_SWITCHING_FAILED
};
class DevExtder
{
friend class MachineObject;
friend class ExtderSystemParser;
public:
DevExtder(DevExtderSystem* owner/*should not be nullptr*/, int id = -1) : system(owner), m_ext_id(id){};
public:
// Ext
int GetExtId() const { return m_ext_id; }
// display
wxString GetDisplayLoc() const;
wxString GetDisplayName() const;
// installed nozzle info
bool HasNozzleInstalled() const = delete;//{ return m_has_nozzle; }
int GetNozzleId() const { return m_current_nozzle_id; }
int GetTargetNozzleId() const = delete;//{ return m_target_nozzle_id; }
NozzleType GetNozzleType() const;
NozzleFlowType GetNozzleFlowType() const;
float GetNozzleDiameter() const;
// temperature
int GetCurrentTemp() const { return m_cur_temp; }
int GetTargetTemp() const { return m_target_temp; }
// filament
bool HasFilamentInExt() const { return m_ext_has_filament; }
bool HasFilamentInBuffer() const = delete; //{ return m_buffer_has_filament; }
bool HasFilamBackup() const { return !m_filam_bak.empty(); }
std::vector<int> GetFilamBackup() const { return m_filam_bak; }
// ams binding on current extruder
const DevAmsSlotInfo& GetSlotPre() const { return m_spre; }
const DevAmsSlotInfo& GetSlotNow() const { return m_snow; }
const DevAmsSlotInfo& GetSlotTarget() const { return m_star; }
private:
void SetExtId(int val) { m_ext_id = val; }
private:
DevExtderSystem* system = nullptr;
// extruder id
int m_ext_id; // 0-right 1-left
// current nozzle
bool m_has_nozzle = false;
int m_current_nozzle_id = 0; // nozzle id now. for some machine, the extruder may have serveral nozzles
int m_target_nozzle_id = 0; // target nozzle id
// temperature
int m_cur_temp = 0;
int m_target_temp = 0;
// filament
bool m_ext_has_filament = false;
bool m_buffer_has_filament = false;
std::vector<int> m_filam_bak;// the refill filam
// binded ams
DevAmsSlotInfo m_spre; // tray_pre
DevAmsSlotInfo m_snow; // tray_now
DevAmsSlotInfo m_star; // tray_tar
int m_ams_stat = 0;
int m_rfid_stat = 0;
};
// ExtderSystem is the extruder management system for the device.
// It consists of multiple extruders (Extder) and nozzles.
// Each extruder can be associated with different nozzles, and the number of extruders
// does not necessarily equal the number of nozzles.
// Note: The IDs of extruders and nozzles may not match or correspond one-to-one.
class DevExtderSystem
{
friend class MachineObject;
friend class ExtderSystemParser;
public:
DevExtderSystem(MachineObject* obj);
~DevExtderSystem() = default;
public:
MachineObject* Owner() const { return m_owner; }
// access extder info
int GetTotalExtderCount() const { assert(m_extders.size() == m_total_extder_count); return m_total_extder_count; }
int GetTotalExtderSize() const { return static_cast<int>(m_extders.size()); }
int GetCurrentExtderId() const { return m_current_extder_id; }
int GetTargetExtderId() const = delete;//{ return m_target_extder_id; }
// switching
DevExtderSwitchState GetSwitchState() const { return m_switch_extder_state; }
bool IsSwitching() const { return m_switch_extder_state == DevExtderSwitchState::ES_SWITCHING;};
bool IsSwitchingFailed() const { return m_switch_extder_state == DevExtderSwitchState::ES_SWITCHING_FAILED; };
bool CanQuitSwitching() const;
bool CanRetrySwitching() const { return IsSwitchingFailed(); };
int CtrlRetrySwitching();
int CtrlQuitSwitching();
std::optional<DevExtder> GetCurrentExtder() const;
std::optional<DevExtder> GetLoadingExtder() const;
std::optional<DevExtder> GetExtderById(int extder_id) const;
const std::vector<DevExtder>& GetExtruders() const { return m_extders;};
// get nozzle info which is installed on the extruder
NozzleType GetNozzleType(int extder_id) const { return GetExtderById(extder_id) ? GetExtderById(extder_id)->GetNozzleType() : NozzleType::ntUndefine; }
NozzleFlowType GetNozzleFlowType(int extder_id) const { return GetExtderById(extder_id) ? GetExtderById(extder_id)->GetNozzleFlowType() : NozzleFlowType::NONE_FLOWTYPE;; }
float GetNozzleDiameter(int extder_id) const { return GetExtderById(extder_id) ? GetExtderById(extder_id)->GetNozzleDiameter() : 0.0; }
int GetNozzleTempCurrent(int extder_id) const { return GetExtderById(extder_id) ? GetExtderById(extder_id)->GetCurrentTemp() : 0; }
int GetNozzleTempTarget(int extder_id) const { return GetExtderById(extder_id) ? GetExtderById(extder_id)->GetTargetTemp() : 0; }
// get slot info which is connected to the extruder
std::string GetCurrentAmsId() const;
std::string GetCurrentSlotId() const;
std::string GetTargetAmsId() const;
std::string GetTargetSlotId() const;
// filament
bool IsBusyLoading() const { return m_current_busy_for_loading; }
int GetLoadingExtderId() const { return m_current_loading_extder_id; }
bool HasFilamentBackup() const;
bool HasFilamentInExt(int exter_id) { return GetExtderById(exter_id) ? GetExtderById(exter_id)->HasFilamentInExt() : false; }
protected:
void AddExtder(const DevExtder& ext) { m_extders[ext.GetExtId()] = ext; };
private:
MachineObject* m_owner = nullptr;
// extruders
int m_total_extder_count = 1;
std::vector<DevExtder> m_extders;
// current extruder and swtching info
int m_current_extder_id = MAIN_EXTRUDER_ID;
// switching
DevExtderSwitchState m_switch_extder_state = DevExtderSwitchState::ES_IDLE;
int m_target_extder_id = MAIN_EXTRUDER_ID;
// loading extruder
bool m_current_busy_for_loading{ false };
int m_current_loading_extder_id = INVALID_EXTRUDER_ID;
};
class ExtderSystemParser
{
public:
static void ParseV1_0(const nlohmann::json& extruder_json, DevExtderSystem* system);
static void ParseV2_0(const nlohmann::json& extruder_json, DevExtderSystem* system);
};
};
@@ -0,0 +1,22 @@
#include <nlohmann/json.hpp>
#include "DevExtruderSystem.h"
#include "slic3r/GUI/DeviceManager.hpp"
using namespace nlohmann;
namespace Slic3r
{
int DevExtderSystem::CtrlRetrySwitching()
{
if (m_owner) { return m_owner->command_ams_control("resume"); }
return -1;
}
int DevExtderSystem::CtrlQuitSwitching()
{
if (m_owner) { return m_owner->command_ams_control("abort"); }
return -1;
}
}
+219
View File
@@ -0,0 +1,219 @@
#include <nlohmann/json.hpp>
#include "DevFan.h"
#include <wx/app.h>
#include "slic3r/GUI/DeviceManager.hpp"
#include "slic3r/GUI/GUI.hpp"
#include "slic3r/GUI/GUI_App.hpp"
using namespace nlohmann;
void Slic3r::DevFan::converse_to_duct(bool is_suppt_part_fun, bool is_suppt_aux_fun, bool is_suppt_cham_fun)
{
m_air_duct_data.modes.clear();
m_air_duct_data.parts.clear();
m_air_duct_data.curren_mode = -1; // def mode
if (is_suppt_part_fun) {
AirParts part_fan;
part_fan.type = int(AirDuctType::AIR_FAN_TYPE);
part_fan.id = int(AIR_FUN::FAN_COOLING_0_AIRDOOR);
part_fan.func = int(AIR_FUN::FAN_COOLING_0_AIRDOOR);
part_fan.state = 0;
part_fan.range_start = 0;
part_fan.range_end = 100;
m_air_duct_data.parts.push_back(part_fan);
}
if (is_suppt_aux_fun) {
AirParts aux_fan;
aux_fan.type = int(AirDuctType::AIR_FAN_TYPE);
aux_fan.id = int(AIR_FUN::FAN_REMOTE_COOLING_0_IDX);
aux_fan.func = int(AIR_FUN::FAN_REMOTE_COOLING_0_IDX);
aux_fan.state = 0;
aux_fan.range_start = 0;
aux_fan.range_end = 100;
m_air_duct_data.parts.push_back(aux_fan);
}
if (is_suppt_aux_fun) {
AirParts chamber_fan;
chamber_fan.type = int(AirDuctType::AIR_FAN_TYPE);
chamber_fan.id = int(AIR_FUN::FAN_CHAMBER_0_IDX);
chamber_fan.func = int(AIR_FUN::FAN_CHAMBER_0_IDX);
chamber_fan.state = 0;
chamber_fan.range_start = 0;
chamber_fan.range_end = 100;
m_air_duct_data.parts.push_back(chamber_fan);
}
}
static std::string _get_string_from_fantype(int type)
{
switch (type) {
case 1: return "cooling_fan";
case 2: return "big_cooling_fan";
case 3: return "chamber_fan";
default: return "";
}
return "";
}
// Old protocol
int Slic3r::DevFan::command_control_fan(int fan_type, int val)
{
std::string gcode = (boost::format("M106 P%1% S%2% \n") % (int) fan_type % (val)).str();
return m_owner->publish_gcode(gcode);
}
// New protocol
int Slic3r::DevFan::command_control_fan_new(int fan_id, int val)
{
BOOST_LOG_TRIVIAL(info) << "New protocol of fan setting(set speed), fan_id = " << fan_id;
json j;
j["print"]["command"] = "set_fan";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["fan_index"] = fan_id;
j["print"]["speed"] = val;
BOOST_LOG_TRIVIAL(info) << "MachineObject::command_control_fan_val, set the speed of fan, fan_id = " << fan_id;
return m_owner->publish_json(j);
}
int Slic3r::DevFan::command_handle_response(const json &response)
{
if (!response.contains("sequence_id")) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ", error reponse.";
return -1;
}
std::string reply = response["sequence_id"].get<std::string>();
auto it = m_callback_list.find(reply);
if (it != m_callback_list.end()) {
if (it->second) it->second(response);
m_callback_list.erase(it);
}
return 0;
}
int Slic3r::DevFan::command_control_air_duct(int mode_id, int submode, const CommandCallBack& cb)
{
BOOST_LOG_TRIVIAL(info) << "MachineObject::command_control_air_duct, set air duct, d = " << mode_id;
m_callback_list[std::to_string(m_owner->m_sequence_id)] = cb;
json j;
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["command"] = "set_airduct";
j["print"]["modeId"] = mode_id;
j["print"]["submode"] = submode;
return m_owner->publish_json(j);
}
void Slic3r::DevFan::ParseV1_0(const json &print_json)
{
if (print_json.contains("fan_gear")) {
fan_gear = print_json["fan_gear"].get<std::uint32_t>();
big_fan2_speed = (int) ((fan_gear & 0x00FF0000) >> 16);
big_fan1_speed = (int) ((fan_gear & 0x0000FF00) >> 8);
cooling_fan_speed = (int) ((fan_gear & 0x000000FF) >> 0);
} else {
if (print_json.contains("cooling_fan_speed")) {
cooling_fan_speed = stoi(print_json["cooling_fan_speed"].get<std::string>());
cooling_fan_speed = round(floor(cooling_fan_speed / float(1.5)) * float(25.5));
} else {
cooling_fan_speed = 0;
}
if (print_json.contains("big_fan1_speed")) {
big_fan1_speed = stoi(print_json["big_fan1_speed"].get<std::string>());
big_fan1_speed = round(floor(big_fan1_speed / float(1.5)) * float(25.5));
} else {
big_fan1_speed = 0;
}
if (print_json.contains("big_fan2_speed")) {
big_fan2_speed = stoi(print_json["big_fan2_speed"].get<std::string>());
big_fan2_speed = round(floor(big_fan2_speed / float(1.5)) * float(25.5));
} else {
big_fan2_speed = 0;
}
}
if (print_json.contains("heatbreak_fan_speed")) { heatbreak_fan_speed = stoi(print_json["heatbreak_fan_speed"].get<std::string>()); }
}
void Slic3r::DevFan::ParseV2_0(const json &print_json) {
if (print_json.contains("support_aux_fan")) {
if (print_json["support_aux_fan"].is_boolean())
is_support_aux_fan = print_json["support_aux_fan"].get<bool>();
}
if (print_json.contains("support_chamber_fan")) {
if (print_json["support_chamber_fan"].is_boolean())
is_support_chamber_fan = print_json["support_chamber_fan"].get<bool>();
}
}
void Slic3r::DevFan::ParseV3_0(const json &device)
{
if (device.contains("airduct")) {
m_air_duct_data.curren_mode = -1;
m_air_duct_data.modes.clear();
m_air_duct_data.parts.clear();
m_air_duct_data.curren_mode = device["airduct"]["modeCur"].get<int>();
const json &airduct = device["airduct"];
if (airduct.contains("modeCur")) { m_air_duct_data.curren_mode = airduct["modeCur"].get<int>(); }
if (airduct.contains("subMode")) { m_air_duct_data.m_sub_mode = airduct["subMode"].get<int>(); }
if (airduct.contains("modeList") && airduct["modeList"].is_array()) {
auto list = airduct["modeList"].get<std::vector<json>>();
for (int i = 0; i < list.size(); ++i) {
// only show 2 mode for o
if (m_owner->is_series_o() && i >= 2) { break; }
json mode_json = list[i];
AirMode mode;
if (mode_json.contains("modeId")) mode.id = mode_json["modeId"].get<int>();
if (mode_json.contains("ctrl")) {
for (auto it_mode_ctrl = mode_json["ctrl"].begin(); it_mode_ctrl != mode_json["ctrl"].end(); it_mode_ctrl++) {
mode.ctrl.push_back((*it_mode_ctrl).get<int>() >> 4);
}
}
if (mode_json.contains("off")) {
for (auto it_mode_off = mode_json["off"].begin(); it_mode_off != mode_json["off"].end(); *it_mode_off++) {
mode.off.push_back((*it_mode_off).get<int>() >> 4);
}
}
if (AIR_DUCT(mode.id) == AIR_DUCT::AIR_DUCT_EXHAUST) { continue; } /*STUDIO-12796*/
m_air_duct_data.modes[mode.id] = mode;
}
}
if (airduct.contains("parts") && airduct["parts"].is_array()) {
for (auto it_part = airduct["parts"].begin(); it_part != airduct["parts"].end(); it_part++) {
int state = (*it_part)["state"].get<int>();
int range = (*it_part)["range"].get<int>();
AirParts part;
part.type = m_owner->get_flag_bits((*it_part)["id"].get<int>(), 0, 4);
part.id = m_owner->get_flag_bits((*it_part)["id"].get<int>(), 4, 9);
part.func = (*it_part)["func"].get<int>();
part.state = m_owner->get_flag_bits(state, 0, 8);
part.range_start = m_owner->get_flag_bits(range, 0, 16);
part.range_end = m_owner->get_flag_bits(range, 16, 16);
m_air_duct_data.parts.push_back(part);
}
}
}
}
+150
View File
@@ -0,0 +1,150 @@
#pragma once
#include <nlohmann/json.hpp>
#include "slic3r/Utils/json_diff.hpp"
namespace Slic3r {
class MachineObject;
enum AirDuctType { AIR_FAN_TYPE, AIR_DOOR_TYPE };
typedef std::function<void(const json &)> CommandCallBack;
enum AIR_FUN {
FAN_HEAT_BREAK_0_IDX = 0,
FAN_COOLING_0_AIRDOOR = 1,
FAN_REMOTE_COOLING_0_IDX = 2,
FAN_CHAMBER_0_IDX = 3,
FAN_HEAT_BREAK_1_IDX = 4,
FAN_MC_BOARD_0_IDX = 5,
FAN_INNNER_LOOP_FAN_0_IDX = 6,
FAN_TOTAL_COUNT = 7
};
enum AIR_DOOR { AIR_DOOR_FUNC_CHAMBER = 0, AIR_DOOR_FUNC_INNERLOOP, AIR_DOOR_FUNC_TOP };
enum AIR_DUCT {
AIR_DUCT_NONE = -1,
AIR_DUCT_COOLING_FILT = 0,
AIR_DUCT_HEATING_INTERNAL_FILT,
AIR_DUCT_EXHAUST,
AIR_DUCT_FULL_COOLING,
AIR_DUCT_INIT = 0xFF // Initial mode, only used within mc
};
struct AirParts
{
int type{0};
int id{0};
int func{0};
int state{0}; // 100%
int range_start{0}; // 100%
int range_end{0}; // 100%
public:
bool operator ==(const AirParts& other) const
{
return (type == other.type) && (id == other.id) && (func == other.func) && (state == other.state) && (range_start == other.range_start) && (range_end == other.range_end);
};
};
struct AirMode
{
int id{-1};
std::vector<int> ctrl;
// If the fan is off, it cannot be controlled and is displayed as off
std::vector<int> off;
// If the fan is not off or ctrl, it will be displayed as auto
public:
bool operator ==(const AirMode& other) const
{
return (id == other.id) && (ctrl == other.ctrl) && (off == other.off);
};
};
struct AirDuctData
{
int curren_mode{0};
std::unordered_map<int, AirMode> modes;
std::vector<AirParts> parts;
int m_sub_mode = -1;// the submode of airduct, for cooling: 0-filter, 1-cooling
bool m_support_cooling_filter = false;// support switch filter on cooling mode or not
public:
bool operator ==(const AirDuctData& other) const
{
return (curren_mode == other.curren_mode) && (modes == other.modes) && (parts == other.parts) &&
(m_sub_mode == other.m_sub_mode) && (m_support_cooling_filter == other.m_support_cooling_filter);
};
bool operator !=(const AirDuctData& other) const
{
return !(operator==(other));
};
bool IsSupportCoolingFilter() const { return m_support_cooling_filter; }
bool IsCoolingFilerOn() const { return m_sub_mode == 0; }
};
class DevFan
{
public:
DevFan(MachineObject *obj) : m_owner(obj){};
public:
enum FanType {//if have devPrinter , delete?
COOLING_FAN = 1,
BIG_COOLING_FAN = 2,
CHAMBER_FAN = 3,
EXHAUST_FAN,
FILTER_FAN,
};
bool is_at_heating_mode() const { return m_air_duct_data.curren_mode == AIR_DUCT_HEATING_INTERNAL_FILT; };
void SetSupportCoolingFilter(bool enable) { m_air_duct_data.m_support_cooling_filter = enable; }
AirDuctData GetAirDuctData() { return m_air_duct_data; };
void converse_to_duct(bool is_suppt_part_fun, bool is_suppt_aux_fun, bool is_suppt_cham_fun); // Convert the data to duct type to make the newand old protocols consistent
int command_handle_response(const json &response);
int command_control_fan(int fan_type, int val); // Old protocol
int command_control_fan_new(int fan_id, int val); // New protocol
int command_control_air_duct(int mode_id, int submode, const CommandCallBack& cb);
void ParseV1_0(const json &print_json);
void ParseV2_0(const json &print_json);
void ParseV3_0(const json &print_json);
public:
bool GetSupportAuxFanData() { return is_support_aux_fan; };
bool GetSupportChamberFan() { return is_support_aux_fan; };
int GetHeatBreakFanSpeed() { return heatbreak_fan_speed; }
int GetCoolingFanSpeed() { return cooling_fan_speed; }
int GetBigFan1Speed() { return big_fan1_speed; }
int GetBigFan2Speed() { return big_fan2_speed; }
uint32_t GetFanGear() { return fan_gear; }
private:
AirDuctData m_air_duct_data;
bool is_support_aux_fan{false};
bool is_support_chamber_fan{false};
int heatbreak_fan_speed = 0;
int cooling_fan_speed = 0;
int big_fan1_speed = 0;
int big_fan2_speed = 0;
uint32_t fan_gear = 0;
std::map<std::string, CommandCallBack> m_callback_list;
MachineObject *m_owner = nullptr;
};
} // namespace Slic3r
@@ -0,0 +1,13 @@
#include "DevFilaAmsSetting.h"
namespace Slic3r {
void DevAmsSystemSetting::Reset()
{
SetDetectOnInsertEnabled(false);
SetDetectOnPowerupEnabled(false);
SetDetectRemainEnabled(false);
SetAutoRefillEnabled(false);
}
}
@@ -0,0 +1,35 @@
#pragma once
namespace Slic3r
{
class DevFilaSystem;
class DevAmsSystemSetting
{
public:
DevAmsSystemSetting(DevFilaSystem* owner) : m_owner(owner) {};
public:
// getters
bool IsDetectOnInsertEnabled() const { return m_enable_detect_on_insert; };
bool IsDetectOnPowerupEnabled() const { return m_enable_detect_on_powerup; }
bool IsDetectRemainEnabled() const { return m_enable_detect_remain; }
bool IsAutoRefillEnabled() const { return m_enable_auto_refill; }
// setters
void Reset();
void SetDetectOnInsertEnabled(bool enable) { m_enable_detect_on_insert = enable; }
void SetDetectOnPowerupEnabled(bool enable) { m_enable_detect_on_powerup = enable; }
void SetDetectRemainEnabled(bool enable) { m_enable_detect_remain = enable; }
void SetAutoRefillEnabled(bool enable) { m_enable_auto_refill = enable; }
private:
DevFilaSystem* m_owner = nullptr;
bool m_enable_detect_on_insert = false;
bool m_enable_detect_on_powerup = false;
bool m_enable_detect_remain = false;
bool m_enable_auto_refill = false;
};
}// namespace Slic3r
@@ -0,0 +1,259 @@
#include <nlohmann/json.hpp>
#include "DevFilaBlackList.h"
#include "DevFilaSystem.h"
#include "DevManager.h"
#include "libslic3r/Utils.hpp"
#include "slic3r/GUI/I18N.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Plater.hpp"
using namespace nlohmann;
namespace Slic3r {
json DevFilaBlacklist::filaments_blacklist = json::object();
bool DevFilaBlacklist::load_filaments_blacklist_config()
{
if (!filaments_blacklist.empty())
{
return false;
}
filaments_blacklist = json::object();
std::string config_file = Slic3r::resources_dir() + "/printers/filaments_blacklist.json";
boost::nowide::ifstream json_file(config_file.c_str());
try {
if (json_file.is_open()) {
json_file >> filaments_blacklist;
return true;
}
else {
BOOST_LOG_TRIVIAL(error) << "load filaments blacklist config failed";
}
}
catch (...) {
BOOST_LOG_TRIVIAL(error) << "load filaments blacklist config failed";
return false;
}
return true;
}
static std::string _get_filament_name_from_ams(int ams_id, int slot_id)
{
std::string name;
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) { return name; }
MachineObject* obj = dev->get_selected_machine();
if (obj == nullptr) { return name; }
if (ams_id < 0 || slot_id < 0)
{
return name;
}
const auto tray = obj->GetFilaSystem()->GetAmsTray(std::to_string(ams_id), std::to_string(slot_id));
if (!tray) { return name; }
std::string filament_id = tray->setting_id;
PresetBundle* preset_bundle = GUI::wxGetApp().preset_bundle;
auto option = preset_bundle->get_filament_by_filament_id(filament_id);
name = option ? option->filament_name : "";
return name;
}
// moved from tao.wang and zhimin.zeng
void check_filaments(std::string model_id,
std::string tag_vendor,
std::string tag_type,
int ams_id,
int slot_id,
std::string tag_name,
bool& in_blacklist,
std::string& ac,
wxString& info,
wxString& wiki_url)
{
if (tag_name.empty())
{
tag_name = _get_filament_name_from_ams(ams_id, slot_id);
}
in_blacklist = false;
std::transform(tag_vendor.begin(), tag_vendor.end(), tag_vendor.begin(), ::tolower);
std::transform(tag_type.begin(), tag_type.end(), tag_type.begin(), ::tolower);
std::transform(tag_name.begin(), tag_name.end(), tag_name.begin(), ::tolower);
DevFilaBlacklist::load_filaments_blacklist_config();
if (DevFilaBlacklist::filaments_blacklist.contains("blacklist"))
{
for (auto filament_item : DevFilaBlacklist::filaments_blacklist["blacklist"])
{
std::string vendor = filament_item.contains("vendor") ? filament_item["vendor"].get<std::string>() : "";
std::string type = filament_item.contains("type") ? filament_item["type"].get<std::string>() : "";
std::string type_suffix = filament_item.contains("type_suffix") ? filament_item["type_suffix"].get<std::string>() : "";
std::string name = filament_item.contains("name") ? filament_item["name"].get<std::string>() : "";
std::string slot = filament_item.contains("slot") ? filament_item["slot"].get<std::string>() : "";
std::vector<std::string> model_ids = filament_item.contains("model_id") ? filament_item["model_id"].get<std::vector<std::string>>() : std::vector<std::string>();
std::string action = filament_item.contains("action") ? filament_item["action"].get<std::string>() : "";
std::string description = filament_item.contains("description") ? filament_item["description"].get<std::string>() : "";
// check model id
if (!model_ids.empty() && std::find(model_ids.begin(), model_ids.end(), model_id) == model_ids.end()) { continue; }
// check vendor
std::transform(vendor.begin(), vendor.end(), vendor.begin(), ::tolower);
if (!vendor.empty())
{
if ((vendor == "bambu lab" && (tag_vendor == vendor)) ||
(vendor == "third party" && (tag_vendor != "bambu lab")))
{
// Do nothing
}
else
{
continue;
}
}
// check type
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
if (!type.empty() && (type != tag_type)) { continue; }
// check type suffix
std::transform(type_suffix.begin(), type_suffix.end(), type_suffix.begin(), ::tolower);
if (!type_suffix.empty())
{
if (tag_type.length() < type_suffix.length()) { continue; }
if ((tag_type.substr(tag_type.length() - type_suffix.length()) != type_suffix)) { continue; }
}
// check name
std::transform(name.begin(), name.end(), name.begin(), ::tolower);
if (!name.empty() && (name != tag_name)) { continue; }
// check loc
if (!slot.empty())
{
bool is_virtual_slot = devPrinterUtil::IsVirtualSlot(ams_id);
bool check_virtual_slot = (slot == "ext");
bool check_ams_slot = (slot == "ams");
if (is_virtual_slot && !check_virtual_slot)
{
continue;
}
else if (!is_virtual_slot && !check_ams_slot)
{
continue;
}
}
if (GUI::wxGetApp().app_config->get("skip_ams_blacklist_check") == "true") {
action = "warning";
}
in_blacklist = true;
ac = action;
info = _L(description);
wiki_url = filament_item.contains("wiki") ? filament_item["wiki"].get<std::string>() : "";
return;
// Using in description
L("TPU is not supported by AMS.");
L("Damp PVA will become flexible and get stuck inside AMS, please take care to dry it before use.");
L("Damp PVA is flexible and may get stuck in extruder. Dry it before use.");
L("The rough surface of PLA Glow can accelerate wear on the AMS system, particularly on the internal components of the AMS Lite.");
L("CF/GF filaments are hard and brittle, it's easy to break or get stuck in AMS, please use with caution.");
L("PPS-CF is brittle and could break in bended PTFE tube above Toolhead.");
L("PPA-CF is brittle and could break in bended PTFE tube above Toolhead.");
}
}
}
void DevFilaBlacklist::check_filaments_in_blacklist(std::string model_id,
std::string tag_vendor,
std::string tag_type,
const std::string& filament_id,
int ams_id,
int slot_id,
std::string tag_name,
bool& in_blacklist,
std::string& ac,
wxString& info)
{
wxString wiki_url;
check_filaments_in_blacklist_url(model_id, tag_vendor, tag_type, filament_id, ams_id, slot_id, tag_name, in_blacklist, ac, info, wiki_url);
}
bool check_filaments_printable(const std::string &tag_vendor, const std::string &tag_type, const std::string& filament_id, int ams_id, bool &in_blacklist, std::string &ac, wxString &info)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) {
return true;
}
MachineObject *obj = dev->get_selected_machine();
if (obj == nullptr || !obj->is_multi_extruders()) {
return true;
}
Preset *printer_preset = GUI::get_printer_preset(obj);
if (!printer_preset)
return true;
ConfigOptionInts *physical_extruder_map_op = dynamic_cast<ConfigOptionInts *>(printer_preset->config.option("physical_extruder_map"));
if (!physical_extruder_map_op)
return true;
std::vector<int> physical_extruder_maps = physical_extruder_map_op->values;
int obj_extruder_id = obj->get_extruder_id_by_ams_id(std::to_string(ams_id));
int extruder_idx = obj_extruder_id;
for (int index = 0; index < physical_extruder_maps.size(); ++index) {
if (physical_extruder_maps[index] == obj_extruder_id) {
extruder_idx = index;
break;
}
}
PresetBundle *preset_bundle = GUI::wxGetApp().preset_bundle;
std::optional<FilamentBaseInfo> filament_info = preset_bundle->get_filament_by_filament_id(filament_id, printer_preset->name);
if (filament_info.has_value() && !(filament_info->filament_printable >> extruder_idx & 1)) {
wxString extruder_name = extruder_idx == 0 ? _L("left") : _L("right");
ac = "prohibition";
info = wxString::Format(_L("%s is not supported by %s extruder."), tag_type, extruder_name);
in_blacklist = true;
return false;
}
return true;
}
void DevFilaBlacklist::check_filaments_in_blacklist_url(std::string model_id, std::string tag_vendor, std::string tag_type, const std::string& filament_id, int ams_id, int slot_id, std::string tag_name, bool& in_blacklist, std::string& ac, wxString& info, wxString& wiki_url)
{
if (ams_id < 0 || slot_id < 0)
{
return;
}
if (!check_filaments_printable(tag_vendor, tag_type, filament_id, ams_id, in_blacklist, ac, info))
{
return;
}
check_filaments(model_id, tag_vendor, tag_type, ams_id, slot_id, tag_name, in_blacklist, ac, info, wiki_url);
}
}
@@ -0,0 +1,17 @@
#pragma once
#include "slic3r/Utils/json_diff.hpp"
namespace Slic3r
{
class DevFilaBlacklist
{
public:
static bool load_filaments_blacklist_config();
static void check_filaments_in_blacklist(std::string model_id, std::string tag_vendor, std::string tag_type, const std::string& filament_id, int ams_id, int slot_id, std::string tag_name, bool& in_blacklist, std::string& ac, wxString& info);
static void check_filaments_in_blacklist_url(std::string model_id, std::string tag_vendor, std::string tag_type, const std::string& filament_id, int ams_id, int slot_id, std::string tag_name, bool& in_blacklist, std::string& ac, wxString& info, wxString& wiki_url);
public:
static json filaments_blacklist;
};// class DevFilaBlacklist
}// namespace Slic3r
+719
View File
@@ -0,0 +1,719 @@
#include <nlohmann/json.hpp>
#include "DevFilaSystem.h"
// TODO: remove this include
#include "slic3r/GUI/DeviceManager.hpp"
#include "slic3r/GUI/I18N.hpp"
#include "DevUtil.h"
using namespace nlohmann;
namespace Slic3r {
static int _hex_digit_to_int(const char c) { return (c >= '0' && c <= '9') ? c - '0' : (c >= 'A' && c <= 'F') ? c - 'A' + 10 : (c >= 'a' && c <= 'f') ? c - 'a' + 10 : -1; }
wxColour DevAmsTray::decode_color(const std::string &color)
{
std::array<int, 4> ret = {0, 0, 0, 0};
const char * c = color.data();
if (color.size() == 8) {
for (size_t j = 0; j < 4; ++j) {
int digit1 = _hex_digit_to_int(*c++);
int digit2 = _hex_digit_to_int(*c++);
if (digit1 == -1 || digit2 == -1) break;
ret[j] = static_cast<float>(digit1 * 16 + digit2);
}
} else { return wxColour(255, 255, 255, 255); }
return wxColour(ret[0], ret[1], ret[2], ret[3]);
}
void DevAmsTray::UpdateColorFromStr(const std::string& color)
{
if (color.empty()) return;
if (this->color != color)
{
wx_color = "#" + wxString::FromUTF8(color);
this->color = color;
}
}
wxColour DevAmsTray::get_color() { return decode_color(color); }
void DevAmsTray::reset()
{
tag_uid = "";
setting_id = "";
filament_setting_id = "";
type = "";
sub_brands = "";
color = "";
weight = "";
diameter = "";
temp = "";
time = "";
bed_temp_type = "";
bed_temp = "";
nozzle_temp_max = "";
nozzle_temp_min = "";
xcam_info = "";
uuid = "";
k = 0.0f;
n = 0.0f;
is_bbl = false;
hold_count = 0;
remain = 0;
}
bool DevAmsTray::is_tray_info_ready()
{
if (color.empty()) return false;
if (type.empty()) return false;
//if (setting_id.empty()) return false;
return true;
}
bool DevAmsTray::is_unset_third_filament()
{
if (this->is_bbl) return false;
return (color.empty() || type.empty());
}
std::string DevAmsTray::get_display_filament_type()
{
if (type == "PLA-S") return "Sup.PLA";
if (type == "PA-S") return "Sup.PA";
if (type == "ABS-S") return "Sup.ABS";
return type;
}
std::string DevAmsTray::get_filament_type()
{
if (type == "Sup.PLA") { return "PLA-S"; }
if (type == "Sup.PA") { return "PA-S"; }
if (type == "Sup.ABS") { return "ABS-S"; }
if (type == "Support W") { return "PLA-S"; }
if (type == "Support G") { return "PA-S"; }
if (type == "Support") { if (setting_id == "GFS00") { type = "PLA-S"; } else if (setting_id == "GFS01") { type = "PA-S"; } else { return "PLA-S"; } }
return type;
}
DevAms::DevAms(const std::string& ams_id, int extruder_id, AmsType type)
{
m_ams_id = ams_id;
m_ext_id = extruder_id;
m_ams_type = type;
}
DevAms::DevAms(const std::string& ams_id, int nozzle_id, int type)
{
m_ams_id = ams_id;
m_ext_id = nozzle_id;
m_ams_type = (AmsType)type;
assert(DUMMY < type && m_ams_type <= N3S);
}
DevAms::~DevAms()
{
for (auto it = m_trays.begin(); it != m_trays.end(); it++)
{
if (it->second)
{
delete it->second;
it->second = nullptr;
}
}
m_trays.clear();
}
static unordered_map<int, wxString> s_ams_display_formats = {
{DevAms::AMS, "AMS-%d"},
{DevAms::AMS_LITE, "AMS Lite-%d"},
{DevAms::N3F, "AMS 2 PRO-%d"},
{DevAms::N3S, "AMS HT-%d"}
};
wxString DevAms::GetDisplayName() const
{
wxString ams_display_format;
auto iter = s_ams_display_formats.find(m_ams_type);
if (iter != s_ams_display_formats.end())
{
ams_display_format = iter->second;
}
else
{
assert(0 && __FUNCTION__);
ams_display_format = "AMS-%d";
}
int num_id;
try
{
num_id = std::stoi(GetAmsId());
}
catch (const std::exception& e)
{
assert(0 && __FUNCTION__);
BOOST_LOG_TRIVIAL(error) << "Invalid AMS ID: " << GetAmsId() << ", error: " << e.what();
num_id = 0;
}
int loc = (num_id > 127) ? (num_id - 127) : (num_id + 1);
return wxString::Format(ams_display_format, loc);
}
int DevAms::GetSlotCount() const
{
if (m_ams_type == AMS || m_ams_type == AMS_LITE || m_ams_type == N3F)
{
return 4;
}
else if (m_ams_type == N3S)
{
return 1;
}
return 1;
}
DevAmsTray* DevAms::GetTray(const std::string& tray_id) const
{
auto it = m_trays.find(tray_id);
if (it != m_trays.end())
{
return it->second;
}
return nullptr;
}
DevFilaSystem::~DevFilaSystem()
{
for (auto it = amsList.begin(); it != amsList.end(); it++)
{
if (it->second)
{
delete it->second;
it->second = nullptr;
}
}
amsList.clear();
}
DevAms* DevFilaSystem::GetAmsById(const std::string& ams_id) const
{
auto it = amsList.find(ams_id);
if (it != amsList.end())
{
return it->second;
}
return nullptr;
}
DevAmsTray* DevFilaSystem::GetAmsTray(const std::string& ams_id, const std::string& tray_id) const
{
auto it = amsList.find(ams_id);
if (it == amsList.end()) return nullptr;
if (!it->second) return nullptr;
return it->second->GetTray(tray_id);;
}
void DevFilaSystem::CollectAmsColors(std::vector<wxColour>& ams_colors) const
{
ams_colors.clear();
ams_colors.reserve(amsList.size());
for (auto ams = amsList.begin(); ams != amsList.end(); ams++)
{
for (auto tray = ams->second->GetTrays().begin(); tray != ams->second->GetTrays().end(); tray++)
{
if (tray->second->is_tray_info_ready())
{
auto ams_color = DevAmsTray::decode_color(tray->second->color);
ams_colors.emplace_back(ams_color);
}
}
}
}
int DevFilaSystem::GetExtruderIdByAmsId(const std::string& ams_id) const
{
auto it = amsList.find(ams_id);
if (it != amsList.end())
{
return it->second->GetExtruderId();
}
else if (stoi(ams_id) == VIRTUAL_TRAY_MAIN_ID)
{
return MAIN_EXTRUDER_ID;
}
else if (stoi(ams_id) == VIRTUAL_TRAY_DEPUTY_ID)
{
return DEPUTY_EXTRUDER_ID;
}
assert(false && __FUNCTION__);
return 0; // not found
}
bool DevFilaSystem::IsAmsSettingUp() const
{
int setting_up_stat = DevUtil::get_flag_bits(m_ams_cali_stat, 0, 8);
if (setting_up_stat == 0x01 || setting_up_stat == 0x02 || setting_up_stat == 0x03 || setting_up_stat == 0x04)
{
return true;
}
return false;
}
bool DevFilaSystem::IsBBL_Filament(std::string tag_uid)
{
if (tag_uid.empty())
{
return false;
}
for (int i = 0; i < tag_uid.length(); i++)
{
if (tag_uid[i] != '0') { return true; }
}
return false;
}
void DevFilaSystemParser::ParseV1_0(const json& jj, MachineObject* obj, DevFilaSystem* system, bool key_field_only)
{
if (jj.contains("ams"))
{
if (jj["ams"].contains("ams"))
{
if (jj["ams"].contains("ams_exist_bits"))
{
obj->ams_exist_bits = stol(jj["ams"]["ams_exist_bits"].get<std::string>(), nullptr, 16);
}
if (jj["ams"].contains("tray_exist_bits"))
{
obj->tray_exist_bits = stol(jj["ams"]["tray_exist_bits"].get<std::string>(), nullptr, 16);
}
if (jj["ams"].contains("cali_stat")) { system->m_ams_cali_stat = jj["ams"]["cali_stat"].get<int>(); }
if (!key_field_only)
{
if (jj["ams"].contains("tray_read_done_bits"))
{
obj->tray_read_done_bits = stol(jj["ams"]["tray_read_done_bits"].get<std::string>(), nullptr, 16);
}
if (jj["ams"].contains("tray_reading_bits"))
{
obj->tray_reading_bits = stol(jj["ams"]["tray_reading_bits"].get<std::string>(), nullptr, 16);
}
if (jj["ams"].contains("tray_is_bbl_bits"))
{
obj->tray_is_bbl_bits = stol(jj["ams"]["tray_is_bbl_bits"].get<std::string>(), nullptr, 16);
}
if (jj["ams"].contains("version"))
{
if (jj["ams"]["version"].is_number())
{
obj->ams_version = jj["ams"]["version"].get<int>();
}
}
#if 0
if (jj["ams"].contains("ams_rfid_status")) { }
#endif
if (time(nullptr) - obj->ams_user_setting_start > HOLD_TIME_3SEC)
{
if (jj["ams"].contains("insert_flag"))
{
system->m_ams_system_setting.SetDetectOnInsertEnabled(jj["ams"]["insert_flag"].get<bool>());
}
if (jj["ams"].contains("power_on_flag"))
{
system->m_ams_system_setting.SetDetectOnPowerupEnabled(jj["ams"]["power_on_flag"].get<bool>());
}
if (jj["ams"].contains("calibrate_remain_flag"))
{
system->m_ams_system_setting.SetDetectRemainEnabled(jj["ams"]["calibrate_remain_flag"].get<bool>());
}
}
json j_ams = jj["ams"]["ams"];
std::set<std::string> ams_id_set;
for (auto it = system->amsList.begin(); it != system->amsList.end(); it++)
{
ams_id_set.insert(it->first);
}
for (auto it = j_ams.begin(); it != j_ams.end(); it++)
{
if (!it->contains("id")) continue;
std::string ams_id = (*it)["id"].get<std::string>();
int extuder_id = MAIN_EXTRUDER_ID; // Default nozzle id
int type_id = 1; // 0:dummy 1:ams 2:ams-lite 3:n3f 4:n3s
/*ams info*/
if (it->contains("info"))
{
const std::string& info = (*it)["info"].get<std::string>();
type_id = DevUtil::get_flag_bits(info, 0, 4);
extuder_id = DevUtil::get_flag_bits(info, 8, 4);
}
/*AMS without initialization*/
if (extuder_id == 0xE)
{
ams_id_set.erase(ams_id);
system->amsList.erase(ams_id);
continue;
}
ams_id_set.erase(ams_id);
DevAms* curr_ams = nullptr;
auto ams_it = system->amsList.find(ams_id);
if (ams_it == system->amsList.end())
{
DevAms* new_ams = new DevAms(ams_id, extuder_id, type_id);
system->amsList.insert(std::make_pair(ams_id, new_ams));
// new ams added event
curr_ams = new_ams;
}
else
{
if (extuder_id != ams_it->second->GetExtruderId())
{
ams_it->second->m_ext_id = extuder_id;
}
curr_ams = ams_it->second;
}
if (!curr_ams) continue;
/*set ams type flag*/
curr_ams->SetAmsType(type_id);
/*set ams exist flag*/
try
{
if (!ams_id.empty())
{
int ams_id_int = atoi(ams_id.c_str());
if (type_id < 4)
{
curr_ams->m_exist = (obj->ams_exist_bits & (1 << ams_id_int)) != 0 ? true : false;
}
else
{
curr_ams->m_exist = DevUtil::get_flag_bits(obj->ams_exist_bits, 4 + (ams_id_int - 128));
}
}
}
catch (...)
{
;
}
if (it->contains("dry_time") && (*it)["dry_time"].is_number())
{
curr_ams->m_left_dry_time = (*it)["dry_time"].get<int>();
}
if (it->contains("humidity"))
{
std::string humidity = (*it)["humidity"].get<std::string>();
try
{
curr_ams->m_humidity_level = atoi(humidity.c_str());
}
catch (...)
{
;
}
}
if (it->contains("humidity_raw"))
{
std::string humidity_raw = (*it)["humidity_raw"].get<std::string>();
try
{
curr_ams->m_humidity_percent = atoi(humidity_raw.c_str());
}
catch (...)
{
;
}
if (curr_ams->GetHumidityPercent() != -1)
{
if (curr_ams->GetHumidityPercent() < 20)
{
curr_ams->m_humidity_level = 5;
}
else if (curr_ams->GetHumidityPercent() < 40)
{
curr_ams->m_humidity_level = 4;
}
else if (curr_ams->GetHumidityPercent() < 60)
{
curr_ams->m_humidity_level = 3;
}
else if (curr_ams->GetHumidityPercent() < 80)
{
curr_ams->m_humidity_level = 2;
}
else
{
curr_ams->m_humidity_level = 1;
}
}
}
if (it->contains("temp"))
{
std::string temp = (*it)["temp"].get<std::string>();
try
{
curr_ams->m_current_temperature = DevUtil::string_to_float(temp);
}
catch (...)
{
curr_ams->m_current_temperature = INVALID_AMS_TEMPERATURE;
}
}
if (it->contains("tray"))
{
std::set<std::string> tray_id_set;
for (auto it = curr_ams->GetTrays().cbegin(); it != curr_ams->GetTrays().cend(); it++)
{
tray_id_set.insert(it->first);
}
for (auto tray_it = (*it)["tray"].begin(); tray_it != (*it)["tray"].end(); tray_it++)
{
if (!tray_it->contains("id")) continue;
std::string tray_id = (*tray_it)["id"].get<std::string>();
tray_id_set.erase(tray_id);
// compare tray_list
DevAmsTray* curr_tray = nullptr;
auto tray_iter = curr_ams->GetTrays().find(tray_id);
if (tray_iter == curr_ams->GetTrays().end())
{
DevAmsTray* new_tray = new DevAmsTray(tray_id);
curr_ams->m_trays.insert(std::make_pair(tray_id, new_tray));
curr_tray = new_tray;
}
else
{
curr_tray = tray_iter->second;
}
if (!curr_tray) continue;
if (curr_tray->hold_count > 0)
{
curr_tray->hold_count--;
continue;
}
curr_tray->id = (*tray_it)["id"].get<std::string>();
if (tray_it->contains("tag_uid"))
curr_tray->tag_uid = (*tray_it)["tag_uid"].get<std::string>();
else
curr_tray->tag_uid = "0";
if (tray_it->contains("tray_info_idx") && tray_it->contains("tray_type"))
{
curr_tray->setting_id = (*tray_it)["tray_info_idx"].get<std::string>();
//std::string type = (*tray_it)["tray_type"].get<std::string>();
std::string type = MachineObject::setting_id_to_type(curr_tray->setting_id, (*tray_it)["tray_type"].get<std::string>());
if (curr_tray->setting_id == "GFS00")
{
curr_tray->type = "PLA-S";
}
else if (curr_tray->setting_id == "GFS01")
{
curr_tray->type = "PA-S";
}
else
{
curr_tray->type = type;
}
}
else
{
curr_tray->setting_id = "";
curr_tray->type = "";
}
if (tray_it->contains("tray_sub_brands"))
curr_tray->sub_brands = (*tray_it)["tray_sub_brands"].get<std::string>();
else
curr_tray->sub_brands = "";
if (tray_it->contains("tray_weight"))
curr_tray->weight = (*tray_it)["tray_weight"].get<std::string>();
else
curr_tray->weight = "";
if (tray_it->contains("tray_diameter"))
curr_tray->diameter = (*tray_it)["tray_diameter"].get<std::string>();
else
curr_tray->diameter = "";
if (tray_it->contains("tray_temp"))
curr_tray->temp = (*tray_it)["tray_temp"].get<std::string>();
else
curr_tray->temp = "";
if (tray_it->contains("tray_time"))
curr_tray->time = (*tray_it)["tray_time"].get<std::string>();
else
curr_tray->time = "";
if (tray_it->contains("bed_temp_type"))
curr_tray->bed_temp_type = (*tray_it)["bed_temp_type"].get<std::string>();
else
curr_tray->bed_temp_type = "";
if (tray_it->contains("bed_temp"))
curr_tray->bed_temp = (*tray_it)["bed_temp"].get<std::string>();
else
curr_tray->bed_temp = "";
if (tray_it->contains("tray_color"))
{
auto color = (*tray_it)["tray_color"].get<std::string>();
curr_tray->UpdateColorFromStr(color);
}
else
{
curr_tray->color = "";
}
if (tray_it->contains("nozzle_temp_max"))
{
curr_tray->nozzle_temp_max = (*tray_it)["nozzle_temp_max"].get<std::string>();
}
else
curr_tray->nozzle_temp_max = "";
if (tray_it->contains("nozzle_temp_min"))
curr_tray->nozzle_temp_min = (*tray_it)["nozzle_temp_min"].get<std::string>();
else
curr_tray->nozzle_temp_min = "";
if (tray_it->contains("xcam_info"))
curr_tray->xcam_info = (*tray_it)["xcam_info"].get<std::string>();
else
curr_tray->xcam_info = "";
if (tray_it->contains("tray_uuid"))
curr_tray->uuid = (*tray_it)["tray_uuid"].get<std::string>();
else
curr_tray->uuid = "0";
if (tray_it->contains("ctype"))
curr_tray->ctype = (*tray_it)["ctype"].get<int>();
else
curr_tray->ctype = 0;
curr_tray->cols.clear();
if (tray_it->contains("cols"))
{
if ((*tray_it)["cols"].is_array())
{
for (auto it = (*tray_it)["cols"].begin(); it != (*tray_it)["cols"].end(); it++)
{
curr_tray->cols.push_back(it.value().get<std::string>());
}
}
}
if (tray_it->contains("remain"))
{
curr_tray->remain = (*tray_it)["remain"].get<int>();
}
else
{
curr_tray->remain = -1;
}
int ams_id_int = 0;
int tray_id_int = 0;
try
{
if (!ams_id.empty() && !curr_tray->id.empty())
{
ams_id_int = atoi(ams_id.c_str());
tray_id_int = atoi(curr_tray->id.c_str());
if (type_id < 4)
{
curr_tray->is_exists = (obj->tray_exist_bits & (1 << (ams_id_int * 4 + tray_id_int))) != 0 ? true : false;
}
else
{
curr_tray->is_exists = DevUtil::get_flag_bits(obj->tray_exist_bits, 16 + (ams_id_int - 128));
}
}
}
catch (...)
{
}
if (tray_it->contains("setting_id"))
{
curr_tray->filament_setting_id = (*tray_it)["setting_id"].get<std::string>();
}
auto curr_time = std::chrono::system_clock::now();
auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(curr_time - obj->extrusion_cali_set_hold_start);
if (diff.count() > HOLD_TIMEOUT || diff.count() < 0
|| ams_id_int != (obj->extrusion_cali_set_tray_id / 4)
|| tray_id_int != (obj->extrusion_cali_set_tray_id % 4))
{
if (tray_it->contains("k"))
{
curr_tray->k = (*tray_it)["k"].get<float>();
}
if (tray_it->contains("n"))
{
curr_tray->n = (*tray_it)["n"].get<float>();
}
}
std::string temp = tray_it->dump();
if (tray_it->contains("cali_idx"))
{
curr_tray->cali_idx = (*tray_it)["cali_idx"].get<int>();
}
}
// remove not in trayList
for (auto tray_it = tray_id_set.begin(); tray_it != tray_id_set.end(); tray_it++)
{
std::string tray_id = *tray_it;
auto tray = curr_ams->GetTrays().find(tray_id);
if (tray != curr_ams->GetTrays().end())
{
curr_ams->m_trays.erase(tray_id);
BOOST_LOG_TRIVIAL(trace) << "parse_json: remove ams_id=" << ams_id << ", tray_id=" << tray_id;
}
}
}
}
// remove not in amsList
for (auto it = ams_id_set.begin(); it != ams_id_set.end(); it++)
{
std::string ams_id = *it;
auto ams = system->amsList.find(ams_id);
if (ams != system->amsList.end())
{
BOOST_LOG_TRIVIAL(trace) << "parse_json: remove ams_id=" << ams_id;
system->amsList.erase(ams_id);
}
}
}
}
}
}
}
+190
View File
@@ -0,0 +1,190 @@
#pragma once
#include "libslic3r/CommonDefs.hpp"
#include "slic3r/Utils/json_diff.hpp"
#include "DevDefs.h"
#include "DevFilaAmsSetting.h"
#include <map>
#include <wx/string.h>
#include <wx/colour.h>
#define HOLD_COUNT_MAX 3
namespace Slic3r
{
class MachineObject;
class DevAmsTray
{
public:
DevAmsTray(std::string tray_id)
{
is_bbl = false;
id = tray_id;
}
static wxColour decode_color(const std::string& color);
bool operator==(DevAmsTray const& o) const
{
return id == o.id && type == o.type && filament_setting_id == o.filament_setting_id && color == o.color;
}
bool operator!=(DevAmsTray const& o) const { return !operator==(o); }
std::string id;
std::string tag_uid; // tag_uid
std::string setting_id; // tray_info_idx
std::string filament_setting_id; // setting_id
std::string type;
std::string sub_brands;
std::string color;
std::vector<std::string> cols;
std::string weight;
std::string diameter;
std::string temp;
std::string time;
std::string bed_temp_type;
std::string bed_temp;
std::string nozzle_temp_max;
std::string nozzle_temp_min;
std::string xcam_info;
std::string uuid;
int ctype = 0;
float k = 0.0f; // k range: 0 ~ 0.5
float n = 0.0f; // k range: 0.6 ~ 2.0
int cali_idx = -1; // - 1 means default
wxColour wx_color;
bool is_bbl;
bool is_exists = false;
int hold_count = 0;
int remain = 0; // filament remain: 0 ~ 100
void set_hold_count() { hold_count = HOLD_COUNT_MAX; }
void UpdateColorFromStr(const std::string& color);
wxColour get_color();
void reset();
bool is_tray_info_ready();
bool is_unset_third_filament();
std::string get_display_filament_type();
std::string get_filament_type();
};
class DevAms
{
friend class DevFilaSystemParser;
public:
enum AmsType : int
{
DUMMY = 0,
AMS = 1, // AMS
AMS_LITE = 2, // AMS-Lite
N3F = 3, // N3F
N3S = 4, // N3S
};
public:
DevAms(const std::string& ams_id, int extruder_id, AmsType type);
DevAms(const std::string& ams_id, int nozzle_id, int type);
~DevAms();
public:
std::string GetAmsId() const { return m_ams_id; }
wxString GetDisplayName() const; // display
void SetAmsType(int type) { m_ams_type = (AmsType)type; }
void SetAmsType(AmsType type) { m_ams_type = type; }
AmsType GetAmsType() const { return m_ams_type; }
// exist or not
bool IsExist() const { return m_exist; }
// slots
int GetSlotCount() const;
DevAmsTray* GetTray(const std::string& tray_id) const;
const std::map<std::string, DevAmsTray*>& GetTrays() const { return m_trays; }
// installed on the extruder
int GetExtruderId() const { return m_ext_id; }
// temperature and humidity
float GetCurrentTemperature() const { return m_current_temperature; }
bool SupportHumidity() const { return (m_ams_type == AMS) || (m_ams_type == N3F) || (m_ams_type == N3S);}
int GetHumidityLevel() const { return m_humidity_level; }
int GetHumidityPercent() const { return m_humidity_percent; }
bool SupportDrying() const { return m_ams_type > AMS_LITE; }
int GetLeftDryTime() const { return m_left_dry_time; }
private:
AmsType m_ams_type = AmsType::AMS;
std::string m_ams_id;
int m_ext_id;//extruder id
bool m_exist = false;
// slots and trays
std::map<std::string, DevAmsTray*> m_trays;//id -> DevAmsTray*
// temperature and humidity
float m_current_temperature = INVALID_AMS_TEMPERATURE; // the temperature
int m_humidity_level = 5;
int m_humidity_percent = -1; // the percentage, -1 means invalid. eg. 100 means 100%
int m_left_dry_time = 0;
};
class DevFilaSystem
{
friend class DevFilaSystemParser;
public:
DevFilaSystem(MachineObject* owner) { m_owner = owner;};
~DevFilaSystem();
public:
bool HasAms() const { return !amsList.empty(); }
bool IsAmsSettingUp() const;
/* ams */
DevAms* GetAmsById(const std::string& ams_id) const;
std::map<std::string, DevAms*>& GetAmsList() { return amsList; }
int GetAmsCount() const { return amsList.size(); }
/* tray*/
DevAmsTray* GetAmsTray(const std::string& ams_id, const std::string& tray_id) const;
void CollectAmsColors(std::vector<wxColour>& ams_colors) const;
// extruder
int GetExtruderIdByAmsId(const std::string& ams_id) const;
/* AMS settings*/
DevAmsSystemSetting& GetAmsSystemSetting() { return m_ams_system_setting; }
bool IsDetectOnInsertEnabled() const { return m_ams_system_setting.IsDetectOnInsertEnabled(); };
bool IsDetectOnPowerupEnabled() const { return m_ams_system_setting.IsDetectOnPowerupEnabled(); }
bool IsDetectRemainEnabled() const { return m_ams_system_setting.IsDetectRemainEnabled(); }
bool IsAutoRefillEnabled() const { return m_ams_system_setting.IsAutoRefillEnabled(); }
public:
static bool IsBBL_Filament(std::string tag_uid);
private:
MachineObject* m_owner;
/* ams properties */
int m_ams_cali_stat = 0;
std::map<std::string, DevAms*> amsList; // key: ams[id], start with 0
DevAmsSystemSetting m_ams_system_setting{ this };
};// class DevFilaSystem
class DevFilaSystemParser
{
public:
static void ParseV1_0(const json& print_json, MachineObject* obj, DevFilaSystem* system, bool key_field_only);
};
}// namespace Slic3r
@@ -0,0 +1,2 @@
#include "DevFirmware.h"
#include "slic3r/GUI/DeviceManager.hpp"
+57
View File
@@ -0,0 +1,57 @@
#pragma once
#include <nlohmann/json.hpp>
#include "slic3r/Utils/json_diff.hpp"
namespace Slic3r {
//Previous definitions
class MachineObject;
enum PrinterFirmwareType
{
FIRMWARE_TYPE_ENGINEER = 0,
FIRMWARE_TYPE_PRODUCTION,
FIRMEARE_TYPE_UKNOWN,
};
class FirmwareInfo
{
public:
std::string module_type; // ota or ams
std::string version;
std::string url;
std::string name;
std::string description;
};
class DevFirmwareVersionInfo
{
public:
std::string name;
wxString product_name;
std::string sn;
std::string hw_ver;
std::string sw_ver;
std::string sw_new_ver;
int firmware_flag = 0;
public:
bool isValid() const { return !sn.empty(); }
bool isAirPump() const { return product_name.Contains("Air Pump"); }
bool isLaszer() const { return product_name.Contains("Laser"); }
bool isCuttingModule() const { return product_name.Contains("Cutting Module"); }
};
class DevFirmware
{
public:
DevFirmware(MachineObject* obj) : m_owner(obj) {}
private:
MachineObject* m_owner = nullptr;
};
} // namespace Slic3r
+67
View File
@@ -0,0 +1,67 @@
//#include "D:/dev/bamboo_slicer/build_release/src/slic3r/CMakeFiles/libslic3r_gui.dir/Release/cmake_pch.hxx"
#include "DevHMS.h"
namespace Slic3r
{
bool DevHMSItem::parse_hms_info(unsigned attr, unsigned code)
{
bool result = true;
unsigned int model_id_int = (attr >> 24) & 0xFF;
this->m_module_id = (ModuleID)model_id_int;
this->m_module_num = (attr >> 16) & 0xFF;
this->m_part_id = (attr >> 8) & 0xFF;
this->m_reserved = (attr >> 0) & 0xFF;
unsigned msg_level_int = code >> 16;
if (msg_level_int < (unsigned)HMS_MSG_LEVEL_MAX)
{
this->m_msg_level = (HMSMessageLevel)msg_level_int;
}
else
{
this->m_msg_level = HMS_UNKNOWN;
}
this->m_msg_code = code & 0xFFFF;
return result;
}
std::string DevHMSItem::get_long_error_code() const
{
char buf[64];
::sprintf(buf, "%02X%02X%02X00000%1X%04X",
this->m_module_id,
this->m_module_num,
this->m_part_id,
(int)this->m_msg_level,
this->m_msg_code);
return std::string(buf);
}
void DevHMS::ParseHMSItems(const json& hms_json)
{
m_hms_list.clear();
try
{
if (hms_json.is_array())
{
for (auto it = hms_json.begin(); it != hms_json.end(); it++)
{
DevHMSItem item;
if ((*it).contains("attr") && (*it).contains("code"))
{
unsigned attr = (*it)["attr"].get<unsigned>();
unsigned code = (*it)["code"].get<unsigned>();
item.parse_hms_info(attr, code);
}
m_hms_list.push_back(item);
}
}
}
catch (const std::exception&)
{
assert(false && "Parse HMS items failed");
}
}
}
+84
View File
@@ -0,0 +1,84 @@
#pragma once
#include "libslic3r/CommonDefs.hpp"
#include "slic3r/Utils/json_diff.hpp"
#include <wx/string.h>
#include <map>
namespace Slic3r
{
// Previous definitions
class MachineObject;
class DevHMSItem;
class DevHMS
{
public:
DevHMS(MachineObject* obj) : m_object(obj) {}
public:
void ParseHMSItems(const json& hms_json);
const std::vector<DevHMSItem>& GetHMSItems() const { return m_hms_list; };
private:
MachineObject* m_object = nullptr;
// all hms for this machine
std::vector<DevHMSItem> m_hms_list;
};
enum HMSMessageLevel
{
HMS_UNKNOWN = 0,
HMS_FATAL = 1,
HMS_SERIOUS = 2,
HMS_COMMON = 3,
HMS_INFO = 4,
HMS_MSG_LEVEL_MAX,
};
enum ModuleID
{
MODULE_UKNOWN = 0x00,
MODULE_01 = 0x01,
MODULE_02 = 0x02,
MODULE_MC = 0x03,
MODULE_04 = 0x04,
MODULE_MAINBOARD = 0x05,
MODULE_06 = 0x06,
MODULE_AMS = 0x07,
MODULE_TH = 0x08,
MODULE_09 = 0x09,
MODULE_10 = 0x0A,
MODULE_11 = 0x0B,
MODULE_XCAM = 0x0C,
MODULE_13 = 0x0D,
MODULE_14 = 0x0E,
MODULE_15 = 0x0F,
MODULE_MAX = 0x10
};
class DevHMSItem
{
public:
std::string get_long_error_code() const;
HMSMessageLevel get_level() const { return m_msg_level; }
void set_read() { m_already_read = true; };
bool has_read() const { return m_already_read; };
protected:
friend void DevHMS::ParseHMSItems(const json& hms_json);
bool parse_hms_info(unsigned attr, unsigned code);
private:
ModuleID m_module_id;
unsigned m_module_num;
unsigned m_part_id;
unsigned m_reserved;
HMSMessageLevel m_msg_level = HMS_UNKNOWN;
int m_msg_code = 0;
bool m_already_read = false;
};
};// End of namespace Slic3r
+7
View File
@@ -0,0 +1,7 @@
#include "DevInfo.h"
#include "slic3r/GUI/DeviceManager.hpp"
namespace Slic3r
{
}
+37
View File
@@ -0,0 +1,37 @@
#pragma once
#include <nlohmann/json.hpp>
#include "slic3r/Utils/json_diff.hpp"
#include <wx/string.h>
namespace Slic3r {
class MachineObject;
/* some static info of machine*/ /*TODO*/
class DevInfo
{
public:
DevInfo(MachineObject* obj) : m_owner(obj) {};
public:
//std::string GetDevName() const { return m_dev_name; }
//std::string GetDevId() const { return m_dev_id; }
//std::string GetDevIP() const { return m_dev_ip; }
//std::string GetPrinterTypeStr() const { return m_printer_type_str; }
//std::string GetPrinterSignal() const { return m_printer_signal; }
//std::string GetConnectType() const { return m_connect_type; }
//std::string GetBindState() const { return m_bind_state; }
private:
//std::string m_dev_name;
//std::string m_dev_id;
//std::string m_dev_ip;
//std::string m_printer_type_str;
//std::string m_printer_signal;
//std::string m_connect_type;
//std::string m_bind_state;
MachineObject* m_owner = nullptr;
};
} // namespace Slic3r
+18
View File
@@ -0,0 +1,18 @@
#include "DevLamp.h"
static Slic3r::DevLamp::LIGHT_EFFECT _light_effect_parse(std::string effect_str)
{
if (effect_str.compare("on") == 0)
return Slic3r::DevLamp::LIGHT_EFFECT_ON;
else if (effect_str.compare("off") == 0)
return Slic3r::DevLamp::LIGHT_EFFECT_OFF;
else if (effect_str.compare("flashing") == 0)
return Slic3r::DevLamp::LIGHT_EFFECT_FLASHING;
return Slic3r::DevLamp::LIGHT_EFFECT_UNKOWN;
}
void Slic3r::DevLamp::SetChamberLight(const std::string& status)
{
m_chamber_light = _light_effect_parse(status);
}
+42
View File
@@ -0,0 +1,42 @@
#pragma once
namespace Slic3r
{
class MachineObject;
class DevLamp
{
public:
DevLamp(MachineObject* obj) : m_owner(obj) {};
public:
enum LIGHT_EFFECT
{
LIGHT_EFFECT_ON,
LIGHT_EFFECT_OFF,
LIGHT_EFFECT_FLASHING,
LIGHT_EFFECT_UNKOWN,
};
public:
void SetChamberLight(const std::string& status);
void SetChamberLight(LIGHT_EFFECT effect) { m_chamber_light = effect; }
bool IsChamberLightOn() const { return m_chamber_light == LIGHT_EFFECT_ON || m_chamber_light == LIGHT_EFFECT_FLASHING; }
void SetLampCloseRecheck(bool enable) { m_lamp_close_recheck = enable;};
bool HasLampCloseRecheck() const { return m_lamp_close_recheck; }
public:
void CtrlSetChamberLight(LIGHT_EFFECT effect);
private:
int command_set_chamber_light(LIGHT_EFFECT effect, int on_time = 500, int off_time = 500, int loops = 1, int interval = 1000);
int command_set_chamber_light2(LIGHT_EFFECT effect, int on_time = 500, int off_time = 500, int loops = 1, int interval = 1000);
private:
MachineObject* m_owner = nullptr;
bool m_lamp_close_recheck = false;
LIGHT_EFFECT m_chamber_light = LIGHT_EFFECT_UNKOWN;
};
}
+64
View File
@@ -0,0 +1,64 @@
#include <nlohmann/json.hpp>
#include "DevLamp.h"
// TODO: remove this include
#include "slic3r/GUI/DeviceManager.hpp"
using namespace nlohmann;
namespace Slic3r
{
static std::string _light_effect_str(DevLamp::LIGHT_EFFECT effect)
{
switch (effect)
{
case Slic3r::DevLamp::LIGHT_EFFECT_ON:
return "on";
case Slic3r::DevLamp::LIGHT_EFFECT_OFF:
return "off";
case Slic3r::DevLamp::LIGHT_EFFECT_FLASHING:
return "flashing";
default:
return "unknown";
}
return "unknown";
}
void DevLamp::CtrlSetChamberLight(LIGHT_EFFECT effect)
{
// copied from others, TODO CHECK
command_set_chamber_light(effect);
command_set_chamber_light2(effect);
}
int DevLamp::command_set_chamber_light(LIGHT_EFFECT effect, int on_time, int off_time, int loops, int interval)
{
json j;
j["system"]["command"] = "ledctrl";
j["system"]["led_node"] = "chamber_light";
j["system"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["system"]["led_mode"] = _light_effect_str(effect);
j["system"]["led_on_time"] = on_time;
j["system"]["led_off_time"] = off_time;
j["system"]["loop_times"] = loops;
j["system"]["interval_time"] = interval;
return m_owner->publish_json(j);
}
int DevLamp::command_set_chamber_light2(LIGHT_EFFECT effect, int on_time, int off_time, int loops, int interval)
{
json j;
j["system"]["command"] = "ledctrl";
j["system"]["led_node"] = "chamber_light2";
j["system"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["system"]["led_mode"] = _light_effect_str(effect);
j["system"]["led_on_time"] = on_time;
j["system"]["led_off_time"] = off_time;
j["system"]["loop_times"] = loops;
j["system"]["interval_time"] = interval;
return m_owner->publish_json(j);
}
}
+876
View File
@@ -0,0 +1,876 @@
#include <nlohmann/json.hpp>
#include "DevManager.h"
#include "DevUtil.h"
// TODO: remove this include
#include "slic3r/GUI/DeviceManager.hpp"
#include "slic3r/GUI/I18N.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/Plater.hpp"
#include "libslic3r/Time.hpp"
using namespace nlohmann;
namespace Slic3r
{
DeviceManager::DeviceManager(NetworkAgent* agent)
{
m_agent = agent;
m_refresher = new DeviceManagerRefresher(this);
DevPrinterConfigUtil::InitFilePath(resources_dir());
// Load saved local machines
if (agent) {
AppConfig* config = GUI::wxGetApp().app_config;
const auto local_machines = config->get_local_machines();
for (auto& it : local_machines) {
const auto& m = it.second;
MachineObject* obj = new MachineObject(this, m_agent, m.dev_name, m.dev_id, m.dev_ip);
obj->printer_type = m.printer_type;
obj->dev_connection_type = "lan";
obj->bind_state = "free";
obj->bind_sec_link = "secure";
obj->m_is_online = true;
obj->last_alive = Slic3r::Utils::get_current_time_utc();
obj->set_access_code(config->get("access_code", m.dev_id), false);
obj->set_user_access_code(config->get("user_access_code", m.dev_id), false);
if (obj->has_access_right()) {
localMachineList.insert(std::make_pair(m.dev_id, obj));
} else {
config->erase_local_machine(m.dev_id);
delete obj;
}
}
}
}
void DeviceManager::update_local_machine(const MachineObject& m)
{
AppConfig* config = GUI::wxGetApp().app_config;
if (config) {
if (m.is_lan_mode_printer()) {
if (m.has_access_right()) {
BBLocalMachine local_machine;
local_machine.dev_id = m.get_dev_id();
local_machine.dev_name = m.get_dev_name();
local_machine.dev_ip = m.get_dev_ip();
local_machine.printer_type = m.printer_type;
config->update_local_machine(local_machine);
}
} else {
config->erase_local_machine(m.get_dev_id());
}
}
}
DeviceManager::~DeviceManager()
{
delete m_refresher;
for (auto it = localMachineList.begin(); it != localMachineList.end(); it++)
{
if (it->second)
{
delete it->second;
it->second = nullptr;
}
}
localMachineList.clear();
for (auto it = userMachineList.begin(); it != userMachineList.end(); it++)
{
if (it->second)
{
delete it->second;
it->second = nullptr;
}
}
userMachineList.clear();
}
void DeviceManager::EnableMultiMachine(bool enable)
{
m_agent->enable_multi_machine(enable);
m_enable_mutil_machine = enable;
}
void DeviceManager::start_refresher() { m_refresher->Start(); }
void DeviceManager::stop_refresher() { m_refresher->Stop(); }
void DeviceManager::keep_alive()
{
MachineObject* obj = this->get_selected_machine();
if (obj)
{
if (obj->keep_alive_count == 0)
{
obj->last_keep_alive = std::chrono::system_clock::now();
}
obj->keep_alive_count++;
std::chrono::system_clock::time_point start = std::chrono::system_clock::now();
auto internal = std::chrono::duration_cast<std::chrono::milliseconds>(start - obj->last_keep_alive);
if (internal.count() > TIMEOUT_FOR_KEEPALIVE && (internal.count() < 1000 * 60 * 60 * 300))
{
BOOST_LOG_TRIVIAL(info) << "keep alive = " << internal.count() << ", count = " << obj->keep_alive_count;
obj->command_request_push_all();
obj->last_keep_alive = start;
}
else if (obj->m_push_count == 0)
{
BOOST_LOG_TRIVIAL(info) << "keep alive = " << internal.count() << ", push_count = 0, count = " << obj->keep_alive_count;
obj->command_request_push_all();
obj->last_keep_alive = start;
}
}
}
void DeviceManager::check_pushing()
{
keep_alive();
MachineObject* obj = this->get_selected_machine();
std::chrono::system_clock::time_point start = std::chrono::system_clock::now();
auto internal = std::chrono::duration_cast<std::chrono::milliseconds>(start - obj->last_update_time);
if (obj && !obj->is_support_mqtt_alive)
{
if (internal.count() > TIMEOUT_FOR_STRAT && internal.count() < 1000 * 60 * 60 * 300)
{
BOOST_LOG_TRIVIAL(info) << "command_pushing: diff = " << internal.count();
obj->command_pushing("start");
}
}
}
void DeviceManager::on_machine_alive(std::string json_str)
{
try {
json j = json::parse(json_str);
std::string dev_name = j["dev_name"].get<std::string>();
std::string dev_id = j["dev_id"].get<std::string>();
std::string dev_ip = j["dev_ip"].get<std::string>();
std::string printer_type_str= j["dev_type"].get<std::string>();
std::string printer_signal = j["dev_signal"].get<std::string>();
std::string connect_type = j["connect_type"].get<std::string>();
std::string bind_state = j["bind_state"].get<std::string>();
if (connect_type == "farm") {
connect_type ="lan";
bind_state = "free";
}
std::string sec_link = "";
std::string ssdp_version = "";
if (j.contains("sec_link")) {
sec_link = j["sec_link"].get<std::string>();
}
if (j.contains("ssdp_version")) {
ssdp_version = j["ssdp_version"].get<std::string>();
}
std::string connection_name = "";
if (j.contains("connection_name")) {
connection_name = j["connection_name"].get<std::string>();
}
MachineObject* obj;
/* update userMachineList info */
auto it = userMachineList.find(dev_id);
if (it != userMachineList.end()) {
if (it->second->get_dev_ip() != dev_ip ||
it->second->bind_state != bind_state ||
it->second->bind_sec_link != sec_link ||
it->second->dev_connection_type != connect_type ||
it->second->bind_ssdp_version != ssdp_version)
{
if (it->second->bind_state != bind_state) {
OnMachineBindStateChanged(it->second, bind_state);
}
it->second->set_dev_ip(dev_ip);
it->second->bind_state = bind_state;
it->second->bind_sec_link = sec_link;
it->second->dev_connection_type = connect_type;
it->second->bind_ssdp_version = ssdp_version;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " UpdateUserMachineInfo"
<< ", dev_id= " << dev_id
<< ", ip = " <<dev_ip
<< ", printer_name= " << dev_name
<< ", con_type= " << connect_type << ", signal= " << printer_signal
<< ", bind_state= " << bind_state;
}
}
/* update localMachineList */
it = localMachineList.find(dev_id);
if (it != localMachineList.end()) {
// update properties
/* ip changed */
obj = it->second;
if (obj->get_dev_ip().compare(dev_ip) != 0) {
if ( connection_name.empty() ) {
BOOST_LOG_TRIVIAL(info) << "MachineObject IP changed from " << obj->get_dev_ip()
<< " to " << dev_ip;
obj->set_dev_ip(dev_ip);
}
else {
if ( obj->dev_connection_name.empty() || obj->dev_connection_name.compare(connection_name) == 0) {
BOOST_LOG_TRIVIAL(info) << "MachineObject IP changed from " << obj->get_dev_ip()
<< " to " << dev_ip << " connection_name is " << connection_name;
if(obj->dev_connection_name.empty()){obj->dev_connection_name = connection_name;}
obj->set_dev_ip(dev_ip);
}
}
/* ip changed reconnect mqtt */
}
if (obj->wifi_signal != printer_signal ||
obj->dev_connection_type != connect_type ||
obj->bind_state != bind_state ||
obj->bind_sec_link != sec_link ||
obj->bind_ssdp_version != ssdp_version ||
obj->printer_type != _parse_printer_type(printer_type_str))
{
if (obj->dev_connection_type != connect_type ||
obj->bind_state != bind_state ||
obj->bind_sec_link != sec_link ||
obj->bind_ssdp_version != ssdp_version ||
obj->printer_type != _parse_printer_type(printer_type_str))
{
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " UpdateLocalMachineInfo"
<< ", dev_id= " << dev_id
<< ", ip = " << dev_ip
<< ", printer_name= " << dev_name
<< ", con_type= " << connect_type << ", signal= " << printer_signal
<< ", bind_state= " << bind_state;
}
else
{
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " UpdateLocalMachineInfo_WIFI"
<< ", dev_id= " << dev_id
<< ", ip = " << dev_ip
<< ", printer_name= " << dev_name
<< ", con_type= " << connect_type << ", signal= " << printer_signal
<< ", bind_state= " << bind_state;
}
obj->wifi_signal = printer_signal;
obj->dev_connection_type = connect_type;
obj->bind_state = bind_state;
obj->bind_sec_link = sec_link;
obj->bind_ssdp_version = ssdp_version;
obj->printer_type = _parse_printer_type(printer_type_str);
}
// U0 firmware
if (obj->dev_connection_type.empty() && obj->bind_state.empty())
obj->bind_state = "free";
obj->last_alive = Slic3r::Utils::get_current_time_utc();
obj->m_is_online = true;
/* if (!obj->dev_ip.empty()) {
Slic3r::GUI::wxGetApp().app_config->set_str("ip_address", obj->dev_id, obj->dev_ip);
Slic3r::GUI::wxGetApp().app_config->save();
}*/
}
else {
/* insert a new machine */
obj = new MachineObject(this, m_agent, dev_name, dev_id, dev_ip);
obj->printer_type = _parse_printer_type(printer_type_str);
obj->wifi_signal = printer_signal;
obj->dev_connection_type = connect_type;
obj->bind_state = bind_state;
obj->bind_sec_link = sec_link;
obj->dev_connection_name = connection_name;
obj->bind_ssdp_version = ssdp_version;
obj->m_is_online = true;
//load access code
AppConfig* config = Slic3r::GUI::wxGetApp().app_config;
if (config) {
obj->set_access_code(Slic3r::GUI::wxGetApp().app_config->get("access_code", dev_id), false);
obj->set_user_access_code(Slic3r::GUI::wxGetApp().app_config->get("user_access_code", dev_id), false);
}
localMachineList.insert(std::make_pair(dev_id, obj));
/* if (!obj->dev_ip.empty()) {
Slic3r::GUI::wxGetApp().app_config->set_str("ip_address", obj->dev_id, obj->dev_ip);
Slic3r::GUI::wxGetApp().app_config->save();
}*/
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " New Machine, dev_id= " << dev_id
<< ", ip = " << dev_ip <<", printer_name = " << dev_name
<< ", con_type= " << connect_type <<", signal= " << printer_signal << ", bind_state= " << bind_state;
}
update_local_machine(*obj);
}
catch (...) {
;
}
}
MachineObject* DeviceManager::insert_local_device(const BBLocalMachine& machine, std::string connection_type, std::string bind_state, std::string version, std::string access_code)
{
MachineObject* obj;
auto it = localMachineList.find(machine.dev_id);
if (it != localMachineList.end()) {
obj = it->second;
} else {
obj = new MachineObject(this, m_agent, machine.dev_name, machine.dev_id, machine.dev_ip);
localMachineList.insert(std::make_pair(machine.dev_id, obj));
}
obj->printer_type = _parse_printer_type(machine.printer_type);
obj->dev_connection_type = connection_type == "farm" ? "lan":connection_type;
obj->bind_state = connection_type == "farm" ? "free":bind_state;
obj->bind_sec_link = "secure";
obj->bind_ssdp_version = version;
obj->m_is_online = true;
obj->last_alive = Slic3r::Utils::get_current_time_utc();
obj->set_access_code(access_code, false);
obj->set_user_access_code(access_code, false);
update_local_machine(*obj);
return obj;
}
int DeviceManager::query_bind_status(std::string& msg)
{
if (!m_agent)
{
msg = "";
return -1;
}
BOOST_LOG_TRIVIAL(trace) << "DeviceManager::query_bind_status";
std::map<std::string, MachineObject*>::iterator it;
std::vector<std::string> query_list;
for (it = localMachineList.begin(); it != localMachineList.end(); it++)
{
query_list.push_back(it->first);
}
unsigned int http_code;
std::string http_body;
int result = m_agent->query_bind_status(query_list, &http_code, &http_body);
if (result < 0)
{
msg = (boost::format("code=%1%,body=%2") % http_code % http_body).str();
}
else
{
msg = "";
try
{
json j = json::parse(http_body);
if (j.contains("bind_list"))
{
for (auto& item : j["bind_list"])
{
auto it = localMachineList.find(item["dev_id"].get<std::string>());
if (it != localMachineList.end())
{
if (!item["user_id"].is_null())
it->second->bind_user_id = item["user_id"].get<std::string>();
if (!item["user_name"].is_null())
it->second->bind_user_name = item["user_name"].get<std::string>();
else
it->second->bind_user_name = "Free";
}
}
}
}
catch (...)
{
;
}
}
return result;
}
MachineObject* DeviceManager::get_user_machine(std::string dev_id)
{
if (!m_agent || !m_agent->is_user_login())
{
return nullptr;
}
std::map<std::string, MachineObject*>::iterator it = userMachineList.find(dev_id);
if (it == userMachineList.end()) return nullptr;
return it->second;
}
MachineObject* DeviceManager::get_my_machine(std::string dev_id)
{
auto list = get_my_machine_list();
auto it = list.find(dev_id);
if (it != list.end())
{
return it->second;
}
return nullptr;
}
void DeviceManager::clean_user_info()
{
BOOST_LOG_TRIVIAL(trace) << "DeviceManager::clean_user_info";
// reset selected_machine
selected_machine = "";
local_selected_machine = "";
// clean user list
for (auto it = userMachineList.begin(); it != userMachineList.end(); it++)
{
if (it->second)
{
it->second->set_access_code("");
delete it->second;
it->second = nullptr;
}
}
userMachineList.clear();
}
bool DeviceManager::set_selected_machine(std::string dev_id)
{
BOOST_LOG_TRIVIAL(info) << "set_selected_machine=" << dev_id;
auto my_machine_list = get_my_machine_list();
auto it = my_machine_list.find(dev_id);
// disconnect last
auto last_selected = my_machine_list.find(selected_machine);
if (last_selected != my_machine_list.end())
{
if (last_selected->second->connection_type() == "lan")
{
m_agent->disconnect_printer();
}
}
// connect curr
if (it != my_machine_list.end())
{
if (selected_machine == dev_id)
{
if (it->second->connection_type() != "lan")
{
// only reset update time
it->second->reset_update_time();
// check subscribe state
Slic3r::GUI::wxGetApp().on_start_subscribe_again(dev_id);
return true;
}
else
{
// lan mode printer reconnect printer
if (m_agent)
{
m_agent->disconnect_printer();
it->second->reset();
#if !BBL_RELEASE_TO_PUBLIC
it->second->connect(Slic3r::GUI::wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false);
#else
it->second->connect(it->second->local_use_ssl_for_mqtt);
#endif
it->second->set_lan_mode_connection_state(true);
}
}
}
else
{
if (m_agent)
{
if (it->second->connection_type() != "lan" || it->second->connection_type().empty())
{
if (m_agent->get_user_selected_machine() == dev_id)
{
it->second->reset_update_time();
}
else
{
BOOST_LOG_TRIVIAL(info) << "static: set_selected_machine: same dev_id = " << dev_id;
m_agent->set_user_selected_machine(dev_id);
it->second->reset();
}
}
else
{
BOOST_LOG_TRIVIAL(info) << "static: set_selected_machine: same dev_id = empty";
it->second->reset();
#if !BBL_RELEASE_TO_PUBLIC
it->second->connect(Slic3r::GUI::wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false);
#else
it->second->connect(it->second->local_use_ssl_for_mqtt);
#endif
m_agent->set_user_selected_machine(dev_id);
it->second->set_lan_mode_connection_state(true);
}
}
}
for (auto& data : it->second->m_nozzle_filament_data)
{
data.second.checked_filament.clear();
}
}
selected_machine = dev_id;
return true;
}
MachineObject* DeviceManager::get_selected_machine()
{
if (selected_machine.empty()) return nullptr;
MachineObject* obj = get_user_machine(selected_machine);
if (obj)
return obj;
// return local machine has access code
auto it = localMachineList.find(selected_machine);
if (it != localMachineList.end())
{
if (it->second->has_access_right())
return it->second;
}
return nullptr;
}
void DeviceManager::add_user_subscribe()
{
/* user machine */
std::vector<std::string> dev_list;
for (auto it = userMachineList.begin(); it != userMachineList.end(); it++)
{
dev_list.push_back(it->first);
BOOST_LOG_TRIVIAL(trace) << "add_user_subscribe: " << it->first;
}
m_agent->add_subscribe(dev_list);
}
void DeviceManager::del_user_subscribe()
{
/* user machine */
std::vector<std::string> dev_list;
for (auto it = userMachineList.begin(); it != userMachineList.end(); it++)
{
dev_list.push_back(it->first);
BOOST_LOG_TRIVIAL(trace) << "del_user_subscribe: " << it->first;
}
m_agent->del_subscribe(dev_list);
}
void DeviceManager::subscribe_device_list(std::vector<std::string> dev_list)
{
std::vector<std::string> unsub_list;
subscribe_list_cache.clear();
for (auto& it : subscribe_list_cache)
{
if (it != selected_machine)
{
unsub_list.push_back(it);
BOOST_LOG_TRIVIAL(trace) << "subscribe_device_list: unsub dev id = " << it;
}
}
BOOST_LOG_TRIVIAL(trace) << "subscribe_device_list: unsub_list size = " << unsub_list.size();
if (!selected_machine.empty())
{
subscribe_list_cache.push_back(selected_machine);
}
for (auto& it : dev_list)
{
subscribe_list_cache.push_back(it);
BOOST_LOG_TRIVIAL(trace) << "subscribe_device_list: sub dev id = " << it;
}
BOOST_LOG_TRIVIAL(trace) << "subscribe_device_list: sub_list size = " << subscribe_list_cache.size();
if (!unsub_list.empty())
m_agent->del_subscribe(unsub_list);
if (!dev_list.empty())
m_agent->add_subscribe(subscribe_list_cache);
}
std::map<std::string, MachineObject*> DeviceManager::get_my_machine_list()
{
std::map<std::string, MachineObject*> result;
for (auto it = userMachineList.begin(); it != userMachineList.end(); it++)
{
if (it->second && !it->second->is_lan_mode_printer())
{
result.insert(std::make_pair(it->first, it->second));
}
}
for (auto it = localMachineList.begin(); it != localMachineList.end(); it++)
{
if (it->second && it->second->has_access_right() && it->second->is_avaliable() && it->second->is_lan_mode_printer())
{
// remove redundant in userMachineList
if (result.find(it->first) == result.end())
{
result.emplace(std::make_pair(it->first, it->second));
}
}
}
return result;
}
std::map<std::string, MachineObject*> DeviceManager::get_my_cloud_machine_list()
{
std::map<std::string, MachineObject*> result;
for (auto it = userMachineList.begin(); it != userMachineList.end(); it++)
{
if (it->second && !it->second->is_lan_mode_printer()) { result.emplace(*it); }
}
return result;
}
std::string DeviceManager::get_first_online_user_machine() const
{
for (auto it = userMachineList.begin(); it != userMachineList.end(); it++)
{
if (it->second && it->second->is_online())
{
return it->second->get_dev_id();
}
}
return "";
}
void DeviceManager::modify_device_name(std::string dev_id, std::string dev_name)
{
BOOST_LOG_TRIVIAL(trace) << "modify_device_name";
if (m_agent)
{
int result = m_agent->modify_printer_name(dev_id, dev_name);
if (result == 0)
{
update_user_machine_list_info();
}
}
}
void DeviceManager::parse_user_print_info(std::string body)
{
if (device_subseries.size() <= 0) {
device_subseries = DevPrinterConfigUtil::get_all_subseries();
if (device_subseries.size() <= 0) {
device_subseries.insert(std::pair<std::string, std::vector<std::string>>("", std::vector<std::string>()));
}
}
BOOST_LOG_TRIVIAL(trace) << "DeviceManager::parse_user_print_info";
std::lock_guard<std::mutex> lock(listMutex);
std::set<std::string> new_list;
try
{
json j = json::parse(body);
#if !BBL_RELEASE_TO_PUBLIC
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": " << j;
#endif
if (j.contains("devices") && !j["devices"].is_null())
{
for (auto& elem : j["devices"])
{
MachineObject* obj = nullptr;
std::string dev_id;
if (!elem["dev_id"].is_null())
{
dev_id = elem["dev_id"].get<std::string>();
new_list.insert(dev_id);
}
std::map<std::string, MachineObject*>::iterator iter = userMachineList.find(dev_id);
if (iter != userMachineList.end())
{
/* update field */
obj = iter->second;
obj->set_dev_id(dev_id);
}
else
{
obj = new MachineObject(this, m_agent, "", "", "");
if (m_agent)
{
obj->set_bind_status(m_agent->get_user_name());
}
if (obj->get_dev_ip().empty())
{
obj->get_dev_ip() = Slic3r::GUI::wxGetApp().app_config->get("ip_address", dev_id);
}
userMachineList.insert(std::make_pair(dev_id, obj));
}
if (!obj) continue;
if (!elem["dev_id"].is_null())
obj->set_dev_id(elem["dev_id"].get<std::string>());
if (!elem["dev_name"].is_null())
obj->set_dev_name(elem["dev_name"].get<std::string>());
if (!elem["dev_online"].is_null())
obj->m_is_online = elem["dev_online"].get<bool>();
if (elem.contains("dev_model_name") && !elem["dev_model_name"].is_null()) {
auto printer_type = elem["dev_model_name"].get<std::string>();
for (const std::pair<std::string, std::vector<std::string>> &pair : device_subseries) {
auto it = std::find(pair.second.begin(), pair.second.end(), printer_type);
if (it != pair.second.end())
{
obj->printer_type = Slic3r::_parse_printer_type(pair.first);
break;
}
else
{
obj->printer_type = Slic3r::_parse_printer_type(printer_type);
}
}
}
if (!elem["task_status"].is_null())
obj->iot_print_status = elem["task_status"].get<std::string>();
if (elem.contains("dev_product_name") && !elem["dev_product_name"].is_null())
obj->dev_product_name = elem["dev_product_name"].get<std::string>();
if (elem.contains("dev_access_code") && !elem["dev_access_code"].is_null())
{
std::string acc_code = elem["dev_access_code"].get<std::string>();
acc_code.erase(std::remove(acc_code.begin(), acc_code.end(), '\n'), acc_code.end());
obj->set_access_code(acc_code);
}
}
//remove MachineObject from userMachineList
std::map<std::string, MachineObject*>::iterator iterat;
for (iterat = userMachineList.begin(); iterat != userMachineList.end(); )
{
if (new_list.find(iterat->first) == new_list.end())
{
iterat = userMachineList.erase(iterat);
}
else
{
iterat++;
}
}
}
}
catch (std::exception& e)
{
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << " exception=" << e.what();
}
}
void DeviceManager::update_user_machine_list_info()
{
if (!m_agent) return;
BOOST_LOG_TRIVIAL(debug) << "update_user_machine_list_info";
unsigned int http_code;
std::string body;
int result = m_agent->get_user_print_info(&http_code, &body);
if (result == 0)
{
parse_user_print_info(body);
}
}
void DeviceManager::load_last_machine()
{
// Get all available machines, include cloud machines and lan machines that have access right
auto all_machines = get_my_machine_list();
if (all_machines.empty())
return;
// Then connect to the machine we last selected if available
const std::string last_monitor_machine = m_agent ? m_agent->get_user_selected_machine() : "";
const auto last_machine = all_machines.find(last_monitor_machine);
if (last_machine != all_machines.end()) {
this->set_selected_machine(last_machine->second->get_dev_id());
} else {
// If not, then select the first available one
this->set_selected_machine(all_machines.begin()->second->get_dev_id());
}
}
void DeviceManager::OnMachineBindStateChanged(MachineObject* obj, const std::string& new_state)
{
if (!obj) { return; }
if (obj->get_dev_id() == selected_machine)
{
if (new_state == "free") { OnSelectedMachineLost(); }
}
}
void DeviceManager::OnSelectedMachineLost()
{
GUI::wxGetApp().sidebar().update_sync_status(nullptr);
GUI::wxGetApp().sidebar().load_ams_list(string(), nullptr);
}
void DeviceManager::reload_printer_settings()
{
for (auto obj : this->userMachineList) { obj.second->reload_printer_settings(); };
}
DeviceManagerRefresher::DeviceManagerRefresher(DeviceManager* manger) : wxObject()
{
m_manager = manger;
m_timer = new wxTimer();
m_timer->Bind(wxEVT_TIMER, &DeviceManagerRefresher::on_timer, this);
}
DeviceManagerRefresher::~DeviceManagerRefresher()
{
m_timer->Stop();
delete m_timer;
}
void DeviceManagerRefresher::on_timer(wxTimerEvent& event)
{
if (!m_manager) { return; }
NetworkAgent* agent = m_manager->get_agent();
if (!agent) { return; }
// reset to active
Slic3r::GUI::wxGetApp().reset_to_active();
MachineObject* obj = m_manager->get_selected_machine();
if (!obj) { return; }
// check valid machine
if (obj && m_manager->get_my_machine(obj->get_dev_id()) == nullptr)
{
m_manager->set_selected_machine("");
agent->set_user_selected_machine("");
return;
}
// do some refresh
if (Slic3r::GUI::wxGetApp().is_user_login())
{
m_manager->check_pushing();
try
{
agent->refresh_connection();
}
catch (...)
{
;
}
}
// certificate
agent->install_device_cert(obj->get_dev_id(), obj->is_lan_mode_printer());
}
}
+125
View File
@@ -0,0 +1,125 @@
#pragma once
#include "libslic3r/CommonDefs.hpp"
#include "slic3r/Utils/json_diff.hpp"
#include <wx/string.h>
namespace Slic3r
{
//Previous definitions
struct BBLocalMachine;
class MachineObject;
class NetworkAgent;
class DeviceManagerRefresher;
class DeviceManager
{
friend class GUI_App;
friend class DeviceManagerRefresher;
private:
NetworkAgent* m_agent{ nullptr };
DeviceManagerRefresher* m_refresher{ nullptr };
bool m_enable_mutil_machine = false;
std::mutex listMutex;
std::string selected_machine; /* dev_id */
std::string local_selected_machine; /* dev_id */
std::map<std::string, MachineObject*> localMachineList; /* dev_id -> MachineObject*, localMachine SSDP */
std::map<std::string, MachineObject*> userMachineList; /* dev_id -> MachineObject* cloudMachine of User */
public:
DeviceManager(NetworkAgent* agent = nullptr);
~DeviceManager();
public:
NetworkAgent* get_agent() const { return m_agent; }
void set_agent(NetworkAgent* agent) { m_agent = agent; }
void start_refresher();
void stop_refresher();
MachineObject* get_selected_machine();
bool set_selected_machine(std::string dev_id);
// local machine
void set_local_selected_machine(std::string dev_id) { local_selected_machine = dev_id; };
MachineObject* get_local_selected_machine() const { return get_local_machine(local_selected_machine); }
// local machine list
void erase_local_machine(std::string dev_id) { localMachineList.erase(dev_id); }
std::map<std::string, MachineObject*> get_local_machinelist() const { return localMachineList; }
MachineObject* get_local_machine(std::string dev_id) const
{
auto it = localMachineList.find(dev_id);
return (it != localMachineList.end()) ? it->second : nullptr;
}
// user machine
std::map<std::string, MachineObject*> get_user_machinelist() const { return userMachineList; }
std::string get_first_online_user_machine() const;
void erase_user_machine(std::string dev_id) { userMachineList.erase(dev_id); }
void clean_user_info();
void load_last_machine();
void update_user_machine_list_info();
void parse_user_print_info(std::string body);
void reload_printer_settings();
MachineObject* get_user_machine(std::string dev_id);
// subscribe
void add_user_subscribe();
void del_user_subscribe();
void subscribe_device_list(std::vector<std::string> dev_list);
/* my machine*/
MachineObject* get_my_machine(std::string dev_id);
std::map<std::string, MachineObject*> get_my_machine_list();
std::map<std::string, MachineObject*> get_my_cloud_machine_list();
void modify_device_name(std::string dev_id, std::string dev_name);
/* create machine or update machine properties */
void on_machine_alive(std::string json_str);
int query_bind_status(std::string& msg);
// mutil-device
void EnableMultiMachine(bool enable = true);
bool IsMultiMachineEnabled() const { return m_enable_mutil_machine; }
std::vector<std::string> subscribe_list_cache;//multiple machine subscribe list cache
std::map<std::string, std::vector<std::string>> device_subseries;
private:
void keep_alive();
void check_pushing();
void OnMachineBindStateChanged(MachineObject* obj, const std::string& new_state);
void OnSelectedMachineLost();
/*TODO*/
public:
// to remove
MachineObject* insert_local_device(const BBLocalMachine& machine, std::string connection_type, std::string bind_state, std::string version, std::string access_code);
static void update_local_machine(const MachineObject& m);
};
class DeviceManagerRefresher : public wxObject
{
wxTimer* m_timer{ nullptr };
int m_timer_interval_msec = 1000;
DeviceManager* m_manager{ nullptr };
public:
DeviceManagerRefresher(DeviceManager* manger);
~DeviceManagerRefresher();
public:
void Start() { m_timer->Start(m_timer_interval_msec); }
void Stop() { m_timer->Stop(); }
protected:
virtual void on_timer(wxTimerEvent& event);
};
};
+364
View File
@@ -0,0 +1,364 @@
#include <nlohmann/json.hpp>
#include "DevMapping.h"
#include "DevFilaSystem.h"
#include "DevUtil.h"
// TODO: remove this include
#include "slic3r/GUI/DeviceManager.hpp"
#include "slic3r/GUI/I18N.hpp"
#include "slic3r/GUI/GuiColor.hpp"
using namespace nlohmann;
namespace Slic3r
{
bool DevMappingUtil::is_valid_mapping_result(const MachineObject* obj, std::vector<FilamentInfo>& result, bool check_empty_slot)
{
if (result.empty()) return false;
for (int i = 0; i < result.size(); i++)
{
// invalid mapping result
if (result[i].tray_id < 0)
{
if (result[i].ams_id.empty() && result[i].slot_id.empty())
{
return false;
}
}
else
{
auto ams_item = obj->GetFilaSystem()->GetAmsById(result[i].ams_id);
if (ams_item == nullptr)
{
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;
return false;
}
}
else
{
if (check_empty_slot)
{
auto tray_item = ams_item->GetTrays().find(result[i].slot_id);
if (tray_item == ams_item->GetTrays().end())
{
result[i].tray_id = -1;
return false;
}
else
{
if (!tray_item->second->is_exists)
{
result[i].tray_id = -1;
return false;
}
}
}
}
}
}
return true;
}
// calc distance map
struct DisValue {
int tray_id;
float distance;
bool is_same_color = true;
bool is_type_match = true;
};
static void _parse_tray_info(int ams_id, int slot_id, DevAmsTray tray, FilamentInfo& result)
{
result.color = tray.color;
result.type = tray.get_filament_type();
result.filament_id = tray.setting_id;
result.ctype = tray.ctype;
result.colors = tray.cols;
/*for new ams mapping*/
result.ams_id = std::to_string(ams_id);
result.slot_id = std::to_string(slot_id);
if (ams_id == VIRTUAL_TRAY_MAIN_ID || ams_id == VIRTUAL_TRAY_DEPUTY_ID)
{
result.tray_id = atoi(tray.id.c_str());
result.id = atoi(tray.id.c_str());
}
else
{
result.id = ams_id * 4 + slot_id;
}
}
int DevMappingUtil::ams_filament_mapping(const MachineObject* obj, const std::vector<FilamentInfo>& filaments, std::vector<FilamentInfo>& result, std::vector<bool> map_opt, std::vector<int> exclude_id, bool nozzle_has_ams_then_ignore_ext)
{
if (filaments.empty())
return -1;
/////////////////////////
// Step 1: collect filaments in machine
std::map<int, FilamentInfo> tray_filaments; // tray_index : tray_color
bool left_nozzle_has_ams = false, right_nozzle_has_ams = false;
const auto& ams_list = obj->GetFilaSystem()->GetAmsList();
for (auto ams = ams_list.begin(); ams != ams_list.end(); ams++)
{
std::string ams_id = ams->second->GetAmsId();
auto ams_type = ams->second->GetAmsType();
for (auto tray = ams->second->GetTrays().begin(); tray != ams->second->GetTrays().end(); tray++)
{
int ams_id = atoi(ams->first.c_str());
int tray_id = atoi(tray->first.c_str());
int tray_index = 0;
if (ams_type == DevAms::AMS || ams_type == DevAms::AMS_LITE || ams_type == DevAms::N3F)
{
tray_index = ams_id * 4 + tray_id;
}
else if (ams_type == DevAms::N3S)
{
tray_index = ams_id + tray_id;
}
else
{
assert(0);
}
// skip exclude id
for (int i = 0; i < exclude_id.size(); i++)
{
if (tray_index == exclude_id[i])
continue;
}
// push
FilamentInfo info;
if (tray->second->is_tray_info_ready())
{
_parse_tray_info(ams_id, tray_id, *(tray->second), info);
}
//first: left,nozzle=1,map=1 second: right,nozzle=0,map=2
bool right_ams_valid = ams->second->GetExtruderId() == 0 && map_opt[MappingOption::USE_RIGHT_AMS];
bool left_ams_valid = ams->second->GetExtruderId() == 1 && map_opt[MappingOption::USE_LEFT_AMS];
if (right_ams_valid || left_ams_valid)
{
tray_filaments.emplace(std::make_pair(tray_index, info));
if (right_ams_valid)
{
right_nozzle_has_ams = true;
}
if (left_ams_valid)
{
left_nozzle_has_ams = true;
}
}
}
}
if (map_opt[MappingOption::USE_RIGHT_EXT] || map_opt[MappingOption::USE_LEFT_EXT])
{
for (auto tray : obj->vt_slot)
{
bool right_ext_valid = (tray.id == std::to_string(VIRTUAL_TRAY_MAIN_ID) && map_opt[MappingOption::USE_RIGHT_EXT]);
bool left_ext_valid = (tray.id == std::to_string(VIRTUAL_TRAY_DEPUTY_ID) && map_opt[MappingOption::USE_LEFT_EXT]);
if (right_ext_valid || left_ext_valid)
{
if (nozzle_has_ams_then_ignore_ext)
{
if (right_ext_valid && right_nozzle_has_ams)
{
continue;
}
if (left_ext_valid && left_nozzle_has_ams)
{
continue;
}
}
FilamentInfo info;
_parse_tray_info(atoi(tray.id.c_str()), 0, tray, info);
tray_filaments.emplace(std::make_pair(info.tray_id, info));
}
}
}
/////////////////////////
// Step 2: collect the distances of filaments_in_slicing to filaments_in_machine
char buffer[256];
std::vector<std::vector<DisValue>> distance_map;
// print title
::sprintf(buffer, "F(id)");
std::string line = std::string(buffer);
for (auto tray = tray_filaments.begin(); tray != tray_filaments.end(); tray++)
{
::sprintf(buffer, " AMS%02d", tray->second.id + 1);
line += std::string(buffer);
}
BOOST_LOG_TRIVIAL(info) << "ams_mapping_distance:" << line;// Print the collected filaments
for (int i = 0; i < filaments.size(); i++)
{
std::vector<DisValue> rol;
::sprintf(buffer, "F(%02d)", filaments[i].id + 1);
line = std::string(buffer);
for (auto tray = tray_filaments.begin(); tray != tray_filaments.end(); tray++)
{
DisValue val;
val.tray_id = tray->second.id;
wxColour c = wxColour(filaments[i].color);
wxColour tray_c = DevAmsTray::decode_color(tray->second.color);
val.distance = GUI::calc_color_distance(c, tray_c);
if (filaments[i].type != tray->second.type)
{
val.distance = 999999;
val.is_type_match = false;
}
else
{
if (c.Alpha() != tray_c.Alpha())
val.distance = 999999;
val.is_type_match = true;
}
::sprintf(buffer, " %6.0f", val.distance);
line += std::string(buffer);
rol.push_back(val);
}
BOOST_LOG_TRIVIAL(info) << "ams_mapping_distance:" << line;
distance_map.push_back(rol);
}
/////////////////////////
// Step 3: do mapping algorithm
// setup the mapping result
for (int i = 0; i < filaments.size(); i++)
{
FilamentInfo info;
info.id = filaments[i].id;
info.tray_id = -1;
info.type = filaments[i].type;
info.filament_id = filaments[i].filament_id;
result.push_back(info);
}
// traverse the mapping
std::set<int> picked_src;
std::set<int> picked_tar;
for (int k = 0; k < distance_map.size(); k++)
{
float min_val = INT_MAX;
int picked_src_idx = -1;
int picked_tar_idx = -1;
for (int i = 0; i < distance_map.size(); i++)
{
if (picked_src.find(i) != picked_src.end())
continue;
// try to mapping to different tray
for (int j = 0; j < distance_map[i].size(); j++)
{
if (picked_tar.find(j) != picked_tar.end())
{
if (distance_map[i][j].is_same_color
&& distance_map[i][j].is_type_match
&& distance_map[i][j].distance < (float)0.0001)
{
min_val = distance_map[i][j].distance;
picked_src_idx = i;
picked_tar_idx = j;
tray_filaments[picked_tar_idx].distance = min_val;
}
continue;
}
if (distance_map[i][j].is_same_color
&& distance_map[i][j].is_type_match)
{
if (min_val > distance_map[i][j].distance)
{
min_val = distance_map[i][j].distance;
picked_src_idx = i;
picked_tar_idx = j;
tray_filaments[picked_tar_idx].distance = min_val;
}
else if (min_val == distance_map[i][j].distance && filaments[picked_src_idx].filament_id != tray_filaments[picked_tar_idx].filament_id && filaments[i].filament_id == tray_filaments[j].filament_id)
{
picked_src_idx = i;
picked_tar_idx = j;
}
}
}
// take a retry to mapping to used tray
if (picked_src_idx < 0 || picked_tar_idx < 0)
{
for (int j = 0; j < distance_map[i].size(); j++)
{
if (distance_map[i][j].is_same_color && distance_map[i][j].is_type_match)
{
if (min_val > distance_map[i][j].distance)
{
min_val = distance_map[i][j].distance;
picked_src_idx = i;
picked_tar_idx = j;
tray_filaments[picked_tar_idx].distance = min_val;
}
else if (min_val == distance_map[i][j].distance && filaments[picked_src_idx].filament_id != tray_filaments[picked_tar_idx].filament_id && filaments[i].filament_id == tray_filaments[j].filament_id)
{
picked_src_idx = i;
picked_tar_idx = j;
}
}
}
}
}
if (picked_src_idx >= 0 && picked_tar_idx >= 0)
{
auto tray = tray_filaments.find(distance_map[k][picked_tar_idx].tray_id);
if (tray != tray_filaments.end())
{
result[picked_src_idx].tray_id = tray->first;
result[picked_src_idx].color = tray->second.color;
result[picked_src_idx].type = tray->second.type;
result[picked_src_idx].distance = tray->second.distance;
result[picked_src_idx].filament_id = tray->second.filament_id;
result[picked_src_idx].ctype = tray->second.ctype;
result[picked_src_idx].colors = tray->second.colors;
/*for new ams mapping*/
result[picked_src_idx].ams_id = tray->second.ams_id;
result[picked_src_idx].slot_id = tray->second.slot_id;
}
::sprintf(buffer, "ams_mapping, picked F(%02d) AMS(%02d), distance=%6.0f", picked_src_idx + 1, picked_tar_idx + 1,
distance_map[picked_src_idx][picked_tar_idx].distance);
BOOST_LOG_TRIVIAL(info) << std::string(buffer);
picked_src.insert(picked_src_idx);
picked_tar.insert(picked_tar_idx);
}
}
//check ams mapping result
if (DevMappingUtil::is_valid_mapping_result(obj, result, true))
{
return 0;
}
/* for (auto it = result.begin(); it != result.end(); it++) {//This code has never been effective before 2025.03.18
if (it->distance >= 6000) {
it->tray_id = -1;
}
}*/
return 0;
}
}
+33
View File
@@ -0,0 +1,33 @@
#pragma once
#include "libslic3r/CommonDefs.hpp"
#include "libslic3r/ProjectTask.hpp"
#include "slic3r/Utils/json_diff.hpp"
#include <wx/string.h>
namespace Slic3r
{
//Previous definitions
class MachineObject;
enum MappingOption
{
USE_LEFT_AMS = 0,
USE_RIGHT_AMS,
USE_LEFT_EXT,
USE_RIGHT_EXT
};
class DevMappingUtil
{
public:
DevMappingUtil() = delete;
~DevMappingUtil() = delete;
public:
static bool is_valid_mapping_result(const MachineObject* obj, std::vector<FilamentInfo>& result, bool check_empty_slot = false);
static int ams_filament_mapping(const MachineObject* obj, const std::vector<FilamentInfo>& filaments, std::vector<FilamentInfo>& result, std::vector<bool> map_opt, std::vector<int> exclude_id = std::vector<int>(), bool nozzle_has_ams_then_ignore_ext = false);
};
};
@@ -0,0 +1,129 @@
#include "DevExtruderSystem.h"
#include "DevNozzleSystem.h"
#include "DevUtil.h"
#include "slic3r/GUI/DeviceManager.hpp"
namespace Slic3r
{
DevNozzle DevNozzleSystem::GetNozzle(int id) const
{
if (m_nozzles.find(id) != m_nozzles.end())
{
return m_nozzles.at(id);
}
return DevNozzle();
}
void DevNozzleSystem::Reset()
{
m_nozzles.clear();
m_extder_exist = 0;
m_state = 0; // idle state
}
static unordered_map<string, NozzleFlowType> _str2_nozzle_flow_type = {
{"S", NozzleFlowType::S_FLOW},
{"H", NozzleFlowType::H_FLOW},
{"A", NozzleFlowType::S_FLOW},
{"X", NozzleFlowType::S_FLOW}
};
static unordered_map<string, NozzleType> _str2_nozzle_type = {
{"00", NozzleType::ntStainlessSteel},
{"01", NozzleType::ntHardenedSteel},
{"05", NozzleType::ntTungstenCarbide}
};
static void s_parse_nozzle_type(const std::string& nozzle_type_str, DevNozzle& nozzle)
{
if (NozzleTypeStrToEumn.count(nozzle_type_str) != 0)
{
nozzle.m_nozzle_type = NozzleTypeStrToEumn[nozzle_type_str];
}
else if (nozzle_type_str.length() >= 4)
{
const std::string& flow_type_str = nozzle_type_str.substr(1, 1);
if (_str2_nozzle_flow_type.count(flow_type_str) != 0)
{
nozzle.m_nozzle_flow = _str2_nozzle_flow_type[flow_type_str];
}
const std::string& type_str = nozzle_type_str.substr(2, 2);
if (_str2_nozzle_type.count(type_str) != 0)
{
nozzle.m_nozzle_type = _str2_nozzle_type[type_str];
}
}
}
void DevNozzleSystemParser::ParseV1_0(const nlohmann::json& nozzletype_json,
const nlohmann::json& diameter_json,
DevNozzleSystem* system)
{
//Since both the old and new protocols push data.
// assert(system->m_nozzles.size() < 2);
DevNozzle nozzle;
nozzle.m_nozzle_id = 0;
nozzle.m_nozzle_flow = NozzleFlowType::S_FLOW; // default flow type
{
float nozzle_diameter = 0.0f;
if (diameter_json.is_number_float())
{
nozzle_diameter = diameter_json.get<float>();
}
else if (diameter_json.is_string())
{
nozzle_diameter = DevUtil::string_to_float(diameter_json.get<std::string>());
}
if (nozzle_diameter == 0.0f)
{
nozzle.m_diameter = 0.0f;
}
else
{
nozzle.m_diameter = round(nozzle_diameter * 10) / 10;
}
}
{
if (nozzletype_json.is_string())
{
s_parse_nozzle_type(nozzletype_json.get<std::string>(), nozzle);
}
}
system->m_nozzles.emplace(0, nozzle);
}
void DevNozzleSystemParser::ParseV2_0(const json& nozzle_json, DevNozzleSystem* system)
{
system->Reset();
if (nozzle_json.contains("exist"))
{
system->m_extder_exist = DevUtil::get_flag_bits(nozzle_json["exist"].get<int>(), 0, 16);
}
if (nozzle_json.contains("state"))
{
system->m_state = DevUtil::get_flag_bits(nozzle_json["state"].get<int>(), 0, 4);
}
for (auto it = nozzle_json["info"].begin(); it != nozzle_json["info"].end(); it++)
{
DevNozzle nozzle_obj;
const auto& njon = it.value();
nozzle_obj.m_nozzle_id = njon["id"].get<int>();
nozzle_obj.m_diameter = njon["diameter"].get<float>();
s_parse_nozzle_type(njon["type"].get<std::string>(), nozzle_obj);
system->m_nozzles[nozzle_obj.m_nozzle_id] = nozzle_obj;
}
}
}
@@ -0,0 +1,50 @@
#pragma once
#include "libslic3r/CommonDefs.hpp"
#include "slic3r/Utils/json_diff.hpp"
#include <wx/string.h>
#include <map>
namespace Slic3r
{
// Previous definitions
class MachineObject;
struct DevNozzle
{
int m_nozzle_id = -1;
NozzleFlowType m_nozzle_flow = NozzleFlowType::S_FLOW;// 0-common 1-high flow
NozzleType m_nozzle_type = NozzleType::ntUndefine;// 0-stainless_steel 1-hardened_steel 5-tungsten_carbide
float m_diameter = 0.4f;// 0.2mm 0.4mm 0.6mm 0.8mm
};
class DevNozzleSystem
{
friend class DevNozzleSystemParser;
public:
DevNozzleSystem(MachineObject* owner) : m_owner(owner) {}
public:
bool ContainsNozzle(int id) const { return m_nozzles.find(id) != m_nozzles.end(); }
DevNozzle GetNozzle(int id) const;
const std::map<int, DevNozzle>& GetNozzles() const { return m_nozzles;}
private:
void Reset();
private:
MachineObject* m_owner = nullptr;
int m_extder_exist = 0; //0- none exist 1-exist, unused
int m_state = 0; //0-idle 1-checking, unused
std::map<int, DevNozzle> m_nozzles;
};
class DevNozzleSystemParser
{
public:
static void ParseV1_0(const nlohmann::json& nozzletype_json, const nlohmann::json& diameter_json, DevNozzleSystem* system);
static void ParseV2_0(const json& nozzle_json, DevNozzleSystem* system);
};
};
@@ -0,0 +1,280 @@
#include "DevPrintOptions.h"
#include "DevUtil.h"
#include "slic3r/GUI/DeviceManager.hpp"
namespace Slic3r
{
void DevPrintOptionsParser::Parse(DevPrintOptions* opts, const nlohmann::json& print_json)
{
try
{
if (print_json.contains("spd_lvl"))
{
opts->m_speed_level = static_cast<DevPrintingSpeedLevel>(print_json["spd_lvl"].get<int>());
}
if (print_json.contains("cfg"))
{
const std::string& cfg = print_json["cfg"].get<std::string>();
opts->m_speed_level = (DevPrintingSpeedLevel)DevUtil::get_flag_bits(cfg, 8, 3);
}
}
catch (const std::exception& e)
{
BOOST_LOG_TRIVIAL(error) << "DevPrintOptionsParser::Parse: Failed to parse print options from JSON." << e.what();
}
}
void DevPrintOptionsParser::ParseDetectionV1_0(DevPrintOptions *opts, MachineObject *obj, const nlohmann::json &print_json)
{
try {
if (print_json.contains("xcam")) {
if (time(nullptr) - opts->xcam_ai_monitoring_hold_start > HOLD_TIME_3SEC) {
if (print_json["xcam"].contains("printing_monitor")) {
// new protocol
opts->xcam_ai_monitoring = print_json["xcam"]["printing_monitor"].get<bool>();
} else {
// old version protocol
if (print_json["xcam"].contains("spaghetti_detector")) {
opts->xcam_ai_monitoring = print_json["xcam"]["spaghetti_detector"].get<bool>();
if (print_json["xcam"].contains("print_halt")) {
bool print_halt = print_json["xcam"]["print_halt"].get<bool>();
if (print_halt) { opts->xcam_ai_monitoring_sensitivity = "medium"; }
}
}
}
if (print_json["xcam"].contains("halt_print_sensitivity")) {
opts->xcam_ai_monitoring_sensitivity = print_json["xcam"]["halt_print_sensitivity"].get<std::string>();
}
}
if (time(nullptr) - opts->xcam_first_layer_hold_start > HOLD_TIME_3SEC) {
if (print_json["xcam"].contains("first_layer_inspector")) { opts->xcam_first_layer_inspector = print_json["xcam"]["first_layer_inspector"].get<bool>(); }
}
if (time(nullptr) - opts->xcam_buildplate_marker_hold_start > HOLD_TIME_3SEC) {
if (print_json["xcam"].contains("buildplate_marker_detector")) {
opts->xcam_buildplate_marker_detector = print_json["xcam"]["buildplate_marker_detector"].get<bool>();
obj->is_support_build_plate_marker_detect = true;
} else {
obj->is_support_build_plate_marker_detect = false;
}
}
}
} catch (...) {
;
}
}
void DevPrintOptionsParser::ParseDetectionV1_1(DevPrintOptions *opts, MachineObject *obj, const nlohmann::json &print_json,bool enable)
{
if (print_json["module_name"].get<std::string>() == "first_layer_inspector") {
if (time(nullptr) - opts->xcam_first_layer_hold_start > HOLD_TIME_3SEC) {
opts->xcam_first_layer_inspector = enable;
}
} else if (print_json["module_name"].get<std::string>() == "buildplate_marker_detector") {
if (time(nullptr) - opts->xcam_buildplate_marker_hold_start > HOLD_TIME_3SEC) {
opts->xcam_buildplate_marker_detector = enable;
}
} else if (print_json["module_name"].get<std::string>() == "printing_monitor") {
if (time(nullptr) - opts->xcam_ai_monitoring_hold_start > HOLD_TIME_3SEC) {
opts->xcam_ai_monitoring = enable;
if (print_json.contains("halt_print_sensitivity")) {
opts->xcam_ai_monitoring_sensitivity = print_json["halt_print_sensitivity"].get<std::string>();
}
}
} else if (print_json["module_name"].get<std::string>() == "spaghetti_detector") {
if (time(nullptr) - opts->xcam_ai_monitoring_hold_start > HOLD_TIME_3SEC) {
// old protocol
opts->xcam_ai_monitoring = enable;
if (print_json.contains("print_halt")) {
if (print_json["print_halt"].get<bool>()) { opts->xcam_ai_monitoring_sensitivity = "medium"; }
}
}
}
}
void DevPrintOptionsParser::ParseDetectionV1_2(DevPrintOptions *opts, MachineObject *obj, const nlohmann::json &print_json) {
try {
if (print_json.contains("option")) {
if (print_json["option"].is_number()) {
int option = print_json["option"].get<int>();
if (time(nullptr) - opts->xcam_auto_recovery_hold_start > HOLD_TIME_3SEC) { opts->xcam_auto_recovery_step_loss = ((option & 0x01) != 0); }
}
}
if (time(nullptr) - opts->xcam_auto_recovery_hold_start > HOLD_TIME_3SEC) {
if (print_json.contains("auto_recovery")) { opts->xcam_auto_recovery_step_loss = print_json["auto_recovery"].get<bool>(); }
}
} catch (...) {}
}
void DevPrintOptionsParser::ParseDetectionV2_0(DevPrintOptions *opts, std::string print_json)
{
if (time(nullptr) - opts->xcam_first_layer_hold_start > HOLD_TIME_3SEC) {
opts->xcam_first_layer_inspector = DevUtil::get_flag_bits(print_json, 12);
}
if (time(nullptr) - opts->xcam_ai_monitoring_hold_start > HOLD_COUNT_MAX) {
opts->xcam_ai_monitoring = DevUtil::get_flag_bits(print_json, 15);
switch (DevUtil::get_flag_bits(print_json, 13, 2)) {
case 0: opts->xcam_ai_monitoring_sensitivity = "never_halt"; break;
case 1: opts->xcam_ai_monitoring_sensitivity = "low"; break;
case 2: opts->xcam_ai_monitoring_sensitivity = "medium"; break;
case 3: opts->xcam_ai_monitoring_sensitivity = "high"; break;
default: break;
}
}
if (time(nullptr) - opts->xcam_auto_recovery_hold_start > HOLD_COUNT_MAX){
opts->xcam_auto_recovery_step_loss =DevUtil::get_flag_bits(print_json, 16);
}
if (time(nullptr) - opts->xcam_prompt_sound_hold_start > HOLD_TIME_3SEC) {
opts->xcam_allow_prompt_sound = DevUtil::get_flag_bits(print_json, 22);
}
if (time(nullptr) - opts->xcam_filament_tangle_detect_hold_start > HOLD_TIME_3SEC) {
opts->xcam_filament_tangle_detect = DevUtil::get_flag_bits(print_json, 23);
}
}
void DevPrintOptions::SetPrintingSpeedLevel(DevPrintingSpeedLevel speed_level)
{
if (speed_level >= SPEED_LEVEL_INVALID && speed_level < SPEED_LEVEL_COUNT)
{
m_speed_level = speed_level;
}
else
{
m_speed_level = SPEED_LEVEL_INVALID; // Reset to invalid if out of range
}
}
int DevPrintOptions::command_xcam_control_ai_monitoring(bool on_off, std::string lvl)
{
bool print_halt = (lvl == "never_halt") ? false : true;
xcam_ai_monitoring = on_off;
xcam_ai_monitoring_hold_start = time(nullptr);
xcam_ai_monitoring_sensitivity = lvl;
return command_xcam_control("printing_monitor", on_off, m_obj, lvl);
}
int DevPrintOptions::command_xcam_control_buildplate_marker_detector(bool on_off)
{
xcam_buildplate_marker_detector = on_off;
xcam_buildplate_marker_hold_start = time(nullptr);
return command_xcam_control("buildplate_marker_detector", on_off ,m_obj);
}
int DevPrintOptions::command_xcam_control_first_layer_inspector(bool on_off, bool print_halt)
{
xcam_first_layer_inspector = on_off;
xcam_first_layer_hold_start = time(nullptr);
return command_xcam_control("first_layer_inspector", on_off, m_obj);
}
int DevPrintOptions::command_xcam_control_auto_recovery_step_loss(bool on_off)
{
xcam_auto_recovery_step_loss = on_off;
xcam_auto_recovery_hold_start = time(nullptr);
return command_set_printing_option(on_off, m_obj);
}
int DevPrintOptions::command_xcam_control_allow_prompt_sound(bool on_off)
{
xcam_allow_prompt_sound = on_off;
xcam_prompt_sound_hold_start = time(nullptr);
return command_set_prompt_sound(on_off, m_obj);
}
int DevPrintOptions::command_xcam_control_filament_tangle_detect(bool on_off)
{
xcam_filament_tangle_detect = on_off;
xcam_filament_tangle_detect_hold_start = time(nullptr);
return command_set_filament_tangle_detect(on_off, m_obj);
}
void DevPrintOptions::parse_auto_recovery_step_loss_status(int flag) {
if (time(nullptr) - xcam_auto_recovery_hold_start > HOLD_TIME_3SEC) {
xcam_auto_recovery_step_loss = ((flag >> 4) & 0x1) != 0;
}
}
void DevPrintOptions::parse_allow_prompt_sound_status(int flag)
{
if (time(nullptr) - xcam_prompt_sound_hold_start > HOLD_TIME_3SEC) {
xcam_allow_prompt_sound = ((flag >> 17) & 0x1) != 0;
}
}
void DevPrintOptions::parse_filament_tangle_detect_status(int flag)
{
if (time(nullptr) - xcam_filament_tangle_detect_hold_start > HOLD_TIME_3SEC) {
xcam_filament_tangle_detect = ((flag >> 20) & 0x1) != 0;
}
}
int DevPrintOptions::command_xcam_control(std::string module_name, bool on_off , MachineObject *obj, std::string lvl)
{
json j;
j["xcam"]["command"] = "xcam_control_set";
j["xcam"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["xcam"]["module_name"] = module_name;
j["xcam"]["control"] = on_off;
j["xcam"]["enable"] = on_off; // old protocol
j["xcam"]["print_halt"] = true; // old protocol
if (!lvl.empty()) { j["xcam"]["halt_print_sensitivity"] = lvl; }
BOOST_LOG_TRIVIAL(info) << "command:xcam_control_set" << ", module_name:" << module_name << ", control:" << on_off << ", halt_print_sensitivity:" << lvl;
return obj->publish_json(j);
}
int DevPrintOptions::command_set_printing_option(bool auto_recovery, MachineObject *obj)
{
json j;
j["print"]["command"] = "print_option";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["option"] = (int) auto_recovery;
j["print"]["auto_recovery"] = auto_recovery;
return obj->publish_json(j);
}
int DevPrintOptions::command_set_prompt_sound(bool prompt_sound, MachineObject *obj)
{
json j;
j["print"]["command"] = "print_option";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["sound_enable"] = prompt_sound;
return obj->publish_json(j);
}
int DevPrintOptions::command_set_filament_tangle_detect(bool filament_tangle_detect, MachineObject *obj)
{
json j;
j["print"]["command"] = "print_option";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
j["print"]["filament_tangle_detect"] = filament_tangle_detect;
return obj->publish_json(j);
}
}
// namespace Slic3r
@@ -0,0 +1,91 @@
#pragma once
#include <nlohmann/json.hpp>
#include "slic3r/Utils/json_diff.hpp"
#include <wx/string.h>
#include "DevDefs.h"
namespace Slic3r {
class MachineObject;
class DevPrintOptions
{
friend class DevPrintOptionsParser;
public:
DevPrintOptions(MachineObject* obj): m_obj(obj) {}
public:
void SetPrintingSpeedLevel(DevPrintingSpeedLevel speed_level);
DevPrintingSpeedLevel GetPrintingSpeedLevel() const { return m_speed_level;}
// detect options
int command_xcam_control_ai_monitoring(bool on_off, std::string lvl);
int command_xcam_control_first_layer_inspector(bool on_off, bool print_halt);
int command_xcam_control_buildplate_marker_detector(bool on_off);
int command_xcam_control_auto_recovery_step_loss(bool on_off);
int command_xcam_control_allow_prompt_sound(bool on_off);
int command_xcam_control_filament_tangle_detect(bool on_off);
int command_xcam_control(std::string module_name, bool on_off, MachineObject *obj ,std::string lvl = "");
// set print option
int command_set_printing_option(bool auto_recovery, MachineObject *obj);
// set prompt sound
int command_set_prompt_sound(bool prompt_sound, MachineObject *obj);
// set fliament tangle detect
int command_set_filament_tangle_detect(bool fliament_tangle_detect, MachineObject *obj);
void parse_auto_recovery_step_loss_status(int flag);
void parse_allow_prompt_sound_status(int flag);
void parse_filament_tangle_detect_status(int flag);
bool GetAiMonitoring() const { return xcam_ai_monitoring; };
bool GetFirstLayerInspector() const{ return xcam_first_layer_inspector; };
bool GetBuildplateMarkerDetector() const { return xcam_buildplate_marker_detector; };
bool GetAutoRecoveryStepLoss() const { return xcam_auto_recovery_step_loss; };
bool GetAllowPromptSound() const { return xcam_allow_prompt_sound; };
bool GetFilamentTangleDetect() const { return xcam_filament_tangle_detect; };
string GetAiMonitoringSensitivity() const { return xcam_ai_monitoring_sensitivity; };
private:
// print option
DevPrintingSpeedLevel m_speed_level = SPEED_LEVEL_INVALID;
// detect options
bool xcam_ai_monitoring{false};
std::string xcam_ai_monitoring_sensitivity;
bool xcam_buildplate_marker_detector{false};
bool xcam_first_layer_inspector{false};
bool xcam_auto_recovery_step_loss{false};
bool xcam_allow_prompt_sound{false};
bool xcam_filament_tangle_detect{false};
time_t xcam_ai_monitoring_hold_start = 0;
time_t xcam_buildplate_marker_hold_start = 0;
time_t xcam_first_layer_hold_start = 0;
time_t xcam_auto_recovery_hold_start = 0;
time_t xcam_prompt_sound_hold_start = 0;
time_t xcam_filament_tangle_detect_hold_start = 0;
MachineObject* m_obj;/*owner*/
};
class DevPrintOptionsParser
{
public:
static void Parse(DevPrintOptions* opts, const nlohmann::json& print_json);
//V1 stands for parse_json; V2 stands for parse_new_json
static void ParseDetectionV1_0(DevPrintOptions *opts, MachineObject *obj, const nlohmann::json &print_json);
static void ParseDetectionV1_1(DevPrintOptions *opts, MachineObject *obj, const nlohmann::json &print_json, bool enable);
static void ParseDetectionV1_2(DevPrintOptions *opts, MachineObject *obj, const nlohmann::json &print_json);
static void ParseDetectionV2_0(DevPrintOptions *opts, std::string print_json);
};
} // namespace Slic3r
@@ -0,0 +1 @@
#include "DevPrintTaskInfo.h"
@@ -0,0 +1,24 @@
#pragma once
// TODO classes to handle dev print task management and ratings
namespace Slic3r
{
struct DevPrintTaskRatingInfo
{
bool request_successful;
int http_code;
int rating_id;
int start_count;
bool success_printed;
std::string content;
std::vector<std::string> image_url_paths;
};
class DevPrintTaskInfo
{
};
}// end namespace Slic3r
+34
View File
@@ -0,0 +1,34 @@
#include "DevStorage.h"
#include "slic3r/GUI/DeviceManager.hpp"
namespace Slic3r {
DevStorage::SdcardState Slic3r::DevStorage::set_sdcard_state(int state)
{
if (state < DevStorage::NO_SDCARD || state > DevStorage::SDCARD_STATE_NUM) {
m_sdcard_state = DevStorage::NO_SDCARD;
} else {
m_sdcard_state = DevStorage::SdcardState(state);
}
return m_sdcard_state;
}
void DevStorage::ParseV1_0(const json &print_json, DevStorage *system)
{
if (system)
{
if (print_json.contains("sdcard")) {
if (print_json["sdcard"].get<bool>())
system->m_sdcard_state = DevStorage::SdcardState::HAS_SDCARD_NORMAL;
else
system->m_sdcard_state = DevStorage::SdcardState::NO_SDCARD;
} else {
system->m_sdcard_state = DevStorage::SdcardState::NO_SDCARD;
}
}
}
} // namespace Slic3r
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#include <nlohmann/json.hpp>
#include "slic3r/Utils/json_diff.hpp"
namespace Slic3r {
class MachineObject;
class DevStorage
{
public:
DevStorage(MachineObject *obj) : m_owner(obj){}
public:
enum SdcardState : int {
NO_SDCARD = 0,
HAS_SDCARD_NORMAL = 1,
HAS_SDCARD_ABNORMAL = 2,
HAS_SDCARD_READONLY = 3,
SDCARD_STATE_NUM = 4
};
/* sdcard */
SdcardState get_sdcard_state() const { return m_sdcard_state; };
SdcardState set_sdcard_state(int state);
static void ParseV1_0(const json &print_json, DevStorage *system);
private:
MachineObject *m_owner;
SdcardState m_sdcard_state { NO_SDCARD };
};
} // namespace Slic3r
+114
View File
@@ -0,0 +1,114 @@
#include "DevUtil.h"
#include "fast_float/fast_float.h"
namespace Slic3r
{
int DevUtil::get_flag_bits(std::string str, int start, int count)
{
try
{
unsigned long long decimal_value = std::stoull(str, nullptr, 16);
unsigned long long mask = (1ULL << count) - 1;
int flag = (decimal_value >> start) & mask;
return flag;
}
catch (const std::exception& e)
{
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": " << e.what();
}
catch (...)
{
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": failed";
}
return 0;
}
int DevUtil::get_flag_bits(int num, int start, int count, int base)
{
try
{
unsigned long long mask = (1ULL << count) - 1;
unsigned long long value;
if (base == 10)
{
value = static_cast<unsigned long long>(num);
}
else if (base == 16)
{
value = static_cast<unsigned long long>(std::stoul(std::to_string(num), nullptr, 16));
}
else
{
throw std::invalid_argument("Unsupported base");
}
int flag = (value >> start) & mask;
return flag;
}
catch (const std::exception& e)
{
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": " << e.what();
}
catch (...)
{
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": failed";
}
return 0;
}
float DevUtil::string_to_float(const std::string& str_value)
{
float value = 0.0f;
try
{
fast_float::from_chars(str_value.c_str(), str_value.c_str() + str_value.size(), value);
}
catch (const std::exception& e)
{
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": " << e.what();
}
catch (...)
{
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": failed";
}
return value;
}
std::string DevUtil::convertToIp(long long ip)
{
std::stringstream ss;
ss << ((ip >> 0) & 0xFF) << "." << ((ip >> 8) & 0xFF) << "." << ((ip >> 16) & 0xFF) << "." << ((ip >> 24) & 0xFF);
return ss.str();
}
std::string DevJsonValParser::get_longlong_val(const nlohmann::json& j)
{
try
{
if (j.is_number())
{
return std::to_string(j.get<long long>());
}
else if (j.is_string())
{
return j.get<std::string>();
}
}
catch (const nlohmann::json::exception& e)
{
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": " << e.what();
}
catch (const std::exception& e)
{
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": " << e.what();
}
return std::string();
}
};// namespace Slic3r
+71
View File
@@ -0,0 +1,71 @@
/**
* @file DevUtil.h
* @brief Provides common static utility methods for general use.
*
* This class offers a collection of static helper functions such as string manipulation,
* file operations, and other frequently used utilities.
*/
#pragma once
#include <string>
#include <sstream>
#include <stdexcept>
#include "nlohmann/json.hpp"
namespace Slic3r
{
class DevUtil
{
public:
DevUtil() = delete;
DevUtil(const DevUtil&) = delete;
DevUtil& operator=(const DevUtil&) = delete;
public:
static int get_flag_bits(std::string str, int start, int count = 1);
static int get_flag_bits(int num, int start, int count = 1, int base = 10);
static float string_to_float(const std::string& str_value);
static std::string convertToIp(long long ip);
};
class DevJsonValParser
{
public:
template<typename T>
static void ParseVal(const nlohmann::json& j, const std::string& key, T& val)
{
try
{
if (j.contains(key)) { val = j[key].get<T>(); }
}
catch (const nlohmann::json::exception& e)
{
assert(0 && __FUNCTION__);
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": " << e.what();
}
}
template<typename T>
static void ParseVal(const nlohmann::json& j, const std::string& key, T& val, T default_val)
{
try
{
j.contains(key) ? (val = j[key].get<T>()) : (val = default_val);
}
catch (const nlohmann::json::exception& e)
{
assert(0 && __FUNCTION__);
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": " << e.what();
}
}
public:
static std::string get_longlong_val(const nlohmann::json& j);
};
}; // namespace Slic3r
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,6 +1,6 @@
//**********************************************************/ //**********************************************************/
/* File: uiAmsHumidityPopup.cpp /* File: uiAmsHumidityPopup.cpp
* Description: The popup with Ams Humidity * Description: The popup with DevAms Humidity
* *
* \n class uiAmsHumidityPopup * \n class uiAmsHumidityPopup
//**********************************************************/ //**********************************************************/
@@ -1,6 +1,6 @@
//**********************************************************/ //**********************************************************/
/* File: uiAmsHumidityPopup.h /* File: uiAmsHumidityPopup.h
* Description: The popup with Ams Humidity * Description: The popup with DevAms Humidity
* *
* \n class uiAmsHumidityPopup * \n class uiAmsHumidityPopup
//**********************************************************/ //**********************************************************/
@@ -28,7 +28,7 @@ struct uiAmsHumidityInfo
}; };
/// </summary> /// </summary>
/// Note: The popup of Ams Humidity with percentage and dry time /// Note: The popup of DevAms Humidity with percentage and dry time
/// Author: xin.zhang /// Author: xin.zhang
/// </summary> /// </summary>
class uiAmsPercentHumidityDryPopup : public wxDialog class uiAmsPercentHumidityDryPopup : public wxDialog
@@ -28,7 +28,7 @@ uiDeviceUpdateVersion::uiDeviceUpdateVersion(wxWindow* parent,
CreateWidgets(); CreateWidgets();
} }
void uiDeviceUpdateVersion::UpdateInfo(const MachineObject::ModuleVersionInfo& info) void uiDeviceUpdateVersion::UpdateInfo(const DevFirmwareVersionInfo& info)
{ {
SetName(I18N::translate(info.product_name)); SetName(I18N::translate(info.product_name));
SetSerial(info.sn); SetSerial(info.sn);
@@ -29,7 +29,7 @@ public:
~uiDeviceUpdateVersion() = default; ~uiDeviceUpdateVersion() = default;
public: public:
void UpdateInfo(const MachineObject::ModuleVersionInfo& info); void UpdateInfo(const DevFirmwareVersionInfo& info);
private: private:
void CreateWidgets(); void CreateWidgets();
+30 -26
View File
@@ -77,6 +77,8 @@
#include "EncodedFilament.hpp" #include "EncodedFilament.hpp"
#include "GeneratedConfig.hpp" #include "GeneratedConfig.hpp"
#include "DeviceCore/DevManager.h"
#include "../Utils/PresetUpdater.hpp" #include "../Utils/PresetUpdater.hpp"
#include "../Utils/PrintHost.hpp" #include "../Utils/PrintHost.hpp"
#include "../Utils/Process.hpp" #include "../Utils/Process.hpp"
@@ -1030,8 +1032,6 @@ void GUI_App::post_init()
mainframe->refresh_plugin_tips(); mainframe->refresh_plugin_tips();
}); });
DeviceManager::load_filaments_blacklist_config();
// remove old log files over LOG_FILES_MAX_NUM // remove old log files over LOG_FILES_MAX_NUM
std::string log_addr = data_dir(); std::string log_addr = data_dir();
if (!log_addr.empty()) { if (!log_addr.empty()) {
@@ -1725,8 +1725,8 @@ void GUI_App::init_networking_callbacks()
obj->erase_user_access_code(); obj->erase_user_access_code();
obj->command_get_access_code(); obj->command_get_access_code();
if (m_agent) if (m_agent)
m_agent->install_device_cert(obj->dev_id, obj->is_lan_mode_printer()); m_agent->install_device_cert(obj->get_dev_id(), obj->is_lan_mode_printer());
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj); GUI::wxGetApp().sidebar().load_ams_list(obj->get_dev_id(), obj);
} }
}); });
}); });
@@ -1764,8 +1764,8 @@ void GUI_App::init_networking_callbacks()
obj->command_request_push_all(true); obj->command_request_push_all(true);
obj->command_get_version(); obj->command_get_version();
event.SetInt(0); event.SetInt(0);
event.SetString(obj->dev_id); event.SetString(obj->get_dev_id());
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj); GUI::wxGetApp().sidebar().load_ams_list(obj->get_dev_id(), obj);
} else if (state == ConnectStatus::ConnectStatusFailed) { } else if (state == ConnectStatus::ConnectStatusFailed) {
// Orca: avoid showing same error message multiple times until next connection attempt. // Orca: avoid showing same error message multiple times until next connection attempt.
const auto already_disconnected = m_device_manager->selected_machine.empty(); const auto already_disconnected = m_device_manager->selected_machine.empty();
@@ -1778,7 +1778,7 @@ void GUI_App::init_networking_callbacks()
text = wxString::Format(_L("Incorrect password")); text = wxString::Format(_L("Incorrect password"));
wxGetApp().show_dialog(text); wxGetApp().show_dialog(text);
} else { } else {
text = wxString::Format(_L("Connect %s failed! [SN:%s, code=%s]"), from_u8(obj->dev_name), obj->dev_id, msg); text = wxString::Format(_L("Connect %s failed! [SN:%s, code=%s]"), from_u8(obj->get_dev_name()), obj->get_dev_id(), msg);
wxGetApp().show_dialog(text); wxGetApp().show_dialog(text);
} }
} }
@@ -1797,15 +1797,15 @@ void GUI_App::init_networking_callbacks()
else { else {
if (state == ConnectStatus::ConnectStatusOk) { if (state == ConnectStatus::ConnectStatusOk) {
event.SetInt(1); event.SetInt(1);
event.SetString(obj->dev_id); event.SetString(obj->get_dev_id());
} }
else if(msg == "5") { else if(msg == "5") {
event.SetInt(5); event.SetInt(5);
event.SetString(obj->dev_id); event.SetString(obj->get_dev_id());
} }
else { else {
event.SetInt(-2); event.SetInt(-2);
event.SetString(obj->dev_id); event.SetString(obj->get_dev_id());
} }
} }
} }
@@ -1829,7 +1829,8 @@ void GUI_App::init_networking_callbacks()
if (obj) { if (obj) {
auto sel = this->m_device_manager->get_selected_machine(); auto sel = this->m_device_manager->get_selected_machine();
if (sel && sel->dev_id == dev_id) { if (sel && sel->get_dev_id() == dev_id)
{
obj->parse_json("cloud", msg); obj->parse_json("cloud", msg);
} }
else { else {
@@ -1837,9 +1838,8 @@ void GUI_App::init_networking_callbacks()
} }
if ((sel == obj || sel == nullptr) && obj->is_ams_need_update) { if (sel == obj || sel == nullptr) {
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj); GUI::wxGetApp().sidebar().load_ams_list(obj->get_dev_id(), obj);
obj->is_ams_need_update = false;
} }
} }
@@ -1881,9 +1881,9 @@ void GUI_App::init_networking_callbacks()
MachineObject* obj = m_device_manager->get_my_machine(dev_id); MachineObject* obj = m_device_manager->get_my_machine(dev_id);
if (obj) { if (obj) {
obj->parse_json("lan", msg, DeviceManager::key_field_only); obj->parse_json("lan", msg);
if (this->m_device_manager->get_selected_machine() == obj && obj->is_ams_need_update) { if (this->m_device_manager->get_selected_machine() == obj) {
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj); GUI::wxGetApp().sidebar().load_ams_list(obj->get_dev_id(), obj);
} }
} }
@@ -1936,11 +1936,16 @@ bool GUI_App::is_blocking_printing(MachineObject *obj_)
target_model = obj_->printer_type; target_model = obj_->printer_type;
} }
if (!obj_)
{
return false;
}
PresetBundle *preset_bundle = wxGetApp().preset_bundle; PresetBundle *preset_bundle = wxGetApp().preset_bundle;
std::string source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); std::string source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
if (source_model != target_model) { if (source_model != target_model) {
std::vector<std::string> compatible_machine = dev->get_compatible_machine(target_model); std::vector<std::string> compatible_machine = obj_->get_compatible_machine();
vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model); vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model);
if (it == compatible_machine.end()) { if (it == compatible_machine.end()) {
return true; return true;
@@ -2195,10 +2200,10 @@ void GUI_App::on_start_subscribe_again(std::string dev_id)
MachineObject* obj = dev->get_selected_machine(); MachineObject* obj = dev->get_selected_machine();
if (!obj) return; if (!obj) return;
if ( (dev_id == obj->dev_id) && obj->is_connecting() && obj->subscribe_counter > 0) { if ( (dev_id == obj->get_dev_id()) && obj->is_connecting() && obj->subscribe_counter > 0) {
obj->subscribe_counter--; obj->subscribe_counter--;
if(wxGetApp().getAgent()) wxGetApp().getAgent()->set_user_selected_machine(dev_id); if(wxGetApp().getAgent()) wxGetApp().getAgent()->set_user_selected_machine(dev_id);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": dev_id=" << obj->dev_id; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": dev_id=" << obj->get_dev_id();
} }
}); });
start_subscribe_timer->Start(5000, wxTIMER_ONE_SHOT); start_subscribe_timer->Start(5000, wxTIMER_ONE_SHOT);
@@ -3006,11 +3011,10 @@ __retry:
m_task_manager = new Slic3r::TaskManager(m_agent); m_task_manager = new Slic3r::TaskManager(m_agent);
m_task_manager->start(); m_task_manager->start();
} }
m_agent->enable_multi_machine(true);
DeviceManager::EnableMultiMachine = true; m_device_manager->EnableMultiMachine(true);
} else { } else {
m_agent->enable_multi_machine(false); m_device_manager->EnableMultiMachine(false);
DeviceManager::EnableMultiMachine = false;
} }
//BBS set config dir //BBS set config dir
@@ -5906,10 +5910,10 @@ bool GUI_App::show_modal_ip_address_enter_dialog(bool input_sn, wxString title)
BOOST_LOG_TRIVIAL(info) << "User enter IP address is " << ip_address; BOOST_LOG_TRIVIAL(info) << "User enter IP address is " << ip_address;
if (!ip_address.empty()) { if (!ip_address.empty()) {
wxGetApp().app_config->set_str("ip_address", obj->dev_id, ip_address.ToStdString()); wxGetApp().app_config->set_str("ip_address", obj->get_dev_id(), ip_address.ToStdString());
wxGetApp().app_config->save(); wxGetApp().app_config->save();
obj->dev_ip = ip_address.ToStdString(); obj->set_dev_ip(ip_address.ToStdString());
obj->set_user_access_code(access_code.ToStdString()); obj->set_user_access_code(access_code.ToStdString());
} }
} }
+10 -7
View File
@@ -1,5 +1,8 @@
#include "HMS.hpp" #include "HMS.hpp"
#include "DeviceManager.hpp" #include "DeviceManager.hpp"
#include "DeviceCore/DevManager.h"
#include "DeviceCore/DevUtil.h"
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
@@ -34,7 +37,7 @@ int get_hms_info_version(std::string& version)
try { try {
json j = json::parse(body); json j = json::parse(body);
if (j.contains("ver")) { if (j.contains("ver")) {
version = JsonValParser::get_longlong_val(j["ver"]); version = DevJsonValParser::get_longlong_val(j["ver"]);
} }
} catch (...) { } catch (...) {
; ;
@@ -89,7 +92,7 @@ int HMSQuery::download_hms_related(const std::string& hms_type, const std::strin
return; return;
} }
const std::string& remote_ver = JsonValParser::get_longlong_val(j["ver"]); const std::string& remote_ver = DevJsonValParser::get_longlong_val(j["ver"]);
if (remote_ver <= local_version) if (remote_ver <= local_version)
{ {
return; return;
@@ -202,10 +205,10 @@ int HMSQuery::load_from_local(const std::string& hms_type, const std::string& de
} }
if (j.contains("version")) { if (j.contains("version")) {
load_version = JsonValParser::get_longlong_val(j["version"]); load_version = DevJsonValParser::get_longlong_val(j["version"]);
} }
else if (j.contains("ver")) { else if (j.contains("ver")) {
load_version = JsonValParser::get_longlong_val(j["ver"]); load_version = DevJsonValParser::get_longlong_val(j["ver"]);
} }
else else
{ {
@@ -307,7 +310,7 @@ string HMSQuery::get_dev_id_type(const MachineObject* obj) const
{ {
if (obj) if (obj)
{ {
return obj->dev_id.substr(0, 3); return obj->get_dev_id().substr(0, 3);
} }
return string(); return string();
@@ -640,11 +643,11 @@ std::string get_hms_wiki_url(std::string error_code)
MachineObject* obj = dev->get_selected_machine(); MachineObject* obj = dev->get_selected_machine();
if (!obj) return url; if (!obj) return url;
if (!obj->dev_id.empty()) { if (!obj->get_dev_id().empty()) {
url = (boost::format("https://%1%/index.php?e=%2%&d=%3%&s=device_hms&lang=%4%") url = (boost::format("https://%1%/index.php?e=%2%&d=%3%&s=device_hms&lang=%4%")
% hms_host % hms_host
% error_code % error_code
% obj->dev_id % obj->get_dev_id()
% lang_code).str(); % lang_code).str();
} }
return url; return url;
+6 -8
View File
@@ -16,7 +16,7 @@ namespace GUI {
wxDEFINE_EVENT(EVT_ALREADY_READ_HMS, wxCommandEvent); wxDEFINE_EVENT(EVT_ALREADY_READ_HMS, wxCommandEvent);
HMSNotifyItem::HMSNotifyItem(const std::string& dev_id, wxWindow *parent, HMSItem& item) HMSNotifyItem::HMSNotifyItem(const std::string& dev_id, wxWindow *parent, DevHMSItem& item)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL) : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
, m_hms_item(item) , m_hms_item(item)
, dev_id(dev_id) , dev_id(dev_id)
@@ -140,7 +140,7 @@ void HMSNotifyItem::init_bitmaps() {
wxBitmap & HMSNotifyItem::get_notify_bitmap() wxBitmap & HMSNotifyItem::get_notify_bitmap()
{ {
switch (m_hms_item.msg_level) { switch (m_hms_item.get_level()) {
case (HMS_FATAL): case (HMS_FATAL):
return m_img_notify_lv1; return m_img_notify_lv1;
break; break;
@@ -153,8 +153,6 @@ wxBitmap & HMSNotifyItem::get_notify_bitmap()
case (HMS_INFO): case (HMS_INFO):
//return m_img_notify_lv4; //return m_img_notify_lv4;
break; break;
case (HMS_UNKNOWN):
case (HMS_MSG_LEVEL_MAX):
default: break; default: break;
} }
return wxNullBitmap; return wxNullBitmap;
@@ -187,7 +185,7 @@ HMSPanel::~HMSPanel() {
; ;
} }
void HMSPanel::append_hms_panel(const std::string& dev_id, HMSItem& item) { void HMSPanel::append_hms_panel(const std::string& dev_id, DevHMSItem& item) {
wxString msg = wxGetApp().get_hms_query()->query_hms_msg(dev_id, item.get_long_error_code()); wxString msg = wxGetApp().get_hms_query()->query_hms_msg(dev_id, item.get_long_error_code());
if (!msg.empty()) { if (!msg.empty()) {
HMSNotifyItem *notify_item = new HMSNotifyItem(dev_id, m_scrolledWindow, item); HMSNotifyItem *notify_item = new HMSNotifyItem(dev_id, m_scrolledWindow, item);
@@ -214,7 +212,7 @@ void HMSPanel::update(MachineObject *obj)
this->Freeze(); this->Freeze();
delete_hms_panels(); delete_hms_panels();
wxString hms_text; wxString hms_text;
for (auto item : obj->hms_list) { for (auto item : obj->GetHMS()->GetHMSItems()) {
if (wxGetApp().get_hms_query()) { if (wxGetApp().get_hms_query()) {
auto key = item.get_long_error_code(); auto key = item.get_long_error_code();
@@ -223,14 +221,14 @@ void HMSPanel::update(MachineObject *obj)
temp_hms_list[key] = item; temp_hms_list[key] = item;
} }
append_hms_panel(obj->dev_id, item); append_hms_panel(obj->get_dev_id(), item);
} }
} }
for (auto it = temp_hms_list.begin(); it != temp_hms_list.end(); ) { for (auto it = temp_hms_list.begin(); it != temp_hms_list.end(); ) {
auto key = it->second.get_long_error_code(); auto key = it->second.get_long_error_code();
bool inr = false; bool inr = false;
for (auto hms : obj->hms_list) { for (auto hms : obj->GetHMS()->GetHMSItems()) {
if (hms.get_long_error_code() == key) { if (hms.get_long_error_code() == key) {
inr = true; inr = true;
break; break;
+6 -4
View File
@@ -9,12 +9,14 @@
#include <slic3r/GUI/StatusPanel.hpp> #include <slic3r/GUI/StatusPanel.hpp>
#include <wx/html/htmlwin.h> #include <wx/html/htmlwin.h>
#include "DeviceCore/DevHMS.h"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
class HMSNotifyItem : public wxPanel class HMSNotifyItem : public wxPanel
{ {
HMSItem & m_hms_item; DevHMSItem & m_hms_item;
std::string m_url; std::string m_url;
std::string dev_id; std::string dev_id;
std::string long_error_code; std::string long_error_code;
@@ -35,7 +37,7 @@ class HMSNotifyItem : public wxPanel
wxBitmap & get_notify_bitmap(); wxBitmap & get_notify_bitmap();
public: public:
HMSNotifyItem(const std::string& dev_id, wxWindow *parent, HMSItem& item); HMSNotifyItem(const std::string& dev_id, wxWindow *parent, DevHMSItem& item);
~HMSNotifyItem(); ~HMSNotifyItem();
void msw_rescale() {} void msw_rescale() {}
@@ -50,7 +52,7 @@ protected:
int last_status; int last_status;
void append_hms_panel(const std::string& dev_id, HMSItem &item); void append_hms_panel(const std::string& dev_id, DevHMSItem &item);
void delete_hms_panels(); void delete_hms_panels();
@@ -69,7 +71,7 @@ public:
void clear_hms_tag(); void clear_hms_tag();
MachineObject *obj { nullptr }; MachineObject *obj { nullptr };
std::map<std::string, HMSItem> temp_hms_list; std::map<std::string, DevHMSItem> temp_hms_list;
}; };
wxDECLARE_EVENT(EVT_ALREADY_READ_HMS, wxCommandEvent); wxDECLARE_EVENT(EVT_ALREADY_READ_HMS, wxCommandEvent);
+2
View File
@@ -4,6 +4,8 @@
#include "slic3r/GUI/GUI.hpp" #include "slic3r/GUI/GUI.hpp"
#include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/DeviceCore/DevManager.h"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
+4 -1
View File
@@ -9,6 +9,9 @@
#include "slic3r/GUI/format.hpp" #include "slic3r/GUI/format.hpp"
#include "bambu_networking.hpp" #include "bambu_networking.hpp"
#include "slic3r/GUI/DeviceCore/DevManager.h"
#include "slic3r/GUI/DeviceCore/DevUtil.h"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@@ -459,7 +462,7 @@ void PrintJob::process(Ctl &ctl)
try { try {
std::ignore = job_info_j.parse(job_info); std::ignore = job_info_j.parse(job_info);
if (job_info_j.contains("job_id")) { if (job_info_j.contains("job_id")) {
curr_job_id = JsonValParser::get_longlong_val(job_info_j["job_id"]); curr_job_id = DevJsonValParser::get_longlong_val(job_info_j["job_id"]);
} }
BOOST_LOG_TRIVIAL(trace) << "print_job: curr_obj_id=" << curr_job_id; BOOST_LOG_TRIVIAL(trace) << "print_job: curr_obj_id=" << curr_job_id;
+2
View File
@@ -64,6 +64,8 @@
#include "DailyTips.hpp" #include "DailyTips.hpp"
#include "FilamentMapDialog.hpp" #include "FilamentMapDialog.hpp"
#include "DeviceCore/DevManager.h"
#ifdef _WIN32 #ifdef _WIN32
#include <dbt.h> #include <dbt.h>
#include <shlobj.h> #include <shlobj.h>
+5 -4
View File
@@ -11,6 +11,7 @@
#include "Widgets/ProgressDialog.hpp" #include "Widgets/ProgressDialog.hpp"
#include <libslic3r/Model.hpp> #include <libslic3r/Model.hpp>
#include <libslic3r/Format/bbs_3mf.hpp> #include <libslic3r/Format/bbs_3mf.hpp>
#include "DeviceCore/DevStorage.h"
#ifdef __WXMSW__ #ifdef __WXMSW__
#include <shellapi.h> #include <shellapi.h>
@@ -216,10 +217,10 @@ MediaFilePanel::~MediaFilePanel()
void MediaFilePanel::UpdateByObj(MachineObject* obj) void MediaFilePanel::UpdateByObj(MachineObject* obj)
{ {
bool sdcard_state_changed = false; bool sdcard_state_changed = false;
std::string machine = obj ? obj->dev_id : ""; std::string machine = obj ? obj->get_dev_id() : "";
if (obj) { if (obj) {
m_lan_mode = obj->is_lan_mode_printer(); m_lan_mode = obj->is_lan_mode_printer();
m_lan_ip = obj->dev_ip; m_lan_ip = obj->get_dev_ip();
m_lan_passwd = obj->get_access_code(); m_lan_passwd = obj->get_access_code();
m_dev_ver = obj->get_ota_version(); m_dev_ver = obj->get_ota_version();
m_device_busy = obj->is_camera_busy_off(); m_device_busy = obj->is_camera_busy_off();
@@ -227,8 +228,8 @@ void MediaFilePanel::UpdateByObj(MachineObject* obj)
m_remote_proto = obj->get_file_remote(); m_remote_proto = obj->get_file_remote();
m_model_download_support = obj->file_model_download; m_model_download_support = obj->file_model_download;
if (m_sdcard_exist != (obj->sdcard_state == MachineObject::SdcardState::HAS_SDCARD_NORMAL)) { if (m_sdcard_exist != (obj->GetStorage()->get_sdcard_state() == DevStorage::HAS_SDCARD_NORMAL)) {
m_sdcard_exist = obj->sdcard_state == MachineObject::SdcardState::HAS_SDCARD_NORMAL; m_sdcard_exist = obj->GetStorage()->get_sdcard_state() == DevStorage::HAS_SDCARD_NORMAL;
sdcard_state_changed = true; sdcard_state_changed = true;
} }
} else { } else {
+3 -3
View File
@@ -144,19 +144,19 @@ MediaPlayCtrl::~MediaPlayCtrl()
void MediaPlayCtrl::SetMachineObject(MachineObject* obj) void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
{ {
std::string machine = obj ? obj->dev_id : ""; std::string machine = obj ? obj->get_dev_id() : "";
if (obj) { if (obj) {
m_camera_exists = obj->has_ipcam; m_camera_exists = obj->has_ipcam;
m_dev_ver = obj->get_ota_version(); m_dev_ver = obj->get_ota_version();
m_lan_mode = obj->is_lan_mode_printer(); m_lan_mode = obj->is_lan_mode_printer();
m_lan_proto = obj->liveview_local; m_lan_proto = obj->liveview_local;
m_remote_proto = obj->get_liveview_remote(); m_remote_proto = obj->get_liveview_remote();
m_lan_ip = obj->dev_ip; m_lan_ip = obj->get_dev_ip();
m_lan_passwd = obj->get_access_code(); m_lan_passwd = obj->get_access_code();
m_device_busy = obj->is_camera_busy_off(); m_device_busy = obj->is_camera_busy_off();
m_tutk_state = obj->tutk_state; m_tutk_state = obj->tutk_state;
if (DeviceManager::get_printer_series(obj->printer_type) == "series_o" && NetworkAgent::use_legacy_network) { if (DevPrinterConfigUtil::get_printer_series_str(obj->printer_type) == "series_o" && NetworkAgent::use_legacy_network) {
// Legacy plugin cannot support remote play for H2D, force using local mode // Legacy plugin cannot support remote play for H2D, force using local mode
m_remote_proto = MachineObject::LVR_None; m_remote_proto = MachineObject::LVR_None;
} }
+12 -10
View File
@@ -29,6 +29,8 @@
#include "Plater.hpp" #include "Plater.hpp"
#include "BindDialog.hpp" #include "BindDialog.hpp"
#include "DeviceCore/DevManager.h"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@@ -126,7 +128,7 @@ MonitorPanel::MonitorPanel(wxWindow* parent, wxWindowID id, const wxPoint& pos,
auto key = e.GetString().ToStdString(); auto key = e.GetString().ToStdString();
auto iter = m_hms_panel->temp_hms_list.find(key); auto iter = m_hms_panel->temp_hms_list.find(key);
if (iter != m_hms_panel->temp_hms_list.end()) { if (iter != m_hms_panel->temp_hms_list.end()) {
m_hms_panel->temp_hms_list[key].already_read = true; m_hms_panel->temp_hms_list[key].set_read();
} }
update_hms_tag(); update_hms_tag();
@@ -164,7 +166,7 @@ void MonitorPanel::init_timer()
if (!dev) return; if (!dev) return;
MachineObject *obj_ = dev->get_selected_machine(); MachineObject *obj_ = dev->get_selected_machine();
if (obj_) if (obj_)
GUI::wxGetApp().sidebar().load_ams_list(obj_->dev_id, obj_); GUI::wxGetApp().sidebar().load_ams_list(obj_->get_dev_id(), obj_);
} }
void MonitorPanel::init_tabpanel() void MonitorPanel::init_tabpanel()
@@ -277,7 +279,7 @@ void MonitorPanel::on_select_printer(wxCommandEvent& event)
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return; if (!dev) return;
if ( dev->get_selected_machine() && (dev->get_selected_machine()->dev_id != event.GetString().ToStdString()) && m_hms_panel) { if ( dev->get_selected_machine() && (dev->get_selected_machine()->get_dev_id() != event.GetString().ToStdString()) && m_hms_panel) {
m_hms_panel->clear_hms_tag(); m_hms_panel->clear_hms_tag();
} }
@@ -293,7 +295,7 @@ void MonitorPanel::on_select_printer(wxCommandEvent& event)
obj_->reset_pa_cali_history_result(); obj_->reset_pa_cali_history_result();
obj_->reset_pa_cali_result(); obj_->reset_pa_cali_result();
Sidebar &sidebar = GUI::wxGetApp().sidebar(); Sidebar &sidebar = GUI::wxGetApp().sidebar();
sidebar.load_ams_list(obj_->dev_id, obj_); sidebar.load_ams_list(obj_->get_dev_id(), obj_);
sidebar.update_sync_status(obj_); sidebar.update_sync_status(obj_);
sidebar.set_need_auto_sync_after_connect_printer(sidebar.need_auto_sync_extruder_list_after_connect_priner(obj_)); sidebar.set_need_auto_sync_after_connect_printer(sidebar.need_auto_sync_extruder_list_after_connect_priner(obj_));
} }
@@ -379,7 +381,7 @@ void MonitorPanel::update_all()
m_media_file_panel->UpdateByObj(obj); m_media_file_panel->UpdateByObj(obj);
} }
if (current_page == m_hms_panel || (obj->hms_list.size() != m_hms_panel->temp_hms_list.size())) { if (current_page == m_hms_panel || (obj->GetHMS()->GetHMSItems().size() != m_hms_panel->temp_hms_list.size())) {
m_hms_panel->update(obj); m_hms_panel->update(obj);
} }
@@ -392,10 +394,10 @@ void MonitorPanel::update_hms_tag()
if (!obj) { break;} if (!obj) { break;}
const wxString &msg = wxGetApp().get_hms_query()->query_hms_msg(obj->dev_id, hmsitem.second.get_long_error_code()); const wxString &msg = wxGetApp().get_hms_query()->query_hms_msg(obj->get_dev_id(), hmsitem.second.get_long_error_code());
if (msg.empty()){ continue;} /*STUDIO-10363 it's hidden message*/ if (msg.empty()){ continue;} /*STUDIO-10363 it's hidden message*/
if (!hmsitem.second.already_read) { if (!hmsitem.second.has_read()) {
//show HMS new tag //show HMS new tag
m_tabpanel->GetBtnsListCtrl()->showNewTag(3, true); m_tabpanel->GetBtnsListCtrl()->showNewTag(3, true);
return; return;
@@ -428,10 +430,10 @@ bool MonitorPanel::Show(bool show)
dev->load_last_machine(); dev->load_last_machine();
obj = dev->get_selected_machine(); obj = dev->get_selected_machine();
if (obj && obj->is_info_ready(false)) if (obj && obj->is_info_ready(false))
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj); GUI::wxGetApp().sidebar().load_ams_list(obj->get_dev_id(), obj);
} else { } else {
obj->reset_update_time(); obj->reset_update_time();
//select_machine(obj->dev_id); //select_machine(obj->get_dev_id());
} }
} }
} else { } else {
@@ -448,7 +450,7 @@ void MonitorPanel::show_status(int status)
if ((last_status & (int)MonitorStatus::MONITOR_CONNECTING) != 0) { if ((last_status & (int)MonitorStatus::MONITOR_CONNECTING) != 0) {
NetworkAgent* agent = wxGetApp().getAgent(); NetworkAgent* agent = wxGetApp().getAgent();
json j; json j;
j["dev_id"] = obj ? obj->dev_id : "obj_nullptr"; j["dev_id"] = obj ? obj->get_dev_id() : "obj_nullptr";
if ((status & (int)MonitorStatus::MONITOR_DISCONNECTED) != 0) { if ((status & (int)MonitorStatus::MONITOR_DISCONNECTED) != 0) {
j["result"] = "failed"; j["result"] = "failed";
} }
+4 -4
View File
@@ -32,7 +32,7 @@ void DeviceItem::sync_state()
{ {
if (obj_) { if (obj_) {
state_online = obj_->is_online(); state_online = obj_->is_online();
state_dev_name = obj_->dev_name; state_dev_name = obj_->get_dev_name();
//printable //printable
if (obj_->print_status == "IDLE") { if (obj_->print_status == "IDLE") {
@@ -115,7 +115,7 @@ bool DeviceItem::is_blocking_printing(MachineObject* obj_)
source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); source_model = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
if (source_model != target_model) { if (source_model != target_model) {
std::vector<std::string> compatible_machine = dev->get_compatible_machine(target_model); std::vector<std::string> compatible_machine = obj_->get_compatible_machine();
vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model); vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model);
if (it == compatible_machine.end()) { if (it == compatible_machine.end()) {
return true; return true;
@@ -202,8 +202,8 @@ std::vector<DeviceItem*> selected_machines(const std::vector<DeviceItem*>& dev_i
std::vector<DeviceItem*> res; std::vector<DeviceItem*> res;
for (const auto& item : dev_item_list) { for (const auto& item : dev_item_list) {
const MachineObject* dev = item->get_obj(); const MachineObject* dev = item->get_obj();
const std::string& dev_name = dev->dev_name; const std::string& dev_name = dev->get_dev_name();
const std::string& dev_ip = dev->dev_ip; const std::string& dev_ip = dev->get_dev_ip();
auto name_it = dev_name.find(search_text); auto name_it = dev_name.find(search_text);
auto ip_it = dev_ip.find(search_text); auto ip_it = dev_ip.find(search_text);
+7 -5
View File
@@ -2,6 +2,8 @@
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "MainFrame.hpp" #include "MainFrame.hpp"
#include "DeviceCore/DevManager.h"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@@ -18,7 +20,7 @@ MultiMachineItem::MultiMachineItem(wxWindow* parent, MachineObject* obj)
Bind(wxEVT_LEFT_DOWN, &MultiMachineItem::OnLeftDown, this); Bind(wxEVT_LEFT_DOWN, &MultiMachineItem::OnLeftDown, this);
Bind(wxEVT_MOTION, &MultiMachineItem::OnMove, this); Bind(wxEVT_MOTION, &MultiMachineItem::OnMove, this);
Bind(EVT_MULTI_DEVICE_VIEW, [this, obj](auto& e) { Bind(EVT_MULTI_DEVICE_VIEW, [this, obj](auto& e) {
wxGetApp().mainframe->jump_to_monitor(obj->dev_id); wxGetApp().mainframe->jump_to_monitor(obj->get_dev_id());
if (wxGetApp().mainframe->m_monitor->get_status_panel()->get_media_play_ctrl()) { if (wxGetApp().mainframe->m_monitor->get_status_panel()->get_media_play_ctrl()) {
wxGetApp().mainframe->m_monitor->get_status_panel()->get_media_play_ctrl()->jump_to_play(); wxGetApp().mainframe->m_monitor->get_status_panel()->get_media_play_ctrl()->jump_to_play();
} }
@@ -152,7 +154,7 @@ void MultiMachineItem::doRender(wxDC& dc)
if (obj_) { if (obj_) {
//dev name //dev name
wxString dev_name = wxString::FromUTF8(obj_->dev_name); wxString dev_name = wxString::FromUTF8(obj_->get_dev_name());
if (!obj_->is_online()) { if (!obj_->is_online()) {
dev_name = dev_name + "(" + _L("Offline") + ")"; dev_name = dev_name + "(" + _L("Offline") + ")";
} }
@@ -235,7 +237,7 @@ void MultiMachineItem::doRender(wxDC& dc)
void MultiMachineItem::post_event(wxCommandEvent&& event) void MultiMachineItem::post_event(wxCommandEvent&& event)
{ {
event.SetEventObject(this); event.SetEventObject(this);
event.SetString(obj_->dev_id); event.SetString(obj_->get_dev_id());
event.SetInt(state_selected); event.SetInt(state_selected);
wxPostEvent(this, event); wxPostEvent(this, event);
} }
@@ -620,8 +622,8 @@ void MultiMachineManagerPage::sync_state(MachineObject* obj_)
ObjState state_obj; ObjState state_obj;
if (obj_) { if (obj_) {
state_obj.dev_id = obj_->dev_id; state_obj.dev_id = obj_->get_dev_id();
state_obj.state_dev_name = obj_->dev_name; state_obj.state_dev_name = obj_->get_dev_name();
if (obj_->print_status == "IDLE") { if (obj_->print_status == "IDLE") {
state_obj.state_device = 0; state_obj.state_device = 0;
+7 -5
View File
@@ -2,6 +2,8 @@
#include "GUI_App.hpp" #include "GUI_App.hpp"
#include "MainFrame.hpp" #include "MainFrame.hpp"
#include "DeviceCore/DevManager.h"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@@ -279,13 +281,13 @@ void DevicePickItem::doRender(wxDC& dc)
left += FromDIP(PICK_LEFT_PRINTABLE); left += FromDIP(PICK_LEFT_PRINTABLE);
//dev names //dev names
DrawTextWithEllipsis(dc, wxString::FromUTF8(get_obj()->dev_name), FromDIP(PICK_LEFT_DEV_NAME), left); DrawTextWithEllipsis(dc, wxString::FromUTF8(get_obj()->get_dev_name()), FromDIP(PICK_LEFT_DEV_NAME), left);
left += FromDIP(PICK_LEFT_DEV_NAME); left += FromDIP(PICK_LEFT_DEV_NAME);
} }
void DevicePickItem::post_event(wxCommandEvent&& event) void DevicePickItem::post_event(wxCommandEvent&& event)
{ {
event.SetEventObject(this); event.SetEventObject(this);
event.SetString(obj_->dev_id); event.SetString(obj_->get_dev_id());
event.SetInt(state_selected); event.SetInt(state_selected);
wxPostEvent(this, event); wxPostEvent(this, event);
} }
@@ -363,7 +365,7 @@ void MultiMachinePickPage::update_selected_count()
int count = 0; int count = 0;
for (auto it = m_device_items.begin(); it != m_device_items.end(); it++) { for (auto it = m_device_items.begin(); it != m_device_items.end(); it++) {
if (it->second->state_selected == 1 ) { if (it->second->state_selected == 1 ) {
selected_multi_devices.push_back(it->second->obj_->dev_id); selected_multi_devices.push_back(it->second->obj_->get_dev_id());
count++; count++;
} }
} }
@@ -423,7 +425,7 @@ void MultiMachinePickPage::refresh_user_device()
std::vector<std::string> subscribe_list; std::vector<std::string> subscribe_list;
for (auto it = user_machine.begin(); it != user_machine.end(); ++it) { for (auto it = user_machine.begin(); it != user_machine.end(); ++it) {
if (it->second->m_extder_data.total_extder_count > 1) { continue; } if (it->second->GetExtderSystem()->GetTotalExtderCount() > 1) { continue; }
if (it->second->printer_type == "O1D") { continue;} /*maybe total_extder_count is not valid, hard codes here. to be moved to printers json*/ if (it->second->printer_type == "O1D") { continue;} /*maybe total_extder_count is not valid, hard codes here. to be moved to printers json*/
DevicePickItem* di = new DevicePickItem(scroll_macine_list, it->second); DevicePickItem* di = new DevicePickItem(scroll_macine_list, it->second);
@@ -451,7 +453,7 @@ void MultiMachinePickPage::refresh_user_device()
} }
//update selected //update selected
auto dev_it = std::find(selected_multi_devices.begin(), selected_multi_devices.end(), it->second->dev_id ); auto dev_it = std::find(selected_multi_devices.begin(), selected_multi_devices.end(), it->second->get_dev_id() );
if (dev_it != selected_multi_devices.end()) { if (dev_it != selected_multi_devices.end()) {
di->state_selected = 1; di->state_selected = 1;
} }
+1 -1
View File
@@ -22,7 +22,7 @@ void MultiSendMachineModel::Init()
wxDataViewItem MultiSendMachineModel::AddMachine(MachineObject* obj) wxDataViewItem MultiSendMachineModel::AddMachine(MachineObject* obj)
{ {
wxString name = from_u8(obj->dev_name); wxString name = from_u8(obj->get_dev_name());
wxDataViewItem new_item; wxDataViewItem new_item;
+5 -3
View File
@@ -7,6 +7,8 @@
#include <wx/listimpl.cpp> #include <wx/listimpl.cpp>
#include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/posix_time.hpp>
#include "DeviceCore/DevManager.h"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@@ -176,7 +178,7 @@ void MultiTaskItem::update_info()
void MultiTaskItem::onPause() void MultiTaskItem::onPause()
{ {
if (get_obj() && !get_obj()->can_resume()) { if (get_obj() && !get_obj()->can_resume()) {
BOOST_LOG_TRIVIAL(info) << "MultiTask: pause current print task dev_id =" << get_obj()->dev_id; BOOST_LOG_TRIVIAL(info) << "MultiTask: pause current print task dev_id =" << get_obj()->get_dev_id();
get_obj()->command_task_pause(); get_obj()->command_task_pause();
m_button_pause->Hide(); m_button_pause->Hide();
m_button_resume->Show(); m_button_resume->Show();
@@ -187,7 +189,7 @@ void MultiTaskItem::onPause()
void MultiTaskItem::onResume() void MultiTaskItem::onResume()
{ {
if (get_obj() && get_obj()->can_resume()) { if (get_obj() && get_obj()->can_resume()) {
BOOST_LOG_TRIVIAL(info) << "MultiTask: resume current print task dev_id =" << get_obj()->dev_id; BOOST_LOG_TRIVIAL(info) << "MultiTask: resume current print task dev_id =" << get_obj()->get_dev_id();
get_obj()->command_task_resume(); get_obj()->command_task_resume();
m_button_pause->Show(); m_button_pause->Show();
m_button_resume->Hide(); m_button_resume->Hide();
@@ -198,7 +200,7 @@ void MultiTaskItem::onResume()
void MultiTaskItem::onStop() void MultiTaskItem::onStop()
{ {
if (get_obj()) { if (get_obj()) {
BOOST_LOG_TRIVIAL(info) << "MultiTask: abort current print task dev_id =" << get_obj()->dev_id; BOOST_LOG_TRIVIAL(info) << "MultiTask: abort current print task dev_id =" << get_obj()->get_dev_id();
get_obj()->command_task_abort(); get_obj()->command_task_abort();
m_button_pause->Hide(); m_button_pause->Hide();
m_button_resume->Hide(); m_button_resume->Hide();
+65 -56
View File
@@ -160,6 +160,9 @@
#include "FilamentMapDialog.hpp" #include "FilamentMapDialog.hpp"
#include "CloneDialog.hpp" #include "CloneDialog.hpp"
#include "DeviceCore/DevFilaSystem.h"
#include "DeviceCore/DevManager.h"
using boost::optional; using boost::optional;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
using Slic3r::_3DScene; using Slic3r::_3DScene;
@@ -394,7 +397,7 @@ struct ExtruderGroup : StaticGroup
void update_ams(); void update_ams();
void sync_ams(MachineObject const *obj, std::vector<Ams *> const &ams4, std::vector<Ams *> const &ams1); void sync_ams(MachineObject const *obj, std::vector<DevAms *> const &ams4, std::vector<DevAms *> const &ams1);
void Rescale() void Rescale()
{ {
@@ -1142,16 +1145,16 @@ void ExtruderGroup::update_ams()
sizer->Layout(); sizer->Layout();
} }
void ExtruderGroup::sync_ams(MachineObject const *obj, std::vector<Ams *> const &ams4, std::vector<Ams *> const &ams1) void ExtruderGroup::sync_ams(MachineObject const *obj, std::vector<DevAms *> const &ams4, std::vector<DevAms *> const &ams1)
{ {
if (ams_4.empty() && ams4.empty() if (ams_4.empty() && ams4.empty()
&& ams_1.empty() && ams1.empty()) && ams_1.empty() && ams1.empty())
return; return;
auto sync = [obj](std::vector<AMSinfo> &infos, std::vector<Ams *> const &ams) -> bool { auto sync = [obj](std::vector<AMSinfo> &infos, std::vector<DevAms *> const &ams) -> bool {
std::vector<AMSinfo> infos2; std::vector<AMSinfo> infos2;
for (auto a : ams) { for (auto a : ams) {
AMSinfo ams_info; AMSinfo ams_info;
ams_info.parse_ams_info(const_cast<MachineObject*>(obj), a, obj->ams_calibrate_remain_flag, obj->is_support_ams_humidity); ams_info.parse_ams_info(const_cast<MachineObject*>(obj), a, obj->GetFilaSystem()->IsDetectRemainEnabled(), obj->is_support_ams_humidity);
infos2.push_back(ams_info); infos2.push_back(ams_info);
} }
if (infos == infos2) if (infos == infos2)
@@ -1210,7 +1213,7 @@ bool Sidebar::priv::sync_extruder_list(bool &only_external_material)
plater->pop_warning_and_go_to_device_page(printer_name, Plater::PrinterWarningType::NOT_CONNECTED, _L("Sync printer information")); plater->pop_warning_and_go_to_device_page(printer_name, Plater::PrinterWarningType::NOT_CONNECTED, _L("Sync printer information"));
return false; return false;
} }
//if (obj->m_extder_data.extders.size() != 2) {//wxString(obj->get_preset_printer_model_name(machine_print_name)) //if (obj->get_extder_system()->extders.size() != 2) {//wxString(obj->get_preset_printer_model_name(machine_print_name))
// plater->pop_warning_and_go_to_device_page(printer_name, Plater::PrinterWarningType::INCONSISTENT, _L("Sync printer information")); // plater->pop_warning_and_go_to_device_page(printer_name, Plater::PrinterWarningType::INCONSISTENT, _L("Sync printer information"));
// return false; // return false;
//} //}
@@ -1253,17 +1256,17 @@ bool Sidebar::priv::sync_extruder_list(bool &only_external_material)
assert(physical_extruder_map->values.size() == extruder_nums); assert(physical_extruder_map->values.size() == extruder_nums);
extruder_map = physical_extruder_map->values; extruder_map = physical_extruder_map->values;
} }
assert(obj->m_extder_data.extders.size() == extruder_nums); assert(obj->GetExtderSystem()->GetTotalExtderCount() == extruder_nums);
std::vector<float> nozzle_diameters; std::vector<float> nozzle_diameters;
nozzle_diameters.resize(extruder_nums); nozzle_diameters.resize(extruder_nums);
for (size_t index = 0; index < extruder_nums; ++index) { for (size_t index = 0; index < extruder_nums; ++index) {
int extruder_id = extruder_map[index]; int extruder_id = extruder_map[index];
nozzle_diameters[extruder_id] = obj->m_extder_data.extders[index].current_nozzle_diameter; nozzle_diameters[extruder_id] = obj->GetExtderSystem()->GetNozzleDiameter(index);
NozzleVolumeType target_type = NozzleVolumeType::nvtStandard; NozzleVolumeType target_type = NozzleVolumeType::nvtStandard;
auto printer_tab = dynamic_cast<TabPrinter *>(wxGetApp().get_tab(Preset::TYPE_PRINTER)); auto printer_tab = dynamic_cast<TabPrinter *>(wxGetApp().get_tab(Preset::TYPE_PRINTER));
if (obj->is_nozzle_flow_type_supported()) { if (obj->is_nozzle_flow_type_supported()) {
if (obj->m_extder_data.extders[index].current_nozzle_flow_type == NozzleFlowType::NONE_FLOWTYPE) { if (obj->GetExtderSystem()->GetNozzleFlowType(index) == NozzleFlowType::NONE_FLOWTYPE) {
MessageDialog dlg(this->plater, _L("There are unset nozzle types. Please set the nozzle types of all extruders before synchronizing."), MessageDialog dlg(this->plater, _L("There are unset nozzle types. Please set the nozzle types of all extruders before synchronizing."),
_L("Sync extruder infomation"), wxICON_WARNING | wxOK); _L("Sync extruder infomation"), wxICON_WARNING | wxOK);
dlg.ShowModal(); dlg.ShowModal();
@@ -1271,30 +1274,27 @@ bool Sidebar::priv::sync_extruder_list(bool &only_external_material)
} }
// hack code, only use standard flow for 0.2 // hack code, only use standard flow for 0.2
if (std::fabs(nozzle_diameters[extruder_id] - 0.2) > EPSILON) if (std::fabs(nozzle_diameters[extruder_id] - 0.2) > EPSILON)
target_type = NozzleVolumeType(obj->m_extder_data.extders[extruder_id].current_nozzle_flow_type - 1); target_type = NozzleVolumeType(obj->GetExtderSystem()->GetNozzleFlowType(extruder_id) - 1);
} }
printer_tab->set_extruder_volume_type(index, target_type); printer_tab->set_extruder_volume_type(index, target_type);
} }
int deputy_4 = 0, main_4 = 0, deputy_1 = 0, main_1 = 0; int deputy_4 = 0, main_4 = 0, deputy_1 = 0, main_1 = 0;
for (auto ams : obj->amsList) { for (auto ams : obj->GetFilaSystem()->GetAmsList()) {
// Main (first) extruder at right // Main (first) extruder at right
if (ams.second->nozzle == 0) { if (ams.second->GetExtruderId() == 0) {
if (ams.second->type == 4) // N3S if (ams.second->GetAmsType() == DevAms::N3S) // N3S
++main_1; ++main_1;
else else
++main_4; ++main_4;
} else if (ams.second->nozzle == 1) { } else if (ams.second->GetExtruderId() == 1) {
if (ams.second->type == 4) // N3S if (ams.second->GetAmsType() == DevAms::N3S) // N3S
++deputy_1; ++deputy_1;
else else
++deputy_4; ++deputy_4;
} }
} }
only_external_material = false; only_external_material = !obj->GetFilaSystem()->HasAms();
if (obj->amsList.size() == 0) {
only_external_material = true;
}
int main_index = obj->is_main_extruder_on_left() ? 0 : 1; int main_index = obj->is_main_extruder_on_left() ? 0 : 1;
int deputy_index = obj->is_main_extruder_on_left() ? 1 : 0; int deputy_index = obj->is_main_extruder_on_left() ? 1 : 0;
@@ -1372,8 +1372,8 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj)
//int nozzle_volue_type{0}; //int nozzle_volue_type{0};
int ams_4{0}; int ams_4{0};
int ams_1{0}; int ams_1{0};
std::vector<Ams *> ams_v4; std::vector<DevAms *> ams_v4;
std::vector<Ams *> ams_v1; std::vector<DevAms *> ams_v1;
bool operator==(const ExtruderInfo &other) const bool operator==(const ExtruderInfo &other) const
{ {
@@ -1393,7 +1393,7 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj)
// 2. update extruder status // 2. update extruder status
int extruder_nums = preset_bundle->get_printer_extruder_count(); int extruder_nums = preset_bundle->get_printer_extruder_count();
if (extruder_nums != obj->m_extder_data.extders.size()) if (extruder_nums != obj->GetExtderSystem()->GetTotalExtderCount())
return; return;
std::vector<ExtruderInfo> extruder_infos(extruder_nums); std::vector<ExtruderInfo> extruder_infos(extruder_nums);
@@ -1429,21 +1429,24 @@ void Sidebar::priv::update_sync_status(const MachineObject *obj)
extruder_infos[1].diameter = float(value); extruder_infos[1].diameter = float(value);
} }
std::vector<ExtruderInfo> machine_extruder_infos(obj->m_extder_data.extders.size()); std::vector<ExtruderInfo> machine_extruder_infos(obj->GetExtderSystem()->GetTotalExtderCount());
for (const Extder &extruder : obj->m_extder_data.extders) {
//machine_extruder_infos[extruder.id].nozzle_volue_type = int(extruder.current_nozzle_flow_type) - 1; const auto& extruders = obj->GetExtderSystem()->GetExtruders();
machine_extruder_infos[extruder.id].diameter = extruder.current_nozzle_diameter; for (const DevExtder &extruder : extruders) {
//machine_extruder_infos[extruder.GetExtId()].nozzle_volue_type = int(extruder.GetNozzleFlowType()) - 1;
machine_extruder_infos[extruder.GetExtId()].diameter = extruder.GetNozzleDiameter();
} }
for (auto &item : obj->amsList) { for (auto &item : obj->GetFilaSystem()->GetAmsList()) {
if (item.second->nozzle >= machine_extruder_infos.size()) if (item.second->GetExtruderId() >= machine_extruder_infos.size())
continue; continue;
if (item.second->type == 4) { // N3S if (item.second->GetAmsType() == DevAms::N3S)
machine_extruder_infos[item.second->nozzle].ams_1++; { // N3S
machine_extruder_infos[item.second->nozzle].ams_v1.push_back(item.second); machine_extruder_infos[item.second->GetExtruderId()].ams_1++;
machine_extruder_infos[item.second->GetExtruderId()].ams_v1.push_back(item.second);
} else { } else {
machine_extruder_infos[item.second->nozzle].ams_4++; machine_extruder_infos[item.second->GetExtruderId()].ams_4++;
machine_extruder_infos[item.second->nozzle].ams_v4.push_back(item.second); machine_extruder_infos[item.second->GetExtruderId()].ams_v4.push_back(item.second);
} }
} }
@@ -2909,7 +2912,7 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
std::map<int, DynamicPrintConfig> filament_ams_list; std::map<int, DynamicPrintConfig> filament_ams_list;
if (!obj) return filament_ams_list; if (!obj) return filament_ams_list;
auto build_tray_config = [](AmsTray const &tray, std::string const &name, std::string ams_id, std::string slot_id) { auto build_tray_config = [](DevAmsTray const &tray, std::string const &name, std::string ams_id, std::string slot_id) {
BOOST_LOG_TRIVIAL(info) << boost::format("build_filament_ams_list: name %1% setting_id %2% type %3% color %4%") BOOST_LOG_TRIVIAL(info) << boost::format("build_filament_ams_list: name %1% setting_id %2% type %3% color %4%")
% name % tray.setting_id % tray.type % tray.color; % name % tray.setting_id % tray.type % tray.color;
DynamicPrintConfig tray_config; DynamicPrintConfig tray_config;
@@ -2954,11 +2957,11 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
return std::string(); return std::string();
}; };
auto list = obj->amsList; auto list = obj->GetFilaSystem()->GetAmsList();
for (auto ams : list) { for (auto ams : list) {
int ams_id = std::stoi(ams.first); int ams_id = std::stoi(ams.first);
int extruder = ams.second->nozzle ? 0 : 0x10000; // Main (first) extruder at right int extruder = ams.second->GetExtruderId() ? 0 : 0x10000; // Main (first) extruder at right
for (auto tray : ams.second->trayList) { for (auto tray : ams.second->GetTrays()) {
int slot_id = std::stoi(tray.first); int slot_id = std::stoi(tray.first);
filament_ams_list.emplace(extruder + (ams_id * 4 + slot_id), filament_ams_list.emplace(extruder + (ams_id * 4 + slot_id),
build_tray_config(*tray.second, get_ams_name(ams_id, slot_id), std::to_string(ams_id), std::to_string(slot_id))); build_tray_config(*tray.second, get_ams_name(ams_id, slot_id), std::to_string(ams_id), std::to_string(slot_id)));
@@ -3035,8 +3038,10 @@ void Sidebar::load_ams_list(std::string const &device, MachineObject* obj)
device_change = true; device_change = true;
} }
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": %1% items") % filament_ams_list.size(); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": %1% items") % filament_ams_list.size();
if (wxGetApp().preset_bundle->filament_ams_list == filament_ams_list) if (wxGetApp().preset_bundle->filament_ams_list == filament_ams_list && !device_change)
{
return; return;
}
wxGetApp().preset_bundle->filament_ams_list = filament_ams_list; wxGetApp().preset_bundle->filament_ams_list = filament_ams_list;
for (auto c : p->combos_filament){ for (auto c : p->combos_filament){
@@ -3055,7 +3060,7 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn)
// Force load ams list // Force load ams list
auto obj = wxGetApp().getDeviceManager()->get_selected_machine(); auto obj = wxGetApp().getDeviceManager()->get_selected_machine();
if (obj) if (obj)
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj); GUI::wxGetApp().sidebar().load_ams_list(obj->get_dev_id(), obj);
auto & list = wxGetApp().preset_bundle->filament_ams_list; auto & list = wxGetApp().preset_bundle->filament_ams_list;
if (list.empty()) { if (list.empty()) {
@@ -6158,14 +6163,14 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
if (dev) { if (dev) {
MachineObject *obj = dev->get_selected_machine(); MachineObject *obj = dev->get_selected_machine();
if (obj && obj->is_info_ready()) { if (obj && obj->is_info_ready()) {
if (obj->m_extder_data.extders.size() > 0) { if (obj->GetExtderSystem()->GetTotalExtderCount() > 0) {
PresetBundle *preset_bundle = wxGetApp().preset_bundle; PresetBundle *preset_bundle = wxGetApp().preset_bundle;
Preset &printer_preset = preset_bundle->printers.get_selected_preset(); Preset &printer_preset = preset_bundle->printers.get_selected_preset();
double preset_nozzle_diameter = 0.4; double preset_nozzle_diameter = 0.4;
const ConfigOption *opt = printer_preset.config.option("nozzle_diameter"); const ConfigOption *opt = printer_preset.config.option("nozzle_diameter");
if (opt) preset_nozzle_diameter = static_cast<const ConfigOptionFloatsNullable *>(opt)->values[0]; if (opt) preset_nozzle_diameter = static_cast<const ConfigOptionFloatsNullable *>(opt)->values[0];
float machine_nozzle_diameter = obj->m_extder_data.extders[0].current_nozzle_diameter; float machine_nozzle_diameter = obj->GetExtderSystem()->GetNozzleDiameter(0);
std::string machine_type = obj->printer_type; std::string machine_type = obj->printer_type;
if (obj->is_support_upgrade_kit && obj->installed_upgrade_kit) machine_type = "C12"; if (obj->is_support_upgrade_kit && obj->installed_upgrade_kit) machine_type = "C12";
@@ -8485,8 +8490,10 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
if (cur_preset.get_printer_type(preset_bundle) == obj->get_show_printer_type()) { if (cur_preset.get_printer_type(preset_bundle) == obj->get_show_printer_type()) {
double preset_nozzle_diameter = cur_preset.config.option<ConfigOptionFloatsNullable>("nozzle_diameter")->values[0]; double preset_nozzle_diameter = cur_preset.config.option<ConfigOptionFloatsNullable>("nozzle_diameter")->values[0];
bool same_nozzle_diameter = true; bool same_nozzle_diameter = true;
for (const Extder &extruder : obj->m_extder_data.extders) {
if (!is_approx(extruder.current_nozzle_diameter, float(preset_nozzle_diameter))) { const auto& extruders = obj->GetExtderSystem()->GetExtruders();
for (const DevExtder &extruder : extruders) {
if (!is_approx(extruder.GetNozzleDiameter(), float(preset_nozzle_diameter))) {
same_nozzle_diameter = false; same_nozzle_diameter = false;
} }
} }
@@ -9888,10 +9895,10 @@ bool Plater::priv::check_ams_status_impl(bool is_slice_all)
if (preset_bundle && preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle) == obj->get_show_printer_type()) { if (preset_bundle && preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle) == obj->get_show_printer_type()) {
bool is_same_as_printer = true; bool is_same_as_printer = true;
auto nozzle_volumes_values = preset_bundle->project_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type")->values; auto nozzle_volumes_values = preset_bundle->project_config.option<ConfigOptionEnumsGeneric>("nozzle_volume_type")->values;
assert(obj->m_extder_data.extders.size() == 2 && nozzle_volumes_values.size() == 2); assert(obj->GetExtderSystem()->GetTotalExtderCount() == 2 && nozzle_volumes_values.size() == 2);
if (obj->m_extder_data.extders.size() == 2 && nozzle_volumes_values.size() == 2) { if (obj->GetExtderSystem()->GetTotalExtderCount() == 2 && nozzle_volumes_values.size() == 2) {
NozzleVolumeType right_nozzle_type = NozzleVolumeType(obj->m_extder_data.extders[0].current_nozzle_flow_type - 1); NozzleVolumeType right_nozzle_type = NozzleVolumeType(obj->GetExtderSystem()->GetNozzleFlowType(0) - 1);
NozzleVolumeType left_nozzle_type = NozzleVolumeType(obj->m_extder_data.extders[1].current_nozzle_flow_type - 1); NozzleVolumeType left_nozzle_type = NozzleVolumeType(obj->GetExtderSystem()->GetNozzleFlowType(1) - 1);
NozzleVolumeType preset_left_type = NozzleVolumeType(nozzle_volumes_values[0]); NozzleVolumeType preset_left_type = NozzleVolumeType(nozzle_volumes_values[0]);
NozzleVolumeType preset_right_type = NozzleVolumeType(nozzle_volumes_values[1]); NozzleVolumeType preset_right_type = NozzleVolumeType(nozzle_volumes_values[1]);
is_same_as_printer = (left_nozzle_type == preset_left_type && right_nozzle_type == preset_right_type); is_same_as_printer = (left_nozzle_type == preset_left_type && right_nozzle_type == preset_right_type);
@@ -9900,15 +9907,15 @@ bool Plater::priv::check_ams_status_impl(bool is_slice_all)
std::vector<std::map<int, int>> ams_count_info; std::vector<std::map<int, int>> ams_count_info;
ams_count_info.resize(2); ams_count_info.resize(2);
int deputy_4 = 0, main_4 = 0, deputy_1 = 0, main_1 = 0; int deputy_4 = 0, main_4 = 0, deputy_1 = 0, main_1 = 0;
for (auto ams : obj->amsList) { for (auto ams : obj->GetFilaSystem()->GetAmsList()) {
// Main (first) extruder at right // Main (first) extruder at right
if (ams.second->nozzle == 0) { if (ams.second->GetExtruderId() == 0) {
if (ams.second->type == 4) // N3S if (ams.second->GetAmsType() == DevAms::N3S) // N3S
++main_1; ++main_1;
else else
++main_4; ++main_4;
} else if (ams.second->nozzle == 1) { } else if (ams.second->GetExtruderId() == 1) {
if (ams.second->type == 4) // N3S if (ams.second->GetAmsType() == DevAms::N3S) // N3S
++deputy_1; ++deputy_1;
else else
++deputy_4; ++deputy_4;
@@ -13840,7 +13847,7 @@ Preset *get_printer_preset(const MachineObject *obj)
return nullptr; return nullptr;
Preset *printer_preset = nullptr; Preset *printer_preset = nullptr;
float machine_nozzle_diameter = obj->m_extder_data.extders[0].current_nozzle_diameter; float machine_nozzle_diameter = obj->GetExtderSystem()->GetNozzleDiameter(0);
PresetBundle *preset_bundle = wxGetApp().preset_bundle; PresetBundle *preset_bundle = wxGetApp().preset_bundle;
for (auto printer_it = preset_bundle->printers.begin(); printer_it != preset_bundle->printers.end(); printer_it++) { for (auto printer_it = preset_bundle->printers.begin(); printer_it != preset_bundle->printers.end(); printer_it++) {
// only use system printer preset // only use system printer preset
@@ -13866,14 +13873,16 @@ bool Plater::check_printer_initialized(MachineObject *obj, bool only_warning, bo
return false; return false;
bool has_been_initialized = true; bool has_been_initialized = true;
for (const Extder& extruder : obj->m_extder_data.extders) {
const auto& extruders = obj->GetExtderSystem()->GetExtruders();
for (const DevExtder& extruder : extruders) {
if (obj->is_multi_extruders()) { if (obj->is_multi_extruders()) {
if (extruder.current_nozzle_flow_type == NozzleFlowType::NONE_FLOWTYPE) { if (extruder.GetNozzleFlowType() == NozzleFlowType::NONE_FLOWTYPE) {
has_been_initialized = false; has_been_initialized = false;
break; break;
} }
} }
if (extruder.current_nozzle_type == NozzleType::ntUndefine) { if (extruder.GetNozzleFlowType() == NozzleType::ntUndefine) {
has_been_initialized = false; has_been_initialized = false;
break; break;
} }
@@ -13882,7 +13891,7 @@ bool Plater::check_printer_initialized(MachineObject *obj, bool only_warning, bo
if (!has_been_initialized) { if (!has_been_initialized) {
if (popup_warning) { if (popup_warning) {
if (!only_warning) { if (!only_warning) {
if (DeviceManager::get_printer_can_set_nozzle(obj->get_show_printer_type())) { if (DevPrinterConfigUtil::get_printer_can_set_nozzle(obj->get_show_printer_type())) {
MessageDialog dlg(wxGetApp().plater(), _L("The nozzle type is not set. Please set the nozzle and try again."), _L("Warning"), wxOK | wxICON_WARNING); MessageDialog dlg(wxGetApp().plater(), _L("The nozzle type is not set. Please set the nozzle and try again."), _L("Warning"), wxOK | wxICON_WARNING);
dlg.ShowModal(); dlg.ShowModal();
} else { } else {
+1 -1
View File
@@ -52,7 +52,7 @@ class PartPlateList;
class SlicingStatusEvent; class SlicingStatusEvent;
enum SLAPrintObjectStep : unsigned int; enum SLAPrintObjectStep : unsigned int;
enum class ConversionType : int; enum class ConversionType : int;
class Ams; class DevAms;
using ModelInstancePtrs = std::vector<ModelInstance*>; using ModelInstancePtrs = std::vector<ModelInstance*>;
-13
View File
@@ -1061,19 +1061,6 @@ PreferencesDialog::PreferencesDialog(wxWindow *parent, wxWindowID id, const wxSt
SetBackgroundColour(*wxWHITE); SetBackgroundColour(*wxWHITE);
create(); create();
wxGetApp().UpdateDlgDarkUI(this); wxGetApp().UpdateDlgDarkUI(this);
Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& event) {
try {
NetworkAgent* agent = GUI::wxGetApp().getAgent();
if (agent) {
json j;
std::string value;
value = wxGetApp().app_config->get("auto_calculate_flush");
j["auto_flushing"] = value;
agent->track_event("preferences_changed", j.dump());
}
} catch(...) {}
event.Skip();
});
} }
void PreferencesDialog::create() void PreferencesDialog::create()
+3 -1
View File
@@ -45,6 +45,8 @@
#include "FilamentPickerDialog.hpp" #include "FilamentPickerDialog.hpp"
#include "wxExtensions.hpp" #include "wxExtensions.hpp"
#include "DeviceCore/DevManager.h"
// A workaround for a set of issues related to text fitting into gtk widgets: // A workaround for a set of issues related to text fitting into gtk widgets:
#if defined(__WXGTK20__) || defined(__WXGTK3__) #if defined(__WXGTK20__) || defined(__WXGTK3__)
#include <glib-2.0/glib-object.h> #include <glib-2.0/glib-object.h>
@@ -469,7 +471,7 @@ void PresetComboBox::add_connected_printers(std::string selected, bool alias_nam
printer_preset->is_visible = true; printer_preset->is_visible = true;
auto printer_model = printer_preset->config.opt_string("printer_model"); auto printer_model = printer_preset->config.opt_string("printer_model");
boost::replace_all(printer_model, "Bambu Lab ", ""); boost::replace_all(printer_model, "Bambu Lab ", "");
auto text = iter->second->dev_name + " (" + printer_model + ")"; auto text = iter->second->get_dev_name() + " (" + printer_model + ")";
int item_id = Append(from_u8(text), wxNullBitmap, &m_first_printer_idx + std::distance(machine_list.begin(), iter)); int item_id = Append(from_u8(text), wxNullBitmap, &m_first_printer_idx + std::distance(machine_list.begin(), iter));
validate_selection(m_selected_dev_id == iter->first); validate_selection(m_selected_dev_id == iter->first);
} }
+17 -15
View File
@@ -5,6 +5,9 @@
#include "Widgets/SwitchButton.hpp" #include "Widgets/SwitchButton.hpp"
#include "MsgDialog.hpp" #include "MsgDialog.hpp"
#include "DeviceCore/DevConfig.h"
#include "DeviceCore/DevExtruderSystem.h"
static const wxColour STATIC_BOX_LINE_COL = wxColour(238, 238, 238); static const wxColour STATIC_BOX_LINE_COL = wxColour(238, 238, 238);
static const wxColour STATIC_TEXT_CAPTION_COL = wxColour(100, 100, 100); static const wxColour STATIC_TEXT_CAPTION_COL = wxColour(100, 100, 100);
static const wxColour STATIC_TEXT_EXPLAIN_COL = wxColour(100, 100, 100); static const wxColour STATIC_TEXT_EXPLAIN_COL = wxColour(100, 100, 100);
@@ -254,8 +257,7 @@ void PrintOptionsDialog::update_options(MachineObject* obj_)
text_ai_detections_caption->Hide(); text_ai_detections_caption->Hide();
} }
if (obj_->GetConfig()->SupportAIMonitor() && !obj_->xcam_disable_ai_detection_display) {
if (obj_->is_support_ai_monitoring && !obj_->xcam_disable_ai_detection_display) {
text_ai_monitoring->Show(); text_ai_monitoring->Show();
m_cb_ai_monitoring->Show(); m_cb_ai_monitoring->Show();
text_ai_monitoring_caption->Show(); text_ai_monitoring_caption->Show();
@@ -373,7 +375,7 @@ void PrintOptionsDialog::update_options(MachineObject* obj_)
line2->Hide(); line2->Hide();
} }
if (obj_->is_support_first_layer_inspect) { if (obj_->GetConfig()->SupportFirstLayerInspect()) {
text_first_layer->Show(); text_first_layer->Show();
m_cb_first_layer->Show(); m_cb_first_layer->Show();
// line3->Show(); // line3->Show();
@@ -525,7 +527,7 @@ void PrintOptionsDialog::UpdateOptionOpenDoorCheck(MachineObject *obj) {
void PrintOptionsDialog::UpdateOptionSavePrintFileToStorage(MachineObject *obj) void PrintOptionsDialog::UpdateOptionSavePrintFileToStorage(MachineObject *obj)
{ {
if (obj && obj->support_save_remote_print_file_to_storage()) if (obj && obj->GetConfig()->SupportSaveRemotePrintFileToStorage())
{ {
m_cb_save_remote_print_file_to_storage->SetValue(obj->get_save_remote_print_file_to_storage()); m_cb_save_remote_print_file_to_storage->SetValue(obj->get_save_remote_print_file_to_storage());
} }
@@ -1271,14 +1273,14 @@ bool PrinterPartsDialog::Show(bool show)
/*disable editing*/ /*disable editing*/
EnableEditing(false); EnableEditing(false);
assert(DeviceManager::get_printer_can_set_nozzle(obj->printer_type) == false);/*editing is not supported*/ assert(DevPrinterConfigUtil::get_printer_can_set_nozzle(obj->printer_type) == false);/*editing is not supported*/
if (obj->m_extder_data.extders.size() <= 1) { if (obj->GetExtderSystem()->GetTotalExtderSize() <= 1) {
single_panel->Show(); single_panel->Show();
multiple_panel->Hide(); multiple_panel->Hide();
auto type = obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_type; auto type = obj->GetExtderSystem()->GetNozzleType(MAIN_EXTRUDER_ID);
auto diameter = obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_diameter; auto diameter = obj->GetExtderSystem()->GetNozzleDiameter(MAIN_EXTRUDER_ID);
nozzle_type_checkbox->SetValue(GetString(type)); nozzle_type_checkbox->SetValue(GetString(type));
nozzle_diameter_checkbox->SetValue(GetString(diameter)); nozzle_diameter_checkbox->SetValue(GetString(diameter));
@@ -1287,7 +1289,7 @@ bool PrinterPartsDialog::Show(bool show)
nozzle_flow_type_checkbox->Show(obj->is_nozzle_flow_type_supported()); nozzle_flow_type_checkbox->Show(obj->is_nozzle_flow_type_supported());
if (obj->is_nozzle_flow_type_supported()) if (obj->is_nozzle_flow_type_supported())
{ {
auto flow_type = obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_flow_type; auto flow_type = obj->GetExtderSystem()->GetNozzleFlowType(MAIN_EXTRUDER_ID);
nozzle_flow_type_checkbox->SetValue(GetString(flow_type)); nozzle_flow_type_checkbox->SetValue(GetString(flow_type));
} }
} else { } else {
@@ -1295,17 +1297,17 @@ bool PrinterPartsDialog::Show(bool show)
multiple_panel->Show(); multiple_panel->Show();
//left //left
auto type = obj->m_extder_data.extders[DEPUTY_NOZZLE_ID].current_nozzle_type; auto type = obj->GetExtderSystem()->GetNozzleType(DEPUTY_EXTRUDER_ID);
auto diameter = obj->m_extder_data.extders[DEPUTY_NOZZLE_ID].current_nozzle_diameter; auto diameter = obj->GetExtderSystem()->GetNozzleDiameter(DEPUTY_EXTRUDER_ID);
auto flow_type = obj->m_extder_data.extders[DEPUTY_NOZZLE_ID].current_nozzle_flow_type; auto flow_type = obj->GetExtderSystem()->GetNozzleFlowType(DEPUTY_EXTRUDER_ID);
multiple_left_nozzle_type_checkbox->SetValue(GetString(type)); multiple_left_nozzle_type_checkbox->SetValue(GetString(type));
multiple_left_nozzle_diameter_checkbox->SetValue(GetString(diameter)); multiple_left_nozzle_diameter_checkbox->SetValue(GetString(diameter));
multiple_left_nozzle_flow_checkbox->SetValue(GetString(flow_type)); multiple_left_nozzle_flow_checkbox->SetValue(GetString(flow_type));
//right //right
type = obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_type; type = obj->GetExtderSystem()->GetNozzleType(MAIN_EXTRUDER_ID);
diameter = obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_diameter; diameter = obj->GetExtderSystem()->GetNozzleDiameter(MAIN_EXTRUDER_ID);
flow_type = obj->m_extder_data.extders[MAIN_NOZZLE_ID].current_nozzle_flow_type; flow_type = obj->GetExtderSystem()->GetNozzleFlowType(MAIN_EXTRUDER_ID);
multiple_right_nozzle_type_checkbox->SetValue(GetString(type)); multiple_right_nozzle_type_checkbox->SetValue(GetString(type));
multiple_right_nozzle_diameter_checkbox->SetValue(GetString(diameter)); multiple_right_nozzle_diameter_checkbox->SetValue(GetString(diameter));
multiple_right_nozzle_flow_checkbox->SetValue(GetString(flow_type)); multiple_right_nozzle_flow_checkbox->SetValue(GetString(flow_type));
@@ -1067,7 +1067,11 @@ void PrinterFileSystem::SendChangedEvent(wxEventType type, size_t index, std::st
void PrinterFileSystem::DumpLog(void * thiz, int, tchar const *msg) void PrinterFileSystem::DumpLog(void * thiz, int, tchar const *msg)
{ {
#if !BBL_RELEASE_TO_PUBLIC
BOOST_LOG_TRIVIAL(info) << "PrinterFileSystem: " << wxString(msg).ToUTF8().data(); BOOST_LOG_TRIVIAL(info) << "PrinterFileSystem: " << wxString(msg).ToUTF8().data();
#endif
static_cast<PrinterFileSystem*>(thiz)->Bambu_FreeLogMsg(msg); static_cast<PrinterFileSystem*>(thiz)->Bambu_FreeLogMsg(msg);
} }
+14 -11
View File
@@ -25,6 +25,9 @@
#include "BitmapCache.hpp" #include "BitmapCache.hpp"
#include "slic3r/GUI/GUI_App.hpp" #include "slic3r/GUI/GUI_App.hpp"
#include "DeviceCore/DevManager.h"
#include "DeviceCore/DevStorage.h"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
wxDEFINE_EVENT(EVT_SECONDARY_CHECK_CONFIRM, wxCommandEvent); wxDEFINE_EVENT(EVT_SECONDARY_CHECK_CONFIRM, wxCommandEvent);
@@ -1558,9 +1561,9 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent)
m_input_modelID->SetMinSize(wxSize(FromDIP(168), FromDIP(28))); m_input_modelID->SetMinSize(wxSize(FromDIP(168), FromDIP(28)));
m_input_modelID->SetMaxSize(wxSize(FromDIP(168), FromDIP(28))); m_input_modelID->SetMaxSize(wxSize(FromDIP(168), FromDIP(28)));
m_models_map = DeviceManager::get_all_model_id_with_name(); m_models_map = DevPrinterConfigUtil::get_all_model_id_with_name();
for (auto it = m_models_map.begin(); it != m_models_map.end(); ++it) { for (auto it = m_models_map.begin(); it != m_models_map.end(); ++it) {
m_input_modelID->Append(it->right); m_input_modelID->Append(it->first);
m_input_modelID->SetSelection(0); m_input_modelID->SetSelection(0);
} }
@@ -1814,11 +1817,11 @@ void InputIpAddressDialog::update_title(wxString title)
void InputIpAddressDialog::set_machine_obj(MachineObject* obj) void InputIpAddressDialog::set_machine_obj(MachineObject* obj)
{ {
m_obj = obj; m_obj = obj;
m_input_ip->GetTextCtrl()->SetLabelText(m_obj->dev_ip); m_input_ip->GetTextCtrl()->SetLabelText(m_obj->get_dev_ip());
m_input_access_code->GetTextCtrl()->SetLabelText(m_obj->get_access_code()); m_input_access_code->GetTextCtrl()->SetLabelText(m_obj->get_access_code());
m_input_printer_name->GetTextCtrl()->SetLabelText(m_obj->dev_name); m_input_printer_name->GetTextCtrl()->SetLabelText(m_obj->get_dev_name());
std::string img_str = DeviceManager::get_printer_diagram_img(m_obj->printer_type); std::string img_str = DevPrinterConfigUtil::get_printer_connect_help_img(m_obj->printer_type);
auto diagram_bmp = create_scaled_bitmap(img_str + "_en", this, 198); auto diagram_bmp = create_scaled_bitmap(img_str + "_en", this, 198);
m_img_help->SetBitmap(diagram_bmp); m_img_help->SetBitmap(diagram_bmp);
@@ -1907,9 +1910,9 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt)
std::string str_sn = m_input_sn->GetTextCtrl()->GetValue().Strip(wxString::both).Upper().ToStdString(); std::string str_sn = m_input_sn->GetTextCtrl()->GetValue().Strip(wxString::both).Upper().ToStdString();
std::string str_model_id = ""; std::string str_model_id = "";
auto it = m_models_map.right.find(m_input_modelID->GetStringSelection().ToStdString()); auto it = m_models_map.find(m_input_modelID->GetStringSelection().ToStdString());
if (it != m_models_map.right.end()) { if (it != m_models_map.end()) {
str_model_id = it->get_left(); str_model_id = it->second;
} }
m_button_manual_setup->Enable(false); m_button_manual_setup->Enable(false);
@@ -1968,7 +1971,7 @@ void InputIpAddressDialog::on_send_retry()
m_worker->wait_for_idle(); m_worker->wait_for_idle();
}); });
auto m_send_job = std::make_unique<SendJob>(m_obj->dev_id); auto m_send_job = std::make_unique<SendJob>(m_obj->get_dev_id());
m_send_job->m_dev_ip = ip.ToStdString(); m_send_job->m_dev_ip = ip.ToStdString();
m_send_job->m_access_code = str_access_code.ToStdString(); m_send_job->m_access_code = str_access_code.ToStdString();
@@ -1982,7 +1985,7 @@ void InputIpAddressDialog::on_send_retry()
m_send_job->connection_type = m_obj->connection_type(); m_send_job->connection_type = m_obj->connection_type();
m_send_job->cloud_print_only = true; m_send_job->cloud_print_only = true;
m_send_job->has_sdcard = m_obj->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL; m_send_job->has_sdcard = m_obj->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::HAS_SDCARD_NORMAL;
m_send_job->set_check_mode(); m_send_job->set_check_mode();
m_send_job->set_project_name("verify_job"); m_send_job->set_project_name("verify_job");
@@ -2095,7 +2098,7 @@ void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_
if (m_obj) { if (m_obj) {
m_obj->set_user_access_code(str_access_code); m_obj->set_user_access_code(str_access_code);
wxGetApp().getDeviceManager()->set_selected_machine(m_obj->dev_id); wxGetApp().getDeviceManager()->set_selected_machine(m_obj->get_dev_id());
} }
+1 -1
View File
@@ -335,7 +335,7 @@ public:
int current_input_index {0}; int current_input_index {0};
std::shared_ptr<BBLStatusBarSend> m_status_bar; std::shared_ptr<BBLStatusBarSend> m_status_bar;
std::unique_ptr<Worker> m_worker; std::unique_ptr<Worker> m_worker;
boost::bimaps::bimap<std::string, std::string> m_models_map; std::map<std::string, std::string> m_models_map;// display_name -> model_id
void switch_input_panel(int index); void switch_input_panel(int index);
void on_cancel(); void on_cancel();
+131 -117
View File
@@ -18,6 +18,14 @@
#include "Jobs/BoostThreadWorker.hpp" #include "Jobs/BoostThreadWorker.hpp"
#include "Jobs/PlaterWorker.hpp" #include "Jobs/PlaterWorker.hpp"
#include "DeviceCore/DevConfig.h"
#include "DeviceCore/DevNozzleSystem.h"
#include "DeviceCore/DevExtruderSystem.h"
#include "DeviceCore/DevFilaBlackList.h"
#include "DeviceCore/DevFilaSystem.h"
#include "DeviceCore/DevManager.h"
#include "DeviceCore/DevMapping.h"
#include "DeviceCore/DevStorage.h"
#include <wx/progdlg.h> #include <wx/progdlg.h>
#include <wx/clipbrd.h> #include <wx/clipbrd.h>
@@ -769,8 +777,8 @@ void SelectMachineDialog::init_bind()
MachineObject* obj = dev->get_selected_machine(); MachineObject* obj = dev->get_selected_machine();
if (!obj) return; if (!obj) return;
if (obj->dev_id == e.GetString()) { if (obj->get_dev_id() == e.GetString()) {
m_printer_box->SetPrinterName(wxString::FromUTF8(obj->dev_name) + "(LAN)"); m_printer_box->SetPrinterName(wxString::FromUTF8(obj->get_dev_name()) + "(LAN)");
} }
} }
}); });
@@ -967,14 +975,14 @@ void SelectMachineDialog::sync_ams_mapping_result(std::vector<FilamentInfo> &res
} }
if (!f->color.empty()) { if (!f->color.empty()) {
ams_col = AmsTray::decode_color(f->color); ams_col = DevAmsTray::decode_color(f->color);
} else { } else {
// default color // default color
ams_col = wxColour(0xCE, 0xCE, 0xCE); ams_col = wxColour(0xCE, 0xCE, 0xCE);
} }
std::vector<wxColour> cols; std::vector<wxColour> cols;
for (auto col : f->colors) { for (auto col : f->colors) {
cols.push_back(AmsTray::decode_color(col)); cols.push_back(DevAmsTray::decode_color(col));
} }
m->set_ams_info(ams_col, ams_id,f->ctype, cols); m->set_ams_info(ams_col, ams_id,f->ctype, cols);
break; break;
@@ -1004,7 +1012,7 @@ void print_ams_mapping_result(std::vector<FilamentInfo>& result)
bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_,bool use_ams) bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_,bool use_ams)
{ {
if (!obj_) return false; if (!obj_) return false;
if (!obj_->has_ams()) { use_ams = false;} /*STUDIO-11971*/ if (!obj_->HasAms()) { use_ams = false;} /*STUDIO-11971*/
obj_->get_ams_colors(m_cur_colors_in_thumbnail); obj_->get_ams_colors(m_cur_colors_in_thumbnail);
// try color and type mapping // try color and type mapping
@@ -1020,7 +1028,7 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_,bool use_ams)
std::vector<bool> map_opt; //four values: use_left_ams, use_right_ams, use_left_ext, use_right_ext std::vector<bool> map_opt; //four values: use_left_ams, use_right_ams, use_left_ext, use_right_ext
if (nozzle_nums > 1){ if (nozzle_nums > 1){
//get nozzle property, the extders are same? //get nozzle property, the extders are same?
if (true/*!can_hybrid_mapping(obj_->m_extder_data)*/){ if (true/*!can_hybrid_mapping(obj_get_extder_data())*/){
std::vector<FilamentInfo> m_ams_mapping_result_left, m_ams_mapping_result_right; std::vector<FilamentInfo> m_ams_mapping_result_left, m_ams_mapping_result_right;
std::vector<FilamentInfo> m_filament_left, m_filament_right; std::vector<FilamentInfo> m_filament_left, m_filament_right;
for (auto it = m_filaments.begin(); it != m_filaments.end(); it++){ for (auto it = m_filaments.begin(); it != m_filaments.end(); it++){
@@ -1039,14 +1047,14 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_,bool use_ams)
} }
bool has_left_ams = false, has_right_ams = false; bool has_left_ams = false, has_right_ams = false;
for (auto ams_item : obj_->amsList) { for (auto ams_item : obj_->GetFilaSystem()->GetAmsList()) {
if (ams_item.second->nozzle == 0) { if (ams_item.second->GetExtruderId() == 0) {
if (obj_->is_main_extruder_on_left()) if (obj_->is_main_extruder_on_left())
has_left_ams = true; has_left_ams = true;
else else
has_right_ams = true; has_right_ams = true;
} }
else if (ams_item.second->nozzle == 1) { else if (ams_item.second->GetExtruderId() == 1) {
if (obj_->is_main_extruder_on_left()) if (obj_->is_main_extruder_on_left())
has_right_ams = true; has_right_ams = true;
else else
@@ -1062,13 +1070,13 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_,bool use_ams)
map_opt[0] = false; map_opt[0] = false;
map_opt[2] = true; map_opt[2] = true;
} }
int result_first = obj_->ams_filament_mapping(m_filament_left, m_ams_mapping_result_left, map_opt); int result_first = DevMappingUtil::ams_filament_mapping(obj_, m_filament_left, m_ams_mapping_result_left, map_opt);
map_opt = { false, true, false, !has_right_ams }; map_opt = { false, true, false, !has_right_ams };
if (!use_ams) { if (!use_ams) {
map_opt[1] = false; map_opt[1] = false;
map_opt[3] = true; map_opt[3] = true;
} }
int result_second = obj_->ams_filament_mapping(m_filament_right, m_ams_mapping_result_right, map_opt); int result_second = DevMappingUtil::ams_filament_mapping(obj_, m_filament_right, m_ams_mapping_result_right, map_opt);
//m_ams_mapping_result.clear(); //m_ams_mapping_result.clear();
m_ams_mapping_result.resize(m_ams_mapping_result_left.size() + m_ams_mapping_result_right.size()); m_ams_mapping_result.resize(m_ams_mapping_result_left.size() + m_ams_mapping_result_right.size());
@@ -1086,7 +1094,7 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_,bool use_ams)
map_opt[0] = false; map_opt[0] = false;
map_opt[1] = false; map_opt[1] = false;
} }
filament_result = obj_->ams_filament_mapping(m_filaments, m_ams_mapping_result, map_opt); filament_result = DevMappingUtil::ams_filament_mapping(obj_, m_filaments, m_ams_mapping_result, map_opt);
} }
//When filaments cannot be matched automatically, whether to use ext for automatic supply //When filaments cannot be matched automatically, whether to use ext for automatic supply
//auto_supply_with_ext(obj_->vt_slot); //auto_supply_with_ext(obj_->vt_slot);
@@ -1100,7 +1108,7 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_,bool use_ams)
map_opt[1] = false; map_opt[1] = false;
map_opt[3] = true; map_opt[3] = true;
} }
filament_result = obj_->ams_filament_mapping(m_filaments, m_ams_mapping_result, map_opt); filament_result = DevMappingUtil::ams_filament_mapping(obj_, m_filaments, m_ams_mapping_result, map_opt);
//auto_supply_with_ext(obj_->vt_slot); //auto_supply_with_ext(obj_->vt_slot);
} }
else { else {
@@ -1109,7 +1117,7 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_,bool use_ams)
map_opt[1] = false; map_opt[1] = false;
map_opt[3] = true; map_opt[3] = true;
} }
filament_result = obj_->ams_filament_mapping(m_filaments, m_ams_mapping_result, map_opt); filament_result = DevMappingUtil::ams_filament_mapping(obj_, m_filaments, m_ams_mapping_result, map_opt);
} }
} }
@@ -1131,10 +1139,10 @@ bool SelectMachineDialog::do_ams_mapping(MachineObject *obj_,bool use_ams)
BOOST_LOG_TRIVIAL(info) << "ams_mapping_array2=" << ams_array2; BOOST_LOG_TRIVIAL(info) << "ams_mapping_array2=" << ams_array2;
BOOST_LOG_TRIVIAL(info) << "ams_mapping_info=" << mapping_info; BOOST_LOG_TRIVIAL(info) << "ams_mapping_info=" << mapping_info;
} }
return obj_->is_valid_mapping_result(m_ams_mapping_result); return DevMappingUtil::is_valid_mapping_result(obj_, m_ams_mapping_result);
} else { } else {
// do not support ams mapping try to use order mapping // do not support ams mapping try to use order mapping
bool is_valid = obj_->is_valid_mapping_result(m_ams_mapping_result); bool is_valid = DevMappingUtil::is_valid_mapping_result(obj_, m_ams_mapping_result);
if (filament_result != 1 && !is_valid) { if (filament_result != 1 && !is_valid) {
//reset invalid result //reset invalid result
for (int i = 0; i < m_ams_mapping_result.size(); i++) { for (int i = 0; i < m_ams_mapping_result.size(); i++) {
@@ -1313,22 +1321,22 @@ bool SelectMachineDialog::build_nozzles_info(std::string& nozzles_info)
return true; return true;
} }
bool SelectMachineDialog::can_hybrid_mapping(ExtderData data) { bool SelectMachineDialog::can_hybrid_mapping(DevExtderSystem data) {
// Mixed mappings are not allowed // Mixed mappings are not allowed
return false; return false;
if (data.total_extder_count <= 1 || data.extders.size() <= 1 || !wxGetApp().preset_bundle) if (data.GetTotalExtderCount() <= 1 || !wxGetApp().preset_bundle)
return false; return false;
//The default two extruders are left, right, but the order of the extruders on the machine is right, left. //The default two extruders are left, right, but the order of the extruders on the machine is right, left.
//Therefore, some adjustments need to be made. //Therefore, some adjustments need to be made.
std::vector<std::string>flow_type_of_machine; std::vector<std::string>flow_type_of_machine;
for (auto it = data.extders.rbegin(); it != data.extders.rend(); it++){ for (const auto& ext : data.GetExtruders())
//exist field is not updated, wait add {
//if (it->exist < 3) return false; std::string type_str = ext.GetNozzleFlowType() == NozzleFlowType::H_FLOW ? "High Flow" : "Standard";
std::string type_str = it->current_nozzle_flow_type ? "High Flow" : "Standard";
flow_type_of_machine.push_back(type_str); flow_type_of_machine.push_back(type_str);
} }
//get the nozzle type of preset --> flow_types //get the nozzle type of preset --> flow_types
const Preset& current_printer = wxGetApp().preset_bundle->printers.get_selected_preset(); const Preset& current_printer = wxGetApp().preset_bundle->printers.get_selected_preset();
const Preset* base_printer = wxGetApp().preset_bundle->printers.get_preset_base(current_printer); const Preset* base_printer = wxGetApp().preset_bundle->printers.get_preset_base(current_printer);
@@ -1348,13 +1356,13 @@ bool SelectMachineDialog::can_hybrid_mapping(ExtderData data) {
} }
//When filaments cannot be matched automatically, whether to use ext for automatic supply //When filaments cannot be matched automatically, whether to use ext for automatic supply
void SelectMachineDialog::auto_supply_with_ext(std::vector<AmsTray> slots) { void SelectMachineDialog::auto_supply_with_ext(std::vector<DevAmsTray> slots) {
if (slots.size() <= 0) return; if (slots.size() <= 0) return;
for (int i = 0; i < m_ams_mapping_result.size(); i++) { for (int i = 0; i < m_ams_mapping_result.size(); i++) {
auto it = m_ams_mapping_result[i]; auto it = m_ams_mapping_result[i];
if (it.ams_id == "") { if (it.ams_id == "") {
AmsTray slot(""); DevAmsTray slot("");
if (m_filaments_map[it.id] == 1 && slots.size() > 1) slot = slots[1]; if (m_filaments_map[it.id] == 1 && slots.size() > 1) slot = slots[1];
else if (m_filaments_map[it.id] == 2) slot = slots[0]; else if (m_filaments_map[it.id] == 2) slot = slots[0];
if (slot.id.empty()) continue; if (slot.id.empty()) continue;
@@ -1368,8 +1376,8 @@ void SelectMachineDialog::auto_supply_with_ext(std::vector<AmsTray> slots) {
} }
} }
bool SelectMachineDialog::is_nozzle_type_match(ExtderData data, wxString& error_message) const { bool SelectMachineDialog::is_nozzle_type_match(DevExtderSystem data, wxString& error_message) const {
if (data.total_extder_count <= 1 || data.extders.size() <= 1 || !wxGetApp().preset_bundle) if (data.GetTotalExtderCount() <= 1 || !wxGetApp().preset_bundle)
return false; return false;
const auto& project_config = wxGetApp().preset_bundle->project_config; const auto& project_config = wxGetApp().preset_bundle->project_config;
@@ -1399,10 +1407,14 @@ bool SelectMachineDialog::is_nozzle_type_match(ExtderData data, wxString& error_
// The default two extruders are left, right, but the order of the extruders on the machine is right, left. // 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; std::vector<std::string> flow_type_of_machine;
for (auto it = data.extders.begin(); it != data.extders.end(); it++) { for (const auto& it : data.GetExtruders())
if (it->current_nozzle_flow_type == NozzleFlowType::H_FLOW) { {
if (it.GetNozzleFlowType() == NozzleFlowType::H_FLOW)
{
flow_type_of_machine.push_back(L("High Flow")); flow_type_of_machine.push_back(L("High Flow"));
} else if (it->current_nozzle_flow_type == NozzleFlowType::S_FLOW){ }
else if (it.GetNozzleFlowType() == NozzleFlowType::S_FLOW)
{
flow_type_of_machine.push_back(L("Standard")); flow_type_of_machine.push_back(L("Standard"));
} }
} }
@@ -1415,11 +1427,11 @@ bool SelectMachineDialog::is_nozzle_type_match(ExtderData data, wxString& error_
if (flow_type_of_machine[target_machine_nozzle_id] != used_extruders_flow[it->first]) { if (flow_type_of_machine[target_machine_nozzle_id] != used_extruders_flow[it->first]) {
wxString pos; wxString pos;
if (target_machine_nozzle_id == DEPUTY_NOZZLE_ID) if (target_machine_nozzle_id == DEPUTY_EXTRUDER_ID)
{ {
pos = _L("left nozzle"); pos = _L("left nozzle");
} }
else if(target_machine_nozzle_id == MAIN_NOZZLE_ID) else if(target_machine_nozzle_id == MAIN_EXTRUDER_ID)
{ {
pos = _L("right nozzle"); pos = _L("right nozzle");
} }
@@ -1480,7 +1492,7 @@ bool SelectMachineDialog::check_sdcard_for_timelpase(MachineObject* obj)
// must set to a status if return true // must set to a status if return true
if (m_checkbox_list["timelapse"]->IsShown() && m_checkbox_list["timelapse"]->getValue() == "on") if (m_checkbox_list["timelapse"]->IsShown() && m_checkbox_list["timelapse"]->getValue() == "on")
{ {
if (obj->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD) { if (obj->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::NO_SDCARD) {
show_status(PrintDialogStatus::PrintStatusTimelapseNoSdcard); show_status(PrintDialogStatus::PrintStatusTimelapseNoSdcard);
return true; return true;
} }
@@ -1614,7 +1626,7 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vector<wxSt
} }
} }
auto target_print_name = wxString(obj_->get_preset_printer_model_name(target_model_id)); auto target_print_name = wxString(DevPrinterConfigUtil::get_printer_display_name(target_model_id));
target_print_name.Replace(wxT("Bambu Lab "), wxEmptyString); target_print_name.Replace(wxT("Bambu Lab "), wxEmptyString);
msg_text = wxString::Format(_L("The selected printer (%s) is incompatible with the print file configuration (%s). Please adjust the printer preset in the prepare page or choose a compatible printer on this page."), sourcet_print_name, target_print_name); msg_text = wxString::Format(_L("The selected printer (%s) is incompatible with the print file configuration (%s). Please adjust the printer preset in the prepare page or choose a compatible printer on this page."), sourcet_print_name, target_print_name);
@@ -1728,7 +1740,7 @@ bool SelectMachineDialog::is_blocking_printing(MachineObject* obj_)
} }
if (source_model != target_model) { if (source_model != target_model) {
std::vector<std::string> compatible_machine = dev->get_compatible_machine(target_model); std::vector<std::string> compatible_machine = obj_->get_compatible_machine();
vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model); vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model);
if (it == compatible_machine.end()) { if (it == compatible_machine.end()) {
return true; return true;
@@ -1762,7 +1774,7 @@ static std::unordered_set<int> _get_used_nozzle_idxes()
} }
static bool _is_nozzle_data_valid(MachineObject* obj_, const ExtderData &ext_data) static bool _is_nozzle_data_valid(MachineObject* obj_, const DevExtderSystem &ext_data)
{ {
if (obj_ == nullptr) return false; if (obj_ == nullptr) return false;
@@ -1774,9 +1786,9 @@ static bool _is_nozzle_data_valid(MachineObject* obj_, const ExtderData &ext_dat
for (int used_filament_idx : used_filament_idxs) for (int used_filament_idx : used_filament_idxs)
{ {
int used_nozzle_idx = cur_plate->get_physical_extruder_by_filament_id(preset_bundle->full_config(), used_filament_idx); int used_nozzle_idx = cur_plate->get_physical_extruder_by_filament_id(preset_bundle->full_config(), used_filament_idx);
if (ext_data.extders[used_nozzle_idx].current_nozzle_type == NozzleType::ntUndefine || if (ext_data.GetNozzleType(used_nozzle_idx) == NozzleType::ntUndefine ||
ext_data.extders[used_nozzle_idx].current_nozzle_diameter <= 0.0f || ext_data.GetNozzleDiameter(used_nozzle_idx) <= 0.0f ||
ext_data.extders[used_nozzle_idx].current_nozzle_flow_type == NozzleFlowType::NONE_FLOWTYPE) { ext_data.GetNozzleFlowType(used_nozzle_idx) == NozzleFlowType::NONE_FLOWTYPE) {
return false; return false;
} }
} }
@@ -1818,7 +1830,7 @@ static bool _is_same_nozzle_diameters(MachineObject* obj, float &tag_nozzle_diam
} }
tag_nozzle_diameter = float(opt_nozzle_diameters->get_at(used_nozzle_idx)); tag_nozzle_diameter = float(opt_nozzle_diameters->get_at(used_nozzle_idx));
if (tag_nozzle_diameter != obj->m_extder_data.extders[used_nozzle_idx].current_nozzle_diameter) if (tag_nozzle_diameter != obj->GetExtderSystem()->GetNozzleDiameter(used_nozzle_idx))
{ {
mismatch_nozzle_id = used_nozzle_idx; mismatch_nozzle_id = used_nozzle_idx;
return false; return false;
@@ -1833,9 +1845,9 @@ static bool _is_same_nozzle_diameters(MachineObject* obj, float &tag_nozzle_diam
return true; return true;
} }
bool SelectMachineDialog::is_nozzle_hrc_matched(const Extder& extruder, std::string& filament_type) const bool SelectMachineDialog::is_nozzle_hrc_matched(const DevExtder* extruder, std::string& filament_type) const
{ {
auto printer_nozzle_hrc = Print::get_hrc_by_nozzle_type(extruder.current_nozzle_type); auto printer_nozzle_hrc = Print::get_hrc_by_nozzle_type(extruder->GetNozzleType());
auto preset_bundle = wxGetApp().preset_bundle; auto preset_bundle = wxGetApp().preset_bundle;
MaterialHash::const_iterator iter = m_materialList.begin(); MaterialHash::const_iterator iter = m_materialList.begin();
@@ -1864,7 +1876,7 @@ bool SelectMachineDialog::is_same_printer_model()
MachineObject* obj_ = dev->get_selected_machine(); MachineObject* obj_ = dev->get_selected_machine();
assert(obj_->dev_id == m_printer_last_select); assert(obj_->get_dev_id() == m_printer_last_select);
if (obj_ == nullptr) { if (obj_ == nullptr) {
return result; return result;
} }
@@ -1972,7 +1984,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
std::string action; std::string action;
wxString info; wxString info;
wxString wiki_url; wxString wiki_url;
DeviceManager::check_filaments_in_blacklist_url(obj_->printer_type, filament_brand, filament_type, m_ams_mapping_result[i].filament_id, ams_id, slot_id, "", in_blacklist, DevFilaBlacklist::check_filaments_in_blacklist_url(obj_->printer_type, filament_brand, filament_type, m_ams_mapping_result[i].filament_id, ams_id, slot_id, "", in_blacklist,
action, info, wiki_url); action, info, wiki_url);
if (in_blacklist && action == "warning") { if (in_blacklist && action == "warning") {
confirm_text.push_back(ConfirmBeforeSendInfo(info, wiki_url)); confirm_text.push_back(ConfirmBeforeSendInfo(info, wiki_url));
@@ -1984,13 +1996,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
bool has_show_traditional_timelapse_waring = false; bool has_show_traditional_timelapse_waring = false;
for (auto warning : plate->get_slice_result()->warnings) { for (auto warning : plate->get_slice_result()->warnings) {
if (warning.msg == BED_TEMP_TOO_HIGH_THAN_FILAMENT) { if (warning.msg == NOT_SUPPORT_TRADITIONAL_TIMELAPSE) {
if ((obj_->get_printer_is_enclosed())){
// confirm_text.push_back(Plater::get_slice_warning_string(warning) + "\n");
// has_slice_warnings = true;
}
}
else if (warning.msg == NOT_SUPPORT_TRADITIONAL_TIMELAPSE) {
if (!has_show_traditional_timelapse_waring && (m_checkbox_list["timelapse"]->getValue() == "on")) { if (!has_show_traditional_timelapse_waring && (m_checkbox_list["timelapse"]->getValue() == "on")) {
confirm_text.push_back(ConfirmBeforeSendInfo(Plater::get_slice_warning_string(warning))); confirm_text.push_back(ConfirmBeforeSendInfo(Plater::get_slice_warning_string(warning)));
has_show_traditional_timelapse_waring = true; has_show_traditional_timelapse_waring = true;
@@ -2019,7 +2025,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
//check for unidentified material //check for unidentified material
auto mapping_result = m_mapping_popup.parse_ams_mapping(obj_->amsList); auto mapping_result = m_mapping_popup.parse_ams_mapping(obj_->GetFilaSystem()->GetAmsList());
auto has_unknown_filament = false; auto has_unknown_filament = false;
for (auto i = 0; i < m_ams_mapping_result.size(); i++) { for (auto i = 0; i < m_ams_mapping_result.size(); i++) {
@@ -2248,14 +2254,16 @@ void SelectMachineDialog::update_option_opts(MachineObject *obj)
} }
/*nozzle_offset_cali*/ /*nozzle_offset_cali*/
if (obj->is_support_nozzle_offset_cali) { bool support_cali_nozzle_offset = obj->GetConfig()->SupportCalibrationNozzleOffset();
if (support_cali_nozzle_offset) {
m_checkbox_list["nozzle_offset_cali"]->update_options(ops_auto, _L("Calibrate nozzle offsets to enhance print quality.\n*Automatic mode: Check for calibration before printing. Skip if unnecessary.")); m_checkbox_list["nozzle_offset_cali"]->update_options(ops_auto, _L("Calibrate nozzle offsets to enhance print quality.\n*Automatic mode: Check for calibration before printing. Skip if unnecessary."));
} }
m_checkbox_list["nozzle_offset_cali"]->Show(obj->is_support_nozzle_offset_cali); m_checkbox_list["nozzle_offset_cali"]->Show(support_cali_nozzle_offset);
/*flow_cali*/ /*flow_cali*/
if (obj->is_support_pa_calibration) { if (obj->is_support_pa_calibration) {
if (obj->is_support_auto_flow_calibration && can_support_auto_cali()) { if (obj->GetConfig()->SupportCalibrationPA_FlowAuto() && can_support_pa_auto_cali())
{
m_checkbox_list["flow_cali"]->update_options(ops_auto, _L("This process determines the dynamic flow values to improve overall print quality.\n*Automatic mode: Skip if the filament was calibrated recently.")); m_checkbox_list["flow_cali"]->update_options(ops_auto, _L("This process determines the dynamic flow values to improve overall print quality.\n*Automatic mode: Skip if the filament was calibrated recently."));
} else { } else {
m_checkbox_list["flow_cali"]->update_options(ops_no_auto, _L("This process determines the dynamic flow values to improve overall print quality.")); m_checkbox_list["flow_cali"]->update_options(ops_no_auto, _L("This process determines the dynamic flow values to improve overall print quality."));
@@ -2304,6 +2312,10 @@ bool SelectMachineDialog::is_enable_external_change_assist(std::vector<FilamentI
void SelectMachineDialog::load_option_vals(MachineObject *obj) void SelectMachineDialog::load_option_vals(MachineObject *obj)
{ {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " start"
<< ", dev_id = " << (obj ? obj->get_dev_id() : "NULL")
<< ", sending mode= " << m_is_in_sending_mode;
if (m_is_in_sending_mode) { return;} if (m_is_in_sending_mode) { return;}
AppConfig* config = wxGetApp().app_config; AppConfig* config = wxGetApp().app_config;
@@ -2384,7 +2396,7 @@ void SelectMachineDialog::on_send_print()
if (!dev) return; if (!dev) return;
MachineObject* obj_ = dev->get_selected_machine(); MachineObject* obj_ = dev->get_selected_machine();
assert(obj_->dev_id == m_printer_last_select); assert(obj_->get_dev_id() == m_printer_last_select);
if (obj_ == nullptr) { return; } if (obj_ == nullptr) { return; }
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", print_job: for send task, current printer id = " << m_printer_last_select << std::endl; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", print_job: for send task, current printer id = " << m_printer_last_select << std::endl;
@@ -2454,7 +2466,7 @@ void SelectMachineDialog::on_send_print()
} }
m_print_job = std::make_shared<PrintJob>(m_printer_last_select); m_print_job = std::make_shared<PrintJob>(m_printer_last_select);
m_print_job->m_dev_ip = obj_->dev_ip; m_print_job->m_dev_ip = obj_->get_dev_ip();
m_print_job->m_ftp_folder = obj_->get_ftp_folder(); m_print_job->m_ftp_folder = obj_->get_ftp_folder();
m_print_job->m_access_code = obj_->get_access_code(); m_print_job->m_access_code = obj_->get_access_code();
#if !BBL_RELEASE_TO_PUBLIC #if !BBL_RELEASE_TO_PUBLIC
@@ -2505,7 +2517,7 @@ void SelectMachineDialog::on_send_print()
BOOST_LOG_TRIVIAL(error) << "build_nozzle_info errors"; BOOST_LOG_TRIVIAL(error) << "build_nozzle_info errors";
} }
m_print_job->has_sdcard = obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL; m_print_job->has_sdcard = obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::HAS_SDCARD_NORMAL;
bool timelapse_option = m_checkbox_list["timelapse"]->IsShown()?true:false; bool timelapse_option = m_checkbox_list["timelapse"]->IsShown()?true:false;
@@ -2526,7 +2538,7 @@ void SelectMachineDialog::on_send_print()
m_checkbox_list["nozzle_offset_cali"]->getValueInt() m_checkbox_list["nozzle_offset_cali"]->getValueInt()
); );
if (obj_->has_ams()) { if (obj_->HasAms()) {
bool has_ext = _HasExt(m_ams_mapping_result); bool has_ext = _HasExt(m_ams_mapping_result);
bool has_ams = _HasAms(m_ams_mapping_result); bool has_ams = _HasAms(m_ams_mapping_result);
@@ -2557,7 +2569,7 @@ void SelectMachineDialog::on_send_print()
// update ota version // update ota version
NetworkAgent* agent = wxGetApp().getAgent(); NetworkAgent* agent = wxGetApp().getAgent();
if (agent) { if (agent) {
std::string dev_ota_str = "dev_ota_ver:" + obj_->dev_id; std::string dev_ota_str = "dev_ota_ver:" + obj_->get_dev_id();
agent->track_update_property(dev_ota_str, obj_->get_ota_version()); agent->track_update_property(dev_ota_str, obj_->get_ota_version());
} }
@@ -2716,7 +2728,7 @@ void SelectMachineDialog::reset_timeout()
static bool static bool
_compare_obj_names(MachineObject* obj1, MachineObject* obj2) _compare_obj_names(MachineObject* obj1, MachineObject* obj2)
{ {
return obj1->dev_name < obj2->dev_name; return obj1->get_dev_name() < obj2->get_dev_name();
} }
/******************************************************************* /*******************************************************************
@@ -2739,7 +2751,7 @@ _collect_sorted_machines(Slic3r::DeviceManager* dev_manager,
/* Step 1 :Collect the target and compatible types*/ /* Step 1 :Collect the target and compatible types*/
PresetBundle* preset_bundle = wxGetApp().preset_bundle; PresetBundle* preset_bundle = wxGetApp().preset_bundle;
const std::string& printer_type = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle); const std::string& printer_type = preset_bundle->printers.get_edited_preset().get_printer_type(preset_bundle);
const auto& compatible_types_list = dev_manager->get_compatible_machine(printer_type); const auto& compatible_types_list = DevPrinterConfigUtil::get_compatible_machine(printer_type);
std::set<std::string> compatible_types_set(compatible_types_list.begin(), compatible_types_list.end()); std::set<std::string> compatible_types_set(compatible_types_list.begin(), compatible_types_list.end());
/* Step 2: collect different machine list*/ /* Step 2: collect different machine list*/
@@ -2817,7 +2829,7 @@ void SelectMachineDialog::update_user_printer()
m_printer_box->SetPrinters(m_list); m_printer_box->SetPrinters(m_list);
if (!m_list.empty()) if (!m_list.empty())
{ {
m_printer_last_select = m_list.front()->dev_id; m_printer_last_select = m_list.front()->get_dev_id();
m_printer_box->GetPrinterComboBox()->SetSelection(0); m_printer_box->GetPrinterComboBox()->SetSelection(0);
wxCommandEvent event(wxEVT_COMBOBOX); wxCommandEvent event(wxEVT_COMBOBOX);
event.SetEventObject(m_printer_box->GetPrinterComboBox()); event.SetEventObject(m_printer_box->GetPrinterComboBox());
@@ -2932,17 +2944,18 @@ void SelectMachineDialog::on_timer(wxTimerEvent &event)
MachineObject* obj_ = dev_->get_my_machine(m_printer_last_select); MachineObject* obj_ = dev_->get_my_machine(m_printer_last_select);
if(!obj_) return; if(!obj_) return;
if (obj_->m_extder_data.total_extder_count > 1) { if (obj_->GetExtderSystem()->GetTotalExtderCount() > 1)
{
change_materialitem_tip(false); /*mapping to both ams and ext, is supported while total_extder_count is 2*/ change_materialitem_tip(false); /*mapping to both ams and ext, is supported while total_extder_count is 2*/
} else { } else {
change_materialitem_tip(true); change_materialitem_tip(true);
} }
if ( obj_->amsList.empty() if (!obj_->GetFilaSystem()->HasAms()
|| obj_->ams_exist_bits == 0 || obj_->ams_exist_bits == 0
|| !obj_->is_support_filament_backup || !obj_->is_support_filament_backup
|| !obj_->is_support_show_filament_backup || !obj_->GetExtderSystem()->HasFilamentBackup()
|| !obj_->ams_auto_switch_filament_flag || !obj_->GetFilaSystem()->IsAutoRefillEnabled()
|| !_HasAms(m_ams_mapping_result)) { || !_HasAms(m_ams_mapping_result)) {
if (m_ams_backup_tip->IsShown()) { if (m_ams_backup_tip->IsShown()) {
m_ams_backup_tip->Hide(); m_ams_backup_tip->Hide();
@@ -2998,7 +3011,7 @@ void SelectMachineDialog::on_selection_changed(wxCommandEvent &event)
m_printer_box->GetPrinterComboBox()->Update(); m_printer_box->GetPrinterComboBox()->Update();
} }
m_printer_last_select = m_list[i]->dev_id; m_printer_last_select = m_list[i]->get_dev_id();
obj = m_list[i]; obj = m_list[i];
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "for send task, current printer id = " << m_printer_last_select << std::endl; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "for send task, current printer id = " << m_printer_last_select << std::endl;
@@ -3011,12 +3024,12 @@ void SelectMachineDialog::on_selection_changed(wxCommandEvent &event)
obj->command_request_push_all(); obj->command_request_push_all();
if (!dev->get_selected_machine()) { if (!dev->get_selected_machine()) {
dev->set_selected_machine(m_printer_last_select); dev->set_selected_machine(m_printer_last_select);
}else if (dev->get_selected_machine()->dev_id != m_printer_last_select) { }else if (dev->get_selected_machine()->get_dev_id() != m_printer_last_select) {
dev->set_selected_machine(m_printer_last_select); dev->set_selected_machine(m_printer_last_select);
} }
// Has changed machine unrecoverably // Has changed machine unrecoverably
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj); GUI::wxGetApp().sidebar().load_ams_list(obj->get_dev_id(), obj);
m_check_flag = false; m_check_flag = false;
} else { } else {
BOOST_LOG_TRIVIAL(error) << "on_selection_changed dev_id not found"; BOOST_LOG_TRIVIAL(error) << "on_selection_changed dev_id not found";
@@ -3035,7 +3048,7 @@ void SelectMachineDialog::update_ams_check(MachineObject *obj)
if (!obj) {return;} if (!obj) {return;}
if (!obj->is_enable_np) { if (!obj->is_enable_np) {
if (obj->has_ams()) { if (obj->HasAms()) {
change_materialitem_tip(false); change_materialitem_tip(false);
} }
else { else {
@@ -3080,7 +3093,7 @@ void SelectMachineDialog::update_filament_change_count()
int hand_changes_count = curr.filament_change_count - best.filament_change_count; int hand_changes_count = curr.filament_change_count - best.filament_change_count;
int saving_weight = curr.filament_flush_weight - best.filament_flush_weight; int saving_weight = curr.filament_flush_weight - best.filament_flush_weight;
if (obj->m_extder_data.total_extder_count > 1) { m_link_edit_nozzle->Show(true); } if (obj->GetExtderSystem()->GetTotalExtderCount() > 1) { m_link_edit_nozzle->Show(true); }
if (hand_changes_count > 0 || saving_weight > 0) { if (hand_changes_count > 0 || saving_weight > 0) {
m_mapping_sugs_sizer->Show(true); m_mapping_sugs_sizer->Show(true);
@@ -3123,7 +3136,7 @@ static wxString _check_kval_not_default(const MachineObject* obj, const std::vec
static wxString _get_nozzle_name(int total_ext_count, int ext_id) static wxString _get_nozzle_name(int total_ext_count, int ext_id)
{ {
if (total_ext_count == 2) { if (total_ext_count == 2) {
if (ext_id == MAIN_NOZZLE_ID) { if (ext_id == MAIN_EXTRUDER_ID) {
return _L("right nozzle"); return _L("right nozzle");
} else { } else {
return _L("left nozzle"); return _L("left nozzle");
@@ -3149,7 +3162,7 @@ static wxString _get_ext_loc_str(const std::unordered_set<int>& extruders, int t
else if (extruders.size() == 1) else if (extruders.size() == 1)
{ {
auto iter = extruders.begin(); auto iter = extruders.begin();
if (*iter == MAIN_NOZZLE_ID) if (*iter == MAIN_EXTRUDER_ID)
{ {
return _L("right extruder"); return _L("right extruder");
} }
@@ -3226,7 +3239,8 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
reset_timeout(); reset_timeout();
/*check print all*/ /*check print all*/
if (!obj_->is_support_print_all && m_print_plate_idx == PLATE_ALL_IDX) { if (!obj_->GetConfig()->SupportPrintAllPlates() && m_print_plate_idx == PLATE_ALL_IDX)
{
show_status(PrintDialogStatus::PrintStatusNotSupportedPrintAll); show_status(PrintDialogStatus::PrintStatusNotSupportedPrintAll);
return; return;
} }
@@ -3289,29 +3303,29 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
} else if (obj_->is_in_printing() || obj_->ams_status_main == AMS_STATUS_MAIN_FILAMENT_CHANGE) { } else if (obj_->is_in_printing() || obj_->ams_status_main == AMS_STATUS_MAIN_FILAMENT_CHANGE) {
show_status(PrintDialogStatus::PrintStatusInPrinting); show_status(PrintDialogStatus::PrintStatusInPrinting);
return; return;
} else if (!obj_->is_support_print_without_sd && (obj_->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD)) { } else if (!obj_->GetConfig()->SupportPrintWithoutSD() && (obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::NO_SDCARD)) {
show_status(PrintDialogStatus::PrintStatusNoSdcard); show_status(PrintDialogStatus::PrintStatusNoSdcard);
return; return;
} }
/*check sdcard when if lan mode printer*/ /*check sdcard when if lan mode printer*/
if (obj_->is_lan_mode_printer()) { if (obj_->is_lan_mode_printer()) {
if (obj_->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD) { if (obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::NO_SDCARD) {
show_status(PrintDialogStatus::PrintStatusLanModeNoSdcard); show_status(PrintDialogStatus::PrintStatusLanModeNoSdcard);
return; return;
} else if (obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_ABNORMAL || obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_READONLY) { } else if (obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::HAS_SDCARD_ABNORMAL || obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::HAS_SDCARD_READONLY) {
show_status(PrintDialogStatus::PrintStatusLanModeSDcardNotAvailable); show_status(PrintDialogStatus::PrintStatusLanModeSDcardNotAvailable);
return; return;
} }
} }
if (!can_support_auto_cali() && m_checkbox_list["flow_cali"]->IsShown() && m_checkbox_list["flow_cali"]->getValue() == "on") { if (!can_support_pa_auto_cali() && m_checkbox_list["flow_cali"]->IsShown() && m_checkbox_list["flow_cali"]->getValue() == "on") {
show_status(PrintDialogStatus::PrintStatusTPUUnsupportAutoCali); show_status(PrintDialogStatus::PrintStatusTPUUnsupportAutoCali);
return; return;
} }
/*disable print when there is no mapping*/ /*disable print when there is no mapping*/
if (obj_->m_extder_data.total_extder_count > 1) { if (obj_->GetExtderSystem()->GetTotalExtderCount() > 1) {
for (auto mres : m_ams_mapping_result) { for (auto mres : m_ams_mapping_result) {
if (mres.ams_id.empty() && mres.slot_id.empty()) { if (mres.ams_id.empty() && mres.slot_id.empty()) {
show_status(PrintDialogStatus::PrintStatusInvalidMapping); show_status(PrintDialogStatus::PrintStatusInvalidMapping);
@@ -3325,13 +3339,13 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
/*the nozzle type of preset and machine are different*/ /*the nozzle type of preset and machine are different*/
if (nozzle_nums > 1 && m_print_type == FROM_NORMAL) { if (nozzle_nums > 1 && m_print_type == FROM_NORMAL) {
if (!_is_nozzle_data_valid(obj_, obj_->m_extder_data)) { if (!_is_nozzle_data_valid(obj_, *obj_->GetExtderSystem())) {
show_status(PrintDialogStatus::PrintStatusNozzleDataInvalid); show_status(PrintDialogStatus::PrintStatusNozzleDataInvalid);
return; return;
} }
wxString error_message; wxString error_message;
if (!is_nozzle_type_match(obj_->m_extder_data, error_message)) { if (!is_nozzle_type_match(*obj_->GetExtderSystem(), error_message)) {
std::vector<wxString> params{error_message}; std::vector<wxString> params{error_message};
params.emplace_back(_L("Tips: If you changed your nozzle of your printer lately, Please go to 'Device -> Printer parts' to change your nozzle setting.")); params.emplace_back(_L("Tips: If you changed your nozzle of your printer lately, Please go to 'Device -> Printer parts' to change your nozzle setting."));
show_status(PrintDialogStatus::PrintStatusNozzleMatchInvalid, params); show_status(PrintDialogStatus::PrintStatusNozzleMatchInvalid, params);
@@ -3347,9 +3361,9 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
if (!_is_same_nozzle_diameters(obj_, nozzle_diameter, mismatch_nozzle_id)) if (!_is_same_nozzle_diameters(obj_, nozzle_diameter, mismatch_nozzle_id))
{ {
std::vector<wxString> msg_params; std::vector<wxString> msg_params;
if (obj_->m_extder_data.total_extder_count == 2) { if (obj_->GetExtderSystem()->GetTotalExtderCount() == 2) {
wxString mismatch_nozzle_str; wxString mismatch_nozzle_str;
if (mismatch_nozzle_id == MAIN_NOZZLE_ID) { if (mismatch_nozzle_id == MAIN_EXTRUDER_ID) {
mismatch_nozzle_str = _L("right nozzle"); mismatch_nozzle_str = _L("right nozzle");
} else { } else {
mismatch_nozzle_str = _L("left nozzle"); mismatch_nozzle_str = _L("left nozzle");
@@ -3358,13 +3372,13 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
const wxString &nozzle_config = wxString::Format(_L("The %s diameter(%.1fmm) of current printer doesn't match with the slicing file (%.1fmm). " const wxString &nozzle_config = wxString::Format(_L("The %s diameter(%.1fmm) of current printer doesn't match with the slicing file (%.1fmm). "
"Please make sure the nozzle installed matches with settings in printer, then set the " "Please make sure the nozzle installed matches with settings in printer, then set the "
"corresponding printer preset when slicing."), "corresponding printer preset when slicing."),
mismatch_nozzle_str, obj_->m_extder_data.extders[mismatch_nozzle_id].current_nozzle_diameter, nozzle_diameter); mismatch_nozzle_str, obj_->GetExtderSystem()->GetNozzleDiameter(mismatch_nozzle_id), nozzle_diameter);
msg_params.emplace_back(nozzle_config); msg_params.emplace_back(nozzle_config);
} else { } else {
const wxString &nozzle_config = wxString::Format(_L("The current nozzle diameter (%.1fmm) doesn't match with the slicing file (%.1fmm). " const wxString &nozzle_config = wxString::Format(_L("The current nozzle diameter (%.1fmm) doesn't match with the slicing file (%.1fmm). "
"Please make sure the nozzle installed matches with settings in printer, then set the " "Please make sure the nozzle installed matches with settings in printer, then set the "
"corresponding printer preset when slicing."), "corresponding printer preset when slicing."),
obj_->m_extder_data.extders[0].current_nozzle_diameter, nozzle_diameter); obj_->GetExtderSystem()->GetNozzleDiameter(0), nozzle_diameter);
msg_params.emplace_back(nozzle_config); msg_params.emplace_back(nozzle_config);
} }
@@ -3374,14 +3388,14 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
} }
const auto &used_nozzle_idxes = _get_used_nozzle_idxes(); const auto &used_nozzle_idxes = _get_used_nozzle_idxes();
for (const auto &extder : obj_->m_extder_data.extders) { for (const auto &extder : obj_->GetExtderSystem()->GetExtruders()) {
if (used_nozzle_idxes.count(extder.nozzle_id) == 0) { continue; } if (used_nozzle_idxes.count(extder.GetNozzleId()) == 0) { continue; }
std::string filament_type; std::string filament_type;
if (!is_nozzle_hrc_matched(extder, filament_type)) { if (!is_nozzle_hrc_matched(&extder, filament_type)) {
std::vector<wxString> error_msg; std::vector<wxString> error_msg;
error_msg.emplace_back(wxString::Format(_L("The hardness of current material (%s) exceeds the hardness of %s(%s). Please verify the nozzle or material settings and try again."), error_msg.emplace_back(wxString::Format(_L("The hardness of current material (%s) exceeds the hardness of %s(%s). Please verify the nozzle or material settings and try again."),
filament_type, _get_nozzle_name(obj_->m_extder_data.total_extder_count, extder.nozzle_id), format_steel_name(extder.current_nozzle_type))); filament_type, _get_nozzle_name(obj_->GetExtderSystem()->GetTotalExtderCount(), extder.GetNozzleId()), format_steel_name(extder.GetNozzleType())));
show_status(PrintDialogStatus::PrintStatusNozzleTypeMismatch, error_msg); show_status(PrintDialogStatus::PrintStatusNozzleTypeMismatch, error_msg);
return; return;
} }
@@ -3397,12 +3411,12 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
} }
} }
if (obj_->is_ams_on_settingup()) { if (obj_->GetFilaSystem()->IsAmsSettingUp()) {
show_status(PrintDialogStatus::PrintStatusAmsOnSettingup); show_status(PrintDialogStatus::PrintStatusAmsOnSettingup);
return; return;
} }
if (!m_ams_mapping_res && !obj_->is_valid_mapping_result(m_ams_mapping_result)) { if (!m_ams_mapping_res && !DevMappingUtil::is_valid_mapping_result(obj_, m_ams_mapping_result)) {
show_status(PrintDialogStatus::PrintStatusAmsMappingInvalid); show_status(PrintDialogStatus::PrintStatusAmsMappingInvalid);
return; return;
} }
@@ -3425,7 +3439,7 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
std::string action; std::string action;
wxString info; wxString info;
wxString wiki_url; wxString wiki_url;
DeviceManager::check_filaments_in_blacklist_url(obj_->printer_type, filament_brand, filament_type, m_ams_mapping_result[i].filament_id, ams_id, slot_id, "", in_blacklist, DevFilaBlacklist::check_filaments_in_blacklist_url(obj_->printer_type, filament_brand, filament_type, m_ams_mapping_result[i].filament_id, ams_id, slot_id, "", in_blacklist,
action, info, wiki_url); action, info, wiki_url);
if (in_blacklist) { if (in_blacklist) {
@@ -3452,7 +3466,7 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
if (item.ams_id.empty()) continue; if (item.ams_id.empty()) continue;
int extruder_id = obj_->get_extruder_id_by_ams_id(item.ams_id); int extruder_id = obj_->get_extruder_id_by_ams_id(item.ams_id);
if (DeviceManager::is_virtual_slot(stoi(item.ams_id))) if (devPrinterUtil::IsVirtualSlot(item.ams_id))
extruder_status[extruder_id].has_vt_slot = true; extruder_status[extruder_id].has_vt_slot = true;
else else
extruder_status[extruder_id].has_ams = true; extruder_status[extruder_id].has_ams = true;
@@ -3469,7 +3483,7 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
// return; // return;
} }
} else { } else {
if (obj_->is_valid_mapping_result(m_ams_mapping_result)) { if (DevMappingUtil::is_valid_mapping_result(obj_, m_ams_mapping_result)) {
if (!check_sdcard_for_timelpase(obj_)) { if (!check_sdcard_for_timelpase(obj_)) {
if (has_timelapse_warning()) { if (has_timelapse_warning()) {
show_status(PrintDialogStatus::PrintStatusTimelapseWarning); show_status(PrintDialogStatus::PrintStatusTimelapseWarning);
@@ -3490,13 +3504,13 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
} }
/*Check the tpu at right*/ /*Check the tpu at right*/
if (obj_->m_extder_data.total_extder_count == 2) { if (obj_->GetExtderSystem()->GetTotalExtderCount() == 2) {
for (const FilamentInfo& item : m_ams_mapping_result) { for (const FilamentInfo& item : m_ams_mapping_result) {
if (item.ams_id.empty()) continue; if (item.ams_id.empty()) continue;
if (item.type.compare("TPU") != 0 && item.type.compare("TPU-AMS") != 0) { continue; } if (item.type.compare("TPU") != 0 && item.type.compare("TPU-AMS") != 0) { continue; }
int extruder_id = obj_->get_extruder_id_by_ams_id(item.ams_id); int extruder_id = obj_->get_extruder_id_by_ams_id(item.ams_id);
if (extruder_id == MAIN_NOZZLE_ID) { if (extruder_id == MAIN_EXTRUDER_ID) {
show_status(PrintDialogStatus::PrintStatusWarningTpuRightColdPulling); show_status(PrintDialogStatus::PrintStatusWarningTpuRightColdPulling);
break; break;
} }
@@ -3513,22 +3527,22 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
try try
{ {
int chamber_temp = chamber_temperatures->values[item.id]; int chamber_temp = chamber_temperatures->values[item.id];
if (chamber_temp >= obj_->chamber_temp_switch_heat) {// check close door if (chamber_temp >= obj_->GetConfig()->GetChamberTempSwitchHeat()) {// check close door
show_status(PrintDialogStatus::PrintStatusFilamentWarningHighChamberTempCloseDoor); show_status(PrintDialogStatus::PrintStatusFilamentWarningHighChamberTempCloseDoor);
if (PrePrintChecker::is_error(PrintDialogStatus::PrintStatusFilamentWarningHighChamberTempCloseDoor)) { return; } if (PrePrintChecker::is_error(PrintDialogStatus::PrintStatusFilamentWarningHighChamberTempCloseDoor)) { return; }
} }
for (const auto& extder : obj_->m_extder_data.extders) { // check vitrification for (const auto& extder : obj_->GetExtderSystem()->GetExtruders()) { // check vitrification
if (extder.ext_has_filament) { if (extder.HasFilamentInExt()) {
const auto& fila_id = obj_->get_filament_id(extder.snow.ams_id, extder.snow.slot_id); const auto& fila_id = obj_->get_filament_id(extder.GetSlotNow().ams_id, extder.GetSlotNow().slot_id);
auto filament_info = wxGetApp().preset_bundle->get_filament_by_filament_id(fila_id); auto filament_info = wxGetApp().preset_bundle->get_filament_by_filament_id(fila_id);
if (filament_info) { if (filament_info) {
if (filament_info->temperature_vitrification - chamber_temp <= 5) { if (filament_info->temperature_vitrification - chamber_temp <= 5) {
known_fila_soften_extruders.insert(extder.id); known_fila_soften_extruders.insert(extder.GetExtId());
} }
} else { } else {
// the minimum temperature_vitrification of the known filaments is 43 degrees // the minimum temperature_vitrification of the known filaments is 43 degrees
if (43 - chamber_temp <= 5) { unknown_fila_soften_extruders.insert(extder.id); } if (43 - chamber_temp <= 5) { unknown_fila_soften_extruders.insert(extder.GetExtId()); }
} }
} }
} }
@@ -3538,14 +3552,14 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
if (!known_fila_soften_extruders.empty()) { if (!known_fila_soften_extruders.empty()) {
const wxString& msg = wxString::Format(_L("The filament on %s may soften. Please unload."), const wxString& msg = wxString::Format(_L("The filament on %s may soften. Please unload."),
_get_ext_loc_str(known_fila_soften_extruders, obj_->m_extder_data.total_extder_count)); _get_ext_loc_str(known_fila_soften_extruders, obj_->GetExtderSystem()->GetTotalExtderCount()));
show_status(PrintDialogStatus::PrintStatusFilamentWarningHighChamberTempSoft, std::vector<wxString> {msg}); show_status(PrintDialogStatus::PrintStatusFilamentWarningHighChamberTempSoft, std::vector<wxString> {msg});
if (PrePrintChecker::is_error(PrintDialogStatus::PrintStatusFilamentWarningHighChamberTempSoft)) { return; } if (PrePrintChecker::is_error(PrintDialogStatus::PrintStatusFilamentWarningHighChamberTempSoft)) { return; }
} }
if (!unknown_fila_soften_extruders.empty()) { if (!unknown_fila_soften_extruders.empty()) {
const wxString& msg = wxString::Format(_L("The filament on %s is unknown and may soften. Please set filament."), const wxString& msg = wxString::Format(_L("The filament on %s is unknown and may soften. Please set filament."),
_get_ext_loc_str(unknown_fila_soften_extruders, obj_->m_extder_data.total_extder_count)); _get_ext_loc_str(unknown_fila_soften_extruders, obj_->GetExtderSystem()->GetTotalExtderCount()));
show_status(PrintDialogStatus::PrintStatusFilamentWarningUnknownHighChamberTempSoft, std::vector<wxString> {msg}); show_status(PrintDialogStatus::PrintStatusFilamentWarningUnknownHighChamberTempSoft, std::vector<wxString> {msg});
if (PrePrintChecker::is_error(PrintDialogStatus::PrintStatusFilamentWarningUnknownHighChamberTempSoft)) { return; } if (PrePrintChecker::is_error(PrintDialogStatus::PrintStatusFilamentWarningUnknownHighChamberTempSoft)) { return; }
} }
@@ -3573,7 +3587,7 @@ bool SelectMachineDialog::has_timelapse_warning(wxString &msg_text)
return false; return false;
} }
bool SelectMachineDialog::can_support_auto_cali() bool SelectMachineDialog::can_support_pa_auto_cali()
{ {
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager(); DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) if (!dev)
@@ -3582,7 +3596,7 @@ bool SelectMachineDialog::can_support_auto_cali()
if (!obj) if (!obj)
return true; return true;
std::vector<std::string> unsupport_auto_cali_filaments = DeviceManager::get_unsupport_auto_cali_filaments(obj->printer_type); std::vector<std::string> unsupport_auto_cali_filaments = DevPrinterConfigUtil::get_unsupport_auto_cali_filaments(obj->printer_type);
if (!unsupport_auto_cali_filaments.empty()) { if (!unsupport_auto_cali_filaments.empty()) {
auto iter = std::find_if(m_filaments.begin(), m_filaments.end(), auto iter = std::find_if(m_filaments.begin(), m_filaments.end(),
[&unsupport_auto_cali_filaments](const FilamentInfo &item) { [&unsupport_auto_cali_filaments](const FilamentInfo &item) {
@@ -3885,7 +3899,7 @@ void SelectMachineDialog::reset_and_sync_ams_list()
size_t nozzle_nums = full_config.option<ConfigOptionFloats>("nozzle_diameter")->values.size(); size_t nozzle_nums = full_config.option<ConfigOptionFloats>("nozzle_diameter")->values.size();
if (nozzle_nums > 1) if (nozzle_nums > 1)
{ {
if (obj_ && can_hybrid_mapping(obj_->m_extder_data)) if (obj_ && can_hybrid_mapping(*obj_->GetExtderSystem()))
{ {
m_mapping_popup.set_show_type(ShowType::LEFT_AND_RIGHT); m_mapping_popup.set_show_type(ShowType::LEFT_AND_RIGHT);
} }
@@ -3906,7 +3920,7 @@ void SelectMachineDialog::reset_and_sync_ams_list()
pos.y += item->GetRect().height; pos.y += item->GetRect().height;
m_mapping_popup.Move(pos); m_mapping_popup.Move(pos);
if (obj_ && obj_->dev_id == m_printer_last_select) { if (obj_ && obj_->get_dev_id() == m_printer_last_select) {
m_mapping_popup.set_parent_item(item); m_mapping_popup.set_parent_item(item);
m_mapping_popup.set_only_show_ext_spool(false); m_mapping_popup.set_only_show_ext_spool(false);
m_mapping_popup.set_current_filament_id(extruder); m_mapping_popup.set_current_filament_id(extruder);
@@ -4265,7 +4279,7 @@ void SelectMachineDialog::set_default_from_sdcard()
MachineObject *obj_ = dev_manager->get_selected_machine(); MachineObject *obj_ = dev_manager->get_selected_machine();
if (!obj_) { return; }; if (!obj_) { return; };
m_printer_box->SetPrinterName(wxString::FromUTF8(obj_->dev_name)); m_printer_box->SetPrinterName(wxString::FromUTF8(obj_->get_dev_name()));
m_print_plate_total = m_required_data_plate_data_list.size(); m_print_plate_total = m_required_data_plate_data_list.size();
update_page_turn_state(true); update_page_turn_state(true);
@@ -4398,7 +4412,7 @@ void SelectMachineDialog::set_default_from_sdcard()
m_mapping_popup.Move(pos); m_mapping_popup.Move(pos);
if (diameters_count > 1) { if (diameters_count > 1) {
if (obj_ && can_hybrid_mapping(obj_->m_extder_data)) { if (obj_ && can_hybrid_mapping(*obj_->GetExtderSystem())) {
m_mapping_popup.set_show_type(ShowType::LEFT_AND_RIGHT); m_mapping_popup.set_show_type(ShowType::LEFT_AND_RIGHT);
} else if (m_filaments_map[m_current_filament_id] == 1) { } else if (m_filaments_map[m_current_filament_id] == 1) {
m_mapping_popup.set_show_type(ShowType::LEFT); m_mapping_popup.set_show_type(ShowType::LEFT);
@@ -4409,7 +4423,7 @@ void SelectMachineDialog::set_default_from_sdcard()
m_mapping_popup.set_show_type(ShowType::RIGHT); m_mapping_popup.set_show_type(ShowType::RIGHT);
} }
if (obj_ && obj_->dev_id == m_printer_last_select) if (obj_ && obj_->get_dev_id() == m_printer_last_select)
{ {
m_mapping_popup.set_parent_item(item); m_mapping_popup.set_parent_item(item);
m_mapping_popup.set_current_filament_id(fo.id); m_mapping_popup.set_current_filament_id(fo.id);
@@ -5046,13 +5060,13 @@ static wxString _get_tips(MachineObject* obj_)
tips = obj_->get_printer_type_display_str(); tips = obj_->get_printer_type_display_str();
wxString ext_diameter; wxString ext_diameter;
if (obj_->m_extder_data.total_extder_count == 1) { if (obj_->GetExtderSystem()->GetTotalExtderCount() == 1) {
ext_diameter += wxString::FromDouble(obj_->m_extder_data.extders[0].current_nozzle_diameter); ext_diameter += wxString::FromDouble(obj_->GetExtderSystem()->GetNozzleDiameter(0));
ext_diameter += "mm"; ext_diameter += "mm";
} else if (obj_->m_extder_data.total_extder_count == 2) { } else if (obj_->GetExtderSystem()->GetTotalExtderCount() == 2) {
ext_diameter += wxString::FromDouble(obj_->m_extder_data.extders[1].current_nozzle_diameter);//Left ext_diameter += wxString::FromDouble(obj_->GetExtderSystem()->GetNozzleDiameter(1));//Left
ext_diameter += "/"; ext_diameter += "/";
ext_diameter += wxString::FromDouble(obj_->m_extder_data.extders[0].current_nozzle_diameter); ext_diameter += wxString::FromDouble(obj_->GetExtderSystem()->GetNozzleDiameter(0));
ext_diameter += "mm"; ext_diameter += "mm";
} else { } else {
assert(0); assert(0);
@@ -5073,7 +5087,7 @@ void PrinterInfoBox::SetPrinters(const std::vector<MachineObject*>& sorted_print
std::vector<DropDown::Item> drop_items; std::vector<DropDown::Item> drop_items;
for (MachineObject* obj : sorted_printers) for (MachineObject* obj : sorted_printers)
{ {
wxString shown_dev_name = wxString::FromUTF8(obj->dev_name); wxString shown_dev_name = wxString::FromUTF8(obj->get_dev_name());
if (obj->is_lan_mode_printer()) { if (obj->is_lan_mode_printer()) {
shown_dev_name += "(LAN)"; shown_dev_name += "(LAN)";
} }
+11 -5
View File
@@ -50,6 +50,12 @@
#define PRINT_OPT_BG_GRAY 0xF8F8F8 #define PRINT_OPT_BG_GRAY 0xF8F8F8
#define PRINT_OPT_ITEM_BG_GRAY 0xEEEEEE #define PRINT_OPT_ITEM_BG_GRAY 0xEEEEEE
// Previous definitions
namespace Slic3r{
class DevExtder;
}
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
std::string get_nozzle_volume_type_cloud_string(NozzleVolumeType nozzle_volume_type); std::string get_nozzle_volume_type_cloud_string(NozzleVolumeType nozzle_volume_type);
@@ -476,10 +482,10 @@ public:
void update_print_error_info(int code, std::string msg, std::string extra); void update_print_error_info(int code, std::string msg, std::string extra);
bool has_timelapse_warning(wxString& msg); bool has_timelapse_warning(wxString& msg);
bool has_timelapse_warning() { wxString msg; return has_timelapse_warning(msg);}; bool has_timelapse_warning() { wxString msg; return has_timelapse_warning(msg);};
bool can_support_auto_cali(); bool can_support_pa_auto_cali();
bool is_same_printer_model(); bool is_same_printer_model();
bool is_blocking_printing(MachineObject* obj_); bool is_blocking_printing(MachineObject* obj_);
bool is_nozzle_hrc_matched(const Extder& extruder, std::string& filament_type) const; bool is_nozzle_hrc_matched(const DevExtder* extruder, std::string& filament_type) const;
bool check_sdcard_for_timelpase(MachineObject* obj); bool check_sdcard_for_timelpase(MachineObject* obj);
bool is_timeout(); bool is_timeout();
int update_print_required_data(Slic3r::DynamicPrintConfig config, Slic3r::Model model, Slic3r::PlateDataPtrs plate_data_list, std::string file_name, std::string file_path); int update_print_required_data(Slic3r::DynamicPrintConfig config, Slic3r::Model model, Slic3r::PlateDataPtrs plate_data_list, std::string file_name, std::string file_path);
@@ -489,9 +495,9 @@ public:
bool do_ams_mapping(MachineObject *obj_,bool use_ams); bool do_ams_mapping(MachineObject *obj_,bool use_ams);
bool get_ams_mapping_result(std::string& mapping_array_str, std::string& mapping_array_str2, std::string& ams_mapping_info); bool get_ams_mapping_result(std::string& mapping_array_str, std::string& mapping_array_str2, std::string& ams_mapping_info);
bool build_nozzles_info(std::string& nozzles_info); bool build_nozzles_info(std::string& nozzles_info);
bool can_hybrid_mapping(ExtderData data); bool can_hybrid_mapping(DevExtderSystem data);
void auto_supply_with_ext(std::vector<AmsTray> slots); void auto_supply_with_ext(std::vector<DevAmsTray> slots);
bool is_nozzle_type_match(ExtderData data, wxString& error_message) const; bool is_nozzle_type_match(DevExtderSystem data, wxString& error_message) const;
int convert_filament_map_nozzle_id_to_task_nozzle_id(int nozzle_id); int convert_filament_map_nozzle_id_to_task_nozzle_id(int nozzle_id);
PrintFromType get_print_type() {return m_print_type;}; PrintFromType get_print_type() {return m_print_type;};
+17 -15
View File
@@ -28,6 +28,8 @@
#include "BitmapCache.hpp" #include "BitmapCache.hpp"
#include "BindDialog.hpp" #include "BindDialog.hpp"
#include "DeviceCore/DevManager.h"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
wxDEFINE_EVENT(EVT_UPDATE_WINDOWS_POSITION, wxCommandEvent); wxDEFINE_EVENT(EVT_UPDATE_WINDOWS_POSITION, wxCommandEvent);
@@ -169,7 +171,7 @@ void MachineObjectPanel::doRender(wxDC &dc)
dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900)); dc.SetTextForeground(StateColor::darkModeColorFor(SELECT_MACHINE_GREY900));
wxString dev_name = ""; wxString dev_name = "";
if (m_info) { if (m_info) {
dev_name = from_u8(m_info->dev_name); dev_name = from_u8(m_info->get_dev_name());
if (m_state == PrinterState::IN_LAN) { if (m_state == PrinterState::IN_LAN) {
dev_name += _L("(LAN)"); dev_name += _L("(LAN)");
@@ -270,7 +272,7 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
} else { } else {
if (m_info) { if (m_info) {
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id); wxGetApp().mainframe->jump_to_monitor(m_info->get_dev_id());
} }
//wxGetApp().mainframe->SetFocus(); //wxGetApp().mainframe->SetFocus();
wxCommandEvent event(EVT_DISSMISS_MACHINE_LIST); wxCommandEvent event(EVT_DISSMISS_MACHINE_LIST);
@@ -281,14 +283,14 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt)
} }
if (m_info && m_info->is_lan_mode_printer()) { if (m_info && m_info->is_lan_mode_printer()) {
if (m_info->has_access_right() && m_info->is_avaliable()) { if (m_info->has_access_right() && m_info->is_avaliable()) {
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id); wxGetApp().mainframe->jump_to_monitor(m_info->get_dev_id());
} else { } else {
wxCommandEvent event(EVT_CONNECT_LAN_PRINT); wxCommandEvent event(EVT_CONNECT_LAN_PRINT);
event.SetEventObject(this); event.SetEventObject(this);
wxPostEvent(this, event); wxPostEvent(this, event);
} }
} else { } else {
wxGetApp().mainframe->jump_to_monitor(m_info->dev_id); wxGetApp().mainframe->jump_to_monitor(m_info->get_dev_id());
} }
} else { } else {
if (m_info && m_info->is_lan_mode_printer()) { if (m_info && m_info->is_lan_mode_printer()) {
@@ -491,7 +493,7 @@ void SelectMachinePopup::update_other_devices()
{ {
DeviceManager* dev = wxGetApp().getDeviceManager(); DeviceManager* dev = wxGetApp().getDeviceManager();
if (!dev) return; if (!dev) return;
m_free_machine_list = dev->get_local_machine_list(); m_free_machine_list = dev->get_local_machinelist();
BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_other_devices start"; BOOST_LOG_TRIVIAL(trace) << "SelectMachinePopup update_other_devices start";
this->Freeze(); this->Freeze();
@@ -507,7 +509,7 @@ void SelectMachinePopup::update_other_devices()
continue; continue;
/* do not show printer in my list */ /* do not show printer in my list */
auto it = m_bind_machine_list.find(mobj->dev_id); auto it = m_bind_machine_list.find(mobj->get_dev_id());
if (it != m_bind_machine_list.end()) if (it != m_bind_machine_list.end())
continue; continue;
@@ -559,7 +561,7 @@ void SelectMachinePopup::update_other_devices()
ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code")); ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code"));
dlg.set_machine_object(mobj); dlg.set_machine_object(mobj);
if (dlg.ShowModal() == wxID_OK) { if (dlg.ShowModal() == wxID_OK) {
wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); wxGetApp().mainframe->jump_to_monitor(mobj->get_dev_id());
} }
} }
} }
@@ -570,7 +572,7 @@ void SelectMachinePopup::update_other_devices()
dlg.update_machine_info(mobj); dlg.update_machine_info(mobj);
int dlg_result = wxID_CANCEL; int dlg_result = wxID_CANCEL;
dlg_result = dlg.ShowModal(); dlg_result = dlg.ShowModal();
if (dlg_result == wxID_OK) { wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); } if (dlg_result == wxID_OK) { wxGetApp().mainframe->jump_to_monitor(mobj->get_dev_id()); }
}); });
} }
@@ -634,7 +636,7 @@ void SelectMachinePopup::update_user_devices()
std::sort(user_machine_list.begin(), user_machine_list.end(), [&](auto& a, auto&b) { std::sort(user_machine_list.begin(), user_machine_list.end(), [&](auto& a, auto&b) {
if (a.second && b.second) { if (a.second && b.second) {
return a.second->dev_name.compare(b.second->dev_name) < 0; return a.second->get_dev_name().compare(b.second->get_dev_name()) < 0;
} }
return false; return false;
}); });
@@ -690,7 +692,7 @@ void SelectMachinePopup::update_user_devices()
if (mobj) { if (mobj) {
AppConfig* config = wxGetApp().app_config; AppConfig* config = wxGetApp().app_config;
if (config) { if (config) {
config->erase_local_machine(mobj->dev_id); config->erase_local_machine(mobj->get_dev_id());
} }
mobj->set_access_code(""); mobj->set_access_code("");
@@ -739,7 +741,7 @@ void SelectMachinePopup::update_user_devices()
ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code")); ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code"));
dlg.set_machine_object(mobj); dlg.set_machine_object(mobj);
if (dlg.ShowModal() == wxID_OK) { if (dlg.ShowModal() == wxID_OK) {
wxGetApp().mainframe->jump_to_monitor(mobj->dev_id); wxGetApp().mainframe->jump_to_monitor(mobj->get_dev_id());
} }
} }
} }
@@ -776,14 +778,14 @@ bool SelectMachinePopup::search_for_printer(MachineObject* obj)
return true; return true;
} }
const auto& name = wxString::FromUTF8(obj->dev_name).ToStdString(); const auto& name = wxString::FromUTF8(obj->get_dev_name()).ToStdString();
const auto& name_it = name.find(search_text); const auto& name_it = name.find(search_text);
if (name_it != std::string::npos) { if (name_it != std::string::npos) {
return true; return true;
} }
#if !BBL_RELEASE_TO_PUBLIC #if !BBL_RELEASE_TO_PUBLIC
const auto& ip_it = obj->dev_ip.find(search_text); const auto& ip_it = obj->get_dev_ip().find(search_text);
if (ip_it != std::string::npos) { if (ip_it != std::string::npos) {
return true; return true;
} }
@@ -908,7 +910,7 @@ void EditDevNameDialog::set_machine_obj(MachineObject *obj)
{ {
m_info = obj; m_info = obj;
if (m_info) if (m_info)
m_textCtr->GetTextCtrl()->SetValue(from_u8(m_info->dev_name)); m_textCtr->GetTextCtrl()->SetValue(from_u8(m_info->get_dev_name()));
} }
void EditDevNameDialog::on_dpi_changed(const wxRect &suggested_rect) void EditDevNameDialog::on_dpi_changed(const wxRect &suggested_rect)
@@ -974,7 +976,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
auto utf8_str = new_dev_name.ToUTF8(); auto utf8_str = new_dev_name.ToUTF8();
auto name = std::string(utf8_str.data(), utf8_str.length()); auto name = std::string(utf8_str.data(), utf8_str.length());
if (m_info) if (m_info)
dev->modify_device_name(m_info->dev_id, name); dev->modify_device_name(m_info->get_dev_id(), name);
} }
DPIDialog::EndModal(wxID_CLOSE); DPIDialog::EndModal(wxID_CLOSE);
} }
+10 -7
View File
@@ -7,6 +7,9 @@
#include "Widgets/RadioBox.hpp" #include "Widgets/RadioBox.hpp"
#include <wx/listimpl.cpp> #include <wx/listimpl.cpp>
#include "DeviceCore/DevManager.h"
#include "DeviceCore/DevStorage.h"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@@ -203,7 +206,7 @@ void SendDeviceItem::doRender(wxDC& dc)
left += FromDIP(SEND_LEFT_PRINTABLE); left += FromDIP(SEND_LEFT_PRINTABLE);
//dev names //dev names
DrawTextWithEllipsis(dc, wxString::FromUTF8(get_obj()->dev_name), FromDIP(SEND_LEFT_DEV_NAME), left); DrawTextWithEllipsis(dc, wxString::FromUTF8(get_obj()->get_dev_name()), FromDIP(SEND_LEFT_DEV_NAME), left);
left += FromDIP(SEND_LEFT_DEV_NAME); left += FromDIP(SEND_LEFT_DEV_NAME);
//device state //device state
@@ -225,7 +228,7 @@ void SendDeviceItem::doRender(wxDC& dc)
//AMS //AMS
if (!obj_->has_ams()) { if (!obj_->HasAms()) {
DrawTextWithEllipsis(dc, _L("No AMS"), FromDIP(SEND_LEFT_DEV_NAME), left); DrawTextWithEllipsis(dc, _L("No AMS"), FromDIP(SEND_LEFT_DEV_NAME), left);
} }
else { else {
@@ -241,7 +244,7 @@ void SendDeviceItem::doRender(wxDC& dc)
void SendDeviceItem::post_event(wxCommandEvent&& event) void SendDeviceItem::post_event(wxCommandEvent&& event)
{ {
event.SetEventObject(this); event.SetEventObject(this);
event.SetString(obj_->dev_id); event.SetString(obj_->get_dev_id());
event.SetInt(state_selected); event.SetInt(state_selected);
wxPostEvent(this, event); wxPostEvent(this, event);
} }
@@ -488,9 +491,9 @@ BBL::PrintParams SendMultiMachinePage::request_params(MachineObject* obj)
else else
curr_plate_idx = m_plater->get_partplate_list().get_curr_plate_index() + 1; curr_plate_idx = m_plater->get_partplate_list().get_curr_plate_index() + 1;
params.dev_ip = obj->dev_ip; params.dev_ip = obj->get_dev_ip();
params.dev_id = obj->dev_id; params.dev_id = obj->get_dev_id();
params.dev_name = obj->dev_name; params.dev_name = obj->get_dev_name();
params.ftp_folder = obj->get_ftp_folder(); params.ftp_folder = obj->get_ftp_folder();
params.connection_type = obj->connection_type(); params.connection_type = obj->connection_type();
params.print_type = "from_normal"; params.print_type = "from_normal";
@@ -601,7 +604,7 @@ BBL::PrintParams SendMultiMachinePage::request_params(MachineObject* obj)
params.comments = "no_ip"; params.comments = "no_ip";
else if (obj->is_support_cloud_print_only) else if (obj->is_support_cloud_print_only)
params.comments = "low_version"; params.comments = "low_version";
else if (obj->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD) else if (obj->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::NO_SDCARD)
params.comments = "no_sdcard"; params.comments = "no_sdcard";
else if (params.password.empty()) else if (params.password.empty())
params.comments = "no_password"; params.comments = "no_password";
+20 -17
View File
@@ -23,6 +23,9 @@
#include <algorithm> #include <algorithm>
#include "BitmapCache.hpp" #include "BitmapCache.hpp"
#include "DeviceCore/DevManager.h"
#include "DeviceCore/DevStorage.h"
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
@@ -803,7 +806,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
m_comboBox_printer->SetTextLabel(""); m_comboBox_printer->SetTextLabel("");
return; return;
} }
assert(obj_->dev_id == m_printer_last_select); assert(obj_->get_dev_id() == m_printer_last_select);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", print_job: for send task, current printer id = " << m_printer_last_select << std::endl; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", print_job: for send task, current printer id = " << m_printer_last_select << std::endl;
show_status(PrintDialogStatus::PrintStatusSending); show_status(PrintDialogStatus::PrintStatusSending);
@@ -960,7 +963,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
} else { } else {
auto m_send_job = std::make_unique<SendJob>(m_printer_last_select); auto m_send_job = std::make_unique<SendJob>(m_printer_last_select);
m_send_job->m_dev_ip = obj_->dev_ip; m_send_job->m_dev_ip = obj_->get_dev_ip();
m_send_job->m_access_code = obj_->get_access_code(); m_send_job->m_access_code = obj_->get_access_code();
@@ -979,7 +982,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
#endif #endif
m_send_job->connection_type = obj_->connection_type(); m_send_job->connection_type = obj_->connection_type();
m_send_job->cloud_print_only = true; m_send_job->cloud_print_only = true;
m_send_job->has_sdcard = obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_NORMAL; m_send_job->has_sdcard = obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::HAS_SDCARD_NORMAL;
m_send_job->set_project_name(m_current_project_name.utf8_string()); m_send_job->set_project_name(m_current_project_name.utf8_string());
enable_prepare_mode = false; enable_prepare_mode = false;
@@ -1116,15 +1119,15 @@ void SendToPrinterDialog::update_user_printer()
// same machine only appear once // same machine only appear once
for (auto it = option_list.begin(); it != option_list.end(); it++) { for (auto it = option_list.begin(); it != option_list.end(); it++) {
if (it->second && (it->second->is_online() || it->second->is_connected())) { if (it->second && (it->second->is_online() || it->second->is_connected())) {
machine_list.push_back(it->second->dev_name); machine_list.push_back(it->second->get_dev_name());
} }
} }
machine_list = sort_string(machine_list); machine_list = sort_string(machine_list);
for (auto tt = machine_list.begin(); tt != machine_list.end(); tt++) { for (auto tt = machine_list.begin(); tt != machine_list.end(); tt++) {
for (auto it = option_list.begin(); it != option_list.end(); it++) { for (auto it = option_list.begin(); it != option_list.end(); it++) {
if (it->second->dev_name == *tt) { if (it->second->get_dev_name() == *tt) {
m_list.push_back(it->second); m_list.push_back(it->second);
wxString dev_name_text = from_u8(it->second->dev_name); wxString dev_name_text = from_u8(it->second->get_dev_name());
if (it->second->is_lan_mode_printer()) { if (it->second->is_lan_mode_printer()) {
dev_name_text += "(LAN)"; dev_name_text += "(LAN)";
} }
@@ -1143,7 +1146,7 @@ void SendToPrinterDialog::update_user_printer()
} }
if (obj) { if (obj) {
m_printer_last_select = obj->dev_id; m_printer_last_select = obj->get_dev_id();
} else { } else {
m_printer_last_select = ""; m_printer_last_select = "";
} }
@@ -1151,14 +1154,14 @@ void SendToPrinterDialog::update_user_printer()
if (m_list.size() > 0) { if (m_list.size() > 0) {
// select a default machine // select a default machine
if (m_printer_last_select.empty()) { if (m_printer_last_select.empty()) {
m_printer_last_select = m_list[0]->dev_id; m_printer_last_select = m_list[0]->get_dev_id();
m_comboBox_printer->SetSelection(0); m_comboBox_printer->SetSelection(0);
wxCommandEvent event(wxEVT_COMBOBOX); wxCommandEvent event(wxEVT_COMBOBOX);
event.SetEventObject(m_comboBox_printer); event.SetEventObject(m_comboBox_printer);
wxPostEvent(m_comboBox_printer, event); wxPostEvent(m_comboBox_printer, event);
} }
for (auto i = 0; i < m_list.size(); i++) { for (auto i = 0; i < m_list.size(); i++) {
if (m_list[i]->dev_id == m_printer_last_select) { if (m_list[i]->get_dev_id() == m_printer_last_select) {
m_comboBox_printer->SetSelection(i); m_comboBox_printer->SetSelection(i);
wxCommandEvent event(wxEVT_COMBOBOX); wxCommandEvent event(wxEVT_COMBOBOX);
event.SetEventObject(m_comboBox_printer); event.SetEventObject(m_comboBox_printer);
@@ -1203,7 +1206,7 @@ void SendToPrinterDialog::on_selection_changed(wxCommandEvent &event)
MachineObject* obj = nullptr; MachineObject* obj = nullptr;
for (int i = 0; i < m_list.size(); i++) { for (int i = 0; i < m_list.size(); i++) {
if (i == selection) { if (i == selection) {
m_printer_last_select = m_list[i]->dev_id; m_printer_last_select = m_list[i]->get_dev_id();
obj = m_list[i]; obj = m_list[i];
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "for send task, current printer id = " << m_printer_last_select << std::endl; BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "for send task, current printer id = " << m_printer_last_select << std::endl;
break; break;
@@ -1216,7 +1219,7 @@ void SendToPrinterDialog::on_selection_changed(wxCommandEvent &event)
if (!dev->get_selected_machine()) { if (!dev->get_selected_machine()) {
dev->set_selected_machine(m_printer_last_select); dev->set_selected_machine(m_printer_last_select);
if (m_file_sys) m_file_sys.reset(); if (m_file_sys) m_file_sys.reset();
}else if (dev->get_selected_machine()->dev_id != m_printer_last_select) { }else if (dev->get_selected_machine()->get_dev_id() != m_printer_last_select) {
m_ability_list.clear(); m_ability_list.clear();
//update_storage_list(std::vector<std::string>()); //update_storage_list(std::vector<std::string>());
dev->set_selected_machine(m_printer_last_select); dev->set_selected_machine(m_printer_last_select);
@@ -1290,7 +1293,7 @@ void SendToPrinterDialog::update_show_status()
// check sdcard when if lan mode printer // check sdcard when if lan mode printer
/* if (obj_->is_lan_mode_printer()) { /* if (obj_->is_lan_mode_printer()) {
}*/ }*/
if (obj_->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD) { if (obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::NO_SDCARD) {
show_status(PrintDialogStatus::PrintStatusNoSdcard); show_status(PrintDialogStatus::PrintStatusNoSdcard);
return; return;
} }
@@ -1316,7 +1319,7 @@ void SendToPrinterDialog::update_show_status()
show_status(PrintDialogStatus::PrintStatusReadingFinished); show_status(PrintDialogStatus::PrintStatusReadingFinished);
return; return;
} else/* if (obj_->connection_type() == "cloud")*/ { } else/* if (obj_->connection_type() == "cloud")*/ {
std::string dev_id = obj_->dev_ip; std::string dev_id = obj_->get_dev_ip();
if (m_file_sys) { if (m_file_sys) {
if (dev_id == m_device_select) { if (dev_id == m_device_select) {
if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && obj_->get_file_remote())) if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && obj_->get_file_remote()))
@@ -1497,7 +1500,7 @@ bool SendToPrinterDialog::is_blocking_printing(MachineObject* obj_)
auto target_model = obj_->printer_type; auto target_model = obj_->printer_type;
if (source_model != target_model) { if (source_model != target_model) {
std::vector<std::string> compatible_machine = dev->get_compatible_machine(target_model); std::vector<std::string> compatible_machine = obj_->get_compatible_machine();
vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model); vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model);
if (it == compatible_machine.end()) { if (it == compatible_machine.end()) {
return true; return true;
@@ -1863,7 +1866,7 @@ void SendToPrinterDialog::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
} }
std::string dev_ver = obj->get_ota_version(); std::string dev_ver = obj->get_ota_version();
std::string dev_id = obj->dev_id; std::string dev_id = obj->get_dev_id();
int remote_proto = obj->get_file_remote(); int remote_proto = obj->get_file_remote();
if (!remote_proto) { if (!remote_proto) {
m_waiting_support = true; m_waiting_support = true;
@@ -1884,7 +1887,7 @@ void SendToPrinterDialog::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
if (agent) { if (agent) {
if (m_tcp_try_connect) { if (m_tcp_try_connect) {
std::string devIP = obj->dev_ip; std::string devIP = obj->get_dev_ip();
std::string accessCode = obj->get_access_code(); std::string accessCode = obj->get_access_code();
std::string tcp_url = "bambu:///local/" + devIP + "?port=6000&user=" + "bblp" + "&passwd=" + accessCode; std::string tcp_url = "bambu:///local/" + devIP + "?port=6000&user=" + "bblp" + "&passwd=" + accessCode;
CallAfter([=] { CallAfter([=] {
@@ -1899,7 +1902,7 @@ void SendToPrinterDialog::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
} }
else if (m_tutk_try_connect){ else if (m_tutk_try_connect){
std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""}; std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""};
agent->get_camera_url(obj->dev_id + "|" + dev_ver + "|" + protocols[1], [this, wfs, m = dev_id, v = agent->get_version(), dv = dev_ver](std::string url) { agent->get_camera_url(obj->get_dev_id() + "|" + dev_ver + "|" + protocols[1], [this, wfs, m = dev_id, v = agent->get_version(), dv = dev_ver](std::string url) {
if (boost::algorithm::starts_with(url, "bambu:///")) { if (boost::algorithm::starts_with(url, "bambu:///")) {
url += "&device=" + m; url += "&device=" + m;
url += "&net_ver=" + v; url += "&net_ver=" + v;
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -39,6 +39,9 @@ class StepIndicator;
#define COMMAND_TIMEOUT 5 #define COMMAND_TIMEOUT 5
namespace Slic3r { namespace Slic3r {
class DevExtderSystem;
namespace GUI { namespace GUI {
// Previous definitions // Previous definitions
@@ -156,10 +159,7 @@ public:
void msw_rescale(); void msw_rescale();
private: private:
void updateSwitchingLabel(const ExtruderSwitchState &state); void updateBy(const DevExtderSystem* ext_system);
void updateBy(const ExtderData& ext_data);
void updateBtnGroup(const ExtderData &ext_data);
void showQuitBtn(bool show); void showQuitBtn(bool show);
void showRetryBtn(bool show); void showRetryBtn(bool show);
+53 -51
View File
@@ -22,6 +22,12 @@
#include "CapsuleButton.hpp" #include "CapsuleButton.hpp"
#include "PrePrintChecker.hpp" #include "PrePrintChecker.hpp"
#include "DeviceCore/DevConfig.h"
#include "DeviceCore/DevFilaSystem.h"
#include "DeviceCore/DevManager.h"
#include "DeviceCore/DevMapping.h"
#include "DeviceCore/DevStorage.h"
using namespace Slic3r; using namespace Slic3r;
using namespace Slic3r::GUI; using namespace Slic3r::GUI;
@@ -333,7 +339,7 @@ wxColour SyncAmsInfoDialog::decode_ams_color(const std::string &color_str) {
if (temp_str.size() == 6) { if (temp_str.size() == 6) {
temp_str += "FF"; temp_str += "FF";
} }
return AmsTray::decode_color(temp_str); return DevAmsTray::decode_color(temp_str);
} }
void SyncAmsInfoDialog::update_map_when_change_map_mode() void SyncAmsInfoDialog::update_map_when_change_map_mode()
@@ -1192,13 +1198,13 @@ void SyncAmsInfoDialog::sync_ams_mapping_result(std::vector<FilamentInfo> &resul
} }
if (!f->color.empty()) { if (!f->color.empty()) {
ams_col = AmsTray::decode_color(f->color); ams_col = DevAmsTray::decode_color(f->color);
} else { } else {
// default color // default color
ams_col = wxColour(0xCE, 0xCE, 0xCE); ams_col = wxColour(0xCE, 0xCE, 0xCE);
} }
std::vector<wxColour> cols; std::vector<wxColour> cols;
for (auto col : f->colors) { cols.push_back(AmsTray::decode_color(col)); } for (auto col : f->colors) { cols.push_back(DevAmsTray::decode_color(col)); }
m->set_ams_info(ams_col, ams_id, f->ctype, cols,true);//sync_ams_mapping_result m->set_ams_info(ams_col, ams_id, f->ctype, cols,true);//sync_ams_mapping_result
break; break;
} }
@@ -1227,19 +1233,19 @@ bool SyncAmsInfoDialog::do_ams_mapping(MachineObject *obj_)
std::vector<bool> map_opt; // four values: use_left_ams, use_right_ams, use_left_ext, use_right_ext std::vector<bool> map_opt; // four values: use_left_ams, use_right_ams, use_left_ext, use_right_ext
if (nozzle_nums > 1) { if (nozzle_nums > 1) {
map_opt = {true, true, true, true}; // four values: use_left_ams, use_right_ams, use_left_ext, use_right_ext map_opt = {true, true, true, true}; // four values: use_left_ams, use_right_ams, use_left_ext, use_right_ext
filament_result = obj_->ams_filament_mapping(m_filaments, m_ams_mapping_result, map_opt, std::vector<int>(), filament_result = DevMappingUtil::ams_filament_mapping(obj_, m_filaments, m_ams_mapping_result, map_opt, std::vector<int>(),
wxGetApp().app_config->get_bool("ams_sync_match_full_use_color_dist") ? false : true); wxGetApp().app_config->get_bool("ams_sync_match_full_use_color_dist") ? false : true);
} }
// single nozzle // single nozzle
else { else {
if (obj_->is_support_amx_ext_mix_mapping()) { if (obj_->is_support_amx_ext_mix_mapping()) {
map_opt = {false, true, false, true}; // four values: use_left_ams, use_right_ams, use_left_ext, use_right_ext map_opt = {false, true, false, true}; // four values: use_left_ams, use_right_ams, use_left_ext, use_right_ext
filament_result = obj_->ams_filament_mapping(m_filaments, m_ams_mapping_result, map_opt, std::vector<int>(), filament_result = DevMappingUtil::ams_filament_mapping(obj_, m_filaments, m_ams_mapping_result, map_opt, std::vector<int>(),
wxGetApp().app_config->get_bool("ams_sync_match_full_use_color_dist") ? false : true); wxGetApp().app_config->get_bool("ams_sync_match_full_use_color_dist") ? false : true);
// auto_supply_with_ext(obj_->vt_slot); // auto_supply_with_ext(obj_->vt_slot);
} else { } else {
map_opt = {false, true, false, false}; map_opt = {false, true, false, false};
filament_result = obj_->ams_filament_mapping(m_filaments, m_ams_mapping_result, map_opt); filament_result = DevMappingUtil::ams_filament_mapping(obj_, m_filaments, m_ams_mapping_result, map_opt);
} }
} }
@@ -1260,11 +1266,11 @@ bool SyncAmsInfoDialog::do_ams_mapping(MachineObject *obj_)
} }
deal_only_exist_ext_spool(obj_); deal_only_exist_ext_spool(obj_);
show_thumbnail_page(); show_thumbnail_page();
return obj_->is_valid_mapping_result(m_ams_mapping_result); return DevMappingUtil::is_valid_mapping_result(obj_, m_ams_mapping_result);
} else { } else {
BOOST_LOG_TRIVIAL(info) << "filament_result != 0"; BOOST_LOG_TRIVIAL(info) << "filament_result != 0";
// do not support ams mapping try to use order mapping // do not support ams mapping try to use order mapping
bool is_valid = obj_->is_valid_mapping_result(m_ams_mapping_result); bool is_valid = DevMappingUtil::is_valid_mapping_result(obj_, m_ams_mapping_result);
if (filament_result != 1 && !is_valid) { if (filament_result != 1 && !is_valid) {
// reset invalid result // reset invalid result
for (int i = 0; i < m_ams_mapping_result.size(); i++) { for (int i = 0; i < m_ams_mapping_result.size(); i++) {
@@ -1285,7 +1291,7 @@ void SyncAmsInfoDialog::deal_only_exist_ext_spool(MachineObject *obj_) {
if (!obj_) if (!obj_)
return; return;
if (!m_append_color_text) { return; } if (!m_append_color_text) { return; }
bool only_exist_ext_spool_flag = m_only_exist_ext_spool_flag = obj_->only_exist_ext_spool(); bool only_exist_ext_spool_flag = m_only_exist_ext_spool_flag = !obj_->GetFilaSystem()->HasAms();
SetTitle(only_exist_ext_spool_flag ? _L("Synchronize Filament Information") : _L("Synchronize AMS Filament Information")); SetTitle(only_exist_ext_spool_flag ? _L("Synchronize Filament Information") : _L("Synchronize AMS Filament Information"));
m_append_color_text->SetLabel(only_exist_ext_spool_flag ? _L("Add unused filaments to filaments list.") : m_append_color_text->SetLabel(only_exist_ext_spool_flag ? _L("Add unused filaments to filaments list.") :
_L("Add unused AMS filaments to filaments list.")); _L("Add unused AMS filaments to filaments list."));
@@ -1442,20 +1448,20 @@ bool SyncAmsInfoDialog::build_nozzles_info(std::string &nozzles_info)
return true; return true;
} }
bool SyncAmsInfoDialog::can_hybrid_mapping(ExtderData data) bool SyncAmsInfoDialog::can_hybrid_mapping(DevExtderSystem data)
{ {
// Mixed mappings are not allowed // Mixed mappings are not allowed
return false; return false;
if (data.total_extder_count <= 1 || data.extders.size() <= 1 || !wxGetApp().preset_bundle) return false; if (data.GetTotalExtderCount() <= 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. // The default two extruders are left, right, but the order of the extruders on the machine is right, left.
// Therefore, some adjustments need to be made. // Therefore, some adjustments need to be made.
std::vector<std::string> flow_type_of_machine; std::vector<std::string> flow_type_of_machine;
for (auto it = data.extders.rbegin(); it != data.extders.rend(); it++) { for (auto it = data.GetExtruders().rbegin(); it != data.GetExtruders().rend(); it++) {
// exist field is not updated, wait add // exist field is not updated, wait add
// if (it->exist < 3) return false; // if (it->exist < 3) return false;
std::string type_str = it->current_nozzle_flow_type ? "High Flow" : "Standard"; std::string type_str = it->GetNozzleFlowType() ? "High Flow" : "Standard";
flow_type_of_machine.push_back(type_str); flow_type_of_machine.push_back(type_str);
} }
// get the nozzle type of preset --> flow_types // get the nozzle type of preset --> flow_types
@@ -1476,14 +1482,14 @@ bool SyncAmsInfoDialog::can_hybrid_mapping(ExtderData data)
} }
// When filaments cannot be matched automatically, whether to use ext for automatic supply // When filaments cannot be matched automatically, whether to use ext for automatic supply
void SyncAmsInfoDialog::auto_supply_with_ext(std::vector<AmsTray> slots) void SyncAmsInfoDialog::auto_supply_with_ext(std::vector<DevAmsTray> slots)
{ {
if (slots.size() <= 0) return; if (slots.size() <= 0) return;
for (int i = 0; i < m_ams_mapping_result.size(); i++) { for (int i = 0; i < m_ams_mapping_result.size(); i++) {
auto it = m_ams_mapping_result[i]; auto it = m_ams_mapping_result[i];
if (it.ams_id == "") { if (it.ams_id == "") {
AmsTray slot(""); DevAmsTray slot("");
if (m_filaments_map[it.id] == 1 && slots.size() > 1) if (m_filaments_map[it.id] == 1 && slots.size() > 1)
slot = slots[1]; slot = slots[1];
else if (m_filaments_map[it.id] == 2) else if (m_filaments_map[it.id] == 2)
@@ -1499,9 +1505,9 @@ void SyncAmsInfoDialog::auto_supply_with_ext(std::vector<AmsTray> slots)
} }
} }
bool SyncAmsInfoDialog::is_nozzle_type_match(ExtderData data, wxString &error_message) const bool SyncAmsInfoDialog::is_nozzle_type_match(DevExtderSystem data, wxString &error_message) const
{ {
if (data.total_extder_count <= 1 || data.extders.size() <= 1 || !wxGetApp().preset_bundle) return false; if (data.GetTotalExtderCount() <= 1 || !wxGetApp().preset_bundle) return false;
const auto &project_config = wxGetApp().preset_bundle->project_config; const auto &project_config = wxGetApp().preset_bundle->project_config;
// check nozzle used // check nozzle used
@@ -1532,10 +1538,10 @@ bool SyncAmsInfoDialog::is_nozzle_type_match(ExtderData data, wxString &error_me
// The default two extruders are left, right, but the order of the extruders on the machine is right, left. // 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; std::vector<std::string> flow_type_of_machine;
for (auto it = data.extders.begin(); it != data.extders.end(); it++) { for (auto it = data.GetExtruders().begin(); it != data.GetExtruders().end(); it++) {
if (it->current_nozzle_flow_type == NozzleFlowType::H_FLOW) { if (it->GetNozzleFlowType() == NozzleFlowType::H_FLOW) {
flow_type_of_machine.push_back("High Flow"); flow_type_of_machine.push_back("High Flow");
} else if (it->current_nozzle_flow_type == NozzleFlowType::S_FLOW) { } else if (it->GetNozzleFlowType() == NozzleFlowType::S_FLOW) {
flow_type_of_machine.push_back("Standard"); flow_type_of_machine.push_back("Standard");
} }
} }
@@ -1548,9 +1554,9 @@ bool SyncAmsInfoDialog::is_nozzle_type_match(ExtderData data, wxString &error_me
if (target_machine_nozzle_id < flow_type_of_machine.size()) { if (target_machine_nozzle_id < flow_type_of_machine.size()) {
if (flow_type_of_machine[target_machine_nozzle_id] != used_extruders_flow[it->first]) { if (flow_type_of_machine[target_machine_nozzle_id] != used_extruders_flow[it->first]) {
wxString pos; wxString pos;
if (target_machine_nozzle_id == DEPUTY_NOZZLE_ID) { if (target_machine_nozzle_id == DEPUTY_EXTRUDER_ID) {
pos = _L("left nozzle"); pos = _L("left nozzle");
} else if ((target_machine_nozzle_id == MAIN_NOZZLE_ID)) { } else if ((target_machine_nozzle_id == MAIN_EXTRUDER_ID)) {
pos = _L("right nozzle"); pos = _L("right nozzle");
} }
@@ -1797,7 +1803,7 @@ void SyncAmsInfoDialog::show_status(PrintDialogStatus status, std::vector<wxStri
if (m_required_data_plate_data_list.size() > 0) { target_model_id = m_required_data_plate_data_list[m_print_plate_idx]->printer_model_id; } if (m_required_data_plate_data_list.size() > 0) { target_model_id = m_required_data_plate_data_list[m_print_plate_idx]->printer_model_id; }
} }
auto target_print_name = wxString(obj_->get_preset_printer_model_name(target_model_id)); auto target_print_name = wxString(DevPrinterConfigUtil::get_printer_display_name(target_model_id));
target_print_name.Replace(wxT("Bambu Lab "), wxEmptyString); target_print_name.Replace(wxT("Bambu Lab "), wxEmptyString);
msg_text = wxString::Format(_L("The selected printer (%s) is incompatible with the chosen printer profile in the slicer (%s)."), sourcet_print_name, msg_text = wxString::Format(_L("The selected printer (%s) is incompatible with the chosen printer profile in the slicer (%s)."), sourcet_print_name,
target_print_name); target_print_name);
@@ -1878,7 +1884,7 @@ bool SyncAmsInfoDialog::is_blocking_printing(MachineObject *obj_)
} }
if (source_model != target_model) { if (source_model != target_model) {
std::vector<std::string> compatible_machine = dev->get_compatible_machine(target_model); std::vector<std::string> compatible_machine = obj_->get_compatible_machine();
vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model); vector<std::string>::iterator it = find(compatible_machine.begin(), compatible_machine.end(), source_model);
if (it == compatible_machine.end()) { return true; } if (it == compatible_machine.end()) { return true; }
} }
@@ -1907,8 +1913,8 @@ bool SyncAmsInfoDialog::is_same_nozzle_diameters(NozzleType &tag_nozzle_type, fl
std::vector<std::string> preset_nozzle_types(nozzle_type->size()); std::vector<std::string> preset_nozzle_types(nozzle_type->size());
for (size_t idx = 0; idx < nozzle_type->size(); ++idx) preset_nozzle_types[idx] = NozzleTypeEumnToStr[NozzleType(nozzle_type->values[idx])]; for (size_t idx = 0; idx < nozzle_type->size(); ++idx) preset_nozzle_types[idx] = NozzleTypeEumnToStr[NozzleType(nozzle_type->values[idx])];
std::vector<std::string> machine_nozzle_types(obj_->m_extder_data.extders.size()); std::vector<std::string> machine_nozzle_types(obj_->GetExtderSystem()->GetTotalExtderCount());
for (size_t idx = 0; idx < obj_->m_extder_data.extders.size(); ++idx) machine_nozzle_types[idx] = obj_->m_extder_data.extders[idx].current_nozzle_type; for (size_t idx = 0; idx < obj_->GetExtderSystem()->GetTotalExtderCount(); ++idx) machine_nozzle_types[idx] = obj_->GetExtderSystem()->GetNozzleType(idx);
auto used_filaments = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_used_filaments(); // 1 based auto used_filaments = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_used_filaments(); // 1 based
auto filament_maps = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_real_filament_maps(preset_bundle->project_config); // 1 based auto filament_maps = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_real_filament_maps(preset_bundle->project_config); // 1 based
@@ -1921,13 +1927,13 @@ bool SyncAmsInfoDialog::is_same_nozzle_diameters(NozzleType &tag_nozzle_type, fl
std::sort(used_extruders.begin(), used_extruders.end()); std::sort(used_extruders.begin(), used_extruders.end());
// TODO [tao wang] : add idx mapping // TODO [tao wang] : add idx mapping
tag_nozzle_type = obj_->m_extder_data.extders[0].current_nozzle_type; tag_nozzle_type = obj_->GetExtderSystem()->GetNozzleType(0);
if (opt_nozzle_diameters != nullptr) { if (opt_nozzle_diameters != nullptr) {
for (auto i = 0; i < used_extruders.size(); i++) { for (auto i = 0; i < used_extruders.size(); i++) {
auto extruder = used_extruders[i]; auto extruder = used_extruders[i];
preset_nozzle_diameters = float(opt_nozzle_diameters->get_at(extruder)); preset_nozzle_diameters = float(opt_nozzle_diameters->get_at(extruder));
if (preset_nozzle_diameters != obj_->m_extder_data.extders[0].current_nozzle_diameter) { is_same_nozzle_diameters = false; } if (preset_nozzle_diameters != obj_->GetExtderSystem()->GetNozzleDiameter(0)) { is_same_nozzle_diameters = false; }
} }
} }
@@ -1948,7 +1954,7 @@ bool SyncAmsInfoDialog::is_same_nozzle_type(std::string &filament_type, NozzleTy
MachineObject *obj_ = dev->get_selected_machine(); MachineObject *obj_ = dev->get_selected_machine();
if (obj_ == nullptr) return true; if (obj_ == nullptr) return true;
NozzleType nozzle_type = obj_->m_extder_data.extders[0].current_nozzle_type; NozzleType nozzle_type = obj_->GetExtderSystem()->GetNozzleType(0);
auto printer_nozzle_hrc = Print::get_hrc_by_nozzle_type(nozzle_type); auto printer_nozzle_hrc = Print::get_hrc_by_nozzle_type(nozzle_type);
auto preset_bundle = wxGetApp().preset_bundle; auto preset_bundle = wxGetApp().preset_bundle;
@@ -1965,7 +1971,7 @@ bool SyncAmsInfoDialog::is_same_nozzle_type(std::string &filament_type, NozzleTy
tag_nozzle_type = NozzleType::ntHardenedSteel; tag_nozzle_type = NozzleType::ntHardenedSteel;
return is_same_nozzle_type; return is_same_nozzle_type;
} else { } else {
tag_nozzle_type = obj_->m_extder_data.extders[0].current_nozzle_type; tag_nozzle_type = obj_->GetExtderSystem()->GetNozzleType(0);
} }
iter++; iter++;
@@ -2189,11 +2195,11 @@ void SyncAmsInfoDialog::update_user_printer()
// same machine only appear once // same machine only appear once
for (auto it = option_list.begin(); it != option_list.end(); it++) { for (auto it = option_list.begin(); it != option_list.end(); it++) {
if (it->second && (it->second->is_online() || it->second->is_connected())) { machine_list.push_back(it->second->dev_name); } if (it->second && (it->second->is_online() || it->second->is_connected())) { machine_list.push_back(it->second->get_dev_name()); }
} }
// lan machine list // lan machine list
auto lan_option_list = dev->get_local_machine_list(); auto lan_option_list = dev->get_local_machinelist();
for (auto elem : lan_option_list) { for (auto elem : lan_option_list) {
MachineObject *mobj = elem.second; MachineObject *mobj = elem.second;
@@ -2203,17 +2209,18 @@ void SyncAmsInfoDialog::update_user_printer()
if (!mobj->is_online()) continue; if (!mobj->is_online()) continue;
if (!mobj->is_lan_mode_printer()) continue; if (!mobj->is_lan_mode_printer()) continue;
if (!mobj->has_access_right()) { if (!mobj->has_access_right()) {
option_list[mobj->dev_name] = mobj; option_list[mobj->get_dev_name()] = mobj;
machine_list.push_back(mobj->dev_name); machine_list.push_back(mobj->get_dev_name());
} }
} }
machine_list = sort_string(machine_list); machine_list = sort_string(machine_list);
for (auto tt = machine_list.begin(); tt != machine_list.end(); tt++) { for (auto tt = machine_list.begin(); tt != machine_list.end(); tt++) {
for (auto it = option_list.begin(); it != option_list.end(); it++) { for (auto it = option_list.begin(); it != option_list.end(); it++) {
if (it->second->dev_name == *tt) { if (it->second->get_dev_name() == *tt)
{
m_list.push_back(it->second); m_list.push_back(it->second);
wxString dev_name_text = from_u8(it->second->dev_name); wxString dev_name_text = from_u8(it->second->get_dev_name());
if (it->second->is_lan_mode_printer()) { dev_name_text += "(LAN)"; } if (it->second->is_lan_mode_printer()) { dev_name_text += "(LAN)"; }
machine_list_name.Add(dev_name_text); machine_list_name.Add(dev_name_text);
break; break;
@@ -2243,8 +2250,8 @@ void SyncAmsInfoDialog::on_timer(wxTimerEvent &event)
m_check_flag = true; m_check_flag = true;
} }
if (!obj_ || obj_->amsList.empty() || obj_->ams_exist_bits == 0 || !obj_->is_support_filament_backup || !obj_->is_support_show_filament_backup || if (!obj_ || !obj_->GetFilaSystem()->HasAms() || obj_->ams_exist_bits == 0 || !obj_->is_support_filament_backup || !obj_->GetExtderSystem()->HasFilamentBackup() ||
!obj_->ams_auto_switch_filament_flag || m_checkbox_list["use_ams"]->getValue() != "on") { !obj_->GetFilaSystem()->IsAutoRefillEnabled() || m_checkbox_list["use_ams"]->getValue() != "on") {
if (m_ams_backup_tip && m_ams_backup_tip->IsShown()) { if (m_ams_backup_tip && m_ams_backup_tip->IsShown()) {
m_ams_backup_tip->Hide(); m_ams_backup_tip->Hide();
img_ams_backup->Hide(); img_ams_backup->Hide();
@@ -2316,7 +2323,7 @@ void SyncAmsInfoDialog::update_show_status()
reset_timeout(); reset_timeout();
if (!obj_->is_support_print_all && m_print_plate_idx == PLATE_ALL_IDX) { if (!obj_->GetConfig()->SupportPrintAllPlates() && m_print_plate_idx == PLATE_ALL_IDX) {
show_status(PrintDialogStatus::PrintStatusNotSupportedPrintAll); show_status(PrintDialogStatus::PrintStatusNotSupportedPrintAll);
return; return;
} }
@@ -2352,17 +2359,17 @@ void SyncAmsInfoDialog::update_show_status()
} else if (obj_->is_in_printing() || obj_->ams_status_main == AMS_STATUS_MAIN_FILAMENT_CHANGE) { } else if (obj_->is_in_printing() || obj_->ams_status_main == AMS_STATUS_MAIN_FILAMENT_CHANGE) {
show_status(PrintDialogStatus::PrintStatusInPrinting); show_status(PrintDialogStatus::PrintStatusInPrinting);
return; return;
} else if (!obj_->is_support_print_without_sd && (obj_->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD)) { } else if (!obj_->GetConfig()->SupportPrintWithoutSD() && (obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::NO_SDCARD)) {
show_status(PrintDialogStatus::PrintStatusNoSdcard); show_status(PrintDialogStatus::PrintStatusNoSdcard);
return; return;
} }
// check sdcard when if lan mode printer // check sdcard when if lan mode printer
if (obj_->is_lan_mode_printer()) { if (obj_->is_lan_mode_printer()) {
if (obj_->get_sdcard_state() == MachineObject::SdcardState::NO_SDCARD) { if (obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::NO_SDCARD) {
show_status(PrintDialogStatus::PrintStatusLanModeNoSdcard); show_status(PrintDialogStatus::PrintStatusLanModeNoSdcard);
return; return;
} else if (obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_ABNORMAL || obj_->get_sdcard_state() == MachineObject::SdcardState::HAS_SDCARD_READONLY) { } else if (obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::HAS_SDCARD_ABNORMAL || obj_->GetStorage()->get_sdcard_state() == DevStorage::SdcardState::HAS_SDCARD_READONLY) {
show_status(PrintDialogStatus::PrintStatusLanModeSDcardNotAvailable); show_status(PrintDialogStatus::PrintStatusLanModeSDcardNotAvailable);
return; return;
} }
@@ -2376,13 +2383,8 @@ void SyncAmsInfoDialog::update_show_status()
// the nozzle type of preset and machine are different // the nozzle type of preset and machine are different
if (nozzle_nums > 1) { if (nozzle_nums > 1) {
if (obj_->is_nozzle_data_invalid()) {
show_status(PrintDialogStatus::PrintStatusNozzleDataInvalid);
return;
}
wxString error_message; wxString error_message;
if (!is_nozzle_type_match(obj_->m_extder_data, error_message)) { if (!is_nozzle_type_match(*obj_->GetExtderSystem(), error_message)) {
std::vector<wxString> params{error_message}; std::vector<wxString> params{error_message};
params.emplace_back(_L("Tips: If you changed your nozzle of your printer lately, Please go to 'Device -> Printer parts' to change your nozzle setting.")); params.emplace_back(_L("Tips: If you changed your nozzle of your printer lately, Please go to 'Device -> Printer parts' to change your nozzle setting."));
show_status(PrintDialogStatus::PrintStatusNozzleMatchInvalid, params); show_status(PrintDialogStatus::PrintStatusNozzleMatchInvalid, params);
@@ -2415,7 +2417,7 @@ void SyncAmsInfoDialog::update_show_status()
if (item.ams_id.empty()) continue; if (item.ams_id.empty()) continue;
int extruder_id = obj_->get_extruder_id_by_ams_id(item.ams_id); int extruder_id = obj_->get_extruder_id_by_ams_id(item.ams_id);
if (DeviceManager::is_virtual_slot(stoi(item.ams_id))) if (devPrinterUtil::IsVirtualSlot(item.ams_id))
extruder_status[extruder_id].has_vt_slot = true; extruder_status[extruder_id].has_vt_slot = true;
else else
extruder_status[extruder_id].has_ams = true; extruder_status[extruder_id].has_ams = true;
@@ -3250,7 +3252,7 @@ void SyncAmsInfoDialog::update_lan_machine_list()
{ {
DeviceManager *dev = wxGetApp().getDeviceManager(); DeviceManager *dev = wxGetApp().getDeviceManager();
if (!dev) return; if (!dev) return;
auto m_free_machine_list = dev->get_local_machine_list(); auto m_free_machine_list = dev->get_local_machinelist();
BOOST_LOG_TRIVIAL(info) << "SelectMachinePopup update_other_devices start"; BOOST_LOG_TRIVIAL(info) << "SelectMachinePopup update_other_devices start";
@@ -3263,7 +3265,7 @@ void SyncAmsInfoDialog::update_lan_machine_list()
if (!mobj->is_lan_mode_printer()) continue; if (!mobj->is_lan_mode_printer()) continue;
if (mobj->has_access_right()) { if (mobj->has_access_right()) {
auto b = mobj->dev_name; auto b = mobj->get_dev_name();
// clear machine list // clear machine list

Some files were not shown because too many files have changed in this diff Show More