mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 06:57:36 -06:00
FIX: [STUDIO-2767] retry with remote tunnel when local failed
Change-Id: Id0172239d752508227729e81bee6c1a6ff4d3e9d
This commit is contained in:
parent
c142c8a31e
commit
d8517991e4
6 changed files with 38 additions and 16 deletions
|
@ -2325,6 +2325,13 @@ bool MachineObject::is_support_print_with_timelapse()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MachineObject::is_camera_busy_off()
|
||||||
|
{
|
||||||
|
if (printer_type == "C11")
|
||||||
|
return is_in_prepare() || is_in_upgrading();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int MachineObject::publish_json(std::string json_str, int qos)
|
int MachineObject::publish_json(std::string json_str, int qos)
|
||||||
{
|
{
|
||||||
if (is_lan_mode_printer()) {
|
if (is_lan_mode_printer()) {
|
||||||
|
|
|
@ -784,7 +784,7 @@ public:
|
||||||
bool is_function_supported(PrinterFunction func);
|
bool is_function_supported(PrinterFunction func);
|
||||||
std::vector<std::string> get_resolution_supported();
|
std::vector<std::string> get_resolution_supported();
|
||||||
bool is_support_print_with_timelapse();
|
bool is_support_print_with_timelapse();
|
||||||
|
bool is_camera_busy_off();
|
||||||
|
|
||||||
/* Msg for display MsgFn */
|
/* Msg for display MsgFn */
|
||||||
typedef std::function<void(std::string topic, std::string payload)> MsgFn;
|
typedef std::function<void(std::string topic, std::string payload)> MsgFn;
|
||||||
|
|
|
@ -82,14 +82,14 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
|
||||||
m_lan_mode = obj->is_lan_mode_printer();
|
m_lan_mode = obj->is_lan_mode_printer();
|
||||||
m_lan_ip = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->dev_ip : "";
|
m_lan_ip = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->dev_ip : "";
|
||||||
m_lan_passwd = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->get_access_code() : "";
|
m_lan_passwd = obj->is_function_supported(PrinterFunction::FUNC_LOCAL_TUNNEL) ? obj->get_access_code() : "";
|
||||||
m_tutk_support = obj->is_function_supported(PrinterFunction::FUNC_REMOTE_TUNNEL);
|
m_remote_support = obj->is_function_supported(PrinterFunction::FUNC_REMOTE_TUNNEL);
|
||||||
m_device_busy = obj->is_in_prepare() || obj->is_in_upgrading();
|
m_device_busy = obj->is_camera_busy_off();
|
||||||
} else {
|
} else {
|
||||||
m_camera_exists = false;
|
m_camera_exists = false;
|
||||||
m_lan_mode = false;
|
m_lan_mode = false;
|
||||||
m_lan_ip.clear();
|
m_lan_ip.clear();
|
||||||
m_lan_passwd.clear();
|
m_lan_passwd.clear();
|
||||||
m_tutk_support = true;
|
m_remote_support = true;
|
||||||
m_device_busy = false;
|
m_device_busy = false;
|
||||||
}
|
}
|
||||||
if (machine == m_machine) {
|
if (machine == m_machine) {
|
||||||
|
@ -99,6 +99,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
|
||||||
}
|
}
|
||||||
m_machine = machine;
|
m_machine = machine;
|
||||||
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl switch machine: " << m_machine;
|
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl switch machine: " << m_machine;
|
||||||
|
m_disable_lan = false;
|
||||||
m_failed_retry = 0;
|
m_failed_retry = 0;
|
||||||
m_last_failed_codes.clear();
|
m_last_failed_codes.clear();
|
||||||
std::string stream_url;
|
std::string stream_url;
|
||||||
|
@ -129,10 +130,19 @@ void MediaPlayCtrl::Play()
|
||||||
Stop(_L("Initialize failed (No Device)!"));
|
Stop(_L("Initialize failed (No Device)!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!IsEnabled()) {
|
||||||
|
Stop(_L("Initialize failed (Device connection not ready)!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!m_camera_exists) {
|
if (!m_camera_exists) {
|
||||||
Stop(_L("Initialize failed (No Camera Device)!"));
|
Stop(_L("Initialize failed (No Camera Device)!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (m_device_busy) {
|
||||||
|
Stop(_L("Printer is busy downloading, Please wait for the downloading to finish."));
|
||||||
|
m_failed_retry = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_last_state = MEDIASTATE_INITIALIZING;
|
m_last_state = MEDIASTATE_INITIALIZING;
|
||||||
m_button_play->SetIcon("media_stop");
|
m_button_play->SetIcon("media_stop");
|
||||||
|
@ -140,7 +150,8 @@ void MediaPlayCtrl::Play()
|
||||||
|
|
||||||
NetworkAgent *agent = wxGetApp().getAgent();
|
NetworkAgent *agent = wxGetApp().getAgent();
|
||||||
std::string agent_version = agent ? agent->get_version() : "";
|
std::string agent_version = agent ? agent->get_version() : "";
|
||||||
if (!m_lan_ip.empty() && (!m_lan_mode || !m_lan_passwd.empty()) && !m_device_busy) {
|
if (!m_disable_lan && !m_lan_ip.empty() && (!m_lan_mode || !m_lan_passwd.empty())) {
|
||||||
|
m_disable_lan = m_remote_support && !m_lan_mode; // try remote next time
|
||||||
m_url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd + "&device=" + m_machine + "&version=" + agent_version;
|
m_url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd + "&device=" + m_machine + "&version=" + agent_version;
|
||||||
m_last_state = MEDIASTATE_LOADING;
|
m_last_state = MEDIASTATE_LOADING;
|
||||||
SetStatus(_L("Loading..."));
|
SetStatus(_L("Loading..."));
|
||||||
|
@ -160,27 +171,24 @@ void MediaPlayCtrl::Play()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_lan_mode) {
|
m_disable_lan = false;
|
||||||
|
if (m_lan_ip.empty())
|
||||||
m_failed_code = 1;
|
m_failed_code = 1;
|
||||||
|
|
||||||
|
if (m_lan_mode) {
|
||||||
Stop(m_lan_passwd.empty()
|
Stop(m_lan_passwd.empty()
|
||||||
? _L("Initialize failed (Not supported with LAN-only mode)!")
|
? _L("Initialize failed (Not supported with LAN-only mode)!")
|
||||||
: _L("Initialize failed (Not accessible in LAN-only mode)!"));
|
: _L("Initialize failed (Not accessible in LAN-only mode)!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_tutk_support) { // not support tutk
|
if (!m_remote_support) { // not support tutk
|
||||||
if (m_device_busy) {
|
|
||||||
Stop(_L("Printer is busy downloading, Please wait for the downloading to finish."));
|
|
||||||
m_failed_retry = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_failed_code = 1;
|
|
||||||
Stop(m_lan_ip.empty()
|
Stop(m_lan_ip.empty()
|
||||||
? _L("Initialize failed (Missing LAN ip of printer)!")
|
? _L("Initialize failed (Missing LAN ip of printer)!")
|
||||||
: _L("Initialize failed (Not supported by printer)!"));
|
: _L("Initialize failed (Not supported by printer)!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (agent) {
|
if (agent) {
|
||||||
agent->get_camera_url(m_machine, [this, m = m_machine, v = agent_version](std::string url) {
|
agent->get_camera_url(m_machine, [this, m = m_machine, v = agent_version](std::string url) {
|
||||||
if (boost::algorithm::starts_with(url, "bambu:///")) {
|
if (boost::algorithm::starts_with(url, "bambu:///")) {
|
||||||
|
@ -248,6 +256,7 @@ void MediaPlayCtrl::Stop(wxString const &msg)
|
||||||
j["dev_ip"] = m_lan_ip;
|
j["dev_ip"] = m_lan_ip;
|
||||||
j["result"] = "failed";
|
j["result"] = "failed";
|
||||||
j["user_triggered"] = m_user_triggered;
|
j["user_triggered"] = m_user_triggered;
|
||||||
|
j["tunnel"] = m_url.find("/local/") == std::string::npos ? "remote" : "local";
|
||||||
j["code"] = m_failed_code;
|
j["code"] = m_failed_code;
|
||||||
j["msg"] = into_u8(msg);
|
j["msg"] = into_u8(msg);
|
||||||
NetworkAgent *agent = wxGetApp().getAgent();
|
NetworkAgent *agent = wxGetApp().getAgent();
|
||||||
|
@ -257,7 +266,7 @@ void MediaPlayCtrl::Stop(wxString const &msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
++m_failed_retry;
|
++m_failed_retry;
|
||||||
if (m_failed_code != 0 && !m_tutk_support && (m_failed_retry > 1 || m_user_triggered)) {
|
if (m_failed_code != 0 && (!m_remote_support || m_lan_mode) && (m_failed_retry > 1 || m_user_triggered)) {
|
||||||
m_next_retry = wxDateTime(); // stop retry
|
m_next_retry = wxDateTime(); // stop retry
|
||||||
if (wxGetApp().show_modal_ip_address_enter_dialog(_L("LAN Connection Failed (Failed to start liveview)"))) {
|
if (wxGetApp().show_modal_ip_address_enter_dialog(_L("LAN Connection Failed (Failed to start liveview)"))) {
|
||||||
m_failed_retry = 0;
|
m_failed_retry = 0;
|
||||||
|
|
|
@ -74,8 +74,9 @@ private:
|
||||||
std::string m_lan_passwd;
|
std::string m_lan_passwd;
|
||||||
bool m_camera_exists = false;
|
bool m_camera_exists = false;
|
||||||
bool m_lan_mode = false;
|
bool m_lan_mode = false;
|
||||||
bool m_tutk_support = false;
|
bool m_remote_support = false;
|
||||||
bool m_device_busy = false;
|
bool m_device_busy = false;
|
||||||
|
bool m_disable_lan = false;
|
||||||
wxString m_url;
|
wxString m_url;
|
||||||
|
|
||||||
std::deque<wxString> m_tasks;
|
std::deque<wxString> m_tasks;
|
||||||
|
|
|
@ -573,6 +573,7 @@ void MonitorPanel::show_status(int status)
|
||||||
m_status_info_panel->show_status(status);
|
m_status_info_panel->show_status(status);
|
||||||
m_hms_panel->show_status(status);
|
m_hms_panel->show_status(status);
|
||||||
m_upgrade_panel->show_status(status);
|
m_upgrade_panel->show_status(status);
|
||||||
|
m_media_file_panel->Enable(status == MonitorStatus::MONITOR_NORMAL);
|
||||||
|
|
||||||
if ((status & (int)MonitorStatus::MONITOR_NO_PRINTER) != 0) {
|
if ((status & (int)MonitorStatus::MONITOR_NO_PRINTER) != 0) {
|
||||||
set_default();
|
set_default();
|
||||||
|
|
|
@ -3488,10 +3488,14 @@ void StatusPanel::show_status(int status)
|
||||||
show_printing_status(false, false);
|
show_printing_status(false, false);
|
||||||
m_calibration_btn->Disable();
|
m_calibration_btn->Disable();
|
||||||
m_options_btn->Disable();
|
m_options_btn->Disable();
|
||||||
|
m_panel_monitoring_title->Disable();
|
||||||
|
m_media_play_ctrl->Disable();
|
||||||
} else if ((status & (int) MonitorStatus::MONITOR_NORMAL) != 0) {
|
} else if ((status & (int) MonitorStatus::MONITOR_NORMAL) != 0) {
|
||||||
show_printing_status(true, true);
|
show_printing_status(true, true);
|
||||||
m_calibration_btn->Disable();
|
m_calibration_btn->Disable();
|
||||||
m_options_btn->Enable();
|
m_options_btn->Enable();
|
||||||
|
m_panel_monitoring_title->Enable();
|
||||||
|
m_media_play_ctrl->Enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue