mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
ENH: [STUDIO-2759] network queue on main thread
Change-Id: Ie1fa855b354047ab015c801cae5df7271e844e58
This commit is contained in:
parent
5a7aa74e62
commit
8dae5b6980
5 changed files with 26 additions and 3 deletions
|
@ -1958,6 +1958,9 @@ void GUI_App::init_networking_callbacks()
|
|||
});
|
||||
};
|
||||
m_agent->set_on_local_message_fn(lan_message_arrive_fn);
|
||||
m_agent->set_queue_on_main_fn([this](std::function<void()> callback) {
|
||||
CallAfter(callback);
|
||||
});
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< boost::format(": exit, m_agent=%1%")%m_agent;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ func_set_get_country_code_fn NetworkAgent::set_get_country_code_fn_ptr =
|
|||
func_set_on_message_fn NetworkAgent::set_on_message_fn_ptr = nullptr;
|
||||
func_set_on_local_connect_fn NetworkAgent::set_on_local_connect_fn_ptr = nullptr;
|
||||
func_set_on_local_message_fn NetworkAgent::set_on_local_message_fn_ptr = nullptr;
|
||||
func_set_queue_on_main_fn NetworkAgent::set_queue_on_main_fn_ptr = nullptr;
|
||||
func_connect_server NetworkAgent::connect_server_ptr = nullptr;
|
||||
func_is_server_connected NetworkAgent::is_server_connected_ptr = nullptr;
|
||||
func_refresh_connection NetworkAgent::refresh_connection_ptr = nullptr;
|
||||
|
@ -195,6 +196,7 @@ int NetworkAgent::initialize_network_module(bool using_backup)
|
|||
set_on_message_fn_ptr = reinterpret_cast<func_set_on_message_fn>(get_network_function("bambu_network_set_on_message_fn"));
|
||||
set_on_local_connect_fn_ptr = reinterpret_cast<func_set_on_local_connect_fn>(get_network_function("bambu_network_set_on_local_connect_fn"));
|
||||
set_on_local_message_fn_ptr = reinterpret_cast<func_set_on_local_message_fn>(get_network_function("bambu_network_set_on_local_message_fn"));
|
||||
set_queue_on_main_fn_ptr = reinterpret_cast<func_set_queue_on_main_fn>(get_network_function("bambu_network_set_queue_on_main_fn"));
|
||||
connect_server_ptr = reinterpret_cast<func_connect_server>(get_network_function("bambu_network_connect_server"));
|
||||
is_server_connected_ptr = reinterpret_cast<func_is_server_connected>(get_network_function("bambu_network_is_server_connected"));
|
||||
refresh_connection_ptr = reinterpret_cast<func_refresh_connection>(get_network_function("bambu_network_refresh_connection"));
|
||||
|
@ -299,6 +301,7 @@ int NetworkAgent::unload_network_module()
|
|||
set_on_message_fn_ptr = nullptr;
|
||||
set_on_local_connect_fn_ptr = nullptr;
|
||||
set_on_local_message_fn_ptr = nullptr;
|
||||
set_queue_on_main_fn_ptr = nullptr;
|
||||
connect_server_ptr = nullptr;
|
||||
is_server_connected_ptr = nullptr;
|
||||
refresh_connection_ptr = nullptr;
|
||||
|
@ -604,6 +607,17 @@ int NetworkAgent::set_on_local_message_fn(OnMessageFn fn)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::set_queue_on_main_fn(QueueOnMainFn fn)
|
||||
{
|
||||
int ret = 0;
|
||||
if (network_agent && set_queue_on_main_fn_ptr) {
|
||||
ret = set_queue_on_main_fn_ptr(network_agent, fn);
|
||||
if (ret)
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%")%network_agent %ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int NetworkAgent::connect_server()
|
||||
{
|
||||
int ret = 0;
|
||||
|
|
|
@ -25,6 +25,7 @@ typedef int (*func_set_get_country_code_fn)(void *agent, GetCountryCodeFn fn);
|
|||
typedef int (*func_set_on_message_fn)(void *agent, OnMessageFn fn);
|
||||
typedef int (*func_set_on_local_connect_fn)(void *agent, OnLocalConnectedFn fn);
|
||||
typedef int (*func_set_on_local_message_fn)(void *agent, OnMessageFn fn);
|
||||
typedef int (*func_set_queue_on_main_fn)(void *agent, QueueOnMainFn fn);
|
||||
typedef int (*func_connect_server)(void *agent);
|
||||
typedef bool (*func_is_server_connected)(void *agent);
|
||||
typedef int (*func_refresh_connection)(void *agent);
|
||||
|
@ -117,6 +118,7 @@ public:
|
|||
int set_on_message_fn(OnMessageFn fn);
|
||||
int set_on_local_connect_fn(OnLocalConnectedFn fn);
|
||||
int set_on_local_message_fn(OnMessageFn fn);
|
||||
int set_queue_on_main_fn(QueueOnMainFn fn);
|
||||
int connect_server();
|
||||
bool is_server_connected();
|
||||
int refresh_connection();
|
||||
|
@ -198,6 +200,7 @@ private:
|
|||
static func_set_on_message_fn set_on_message_fn_ptr;
|
||||
static func_set_on_local_connect_fn set_on_local_connect_fn_ptr;
|
||||
static func_set_on_local_message_fn set_on_local_message_fn_ptr;
|
||||
static func_set_queue_on_main_fn set_queue_on_main_fn_ptr;
|
||||
static func_connect_server connect_server_ptr;
|
||||
static func_is_server_connected is_server_connected_ptr;
|
||||
static func_refresh_connection refresh_connection_ptr;
|
||||
|
|
|
@ -79,8 +79,7 @@ namespace BBL {
|
|||
|
||||
#define BAMBU_NETWORK_LIBRARY "bambu_networking"
|
||||
#define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent"
|
||||
#define BAMBU_NETWORK_AGENT_VERSION "01.06.01.01"
|
||||
|
||||
#define BAMBU_NETWORK_AGENT_VERSION "01.06.05.01"
|
||||
|
||||
//iot preset type strings
|
||||
#define IOT_PRINTER_TYPE_STRING "printer"
|
||||
|
@ -112,6 +111,8 @@ typedef std::function<void(int status, int code, std::string msg)> OnUpdateStatu
|
|||
typedef std::function<bool()> WasCancelledFn;
|
||||
// local callbacks
|
||||
typedef std::function<void(std::string dev_info_json_str)> OnMsgArrivedFn;
|
||||
// queue call to main thread
|
||||
typedef std::function<void(std::function<void()>)> QueueOnMainFn;
|
||||
|
||||
typedef std::function<void(int progress)> ProgressFn;
|
||||
typedef std::function<void(int retcode, std::string info)> LoginFn;
|
||||
|
|
|
@ -10,4 +10,6 @@ endif()
|
|||
if(NOT DEFINED BBL_INTERNAL_TESTING)
|
||||
set(BBL_INTERNAL_TESTING "1")
|
||||
endif()
|
||||
set(SLIC3R_VERSION "01.06.01.54")
|
||||
|
||||
# The build_version should start from 50 in master branch
|
||||
set(SLIC3R_VERSION "01.06.05.01")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue