mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 19:33:47 +00:00
FIX: fix send sd card with cloud issue
JIRA: STUDIO-9376 STUDIO-9419 1. Cancel sending during sending and then resend failed 2. Optimization of prompt language after sending failure Change-Id: I60bc4525b41cd4f803b811f0d1971bfed5cda0c5 (cherry picked from commit 92bd0cd18e4ea79b8b29f147e5ea09663837f7c0)
This commit is contained in:
@@ -415,6 +415,13 @@ std::string PrinterFileSystem::File::Metadata(std::string const &key, std::strin
|
|||||||
return iter == metadata.end() || iter->second.empty() ? dflt : iter->second;
|
return iter == metadata.end() || iter->second.empty() ? dflt : iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrinterFileSystem::UploadFile::~UploadFile()
|
||||||
|
{
|
||||||
|
if (upload && upload->ifs.is_open()) {
|
||||||
|
upload->ifs.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
size_t PrinterFileSystem::GetIndexAtTime(boost::uint32_t time)
|
size_t PrinterFileSystem::GetIndexAtTime(boost::uint32_t time)
|
||||||
{
|
{
|
||||||
auto iter = std::upper_bound(m_file_list.begin(), m_file_list.end(), File{"", "", time});
|
auto iter = std::upper_bound(m_file_list.begin(), m_file_list.end(), File{"", "", time});
|
||||||
@@ -1140,6 +1147,9 @@ void PrinterFileSystem::RequestUploadFile()
|
|||||||
|
|
||||||
// reset m_upload_file
|
// reset m_upload_file
|
||||||
if (m_upload_file) {
|
if (m_upload_file) {
|
||||||
|
if (m_upload_file->upload->ifs.is_open()) {
|
||||||
|
m_upload_file->upload->ifs.close();
|
||||||
|
}
|
||||||
m_upload_file.reset();
|
m_upload_file.reset();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -1244,6 +1254,16 @@ void PrinterFileSystem::CancelUploadTask(bool send_cancel_req)
|
|||||||
if (!m_upload_file)
|
if (!m_upload_file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
{
|
||||||
|
boost::unique_lock l(m_mutex);
|
||||||
|
if (m_produce_message_cb_map.find(m_upload_seq) != m_produce_message_cb_map.end())
|
||||||
|
m_produce_message_cb_map.erase(m_upload_seq);
|
||||||
|
if (m_upload_file->upload->ifs.is_open()) {
|
||||||
|
m_upload_file->upload->ifs.close();
|
||||||
|
}
|
||||||
|
m_upload_file.reset();
|
||||||
|
}
|
||||||
|
|
||||||
if (send_cancel_req) {
|
if (send_cancel_req) {
|
||||||
CancelRequest(m_upload_seq);
|
CancelRequest(m_upload_seq);
|
||||||
} else {
|
} else {
|
||||||
@@ -1422,8 +1442,8 @@ void PrinterFileSystem::HandleResponse(boost::unique_lock<boost::mutex> &l, Bamb
|
|||||||
json_end = end;
|
json_end = end;
|
||||||
std::string msg((char const *) sample.buffer, json_end - sample.buffer);
|
std::string msg((char const *) sample.buffer, json_end - sample.buffer);
|
||||||
json root;
|
json root;
|
||||||
//OutputDebugStringA(msg.c_str());
|
// OutputDebugStringA(msg.c_str());
|
||||||
//OutputDebugStringA("\n");
|
// OutputDebugStringA("\n");
|
||||||
wxLogInfo("PrinterFileSystem::HandleResponse <<<: \n%s\n", wxString::FromUTF8(msg));
|
wxLogInfo("PrinterFileSystem::HandleResponse <<<: \n%s\n", wxString::FromUTF8(msg));
|
||||||
std::istringstream iss(msg);
|
std::istringstream iss(msg);
|
||||||
int cmd = 0;
|
int cmd = 0;
|
||||||
@@ -1669,5 +1689,4 @@ void StaticBambuLib::release()
|
|||||||
}
|
}
|
||||||
|
|
||||||
extern "C" BambuLib *bambulib_get() {
|
extern "C" BambuLib *bambulib_get() {
|
||||||
return &StaticBambuLib::get();
|
return &StaticBambuLib::get(); }
|
||||||
}
|
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ public:
|
|||||||
std::unique_ptr<Upload> upload;
|
std::unique_ptr<Upload> upload;
|
||||||
|
|
||||||
bool IsUploading() const { return flags & FF_UPLOADING; }
|
bool IsUploading() const { return flags & FF_UPLOADING; }
|
||||||
|
~UploadFile();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Void {};
|
struct Void {};
|
||||||
|
|||||||
@@ -159,6 +159,11 @@ void SendToPrinterDialog::on_rename_enter()
|
|||||||
m_valid_type = NoValid;
|
m_valid_type = NoValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_valid_type == Valid && new_file_name.size() >= 100) {
|
||||||
|
info_line = _L("The name length exceeds the limit.");
|
||||||
|
m_valid_type = NoValid;
|
||||||
|
}
|
||||||
|
|
||||||
if (m_valid_type != Valid) {
|
if (m_valid_type != Valid) {
|
||||||
MessageDialog msg_wingow(nullptr, info_line, "", wxICON_WARNING | wxOK);
|
MessageDialog msg_wingow(nullptr, info_line, "", wxICON_WARNING | wxOK);
|
||||||
if (msg_wingow.ShowModal() == wxID_OK) {
|
if (msg_wingow.ShowModal() == wxID_OK) {
|
||||||
@@ -725,6 +730,8 @@ void SendToPrinterDialog::init_timer()
|
|||||||
void SendToPrinterDialog::on_cancel(wxCloseEvent &event)
|
void SendToPrinterDialog::on_cancel(wxCloseEvent &event)
|
||||||
{
|
{
|
||||||
m_worker->cancel_all();
|
m_worker->cancel_all();
|
||||||
|
|
||||||
|
#if !BBL_RELEASE_TO_PUBLIC
|
||||||
if (m_file_sys) {
|
if (m_file_sys) {
|
||||||
m_file_sys->CancelUploadTask();
|
m_file_sys->CancelUploadTask();
|
||||||
|
|
||||||
@@ -733,6 +740,7 @@ void SendToPrinterDialog::on_cancel(wxCloseEvent &event)
|
|||||||
m_task_timer.reset();
|
m_task_timer.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
this->EndModal(wxID_CANCEL);
|
this->EndModal(wxID_CANCEL);
|
||||||
}
|
}
|
||||||
@@ -771,6 +779,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
|
|||||||
m_status_bar->set_cancel_callback_fina([this]() {
|
m_status_bar->set_cancel_callback_fina([this]() {
|
||||||
BOOST_LOG_TRIVIAL(info) << "print_job: enter canceled";
|
BOOST_LOG_TRIVIAL(info) << "print_job: enter canceled";
|
||||||
m_worker->cancel_all();
|
m_worker->cancel_all();
|
||||||
|
#if !BBL_RELEASE_TO_PUBLIC
|
||||||
if (m_file_sys) {
|
if (m_file_sys) {
|
||||||
m_file_sys->CancelUploadTask();
|
m_file_sys->CancelUploadTask();
|
||||||
if (m_task_timer && m_task_timer->IsRunning()) {
|
if (m_task_timer && m_task_timer->IsRunning()) {
|
||||||
@@ -778,6 +787,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
|
|||||||
m_task_timer.reset();
|
m_task_timer.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
m_is_canceled = true;
|
m_is_canceled = true;
|
||||||
wxCommandEvent* event = new wxCommandEvent(EVT_PRINT_JOB_CANCEL);
|
wxCommandEvent* event = new wxCommandEvent(EVT_PRINT_JOB_CANCEL);
|
||||||
wxQueueEvent(this, event);
|
wxQueueEvent(this, event);
|
||||||
@@ -832,6 +842,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
|
|||||||
fs::path default_output_file_path = boost::filesystem::path(default_output_file.c_str());
|
fs::path default_output_file_path = boost::filesystem::path(default_output_file.c_str());
|
||||||
file_name = default_output_file_path.filename().string();
|
file_name = default_output_file_path.filename().string();
|
||||||
}*/
|
}*/
|
||||||
|
#if !BBL_RELEASE_TO_PUBLIC
|
||||||
if (!obj_->is_lan_mode_printer()) {
|
if (!obj_->is_lan_mode_printer()) {
|
||||||
update_print_status_msg(wxEmptyString, false, false);
|
update_print_status_msg(wxEmptyString, false, false);
|
||||||
if (m_file_sys) {
|
if (m_file_sys) {
|
||||||
@@ -839,7 +850,17 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
|
|||||||
m_plater->get_print_job_data(&print_data);
|
m_plater->get_print_job_data(&print_data);
|
||||||
std::string project_name = m_current_project_name.utf8_string() + ".3mf";
|
std::string project_name = m_current_project_name.utf8_string() + ".3mf";
|
||||||
std::string _3mf_path = print_data._3mf_path.string();
|
std::string _3mf_path = print_data._3mf_path.string();
|
||||||
m_file_sys->SetUploadFile(_3mf_path, project_name, get_storage_selected());
|
|
||||||
|
std::string storage;
|
||||||
|
auto it = std::find_if(m_ability_list.begin(), m_ability_list.end(), [](const std::string& s) {
|
||||||
|
return s != EMMC_STORAGE;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (it != m_ability_list.end())
|
||||||
|
m_file_sys->SetUploadFile(_3mf_path, project_name, *it);
|
||||||
|
else {
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "SendToPrinter::send job: The printer media capability set is incorrect.";
|
||||||
|
}
|
||||||
m_file_sys->RequestUploadFile();
|
m_file_sys->RequestUploadFile();
|
||||||
|
|
||||||
// time out
|
// time out
|
||||||
@@ -863,6 +884,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
|
|||||||
m_task_timer->StartOnce(timeout_period);
|
m_task_timer->StartOnce(timeout_period);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
#endif
|
||||||
auto m_send_job = std::make_unique<SendJob>(m_printer_last_select);
|
auto m_send_job = std::make_unique<SendJob>(m_printer_last_select);
|
||||||
m_send_job->m_dev_ip = obj_->dev_ip;
|
m_send_job->m_dev_ip = obj_->dev_ip;
|
||||||
m_send_job->m_access_code = obj_->get_access_code();
|
m_send_job->m_access_code = obj_->get_access_code();
|
||||||
@@ -893,9 +915,11 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
|
|||||||
m_send_job->set_check_mode();
|
m_send_job->set_check_mode();
|
||||||
m_send_job->check_and_continue();
|
m_send_job->check_and_continue();
|
||||||
}
|
}
|
||||||
|
|
||||||
replace_job(*m_worker, std::move(m_send_job));
|
replace_job(*m_worker, std::move(m_send_job));
|
||||||
|
#if !BBL_RELEASE_TO_PUBLIC
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "send_job: send print job";
|
BOOST_LOG_TRIVIAL(info) << "send_job: send print job";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -937,10 +961,10 @@ void SendToPrinterDialog::update_user_machine_list()
|
|||||||
void SendToPrinterDialog::on_refresh(wxCommandEvent &event)
|
void SendToPrinterDialog::on_refresh(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
BOOST_LOG_TRIVIAL(info) << "m_printer_last_select: on_refresh";
|
BOOST_LOG_TRIVIAL(info) << "m_printer_last_select: on_refresh";
|
||||||
/* show_status(PrintDialogStatus::PrintStatusRefreshingMachineList);
|
show_status(PrintDialogStatus::PrintStatusRefreshingMachineList);
|
||||||
update_user_machine_list();*/
|
update_user_machine_list();
|
||||||
/*todo refresh*/
|
/*todo refresh*/
|
||||||
if (m_file_sys) { m_file_sys->Retry(); }
|
/*if (m_file_sys) { m_file_sys->Retry(); }*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendToPrinterDialog::on_print_job_cancel(wxCommandEvent &evt)
|
void SendToPrinterDialog::on_print_job_cancel(wxCommandEvent &evt)
|
||||||
@@ -1092,12 +1116,16 @@ void SendToPrinterDialog::on_selection_changed(wxCommandEvent &event)
|
|||||||
obj->command_request_push_all();
|
obj->command_request_push_all();
|
||||||
if (!dev->get_selected_machine()) {
|
if (!dev->get_selected_machine()) {
|
||||||
dev->set_selected_machine(m_printer_last_select, true);
|
dev->set_selected_machine(m_printer_last_select, true);
|
||||||
|
#if !BBL_RELEASE_TO_PUBLIC
|
||||||
if (m_file_sys) m_file_sys.reset();
|
if (m_file_sys) m_file_sys.reset();
|
||||||
|
#endif
|
||||||
}else if (dev->get_selected_machine()->dev_id != m_printer_last_select) {
|
}else if (dev->get_selected_machine()->dev_id != m_printer_last_select) {
|
||||||
m_ability_list.clear();
|
m_ability_list.clear();
|
||||||
update_storage_list(std::vector<std::string>());
|
//update_storage_list(std::vector<std::string>());
|
||||||
dev->set_selected_machine(m_printer_last_select, true);
|
dev->set_selected_machine(m_printer_last_select, true);
|
||||||
|
#if !BBL_RELEASE_TO_PUBLIC
|
||||||
if (m_file_sys) m_file_sys.reset();
|
if (m_file_sys) m_file_sys.reset();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1181,6 +1209,11 @@ void SendToPrinterDialog::update_show_status()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_is_in_sending_mode) {
|
if (!m_is_in_sending_mode) {
|
||||||
|
#if BBL_RELEASE_PUPBLIC
|
||||||
|
show_status(PrintDialogStatus::PrintStatusReadingFinished);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (obj_->connection_type() == "lan") {
|
if (obj_->connection_type() == "lan") {
|
||||||
show_status(PrintDialogStatus::PrintStatusReadingFinished);
|
show_status(PrintDialogStatus::PrintStatusReadingFinished);
|
||||||
return;
|
return;
|
||||||
@@ -1192,6 +1225,8 @@ void SendToPrinterDialog::update_show_status()
|
|||||||
if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && obj_->get_file_remote()))
|
if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && obj_->get_file_remote()))
|
||||||
m_file_sys->Retry();
|
m_file_sys->Retry();
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
m_file_sys->Stop(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1260,7 +1295,7 @@ void SendToPrinterDialog::update_show_status()
|
|||||||
m_ability_list = fs->GetMediaAbilityList();
|
m_ability_list = fs->GetMediaAbilityList();
|
||||||
|
|
||||||
if (e.GetInt() == PrinterFileSystem::RequestMediaAbilityStatus::S_SUCCESS) {
|
if (e.GetInt() == PrinterFileSystem::RequestMediaAbilityStatus::S_SUCCESS) {
|
||||||
update_storage_list(m_ability_list);
|
//update_storage_list(m_ability_list);
|
||||||
show_status(PrintDialogStatus::PrintStatusReadingFinished);
|
show_status(PrintDialogStatus::PrintStatusReadingFinished);
|
||||||
} else {
|
} else {
|
||||||
show_status(PrintDialogStatus::PrintStatusPublicInitFailed);
|
show_status(PrintDialogStatus::PrintStatusPublicInitFailed);
|
||||||
@@ -1272,7 +1307,9 @@ void SendToPrinterDialog::update_show_status()
|
|||||||
boost::shared_ptr fs(wfs.lock());
|
boost::shared_ptr fs(wfs.lock());
|
||||||
if (!fs) return;
|
if (!fs) return;
|
||||||
int progress = e.GetInt();
|
int progress = e.GetInt();
|
||||||
m_status_bar->set_progress(10 + std::floor(progress * 0.9));
|
bool cancelled = false;
|
||||||
|
wxString msg = _L("Sending...");
|
||||||
|
m_status_bar->update_status(msg, cancelled, 10 + std::floor(progress * 0.9), true);
|
||||||
|
|
||||||
if (m_task_timer && m_task_timer->IsRunning()) m_task_timer->Stop();
|
if (m_task_timer && m_task_timer->IsRunning()) m_task_timer->Stop();
|
||||||
|
|
||||||
@@ -1287,7 +1324,7 @@ void SendToPrinterDialog::update_show_status()
|
|||||||
boost::shared_ptr fs(wfs.lock());
|
boost::shared_ptr fs(wfs.lock());
|
||||||
if (!fs) return;
|
if (!fs) return;
|
||||||
fs->CancelUploadTask(false);
|
fs->CancelUploadTask(false);
|
||||||
update_print_status_msg(_L("Upload file timeout, please check if the firmware version supports it."), false, true);
|
update_print_status_msg(_L("File upload timed out. Please check if the firmware version supports this operation or verify if the printer is functioning properly."), false, true);
|
||||||
},
|
},
|
||||||
m_task_timer->GetId());
|
m_task_timer->GetId());
|
||||||
m_task_timer->StartOnce(timeout_period);
|
m_task_timer->StartOnce(timeout_period);
|
||||||
@@ -1297,6 +1334,8 @@ void SendToPrinterDialog::update_show_status()
|
|||||||
boost::shared_ptr fs(wfs.lock());
|
boost::shared_ptr fs(wfs.lock());
|
||||||
if (!fs) return;
|
if (!fs) return;
|
||||||
|
|
||||||
|
if (m_task_timer && m_task_timer->IsRunning()) m_task_timer->Stop();
|
||||||
|
|
||||||
if (e.GetInt() == PrinterFileSystem::FF_UPLOADDONE) {
|
if (e.GetInt() == PrinterFileSystem::FF_UPLOADDONE) {
|
||||||
show_status(PrintDialogStatus::PrintStatusReadingFinished);
|
show_status(PrintDialogStatus::PrintStatusReadingFinished);
|
||||||
wxCommandEvent *evt = new wxCommandEvent(m_plater->get_send_finished_event());
|
wxCommandEvent *evt = new wxCommandEvent(m_plater->get_send_finished_event());
|
||||||
@@ -1313,6 +1352,7 @@ void SendToPrinterDialog::update_show_status()
|
|||||||
m_file_sys->Start();
|
m_file_sys->Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SendToPrinterDialog::is_blocking_printing(MachineObject* obj_)
|
bool SendToPrinterDialog::is_blocking_printing(MachineObject* obj_)
|
||||||
@@ -1613,7 +1653,7 @@ bool SendToPrinterDialog::Show(bool show)
|
|||||||
// set default value when show this dialog
|
// set default value when show this dialog
|
||||||
if (show) {
|
if (show) {
|
||||||
m_ability_list.clear();
|
m_ability_list.clear();
|
||||||
update_storage_list(std::vector<std::string>());
|
//update_storage_list(std::vector<std::string>());
|
||||||
wxGetApp().reset_to_active();
|
wxGetApp().reset_to_active();
|
||||||
set_default();
|
set_default();
|
||||||
update_user_machine_list();
|
update_user_machine_list();
|
||||||
@@ -1629,9 +1669,14 @@ bool SendToPrinterDialog::Show(bool show)
|
|||||||
Fit();
|
Fit();
|
||||||
if (show) { CenterOnParent(); }
|
if (show) { CenterOnParent(); }
|
||||||
|
|
||||||
if (m_file_sys) {
|
#if !BBL_RELEASE_TO_PUBLIC
|
||||||
show ? m_file_sys->Start() : m_file_sys->Stop();
|
if (m_file_sys && !show) {
|
||||||
|
m_file_sys->Stop(true);
|
||||||
|
m_waiting_enable = false;
|
||||||
|
m_waiting_support = false;
|
||||||
|
m_file_sys.reset();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return DPIDialog::Show(show);
|
return DPIDialog::Show(show);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user