mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
Update the codes to 01.01.00.10 for the formal release
1. first formal version of macos 2. add the bambu networking plugin install logic 3. auto compute the wipe volume when filament change 4. add the logic of wiping into support 5. refine the GUI layout and icons, improve the gui apperance in lots of small places 6. serveral improve to support 7. support AMS auto-mapping 8. disable lots of unstable features: such as params table, media file download, HMS 9. fix serveral kinds of bugs 10. update the document of building 11. ...
This commit is contained in:
parent
e1528e4299
commit
e9e4d75877
267 changed files with 10326 additions and 32228 deletions
|
@ -11,16 +11,24 @@
|
|||
#include "NetworkAgent.hpp"
|
||||
|
||||
|
||||
|
||||
using namespace BBL;
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
#define BAMBU_SOURCE_LIBRARY "BambuSource"
|
||||
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
static HMODULE netwoking_module = NULL;
|
||||
static HMODULE source_module = NULL;
|
||||
#else
|
||||
static void* netwoking_module = NULL;
|
||||
static void* source_module = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
func_check_debug_consistent NetworkAgent::check_debug_consistent_ptr = nullptr;
|
||||
func_get_version NetworkAgent::get_version_ptr = nullptr;
|
||||
func_create_agent NetworkAgent::create_agent_ptr = nullptr;
|
||||
func_destroy_agent NetworkAgent::destroy_agent_ptr = nullptr;
|
||||
func_init_log NetworkAgent::init_log_ptr = nullptr;
|
||||
|
@ -103,36 +111,50 @@ int NetworkAgent::initialize_network_module()
|
|||
{
|
||||
//int ret = -1;
|
||||
std::string library;
|
||||
auto plugin_folder = boost::filesystem::path(wxStandardPaths::Get().GetUserDataDir().ToUTF8().data()) / "plugins";
|
||||
|
||||
//first load the library
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
library = std::string(BAMBU_NETWORK_LIBRARY) + ".dll";
|
||||
library = plugin_folder.string() + "/" + std::string(BAMBU_NETWORK_LIBRARY) + ".dll";
|
||||
wchar_t lib_wstr[128];
|
||||
memset(lib_wstr, 0, sizeof(lib_wstr));
|
||||
::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str())+1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0]));
|
||||
netwoking_module = LoadLibrary(lib_wstr);
|
||||
#elif defined(__WXMAC__)
|
||||
std::string resource_dir = resources_dir();
|
||||
library = resource_dir + "/../Library/"+ std::string("lib") + BAMBU_NETWORK_LIBRARY + ".dylib";
|
||||
/*if (!netwoking_module) {
|
||||
library = std::string(BAMBU_NETWORK_LIBRARY) + ".dll";
|
||||
memset(lib_wstr, 0, sizeof(lib_wstr));
|
||||
::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str()) + 1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0]));
|
||||
netwoking_module = LoadLibrary(lib_wstr);
|
||||
}*/
|
||||
#else
|
||||
#if defined(__WXMAC__)
|
||||
library = plugin_folder.string() + "/" + std::string("lib") + std::string(BAMBU_NETWORK_LIBRARY) + ".dylib";
|
||||
#else
|
||||
library = plugin_folder.string() + "/" + std::string("lib") + std::string(BAMBU_NETWORK_LIBRARY) + ".so";
|
||||
#endif
|
||||
printf("loading network module at %s\n", library.c_str());
|
||||
netwoking_module = dlopen( library.c_str(), RTLD_LAZY);
|
||||
if (!netwoking_module) {
|
||||
/*#if defined(__WXMAC__)
|
||||
library = std::string("lib") + BAMBU_NETWORK_LIBRARY + ".dylib";
|
||||
netwoking_module = dlopen( library.c_str(), RTLD_LAZY);
|
||||
#else
|
||||
library = std::string("lib") + BAMBU_NETWORK_LIBRARY + ".so";
|
||||
#endif*/
|
||||
//netwoking_module = dlopen( library.c_str(), RTLD_LAZY);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", error, dlerror is %1%")%dlerror();
|
||||
}
|
||||
printf("after dlopen, network_module is %p\n", netwoking_module);
|
||||
#else
|
||||
library = std::string("lib") + BAMBU_NETWORK_LIBRARY + ".so";
|
||||
netwoking_module = dlopen( library.c_str(), RTLD_LAZY);
|
||||
#endif
|
||||
|
||||
if (!netwoking_module) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", can not Load Library for %1%")%library;
|
||||
return -1;
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", successfully loaded library %1%")%library;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", successfully loaded library %1%, module %2%")%library %netwoking_module;
|
||||
|
||||
//load the functions
|
||||
check_debug_consistent_ptr = reinterpret_cast<func_check_debug_consistent>(get_network_function("bambu_network_check_debug_consistent"));
|
||||
get_version_ptr = reinterpret_cast<func_get_version>(get_network_function("bambu_network_get_version"));
|
||||
create_agent_ptr = reinterpret_cast<func_create_agent>(get_network_function("bambu_network_create_agent"));
|
||||
destroy_agent_ptr = reinterpret_cast<func_destroy_agent>(get_network_function("bambu_network_destroy_agent"));
|
||||
init_log_ptr = reinterpret_cast<func_init_log>(get_network_function("bambu_network_init_log"));
|
||||
|
@ -196,6 +218,140 @@ int NetworkAgent::initialize_network_module()
|
|||
return 0;
|
||||
}
|
||||
|
||||
int NetworkAgent::unload_network_module()
|
||||
{
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", network module %1%")%netwoking_module;
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
if (netwoking_module) {
|
||||
FreeLibrary(netwoking_module);
|
||||
netwoking_module = NULL;
|
||||
}
|
||||
if (source_module) {
|
||||
FreeLibrary(source_module);
|
||||
source_module = NULL;
|
||||
}
|
||||
#else
|
||||
if (netwoking_module) {
|
||||
dlclose(netwoking_module);
|
||||
netwoking_module = NULL;
|
||||
}
|
||||
if (source_module) {
|
||||
dlclose(source_module);
|
||||
source_module = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
check_debug_consistent_ptr = nullptr;
|
||||
get_version_ptr = nullptr;
|
||||
create_agent_ptr = nullptr;
|
||||
destroy_agent_ptr = nullptr;
|
||||
init_log_ptr = nullptr;
|
||||
set_config_dir_ptr = nullptr;
|
||||
set_cert_file_ptr = nullptr;
|
||||
set_country_code_ptr = nullptr;
|
||||
start_ptr = nullptr;
|
||||
set_on_ssdp_msg_fn_ptr = nullptr;
|
||||
set_on_user_login_fn_ptr = nullptr;
|
||||
set_on_printer_connected_fn_ptr = nullptr;
|
||||
set_on_server_connected_fn_ptr = nullptr;
|
||||
set_on_http_error_fn_ptr = nullptr;
|
||||
set_get_country_code_fn_ptr = nullptr;
|
||||
set_on_message_fn_ptr = nullptr;
|
||||
set_on_local_connect_fn_ptr = nullptr;
|
||||
set_on_local_message_fn_ptr = nullptr;
|
||||
connect_server_ptr = nullptr;
|
||||
is_server_connected_ptr = nullptr;
|
||||
refresh_connection_ptr = nullptr;
|
||||
start_subscribe_ptr = nullptr;
|
||||
stop_subscribe_ptr = nullptr;
|
||||
send_message_ptr = nullptr;
|
||||
connect_printer_ptr = nullptr;
|
||||
disconnect_printer_ptr = nullptr;
|
||||
send_message_to_printer_ptr = nullptr;
|
||||
start_discovery_ptr = nullptr;
|
||||
change_user_ptr = nullptr;
|
||||
is_user_login_ptr = nullptr;
|
||||
user_logout_ptr = nullptr;
|
||||
get_user_id_ptr = nullptr;
|
||||
get_user_name_ptr = nullptr;
|
||||
get_user_avatar_ptr = nullptr;
|
||||
get_user_nickanme_ptr = nullptr;
|
||||
build_login_cmd_ptr = nullptr;
|
||||
build_logout_cmd_ptr = nullptr;
|
||||
build_login_info_ptr = nullptr;
|
||||
bind_ptr = nullptr;
|
||||
unbind_ptr = nullptr;
|
||||
get_bambulab_host_ptr = nullptr;
|
||||
get_user_selected_machine_ptr = nullptr;
|
||||
set_user_selected_machine_ptr = nullptr;
|
||||
start_print_ptr = nullptr;
|
||||
start_local_print_with_record_ptr = nullptr;
|
||||
start_local_print_ptr = nullptr;
|
||||
get_user_presets_ptr = nullptr;
|
||||
request_setting_id_ptr = nullptr;
|
||||
put_setting_ptr = nullptr;
|
||||
get_setting_list_ptr = nullptr;
|
||||
delete_setting_ptr = nullptr;
|
||||
get_studio_info_url_ptr = nullptr;
|
||||
set_extra_http_header_ptr = nullptr;
|
||||
check_user_task_report_ptr = nullptr;
|
||||
get_user_print_info_ptr = nullptr;
|
||||
get_printer_firmware_ptr = nullptr;
|
||||
get_task_plate_index_ptr = nullptr;
|
||||
get_slice_info_ptr = nullptr;
|
||||
query_bind_status_ptr = nullptr;
|
||||
modify_printer_name_ptr = nullptr;
|
||||
get_camera_url_ptr = nullptr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
HMODULE NetworkAgent::get_bambu_source_entry()
|
||||
#else
|
||||
void* NetworkAgent::get_bambu_source_entry()
|
||||
#endif
|
||||
{
|
||||
if ((source_module) || (!netwoking_module))
|
||||
return source_module;
|
||||
|
||||
//int ret = -1;
|
||||
std::string library;
|
||||
auto plugin_folder = boost::filesystem::path(wxStandardPaths::Get().GetUserDataDir().ToUTF8().data()) / "plugins";
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
wchar_t lib_wstr[128];
|
||||
|
||||
//goto load bambu source
|
||||
library = plugin_folder.string() + "/" + std::string(BAMBU_SOURCE_LIBRARY) + ".dll";
|
||||
memset(lib_wstr, 0, sizeof(lib_wstr));
|
||||
::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str())+1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0]));
|
||||
source_module = LoadLibrary(lib_wstr);
|
||||
/*if (!source_module) {
|
||||
library = std::string(BAMBU_SOURCE_LIBRARY) + ".dll";
|
||||
memset(lib_wstr, 0, sizeof(lib_wstr));
|
||||
::MultiByteToWideChar(CP_UTF8, NULL, library.c_str(), strlen(library.c_str()) + 1, lib_wstr, sizeof(lib_wstr) / sizeof(lib_wstr[0]));
|
||||
source_module = LoadLibrary(lib_wstr);
|
||||
}*/
|
||||
#else
|
||||
#if defined(__WXMAC__)
|
||||
library = plugin_folder.string() + "/" + std::string("lib") + std::string(BAMBU_SOURCE_LIBRARY) + ".dylib";
|
||||
#else
|
||||
library = plugin_folder.string() + "/" + std::string("lib") + std::string(BAMBU_SOURCE_LIBRARY) + ".so";
|
||||
#endif
|
||||
source_module = dlopen( library.c_str(), RTLD_LAZY);
|
||||
/*if (!source_module) {
|
||||
#if defined(__WXMAC__)
|
||||
library = std::string("lib") + BAMBU_SOURCE_LIBRARY + ".dylib";
|
||||
#else
|
||||
library = std::string("lib") + BAMBU_SOURCE_LIBRARY + ".so";
|
||||
#endif
|
||||
source_module = dlopen( library.c_str(), RTLD_LAZY);
|
||||
}*/
|
||||
#endif
|
||||
|
||||
return source_module;
|
||||
}
|
||||
|
||||
void* NetworkAgent::get_network_function(const char* name)
|
||||
{
|
||||
void* function = nullptr;
|
||||
|
@ -215,6 +371,28 @@ void* NetworkAgent::get_network_function(const char* name)
|
|||
return function;
|
||||
}
|
||||
|
||||
std::string NetworkAgent::get_version()
|
||||
{
|
||||
bool consistent = true;
|
||||
//check the debug consistent first
|
||||
if (check_debug_consistent_ptr) {
|
||||
#if defined(NDEBUG)
|
||||
consistent = check_debug_consistent_ptr(false);
|
||||
#else
|
||||
consistent = check_debug_consistent_ptr(true);
|
||||
#endif
|
||||
}
|
||||
if (!consistent) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(", inconsistent library,return 00.00.00.00!");
|
||||
return "00.00.00.00";
|
||||
}
|
||||
if (get_version_ptr) {
|
||||
return get_version_ptr();
|
||||
}
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(", get_version not supported,return 00.00.00.00!");
|
||||
return "00.00.00.00";
|
||||
}
|
||||
|
||||
int NetworkAgent::init_log()
|
||||
{
|
||||
int ret = 0;
|
||||
|
@ -737,7 +915,7 @@ int NetworkAgent::check_user_task_report(int* task_id, bool* printable)
|
|||
int ret = 0;
|
||||
if (network_agent && check_user_task_report_ptr) {
|
||||
ret = check_user_task_report_ptr(network_agent, task_id, printable);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, task_id=%3%, printable=%4%")%network_agent %ret %(*task_id) %(*printable);
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, task_id=%3%, printable=%4%")%network_agent %ret %(*task_id) %(*printable);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -747,7 +925,7 @@ int NetworkAgent::get_user_print_info(unsigned int* http_code, std::string* http
|
|||
int ret = 0;
|
||||
if (network_agent && get_user_print_info_ptr) {
|
||||
ret = get_user_print_info_ptr(network_agent, http_code, http_body);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, http_code=%3%, http_body=%4%")%network_agent %ret %(*http_code) %(*http_body);
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, http_code=%3%, http_body=%4%")%network_agent %ret %(*http_code) %(*http_body);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -757,7 +935,7 @@ int NetworkAgent::get_printer_firmware(std::string dev_id, unsigned* http_code,
|
|||
int ret = 0;
|
||||
if (network_agent && get_printer_firmware_ptr) {
|
||||
ret = get_printer_firmware_ptr(network_agent, dev_id, http_code, http_body);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" : network_agent=%1%, ret=%2%, dev_id=%3%, http_code=%4%, http_body=%5%")
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(" : network_agent=%1%, ret=%2%, dev_id=%3%, http_code=%4%, http_body=%5%")
|
||||
%network_agent %ret %dev_id %(*http_code) %(*http_body);
|
||||
}
|
||||
return ret;
|
||||
|
@ -779,7 +957,7 @@ int NetworkAgent::get_slice_info(std::string project_id, std::string profile_id,
|
|||
int ret;
|
||||
if (network_agent && get_slice_info_ptr) {
|
||||
ret = get_slice_info_ptr(network_agent, project_id, profile_id, plate_index, slice_json);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" : network_agent=%1%, project_id=%2%, profile_id=%3%, plate_index=%4%, slice_json=%5%")
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(" : network_agent=%1%, project_id=%2%, profile_id=%3%, plate_index=%4%, slice_json=%5%")
|
||||
%network_agent %project_id %profile_id %plate_index %(*slice_json);
|
||||
}
|
||||
return ret;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue