diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index ea8aca89f8..d7f557bf4d 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -4853,8 +4853,9 @@ void GUI_App::check_new_version_sf(bool show_tips, bool by_user) Semver server_version = get_version(version_info.version_str, matcher); - if (current_version >= server_version && by_user) { - this->no_new_version(); + if (current_version >= server_version) { + if(by_user) + this->no_new_version(); return; } diff --git a/src/slic3r/GUI/SSWCP.cpp b/src/slic3r/GUI/SSWCP.cpp index 4de740574b..3c53500bf1 100644 --- a/src/slic3r/GUI/SSWCP.cpp +++ b/src/slic3r/GUI/SSWCP.cpp @@ -2084,11 +2084,9 @@ void SSWCP_MachineOption_Instance::process() sw_ServerClientManagerSetUserinfo(); } else if (m_cmd == "sw_DefectDetactionConfig"){ sw_DefectDetactionConfig(); - } else if (m_cmd == GETCAMERA_TIMELAPSE_INSTANCE) { - CmdForwarding(); - } + } else if (m_cmd == GET_DEVICEDATA_STORAGESPACE) { - CmdForwarding(); + sw_GetDeviceDataStorageSpace(); } else { handle_general_fail(); @@ -3674,6 +3672,28 @@ void SSWCP_MachineOption_Instance::sw_UploadCameraTimelapse() handle_general_fail(); } } +void SSWCP_MachineOption_Instance::CmdForwarding() +{ + try { + std::shared_ptr host = nullptr; + wxGetApp().get_connect_host(host); + + if (!host) { + handle_general_fail(-1, "Connection lost!"); + return; + } + + auto weak_self = std::weak_ptr(shared_from_this()); + host->test_async_wcp_mqtt_moonraker(m_param_data, [weak_self](const json& response) { + auto self = weak_self.lock(); + if (self) { + SSWCP_Instance::on_mqtt_msg_arrived(self, response); + } + }); + } catch (std::exception& e) { + handle_general_fail(); + } +} void SSWCP_MachineOption_Instance::sw_GetTimelapseInstance() { @@ -3698,8 +3718,9 @@ void SSWCP_MachineOption_Instance::sw_GetTimelapseInstance() handle_general_fail(); } } +void SSWCP_MachineOption_Instance::sw_GetDeviceDataStorageSpace() +{ -void SSWCP_MachineOption_Instance::CmdForwarding() { try { std::shared_ptr host = nullptr; wxGetApp().get_connect_host(host); @@ -3710,7 +3731,7 @@ void SSWCP_MachineOption_Instance::CmdForwarding() { } auto weak_self = std::weak_ptr(shared_from_this()); - host->async_delete_camera_timelapse(m_param_data, [weak_self](const json& response) { + host->async_get_userdata_space(m_param_data, [weak_self](const json& response) { auto self = weak_self.lock(); if (self) { SSWCP_Instance::on_mqtt_msg_arrived(self, response); @@ -3721,7 +3742,6 @@ void SSWCP_MachineOption_Instance::CmdForwarding() { } } - void SSWCP_MachineOption_Instance::sw_DeleteCameraTimelapse() { try { @@ -5844,7 +5864,6 @@ std::unordered_set SSWCP::m_machine_option_cmd_list = { "sw_GetTimelapseInstance", "sw_ServerClientManagerSetUserinfo", "sw_DefectDetactionConfig", - GETCAMERA_TIMELAPSE_INSTANCE, GET_DEVICEDATA_STORAGESPACE }; @@ -5936,7 +5955,6 @@ void SSWCP::handle_web_message(std::string message, wxWebView* webview) { if (payload.count("event_id") && !payload["event_id"].is_null()) { event_id = payload["event_id"].get(); } - std::shared_ptr instance = create_sswcp_instance(cmd, header, params, event_id, webview); if (instance) { if (event_id != "") { diff --git a/src/slic3r/GUI/SSWCP.hpp b/src/slic3r/GUI/SSWCP.hpp index 5e4182a0f3..e010007c3e 100644 --- a/src/slic3r/GUI/SSWCP.hpp +++ b/src/slic3r/GUI/SSWCP.hpp @@ -29,7 +29,6 @@ using tcp = asio::ip::tcp; #define GET_PRIVACY_STATUS "sw_GetUserUpdatePrivacy" #define UPLOAD_CAMERA_TIMELAPSE "sw_UploadCameraTimelapse" #define DELETE_CAMERA_TIMELAPSE "sw_DeleteCameraTimelapse" -#define GETCAMERA_TIMELAPSE_INSTANCE "sw_GetCameraTimelapseInstance" #define GET_DEVICEDATA_STORAGESPACE "sw_GetDeviceDataStorageSpace" namespace Slic3r { namespace GUI { @@ -426,6 +425,8 @@ private: void sw_DefectDetactionConfig(); + void sw_GetDeviceDataStorageSpace(); + void CmdForwarding(); // Download machine file diff --git a/src/slic3r/Utils/MoonRaker.cpp b/src/slic3r/Utils/MoonRaker.cpp index d4c2140bda..afd1cd31a5 100644 --- a/src/slic3r/Utils/MoonRaker.cpp +++ b/src/slic3r/Utils/MoonRaker.cpp @@ -2399,6 +2399,30 @@ void Moonraker_Mqtt::async_get_timelapse_instance(const nlohmann::json& targets, } } +//get the mechine local storage space +void Moonraker_Mqtt::async_get_userdata_space(const nlohmann::json& targets, std::function callback) +{ + auto& wcp_loger = GUI::WCP_Logger::getInstance(); + std::string method = "camera.get_timelapse_instance"; + + json params = json::object(); + + params = targets; + + if (!send_to_request(method, params, true, callback, + [callback, &wcp_loger]() { + BOOST_LOG_TRIVIAL(warning) << "[Moonraker_Mqtt] get uoser storage space"; + wcp_loger.add_log("get uoser storage space timeout", false, "", "Moonraker_Mqtt", "warning"); + json res; + res["error"] = "timeout"; + callback(res); + }) &&callback) { + BOOST_LOG_TRIVIAL(error) << "[Moonraker_Mqtt]send the cmd to get uoser storage space fail"; + wcp_loger.add_log("send the cmd to get uoser storage space fail", false, "", "Moonraker_Mqtt", "error"); + callback(json::value_t::null); + } +} + // 请求删除延时摄影文件 void Moonraker_Mqtt::async_delete_camera_timelapse(const nlohmann::json& targets, std::function callback) diff --git a/src/slic3r/Utils/MoonRaker.hpp b/src/slic3r/Utils/MoonRaker.hpp index 784f682aac..7e04783c21 100644 --- a/src/slic3r/Utils/MoonRaker.hpp +++ b/src/slic3r/Utils/MoonRaker.hpp @@ -140,6 +140,7 @@ public: virtual void async_defect_detaction_config(const nlohmann::json& targets, std::function) {} + virtual void async_get_userdata_space(const nlohmann::json& targets, std::function) {} protected: // Internal upload implementations @@ -272,6 +273,8 @@ public: virtual void async_get_timelapse_instance(const nlohmann::json& targets, std::function) override; + virtual void async_get_userdata_space(const nlohmann::json& targets, std::function) override; + virtual void async_defect_detaction_config(const nlohmann::json& targets, std::function) override; void set_connection_lost(std::function callback) override; diff --git a/src/slic3r/Utils/PrintHost.hpp b/src/slic3r/Utils/PrintHost.hpp index 2ecb087ce0..4fe08be21a 100644 --- a/src/slic3r/Utils/PrintHost.hpp +++ b/src/slic3r/Utils/PrintHost.hpp @@ -170,6 +170,8 @@ public: virtual void async_delete_camera_timelapse(const nlohmann::json& targets, std::function) {} virtual void async_get_timelapse_instance(const nlohmann::json& targets, std::function) {} + + virtual void async_get_userdata_space(const nlohmann::json& targets, std::function) {} virtual void async_defect_detaction_config(const nlohmann::json& targets, std::function) {}