feature add function for web to get the machine storage space.

This commit is contained in:
alves
2026-01-22 14:43:18 +08:00
parent 5d6a6ca2b6
commit 7496e9acd0
6 changed files with 61 additions and 12 deletions

View File

@@ -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<PrintHost> host = nullptr;
wxGetApp().get_connect_host(host);
if (!host) {
handle_general_fail(-1, "Connection lost!");
return;
}
auto weak_self = std::weak_ptr<SSWCP_Instance>(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<PrintHost> host = nullptr;
wxGetApp().get_connect_host(host);
@@ -3710,7 +3731,7 @@ void SSWCP_MachineOption_Instance::CmdForwarding() {
}
auto weak_self = std::weak_ptr<SSWCP_Instance>(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<std::string> 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::string>();
}
std::shared_ptr<SSWCP_Instance> instance = create_sswcp_instance(cmd, header, params, event_id, webview);
if (instance) {
if (event_id != "") {