diff --git a/localization/i18n/list.txt b/localization/i18n/list.txt index 52046c7c88..d519a11168 100644 --- a/localization/i18n/list.txt +++ b/localization/i18n/list.txt @@ -8,6 +8,8 @@ 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/DevExtensionTool.h +src/slic3r/GUI/DeviceCore/DevExtensionTool.cpp src/slic3r/GUI/DeviceCore/DevExtruderSystem.h src/slic3r/GUI/DeviceCore/DevExtruderSystem.cpp src/slic3r/GUI/DeviceCore/DevExtruderSystemCtrl.cpp diff --git a/src/slic3r/GUI/DeviceCore/CMakeLists.txt b/src/slic3r/GUI/DeviceCore/CMakeLists.txt index caa29364ed..d88fad3706 100644 --- a/src/slic3r/GUI/DeviceCore/CMakeLists.txt +++ b/src/slic3r/GUI/DeviceCore/CMakeLists.txt @@ -13,6 +13,8 @@ list(APPEND SLIC3R_GUI_SOURCES GUI/DeviceCore/DevCtrl.h GUI/DeviceCore/DevCtrl.cpp GUI/DeviceCore/DevDefs.h + GUI/DeviceCore/DevExtensionTool.h + GUI/DeviceCore/DevExtensionTool.cpp GUI/DeviceCore/DevExtruderSystem.h GUI/DeviceCore/DevExtruderSystem.cpp GUI/DeviceCore/DevExtruderSystemCtrl.cpp diff --git a/src/slic3r/GUI/DeviceCore/DevExtensionTool.cpp b/src/slic3r/GUI/DeviceCore/DevExtensionTool.cpp new file mode 100644 index 0000000000..5426a9bba3 --- /dev/null +++ b/src/slic3r/GUI/DeviceCore/DevExtensionTool.cpp @@ -0,0 +1,39 @@ +#include "DevExtensionTool.h" +#include "DevUtil.h" + +#include + +using namespace nlohmann; + +namespace Slic3r +{ + +DevExtensionTool::DevExtensionTool(MachineObject* obj) : m_owner(obj) +{ + m_mount_3dp = MOUNT_NOT_MOUNTED; + m_calib = CALIB_NONE; + m_tool_type = TOOL_TYPE_EMPTY; +} + +void DevExtensionToolParser::ParseV2_0(const nlohmann::json& extension_tool_json, std::weak_ptr extension_tool) +{ + if (auto ext_tool = extension_tool.lock()) + { + DevJsonValParser::ParseVal(extension_tool_json, "mount_3d", ext_tool->m_mount_3dp, ext_tool->m_mount_3dp); + DevJsonValParser::ParseVal(extension_tool_json, "calib", ext_tool->m_calib, ext_tool->m_calib); + + { + const std::string& type_str = DevJsonValParser::GetVal(extension_tool_json, "type", ""); + static std::map s_type_map = { + {"CP00", DevExtensionTool::TOOL_TYPE_CUT_CP00}, + {"LB00", DevExtensionTool::TOOL_TYPE_LASER_LB00}, + {"F000", DevExtensionTool::TOOL_TYPE_FAN_F000} + }; + + auto iter = s_type_map.find(type_str); + iter != s_type_map.end() ? ext_tool->m_tool_type = iter->second : DevExtensionTool::TOOL_TYPE_EMPTY; + } + } +} + +} \ No newline at end of file diff --git a/src/slic3r/GUI/DeviceCore/DevExtensionTool.h b/src/slic3r/GUI/DeviceCore/DevExtensionTool.h new file mode 100644 index 0000000000..02f0b6a213 --- /dev/null +++ b/src/slic3r/GUI/DeviceCore/DevExtensionTool.h @@ -0,0 +1,67 @@ +#pragma once +#include +#include "libslic3r/CommonDefs.hpp" + +#include "slic3r/Utils/json_diff.hpp" +#include + +#include "DevDefs.h" + +namespace Slic3r +{ + +//Previous definitions +class MachineObject; + +// some extension tools for toolheads +class DevExtensionTool +{ + friend class DevExtensionToolParser; +public: + static std::shared_ptr Create(MachineObject* obj) { return std::shared_ptr(new DevExtensionTool(obj)); } + +public: + // tool type + bool IsToolTypeFanF000() const { return m_tool_type == TOOL_TYPE_FAN_F000; } + + // mount state + bool IsMounted() const { return m_mount_3dp == MOUNT_MOUNTED; } + +protected: + DevExtensionTool(MachineObject* obj); + +private: + MachineObject* m_owner = nullptr; + + enum MountState + { + MOUNT_NOT_MOUNTED = 0, + MOUNT_MOUNTED = 1, + MOUNT_NO_MODULE = 2, + MOUNT_NO_CABLE = 3 + } m_mount_3dp; + + enum CalibState + { + CALIB_NONE = 0, + CALIB_FIRST = 1, + CALIB_MOUNT = 2 + } m_calib; + + enum ToolType + { + TOOL_TYPE_EMPTY = 0, + TOOL_TYPE_CUT_CP00 = 1, + TOOL_TYPE_LASER_LB00 = 2, + TOOL_TYPE_FAN_F000 = 3, + } m_tool_type; +}; + + +class DevExtensionToolParser +{ +public: + static void ParseV2_0(const nlohmann::json& extension_tool_json, std::weak_ptr extension_tool); +}; + +}; \ No newline at end of file diff --git a/src/slic3r/GUI/DeviceCore/DevUtil.h b/src/slic3r/GUI/DeviceCore/DevUtil.h index 4282d31cf7..252e69558d 100644 --- a/src/slic3r/GUI/DeviceCore/DevUtil.h +++ b/src/slic3r/GUI/DeviceCore/DevUtil.h @@ -37,6 +37,22 @@ public: class DevJsonValParser { public: + template + static T GetVal(const nlohmann::json& j, const std::string& key, const T& default_val = T()) + { + try + { + if (j.contains(key)) { return j[key].get(); } + } + catch (const nlohmann::json::exception& e) + { + assert(0 && __FUNCTION__); + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": " << e.what(); + } + + return default_val; + } + template static void ParseVal(const nlohmann::json& j, const std::string& key, T& val) { diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index b8f4a7826d..416321f195 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -23,6 +23,7 @@ #include "fast_float/fast_float.h" #include "DeviceCore/DevFilaSystem.h" +#include "DeviceCore/DevExtensionTool.h" #include "DeviceCore/DevExtruderSystem.h" #include "DeviceCore/DevNozzleSystem.h" #include "DeviceCore/DevBed.h" @@ -530,6 +531,7 @@ MachineObject::MachineObject(DeviceManager* manager, NetworkAgent* agent, std::s m_bed = new DevBed(this); m_storage = new DevStorage(this); m_extder_system = new DevExtderSystem(this); + m_extension_tool = DevExtensionTool::Create(this); m_nozzle_system = new DevNozzleSystem(this); m_fila_system = new DevFilaSystem(this); m_hms_system = new DevHMS(this); @@ -4972,6 +4974,7 @@ void MachineObject::parse_new_info(json print) if (device.contains("nozzle")) { DevNozzleSystemParser::ParseV2_0(device["nozzle"], m_nozzle_system); } if (device.contains("extruder")) { ExtderSystemParser::ParseV2_0(device["extruder"], m_extder_system);} + if (device.contains("ext_tool")) { DevExtensionToolParser::ParseV2_0(device["ext_tool"], m_extension_tool); } if (device.contains("ctc")) { json const& ctc = device["ctc"]; diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 5fda0eec8d..b09954bbb8 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -79,6 +79,7 @@ class DevAmsTray; class DevBed; class DevConfig; class DevCtrl; +class DevExtensionTool; class DevExtderSystem; class DevFan; class DevFilaSystem; @@ -110,6 +111,7 @@ private: /*parts*/ DevLamp* m_lamp; + std::shared_ptr m_extension_tool; DevExtderSystem* m_extder_system; DevNozzleSystem* m_nozzle_system; DevFilaSystem* m_fila_system; @@ -318,6 +320,8 @@ public: /* parts */ DevExtderSystem* GetExtderSystem() const { return m_extder_system; } + std::weak_ptr GetExtensionTool() const { return m_extension_tool; } + DevNozzleSystem* GetNozzleSystem() const { return m_nozzle_system;} DevFilaSystem* GetFilaSystem() const { return m_fila_system;} diff --git a/src/slic3r/GUI/PrePrintChecker.hpp b/src/slic3r/GUI/PrePrintChecker.hpp index f02f9c1b33..adb54dd3fc 100644 --- a/src/slic3r/GUI/PrePrintChecker.hpp +++ b/src/slic3r/GUI/PrePrintChecker.hpp @@ -88,6 +88,7 @@ enum PrintDialogStatus : unsigned int { PrintStatusTimelapseNoSdcard, PrintStatusTimelapseWarning, PrintStatusMixAmsAndVtSlotWarning, + PrintStatusToolHeadCoolingFanWarning, PrintStatusPrinterWarningEnd, // Warnings for filament diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 7ab5e55b8f..ee214516b7 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -20,6 +20,7 @@ #include "DeviceCore/DevConfig.h" #include "DeviceCore/DevNozzleSystem.h" +#include "DeviceCore/DevExtensionTool.h" #include "DeviceCore/DevExtruderSystem.h" #include "DeviceCore/DevFilaBlackList.h" #include "DeviceCore/DevFilaSystem.h" @@ -1676,6 +1677,9 @@ void SelectMachineDialog::show_status(PrintDialogStatus status, std::vectorGetExtensionTool().lock()) + { + if (extension_tool->IsToolTypeFanF000() && !extension_tool->IsMounted() ) + { + for (const FilamentInfo& item : m_ams_mapping_result) + { + auto filament_info = wxGetApp().preset_bundle->get_filament_by_filament_id(item.filament_id); + if (filament_info && (filament_info->temperature_vitrification <= 50)) + { + show_status(PrintDialogStatus::PrintStatusToolHeadCoolingFanWarning, + { _L("Install toolhead enhanced cooling fan to prevent filament softening.")}, + "https://e.bambulab.com/t?c=l3T7caKGeNt3omA9"); + return; + } + } + } + } +} + ThumbnailPanel::ThumbnailPanel(wxWindow *parent, wxWindowID winid, const wxPoint &pos, const wxSize &size) : wxPanel(parent, winid, pos, size) { diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index 0e45f543a6..38b467016b 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -445,6 +445,9 @@ public: void update_user_printer(); void reset_ams_material(); void update_show_status(MachineObject* obj_ = nullptr); + + void UpdateStatusCheckWarning_ExtensionTool(MachineObject* obj_); + void update_ams_check(MachineObject* obj); void update_filament_change_count(); void on_rename_click(wxMouseEvent &event);