NEW: support hms error code
Change-Id: Ic256a83cf501fb05bb9d3203f3d24cb1d1290fa4
This commit is contained in:
parent
91ad448f00
commit
d7db83812f
|
@ -67,11 +67,11 @@ std::string AppConfig::get_hms_host()
|
|||
std::string host = "";
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
if (sel == ENV_DEV_HOST)
|
||||
host = "e-dev.bambu-lab.com";
|
||||
host = "e-dev.bambulab.net";
|
||||
else if (sel == ENV_QAT_HOST)
|
||||
host = "e-qa.bambu-lab.com";
|
||||
host = "e-qa.bambulab.net";
|
||||
else if (sel == ENV_PRE_HOST)
|
||||
host = "e-pre.bambu-lab.com";
|
||||
host = "e-pre.bambulab.net";
|
||||
else if (sel == ENV_PRODUCT_HOST)
|
||||
host = "e.bambulab.com";
|
||||
return host;
|
||||
|
|
|
@ -40,30 +40,45 @@ int get_hms_info_version(std::string& version)
|
|||
return result;
|
||||
}
|
||||
|
||||
int HMSQuery::download_hms_info()
|
||||
int HMSQuery::download_hms_related(std::string hms_type, json* receive_json)
|
||||
{
|
||||
std::string local_version = "0";
|
||||
load_from_local(local_version, hms_type, receive_json);
|
||||
AppConfig* config = wxGetApp().app_config;
|
||||
if (!config) return -1;
|
||||
|
||||
std::string hms_host = wxGetApp().app_config->get_hms_host();
|
||||
std::string lang;
|
||||
std::string query_params = HMSQuery::build_query_params(lang);
|
||||
std::string url = (boost::format("https://%1%/query.php?%2%") % hms_host % query_params).str();
|
||||
std::string url;
|
||||
if (hms_type.compare(QUERY_HMS_INFO) == 0) {
|
||||
url = (boost::format("https://%1%/query.php?%2%&v=%3%") % hms_host % query_params % local_version).str();
|
||||
}
|
||||
else if (hms_type.compare(QUERY_HMS_ACTION) == 0) {
|
||||
url = (boost::format("https://%1%/hms/GetActionImage.php?v=%2%") % hms_host % local_version).str();
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "hms: download url = " << url;
|
||||
|
||||
Slic3r::Http http = Slic3r::Http::get(url);
|
||||
m_hms_json.clear();
|
||||
http.on_complete([this](std::string body, unsigned status) {
|
||||
http.on_complete([this, receive_json, hms_type](std::string body, unsigned status) {
|
||||
try {
|
||||
json j = json::parse(body);
|
||||
if (j.contains("result")) {
|
||||
if (j["result"] == 0 && j.contains("data")) {
|
||||
this->m_hms_json = j["data"];
|
||||
if (hms_type.compare(QUERY_HMS_INFO) == 0) {
|
||||
(*receive_json) = j["data"];
|
||||
this->save_local = true;
|
||||
}
|
||||
else if (hms_type.compare(QUERY_HMS_ACTION) == 0) {
|
||||
(*receive_json)["data"] = j["data"];
|
||||
this->save_local = true;
|
||||
}
|
||||
if (j.contains("ver"))
|
||||
m_hms_json["version"] = std::to_string(j["ver"].get<long long>());
|
||||
(*receive_json)["version"] = std::to_string(j["ver"].get<long long>());
|
||||
} else if (j["result"] == 201){
|
||||
BOOST_LOG_TRIVIAL(info) << "HMSQuery: HMS info is the latest version";
|
||||
}else{
|
||||
this->m_hms_json.clear();
|
||||
receive_json->clear();
|
||||
BOOST_LOG_TRIVIAL(info) << "HMSQuery: update hms info error = " << j["result"].get<int>();
|
||||
}
|
||||
}
|
||||
|
@ -76,19 +91,21 @@ int HMSQuery::download_hms_info()
|
|||
BOOST_LOG_TRIVIAL(error) << "HMSQuery: update hms info error = " << error << ", body = " << body << ", status = " << status;
|
||||
}).perform_sync();
|
||||
|
||||
if (!m_hms_json.empty())
|
||||
save_to_local(lang);
|
||||
if (!receive_json->empty() && save_local == true) {
|
||||
save_to_local(lang, hms_type, *receive_json);
|
||||
save_local = false;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int HMSQuery::load_from_local(std::string &version_info)
|
||||
int HMSQuery::load_from_local(std::string& version_info, std::string hms_type, json* load_json)
|
||||
{
|
||||
if (data_dir().empty()) {
|
||||
version_info = "";
|
||||
version_info = "0";
|
||||
BOOST_LOG_TRIVIAL(error) << "HMS: load_from_local, data_dir() is empty";
|
||||
return -1;
|
||||
}
|
||||
std::string filename = get_hms_file(HMSQuery::hms_language_code());
|
||||
std::string filename = get_hms_file(hms_type, HMSQuery::hms_language_code());
|
||||
auto hms_folder = (boost::filesystem::path(data_dir()) / "hms");
|
||||
if (!fs::exists(hms_folder))
|
||||
fs::create_directory(hms_folder);
|
||||
|
@ -97,9 +114,9 @@ int HMSQuery::load_from_local(std::string &version_info)
|
|||
std::ifstream json_file(encode_path(dir_str.c_str()));
|
||||
try {
|
||||
if (json_file.is_open()) {
|
||||
json_file >> m_hms_json;
|
||||
if (m_hms_json.contains("version")) {
|
||||
version_info = m_hms_json["version"].get<std::string>();
|
||||
json_file >> (*load_json);
|
||||
if ((*load_json).contains("version")) {
|
||||
version_info = (*load_json)["version"].get<std::string>();
|
||||
return 0;
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(warning) << "HMS: load_from_local, no version info";
|
||||
|
@ -107,28 +124,28 @@ int HMSQuery::load_from_local(std::string &version_info)
|
|||
}
|
||||
}
|
||||
} catch(...) {
|
||||
version_info = "";
|
||||
version_info = "0";
|
||||
BOOST_LOG_TRIVIAL(error) << "HMS: load_from_local failed";
|
||||
return -1;
|
||||
}
|
||||
version_info = "";
|
||||
version_info = "0";
|
||||
return 0;
|
||||
}
|
||||
|
||||
int HMSQuery::save_to_local(std::string lang)
|
||||
int HMSQuery::save_to_local(std::string lang, std::string hms_type, json save_json)
|
||||
{
|
||||
if (data_dir().empty()) {
|
||||
BOOST_LOG_TRIVIAL(error) << "HMS: save_to_local, data_dir() is empty";
|
||||
return -1;
|
||||
}
|
||||
std::string filename = get_hms_file(lang);
|
||||
std::string filename = get_hms_file(hms_type,lang);
|
||||
auto hms_folder = (boost::filesystem::path(data_dir()) / "hms");
|
||||
if (!fs::exists(hms_folder))
|
||||
fs::create_directory(hms_folder);
|
||||
std::string dir_str = (hms_folder / filename).make_preferred().string();
|
||||
std::ofstream json_file(encode_path(dir_str.c_str()));
|
||||
if (json_file.is_open()) {
|
||||
json_file << std::setw(4) << m_hms_json << std::endl;
|
||||
json_file << std::setw(4) << save_json << std::endl;
|
||||
json_file.close();
|
||||
return 0;
|
||||
}
|
||||
|
@ -169,9 +186,13 @@ std::string HMSQuery::build_query_params(std::string& lang)
|
|||
return query_params;
|
||||
}
|
||||
|
||||
std::string HMSQuery::get_hms_file(std::string lang)
|
||||
std::string HMSQuery::get_hms_file(std::string hms_type, std::string lang)
|
||||
{
|
||||
//std::string lang_code = HMSQuery::hms_language_code();
|
||||
//return hms action filename
|
||||
if (hms_type.compare(QUERY_HMS_ACTION) == 0) {
|
||||
return (boost::format("hms_action.json")).str();
|
||||
}
|
||||
//return hms filename
|
||||
return (boost::format("hms_%1%.json") % lang).str();
|
||||
}
|
||||
|
||||
|
@ -188,9 +209,9 @@ wxString HMSQuery::_query_hms_msg(std::string long_error_code, std::string lang_
|
|||
if (long_error_code.empty())
|
||||
return wxEmptyString;
|
||||
|
||||
if (m_hms_json.contains("device_hms")) {
|
||||
if (m_hms_json["device_hms"].contains(lang_code)) {
|
||||
for (auto item = m_hms_json["device_hms"][lang_code].begin(); item != m_hms_json["device_hms"][lang_code].end(); item++) {
|
||||
if (m_hms_info_json.contains("device_hms")) {
|
||||
if (m_hms_info_json["device_hms"].contains(lang_code)) {
|
||||
for (auto item = m_hms_info_json["device_hms"][lang_code].begin(); item != m_hms_info_json["device_hms"][lang_code].end(); item++) {
|
||||
if (item->contains("ecode")) {
|
||||
std::string temp_string = (*item)["ecode"].get<std::string>();
|
||||
if (boost::to_upper_copy(temp_string) == long_error_code) {
|
||||
|
@ -204,8 +225,8 @@ wxString HMSQuery::_query_hms_msg(std::string long_error_code, std::string lang_
|
|||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "hms: query_hms_msg, do not contains lang_code = " << lang_code;
|
||||
// return first language
|
||||
if (!m_hms_json["device_hms"].empty()) {
|
||||
for (auto lang : m_hms_json["device_hms"]) {
|
||||
if (!m_hms_info_json["device_hms"].empty()) {
|
||||
for (auto lang : m_hms_info_json["device_hms"]) {
|
||||
for (auto item = lang.begin(); item != lang.end(); item++) {
|
||||
if (item->contains("ecode")) {
|
||||
std::string temp_string = (*item)["ecode"].get<std::string>();
|
||||
|
@ -228,9 +249,9 @@ wxString HMSQuery::_query_hms_msg(std::string long_error_code, std::string lang_
|
|||
|
||||
wxString HMSQuery::_query_error_msg(std::string error_code, std::string lang_code)
|
||||
{
|
||||
if (m_hms_json.contains("device_error")) {
|
||||
if (m_hms_json["device_error"].contains(lang_code)) {
|
||||
for (auto item = m_hms_json["device_error"][lang_code].begin(); item != m_hms_json["device_error"][lang_code].end(); item++) {
|
||||
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<std::string>()) == error_code) {
|
||||
if (item->contains("intro")) {
|
||||
return wxString::FromUTF8((*item)["intro"].get<std::string>());
|
||||
|
@ -241,8 +262,8 @@ wxString HMSQuery::_query_error_msg(std::string error_code, std::string lang_cod
|
|||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "hms: query_error_msg, do not contains lang_code = " << lang_code;
|
||||
// return first language
|
||||
if (!m_hms_json["device_error"].empty()) {
|
||||
for (auto lang : m_hms_json["device_error"]) {
|
||||
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<std::string>()) == error_code) {
|
||||
if (item->contains("intro")) {
|
||||
|
@ -261,6 +282,33 @@ wxString HMSQuery::_query_error_msg(std::string error_code, std::string lang_cod
|
|||
return wxEmptyString;
|
||||
}
|
||||
|
||||
wxString HMSQuery::_query_error_url_action(std::string long_error_code, std::string dev_id, std::vector<int>& button_action)
|
||||
{
|
||||
if (m_hms_action_json.contains("data")) {
|
||||
for (auto item = m_hms_action_json["data"].begin(); item != m_hms_action_json["data"].end(); item++) {
|
||||
if (item->contains("ecode") && boost::to_upper_copy((*item)["ecode"].get<std::string>()) == long_error_code) {
|
||||
if (item->contains("device") && (boost::to_upper_copy((*item)["device"].get<std::string>()) == dev_id ||
|
||||
(*item)["device"].get<std::string>() == "default")) {
|
||||
if (item->contains("actions")) {
|
||||
for (auto item_actions = (*item)["actions"].begin(); item_actions != (*item)["actions"].end(); item_actions++) {
|
||||
button_action.emplace_back(item_actions->get<int>());
|
||||
}
|
||||
}
|
||||
if (item->contains("image")) {
|
||||
return wxString::FromUTF8((*item)["image"].get<std::string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
BOOST_LOG_TRIVIAL(info) << "data is not exists";
|
||||
return wxEmptyString;
|
||||
}
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
|
||||
wxString HMSQuery::query_print_error_msg(int print_error)
|
||||
{
|
||||
char buf[32];
|
||||
|
@ -269,29 +317,22 @@ wxString HMSQuery::query_print_error_msg(int print_error)
|
|||
return _query_error_msg(std::string(buf), lang_code);
|
||||
}
|
||||
|
||||
wxString HMSQuery::query_print_error_url_action(int print_error, std::string dev_id, std::vector<int>& button_action)
|
||||
{
|
||||
char buf[32];
|
||||
::sprintf(buf, "%08X", print_error);
|
||||
//The first three digits of SN number
|
||||
dev_id = dev_id.substr(0, 3);
|
||||
return _query_error_url_action(std::string(buf), dev_id, button_action);
|
||||
}
|
||||
|
||||
|
||||
int HMSQuery::check_hms_info()
|
||||
{
|
||||
boost::thread check_thread = boost::thread([this] {
|
||||
bool download_new_hms_info = true;
|
||||
// load local hms json file
|
||||
std::string version = "";
|
||||
if (load_from_local(version) == 0) {
|
||||
BOOST_LOG_TRIVIAL(info) << "HMS: check_hms_info current version = " << version;
|
||||
std::string new_version;
|
||||
get_hms_info_version(new_version);
|
||||
BOOST_LOG_TRIVIAL(info) << "HMS: check_hms_info latest version = " << new_version;
|
||||
|
||||
if (new_version.empty()) {return 0;}
|
||||
|
||||
if (!version.empty() && version == new_version) {
|
||||
download_new_hms_info = false;
|
||||
}
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << "HMS: check_hms_info need download new hms info = " << download_new_hms_info;
|
||||
// download if version is update
|
||||
if (download_new_hms_info) {
|
||||
download_hms_info();
|
||||
}
|
||||
download_hms_related(QUERY_HMS_INFO, &m_hms_info_json);
|
||||
download_hms_related(QUERY_HMS_ACTION, &m_hms_action_json);
|
||||
return 0;
|
||||
});
|
||||
return 0;
|
||||
|
|
|
@ -16,23 +16,30 @@ namespace Slic3r {
|
|||
namespace GUI {
|
||||
|
||||
#define HMS_INFO_FILE "hms.json"
|
||||
#define QUERY_HMS_INFO "query_hms_info"
|
||||
#define QUERY_HMS_ACTION "query_hms_action"
|
||||
|
||||
class HMSQuery {
|
||||
protected:
|
||||
json m_hms_json;
|
||||
int download_hms_info();
|
||||
int load_from_local(std::string& version_info);
|
||||
int save_to_local(std::string lang);
|
||||
std::string get_hms_file(std::string lang);
|
||||
wxString _query_hms_msg(std::string long_error_code, std::string lang_code = "en");
|
||||
wxString _query_error_msg(std::string long_error_code, std::string lang_code = "en");
|
||||
json m_hms_info_json;
|
||||
json m_hms_action_json;
|
||||
int download_hms_related(std::string hms_type,json* receive_json);
|
||||
int load_from_local(std::string& version_info, std::string hms_type, json* load_json);
|
||||
int save_to_local(std::string lang, std::string hms_type,json save_json);
|
||||
std::string get_hms_file(std::string hms_type, std::string lang = std::string("en"));
|
||||
wxString _query_hms_msg(std::string long_error_code, std::string lang_code = std::string("en"));
|
||||
wxString _query_error_msg(std::string long_error_code, std::string lang_code = std::string("en"));
|
||||
wxString _query_error_url_action(std::string long_error_code, std::string dev_id, std::vector<int>& button_action);
|
||||
public:
|
||||
HMSQuery() {}
|
||||
int check_hms_info();
|
||||
wxString query_hms_msg(std::string long_error_code);
|
||||
wxString query_print_error_msg(int print_error);
|
||||
wxString query_print_error_url_action(int print_error, std::string dev_id, std::vector<int>& button_action);
|
||||
static std::string hms_language_code();
|
||||
static std::string build_query_params(std::string& lang);
|
||||
|
||||
bool save_local = false;
|
||||
};
|
||||
|
||||
int get_hms_info_version(std::string &version);
|
||||
|
|
|
@ -583,6 +583,13 @@ void MediaPlayCtrl::msw_rescale() {
|
|||
m_button_play->Rescale();
|
||||
}
|
||||
|
||||
void MediaPlayCtrl::jump_to_play()
|
||||
{
|
||||
if (m_last_state != MEDIASTATE_IDLE)
|
||||
return;
|
||||
TogglePlay();
|
||||
}
|
||||
|
||||
void MediaPlayCtrl::onStateChanged(wxMediaEvent &event)
|
||||
{
|
||||
auto last_state = m_last_state;
|
||||
|
|
|
@ -42,6 +42,8 @@ public:
|
|||
|
||||
void msw_rescale();
|
||||
|
||||
void jump_to_play();
|
||||
|
||||
protected:
|
||||
void onStateChanged(wxMediaEvent & event);
|
||||
|
||||
|
|
|
@ -132,6 +132,8 @@ AddMachinePanel::~AddMachinePanel() {
|
|||
update_hms_tag();
|
||||
e.Skip();
|
||||
});
|
||||
|
||||
Bind(EVT_JUMP_TO_HMS, &MonitorPanel::jump_to_HMS, this);
|
||||
}
|
||||
|
||||
MonitorPanel::~MonitorPanel()
|
||||
|
@ -576,6 +578,15 @@ std::string MonitorPanel::get_string_from_tab(PrinterTab tab)
|
|||
return "";
|
||||
}
|
||||
|
||||
void MonitorPanel::jump_to_HMS(wxCommandEvent& e)
|
||||
{
|
||||
if (!this->IsShown())
|
||||
return;
|
||||
auto page = m_tabpanel->GetCurrentPage();
|
||||
if (page && page != m_hms_panel)
|
||||
m_tabpanel->SetSelection(PT_HMS);
|
||||
}
|
||||
|
||||
|
||||
} // GUI
|
||||
} // Slic3r
|
||||
|
|
|
@ -155,6 +155,8 @@ public:
|
|||
|
||||
void stop_update() {update_flag = false;};
|
||||
void start_update() {update_flag = true;};
|
||||
|
||||
void jump_to_HMS(wxCommandEvent& e);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -28,12 +28,16 @@ wxDEFINE_EVENT(EVT_SECONDARY_CHECK_CONFIRM, wxCommandEvent);
|
|||
wxDEFINE_EVENT(EVT_SECONDARY_CHECK_CANCEL, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_SECONDARY_CHECK_DONE, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_SECONDARY_CHECK_RESUME, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_LOAD_VAMS_TRAY, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_CHECKBOX_CHANGE, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_ENTER_IP_ADDRESS, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_CLOSE_IPADDRESS_DLG, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_CHECK_IP_ADDRESS_FAILED, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_SECONDARY_CHECK_RETRY, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_PRINT_ERROR_STOP, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_UPDATE_NOZZLE, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_JUMP_TO_HMS, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_JUMP_TO_LIVEVIEW, wxCommandEvent);
|
||||
|
||||
ReleaseNoteDialog::ReleaseNoteDialog(Plater *plater /*= nullptr*/)
|
||||
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, _L("Release Note"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
|
||||
|
@ -841,6 +845,314 @@ void SecondaryCheckDialog::rescale()
|
|||
m_button_cancel->Rescale();
|
||||
}
|
||||
|
||||
PrintErrorDialog::PrintErrorDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style)
|
||||
:DPIFrame(parent, id, title, pos, size, style)
|
||||
{
|
||||
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
|
||||
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
|
||||
btn_bg_white = StateColor(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
|
||||
|
||||
m_sizer_main = new wxBoxSizer(wxVERTICAL);
|
||||
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(350), 1));
|
||||
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
|
||||
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(5));
|
||||
|
||||
wxBoxSizer* m_sizer_right = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
m_sizer_right->Add(0, 0, 1, wxTOP, FromDIP(5));
|
||||
|
||||
m_vebview_release_note = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL);
|
||||
m_vebview_release_note->SetScrollRate(0, 5);
|
||||
m_vebview_release_note->SetBackgroundColour(*wxWHITE);
|
||||
m_vebview_release_note->SetMinSize(wxSize(FromDIP(320), FromDIP(250)));
|
||||
m_sizer_right->Add(m_vebview_release_note, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(15));
|
||||
|
||||
m_error_prompt_pic_static = new wxStaticBitmap(m_vebview_release_note, wxID_ANY, wxBitmap(), wxDefaultPosition, wxSize(FromDIP(300), FromDIP(180)));
|
||||
|
||||
auto bottom_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_sizer_button = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
bottom_sizer->Add(m_sizer_button, 0, wxEXPAND | wxRIGHT | wxLEFT, 0);
|
||||
|
||||
m_sizer_right->Add(bottom_sizer, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(15));
|
||||
m_sizer_right->Add(0, 0, 0, wxTOP, FromDIP(10));
|
||||
|
||||
m_sizer_main->Add(m_sizer_right, 0, wxBOTTOM | wxEXPAND, FromDIP(5));
|
||||
|
||||
Bind(wxEVT_CLOSE_WINDOW, [this](auto& e) {this->on_hide(); });
|
||||
Bind(wxEVT_ACTIVATE, [this](auto& e) { if (!e.GetActive()) this->RequestUserAttention(wxUSER_ATTENTION_ERROR); });
|
||||
Bind(wxEVT_WEBREQUEST_STATE, &PrintErrorDialog::on_webrequest_state, this);
|
||||
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
Layout();
|
||||
m_sizer_main->Fit(this);
|
||||
|
||||
init_button_list();
|
||||
|
||||
CenterOnParent();
|
||||
wxGetApp().UpdateFrameDarkUI(this);
|
||||
}
|
||||
|
||||
void PrintErrorDialog::post_event(wxCommandEvent&& event)
|
||||
{
|
||||
if (event_parent) {
|
||||
event.SetString("");
|
||||
event.SetEventObject(event_parent);
|
||||
wxPostEvent(event_parent, event);
|
||||
event.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
void PrintErrorDialog::on_webrequest_state(wxWebRequestEvent& evt)
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(trace) << "monitor: monitor_panel web request state = " << evt.GetState();
|
||||
switch (evt.GetState()) {
|
||||
case wxWebRequest::State_Completed: {
|
||||
wxImage img(*evt.GetResponse().GetStream());
|
||||
wxImage resize_img = img.Scale(FromDIP(320), FromDIP(180), wxIMAGE_QUALITY_HIGH);
|
||||
wxBitmap error_prompt_pic = resize_img;
|
||||
m_error_prompt_pic_static->SetBitmap(error_prompt_pic);
|
||||
Layout();
|
||||
Fit();
|
||||
|
||||
break;
|
||||
}
|
||||
case wxWebRequest::State_Failed:
|
||||
case wxWebRequest::State_Cancelled:
|
||||
case wxWebRequest::State_Unauthorized: {
|
||||
m_error_prompt_pic_static->SetBitmap(wxBitmap());
|
||||
break;
|
||||
}
|
||||
case wxWebRequest::State_Active:
|
||||
case wxWebRequest::State_Idle: break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void PrintErrorDialog::update_text_image(wxString text, wxString image_url)
|
||||
{
|
||||
//if (!m_sizer_text_release_note) {
|
||||
// m_sizer_text_release_note = new wxBoxSizer(wxVERTICAL);
|
||||
//}
|
||||
wxBoxSizer* sizer_text_release_note = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
|
||||
if (!m_staticText_release_note) {
|
||||
m_staticText_release_note = new Label(m_vebview_release_note, text, LB_AUTO_WRAP);
|
||||
sizer_text_release_note->Add(m_error_prompt_pic_static, 0, wxALIGN_CENTER, FromDIP(5));
|
||||
sizer_text_release_note->Add(m_staticText_release_note, 0, wxALIGN_CENTER , FromDIP(5));
|
||||
m_vebview_release_note->SetSizer(sizer_text_release_note);
|
||||
}
|
||||
if (!image_url.empty()) {
|
||||
web_request = wxWebSession::GetDefault().CreateRequest(this, image_url);
|
||||
BOOST_LOG_TRIVIAL(trace) << "monitor: create new webrequest, state = " << web_request.GetState() << ", url = " << image_url;
|
||||
if (web_request.GetState() == wxWebRequest::State_Idle)
|
||||
web_request.Start();
|
||||
BOOST_LOG_TRIVIAL(trace) << "monitor: start new webrequest, state = " << web_request.GetState() << ", url = " << image_url;
|
||||
m_error_prompt_pic_static->Show();
|
||||
|
||||
}
|
||||
else {
|
||||
m_error_prompt_pic_static->Hide();
|
||||
}
|
||||
sizer_text_release_note->Layout();
|
||||
m_staticText_release_note->SetMaxSize(wxSize(FromDIP(300), -1));
|
||||
m_staticText_release_note->SetMinSize(wxSize(FromDIP(300), -1));
|
||||
m_staticText_release_note->SetLabelText(text);
|
||||
//m_staticText_release_note->SetForegroundColour(wxColour("#5C5C5C"));
|
||||
m_vebview_release_note->Layout();
|
||||
|
||||
auto text_size = m_staticText_release_note->GetBestSize();
|
||||
if (text_size.y < FromDIP(360))
|
||||
if (!image_url.empty()) {
|
||||
m_vebview_release_note->SetMinSize(wxSize(FromDIP(320), text_size.y + FromDIP(220)));
|
||||
}
|
||||
else {
|
||||
m_vebview_release_note->SetMinSize(wxSize(FromDIP(320), text_size.y + FromDIP(25)));
|
||||
}
|
||||
else {
|
||||
m_vebview_release_note->SetMinSize(wxSize(FromDIP(320), FromDIP(340)));
|
||||
}
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
|
||||
void PrintErrorDialog::on_show()
|
||||
{
|
||||
wxGetApp().UpdateFrameDarkUI(this);
|
||||
|
||||
this->Show();
|
||||
this->Raise();
|
||||
}
|
||||
|
||||
void PrintErrorDialog::on_hide()
|
||||
{
|
||||
//m_sizer_button->Clear();
|
||||
//m_sizer_button->Layout();
|
||||
//m_used_button.clear();
|
||||
this->Hide();
|
||||
if (web_request.IsOk() && web_request.GetState() == wxWebRequest::State_Active) {
|
||||
BOOST_LOG_TRIVIAL(info) << "web_request: cancelled";
|
||||
web_request.Cancel();
|
||||
}
|
||||
m_error_prompt_pic_static->SetBitmap(wxBitmap());
|
||||
|
||||
if (wxGetApp().mainframe != nullptr) {
|
||||
wxGetApp().mainframe->Show();
|
||||
wxGetApp().mainframe->Raise();
|
||||
}
|
||||
}
|
||||
|
||||
void PrintErrorDialog::update_title_style(wxString title, std::vector<int> button_style, wxWindow* parent)
|
||||
{
|
||||
SetTitle(title);
|
||||
event_parent = parent;
|
||||
for (int used_button_id : m_used_button) {
|
||||
if (m_button_list.find(used_button_id) != m_button_list.end()) {
|
||||
m_button_list[used_button_id]->Hide();
|
||||
}
|
||||
}
|
||||
m_sizer_button->Clear();
|
||||
m_used_button = button_style;
|
||||
for (int button_id : button_style) {
|
||||
if (m_button_list.find(button_id) != m_button_list.end()) {
|
||||
m_sizer_button->Add(m_button_list[button_id], 0, wxALL, FromDIP(5));
|
||||
m_button_list[button_id]->Show();
|
||||
}
|
||||
}
|
||||
Layout();
|
||||
Fit();
|
||||
|
||||
}
|
||||
|
||||
void PrintErrorDialog::init_button(PrintErrorButton style,wxString buton_text) {
|
||||
Button* print_error_button = new Button(this, buton_text);
|
||||
print_error_button->SetBackgroundColor(btn_bg_white);
|
||||
print_error_button->SetBorderColor(wxColour(38, 46, 48));
|
||||
print_error_button->SetFont(Label::Body_14);
|
||||
print_error_button->SetSize(wxSize(FromDIP(300), FromDIP(30)));
|
||||
print_error_button->SetMinSize(wxSize(FromDIP(300), FromDIP(30)));
|
||||
print_error_button->SetMaxSize(wxSize(-1, FromDIP(30)));
|
||||
print_error_button->SetCornerRadius(FromDIP(5));
|
||||
print_error_button->Hide();
|
||||
m_button_list[style] = print_error_button;
|
||||
|
||||
}
|
||||
|
||||
void PrintErrorDialog::init_button_list() {
|
||||
|
||||
init_button(RESUME_PRINTING, _L("Resume Printing"));
|
||||
m_button_list[RESUME_PRINTING]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
wxCommandEvent evt(EVT_SECONDARY_CHECK_RETRY, GetId());
|
||||
e.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
this->on_hide();
|
||||
});
|
||||
|
||||
init_button(RESUME_PRINTING_DEFECTS, _L("Resume Printing(defects acceptable)"));
|
||||
m_button_list[RESUME_PRINTING_DEFECTS]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
wxCommandEvent evt(EVT_SECONDARY_CHECK_RETRY, GetId());
|
||||
e.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
this->on_hide();
|
||||
});
|
||||
|
||||
|
||||
init_button(RESUME_PRINTING_PROBELM_SOLVED, _L("Resume Printing(problem solved)"));
|
||||
m_button_list[RESUME_PRINTING_PROBELM_SOLVED]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
//load filament and resume printing
|
||||
wxCommandEvent evt(EVT_SECONDARY_CHECK_RETRY, GetId());
|
||||
e.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
this->on_hide();
|
||||
});
|
||||
|
||||
init_button(STOP_PRINTING, _L("Stop Printing"));
|
||||
m_button_list[STOP_PRINTING]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
post_event(wxCommandEvent(EVT_PRINT_ERROR_STOP));
|
||||
e.Skip();
|
||||
});
|
||||
|
||||
init_button(CHECK_ASSISTANT, _L("Check Assistant"));
|
||||
m_button_list[CHECK_ASSISTANT]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
post_event(wxCommandEvent(EVT_JUMP_TO_HMS));
|
||||
this->on_hide();
|
||||
});
|
||||
|
||||
init_button(FILAMENT_EXTRUDED, _L("Filament Extruded, Continue"));
|
||||
m_button_list[FILAMENT_EXTRUDED]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
post_event(wxCommandEvent(EVT_SECONDARY_CHECK_DONE));
|
||||
e.Skip();
|
||||
});
|
||||
|
||||
init_button(RETRY_FILAMENT_EXTRUDED, _L("Not Extruded Yet,Retry"));
|
||||
m_button_list[RETRY_FILAMENT_EXTRUDED]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
wxCommandEvent evt(EVT_SECONDARY_CHECK_RETRY, GetId());
|
||||
e.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
this->on_hide();
|
||||
});
|
||||
|
||||
init_button(CONTINUE, _L("Finished, Continue"));
|
||||
m_button_list[CONTINUE]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
post_event(wxCommandEvent(EVT_SECONDARY_CHECK_DONE));
|
||||
e.Skip();
|
||||
});
|
||||
|
||||
init_button(LOAD_VIRTUAL_TRAY, _L("Load Filament"));
|
||||
m_button_list[LOAD_VIRTUAL_TRAY]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
post_event(wxCommandEvent(EVT_LOAD_VAMS_TRAY));
|
||||
e.Skip();
|
||||
});
|
||||
|
||||
init_button(OK_BUTTON, _L("OK"));
|
||||
m_button_list[OK_BUTTON]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
wxCommandEvent evt(EVT_SECONDARY_CHECK_CONFIRM, GetId());
|
||||
e.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
this->on_hide();
|
||||
});
|
||||
|
||||
init_button(FILAMENT_LOAD_RESUME, _L("Filament Loaded, Resume"));
|
||||
m_button_list[FILAMENT_LOAD_RESUME]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
post_event(wxCommandEvent(EVT_SECONDARY_CHECK_RESUME));
|
||||
e.Skip();
|
||||
});
|
||||
|
||||
init_button(JUMP_TO_LIVEVIEW, _L("View Liveview"));
|
||||
m_button_list[JUMP_TO_LIVEVIEW]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
|
||||
post_event(wxCommandEvent(EVT_JUMP_TO_LIVEVIEW));
|
||||
e.Skip();
|
||||
});
|
||||
}
|
||||
|
||||
PrintErrorDialog::~PrintErrorDialog()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PrintErrorDialog::on_dpi_changed(const wxRect& suggested_rect)
|
||||
{
|
||||
rescale();
|
||||
}
|
||||
|
||||
void PrintErrorDialog::msw_rescale() {
|
||||
wxGetApp().UpdateFrameDarkUI(this);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void PrintErrorDialog::rescale()
|
||||
{
|
||||
for(auto used_button:m_used_button)
|
||||
m_button_list[used_button]->Rescale();
|
||||
}
|
||||
|
||||
ConfirmBeforeSendDialog::ConfirmBeforeSendDialog(wxWindow* parent, wxWindowID id, const wxString& title, enum ButtonStyle btn_style, const wxPoint& pos, const wxSize& size, long style, bool not_show_again_check)
|
||||
:DPIDialog(parent, id, title, pos, size, style)
|
||||
{
|
||||
|
|
|
@ -45,7 +45,11 @@ wxDECLARE_EVENT(EVT_SECONDARY_CHECK_CANCEL, wxCommandEvent);
|
|||
wxDECLARE_EVENT(EVT_SECONDARY_CHECK_RETRY, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_SECONDARY_CHECK_DONE, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_SECONDARY_CHECK_RESUME, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_PRINT_ERROR_STOP, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_UPDATE_NOZZLE, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_LOAD_VAMS_TRAY, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_JUMP_TO_HMS, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_JUMP_TO_LIVEVIEW, wxCommandEvent);
|
||||
|
||||
class ReleaseNoteDialog : public DPIDialog
|
||||
{
|
||||
|
@ -157,6 +161,57 @@ public:
|
|||
std::string show_again_config_text = "";
|
||||
};
|
||||
|
||||
class PrintErrorDialog : public DPIFrame
|
||||
{
|
||||
private:
|
||||
wxWindow* event_parent{ nullptr };
|
||||
public:
|
||||
enum PrintErrorButton {
|
||||
RESUME_PRINTING = 2,
|
||||
RESUME_PRINTING_DEFECTS = 3,
|
||||
RESUME_PRINTING_PROBELM_SOLVED = 4,
|
||||
STOP_PRINTING = 5,
|
||||
CHECK_ASSISTANT = 6,
|
||||
FILAMENT_EXTRUDED = 7,
|
||||
RETRY_FILAMENT_EXTRUDED = 8,
|
||||
CONTINUE = 9,
|
||||
LOAD_VIRTUAL_TRAY = 10,
|
||||
OK_BUTTON = 11,
|
||||
FILAMENT_LOAD_RESUME,
|
||||
JUMP_TO_LIVEVIEW,
|
||||
ERROR_BUTTON_COUNT
|
||||
};
|
||||
PrintErrorDialog(
|
||||
wxWindow* parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxString& title = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxCLOSE_BOX | wxCAPTION
|
||||
);
|
||||
void update_text_image(wxString text, wxString image_url);
|
||||
void on_show();
|
||||
void on_hide();
|
||||
void update_title_style(wxString title, std::vector<int> style, wxWindow* parent = nullptr);
|
||||
void post_event(wxCommandEvent&& event);
|
||||
void rescale();
|
||||
~PrintErrorDialog();
|
||||
void on_dpi_changed(const wxRect& suggested_rect);
|
||||
void msw_rescale();
|
||||
void init_button(PrintErrorButton style, wxString buton_text);
|
||||
void init_button_list();
|
||||
void on_webrequest_state(wxWebRequestEvent& evt);
|
||||
|
||||
StateColor btn_bg_white;
|
||||
wxWebRequest web_request;
|
||||
wxStaticBitmap* m_error_prompt_pic_static;
|
||||
Label* m_staticText_release_note{ nullptr };
|
||||
wxBoxSizer* m_sizer_main;
|
||||
wxBoxSizer* m_sizer_button;
|
||||
wxScrolledWindow* m_vebview_release_note{ nullptr };
|
||||
std::map<int, Button*> m_button_list;
|
||||
std::vector<int> m_used_button;
|
||||
};
|
||||
|
||||
struct ConfirmBeforeSendInfo
|
||||
{
|
||||
|
|
|
@ -1700,6 +1700,14 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co
|
|||
Bind(EVT_FAN_CHANGED, &StatusPanel::on_fan_changed, this);
|
||||
Bind(EVT_SECONDARY_CHECK_DONE, &StatusPanel::on_print_error_done, this);
|
||||
Bind(EVT_SECONDARY_CHECK_RESUME, &StatusPanel::on_subtask_pause_resume, this);
|
||||
Bind(EVT_PRINT_ERROR_STOP, &StatusPanel::on_subtask_abort, this);
|
||||
Bind(EVT_LOAD_VAMS_TRAY, &StatusPanel::on_ams_load_vams, this);
|
||||
Bind(EVT_JUMP_TO_LIVEVIEW, [this](wxCommandEvent& e) {
|
||||
m_media_play_ctrl->jump_to_play();
|
||||
if (m_print_error_dlg)
|
||||
m_print_error_dlg->on_hide();
|
||||
});
|
||||
|
||||
|
||||
m_switch_speed->Connect(wxEVT_LEFT_DOWN, wxCommandEventHandler(StatusPanel::on_switch_speed), NULL, this);
|
||||
m_calibration_btn->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_start_calibration), NULL, this);
|
||||
|
@ -1854,6 +1862,8 @@ void StatusPanel::on_subtask_pause_resume(wxCommandEvent &event)
|
|||
}
|
||||
if (m_print_error_dlg) {
|
||||
m_print_error_dlg->on_hide();
|
||||
}if (m_print_error_dlg_no_action) {
|
||||
m_print_error_dlg_no_action->on_hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2078,46 +2088,27 @@ void StatusPanel::show_recenter_dialog() {
|
|||
obj->command_go_home();
|
||||
}
|
||||
|
||||
void StatusPanel::show_error_message(MachineObject* obj, wxString msg, std::string print_error_str)
|
||||
void StatusPanel::show_error_message(MachineObject* obj, wxString msg, std::string print_error_str, wxString image_url, std::vector<int> used_button)
|
||||
{
|
||||
if (msg.IsEmpty()) {
|
||||
error_info_reset();
|
||||
} else {
|
||||
m_project_task_panel->show_error_msg(msg);
|
||||
|
||||
auto it_retry = std::find(message_containing_retry.begin(), message_containing_retry.end(), print_error_str);
|
||||
auto it_done = std::find(message_containing_done.begin(), message_containing_done.end(), print_error_str);
|
||||
auto it_resume = std::find(message_containing_resume.begin(), message_containing_resume.end(), print_error_str);
|
||||
|
||||
if (!used_button.empty()) {
|
||||
BOOST_LOG_TRIVIAL(info) << "show print error! error_msg = " << msg;
|
||||
if (m_print_error_dlg == nullptr) {
|
||||
m_print_error_dlg = new SecondaryCheckDialog(this->GetParent(), wxID_ANY, _L("Warning"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM);
|
||||
m_print_error_dlg = new PrintErrorDialog(this->GetParent(), wxID_ANY, _L("Error"));
|
||||
}
|
||||
|
||||
if (it_done != message_containing_done.end() && it_retry != message_containing_retry.end()) {
|
||||
m_print_error_dlg->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::DONE_AND_RETRY, this);
|
||||
}
|
||||
else if (it_done != message_containing_done.end()) {
|
||||
m_print_error_dlg->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::CONFIRM_AND_DONE, this);
|
||||
}
|
||||
else if (it_retry != message_containing_retry.end()) {
|
||||
m_print_error_dlg->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::CONFIRM_AND_RETRY, this);
|
||||
}
|
||||
else if (it_resume!= message_containing_resume.end()) {
|
||||
m_print_error_dlg->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::CONFIRM_AND_RESUME, this);
|
||||
}
|
||||
else {
|
||||
m_print_error_dlg->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM, this);
|
||||
}
|
||||
m_print_error_dlg->update_text(msg);
|
||||
|
||||
m_print_error_dlg->update_title_style(_L("Error"), used_button, this);
|
||||
m_print_error_dlg->update_text_image(msg, image_url);
|
||||
m_print_error_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, obj](wxCommandEvent& e) {
|
||||
if (obj) {
|
||||
obj->command_clean_print_error(obj->subtask_id_, obj->print_error);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
m_print_error_dlg->Bind(EVT_SECONDARY_CHECK_RETRY, [this, obj](wxCommandEvent& e) {
|
||||
if (m_ams_control) {
|
||||
m_ams_control->on_retry();
|
||||
|
@ -2125,6 +2116,48 @@ void StatusPanel::show_error_message(MachineObject* obj, wxString msg, std::stri
|
|||
});
|
||||
|
||||
m_print_error_dlg->on_show();
|
||||
}
|
||||
else {
|
||||
//old error code dialog
|
||||
auto it_retry = std::find(message_containing_retry.begin(), message_containing_retry.end(), print_error_str);
|
||||
auto it_done = std::find(message_containing_done.begin(), message_containing_done.end(), print_error_str);
|
||||
auto it_resume = std::find(message_containing_resume.begin(), message_containing_resume.end(), print_error_str);
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "show print error! error_msg = " << msg;
|
||||
if (m_print_error_dlg_no_action == nullptr) {
|
||||
m_print_error_dlg_no_action = new SecondaryCheckDialog(this->GetParent(), wxID_ANY, _L("Warning"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM);
|
||||
}
|
||||
|
||||
if (it_done != message_containing_done.end() && it_retry != message_containing_retry.end()) {
|
||||
m_print_error_dlg_no_action->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::DONE_AND_RETRY, this);
|
||||
}
|
||||
else if (it_done != message_containing_done.end()) {
|
||||
m_print_error_dlg_no_action->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::CONFIRM_AND_DONE, this);
|
||||
}
|
||||
else if (it_retry != message_containing_retry.end()) {
|
||||
m_print_error_dlg_no_action->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::CONFIRM_AND_RETRY, this);
|
||||
}
|
||||
else if (it_resume != message_containing_resume.end()) {
|
||||
m_print_error_dlg_no_action->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::CONFIRM_AND_RESUME, this);
|
||||
}
|
||||
else {
|
||||
m_print_error_dlg_no_action->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM, this);
|
||||
}
|
||||
m_print_error_dlg_no_action->update_text(msg);
|
||||
m_print_error_dlg_no_action->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, obj](wxCommandEvent& e) {
|
||||
if (obj) {
|
||||
obj->command_clean_print_error(obj->subtask_id_, obj->print_error);
|
||||
}
|
||||
});
|
||||
|
||||
m_print_error_dlg_no_action->Bind(EVT_SECONDARY_CHECK_RETRY, [this, obj](wxCommandEvent& e) {
|
||||
if (m_ams_control) {
|
||||
m_ams_control->on_retry();
|
||||
}
|
||||
});
|
||||
|
||||
m_print_error_dlg_no_action->on_show();
|
||||
}
|
||||
wxGetApp().mainframe->RequestUserAttention(wxUSER_ATTENTION_ERROR);
|
||||
}
|
||||
}
|
||||
|
@ -2143,17 +2176,27 @@ void StatusPanel::update_error_message()
|
|||
::sprintf(buf, "%08X", obj->print_error);
|
||||
std::string print_error_str = std::string(buf);
|
||||
if (print_error_str.size() > 4) {
|
||||
print_error_str.insert(4, " ");
|
||||
print_error_str.insert(4, "-");
|
||||
}
|
||||
|
||||
wxString error_msg = wxGetApp().get_hms_query()->query_print_error_msg(obj->print_error);
|
||||
std::vector<int> used_button;
|
||||
wxString error_image_url = wxGetApp().get_hms_query()->query_print_error_url_action(obj->print_error,obj->dev_id, used_button);
|
||||
// special case
|
||||
if (print_error_str == "0300-8003" || print_error_str == "0300-8002" || print_error_str == "0300-800A")
|
||||
used_button.emplace_back(PrintErrorDialog::PrintErrorButton::JUMP_TO_LIVEVIEW);
|
||||
if (!error_msg.IsEmpty()) {
|
||||
wxDateTime now = wxDateTime::Now();
|
||||
wxString show_time = now.Format("%H:%M:%S");
|
||||
error_msg = wxString::Format("%s[%s %s]",
|
||||
wxString show_time;
|
||||
#if !BBL_RELEASE_TO_PUBLIC
|
||||
show_time = now.Format("%Y-%m-%d %H:%M:%S");
|
||||
#else
|
||||
show_time = now.Format("%H:%M:%S");
|
||||
#endif
|
||||
error_msg = wxString::Format("%s\n[%s %s]",
|
||||
error_msg,
|
||||
print_error_str, show_time);
|
||||
show_error_message(obj, error_msg, print_error_str);
|
||||
show_error_message(obj, error_msg, print_error_str,error_image_url,used_button);
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(info) << "show print error! error_msg is empty, print error = " << obj->print_error;
|
||||
}
|
||||
|
@ -3440,6 +3483,16 @@ void StatusPanel::on_ams_load_curr()
|
|||
}
|
||||
}
|
||||
|
||||
void StatusPanel::on_ams_load_vams(wxCommandEvent& event) {
|
||||
BOOST_LOG_TRIVIAL(info) << "on_ams_load_vams_tray";
|
||||
|
||||
m_ams_control->SwitchAms(std::to_string(VIRTUAL_TRAY_ID));
|
||||
on_ams_load_curr();
|
||||
if (m_print_error_dlg) {
|
||||
m_print_error_dlg->on_hide();
|
||||
}
|
||||
}
|
||||
|
||||
void StatusPanel::on_ams_unload(SimpleEvent &event)
|
||||
{
|
||||
if (obj) { obj->command_ams_switch(255); }
|
||||
|
@ -3768,6 +3821,8 @@ void StatusPanel::on_print_error_done(wxCommandEvent& event)
|
|||
obj->command_ams_control("done");
|
||||
if (m_print_error_dlg) {
|
||||
m_print_error_dlg->on_hide();
|
||||
}if (m_print_error_dlg_no_action) {
|
||||
m_print_error_dlg_no_action->on_hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -460,7 +460,8 @@ protected:
|
|||
CalibrationDialog* calibration_dlg {nullptr};
|
||||
AMSMaterialsSetting *m_filament_setting_dlg{nullptr};
|
||||
|
||||
SecondaryCheckDialog* m_print_error_dlg = nullptr;
|
||||
PrintErrorDialog* m_print_error_dlg = nullptr;
|
||||
SecondaryCheckDialog* m_print_error_dlg_no_action = nullptr;
|
||||
SecondaryCheckDialog* abort_dlg = nullptr;
|
||||
SecondaryCheckDialog* con_load_dlg = nullptr;
|
||||
SecondaryCheckDialog* ctrl_e_hint_dlg = nullptr;
|
||||
|
@ -513,7 +514,7 @@ protected:
|
|||
void on_subtask_pause_resume(wxCommandEvent &event);
|
||||
void on_subtask_abort(wxCommandEvent &event);
|
||||
void on_print_error_clean(wxCommandEvent &event);
|
||||
void show_error_message(MachineObject* obj, wxString msg, std::string print_error_str = "");
|
||||
void show_error_message(MachineObject* obj, wxString msg, std::string print_error_str = "",wxString image_url="",std::vector<int> used_button=std::vector<int>());
|
||||
void error_info_reset();
|
||||
void show_recenter_dialog();
|
||||
|
||||
|
@ -542,6 +543,7 @@ protected:
|
|||
void on_ams_load(SimpleEvent &event);
|
||||
void update_filament_step();
|
||||
void on_ams_load_curr();
|
||||
void on_ams_load_vams(wxCommandEvent& event);
|
||||
void on_ams_unload(SimpleEvent &event);
|
||||
void on_ams_filament_backup(SimpleEvent& event);
|
||||
void on_ams_setting_click(SimpleEvent& event);
|
||||
|
|
|
@ -2558,7 +2558,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
|||
wxBoxSizer *m_sizer_button = new wxBoxSizer(wxVERTICAL);
|
||||
wxBoxSizer *m_sizer_button_area = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
m_button_extruder_feed = new Button(m_button_area, _L("Load Filament"));
|
||||
m_button_extruder_feed = new Button(m_button_area, _L("Load"));
|
||||
m_button_extruder_feed->SetFont(Label::Body_13);
|
||||
|
||||
m_button_extruder_feed->SetBackgroundColor(btn_bg_green);
|
||||
|
@ -2576,7 +2576,7 @@ AMSControl::AMSControl(wxWindow *parent, wxWindowID id, const wxPoint &pos, cons
|
|||
if (wxGetApp().app_config->get("language") == "cs_CZ") m_button_extruder_feed->SetFont(Label::Body_9);
|
||||
if (wxGetApp().app_config->get("language") == "uk_UA") m_button_extruder_feed->SetFont(Label::Body_9);
|
||||
|
||||
m_button_extruder_back = new Button(m_button_area, _L("Unload Filament"));
|
||||
m_button_extruder_back = new Button(m_button_area, _L("Unload"));
|
||||
m_button_extruder_back->SetBackgroundColor(btn_bg_white);
|
||||
m_button_extruder_back->SetBorderColor(btn_bd_white);
|
||||
m_button_extruder_back->SetTextColor(btn_text_white);
|
||||
|
|
Loading…
Reference in New Issue