mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-19 23:01:22 -06:00
NEW: add track events for debugging network
Change-Id: I671f91b4af00277236ca71014f8d667109756d00 Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
parent
bd75af4a43
commit
6827b41eb3
13 changed files with 187 additions and 12 deletions
|
@ -97,6 +97,10 @@ func_get_profile_3mf NetworkAgent::get_profile_3mf_ptr = nullptr;
|
|||
func_get_model_publish_url NetworkAgent::get_model_publish_url_ptr = nullptr;
|
||||
func_get_model_mall_home_url NetworkAgent::get_model_mall_home_url_ptr = nullptr;
|
||||
func_get_my_profile NetworkAgent::get_my_profile_ptr = nullptr;
|
||||
func_track_enable NetworkAgent::track_enable_ptr = nullptr;
|
||||
func_track_event NetworkAgent::track_event_ptr = nullptr;
|
||||
func_track_header NetworkAgent::track_header_ptr = nullptr;
|
||||
func_track_update_property NetworkAgent::track_update_property_ptr = nullptr;
|
||||
|
||||
|
||||
NetworkAgent::NetworkAgent()
|
||||
|
@ -240,6 +244,10 @@ int NetworkAgent::initialize_network_module(bool using_backup)
|
|||
get_model_publish_url_ptr = reinterpret_cast<func_get_model_publish_url>(get_network_function("bambu_network_get_model_publish_url"));
|
||||
get_model_mall_home_url_ptr = reinterpret_cast<func_get_model_mall_home_url>(get_network_function("bambu_network_get_model_mall_home_url"));
|
||||
get_my_profile_ptr = reinterpret_cast<func_get_my_profile>(get_network_function("bambu_network_get_my_profile"));
|
||||
track_enable_ptr = reinterpret_cast<func_track_enable>(get_network_function("bambu_network_track_enable"));
|
||||
track_event_ptr = reinterpret_cast<func_track_event>(get_network_function("bambu_network_track_event"));
|
||||
track_header_ptr = reinterpret_cast<func_track_header>(get_network_function("bambu_network_track_header"));
|
||||
track_update_property_ptr = reinterpret_cast<func_track_update_property>(get_network_function("bambu_network_track_update_property"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -336,6 +344,10 @@ int NetworkAgent::unload_network_module()
|
|||
get_model_publish_url_ptr = nullptr;
|
||||
get_model_mall_home_url_ptr = nullptr;
|
||||
get_my_profile_ptr = nullptr;
|
||||
track_enable_ptr = nullptr;
|
||||
track_event_ptr = nullptr;
|
||||
track_header_ptr = nullptr;
|
||||
track_update_property_ptr = nullptr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -787,11 +799,11 @@ std::string NetworkAgent::build_login_info()
|
|||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::bind(std::string dev_ip, std::string timezone, OnUpdateStatusFn update_fn)
|
||||
int NetworkAgent::bind(std::string dev_ip, std::string dev_id, std::string timezone, OnUpdateStatusFn update_fn)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && bind_ptr) {
|
||||
ret = bind_ptr(network_agent, dev_ip, timezone, update_fn);
|
||||
ret = bind_ptr(network_agent, dev_ip, dev_id, timezone, update_fn);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, dev_ip=%3%, timezone=%4%")
|
||||
%network_agent %ret %dev_ip %timezone;
|
||||
|
@ -1130,4 +1142,48 @@ int NetworkAgent::get_my_profile(std::string token, unsigned int *http_code, std
|
|||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::track_enable(bool enable)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && track_enable_ptr) {
|
||||
ret = track_enable_ptr(network_agent, enable);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("error network_agnet=%1%, ret = %2%") % network_agent % ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::track_event(std::string evt_key, std::string content)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && track_event_ptr) {
|
||||
ret = track_event_ptr(network_agent, evt_key, content);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("error network_agnet=%1%, ret = %2%") % network_agent % ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::track_header(std::string header)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && track_header_ptr) {
|
||||
ret = track_header_ptr(network_agent, header);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("error network_agnet=%1%, ret = %2%") % network_agent % ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::track_update_property(std::string name, std::string value, std::string type)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && track_update_property_ptr) {
|
||||
ret = track_update_property_ptr(network_agent, name, value, type);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format("error network_agnet=%1%, ret = %2%") % network_agent % ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
} //namespace
|
||||
|
|
|
@ -45,7 +45,7 @@ typedef std::string (*func_get_user_nickanme)(void *agent);
|
|||
typedef std::string (*func_build_login_cmd)(void *agent);
|
||||
typedef std::string (*func_build_logout_cmd)(void *agent);
|
||||
typedef std::string (*func_build_login_info)(void *agent);
|
||||
typedef int (*func_bind)(void *agent, std::string dev_ip, std::string timezone, OnUpdateStatusFn update_fn);
|
||||
typedef int (*func_bind)(void *agent, std::string dev_ip, std::string dev_id, std::string timezone, OnUpdateStatusFn update_fn);
|
||||
typedef int (*func_unbind)(void *agent, std::string dev_id);
|
||||
typedef std::string (*func_get_bambulab_host)(void *agent);
|
||||
typedef std::string (*func_get_user_selected_machine)(void *agent);
|
||||
|
@ -77,6 +77,10 @@ typedef int (*func_get_profile_3mf)(void *agent, BBLProfile* profile);
|
|||
typedef int (*func_get_model_publish_url)(void *agent, std::string* url);
|
||||
typedef int (*func_get_model_mall_home_url)(void *agent, std::string* url);
|
||||
typedef int (*func_get_my_profile)(void *agent, std::string token, unsigned int *http_code, std::string *http_body);
|
||||
typedef int (*func_track_enable)(void *agent, bool enable);
|
||||
typedef int (*func_track_event)(void *agent, std::string evt_key, std::string content);
|
||||
typedef int (*func_track_header)(void *agent, std::string header);
|
||||
typedef int (*func_track_update_property)(void *agent, std::string name, std::string value, std::string type);
|
||||
|
||||
|
||||
//the NetworkAgent class
|
||||
|
@ -130,7 +134,7 @@ public:
|
|||
std::string build_login_cmd();
|
||||
std::string build_logout_cmd();
|
||||
std::string build_login_info();
|
||||
int bind(std::string dev_ip, std::string timezone, OnUpdateStatusFn update_fn);
|
||||
int bind(std::string dev_ip, std::string dev_id, std::string timezone, OnUpdateStatusFn update_fn);
|
||||
int unbind(std::string dev_id);
|
||||
std::string get_bambulab_host();
|
||||
std::string get_user_selected_machine();
|
||||
|
@ -162,6 +166,10 @@ public:
|
|||
int get_model_publish_url(std::string* url);
|
||||
int get_model_mall_home_url(std::string* url);
|
||||
int get_my_profile(std::string token, unsigned int* http_code, std::string* http_body);
|
||||
int track_enable(bool enable);
|
||||
int track_event(std::string evt_key, std::string content);
|
||||
int track_header(std::string header);
|
||||
int track_update_property(std::string name, std::string value, std::string type = "string");
|
||||
|
||||
private:
|
||||
|
||||
|
@ -237,6 +245,10 @@ private:
|
|||
static func_get_model_publish_url get_model_publish_url_ptr;
|
||||
static func_get_model_mall_home_url get_model_mall_home_url_ptr;
|
||||
static func_get_my_profile get_my_profile_ptr;
|
||||
static func_track_enable track_enable_ptr;
|
||||
static func_track_event track_event_ptr;
|
||||
static func_track_header track_header_ptr;
|
||||
static func_track_update_property track_update_property_ptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue