feature add bury point for soft

This commit is contained in:
alves
2025-12-16 10:55:59 +08:00
parent 9fb4c6f908
commit 472db8ba6a
10 changed files with 89 additions and 6 deletions

View File

@@ -115,9 +115,9 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dev-utils/platform/msw/Snapmaker_Orca
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dev-utils/platform/msw/Snapmaker_Orca.manifest.in ${CMAKE_CURRENT_BINARY_DIR}/Snapmaker_Orca.manifest @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dev-utils/platform/osx/Info.plist.in ${CMAKE_CURRENT_BINARY_DIR}/Info.plist @ONLY)
if (WIN32)
add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp dev-utils/BaseException.cpp dev-utils/BaseException.h dev-utils/StackWalker.cpp dev-utils/StackWalker.h sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp)
add_library(Snapmaker_Orca SHARED Snapmaker_Orca.cpp Snapmaker_Orca.hpp dev-utils/BaseException.cpp dev-utils/BaseException.h dev-utils/StackWalker.cpp dev-utils/StackWalker.h sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp bury_cfg/bury_point.hpp bury_cfg/bury_point.cpp)
else ()
add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp)
add_executable(Snapmaker_Orca Snapmaker_Orca.cpp Snapmaker_Orca.hpp sentry_wrapper/SentryWrapper.hpp sentry_wrapper/SentryWrapper.cpp bury_cfg/bury_point.hpp bury_cfg/bury_point.cpp)
endif ()
if (MINGW)
@@ -181,7 +181,7 @@ if (WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -municode")
endif()
add_executable(Snapmaker_Orca_app_gui WIN32 Snapmaker_Orca_app_msvc.cpp sentry_wrapper/SentryWrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/Snapmaker_Orca.rc)
add_executable(Snapmaker_Orca_app_gui WIN32 Snapmaker_Orca_app_msvc.cpp sentry_wrapper/SentryWrapper.cpp bury_cfg/bury_point.cpp ${CMAKE_CURRENT_BINARY_DIR}/Snapmaker_Orca.rc)
# Generate debug symbols even in release mode.
if(MSVC)
target_link_options(Snapmaker_Orca_app_gui PUBLIC "$<$<CONFIG:RELEASE>:/DEBUG>")

View File

@@ -6296,9 +6296,12 @@ extern "C" {
int main(int argc, char **argv)
{
initSentry();
std::string softStartTime = BP_SOFT_START_TIME+ ":" + get_timestamp_seconds();
sentryReportLog(SENTRY_LOG_TRACE, softStartTime, BP_START_SOFT);
auto res = CLI().run(argc, argv);
std::string softEndTime = BP_SOFT_END_TIME + ":" + get_timestamp_seconds();
sentryReportLog(SENTRY_LOG_TRACE, softEndTime, BP_START_SOFT);
exitSentry();
return res;

View File

@@ -227,6 +227,8 @@ int wmain(int argc, wchar_t** argv)
_set_error_mode(_OUT_TO_MSGBOX);
initSentry();
std::string softStartTime = BP_SOFT_START_TIME + std::string(":") + get_timestamp_seconds();
sentryReportLog(SENTRY_LOG_TRACE, softStartTime, BP_START_SOFT);
std::vector<wchar_t*> argv_extended;
argv_extended.emplace_back(argv[0]);
@@ -292,6 +294,8 @@ int wmain(int argc, wchar_t** argv)
HINSTANCE hInstance_Slic3r = LoadLibraryExW(path_to_slic3r, nullptr, 0);
if (hInstance_Slic3r == nullptr) {
printf("Snapmaker_Orca.dll was not loaded, error=%d\n", GetLastError());
std::string softEndTime = BP_SOFT_END_TIME + std::string(":") + get_timestamp_seconds();
sentryReportLog(SENTRY_LOG_TRACE, softEndTime, BP_START_SOFT);
exitSentry();
return -1;
}
@@ -308,12 +312,16 @@ int wmain(int argc, wchar_t** argv)
);
if (Snapmaker_Orca_main == nullptr) {
printf("could not locate the function Snapmaker_Orca_main in Snapmaker_Orca.dll\n");
std::string softEndTime = BP_SOFT_END_TIME + std::string(":") + get_timestamp_seconds();
sentryReportLog(SENTRY_LOG_TRACE, softEndTime, BP_START_SOFT);
exitSentry();
return -1;
}
// argc minus the trailing nullptr of the argv
auto res = Snapmaker_Orca_main((int) argv_extended.size() - 1, argv_extended.data());
std::string softEndTime = BP_SOFT_END_TIME + std::string(":") + get_timestamp_seconds();
sentryReportLog(SENTRY_LOG_TRACE, softEndTime, BP_START_SOFT);
exitSentry();
return res;
}

View File

@@ -0,0 +1,18 @@
#include "bury_point.hpp"
#include <chrono>
#include <ctime>
#include <iomanip>
#include <sstream>
std::string get_timestamp_seconds()
{
auto now = std::chrono::system_clock::now();
auto timestamp = std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch()).count();
std::ostringstream oss;
oss << timestamp;
auto strTime = oss.str();
return strTime;
}

View File

