NEW:add filaments not supported by detection

Change-Id: I1cabf8631e77fbaf42d2b30ee3e715c8f2459bda
This commit is contained in:
tao wang 2023-02-08 10:21:44 +08:00 committed by Lane.Wei
parent 33c22bef62
commit 7c728452a2
7 changed files with 140 additions and 0 deletions

View file

@ -0,0 +1,30 @@
{
"whitelist": [
],
"blacklist": [
{
"vendor": "Third Party",
"type": "TPU",
"action": "prohibition",
"description": "TPU is not supported by AMS."
},
{
"vendor": "Third Party",
"type": "PVA",
"action": "warning",
"description": "Damp PVA will become flexible and get stuck inside AMS,please take care to dry it before use."
},
{
"vendor": "Third Party",
"type": "PA-CF",
"action": "warning",
"description": "CF/GF filaments are hard and brittle, It's easy to break or get stuck in AMS, please use with caution."
},
{
"vendor": "Third Party",
"type": "PLA-CF",
"action": "warning",
"description": "CF/GF filaments are hard and brittle, It's easy to break or get stuck in AMS, please use with caution."
}
]
}

View file

@ -712,6 +712,29 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
if (preset_bundle) {
for (auto it = preset_bundle->filaments.begin(); it != preset_bundle->filaments.end(); it++) {
if (it->alias.compare(m_comboBox_filament->GetValue().ToStdString()) == 0) {
//check is it in the filament blacklist
bool in_blacklist = false;
std::string action;
std::string info;
std::string filamnt_type;
it->get_filament_type(filamnt_type);
DeviceManager::check_filaments_in_blacklist(it->vendor->name, filamnt_type, in_blacklist, action, info);
if (in_blacklist) {
if (action == "prohibition") {
MessageDialog msg_wingow(nullptr, info, _L("Error"), wxICON_WARNING | wxOK);
msg_wingow.ShowModal();
m_comboBox_filament->SetSelection(m_filament_selection);
return;
}
else if (action == "warning") {
MessageDialog msg_wingow(nullptr, info, _L("Warning"), wxICON_INFORMATION | wxOK);
msg_wingow.ShowModal();
}
}
// ) if nozzle_temperature_range is found
ConfigOption* opt_min = it->config.option("nozzle_temperature_range_low");
if (opt_min) {
@ -742,6 +765,8 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
}
if (!found_filament_type)
m_filament_type = "";
break;
}
}
}
@ -751,6 +776,8 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
if (m_input_nozzle_max->GetTextCtrl()->GetValue().IsEmpty()) {
m_input_nozzle_max->GetTextCtrl()->SetValue("220");
}
m_filament_selection = evt.GetSelection();
}
void AMSMaterialsSetting::on_dpi_changed(const wxRect &suggested_rect) { this->Refresh(); }

View file

@ -98,6 +98,7 @@ protected:
TextInput* m_input_k_val;
wxStaticText* m_n_param;
TextInput* m_input_n_val;
int m_filament_selection;
#ifdef __APPLE__
wxComboBox *m_comboBox_filament;

View file

@ -3999,6 +3999,7 @@ void DeviceManager::load_last_machine()
}
json DeviceManager::function_table = json::object();
json DeviceManager::filaments_blacklist = json::object();
std::string DeviceManager::parse_printer_type(std::string type_str)
{
@ -4107,6 +4108,79 @@ bool DeviceManager::load_functional_config(std::string config_file)
return true;
}
bool DeviceManager::load_filaments_blacklist_config(std::string config_file)
{
filaments_blacklist = json::object();
std::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, file = " << config_file;
}
}
catch (...) {
BOOST_LOG_TRIVIAL(error) << "load filaments blacklist config failed, file = " << config_file;
return false;
}
return true;
}
void DeviceManager::check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info)
{
in_blacklist = false;
if (filaments_blacklist.contains("blacklist")) {
for (auto prohibited_filament : filaments_blacklist["blacklist"]) {
std::string vendor;
std::string type;
std::string action;
std::string description;
if (prohibited_filament.contains("vendor") &&
prohibited_filament.contains("type") &&
prohibited_filament.contains("action") &&
prohibited_filament.contains("description"))
{
vendor = prohibited_filament["vendor"].get<std::string>();
type = prohibited_filament["type"].get<std::string>();
action = prohibited_filament["action"].get<std::string>();
description = prohibited_filament["description"].get<std::string>();
}
else {
return;
}
std::transform(vendor.begin(), vendor.end(), vendor.begin(), ::tolower);
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(type.begin(), type.end(), type.begin(), ::tolower);
//third party
if (vendor == "third party") {
if ("bambulab" != vendor && tag_type == type) {
in_blacklist = true;
ac = action;
info = description;
return;
}
}
else {
if (vendor == tag_vendor && tag_type == type) {
in_blacklist = true;
ac = action;
info = description;
return;
}
}
}
}
}
std::string DeviceManager::load_gcode(std::string type_str, std::string gcode_file)
{
std::string gcode_full_path = Slic3r::resources_dir() + "/printers/" + gcode_file;

View file

@ -826,6 +826,8 @@ public:
void load_last_machine();
static json function_table;
static json filaments_blacklist;
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);
@ -834,6 +836,8 @@ public:
static bool get_bed_temperature_limit(std::string type_str, int& limit);
static bool load_functional_config(std::string config_file);
static bool load_filaments_blacklist_config(std::string config_file);
static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info);
static std::string load_gcode(std::string type_str, std::string gcode_file);
};

View file

@ -1162,6 +1162,9 @@ void GUI_App::post_init()
std::string functional_config_file = Slic3r::resources_dir() + "/config.json";
DeviceManager::load_functional_config(encode_path(functional_config_file.c_str()));
std::string filaments_blacklist_config_file = Slic3r::resources_dir() + "/printers/filaments_blacklist.json";
DeviceManager::load_filaments_blacklist_config(encode_path(filaments_blacklist_config_file.c_str()));
// remove old log files over LOG_FILES_MAX_NUM
std::string log_addr = data_dir();
if (!log_addr.empty()) {

View file

@ -284,6 +284,7 @@ private:
bool m_adding_script_handler { false };
bool m_side_popup_status{false};
public:
void check_filaments_in_blacklist(std::string tag_supplier, std::string tag_material, bool& in_blacklist, std::string& action, std::string& info);
std::string get_local_models_path();
bool OnInit() override;
bool initialized() const { return m_initialized; }