mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-09-28 15:33:16 +08:00
ENH:Modification to Optimization of File Transfer System
jira: [STUDIO-11777] Change-Id: Ica33b4a8177691590c07c3941b738939845d1e55
This commit is contained in:
parent
10fb2bedd0
commit
2100066a4a
@ -767,8 +767,6 @@ void SendToPrinterDialog::on_cancel(wxCloseEvent &event)
|
|||||||
m_send_job->join();
|
m_send_job->join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !BBL_RELEASE_TO_PUBLIC
|
|
||||||
if (m_file_sys) {
|
if (m_file_sys) {
|
||||||
m_file_sys->CancelUploadTask();
|
m_file_sys->CancelUploadTask();
|
||||||
|
|
||||||
@ -777,7 +775,6 @@ void SendToPrinterDialog::on_cancel(wxCloseEvent &event)
|
|||||||
m_task_timer.reset();
|
m_task_timer.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
m_tcp_try_connect = true;
|
m_tcp_try_connect = true;
|
||||||
m_tutk_try_connect = false;
|
m_tutk_try_connect = false;
|
||||||
m_ftp_try_connect = false;
|
m_ftp_try_connect = false;
|
||||||
@ -824,7 +821,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
|
|||||||
}
|
}
|
||||||
m_send_job->join();
|
m_send_job->join();
|
||||||
}
|
}
|
||||||
#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()) {
|
||||||
@ -832,7 +829,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);
|
||||||
@ -887,7 +884,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() && obj_->is_support_brtc) {
|
if (!obj_->is_lan_mode_printer() && obj_->is_support_brtc) {
|
||||||
update_print_status_msg(wxEmptyString, false, false);
|
update_print_status_msg(wxEmptyString, false, false);
|
||||||
if (m_file_sys) {
|
if (m_file_sys) {
|
||||||
@ -930,7 +927,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
m_send_job = std::make_shared<SendJob>(m_status_bar, m_plater, m_printer_last_select);
|
m_send_job = std::make_shared<SendJob>(m_status_bar, m_plater, 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();
|
||||||
@ -977,9 +974,8 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
|
|||||||
} else {
|
} else {
|
||||||
m_send_job->start();
|
m_send_job->start();
|
||||||
}
|
}
|
||||||
#if !BBL_RELEASE_TO_PUBLIC
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << "send_job: send print job";
|
BOOST_LOG_TRIVIAL(info) << "send_job: send print job";
|
||||||
}
|
}
|
||||||
@ -1178,16 +1174,12 @@ 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 {
|
||||||
@ -1267,11 +1259,6 @@ void SendToPrinterDialog::update_show_status()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_is_in_sending_mode) {
|
if (!m_is_in_sending_mode) {
|
||||||
#if BBL_RELEASE_TO_PUBLIC
|
|
||||||
show_status(PrintDialogStatus::PrintStatusReadingFinished);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (!obj_->is_support_brtc || m_ftp_try_connect) {
|
if (!obj_->is_support_brtc || m_ftp_try_connect) {
|
||||||
if (m_file_sys) {
|
if (m_file_sys) {
|
||||||
m_device_select.clear();
|
m_device_select.clear();
|
||||||
@ -1361,76 +1348,75 @@ void SendToPrinterDialog::update_show_status()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
m_file_sys->Bind(EVT_MEDIA_ABILITY_CHANGED, [this, wfs = boost::weak_ptr(m_file_sys)](auto e) {
|
m_file_sys->Bind(EVT_MEDIA_ABILITY_CHANGED, [this, wfs = boost::weak_ptr(m_file_sys)](auto e) {
|
||||||
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()) {
|
if (m_task_timer && m_task_timer->IsRunning()) {
|
||||||
m_task_timer->Stop();
|
m_task_timer->Stop();
|
||||||
m_task_timer.reset();
|
m_task_timer.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
update_print_status_msg(e.GetString(), false, true);
|
update_print_status_msg(e.GetString(), false, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
m_file_sys->Bind(EVT_UPLOADING, [this, wfs = boost::weak_ptr(m_file_sys)](auto e) {
|
m_file_sys->Bind(EVT_UPLOADING, [this, wfs = boost::weak_ptr(m_file_sys)](auto e) {
|
||||||
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();
|
||||||
bool cancelled = false;
|
bool cancelled = false;
|
||||||
wxString msg = _L("Sending...");
|
wxString msg = _L("Sending...");
|
||||||
m_status_bar->update_status(msg, cancelled, 10 + std::floor(progress * 0.9), true);
|
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();
|
||||||
|
|
||||||
if (progress == 99) {
|
if (progress == 99) {
|
||||||
m_task_timer.reset(new wxTimer());
|
m_task_timer.reset(new wxTimer());
|
||||||
m_task_timer->SetOwner(this);
|
m_task_timer->SetOwner(this);
|
||||||
|
|
||||||
this->Bind(
|
this->Bind(
|
||||||
wxEVT_TIMER,
|
wxEVT_TIMER,
|
||||||
[this, wfs = boost::weak_ptr(m_file_sys)](auto e) {
|
[this, wfs = boost::weak_ptr(m_file_sys)](auto e) {
|
||||||
show_status(PrintDialogStatus::PrintStatusPublicUploadFiled);
|
show_status(PrintDialogStatus::PrintStatusPublicUploadFiled);
|
||||||
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("File upload timed out. Please check if the firmware version supports this operation or verify if the printer is functioning properly."), 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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
m_file_sys->Bind(EVT_UPLOAD_CHANGED, [this, wfs = boost::weak_ptr(m_file_sys)](auto e) {
|
m_file_sys->Bind(EVT_UPLOAD_CHANGED, [this, wfs = boost::weak_ptr(m_file_sys)](auto e) {
|
||||||
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 (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());
|
||||||
evt->SetString(from_u8(m_current_project_name.utf8_string()));
|
evt->SetString(from_u8(m_current_project_name.utf8_string()));
|
||||||
wxQueueEvent(m_plater, evt);
|
wxQueueEvent(m_plater, evt);
|
||||||
} else if (e.GetInt() == PrinterFileSystem::FF_UPLOADCANCEL) {
|
} else if (e.GetInt() == PrinterFileSystem::FF_UPLOADCANCEL) {
|
||||||
show_status(PrintDialogStatus::PrintStatusPublicUploadFiled);
|
show_status(PrintDialogStatus::PrintStatusPublicUploadFiled);
|
||||||
wxString err_msg = e.GetString();
|
wxString err_msg = e.GetString();
|
||||||
if (err_msg.IsEmpty())
|
if (err_msg.IsEmpty())
|
||||||
err_msg = _L("Sending failed, please try again!");
|
err_msg = _L("Sending failed, please try again!");
|
||||||
update_print_status_msg(err_msg, false, true);
|
update_print_status_msg(err_msg, false, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
m_file_sys->Start();
|
m_file_sys->Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SendToPrinterDialog::is_blocking_printing(MachineObject* obj_)
|
bool SendToPrinterDialog::is_blocking_printing(MachineObject* obj_)
|
||||||
@ -1776,14 +1762,11 @@ bool SendToPrinterDialog::Show(bool show)
|
|||||||
Fit();
|
Fit();
|
||||||
if (show) { CenterOnParent(); }
|
if (show) { CenterOnParent(); }
|
||||||
|
|
||||||
#if !BBL_RELEASE_TO_PUBLIC
|
|
||||||
if (m_file_sys) {
|
if (m_file_sys) {
|
||||||
m_waiting_enable = false;
|
m_waiting_enable = false;
|
||||||
m_waiting_support = false;
|
m_waiting_support = false;
|
||||||
show ? m_file_sys->Start() : m_file_sys->Stop();
|
show ? m_file_sys->Start() : m_file_sys->Stop();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return DPIDialog::Show(show);
|
return DPIDialog::Show(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user