mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-30 04:02:52 -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
|
|
@ -99,9 +99,11 @@ void BindJob::process()
|
|||
} else if (stage == BBL::BindJobStage::LoginStageFinished) {
|
||||
curr_percent = 100;
|
||||
msg = _L("Logging in");
|
||||
} else {
|
||||
msg = _L("Logging in");
|
||||
}
|
||||
if (code != 0) {
|
||||
msg = login_failed_str + wxString::Format("(code=%d,info=%s)", code, info);
|
||||
msg = _L("Login failed") + wxString::Format("(code=%d,info=%s)", code, info);
|
||||
}
|
||||
update_status(curr_percent, msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,49 @@ void PrintJob::on_success(std::function<void()> success)
|
|||
m_success_fun = success;
|
||||
}
|
||||
|
||||
wxString PrintJob::get_http_error_msg(unsigned int status, std::string body)
|
||||
{
|
||||
int code = 0;
|
||||
std::string error;
|
||||
std::string message;
|
||||
wxString result;
|
||||
if (status >= 400 && status < 500)
|
||||
try {
|
||||
json j = json::parse(body);
|
||||
if (j.contains("code")) {
|
||||
if (!j["code"].is_null())
|
||||
code = j["code"].get<int>();
|
||||
}
|
||||
if (j.contains("error")) {
|
||||
if (!j["error"].is_null())
|
||||
error = j["error"].get<std::string>();
|
||||
}
|
||||
if (j.contains("message")) {
|
||||
if (!j["message"].is_null())
|
||||
message = j["message"].get<std::string>();
|
||||
}
|
||||
switch (status) {
|
||||
;
|
||||
}
|
||||
}
|
||||
catch (...) {
|
||||
;
|
||||
}
|
||||
else if (status == 503) {
|
||||
return _L("Service Unavailable");
|
||||
}
|
||||
else {
|
||||
wxString unkown_text = _L("Unkown Error.");
|
||||
unkown_text += wxString::Format("status=%u, body=%s", status, body);
|
||||
return unkown_text;
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(error) << "http_error: status=" << status << ", code=" << code << ", error=" << error;
|
||||
|
||||
result = wxString::Format("code=%u, error=%s", code, from_u8(error));
|
||||
return result;
|
||||
}
|
||||
|
||||
void PrintJob::process()
|
||||
{
|
||||
/* display info */
|
||||
|
|
@ -114,8 +157,10 @@ void PrintJob::process()
|
|||
params.dev_ip = m_dev_ip;
|
||||
params.username = "bblp";
|
||||
params.password = m_access_code;
|
||||
wxString error_text;
|
||||
wxString msg_text;
|
||||
|
||||
auto update_fn = [this, &msg, &curr_percent](int stage, int code, std::string info) {
|
||||
auto update_fn = [this, &msg, &curr_percent, &error_text](int stage, int code, std::string info) {
|
||||
if (stage == BBL::SendingPrintJobStage::PrintingStageCreate) {
|
||||
if (this->connection_type == "lan") {
|
||||
msg = _L("Sending print job over LAN");
|
||||
|
|
@ -157,7 +202,7 @@ void PrintJob::process()
|
|||
}
|
||||
else if (stage == BBL::SendingPrintJobStage::PrintingStageFinished) {
|
||||
curr_percent = 100;
|
||||
msg = wxString::Format(_L("Successfully sent.Will automatically jump to the device page in %s s"), info);
|
||||
msg = wxString::Format(_L("Successfully sent. Will automatically jump to the device page in %s s"), info);
|
||||
} else {
|
||||
if (this->connection_type == "lan") {
|
||||
msg = _L("Sending print job over LAN");
|
||||
|
|
@ -165,6 +210,10 @@ void PrintJob::process()
|
|||
msg = _L("Sending print job through cloud service");
|
||||
}
|
||||
}
|
||||
if (code != 0) {
|
||||
error_text = this->get_http_error_msg(code, info);
|
||||
msg += wxString::Format("[%s]", error_text);
|
||||
}
|
||||
this->update_status(curr_percent, msg);
|
||||
};
|
||||
|
||||
|
|
@ -193,19 +242,6 @@ void PrintJob::process()
|
|||
BOOST_LOG_TRIVIAL(info) << "print_job: send with cloud";
|
||||
this->update_status(curr_percent, _L("Sending print job through cloud service"));
|
||||
result = m_agent->start_print(params, update_fn, cancel_fn);
|
||||
if (result < 0) {
|
||||
if (!params.password.empty() && !params.dev_ip.empty()) {
|
||||
//try to send with local only
|
||||
if (this->has_sdcard) {
|
||||
this->update_status(curr_percent, _L("Sending print job over LAN"));
|
||||
result = m_agent->start_local_print(params, update_fn, cancel_fn);
|
||||
} else {
|
||||
this->update_status(curr_percent, _L("Failed to connect to the cloud server connection. Please insert an SD card and resend the print job, which will transfer the print file via LAN. "));
|
||||
BOOST_LOG_TRIVIAL(error) << "print_job: failed, need sdcard";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this->has_sdcard) {
|
||||
|
|
@ -224,26 +260,29 @@ void PrintJob::process()
|
|||
|
||||
if (result < 0) {
|
||||
if (result == BAMBU_NETWORK_ERR_FTP_LOGIN_DENIED) {
|
||||
update_status(curr_percent, upload_failed_str);
|
||||
msg_text = upload_failed_str;
|
||||
} if (result == BAMBU_NETWORK_ERR_FILE_NOT_EXIST) {
|
||||
update_status(curr_percent, file_is_not_exists_str);
|
||||
msg_text = file_is_not_exists_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_FILE_OVER_SIZE) {
|
||||
update_status(curr_percent, file_over_size_str);
|
||||
msg_text = file_over_size_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_CHECK_MD5_FAILED) {
|
||||
update_status(curr_percent, failed_in_cloud_service_str);
|
||||
msg_text = failed_in_cloud_service_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_INVALID_PARAMS) {
|
||||
update_status(curr_percent, upload_failed_str);
|
||||
msg_text = upload_failed_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_CANCELED) {
|
||||
update_status(curr_percent, print_canceled_str);
|
||||
msg_text = print_canceled_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_TIMEOUT) {
|
||||
update_status(curr_percent, timeout_to_upload_str);
|
||||
msg_text = timeout_to_upload_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_INVALID_RESULT) {
|
||||
update_status(curr_percent, upload_failed_str);
|
||||
msg_text = upload_failed_str;
|
||||
} else if (result == BAMBU_NETWORK_ERR_FTP_UPLOAD_FAILED) {
|
||||
update_status(curr_percent, upload_failed_str);
|
||||
msg_text = upload_failed_str;
|
||||
} else {
|
||||
update_status(curr_percent, failed_in_cloud_service_str);
|
||||
}
|
||||
if (!error_text.IsEmpty())
|
||||
msg_text += wxString::Format("[%s]", error_text);
|
||||
update_status(curr_percent, msg_text);
|
||||
BOOST_LOG_TRIVIAL(error) << "print_job: failed, result = " << result;
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << "print_job: send ok.";
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ public:
|
|||
void set_print_job_finished_event(int event_id) { m_print_job_completed_id = event_id; }
|
||||
|
||||
void on_success(std::function<void()> success);
|
||||
wxString get_http_error_msg(unsigned int status, std::string body);
|
||||
void process() override;
|
||||
void finalize() override;
|
||||
};
|
||||
|
|
|
|||
136
src/slic3r/GUI/Jobs/UpgradeNetworkJob.cpp
Normal file
136
src/slic3r/GUI/Jobs/UpgradeNetworkJob.cpp
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
#include "UpgradeNetworkJob.hpp"
|
||||
|
||||
#include "slic3r/GUI/GUI.hpp"
|
||||
#include "slic3r/GUI/GUI_App.hpp"
|
||||
#include "slic3r/Utils/Http.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
wxDEFINE_EVENT(EVT_UPGRADE_UPDATE_MESSAGE, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_UPGRADE_NETWORK_SUCCESS, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_UPGRADE_NETWORK_FAILED, wxCommandEvent);
|
||||
|
||||
|
||||
UpgradeNetworkJob::UpgradeNetworkJob(std::shared_ptr<ProgressIndicator> pri)
|
||||
: Job{std::move(pri)}
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void UpgradeNetworkJob::on_exception(const std::exception_ptr &eptr)
|
||||
{
|
||||
try {
|
||||
if (eptr)
|
||||
std::rethrow_exception(eptr);
|
||||
} catch (std::exception &e) {
|
||||
UpgradeNetworkJob::on_exception(eptr);
|
||||
}
|
||||
}
|
||||
|
||||
void UpgradeNetworkJob::on_success(std::function<void()> success)
|
||||
{
|
||||
m_success_fun = success;
|
||||
}
|
||||
|
||||
void UpgradeNetworkJob::update_status(int st, const wxString &msg)
|
||||
{
|
||||
GUI::Job::update_status(st, msg);
|
||||
wxCommandEvent event(EVT_UPGRADE_UPDATE_MESSAGE);
|
||||
event.SetString(msg);
|
||||
event.SetEventObject(m_event_handle);
|
||||
wxPostEvent(m_event_handle, event);
|
||||
}
|
||||
|
||||
void UpgradeNetworkJob::process()
|
||||
{
|
||||
// downloading
|
||||
int result = 0;
|
||||
|
||||
AppConfig* app_config = wxGetApp().app_config;
|
||||
if (!app_config)
|
||||
return;
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "[download_plugin]: enter";
|
||||
|
||||
// get temp path
|
||||
fs::path target_file_path = (fs::temp_directory_path() / "network_plugin.zip");
|
||||
fs::path tmp_path = target_file_path;
|
||||
auto path_str = tmp_path.string() + wxString::Format(".%d%s", get_current_pid(), ".tmp").ToStdString();
|
||||
tmp_path = fs::path(path_str);
|
||||
|
||||
auto cancel_fn = [this]() {
|
||||
return was_canceled();
|
||||
};
|
||||
int curr_percent = 0;
|
||||
result = wxGetApp().download_plugin(
|
||||
[this, &curr_percent](int state, int percent, bool &cancel) {
|
||||
if (state == InstallStatusNormal) {
|
||||
update_status(percent, _L("Downloading"));
|
||||
} else if (state == InstallStatusDownloadFailed) {
|
||||
update_status(percent, _L("Download failed"));
|
||||
} else {
|
||||
update_status(percent, _L("Downloading"));
|
||||
}
|
||||
curr_percent = percent;
|
||||
}, cancel_fn);
|
||||
|
||||
if (was_canceled()) {
|
||||
update_status(0, _L("Cancelled"));
|
||||
wxCommandEvent event(wxEVT_CLOSE_WINDOW);
|
||||
event.SetEventObject(m_event_handle);
|
||||
wxPostEvent(m_event_handle, event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result < 0) {
|
||||
update_status(curr_percent, _L("Download failed"));
|
||||
wxCommandEvent event(EVT_UPGRADE_NETWORK_FAILED);
|
||||
event.SetEventObject(m_event_handle);
|
||||
wxPostEvent(m_event_handle, event);
|
||||
return;
|
||||
}
|
||||
|
||||
result = wxGetApp().install_plugin([this](int state, int percent, bool&cancel) {
|
||||
if (state == InstallStatusInstallCompleted) {
|
||||
update_status(percent, _L("Finish"));
|
||||
} else {
|
||||
update_status(percent, _L("Installing"));
|
||||
}
|
||||
}, cancel_fn);
|
||||
|
||||
if (was_canceled()) {
|
||||
update_status(0, _L("Cancelled"));
|
||||
wxCommandEvent event(wxEVT_CLOSE_WINDOW);
|
||||
event.SetEventObject(m_event_handle);
|
||||
wxPostEvent(m_event_handle, event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result != 0) {
|
||||
update_status(curr_percent, _L("Install failed"));
|
||||
wxCommandEvent event(EVT_UPGRADE_NETWORK_FAILED);
|
||||
event.SetEventObject(m_event_handle);
|
||||
wxPostEvent(m_event_handle, event);
|
||||
return;
|
||||
}
|
||||
|
||||
wxCommandEvent event(EVT_UPGRADE_NETWORK_SUCCESS);
|
||||
event.SetEventObject(m_event_handle);
|
||||
wxPostEvent(m_event_handle, event);
|
||||
return;
|
||||
}
|
||||
|
||||
void UpgradeNetworkJob::finalize()
|
||||
{
|
||||
if (was_canceled()) return;
|
||||
|
||||
Job::finalize();
|
||||
}
|
||||
|
||||
void UpgradeNetworkJob::set_event_handle(wxWindow *hanle)
|
||||
{
|
||||
m_event_handle = hanle;
|
||||
}
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
56
src/slic3r/GUI/Jobs/UpgradeNetworkJob.hpp
Normal file
56
src/slic3r/GUI/Jobs/UpgradeNetworkJob.hpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#ifndef __UpgradeNetworkJob_HPP__
|
||||
#define __UpgradeNetworkJob_HPP__
|
||||
|
||||
#include <functional>
|
||||
#include "Job.hpp"
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
enum PluginInstallStatus {
|
||||
InstallStatusNormal = 0,
|
||||
InstallStatusDownloadFailed = 1,
|
||||
InstallStatusDownloadCompleted = 2,
|
||||
InstallStatusUnzipFailed = 3,
|
||||
InstallStatusInstallCompleted = 4,
|
||||
};
|
||||
|
||||
typedef std::function<void(int status, int percent, bool& cancel)> InstallProgressFn;
|
||||
|
||||
class UpgradeNetworkJob : public Job
|
||||
{
|
||||
wxWindow * m_event_handle{nullptr};
|
||||
std::function<void()> m_success_fun{nullptr};
|
||||
bool m_job_finished{ false };
|
||||
int m_print_job_completed_id = 0;
|
||||
|
||||
InstallProgressFn pro_fn { nullptr };
|
||||
|
||||
protected:
|
||||
void on_exception(const std::exception_ptr &) override;
|
||||
public:
|
||||
UpgradeNetworkJob(std::shared_ptr<ProgressIndicator> pri);
|
||||
|
||||
int status_range() const override
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
bool is_finished() { return m_job_finished; }
|
||||
|
||||
void on_success(std::function<void()> success);
|
||||
void update_status(int st, const wxString &msg);
|
||||
void process() override;
|
||||
void finalize() override;
|
||||
void set_event_handle(wxWindow* hanle);
|
||||
};
|
||||
|
||||
wxDECLARE_EVENT(EVT_UPGRADE_UPDATE_MESSAGE, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_UPGRADE_NETWORK_SUCCESS, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_UPGRADE_NETWORK_FAILED, wxCommandEvent);
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
#endif // ARRANGEJOB_HPP
|
||||
Loading…
Add table
Add a link
Reference in a new issue