From 3034ec742534fdda320fa212a0c6b53cf80ccd2f Mon Sep 17 00:00:00 2001 From: Stone Li Date: Thu, 1 Dec 2022 17:35:54 +0800 Subject: [PATCH] NEW: add limitation of bed temperature Change-Id: Ib25f28d8803a022678d67ee05cf1d0c48e8727c4 Signed-off-by: Stone Li --- resources/config.json | 1 + src/slic3r/GUI/DeviceManager.cpp | 34 ++++++++++++++++++++++++++++++++ src/slic3r/GUI/DeviceManager.hpp | 7 +++++++ src/slic3r/GUI/StatusPanel.cpp | 7 +++++++ 4 files changed, 49 insertions(+) diff --git a/resources/config.json b/resources/config.json index 11434fe87..660cbfca3 100644 --- a/resources/config.json +++ b/resources/config.json @@ -21,6 +21,7 @@ "FUNC_ALTER_RESOLUTION": false }, "camera_resolution":["720p"], + "bed_temperature_limit": 100, "model_id": "C11", "printer_type": "C11" }, diff --git a/src/slic3r/GUI/DeviceManager.cpp b/src/slic3r/GUI/DeviceManager.cpp index 637ce9358..14fd23c40 100644 --- a/src/slic3r/GUI/DeviceManager.cpp +++ b/src/slic3r/GUI/DeviceManager.cpp @@ -1138,6 +1138,7 @@ void MachineObject::parse_state_changed_event() void MachineObject::parse_status(int flag) { + is_220V_voltage = ((flag >> 3) & 0x1) != 0; if (xcam_auto_recovery_hold_count > 0) xcam_auto_recovery_hold_count--; else { @@ -1164,6 +1165,22 @@ PrintingSpeedLevel MachineObject::_parse_printing_speed_lvl(int lvl) return PrintingSpeedLevel::SPEED_LEVEL_INVALID; } +int MachineObject::get_bed_temperature_limit() +{ + if (printer_type == "BL-P001" || printer_type == "BL-P002") { + if (is_220V_voltage) + return 110; + else { + return 120; + } + } else { + int limit = BED_TEMP_LIMIT; + DeviceManager::get_bed_temperature_limit(printer_type, limit); + return limit; + } + return BED_TEMP_LIMIT; +} + bool MachineObject::is_sdcard_printing() { if (can_abort() @@ -1772,6 +1789,7 @@ void MachineObject::reset() BOOST_LOG_TRIVIAL(trace) << "reset dev_id=" << dev_id; last_update_time = std::chrono::system_clock::now(); m_push_count = 0; + is_220V_voltage = false; camera_recording = false; camera_recording_when_printing = false; camera_timelapse = false; @@ -3595,6 +3613,22 @@ std::vector DeviceManager::get_resolution_supported(std::string typ return resolution_supported; } +bool DeviceManager::get_bed_temperature_limit(std::string type_str, int &limit) +{ + bool result = false; + if (DeviceManager::function_table.contains("printers")) { + for (auto printer : DeviceManager::function_table["printers"]) { + if (printer.contains("model_id") && printer["model_id"].get() == type_str) { + if (printer.contains("bed_temperature_limit")) { + limit = printer["bed_temperature_limit"].get(); + return true; + } + } + } + } + return result; +} + bool DeviceManager::load_functional_config(std::string config_file) { std::ifstream json_file(config_file.c_str()); diff --git a/src/slic3r/GUI/DeviceManager.hpp b/src/slic3r/GUI/DeviceManager.hpp index 8a3e2223e..d1398724a 100644 --- a/src/slic3r/GUI/DeviceManager.hpp +++ b/src/slic3r/GUI/DeviceManager.hpp @@ -22,6 +22,7 @@ #define FILAMENT_MAX_TEMP 300 #define FILAMENT_DEF_TEMP 220 #define FILAMENT_MIN_TEMP 120 +#define BED_TEMP_LIMIT 120 #define HOLD_COUNT_MAX 3 @@ -499,6 +500,10 @@ public: /* printing */ std::string print_type; + float nozzle { 0.0f }; + bool is_220V_voltage { false }; + + int mc_print_stage; int mc_print_sub_stage; int mc_print_error_code; @@ -536,6 +541,7 @@ public: PrintingSpeedLevel printing_speed_lvl; int printing_speed_mag = 100; PrintingSpeedLevel _parse_printing_speed_lvl(int lvl); + int get_bed_temperature_limit(); /* camera */ bool has_ipcam { false }; @@ -747,6 +753,7 @@ public: static bool is_function_supported(std::string type_str, std::string function_name); static std::vector get_resolution_supported(std::string type_str); + static bool get_bed_temperature_limit(std::string type_str, int& limit); static bool load_functional_config(std::string config_file); }; diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index 25f7aabcb..e3a7c1aff 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -1590,6 +1590,7 @@ void StatusPanel::update_temp_ctrl(MachineObject *obj) if (!obj) return; m_tempCtrl_bed->SetCurrTemp((int) obj->bed_temp); + m_tempCtrl_bed->SetMaxTemp(obj->get_bed_temperature_limit()); // update temprature if not input temp target if (m_temp_bed_timeout > 0) { @@ -2243,6 +2244,12 @@ void StatusPanel::on_set_bed_temp() long bed_temp; if (str.ToLong(&bed_temp) && obj) { set_hold_count(m_temp_bed_timeout); + int limit = obj->get_bed_temperature_limit(); + if (bed_temp >= limit) { + BOOST_LOG_TRIVIAL(info) << "can not set over limit = " << limit << ", set temp = " << bed_temp; + bed_temp = limit; + m_tempCtrl_bed->SetTagTemp(wxString::Format("%d", bed_temp)); + } obj->command_set_bed(bed_temp); } } catch (...) {