ENH: add param printer_is_enclosed

1.Use printer_is_enclosed to decide whether display a pop up when bed
temp is higher than softening temp

jira: STUDIO-4532

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I8602db8815093acded0439336f9a8fee52670261
This commit is contained in:
xun.zhang 2023-10-09 16:57:50 +08:00 committed by Lane.Wei
parent 0bf2fa181a
commit 562f87f550
9 changed files with 54 additions and 37 deletions

View File

@ -47,7 +47,8 @@
"use_ams_type":"generic",
"printer_arch":"core_xy",
"printer_series":"series_x1",
"has_cali_line":true
"has_cali_line":true,
"printer_is_enclosed":true
},
"01.01.01.00": {
"print": {

View File

@ -47,7 +47,8 @@
"use_ams_type":"generic",
"printer_arch" : "core_xy",
"printer_series":"series_x1",
"has_cali_line":true
"has_cali_line":true,
"printer_is_enclosed":true
},
"01.01.01.00": {
"print": {

View File

@ -45,7 +45,8 @@
"use_ams_type":"generic",
"printer_arch" : "core_xy",
"printer_series":"series_p1p",
"has_cali_line":false
"has_cali_line":false,
"printer_is_enclosed":false
},
"01.02.00.00": {
"print": {

View File

@ -45,7 +45,8 @@
"use_ams_type":"generic",
"printer_arch" : "core_xy",
"printer_series":"series_p1p",
"has_cali_line":false
"has_cali_line":false,
"printer_is_enclosed":true
},
"01.02.99.10" : {
"print": {

View File

@ -50,7 +50,8 @@
"use_ams_type":"generic",
"printer_arch" : "core_xy",
"printer_series":"series_x1",
"has_cali_line":true
"has_cali_line":true,
"printer_is_enclosed":true
},
"01.05.06.06": {
"rv2166": "00.00.21.20"

View File

@ -46,6 +46,7 @@
"use_ams_type":"f1",
"printer_arch" : "i3",
"printer_series":"series_p1p",
"has_cali_line":false
"has_cali_line":false,
"printer_is_enclosed":false
}
}

View File

@ -483,6 +483,11 @@ std::string MachineObject::get_printer_ams_type() const
return DeviceManager::get_printer_ams_type(printer_type);
}
bool MachineObject::get_printer_is_enclosed() const
{
return DeviceManager::get_printer_is_enclosed(printer_type);
}
void MachineObject::reload_printer_settings()
{
print_json.load_compatible_settings("", "");
@ -5373,63 +5378,47 @@ void DeviceManager::load_last_machine()
json DeviceManager::filaments_blacklist = json::object();
std::string DeviceManager::get_string_from_config(std::string type_str, std::string item)
{
std::string config_file = Slic3r::resources_dir() + "/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(item)) {
return printer[item].get<std::string>();
}
}
}
}
catch (...) {}
return "";
}
std::string DeviceManager::parse_printer_type(std::string type_str)
{
return get_string_from_config(type_str, "printer_type");
return get_value_from_config<std::string>(type_str, "printer_type");
}
std::string DeviceManager::get_printer_display_name(std::string type_str)
{
return get_string_from_config(type_str, "display_name");
return get_value_from_config<std::string>(type_str, "display_name");
}
std::string DeviceManager::get_ftp_folder(std::string type_str)
{
return get_string_from_config(type_str, "ftp_folder");
return get_value_from_config<std::string>(type_str, "ftp_folder");
}
PrinterArch DeviceManager::get_printer_arch(std::string type_str)
{
return get_printer_arch_by_str(get_string_from_config(type_str, "printer_arch"));
return get_printer_arch_by_str(get_value_from_config<std::string>(type_str, "printer_arch"));
}
std::string DeviceManager::get_printer_thumbnail_img(std::string type_str)
{
return get_string_from_config(type_str, "printer_thumbnail_image");
return get_value_from_config<std::string>(type_str, "printer_thumbnail_image");
}
std::string DeviceManager::get_printer_ams_type(std::string type_str)
{
return get_string_from_config(type_str, "use_ams_type");
return get_value_from_config<std::string>(type_str, "use_ams_type");
}
std::string DeviceManager::get_printer_series(std::string type_str)
{
return get_string_from_config(type_str, "printer_series");
return get_value_from_config<std::string>(type_str, "printer_series");
}
std::string DeviceManager::get_printer_diagram_img(std::string type_str)
{
return get_string_from_config(type_str, "printer_connect_help_image");
return get_value_from_config<std::string>(type_str, "printer_connect_help_image");
}
std::string DeviceManager::get_printer_ams_img(std::string type_str)
{
return get_string_from_config(type_str, "printer_use_ams_image");
return get_value_from_config<std::string>(type_str, "printer_use_ams_image");
}
bool DeviceManager::get_printer_is_enclosed(std::string type_str) {
return get_value_from_config<bool>(type_str, "printer_is_enclosed");
}
std::vector<std::string> DeviceManager::get_resolution_supported(std::string type_str)
{
std::vector<std::string> resolution_supported;

View File

@ -7,13 +7,14 @@
#include <memory>
#include <chrono>
#include <boost/thread.hpp>
#include <boost/nowide/fstream.hpp>
#include "nlohmann/json.hpp"
#include "libslic3r/ProjectTask.hpp"
#include "slic3r/Utils/json_diff.hpp"
#include "slic3r/Utils/NetworkAgent.hpp"
#include "CameraPopup.hpp"
#include "libslic3r/Calib.hpp"
#include "libslic3r/Utils.hpp"
#define USE_LOCAL_SOCKET_BIND 0
#define DISCONNECT_TIMEOUT 30000.f // milliseconds
@ -424,6 +425,7 @@ public:
PrinterSeries get_printer_series() const;
PrinterArch get_printer_arch() const;
std::string get_printer_ams_type() const;
bool get_printer_is_enclosed() const;
void reload_printer_settings();
@ -969,7 +971,26 @@ public:
static json function_table;
static json filaments_blacklist;
static std::string get_string_from_config(std::string type_str, std::string item);
template<typename T>
static T get_value_from_config(std::string type_str, std::string item){
std::string config_file = Slic3r::resources_dir() + "/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(item)) {
return printer[item].get<T>();
}
}
}
}
catch (...) {}
return "";
}
static std::string parse_printer_type(std::string type_str);
static std::string get_printer_display_name(std::string type_str);
static std::string get_printer_thumbnail_img(std::string type_str);
@ -979,6 +1000,7 @@ public:
static std::string get_printer_ams_img(std::string type_str);
static PrinterArch get_printer_arch(std::string type_str);
static std::string get_ftp_folder(std::string type_str);
static bool get_printer_is_enclosed(std::string type_str);
static std::vector<std::string> get_resolution_supported(std::string type_str);
static std::vector<std::string> get_compatible_machine(std::string type_str);
static bool load_filaments_blacklist_config(std::string config_file);

View File

@ -2378,7 +2378,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
for (auto warning : plate->get_slice_result()->warnings) {
if (warning.msg == BED_TEMP_TOO_HIGH_THAN_FILAMENT) {
if ((obj_->get_printer_series() == PrinterSeries::SERIES_X1)) {
if ((obj_->get_printer_is_enclosed())){
confirm_text.push_back(Plater::get_slice_warning_string(warning) + "\n");
has_slice_warnings = true;
}