@@ -0,0 +1,39 @@
#ifndef _BURY_POINT_hpp_
#define _BURY_POINT_hpp_
#include <string>
#include <iostream>
#define BP_START_SOFT "bury_point_start_soft"
#define BP_SOFT_START_TIME "soft_start_time"
#define BP_SOFT_END_TIME "soft_end_time"
#define BP_DEIVCE_CONNECT "bury_point_device_connect"
#define BP_CONNECT_DEVICE_ID "device_id"
#define BP_CONNECT_NET_TYPE "net_type"
#define BP_LOGIN "bury_point_login"
#define BP_LOGIN_USER_ID "user_id"
#define BP_LOGIN_HTTP_CODE "http_code"
#define BP_VIDEO_START "bury_point_video_start"
#define BP_VIDEO_STATUS "video_status"
#define BP_DEVICE_ERROR "bury_point_device_error"
#define BP_DEVICE_ERROR_STATUS "error_status"
#define BP_UPLOAD "bury_point_upload"
#define BP_UPLOAD_AND_PRINT "bury_point_upload_and_print"
#define BP_COLOR_PAINTING "bury_point_color_painting"
#define BP_VIDEO_ABNORMAL "bury_point_video_abnormal"
//webview bury point
static bool isAgreeSlice = false;
extern std::string get_timestamp_seconds();
#endif

View File

@@ -2,6 +2,7 @@
#define slic3r_SentryWrapper_hpp_
#include <string>
#include "bury_cfg/bury_point.hpp"
namespace Slic3r {

View File

@@ -34,6 +34,7 @@
#include <wx/glcanvas.h>
#include "sentry_wrapper/SentryWrapper.hpp"
namespace Slic3r {
namespace GUI {
//BBS: GUI refactor: to support top layout
@@ -350,6 +351,8 @@ bool GLGizmosManager::open_gizmo(EType type)
#ifdef __WXOSX__
m_parent.post_event(SimpleEvent(wxEVT_PAINT));
#endif
if (EType::MmSegmentation == type)
sentryReportLog(SENTRY_LOG_TRACE, "", BP_COLOR_PAINTING);
return true;
}
return false;

View File

@@ -3,6 +3,7 @@
#include <algorithm>
#include <iomanip>
#include "sentry_wrapper/SentryWrapper.hpp"
#include <wx/frame.h>
#include <wx/progdlg.h>
#include <wx/sizer.h>
@@ -152,6 +153,7 @@ void PrintHostSendDialog::init()
auto* btn_ok = add_button(wxID_OK, true, _L("Upload"));
btn_ok->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) {
sentryReportLog(SENTRY_LOG_TRACE, "", BP_UPLOAD);
if (validate_path(txt_filename->GetValue())) {
post_upload_action = PrintHostPostUploadAction::None;
EndDialog(wxID_OK);
@@ -172,6 +174,7 @@ void PrintHostSendDialog::init()
if (post_actions.has(PrintHostPostUploadAction::StartPrint)) {
auto* btn_print = add_button(wxID_YES, false, _L("Upload and Print"));
btn_print->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) {
sentryReportLog(SENTRY_LOG_TRACE, "", BP_UPLOAD_AND_PRINT);
if (validate_path(txt_filename->GetValue())) {
post_upload_action = PrintHostPostUploadAction::StartPrint;
EndDialog(wxID_OK);

View File

@@ -25,6 +25,7 @@
#include <sstream>
#include <slic3r/GUI/Widgets/WebView.hpp>
#include "sentry_wrapper/SentryWrapper.hpp"
using namespace std;
using namespace nlohmann;
@@ -198,11 +199,13 @@ void SMUserLogin::OnNavigationRequest(wxWebViewEvent &evt)
http.header("Authorization",token);
http.on_complete([&](std::string body, unsigned status) {
if (status == 200) {
std::string user_id = "";
json response = json::parse(body);
if (response.count("data")) {
json data = response["data"];
if (data.count("id")) {
wxGetApp().sm_get_userinfo()->set_user_id(std::to_string(data["id"].get<int>()));
user_id = std::to_string(data["id"].get<int>());
}
if (data.count("nickname")) {
wxGetApp().sm_get_userinfo()->set_user_name(data["nickname"].get<std::string>());
@@ -214,13 +217,15 @@ void SMUserLogin::OnNavigationRequest(wxWebViewEvent &evt)
wxGetApp().sm_get_userinfo()->set_user_account(data["account"].get<std::string>());
}
}
string userInfo = BP_LOGIN_USER_ID + std::string(":") + user_id;
sentryReportLog(SENTRY_LOG_TRACE, userInfo, BP_LOGIN);
wxGetApp().sm_get_userinfo()->set_user_token(token);
wxGetApp().sm_get_userinfo()->set_user_login(true);
}
})
.on_error([&](std::string body, std::string error, unsigned status) {
std::string http_code = BP_LOGIN_HTTP_CODE + string(":") + std::to_string(status);
sentryReportLog(SENTRY_LOG_TRACE, http_code, BP_LOGIN);
})
.perform_sync();
});

View File

@@ -28,6 +28,7 @@
#include "slic3r/GUI/WebPreprintDialog.hpp"
#include "slic3r/GUI/SSWCP.hpp"
#include "sentry_wrapper/SentryWrapper.hpp"
#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
@@ -2287,6 +2288,7 @@ void Moonraker_Mqtt::async_camera_start(const std::string& domain, int interval,
callback) {
BOOST_LOG_TRIVIAL(error) << "[Moonraker_Mqtt] 发送启动摄像头监控请求失败";
wcp_loger.add_log("发送启动摄像头监控请求失败", false, "", "Moonraker_Mqtt", "error");
sentryReportLog(SENTRY_LOG_TRACE, "open video cmd error", BP_VIDEO_ABNORMAL);
callback(json::value_t::null);
}
}
@@ -2336,6 +2338,7 @@ void Moonraker_Mqtt::async_canmera_stop(const std::string& domain, std::function
callback) {
BOOST_LOG_TRIVIAL(error) << "[Moonraker_Mqtt] 发送停止摄像头监控请求失败";
wcp_loger.add_log("发送停止摄像头监控请求失败", false, "", "Moonraker_Mqtt", "error");
sentryReportLog(SENTRY_LOG_TRACE, "stop video cmd error", BP_VIDEO_ABNORMAL);
callback(json::value_t::null);
}
}