diff --git a/src/slic3r/GUI/HMS.cpp b/src/slic3r/GUI/HMS.cpp index 6983cd2c0..560df58fb 100644 --- a/src/slic3r/GUI/HMS.cpp +++ b/src/slic3r/GUI/HMS.cpp @@ -406,7 +406,40 @@ wxString HMSQuery::_query_hms_msg(const string& dev_id_type, const string& long_ return wxEmptyString; } -wxString HMSQuery::_query_error_msg(const std::string& dev_id_type, +bool HMSQuery::_is_internal_error(const string &dev_id_type, + const string &error_code, + const string &lang_code) +{ + init_hms_info(dev_id_type); + auto iter = m_hms_info_jsons.find(dev_id_type); + if (iter == m_hms_info_jsons.end()) { return false; } + + const json &m_hms_info_json = iter->second; + if (m_hms_info_json.contains("device_error")) { + if (m_hms_info_json["device_error"].contains(lang_code)) { + for (auto item = m_hms_info_json["device_error"][lang_code].begin(); item != m_hms_info_json["device_error"][lang_code].end(); item++) { + if (item->contains("ecode") && boost::to_upper_copy((*item)["ecode"].get()) == error_code) { + if (item->contains("intro")) { return wxString::FromUTF8((*item)["intro"].get()).IsEmpty(); } + } + } + } else { + // return first language + if (!m_hms_info_json["device_error"].empty()) { + for (auto lang : m_hms_info_json["device_error"]) { + for (auto item = lang.begin(); item != lang.end(); item++) { + if (item->contains("ecode") && boost::to_upper_copy((*item)["ecode"].get()) == error_code) { + if (item->contains("intro")) { return wxString::FromUTF8((*item)["intro"].get()).IsEmpty(); } + } + } + } + } + } + } + + return false; +} + +wxString HMSQuery::_query_error_msg(const std::string &dev_id_type, const std::string& error_code, const std::string& lang_code) { @@ -488,7 +521,15 @@ wxString HMSQuery::_query_error_image_action(const std::string& dev_id_type, con } -wxString HMSQuery::query_print_error_msg(const MachineObject* obj, int print_error) +bool HMSQuery::is_internal_error(const MachineObject *obj, int print_error) +{ + char buf[32]; + ::sprintf(buf, "%08X", print_error); + std::string lang_code = HMSQuery::hms_language_code(); + return _is_internal_error(get_dev_id_type(obj), std::string(buf), lang_code); +} + +wxString HMSQuery::query_print_error_msg(const MachineObject *obj, int print_error) { if (!obj) { diff --git a/src/slic3r/GUI/HMS.hpp b/src/slic3r/GUI/HMS.hpp index 9a8c451c5..9b1ac469b 100644 --- a/src/slic3r/GUI/HMS.hpp +++ b/src/slic3r/GUI/HMS.hpp @@ -42,6 +42,8 @@ public: // query wxString query_hms_msg(const MachineObject* obj, const std::string& long_error_code); wxString query_hms_msg(const std::string& dev_id, const std::string& long_error_code); + + bool is_internal_error(const MachineObject *obj, int print_error); wxString query_print_error_msg(const MachineObject* obj, int print_error); wxString query_print_error_msg(const std::string& dev_id, int print_error); wxString query_print_image_action(const MachineObject* obj, int print_error, std::vector& button_action); @@ -65,6 +67,8 @@ private: // internal query string get_dev_id_type(const MachineObject* obj) const; wxString _query_hms_msg(const string& dev_id_type, const string& long_error_code, const string& lang_code = std::string("en")); + + bool _is_internal_error(const string &dev_id_type, const string &long_error_code, const string &lang_code = std::string("en")); wxString _query_error_msg(const string& dev_id_type, const std::string& long_error_code, const std::string& lang_code = std::string("en")); wxString _query_error_image_action(const string& dev_id_type, const std::string& long_error_code, std::vector& button_action); }; diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index 49dcd5a22..b45220f97 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -2766,6 +2766,11 @@ void StatusPanel::update_error_message() if (print_error_str.size() > 4) { print_error_str.insert(4, "-"); } wxString error_msg = wxGetApp().get_hms_query()->query_print_error_msg(obj, obj->print_error); + if (wxGetApp().get_hms_query()->is_internal_error(obj, obj->print_error)) + { + return; + } + std::vector used_button; wxString error_image_url = wxGetApp().get_hms_query()->query_print_image_action(obj, obj->print_error, used_button); // special case