Update BBS network plugin to 1.10.1 (#8148)

This PR ported the following changes based on BBS 1.10.1 codebase:

- The ability of binding printers via IP (Fix #8099)
- The ability of setting AMS filaments during print (Fix #7882)
- Some other related fixes and improvements

Thanks BambuLab for those improvements!

~~Please note: with this update, we will no longer be able to streaming
the live camera through cloud, only through Lan (even if the printer is
not in Lan mode). At least that's what I saw with this PR and also
#8103, more tests & feedbacks on this are needed.~~ Update: nvm, I
missed a commit that fixes the remote live view. It's working now.

Unfortunately even with this update you still cannot bind the printer in
a different subnet, which is an inherent problem from BBS:
https://github.com/bambulab/BambuStudio/issues/4512
https://github.com/bambulab/BambuStudio/issues/5070
https://github.com/bambulab/BambuStudio/issues/5833
and more...
This commit is contained in:
SoftFever 2025-01-31 15:56:47 +08:00 committed by GitHub
commit 82ce8c94b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 1197 additions and 445 deletions

View file

@ -6,10 +6,10 @@
"resolution_supported": [ "720p", "1080p" ],
"virtual_camera": "enabled",
"liveview": {
"remote": "enabled"
"remote": "tutk"
},
"file": {
"remote": "enabled",
"remote": "tutk",
"model_download": "enabled"
}
},

View file

@ -6,10 +6,10 @@
"resolution_supported": [ "720p", "1080p" ],
"virtual_camera": "enabled",
"liveview": {
"remote": "enabled"
"remote": "tutk"
},
"file": {
"remote": "enabled",
"remote": "tutk",
"model_download": "enabled"
}
},

View file

@ -58,7 +58,7 @@
"print": {
"ipcam": {
"liveview": {
"remote": "enabled"
"remote": "tutk"
}
}
}
@ -79,7 +79,7 @@
"print": {
"ipcam": {
"file": {
"remote": "enabled"
"remote": "tutk"
}
},
"support_user_preset":true

View file

@ -60,7 +60,7 @@
"print": {
"ipcam": {
"liveview": {
"remote": "enabled"
"remote": "tutk"
}
},
"support_mqtt_alive":true,
@ -71,7 +71,7 @@
"print": {
"ipcam": {
"file": {
"remote": "enabled"
"remote": "tutk"
}
},
"support_user_preset":true

View file

@ -6,10 +6,10 @@
"resolution_supported": [ "720p", "1080p" ],
"virtual_camera": "enabled",
"liveview": {
"remote": "enabled"
"remote": "tutk"
},
"file": {
"remote": "enabled",
"remote": "tutk",
"model_download": "enabled"
}
},

View file

@ -6,7 +6,7 @@
"resolution_supported": [ "720p" ],
"liveview": {
"local": "local",
"remote": "enabled"
"remote": "tutk"
}
},
"support_motor_noise_cali":true,
@ -53,7 +53,7 @@
"print": {
"ipcam": {
"file": {
"remote": "enabled"
"remote": "tutk"
}
},
"support_user_preset":true

View file

@ -6,7 +6,7 @@
"resolution_supported": [ "720p" ],
"liveview": {
"local": "local",
"remote": "enabled"
"remote": "tutk"
}
},
"support_motor_noise_cali":true,
@ -53,7 +53,7 @@
"print": {
"ipcam": {
"file": {
"remote": "enabled"
"remote": "tutk"
}
}
}

View file

@ -1 +1 @@
01.08.03.01
01.10.00.01

View file

@ -1961,7 +1961,7 @@ std::set<std::string> PresetBundle::get_printer_names_by_printer_type_and_nozzle
if (printer_it->name.find(nozzle_diameter_str) != std::string::npos) printer_names.insert(printer_it->name);
}
//assert(printer_names.size() == 1);
assert(printer_names.size() == 1);
for (auto& printer_name : printer_names) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " printer name: " << printer_name;

View file

@ -258,7 +258,7 @@ void AMSMaterialsSetting::create_panel_normal(wxWindow* parent)
m_panel_SN->Fit();
wxBoxSizer* m_tip_sizer = new wxBoxSizer(wxHORIZONTAL);
m_tip_readonly = new Label(parent, _L("Setting AMS slot information while printing is not supported"));
m_tip_readonly = new Label(parent, _L(""));
m_tip_readonly->SetForegroundColour(*wxBLACK);
m_tip_readonly->SetBackgroundColour(*wxWHITE);
m_tip_readonly->SetMinSize(wxSize(FromDIP(380), -1));
@ -413,20 +413,27 @@ void AMSMaterialsSetting::update()
void AMSMaterialsSetting::enable_confirm_button(bool en)
{
m_button_confirm->Show(en);
m_tip_readonly->SetLabelText(wxEmptyString);
if (!en) {
m_button_confirm->Show(obj->is_support_filament_setting_inprinting);
}
else {
m_button_confirm->Show(en);
}
if (!m_is_third) {
m_tip_readonly->Hide();
}
else {
//m_comboBox_filament->Show(en);
//m_readonly_filament->Show(!en);
if (!obj->is_support_filament_setting_inprinting) {
if (!is_virtual_tray()) {
m_tip_readonly->SetLabelText(_L("Setting AMS slot information while printing is not supported"));
} else {
m_tip_readonly->SetLabelText(_L("Setting Virtual slot information while printing is not supported"));
}
}
if ( !is_virtual_tray() ) {
m_tip_readonly->SetLabelText(_L("Setting AMS slot information while printing is not supported"));
}
else {
m_tip_readonly->SetLabelText(_L("Setting Virtual slot information while printing is not supported"));
}
m_tip_readonly->Wrap(FromDIP(380));
m_tip_readonly->Show(!en);
}
@ -705,9 +712,14 @@ void AMSMaterialsSetting::on_picker_color(wxCommandEvent& event)
void AMSMaterialsSetting::on_clr_picker(wxMouseEvent &event)
{
if(!m_is_third || obj->is_in_printing() || obj->can_resume())
if(!m_is_third)
return;
if (obj->is_in_printing() || obj->can_resume()) {
if (!obj->is_support_filament_setting_inprinting) {
return;
}
}
std::vector<wxColour> ams_colors;
for (auto ams_it = obj->amsList.begin(); ams_it != obj->amsList.end(); ++ams_it) {
@ -922,8 +934,8 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
}
m_button_reset->Show();
m_button_confirm->Show();
}
//m_button_confirm->Show();
}
m_comboBox_filament->Set(filament_items);
m_comboBox_filament->SetSelection(selection_idx);

View file

@ -907,7 +907,7 @@ AmsHumidityTipPopup::AmsHumidityTipPopup(wxWindow* parent)
close_img = ScalableBitmap(this, "hum_popup_close", 24);
m_staticText = new Label(this, _L("Current Cabin humidity"));
m_staticText = new Label(this, _L("Current AMS humidity"));
m_staticText->SetFont(::Label::Head_24);
humidity_level_list = new AmsHumidityLevelList(this);

View file

@ -2,10 +2,10 @@
#include "GUI_App.hpp"
#include <wx/wx.h>
#include <wx/mstream.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include "wx/evtloop.h"
#include <wx/mstream.h>
#include <wx/tokenzr.h>
#include <wx/richmsgdlg.h>
#include <wx/richtext/richtextctrl.h>
@ -760,7 +760,7 @@ PingCodeBindDialog::~PingCodeBindDialog() {
json j = json::parse(str.utf8_string());
if (j.contains("err_code")) {
int error_code = j["err_code"].get<int>();
extra = wxGetApp().get_hms_query()->query_print_error_msg(error_code);
wxGetApp().get_hms_query()->query_print_error_msg(error_code, extra);
}
}
catch (...) {

View file

@ -18,6 +18,7 @@
#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include "fast_float/fast_float.h"
#include <wx/dir.h>
#define CALI_DEBUG
#define MINUTE_30 1800000 //ms
@ -1430,7 +1431,9 @@ void MachineObject::parse_status(int flag)
sdcard_state = MachineObject::SdcardState((flag >> 8) & 0x11);
network_wired = ((flag >> 18) & 0x1) != 0;
is_support_agora = ((flag >> 30) & 0x1) != 0;
if (is_support_agora)
is_support_tunnel_mqtt = false;
}
PrintingSpeedLevel MachineObject::_parse_printing_speed_lvl(int lvl)
@ -1845,7 +1848,8 @@ int MachineObject::command_ams_calibrate(int ams_id)
int MachineObject::command_ams_filament_settings(int ams_id, int tray_id, std::string filament_id, std::string setting_id, std::string tray_color, std::string tray_type, int nozzle_temp_min, int nozzle_temp_max)
{
BOOST_LOG_TRIVIAL(info) << "command_ams_filament_settings, ams_id = " << ams_id << ", tray_id = " << tray_id << ", tray_color = " << tray_color
<< ", tray_type = " << tray_type << ", setting_id = " << setting_id << ", temp_min: = " << nozzle_temp_min << ", temp_max: = " << nozzle_temp_max;
<< ", tray_type = " << tray_type << ", filament_id = " << filament_id
<< ", setting_id = " << setting_id << ", temp_min: = " << nozzle_temp_min << ", temp_max: = " << nozzle_temp_max;
json j;
j["print"]["command"] = "ams_filament_setting";
j["print"]["sequence_id"] = std::to_string(MachineObject::m_sequence_id++);
@ -2664,7 +2668,6 @@ std::string MachineObject::setting_id_to_type(std::string setting_id, std::strin
if (type.empty()) { type = tray_type; }
BOOST_LOG_TRIVIAL(info) << "The values of tray_info_idx and tray_type do not match tray_info_idx " << setting_id << " tray_type " << tray_type << " system_type" << type;
}
return type;
}
@ -2696,7 +2699,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
if (j_pre.empty()) {
return 0;
}
if (j_pre.contains("print")) {
if (m_active_state == NotActive) m_active_state = Active;
if (j_pre["print"].contains("command")) {
@ -2902,7 +2904,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
}
if (!key_field_only) {
if (!DeviceManager::EnableMultiMachine) {
if (!DeviceManager::EnableMultiMachine && !is_support_agora) {
if (jj.contains("support_tunnel_mqtt")) {
if (jj["support_tunnel_mqtt"].is_boolean()) {
is_support_tunnel_mqtt = jj["support_tunnel_mqtt"].get<bool>();
@ -3079,9 +3081,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
}
}
if (jj.contains("command")) {
if (jj["command"].get<std::string>() == "ams_change_filament") {
if (jj.contains("errno")) {
if (jj["errno"].is_number()) {
@ -3113,8 +3113,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
}
}
}
if (jj["command"].get<std::string>() == "push_status") {
m_push_count++;
last_push_time = last_update_time;
@ -3167,6 +3165,19 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
mc_print_line_number = atoi(jj["mc_print_line_number"].get<std::string>().c_str());
}
}
if (!key_field_only) {
if (jj.contains("flag3")) {
int flag3 = jj["flag3"].get<int>();
is_support_filament_setting_inprinting = get_flag_bits(flag3, 3);
}
}
if (!key_field_only) {
if (jj.contains("net")) {
if (jj["net"].contains("conf")) {
network_wired = (jj["net"]["conf"].get<int>() & (0x1)) != 0;
}
}
}
#pragma endregion
#pragma region online
@ -3266,7 +3277,7 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
if (jj.contains("project_id")
&& jj.contains("profile_id")
&& jj.contains("subtask_id")
){
) {
obj_subtask_id = jj["subtask_id"].get<std::string>();
int plate_index = -1;
@ -3297,7 +3308,6 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
}
}
#pragma endregion
#pragma region status
@ -3567,13 +3577,14 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
&& jj["upgrade_state"]["dis_state"].get<int>() == 3) {
GUI::wxGetApp().CallAfter([this] {
this->command_get_version();
});
});
}
if (upgrade_display_hold_count > 0)
upgrade_display_hold_count--;
else
upgrade_display_state = jj["upgrade_state"]["dis_state"].get<int>();
} else {
}
else {
if (upgrade_display_hold_count > 0)
upgrade_display_hold_count--;
else {
@ -3624,7 +3635,8 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
new_ver_list.insert(std::make_pair(ver_info.name, ver_info));
}
} else {
}
else {
new_ver_list.clear();
}
}
@ -3687,11 +3699,18 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
if (ipcam.contains("liveview")) {
char const *local_protos[] = {"none", "disabled", "local", "rtsps", "rtsp"};
liveview_local = enum_index_of(ipcam["liveview"].value<std::string>("local", "none").c_str(), local_protos, 5, LiveviewLocal::LVL_None);
liveview_remote = ipcam["liveview"].value<std::string>("remote", "disabled") == "enabled";
char const *remote_protos[] = {"none", "tutk", "agora", "tutk_agaro"};
liveview_remote = enum_index_of(ipcam["liveview"].value<std::string>("remote", "none").c_str(), remote_protos, 4, LiveviewRemote::LVR_None);
if (is_support_agora)
liveview_remote = liveview_remote == LVR_None ? LVR_Agora : liveview_remote == LVR_Tutk ? LVR_TutkAgora : liveview_remote;
}
if (ipcam.contains("file")) {
file_local = ipcam["file"].value<std::string>("local", "disabled") == "enabled";
file_remote = ipcam["file"].value<std::string>("remote", "disabled") == "enabled";
char const *local_protos[] = {"none", "local"};
file_local = enum_index_of(ipcam["file"].value<std::string>("local", "none").c_str(), local_protos, 2, FileLocal::FL_None);
char const *remote_protos[] = {"none", "tutk", "agora", "tutk_agaro"};
file_remote = enum_index_of(ipcam["file"].value<std::string>("remote", "none").c_str(), remote_protos, 4, FileRemote::FR_None);
if (is_support_agora)
file_remote = file_remote == FR_None ? FR_Agora : file_remote == FR_Tutk ? FR_TutkAgora : file_remote;
file_model_download = ipcam["file"].value<std::string>("model_download", "disabled") == "enabled";
}
virtual_camera = ipcam.value<std::string>("virtual_camera", "disabled") == "enabled";
@ -3804,11 +3823,13 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
;
}
PresetBundle *preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle;
std::map<std::string, std::vector<Preset const *>> filament_list = preset_bundle->filaments.get_filament_presets();
std::ostringstream stream;
stream << std::fixed << std::setprecision(1) << nozzle_diameter;
std::string nozzle_diameter_str = stream.str();
if (m_printer_preset_name.find(nozzle_diameter_str + " nozzle") == std::string::npos)
update_printer_preset_name(nozzle_diameter_str);
update_filament_list();
std::set<std::string> need_checked_filament_id;
if (jj.contains("ams")) {
if (jj["ams"].contains("ams")) {
long int last_ams_exist_bits = ams_exist_bits;
@ -3970,15 +3991,24 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
} else {
curr_tray->type = type;
}
if (filament_list.find(curr_tray->setting_id) == filament_list.end()) {
wxColour color = *wxWHITE;
char col_buf[10];
sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue());
try {
this->command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), "", "", std::string(col_buf), "", 0, 0);
continue;
} catch (...) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " stoi error and ams_id: " << ams_id << " tray_id" << tray_id;
// settings_id is not exist in filament_list
if (curr_tray->setting_id.size() == 8 && curr_tray->setting_id[0] == 'P' &&
m_filament_list.find(curr_tray->setting_id) == m_filament_list.end()) {
if (m_checked_filament.find(curr_tray->setting_id) == m_checked_filament.end()) {
need_checked_filament_id.insert(curr_tray->setting_id);
wxColour color = *wxWHITE;
char col_buf[10];
sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue());
try {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__
<< " ams settings_id is not exist in filament_list and reset, ams_id: " << ams_id
<< " tray_id" << tray_id << "filament_id: " << curr_tray->setting_id;
this->command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), "", "", std::string(col_buf), "", 0, 0);
continue;
} catch (...) {
BOOST_LOG_TRIVIAL(info)
<< __FUNCTION__ << " " << __LINE__ << " stoi error and ams_id: " << ams_id << " tray_id" << tray_id;
}
}
}
} else {
@ -4028,20 +4058,27 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
curr_tray->nozzle_temp_min = (*tray_it)["nozzle_temp_min"].get<std::string>();
else
curr_tray->nozzle_temp_min = "";
if (curr_tray->nozzle_temp_min != "" && curr_tray->nozzle_temp_max != "") {
try {
std::string preset_setting_id;
bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(
MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, curr_tray->setting_id,
curr_tray->tag_uid, curr_tray->nozzle_temp_min, curr_tray->nozzle_temp_max, preset_setting_id);
if (!is_equation) {
command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), curr_tray->setting_id, preset_setting_id,
curr_tray->color, curr_tray->type,
std::stoi(curr_tray->nozzle_temp_min),
std::stoi(curr_tray->nozzle_temp_max));
if (curr_tray->setting_id.size() == 8 && curr_tray->setting_id[0] == 'P' && curr_tray->nozzle_temp_min != "" && curr_tray->nozzle_temp_max != "") {
if (m_checked_filament.find(vt_tray.setting_id) == m_checked_filament.end()) {
need_checked_filament_id.insert(vt_tray.setting_id);
try {
std::string preset_setting_id;
bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(
MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, curr_tray->setting_id,
curr_tray->tag_uid, curr_tray->nozzle_temp_min, curr_tray->nozzle_temp_max, preset_setting_id);
if (!is_equation) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__
<< " ams filament is not match min max temp and reset, ams_id: " << ams_id
<< " tray_id" << tray_id << "filament_id: " << curr_tray->setting_id;
command_ams_filament_settings(std::stoi(ams_id), std::stoi(tray_id), curr_tray->setting_id, preset_setting_id,
curr_tray->color, curr_tray->type,
std::stoi(curr_tray->nozzle_temp_min),
std::stoi(curr_tray->nozzle_temp_max));
}
continue;
} catch (...) {
BOOST_LOG_TRIVIAL(info) << "check fail and curr_tray ams_id" << ams_id << " curr_tray tray_id"<<tray_id;
}
} catch (...) {
BOOST_LOG_TRIVIAL(info) << "check fail and curr_tray ams_id" << ams_id << " curr_tray tray_id"<<tray_id;
}
}
if (tray_it->contains("xcam_info"))
@ -4165,15 +4202,19 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
else {
vt_tray.type = type;
}
if (filament_list.find(vt_tray.setting_id) == filament_list.end()) {
wxColour color = *wxWHITE;
char col_buf[10];
sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue());
try {
BOOST_LOG_TRIVIAL(info) << "no filament_id in filament_list and reset vt_tray and the filament_id is: " << vt_tray.setting_id;
this->command_ams_filament_settings(255, std::stoi(vt_tray.id), "", "", std::string(col_buf), "", 0, 0);
} catch (...) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " stoi error and tray_id" << vt_tray.id;
if (vt_tray.setting_id.size() == 8 && vt_tray.setting_id[0] == 'P' &&
m_filament_list.find(vt_tray.setting_id) == m_filament_list.end()) {
if (m_checked_filament.find(vt_tray.setting_id) == m_checked_filament.end()) {
need_checked_filament_id.insert(vt_tray.setting_id);
wxColour color = *wxWHITE;
char col_buf[10];
sprintf(col_buf, "%02X%02X%02XFF", (int) color.Red(), (int) color.Green(), (int) color.Blue());
try {
BOOST_LOG_TRIVIAL(info) << "vt_tray.setting_id is not exist in filament_list and reset vt_tray and the filament_id is: " << vt_tray.setting_id;
this->command_ams_filament_settings(255, std::stoi(vt_tray.id), "", "", std::string(col_buf), "", 0, 0);
} catch (...) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " stoi error and tray_id" << vt_tray.id;
}
}
}
}
@ -4223,21 +4264,23 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
vt_tray.nozzle_temp_min = jj["vt_tray"]["nozzle_temp_min"].get<std::string>();
else
vt_tray.nozzle_temp_min = "";
if (vt_tray.nozzle_temp_min != "" && vt_tray.nozzle_temp_max != "") {
try {
std::string preset_setting_id;
bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(
MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, vt_tray.setting_id, vt_tray.tag_uid,
vt_tray.nozzle_temp_min, vt_tray.nozzle_temp_max, preset_setting_id);
if (!is_equation) {
command_ams_filament_settings(255, std::stoi(vt_tray.id), vt_tray.setting_id, preset_setting_id, vt_tray.color, vt_tray.type,
std::stoi(vt_tray.nozzle_temp_min), std::stoi(vt_tray.nozzle_temp_max));
if (vt_tray.setting_id.size() == 8 && vt_tray.setting_id[0] == 'P' && vt_tray.nozzle_temp_min != "" && vt_tray.nozzle_temp_max != "") {
if (m_checked_filament.find(vt_tray.setting_id) == m_checked_filament.end()) {
need_checked_filament_id.insert(vt_tray.setting_id);
try {
std::string preset_setting_id;
bool is_equation = preset_bundle->check_filament_temp_equation_by_printer_type_and_nozzle_for_mas_tray(
MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str, vt_tray.setting_id, vt_tray.tag_uid,
vt_tray.nozzle_temp_min, vt_tray.nozzle_temp_max, preset_setting_id);
if (!is_equation) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " vt_tray filament is not match min max temp and reset, filament_id: " << vt_tray.setting_id;
command_ams_filament_settings(255, std::stoi(vt_tray.id), vt_tray.setting_id, preset_setting_id, vt_tray.color, vt_tray.type,
std::stoi(vt_tray.nozzle_temp_min), std::stoi(vt_tray.nozzle_temp_max));
}
} catch (...) {
BOOST_LOG_TRIVIAL(info) << "check fail and vt_tray.id" << vt_tray.id;
}
}
catch(...) {
BOOST_LOG_TRIVIAL(info) << "check fail and vt_tray.id" << vt_tray.id;
}
}
if (jj["vt_tray"].contains("xcam_info"))
vt_tray.xcam_info = jj["vt_tray"]["xcam_info"].get<std::string>();
@ -4277,8 +4320,9 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
;
}
}
for (auto &filament_id : need_checked_filament_id)
m_checked_filament.insert(filament_id);
#pragma endregion
} else if (jj["command"].get<std::string>() == "gcode_line") {
//ack of gcode_line
BOOST_LOG_TRIVIAL(debug) << "parse_json, ack of gcode_line = " << j.dump(4);
@ -4303,6 +4347,14 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
}
}
} else if (jj["command"].get<std::string>() == "ams_filament_setting" && !key_field_only) {
if (jj.contains("result") && jj.contains("reason")) {
if (jj["result"].get<std::string>() == "fail") {
auto err_code = jj["err_code"].get<int>();
print_error = err_code;
}
}
// BBS trigger ams UI update
ams_version = -1;
@ -4436,6 +4488,12 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
}
}
} else if (jj["command"].get<std::string>() == "extrusion_cali_set") {
if (jj.contains("result") && jj.contains("reason")) {
if (jj["result"].get<std::string>() == "fail") {
auto err_code = jj["err_code"].get<int>();
print_error = err_code;
}
}
#ifdef CALI_DEBUG
std::string str = jj.dump();
BOOST_LOG_TRIVIAL(info) << "extrusion_cali_set: " << str;
@ -4480,6 +4538,13 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
extrusion_cali_set_hold_start = std::chrono::system_clock::now();
}
else if (jj["command"].get<std::string>() == "extrusion_cali_sel") {
if (jj.contains("result") && jj.contains("reason")) {
if (jj["result"].get<std::string>() == "fail") {
auto err_code = jj["err_code"].get<int>();
print_error = err_code;
}
}
#ifdef CALI_DEBUG
std::string str = jj.dump();
BOOST_LOG_TRIVIAL(info) << "extrusion_cali_sel: " << str;
@ -4521,6 +4586,13 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
}
}
else if (jj["command"].get<std::string>() == "extrusion_cali_get") {
if (jj.contains("result") && jj.contains("reason")) {
if (jj["result"].get<std::string>() == "fail") {
auto err_code = jj["err_code"].get<int>();
print_error = err_code;
}
}
reset_pa_cali_history_result();
has_get_pa_calib_tab = true;
@ -4584,6 +4656,13 @@ int MachineObject::parse_json(std::string payload, bool key_field_only)
// notify cali history to update
}
else if (jj["command"].get<std::string>() == "extrusion_cali_get_result") {
if (jj.contains("result") && jj.contains("reason")) {
if (jj["result"].get<std::string>() == "fail") {
auto err_code = jj["err_code"].get<int>();
print_error = err_code;
}
}
reset_pa_cali_result();
get_pa_calib_result = true;
@ -5091,6 +5170,93 @@ std::string MachineObject::get_string_from_fantype(FanType type)
return "";
}
void MachineObject::update_filament_list()
{
PresetBundle *preset_bundle = Slic3r::GUI::wxGetApp().preset_bundle;
// custom filament
std::map<std::string, std::pair<int, int>> filament_list;
for (auto &preset : preset_bundle->filaments()) {
if (preset.is_user() && preset.inherits() == "") {
ConfigOption * printer_opt = const_cast<Preset&>(preset).config.option("compatible_printers");
ConfigOptionStrings *printer_strs = dynamic_cast<ConfigOptionStrings *>(printer_opt);
for (const std::string &printer_str : printer_strs->values) {
if (printer_str == m_printer_preset_name) {
ConfigOption *opt_min = const_cast<Preset &>(preset).config.option("nozzle_temperature_range_low");
int min_temp = -1;
if (opt_min) {
ConfigOptionInts *opt_min_ints = dynamic_cast<ConfigOptionInts *>(opt_min);
min_temp = opt_min_ints->get_at(0);
}
ConfigOption *opt_max = const_cast<Preset &>(preset).config.option("nozzle_temperature_range_high");
int max_temp = -1;
if (opt_max) {
ConfigOptionInts *opt_max_ints = dynamic_cast<ConfigOptionInts *>(opt_max);
max_temp = opt_max_ints->get_at(0);
}
filament_list[preset.filament_id] = std::make_pair(min_temp, max_temp);
break;
}
}
}
}
for (auto it = filament_list.begin(); it != filament_list.end(); it++) {
if (m_filament_list.find(it->first) != m_filament_list.end()) {
assert(it->first.size() == 8 && it->first[0] == 'P');
if (it->second.first != m_filament_list[it->first].first) {
BOOST_LOG_TRIVIAL(info) << "old min temp is not equal to new min temp and filament id: " << it->first;
continue;
}
if (it->second.second != m_filament_list[it->first].second) {
BOOST_LOG_TRIVIAL(info) << "old max temp is not equal to new max temp and filament id: " << it->first;
continue;
}
m_filament_list.erase(it->first);
}
}
for (auto it = m_filament_list.begin(); it != m_filament_list.end(); it++) {
m_checked_filament.erase(it->first);
}
m_filament_list = filament_list;
}
int MachineObject::get_flag_bits(std::string str, int start, int count)
{
int decimal_value = std::stoi(str, nullptr, 16);
int mask = 0;
for (int i = 0; i < count; i++) { mask += 1 << (start + i); }
int flag = (decimal_value & (mask)) >> start;
return flag;
}
int MachineObject::get_flag_bits(int num, int start, int count)
{
int decimal_value = num;
int mask = 0;
for (int i = 0; i < count; i++) { mask += 1 << (start + i); }
int flag = (decimal_value & (mask)) >> start;
return flag;
}
void MachineObject::update_printer_preset_name(const std::string &nozzle_diameter_str)
{
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << "start update preset_name";
auto preset_boundle = Slic3r::GUI::wxGetApp().preset_bundle;
auto printer_set = preset_boundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(this->printer_type), nozzle_diameter_str);
if (printer_set.size() > 0)
m_printer_preset_name = *printer_set.begin();
else
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << " update printer preset name failed ";
}
bool DeviceManager::EnableMultiMachine = false;
bool DeviceManager::key_field_only = false;
@ -5160,6 +5326,8 @@ void DeviceManager::check_pushing()
}
}
void DeviceManager::on_machine_alive(std::string json_str)
{
try {
@ -5172,6 +5340,12 @@ void DeviceManager::on_machine_alive(std::string json_str)
std::string printer_signal = j["dev_signal"].get<std::string>();
std::string connect_type = j["connect_type"].get<std::string>();
std::string bind_state = j["bind_state"].get<std::string>();
if (connect_type == "farm") {
connect_type ="lan";
bind_state = "free";
}
std::string sec_link = "";
std::string ssdp_version = "";
if (j.contains("sec_link")) {
@ -5275,6 +5449,21 @@ void DeviceManager::on_machine_alive(std::string json_str)
}
}
MachineObject* DeviceManager::insert_local_device(std::string dev_name, std::string dev_id, std::string dev_ip, std::string connection_type, std::string bind_state, std::string version, std::string access_code)
{
MachineObject* obj;
obj = new MachineObject(m_agent, dev_name, dev_id, dev_ip);
obj->printer_type = MachineObject::parse_printer_type("C11");
obj->dev_connection_type = connection_type;
obj->bind_state = bind_state;
obj->bind_sec_link = "secure";
obj->bind_ssdp_version = version;
obj->m_is_online = true;
obj->set_access_code(access_code, false);
obj->set_user_access_code(access_code, false);
return obj;
}
void DeviceManager::disconnect_all()
{
@ -5469,6 +5658,7 @@ bool DeviceManager::set_selected_machine(std::string dev_id, bool need_disconnec
}
}
}
it->second->m_checked_filament.clear();
}
selected_machine = dev_id;
return true;
@ -5662,7 +5852,7 @@ void DeviceManager::parse_user_print_info(std::string body)
}
}
}
catch (std::exception&) {
catch (std::exception& e) {
;
}
}
@ -5761,6 +5951,7 @@ std::string DeviceManager::get_printer_ams_img(std::string type_str)
bool DeviceManager::get_printer_is_enclosed(std::string type_str) {
return get_value_from_config<bool>(type_str, "printer_is_enclosed");
}
std::vector<std::string> DeviceManager::get_resolution_supported(std::string type_str)
{
std::vector<std::string> resolution_supported;
@ -5806,6 +5997,49 @@ std::vector<std::string> DeviceManager::get_compatible_machine(std::string type_
return compatible_machine;
}
boost::bimaps::bimap<std::string, std::string> DeviceManager::get_all_model_id_with_name()
{
boost::bimaps::bimap<std::string, std::string> models;
std::vector<wxString> m_files;
wxDir dir(Slic3r::resources_dir() + "/printers/");
if (!dir.IsOpened()) {
return models;
}
wxString filename;
bool hasFile = dir.GetFirst(&filename, wxEmptyString, wxDIR_FILES);
while (hasFile) {
m_files.push_back(filename);
hasFile = dir.GetNext(&filename);
}
for (wxString file : m_files) {
std::string config_file = Slic3r::resources_dir() + "/printers/" + file.ToStdString();
boost::nowide::ifstream json_file(config_file.c_str());
try {
json jj;
if (json_file.is_open()) {
json_file >> jj;
if (jj.contains("00.00.00.00")) {
json const &printer = jj["00.00.00.00"];
std::string model_id;
std::string display_name;
if (printer.contains("model_id")) {model_id = printer["model_id"].get<std::string>();}
if (printer.contains("display_name")) {display_name = printer["display_name"].get<std::string>();}
if (!model_id.empty() && !display_name.empty()) {
models.left.insert(make_pair(model_id, display_name));
}
}
}
} catch (...) {}
}
return models;
}
bool DeviceManager::load_filaments_blacklist_config()
{
@ -5857,15 +6091,11 @@ void DeviceManager::check_filaments_in_blacklist(std::string tag_vendor, std::st
{
vendor = prohibited_filament["vendor"].get<std::string>();
type = prohibited_filament["type"].get<std::string>();
if (GUI::wxGetApp().app_config->get("skip_ams_blacklist_check") == "true") {
action = "warning";
}
else {
action = prohibited_filament["action"].get<std::string>();
}
if (GUI::wxGetApp().app_config->get("skip_ams_blacklist_check") == "true") {
action = "warning";
} else {
action = prohibited_filament["action"].get<std::string>();
}
description = prohibited_filament["description"].get<std::string>();
description = blacklist_prompt[description].ToUTF8().data();

View file

@ -2,17 +2,18 @@
#define slic3r_DeviceManager_hpp_
#include <map>
#include <mutex>
#include <vector>
#include <string>
#include <memory>
#include <chrono>
#include <mutex>
#include <boost/thread.hpp>
#include <boost/nowide/fstream.hpp>
#include "nlohmann/json.hpp"
#include "libslic3r/ProjectTask.hpp"
#include "slic3r/Utils/json_diff.hpp"
#include "slic3r/Utils/NetworkAgent.hpp"
#include "boost/bimap/bimap.hpp"
#include "CameraPopup.hpp"
#include "libslic3r/calib.hpp"
#include "libslic3r/Utils.hpp"
@ -313,6 +314,7 @@ struct DisValue {
bool is_type_match = true;
};
class Preset;
class MachineObject
{
private:
@ -708,9 +710,22 @@ public:
LVL_Rtsps,
LVL_Rtsp
} liveview_local{ LVL_None };
bool liveview_remote{false};
bool file_local{false};
bool file_remote{false};
enum LiveviewRemote {
LVR_None,
LVR_Tutk,
LVR_Agora,
LVR_TutkAgora
} liveview_remote{ LVR_None };
enum FileLocal {
FL_None,
FL_Local
} file_local{ FL_None };
enum FileRemote {
FR_None,
FR_Tutk,
FR_Agora,
FR_TutkAgora
} file_remote{ FR_None };
bool file_model_download{false};
bool virtual_camera{false};
@ -762,6 +777,8 @@ public:
bool is_support_p1s_plus{false};
bool is_support_nozzle_blob_detection{false};
bool is_support_air_print_detection{false};
bool is_support_filament_setting_inprinting{false};
bool is_support_agora{false};
int nozzle_max_temperature = -1;
int bed_temperature_limit = -1;
@ -958,6 +975,15 @@ public:
void get_firmware_info();
bool is_firmware_info_valid();
std::string get_string_from_fantype(FanType type);
/* Device Filament Check */
std::set<std::string> m_checked_filament;
std::string m_printer_preset_name;
std::map<std::string, std::pair<int, int>> m_filament_list; // filament_id, pair<min temp, max temp>
void update_filament_list();
int get_flag_bits(std::string str, int start, int count = 1);
int get_flag_bits(int num, int start, int count = 1);
void update_printer_preset_name(const std::string &nozzle_diameter_str);
};
class DeviceManager
@ -1006,7 +1032,7 @@ public:
/* create machine or update machine properties */
void on_machine_alive(std::string json_str);
MachineObject* insert_local_device(std::string dev_name, std::string dev_id, std::string dev_ip, std::string connection_type, std::string bind_state, std::string version, std::string access_code);
/* disconnect all machine connections */
void disconnect_all();
int query_bind_status(std::string &msg);
@ -1052,11 +1078,12 @@ public:
static std::string get_printer_ams_img(std::string type_str);
static PrinterArch get_printer_arch(std::string type_str);
static std::string get_ftp_folder(std::string type_str);
static bool get_printer_is_enclosed(std::string type_str);
static std::vector<std::string> get_resolution_supported(std::string type_str);
static std::vector<std::string> get_compatible_machine(std::string type_str);
static bool get_printer_is_enclosed(std::string type_str);
static bool load_filaments_blacklist_config();
static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info);
static std::vector<std::string> get_resolution_supported(std::string type_str);
static std::vector<std::string> get_compatible_machine(std::string type_str);
static boost::bimaps::bimap<std::string, std::string> get_all_model_id_with_name();
static std::string load_gcode(std::string type_str, std::string gcode_file);
};

View file

@ -1024,8 +1024,10 @@ void GUI_App::post_init()
for (auto& it : boost::filesystem::directory_iterator(log_folder)) {
auto temp_path = it.path();
try {
std::time_t lw_t = boost::filesystem::last_write_time(temp_path) ;
files_vec.push_back({ lw_t, temp_path.filename().string() });
if (it.status().type() == boost::filesystem::regular_file) {
std::time_t lw_t = boost::filesystem::last_write_time(temp_path) ;
files_vec.push_back({ lw_t, temp_path.filename().string() });
}
} catch (const std::exception &) {
}
}
@ -1569,6 +1571,33 @@ void GUI_App::init_networking_callbacks()
// GUI::wxGetApp().request_user_handle(online_login);
// });
m_agent->set_server_callback([this](std::string url, int status) {
CallAfter([this]() {
if (!m_server_error_dialog) {
/*m_server_error_dialog->EndModal(wxCLOSE);
m_server_error_dialog->Destroy();
m_server_error_dialog = nullptr;*/
m_server_error_dialog = new NetworkErrorDialog(mainframe);
}
if(plater()->get_select_machine_dialog() && plater()->get_select_machine_dialog()->IsShown()){
return;
}
if (m_server_error_dialog->m_show_again) {
return;
}
if (m_server_error_dialog->IsShown()) {
return;
}
m_server_error_dialog->ShowModal();
});
});
m_agent->set_on_server_connected_fn([this](int return_code, int reason_code) {
if (m_is_closing) {
return;
@ -3225,6 +3254,23 @@ void GUI_App::link_to_network_check()
wxLaunchDefaultBrowser(url);
}
void GUI_App::link_to_lan_only_wiki()
{
std::string url;
std::string country_code = app_config->get_country_code();
if (country_code == "US") {
url = "https://wiki.bambulab.com/en/knowledge-sharing/enable-lan-mode";
}
else if (country_code == "CN") {
url = "https://wiki.bambulab.com/zh/knowledge-sharing/enable-lan-mode";
}
else {
url = "https://wiki.bambulab.com/en/knowledge-sharing/enable-lan-mode";
}
wxLaunchDefaultBrowser(url);
}
bool GUI_App::tabs_as_menu() const
{
return false;
@ -3684,7 +3730,7 @@ void GUI_App::request_user_logout()
{
if (m_agent && m_agent->is_user_login()) {
// Update data first before showing dialogs
m_agent->user_logout();
m_agent->user_logout(true);
m_agent->set_user_selected_machine("");
/* delete old user settings */
bool transfer_preset_changes = false;

View file

@ -1,13 +1,6 @@
#ifndef slic3r_GUI_App_hpp_
#define slic3r_GUI_App_hpp_
#include <wx/app.h>
#include <wx/colour.h>
#include <wx/font.h>
#include <wx/string.h>
#include <wx/snglinst.h>
#include <wx/msgdlg.h>
#include <memory>
#include <string>
#include "ImGuiWrapper.hpp"
@ -26,6 +19,13 @@
#include "slic3r/GUI/HttpServer.hpp"
#include "../Utils/PrintHost.hpp"
#include <wx/app.h>
#include <wx/colour.h>
#include <wx/font.h>
#include <wx/string.h>
#include <wx/snglinst.h>
#include <wx/msgdlg.h>
#include <mutex>
#include <stack>
@ -81,6 +81,7 @@ class ParamsDialog;
class HMSQuery;
class ModelMallDialog;
class PingCodeBindDialog;
class NetworkErrorDialog;
enum FileType
@ -274,7 +275,7 @@ private:
std::unique_ptr <OtherInstanceMessageHandler> m_other_instance_message_handler;
std::unique_ptr <wxSingleInstanceChecker> m_single_instance_checker;
std::string m_instance_hash_string;
size_t m_instance_hash_int;
size_t m_instance_hash_int;
std::unique_ptr<Downloader> m_downloader;
@ -309,8 +310,8 @@ private:
HttpServer m_http_server;
bool m_show_gcode_window{true};
boost::thread m_check_network_thread;
public:
//try again when subscription fails
public:
//try again when subscription fails
void on_start_subscribe_again(std::string dev_id);
void check_filaments_in_blacklist(std::string tag_supplier, std::string tag_material, bool& in_blacklist, std::string& action, std::string& info);
std::string get_local_models_path();
@ -393,9 +394,9 @@ private:
bool get_side_menu_popup_status();
void set_side_menu_popup_status(bool status);
void link_to_network_check();
void link_to_lan_only_wiki();
const wxColour& get_label_clr_modified(){ return m_color_label_modified; }
const wxColour& get_label_clr_modified() { return m_color_label_modified; }
const wxColour& get_label_clr_sys() { return m_color_label_sys; }
const wxColour& get_label_clr_default() { return m_color_label_default; }
const wxColour& get_window_default_clr(){ return m_color_window_default; }
@ -556,7 +557,7 @@ private:
#endif /* __APPLE */
Sidebar& sidebar();
GizmoObjectManipulation* obj_manipul();
GizmoObjectManipulation *obj_manipul();
ObjectSettings* obj_settings();
ObjectList* obj_list();
ObjectLayers* obj_layers();
@ -574,6 +575,8 @@ private:
ModelMallDialog* m_mall_publish_dialog{ nullptr };
PingCodeBindDialog* m_ping_code_binding_dialog{ nullptr };
NetworkErrorDialog* m_server_error_dialog { nullptr };
void set_download_model_url(std::string url) {m_mall_model_download_url = url;}
void set_download_model_name(std::string name) {m_mall_model_download_name = name;}
std::string get_download_model_url() {return m_mall_model_download_url;}

View file

@ -243,14 +243,15 @@ wxString HMSQuery::_query_hms_msg(std::string long_error_code, std::string lang_
return wxEmptyString;
}
wxString HMSQuery::_query_error_msg(std::string error_code, std::string lang_code)
bool HMSQuery::_query_error_msg(wxString &error_msg, std::string error_code, std::string lang_code)
{
if (m_hms_info_json.contains("device_error")) {
if (m_hms_info_json["device_error"].contains(lang_code)) {
for (auto item = m_hms_info_json["device_error"][lang_code].begin(); item != m_hms_info_json["device_error"][lang_code].end(); item++) {
if (item->contains("ecode") && boost::to_upper_copy((*item)["ecode"].get<std::string>()) == error_code) {
if (item->contains("intro")) {
return wxString::FromUTF8((*item)["intro"].get<std::string>());
error_msg = wxString::FromUTF8((*item)["intro"].get<std::string>());
return true;
}
}
}
@ -263,7 +264,8 @@ wxString HMSQuery::_query_error_msg(std::string error_code, std::string lang_cod
for (auto item = lang.begin(); item != lang.end(); item++) {
if (item->contains("ecode") && boost::to_upper_copy((*item)["ecode"].get<std::string>()) == error_code) {
if (item->contains("intro")) {
return wxString::FromUTF8((*item)["intro"].get<std::string>());
error_msg = wxString::FromUTF8((*item)["intro"].get<std::string>());
return true;
}
}
}
@ -273,9 +275,11 @@ wxString HMSQuery::_query_error_msg(std::string error_code, std::string lang_cod
}
else {
BOOST_LOG_TRIVIAL(info) << "device_error is not exists";
return wxEmptyString;
error_msg = wxEmptyString;
return false;
}
return wxEmptyString;
error_msg = wxEmptyString;
return false;
}
wxString HMSQuery::_query_error_url_action(std::string long_error_code, std::string dev_id, std::vector<int>& button_action)
@ -305,12 +309,12 @@ wxString HMSQuery::_query_error_url_action(std::string long_error_code, std::str
}
wxString HMSQuery::query_print_error_msg(int print_error)
bool HMSQuery::query_print_error_msg(int print_error, wxString &error_msg)
{
char buf[32];
::sprintf(buf, "%08X", print_error);
std::string lang_code = HMSQuery::hms_language_code();
return _query_error_msg(std::string(buf), lang_code);
return _query_error_msg(error_msg, std::string(buf), lang_code);
}
wxString HMSQuery::query_print_error_url_action(int print_error, std::string dev_id, std::vector<int>& button_action)

View file

@ -28,13 +28,13 @@ protected:
int save_to_local(std::string lang, std::string hms_type,json save_json);
std::string get_hms_file(std::string hms_type, std::string lang = std::string("en"));
wxString _query_hms_msg(std::string long_error_code, std::string lang_code = std::string("en"));
wxString _query_error_msg(std::string long_error_code, std::string lang_code = std::string("en"));
bool _query_error_msg(wxString &error_msg, std::string long_error_code, std::string lang_code = std::string("en"));
wxString _query_error_url_action(std::string long_error_code, std::string dev_id, std::vector<int>& button_action);
public:
HMSQuery() {}
int check_hms_info();
wxString query_hms_msg(std::string long_error_code);
wxString query_print_error_msg(int print_error);
bool query_print_error_msg(int print_error, wxString &error_msg);
wxString query_print_error_url_action(int print_error, std::string dev_id, std::vector<int>& button_action);
static std::string hms_language_code();
static std::string build_query_params(std::string& lang);

View file

@ -105,7 +105,9 @@ void BindJob::process(Ctl &ctl)
try
{
error_code = stoi(result_info);
result_info = wxGetApp().get_hms_query()->query_print_error_msg(error_code).ToStdString();
wxString error_msg;
wxGetApp().get_hms_query()->query_print_error_msg(error_code, error_msg);
result_info = error_msg.ToStdString();
}
catch (...) {
;

View file

@ -219,10 +219,10 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
m_lan_ip = obj->dev_ip;
m_lan_passwd = obj->get_access_code();
m_dev_ver = obj->get_ota_version();
m_device_busy = obj->is_camera_busy_off();
m_device_busy = obj->is_camera_busy_off();
m_sdcard_exist = obj->has_sdcard();
m_local_support = obj->file_local;
m_remote_support = obj->file_remote;
m_local_proto = obj->file_local;
m_remote_proto = obj->file_remote;
m_model_download_support = obj->file_model_download;
} else {
m_lan_mode = false;
@ -231,13 +231,13 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
m_dev_ver.clear();
m_sdcard_exist = false;
m_device_busy = false;
m_local_support = false;
m_remote_support = false;
m_local_proto = 0;
m_remote_proto = 0;
m_model_download_support = false;
}
Enable(obj && obj->is_connected() && obj->m_push_count > 0);
if (machine == m_machine) {
if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && (m_local_support || m_remote_support))) {
if ((m_waiting_enable && IsEnabled()) || (m_waiting_support && (m_local_proto || m_remote_proto))) {
auto fs = m_image_grid->GetFileSystem();
if (fs) fs->Retry();
}
@ -255,7 +255,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
m_button_management->Enable(false);
SetSelecting(false);
if (m_machine.empty()) {
m_image_grid->SetStatus(m_bmp_failed, _L("No printers."));
m_image_grid->SetStatus(m_bmp_failed, _L("Please confirm if the printer is connected."));
} else {
boost::shared_ptr<PrinterFileSystem> fs(new PrinterFileSystem);
fs->Attached();
@ -296,7 +296,7 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
switch (status) {
case PrinterFileSystem::Initializing: icon = m_bmp_loading; msg = _L("Initializing..."); break;
case PrinterFileSystem::Connecting: icon = m_bmp_loading; msg = _L("Connecting..."); break;
case PrinterFileSystem::Failed: icon = m_bmp_failed; if (extra != 1) msg = _L("Connect failed [%d]!"); break;
case PrinterFileSystem::Failed: icon = m_bmp_failed; if (extra != 1) msg = _L("Please check the network and try again, You can restart or update the printer if the issue persists."); break;
case PrinterFileSystem::ListSyncing: icon = m_bmp_loading; msg = _L("Loading file list..."); break;
case PrinterFileSystem::ListReady: icon = extra == 0 ? m_bmp_empty : m_bmp_failed; msg = extra == 0 ? _L("No files") : _L("Load failed"); break;
}
@ -310,7 +310,6 @@ void MediaFilePanel::SetMachineObject(MachineObject* obj)
if (e.GetInt() == PrinterFileSystem::Initializing)
fetchUrl(boost::weak_ptr(fs));
err = fs->GetLastError();
if ((status == PrinterFileSystem::Failed && m_last_errors.find(err) == m_last_errors.end()) ||
status == PrinterFileSystem::ListReady) {
m_last_errors.insert(fs->GetLastError());
@ -421,6 +420,7 @@ void MediaFilePanel::modeChanged(wxCommandEvent& e1)
}
extern wxString hide_passwd(wxString url, std::vector<wxString> const &passwords);
extern void refresh_agora_url(char const *device, char const *dev_ver, char const *channel, void *context, void (*callback)(void *context, char const *url));
void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
{
@ -428,19 +428,19 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
if (!fs || fs != m_image_grid->GetFileSystem()) return;
if (!IsEnabled()) {
m_waiting_enable = true;
m_image_grid->SetStatus(m_bmp_failed, _L("Initialize failed (Device connection not ready)!"));
m_image_grid->SetStatus(m_bmp_failed, _L("Please confirm if the printer is connected."));
fs->SetUrl("0");
return;
}
m_waiting_enable = false;
if (!m_local_support && !m_remote_support) {
if (!m_local_proto && !m_remote_proto) {
m_waiting_support = true;
m_image_grid->SetStatus(m_bmp_failed, _L("Browsing file in SD card is not supported in current firmware. Please update the printer firmware."));
fs->SetUrl("0");
return;
}
if (!m_sdcard_exist) {
m_image_grid->SetStatus(m_bmp_failed, _L("Initialize failed (Storage unavailable, insert SD card.)!"));
m_image_grid->SetStatus(m_bmp_failed, _L("Please check if the SD card is inserted into the printer.\nIf it still cannot be read, you can try formatting the SD card."));
fs->SetUrl("0");
return;
}
@ -452,7 +452,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
m_waiting_support = false;
NetworkAgent *agent = wxGetApp().getAgent();
std::string agent_version = agent ? agent->get_version() : "";
if ((m_lan_mode || !m_remote_support) && m_local_support && !m_lan_ip.empty()) {
if ((m_lan_mode || !m_remote_proto) && m_local_proto && !m_lan_ip.empty()) {
std::string url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd;
url += "&device=" + m_machine;
url += "&net_ver=" + agent_version;
@ -462,7 +462,7 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
fs->SetUrl(url);
return;
}
if (!m_remote_support && m_local_support) { // not support tutk
if (!m_remote_proto && m_local_proto) { // not support tutk
m_image_grid->SetStatus(m_bmp_failed, _L("Please enter the IP of printer to connect."));
fs->SetUrl("0");
fs.reset();
@ -478,12 +478,14 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
return;
}
if (agent) {
agent->get_camera_url(m_machine,
std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""};
agent->get_camera_url(m_machine + "|" + m_dev_ver + "|" + protocols[m_remote_proto],
[this, wfs, m = m_machine, v = agent->get_version(), dv = m_dev_ver](std::string url) {
if (boost::algorithm::starts_with(url, "bambu:///")) {
url += "&device=" + m;
url += "&net_ver=" + v;
url += "&dev_ver=" + dv;
url += "&refresh_url=" + boost::lexical_cast<std::string>(&refresh_agora_url);
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
url += "&cli_ver=" + std::string(SLIC3R_VERSION);
}
@ -492,9 +494,9 @@ void MediaFilePanel::fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs)
boost::shared_ptr fs(wfs.lock());
if (!fs || fs != m_image_grid->GetFileSystem()) return;
if (boost::algorithm::starts_with(url, "bambu:///")) {
fs->SetUrl(url + "&device=" + m + "&dev_ver=" + v);
fs->SetUrl(url);
} else {
m_image_grid->SetStatus(m_bmp_failed, wxString::Format(_L("Initialize failed (%s)!"), url.empty() ? _L("Network unreachable") : from_u8(url)));
m_image_grid->SetStatus(m_bmp_failed, _L("Connection Failed. Please check the network and try again"));
fs->SetUrl("3");
}
});

View file

@ -8,9 +8,11 @@
#ifndef MediaFilePanel_h
#define MediaFilePanel_h
#include <set>
#include "GUI_Utils.hpp"
#include "wxExtensions.hpp"
#include <set>
#include <wx/frame.h>
class Button;
@ -83,8 +85,8 @@ private:
std::string m_dev_ver;
bool m_lan_mode = false;
bool m_sdcard_exist = false;
bool m_local_support = false;
bool m_remote_support = false;
int m_local_proto = false;
int m_remote_proto = false;
bool m_model_download_support = false;
bool m_device_busy = false;
bool m_waiting_enable = false;

View file

@ -150,7 +150,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
m_dev_ver = obj->get_ota_version();
m_lan_mode = obj->is_lan_mode_printer();
m_lan_proto = obj->liveview_local;
m_remote_support = obj->liveview_remote;
m_remote_proto = obj->liveview_remote;
m_lan_ip = obj->dev_ip;
m_lan_passwd = obj->get_access_code();
m_device_busy = obj->is_camera_busy_off();
@ -163,7 +163,7 @@ void MediaPlayCtrl::SetMachineObject(MachineObject* obj)
m_lan_passwd.clear();
m_dev_ver.clear();
m_tutk_state.clear();
m_remote_support = true;
m_remote_proto = 0;
m_device_busy = false;
}
Enable(obj && obj->is_connected() && obj->m_push_count > 0);
@ -212,6 +212,7 @@ wxString hide_id_middle_string(wxString const &str, size_t offset = 0, size_t le
wxString hide_passwd(wxString url, std::vector<wxString> const &passwords)
{
#if BBL_RELEASE_TO_PUBLIC
for (auto &p : passwords) {
auto i = url.find(p);
if (i == wxString::npos)
@ -228,9 +229,22 @@ wxString hide_passwd(wxString url, std::vector<wxString> const &passwords)
else if (j == url.length() || url[j] == '@' || url[j] == '&')
url.replace(i, l, l, wxUniChar('*'));
}
#endif
return url;
}
void refresh_agora_url(char const* device, char const* dev_ver, char const* channel, void* context, void (*callback)(void* context, char const* url))
{
std::string device2 =device;
device2 += "|";
device2 += dev_ver;
device2 += "|\"agora\"|";
device2 += channel;
wxGetApp().getAgent()->get_camera_url(device2, [context, callback](std::string url) {
callback(context, url.c_str());
});
}
void MediaPlayCtrl::Play()
{
if (!m_next_retry.IsValid() || wxDateTime::Now() < m_next_retry)
@ -259,11 +273,10 @@ void MediaPlayCtrl::Play()
return;
}
m_button_play->SetIcon("media_stop");
NetworkAgent *agent = wxGetApp().getAgent();
std::string agent_version = agent ? agent->get_version() : "";
if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_support) && !m_disable_lan && !m_lan_ip.empty()) {
m_disable_lan = m_remote_support && !m_lan_mode; // try remote next time
if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_proto) && !m_disable_lan && !m_lan_ip.empty()) {
m_disable_lan = m_remote_proto && !m_lan_mode; // try remote next time
std::string url;
if (m_lan_proto == MachineObject::LVL_Local)
url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd;
@ -279,18 +292,19 @@ void MediaPlayCtrl::Play()
BOOST_LOG_TRIVIAL(info) << "MediaPlayCtrl: " << hide_passwd(hide_id_middle_string(url, url.find(m_lan_ip), m_lan_ip.length()), {m_lan_passwd});
m_url = url;
load();
m_button_play->SetIcon("media_stop");
return;
}
// m_lan_mode && m_lan_proto > LVL_Disable (use local tunnel)
// m_lan_mode && m_lan_proto == LVL_Disable (*)
// m_lan_mode && m_lan_proto == LVL_None (x)
// !m_lan_mode && m_remote_support (go on)
// !m_lan_mode && !m_remote_support && m_lan_proto > LVL_None (use local tunnel)
// !m_lan_mode && !m_remote_support && m_lan_proto == LVL_Disable (*)
// !m_lan_mode && !m_remote_support && m_lan_proto == LVL_None (x)
// !m_lan_mode && m_remote_proto (go on)
// !m_lan_mode && !m_remote_proto && m_lan_proto > LVL_None (use local tunnel)
// !m_lan_mode && !m_remote_proto && m_lan_proto == LVL_Disable (*)
// !m_lan_mode && !m_remote_proto && m_lan_proto == LVL_None (x)
if (m_lan_proto <= MachineObject::LVL_Disable && (m_lan_mode || !m_remote_support)) {
if (m_lan_proto <= MachineObject::LVL_Disable && (m_lan_mode || !m_remote_proto)) {
Stop(m_lan_proto == MachineObject::LVL_None
? _L("Problem occurred. Please update the printer firmware and try again.")
: _L("LAN Only Liveview is off. Please turn on the liveview on printer screen."));
@ -300,8 +314,9 @@ void MediaPlayCtrl::Play()
m_disable_lan = false;
m_failed_code = 0;
m_last_state = MEDIASTATE_INITIALIZING;
if (!m_remote_support) { // not support tutk
m_button_play->SetIcon("media_stop");
if (!m_remote_proto) { // not support tutk
m_failed_code = -1;
m_url = "bambu:///local/";
Stop(_L("Please enter the IP of printer to connect."));
@ -312,12 +327,14 @@ void MediaPlayCtrl::Play()
SetStatus(_L("Initializing..."));
if (agent) {
agent->get_camera_url(m_machine,
std::string protocols[] = {"", "\"tutk\"", "\"agora\"", "\"tutk\",\"agora\""};
agent->get_camera_url(m_machine + "|" + m_dev_ver + "|" + protocols[m_remote_proto],
[this, m = m_machine, v = agent_version, dv = m_dev_ver](std::string url) {
if (boost::algorithm::starts_with(url, "bambu:///")) {
url += "&device=" + into_u8(m);
url += "&net_ver=" + v;
url += "&dev_ver=" + dv;
url += "&refresh_url=" + boost::lexical_cast<std::string>(&refresh_agora_url);
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
url += "&cli_ver=" + std::string(SLIC3R_VERSION);
}
@ -331,7 +348,7 @@ void MediaPlayCtrl::Play()
if (m_last_state == MEDIASTATE_INITIALIZING) {
if (url.empty() || !boost::algorithm::starts_with(url, "bambu:///")) {
m_failed_code = 3;
Stop(_L("Connection Failed. Please check the network and try again"));
Stop(_L("Connection Failed. Please check the network and try again"), from_u8(url));
} else {
m_url = url;
load();
@ -346,7 +363,7 @@ void MediaPlayCtrl::Play()
void start_ping_test();
void MediaPlayCtrl::Stop(wxString const &msg)
void MediaPlayCtrl::Stop(wxString const &msg, wxString const &msg2)
{
int last_state = m_last_state;
@ -375,7 +392,7 @@ void MediaPlayCtrl::Stop(wxString const &msg)
#endif
SetStatus(msg2);
} else
SetStatus(_L("Stopped."), false);
SetStatus(_L("Video Stopped."), false);
m_last_state = MEDIASTATE_IDLE;
bool auto_retry = wxGetApp().app_config->get("liveview", "auto_retry") != "false";
if (!auto_retry || m_failed_code >= 100 || m_failed_code == 1) // not keep retry on local error or EOS
@ -493,7 +510,7 @@ void MediaPlayCtrl::ToggleStream()
wxGetApp().app_config->set("not_show_vcamera_stop_prev", "1");
if (res == wxID_CANCEL) return;
}
if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_support) && !m_disable_lan && !m_lan_ip.empty()) {
if (m_lan_proto > MachineObject::LVL_Disable && (m_lan_mode || !m_remote_proto) && !m_disable_lan && !m_lan_ip.empty()) {
std::string url;
if (m_lan_proto == MachineObject::LVL_Local)
url = "bambu:///local/" + m_lan_ip + ".?port=6000&user=" + m_lan_user + "&passwd=" + m_lan_passwd;
@ -519,6 +536,7 @@ void MediaPlayCtrl::ToggleStream()
url += "&device=" + m;
url += "&net_ver=" + v;
url += "&dev_ver=" + dv;
url += "&refresh_url=" + boost::lexical_cast<std::string>(&refresh_agora_url);
url += "&cli_id=" + wxGetApp().app_config->get("slicer_uuid");
url += "&cli_ver=" + std::string(SLIC3R_VERSION);
}

View file

@ -49,7 +49,7 @@ protected:
void Play();
void Stop(wxString const &msg = {});
void Stop(wxString const &msg = {}, wxString const &msg2 = {});
void TogglePlay();
@ -83,7 +83,7 @@ private:
std::string m_tutk_state;
bool m_camera_exists = false;
bool m_lan_mode = false;
bool m_remote_support = false;
int m_remote_proto = 0;
bool m_device_busy = false;
bool m_disable_lan = false;
wxString m_url;

View file

@ -638,7 +638,7 @@ wxBoxSizer *Newer3mfVersionDialog::get_btn_sizer()
}
});
}
if (!file_version_newer) {
m_later_btn = new Button(this, _L("Not for now"));
m_later_btn->SetBackgroundColor(btn_bg_white);
@ -660,6 +660,109 @@ wxBoxSizer *Newer3mfVersionDialog::get_btn_sizer()
return horizontal_sizer;
}
NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent)
: DPIDialog(parent ? parent : nullptr, wxID_ANY, _L("Server Exception"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
{
this->SetBackgroundColour(*wxWHITE);
std::string icon_path = (boost::format("%1%/images/BambuStudioTitle.ico") % resources_dir()).str();
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
wxBoxSizer* sizer_main = new wxBoxSizer(wxVERTICAL);
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
wxBoxSizer* sizer_bacis_text = new wxBoxSizer(wxVERTICAL);
m_text_basic = new Label(this, _L("The server is unable to respond. Please click the link below to check the server status."));
m_text_basic->SetForegroundColour(0x323A3C);
m_text_basic->SetMinSize(wxSize(FromDIP(470), -1));
m_text_basic->SetMaxSize(wxSize(FromDIP(470), -1));
m_text_basic->Wrap(FromDIP(470));
m_text_basic->SetFont(::Label::Body_14);
sizer_bacis_text->Add(m_text_basic, 0, wxALL, 0);
wxBoxSizer* sizer_link = new wxBoxSizer(wxVERTICAL);
m_link_server_state = new wxHyperlinkCtrl(this, wxID_ANY, _L("Check the status of current system services"), "");
m_link_server_state->SetFont(::Label::Body_13);
m_link_server_state->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_network_check(); });
m_link_server_state->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); });
m_link_server_state->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); });
sizer_link->Add(m_link_server_state, 0, wxALL, 0);
wxBoxSizer* sizer_help = new wxBoxSizer(wxVERTICAL);
m_text_proposal = new Label(this, _L("If the server is in a fault state, you can temporarily use offline printing or local network printing."));
m_text_proposal->SetMinSize(wxSize(FromDIP(470), -1));
m_text_proposal->SetMaxSize(wxSize(FromDIP(470), -1));
m_text_proposal->Wrap(FromDIP(470));
m_text_proposal->SetFont(::Label::Body_14);
m_text_proposal->SetForegroundColour(0x323A3C);
m_text_wiki = new wxHyperlinkCtrl(this, wxID_ANY, _L("How to use LAN only mode"), "");
m_text_wiki->SetFont(::Label::Body_13);
m_text_wiki->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {wxGetApp().link_to_lan_only_wiki(); });
m_text_wiki->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_HAND); });
m_text_wiki->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) {SetCursor(wxCURSOR_ARROW); });
sizer_help->Add(m_text_proposal, 0, wxEXPAND, 0);
sizer_help->Add(m_text_wiki, 0, wxALL, 0);
wxBoxSizer* sizer_button = new wxBoxSizer(wxHORIZONTAL);
/*dont show again*/
auto checkbox = new ::CheckBox(this);
checkbox->SetValue(false);
auto checkbox_title = new Label(this, _L("Don't show this dialog again"));
checkbox_title->SetForegroundColour(0x323A3C);
checkbox_title->SetFont(::Label::Body_14);
checkbox_title->Wrap(-1);
checkbox->Bind(wxEVT_TOGGLEBUTTON, [this, checkbox](wxCommandEvent &e) {
m_show_again = checkbox->GetValue();
e.Skip();
});
auto bt_enable = StateColor(std::pair<wxColour, int>(wxColour(27, 136, 68), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(0, 174, 66), StateColor::Normal));
m_button_confirm = new Button(this, _L("Confirm"));
m_button_confirm->SetBackgroundColor(bt_enable);
m_button_confirm->SetBorderColor(bt_enable);
m_button_confirm->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
m_button_confirm->SetMinSize(wxSize(FromDIP(68), FromDIP(23)));
m_button_confirm->SetMinSize(wxSize(FromDIP(68), FromDIP(23)));
m_button_confirm->SetCornerRadius(12);
m_button_confirm->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {EndModal(wxCLOSE);});
sizer_button->Add(checkbox, 0, wxALL, 5);
sizer_button->Add(checkbox_title, 0, wxALL, 5);
sizer_button->Add(0, 0, 1, wxEXPAND, 5);
sizer_button->Add(m_button_confirm, 0, wxALL, 5);
sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
sizer_main->Add(0, 0, 0, wxTOP, 20);
sizer_main->Add(sizer_bacis_text, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
sizer_main->Add(0, 0, 0, wxTOP, 6);
sizer_main->Add(sizer_link, 0, wxLEFT | wxRIGHT, 15);
sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(20));
sizer_main->Add(sizer_help, 1, wxLEFT | wxRIGHT, 15);
sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(20));
sizer_main->Add(sizer_button, 1, wxEXPAND | wxLEFT | wxRIGHT, 15);
sizer_main->Add(0, 0, 0, wxTOP, 18);
SetSizer(sizer_main);
Layout();
sizer_main->Fit(this);
Centre(wxBOTH);
}
} // namespace GUI
} // namespace Slic3r

View file

@ -410,6 +410,25 @@ private:
wxStaticText *m_msg_text = nullptr;
};
class NetworkErrorDialog : public DPIDialog
{
public:
NetworkErrorDialog(wxWindow* parent);
~NetworkErrorDialog() {};
virtual void on_dpi_changed(const wxRect& suggested_rect) {};
private:
Label* m_text_basic;
wxHyperlinkCtrl* m_link_server_state;
Label* m_text_proposal;
wxHyperlinkCtrl* m_text_wiki;
Button * m_button_confirm;
public:
bool m_show_again{false};
};
}
}

View file

@ -1751,6 +1751,11 @@ void Sidebar::load_ams_list(std::string const &device, MachineObject* obj)
void Sidebar::sync_ams_list()
{
// Force load ams list
auto obj = wxGetApp().getDeviceManager()->get_selected_machine();
if (obj)
GUI::wxGetApp().sidebar().load_ams_list(obj->dev_id, obj);
auto & list = wxGetApp().preset_bundle->filament_ams_list;
if (list.empty()) {
MessageDialog dlg(this,

View file

@ -1239,6 +1239,8 @@ void PrinterFileSystem::Reconnect(boost::unique_lock<boost::mutex> &l, int resul
if (c) c(result, r, nullptr);
}
m_messages.clear();
if (result)
m_cond.timed_wait(l, boost::posix_time::seconds(10));
while (true) {
while (m_stopped) {
if (m_session.owner == nullptr)

View file

@ -36,11 +36,13 @@ wxDEFINE_EVENT(EVT_CHECKBOX_CHANGE, wxCommandEvent);
wxDEFINE_EVENT(EVT_ENTER_IP_ADDRESS, wxCommandEvent);
wxDEFINE_EVENT(EVT_CLOSE_IPADDRESS_DLG, wxCommandEvent);
wxDEFINE_EVENT(EVT_CHECK_IP_ADDRESS_FAILED, wxCommandEvent);
wxDEFINE_EVENT(EVT_CHECK_IP_ADDRESS_LAYOUT, wxCommandEvent);
wxDEFINE_EVENT(EVT_SECONDARY_CHECK_RETRY, wxCommandEvent);
wxDEFINE_EVENT(EVT_PRINT_ERROR_STOP, wxCommandEvent);
wxDEFINE_EVENT(EVT_UPDATE_NOZZLE, wxCommandEvent);
wxDEFINE_EVENT(EVT_JUMP_TO_HMS, wxCommandEvent);
wxDEFINE_EVENT(EVT_JUMP_TO_LIVEVIEW, wxCommandEvent);
wxDEFINE_EVENT(EVT_UPDATE_TEXT_MSG, wxCommandEvent);
ReleaseNoteDialog::ReleaseNoteDialog(Plater *plater /*= nullptr*/)
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, _L("Release Note"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
@ -896,7 +898,7 @@ PrintErrorDialog::PrintErrorDialog(wxWindow* parent, wxWindowID id, const wxStri
bottom_sizer->Add(m_sizer_button, 0, wxEXPAND | wxRIGHT | wxLEFT, 0);
m_sizer_right->Add(bottom_sizer, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(15));
m_sizer_right->Add(bottom_sizer, 0, wxEXPAND | wxRIGHT | wxLEFT, FromDIP(20));
m_sizer_right->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_main->Add(m_sizer_right, 0, wxBOTTOM | wxEXPAND, FromDIP(5));
@ -952,20 +954,34 @@ void PrintErrorDialog::on_webrequest_state(wxWebRequestEvent& evt)
}
}
void PrintErrorDialog::update_text_image(wxString text, wxString image_url)
void PrintErrorDialog::update_text_image(const wxString& text, const wxString& error_code, const wxString& image_url)
{
//if (!m_sizer_text_release_note) {
// m_sizer_text_release_note = new wxBoxSizer(wxVERTICAL);
//}
wxBoxSizer* sizer_text_release_note = new wxBoxSizer(wxVERTICAL);
wxString error_code_msg = error_code;
if (!error_code.IsEmpty()) {
wxDateTime now = wxDateTime::Now();
wxString show_time = now.Format("%H%M%d");
error_code_msg = wxString::Format("[%S %S]", error_code, show_time);
}
if (!m_staticText_release_note) {
m_staticText_release_note = new Label(m_vebview_release_note, text, LB_AUTO_WRAP);
sizer_text_release_note->Add(m_error_prompt_pic_static, 0, wxALIGN_CENTER, FromDIP(5));
sizer_text_release_note->AddSpacer(10);
sizer_text_release_note->Add(m_staticText_release_note, 0, wxALIGN_CENTER , FromDIP(5));
m_vebview_release_note->SetSizer(sizer_text_release_note);
}
if (!m_staticText_error_code) {
m_staticText_error_code = new Label(m_vebview_release_note, error_code_msg, LB_AUTO_WRAP);
sizer_text_release_note->AddSpacer(5);
sizer_text_release_note->Add(m_staticText_error_code, 0, wxALIGN_CENTER, FromDIP(5));
}
m_vebview_release_note->SetSizer(sizer_text_release_note);
if (!image_url.empty()) {
web_request = wxWebSession::GetDefault().CreateRequest(this, image_url);
BOOST_LOG_TRIVIAL(trace) << "monitor: create new webrequest, state = " << web_request.GetState() << ", url = " << image_url;
@ -982,6 +998,9 @@ void PrintErrorDialog::update_text_image(wxString text, wxString image_url)
m_staticText_release_note->SetMaxSize(wxSize(FromDIP(300), -1));
m_staticText_release_note->SetMinSize(wxSize(FromDIP(300), -1));
m_staticText_release_note->SetLabelText(text);
m_staticText_error_code->SetMaxSize(wxSize(FromDIP(300), -1));
m_staticText_error_code->SetMinSize(wxSize(FromDIP(300), -1));
m_staticText_error_code->SetLabelText(error_code_msg);
m_vebview_release_note->Layout();
auto text_size = m_staticText_release_note->GetBestSize();
@ -1048,7 +1067,8 @@ void PrintErrorDialog::update_title_style(wxString title, std::vector<int> butto
}
void PrintErrorDialog::init_button(PrintErrorButton style,wxString buton_text) {
void PrintErrorDialog::init_button(PrintErrorButton style,wxString buton_text)
{
Button* print_error_button = new Button(this, buton_text);
print_error_button->SetBackgroundColor(btn_bg_white);
print_error_button->SetBorderColor(wxColour(38, 46, 48));
@ -1062,8 +1082,8 @@ void PrintErrorDialog::init_button(PrintErrorButton style,wxString buton_text) {
}
void PrintErrorDialog::init_button_list() {
void PrintErrorDialog::init_button_list()
{
init_button(RESUME_PRINTING, _L("Resume Printing"));
m_button_list[RESUME_PRINTING]->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
post_event(wxCommandEvent(EVT_SECONDARY_CHECK_RESUME));
@ -1436,55 +1456,71 @@ void ConfirmBeforeSendDialog::rescale()
m_button_cancel->Rescale();
}
InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
:DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, _L("LAN Connection Failed (Sending print file)"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
InputIpAddressDialog::InputIpAddressDialog(wxWindow *parent)
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe),
wxID_ANY,
_L("Connect the printer using IP and access code"),
wxDefaultPosition,
wxDefaultSize,
wxCAPTION | wxCLOSE_BOX)
{
std::string icon_path = (boost::format("%1%/images/OrcaSlicerTitle.ico") % resources_dir()).str();
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
SetBackgroundColour(*wxWHITE);
m_result = -1;
wxBoxSizer* m_sizer_body = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* m_sizer_main = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* m_sizer_main_left = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* m_sizer_main_right = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* m_sizer_msg = new wxBoxSizer(wxHORIZONTAL);
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
m_result = -1;
wxBoxSizer *m_sizer_body = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *m_sizer_main = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *m_sizer_main_left = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *m_sizer_main_right = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *m_sizer_msg = new wxBoxSizer(wxHORIZONTAL);
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
m_line_top->SetBackgroundColour(wxColour(166, 169, 170));
comfirm_before_enter_text = _L("Step 1, please confirm Orca Slicer and your printer are in the same LAN.");
comfirm_after_enter_text = _L("Step 2, if the IP and Access Code below are different from the actual values on your printer, please correct them.");
comfirm_before_enter_text = _L("Step 1. Please confirm Orca Slicer and your printer are in the same LAN.");
comfirm_after_enter_text = _L("Step 2. If the IP and Access Code below are different from the actual values on your printer, please correct them.");
comfirm_last_enter_text = _L("Step 3. Please obtain the device SN from the printer side; it is usually found in the device information on the printer screen.");
m_tip1 = new Label(this, ::Label::Body_13, comfirm_before_enter_text, LB_AUTO_WRAP);
m_tip1->SetMinSize(wxSize(FromDIP(352), -1));
m_tip1->SetMaxSize(wxSize(FromDIP(352), -1));
m_tip1->Wrap(FromDIP(352));
auto m_line_tips = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
m_line_tips->SetBackgroundColour(wxColour(0xEEEEEE));
m_tip2 = new Label(this, ::Label::Body_13, comfirm_after_enter_text, LB_AUTO_WRAP);
m_tip2->SetMinSize(wxSize(FromDIP(352), -1));
m_tip2->SetMaxSize(wxSize(FromDIP(352), -1));
auto m_input_tip_area = new wxBoxSizer(wxHORIZONTAL);
auto m_input_area = new wxBoxSizer(wxHORIZONTAL);
m_tip3 = new Label(this, ::Label::Body_13, comfirm_last_enter_text, LB_AUTO_WRAP);
m_tip3->SetMinSize(wxSize(FromDIP(352), -1));
m_tip3->SetMaxSize(wxSize(FromDIP(352), -1));
m_tips_ip = new Label(this, _L("IP"));
ip_input_top_panel = new wxPanel(this);
ip_input_bot_panel = new wxPanel(this);
ip_input_top_panel->SetBackgroundColour(*wxWHITE);
ip_input_bot_panel->SetBackgroundColour(*wxWHITE);
auto m_input_top_sizer = new wxBoxSizer(wxVERTICAL);
auto m_input_bot_sizer = new wxBoxSizer(wxVERTICAL);
/*top input*/
auto m_input_tip_area = new wxBoxSizer(wxHORIZONTAL);
auto m_input_area = new wxBoxSizer(wxHORIZONTAL);
m_tips_ip = new Label(ip_input_top_panel, _L("IP"));
m_tips_ip->SetMinSize(wxSize(FromDIP(168), -1));
m_tips_ip->SetMaxSize(wxSize(FromDIP(168), -1));
m_input_ip = new TextInput(this, wxEmptyString, wxEmptyString);
m_input_ip = new TextInput(ip_input_top_panel, wxEmptyString, wxEmptyString);
m_input_ip->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this);
m_input_ip->SetMinSize(wxSize(FromDIP(168), FromDIP(28)));
m_input_ip->SetMaxSize(wxSize(FromDIP(168), FromDIP(28)));
m_tips_access_code = new Label(this, _L("Access Code"));
m_tips_access_code->SetMinSize(wxSize(FromDIP(168),-1));
m_tips_access_code->SetMaxSize(wxSize(FromDIP(168),-1));
m_tips_access_code = new Label(ip_input_top_panel, _L("Access Code"));
m_tips_access_code->SetMinSize(wxSize(FromDIP(168), -1));
m_tips_access_code->SetMaxSize(wxSize(FromDIP(168), -1));
m_input_access_code = new TextInput(this, wxEmptyString, wxEmptyString);
m_input_access_code = new TextInput(ip_input_top_panel, wxEmptyString, wxEmptyString);
m_input_access_code->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this);
m_input_access_code->SetMinSize(wxSize(FromDIP(168), FromDIP(28)));
m_input_access_code->SetMaxSize(wxSize(FromDIP(168), FromDIP(28)));
@ -1492,42 +1528,89 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
m_input_tip_area->Add(m_tips_ip, 0, wxALIGN_CENTER, 0);
m_input_tip_area->Add(0, 0, 0, wxLEFT, FromDIP(16));
m_input_tip_area->Add(m_tips_access_code, 0, wxALIGN_CENTER, 0);
m_input_area->Add(m_input_ip, 0, wxALIGN_CENTER, 0);
m_input_area->Add(0, 0, 0, wxLEFT, FromDIP(16));
m_input_area->Add(m_input_access_code, 0, wxALIGN_CENTER, 0);
m_input_top_sizer->Add(m_input_tip_area, 0, wxRIGHT | wxEXPAND, FromDIP(18));
m_input_top_sizer->Add(0, 0, 0, wxTOP, FromDIP(4));
m_input_top_sizer->Add(m_input_area, 0, wxRIGHT | wxEXPAND, FromDIP(18));
ip_input_top_panel->SetSizer(m_input_top_sizer);
ip_input_top_panel->Layout();
ip_input_top_panel->Fit();
/*bom input*/
auto m_input_sn_area = new wxBoxSizer(wxHORIZONTAL);
auto m_input_modelID_area = new wxBoxSizer(wxHORIZONTAL);
m_tips_sn = new Label(ip_input_bot_panel, "SN");
m_tips_sn->SetMinSize(wxSize(FromDIP(168), -1));
m_tips_sn->SetMaxSize(wxSize(FromDIP(168), -1));
m_input_sn = new TextInput(ip_input_bot_panel, wxEmptyString, wxEmptyString);
m_input_sn->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this);
m_input_sn->SetMinSize(wxSize(FromDIP(168), FromDIP(28)));
m_input_sn->SetMaxSize(wxSize(FromDIP(168), FromDIP(28)));
m_tips_modelID = new Label(ip_input_bot_panel, _L("Printer model"));
m_tips_modelID->SetMinSize(wxSize(FromDIP(168), -1));
m_tips_modelID->SetMaxSize(wxSize(FromDIP(168), -1));
m_input_modelID = new ComboBox(ip_input_bot_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(FromDIP(168), FromDIP(28)), 0, nullptr, wxCB_READONLY);
// m_input_modelID->Bind(wxEVT_TEXT, &InputIpAddressDialog::on_text, this);
m_input_modelID->SetMinSize(wxSize(FromDIP(168), FromDIP(28)));
m_input_modelID->SetMaxSize(wxSize(FromDIP(168), FromDIP(28)));
m_models_map = DeviceManager::get_all_model_id_with_name();
for (auto it = m_models_map.begin(); it != m_models_map.end(); ++it) {
m_input_modelID->Append(it->right);
m_input_modelID->SetSelection(0);
}
m_input_sn_area->Add(m_tips_sn, 0, wxALIGN_CENTER, 0);
m_input_sn_area->Add(0, 0, 0, wxLEFT, FromDIP(16));
m_input_sn_area->Add(m_tips_modelID, 0, wxALIGN_CENTER, 0);
m_input_modelID_area->Add(m_input_sn, 0, wxALIGN_CENTER, 0);
m_input_modelID_area->Add(0, 0, 0, wxLEFT, FromDIP(16));
m_input_modelID_area->Add(m_input_modelID, 0, wxALIGN_CENTER, 0);
m_input_bot_sizer->Add(m_input_sn_area, 0, wxRIGHT | wxEXPAND, FromDIP(18));
m_input_bot_sizer->Add(0, 0, 0, wxTOP, FromDIP(4));
m_input_bot_sizer->Add(m_input_modelID_area, 0, wxRIGHT | wxEXPAND, FromDIP(18));
ip_input_bot_panel->SetSizer(m_input_bot_sizer);
ip_input_bot_panel->Layout();
ip_input_bot_panel->Fit();
/*other*/
m_test_right_msg = new Label(this, Label::Body_13, wxEmptyString, LB_AUTO_WRAP);
m_test_right_msg->SetForegroundColour(wxColour(38, 166, 154));
m_test_right_msg->Hide();
m_test_wrong_msg = new Label(this, Label::Body_13, wxEmptyString, LB_AUTO_WRAP);
m_test_wrong_msg->SetForegroundColour(wxColour(208, 27, 27));
m_test_wrong_msg->Hide();
m_tip3 = new Label(this, Label::Body_12, _L("Where to find your printer's IP and Access Code?"), LB_AUTO_WRAP);
m_tip3->SetMinSize(wxSize(FromDIP(352), -1));
m_tip3->SetMaxSize(wxSize(FromDIP(352), -1));
m_tip4 = new Label(this, ::Label::Body_13, _L("Step 3: Ping the IP address to check for packet loss and latency."), LB_AUTO_WRAP);
m_tip4 = new Label(this, Label::Body_12, _L("Where to find your printer's IP and Access Code?"), LB_AUTO_WRAP);
m_tip4->SetMinSize(wxSize(FromDIP(352), -1));
m_tip4->SetMaxSize(wxSize(FromDIP(352), -1));
m_trouble_shoot = new wxHyperlinkCtrl(this, wxID_ANY, "How to trouble shooting", "");
m_img_help = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("input_access_code_x1_en", this, 198), wxDefaultPosition, wxSize(FromDIP(352), -1), 0);
auto m_sizer_button = new wxBoxSizer(wxHORIZONTAL);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Pressed), std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
StateColor btn_bg_white(std::pair<wxColour, int>(wxColour(206, 206, 206), StateColor::Pressed), std::pair<wxColour, int>(wxColour(238, 238, 238), StateColor::Hovered),
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
std::pair<wxColour, int>(*wxWHITE, StateColor::Normal));
m_button_ok = new Button(this, _L("Test"));
m_button_ok = new Button(this, _L("Connect"));
m_button_ok->SetBackgroundColor(btn_bg_green);
m_button_ok->SetBorderColor(*wxWHITE);
m_button_ok->SetTextColor(wxColour(0xFFFFFE));
@ -1535,11 +1618,12 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
m_button_ok->SetSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetMinSize(wxSize(FromDIP(58), FromDIP(24)));
m_button_ok->SetCornerRadius(FromDIP(12));
m_button_ok->Bind(wxEVT_LEFT_DOWN, &InputIpAddressDialog::on_ok, this);
m_button_ok->Enable(false);
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
auto m_button_cancel = new Button(this, _L("Close"));
/*auto m_button_cancel = new Button(this, _L("Close"));
m_button_cancel->SetBackgroundColor(btn_bg_white);
m_button_cancel->SetBorderColor(wxColour(38, 46, 48));
m_button_cancel->SetFont(Label::Body_12);
@ -1549,40 +1633,31 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
m_button_cancel->Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& e) {
on_cancel();
});
});*/
m_sizer_button->AddStretchSpacer();
//m_sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5));
m_sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
m_sizer_button->Add(m_button_ok, 0, wxALL, FromDIP(5));
// m_sizer_button->Add(m_button_cancel, 0, wxALL, FromDIP(5));
m_sizer_button->Layout();
m_status_bar = std::make_shared<BBLStatusBarSend>(this);
m_status_bar = std::make_shared<BBLStatusBarSend>(this);
m_status_bar->get_panel()->Hide();
m_worker = std::make_unique<PlaterWorker<BoostThreadWorker>>(this, m_status_bar, "send_worker");
auto m_step_icon_panel1 = new wxWindow(this, wxID_ANY);
auto m_step_icon_panel2 = new wxWindow(this, wxID_ANY);
m_step_icon_panel3 = new wxWindow(this, wxID_ANY);
m_step_icon_panel1->SetBackgroundColour(*wxWHITE);
m_step_icon_panel2->SetBackgroundColour(*wxWHITE);
m_step_icon_panel3->SetBackgroundColour(*wxWHITE);
auto m_sizer_step_icon_panel1 = new wxBoxSizer(wxVERTICAL);
auto m_sizer_step_icon_panel2 = new wxBoxSizer(wxVERTICAL);
auto m_sizer_step_icon_panel3 = new wxBoxSizer(wxVERTICAL);
m_img_step1 = new wxStaticBitmap(m_step_icon_panel1, wxID_ANY, create_scaled_bitmap("ip_address_step", this, 6), wxDefaultPosition, wxSize(FromDIP(6), FromDIP(6)), 0);
auto m_line_tips_left = new wxPanel(m_step_icon_panel1, wxID_ANY, wxDefaultPosition, wxSize(-1, 1));
m_line_tips_left->SetBackgroundColour(wxColour(0xEEEEEE));
m_img_step2 = new wxStaticBitmap(m_step_icon_panel2, wxID_ANY, create_scaled_bitmap("ip_address_step", this, 6), wxDefaultPosition, wxSize(FromDIP(6), FromDIP(6)), 0);
m_img_step3 = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("ip_address_step", this, 6), wxDefaultPosition, wxSize(FromDIP(6), FromDIP(6)), 0);
m_sizer_step_icon_panel1->Add(m_img_step1, 0, wxALIGN_CENTER|wxALL, FromDIP(5));
m_img_step3 = new wxStaticBitmap(m_step_icon_panel3, wxID_ANY, create_scaled_bitmap("ip_address_step", this, 6), wxDefaultPosition, wxSize(FromDIP(6), FromDIP(6)), 0);
m_step_icon_panel1->SetSizer(m_sizer_step_icon_panel1);
m_step_icon_panel1->Layout();
@ -1592,52 +1667,52 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
m_step_icon_panel2->Layout();
m_step_icon_panel2->Fit();
m_step_icon_panel3->SetSizer(m_sizer_step_icon_panel3);
m_step_icon_panel3->Layout();
m_step_icon_panel3->Fit();
m_sizer_step_icon_panel2->Add(m_img_step2, 0, wxALIGN_CENTER|wxALL, FromDIP(5));
//m_sizer_step_icon_panel3->Add(m_img_step3, 0, wxALIGN_CENTER|wxALL, FromDIP(5));
m_sizer_step_icon_panel1->Add(m_img_step1, 0, wxALIGN_CENTER | wxALL, FromDIP(5));
m_sizer_step_icon_panel2->Add(m_img_step2, 0, wxALIGN_CENTER | wxALL, FromDIP(5));
m_sizer_step_icon_panel3->Add(m_img_step3, 0, wxALIGN_CENTER | wxALL, FromDIP(5));
m_step_icon_panel1->SetMinSize(wxSize(-1, m_tip1->GetBestSize().y));
m_step_icon_panel1->SetMaxSize(wxSize(-1, m_tip1->GetBestSize().y));
m_sizer_msg->Add(0, 0, 0, wxALIGN_CENTER, FromDIP(20));
m_sizer_msg->Add(m_img_step3, 0, wxALL, FromDIP(5));
m_sizer_msg->Add(0, 0, 0, wxALIGN_CENTER, FromDIP(8));
m_sizer_msg->Add(m_tip4, 0, wxALIGN_CENTER | wxEXPAND | wxLEFT, FromDIP(5));
m_img_step3->Hide();
m_tip4->Hide();
m_step_icon_panel2->SetMinSize(wxSize(-1, m_tip2->GetBestSize().y));
m_step_icon_panel2->SetMaxSize(wxSize(-1, m_tip2->GetBestSize().y));
m_sizer_msg->Layout();
m_sizer_main_left->Add(m_step_icon_panel1, 0, wxEXPAND, 0);
m_sizer_main_left->Add(0, 0, 0, wxTOP, FromDIP(20));
m_sizer_main_left->Add(m_line_tips_left, 1, wxEXPAND, 0);
m_sizer_main_left->Add(0, 0, 0, wxTOP, FromDIP(20));
m_sizer_main_left->Add(m_step_icon_panel2, 0, wxEXPAND, 0);
m_sizer_main_left->Add(0, 0, 0, wxTOP, FromDIP(20));
m_sizer_main_left->Add(m_step_icon_panel3, 0, wxEXPAND, 0);
m_sizer_main_left->Layout();
m_trouble_shoot->Hide();
m_sizer_main_right->Add(m_tip1, 0, wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(m_tip1, 0, wxRIGHT | wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(20));
m_sizer_main_right->Add(m_line_tips, 0, wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(20));
m_sizer_main_right->Add(m_tip2, 0, wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(m_tip2, 0, wxRIGHT | wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(2));
m_sizer_main_right->Add(m_tip3, 0, wxTOP|wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(12));
m_sizer_main_right->Add(m_tip3, 0, wxRIGHT | wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4));
m_sizer_main_right->Add(m_tip4, 0, wxRIGHT | wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(3));
m_sizer_main_right->Add(m_img_help, 0, 0, 0);
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(12));
m_sizer_main_right->Add(m_input_tip_area, 0, wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(ip_input_top_panel, 0, wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(ip_input_bot_panel, 0, wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4));
m_sizer_main_right->Add(m_input_area, 0, wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4));
m_sizer_main_right->Add(m_button_ok, 0, wxRIGHT, FromDIP(18));
//m_sizer_main_right->Add(m_button_ok, 0, wxRIGHT, FromDIP(18));
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4));
m_sizer_main_right->Add(m_test_right_msg, 0, wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(m_test_wrong_msg, 0, wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(16));
m_sizer_main_right->Add(0, 0, 0, wxTOP, FromDIP(4));
m_sizer_main_right->Add(m_status_bar->get_panel(), 0,wxRIGHT|wxEXPAND, FromDIP(18));
m_sizer_main_right->Layout();
@ -1646,17 +1721,19 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
m_sizer_main->Layout();
m_sizer_body->Add(m_line_top, 0, wxEXPAND, 0);
m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(20));
m_sizer_body->Add(m_sizer_main, 0, wxEXPAND, 0);
m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_body->Add(m_sizer_main, 0, wxRIGHT, FromDIP(10));
m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(4));
m_sizer_body->Add(m_sizer_msg, 0, wxLEFT|wxEXPAND, FromDIP(18));
m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(4));
m_sizer_body->Add(m_trouble_shoot, 0, wxLEFT | wxRIGHT | wxEXPAND, FromDIP(40));
m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(8));
m_sizer_body->Add(m_sizer_button, 0, wxRIGHT | wxEXPAND, FromDIP(25));
m_sizer_body->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_body->Layout();
switch_input_panel(0);
SetSizer(m_sizer_body);
Layout();
Fit();
@ -1665,24 +1742,60 @@ InputIpAddressDialog::InputIpAddressDialog(wxWindow* parent)
Move(wxPoint(GetScreenPosition().x, GetScreenPosition().y - FromDIP(50)));
wxGetApp().UpdateDlgDarkUI(this);
Bind(EVT_CHECK_IP_ADDRESS_FAILED, &InputIpAddressDialog::on_check_ip_address_failed, this);
closeTimer = new wxTimer();
closeTimer->SetOwner(this);
Bind(wxEVT_TIMER, &InputIpAddressDialog::OnTimer, this);
//Bind(EVT_CHECK_IP_ADDRESS_FAILED, &InputIpAddressDialog::on_check_ip_address_failed, this);
Bind(EVT_CLOSE_IPADDRESS_DLG, [this](auto& e) {
m_status_bar->reset();
EndModal(wxID_YES);
});
Bind(wxEVT_CLOSE_WINDOW, [this](auto& e) {on_cancel();});
Bind(wxEVT_CLOSE_WINDOW, [this](auto& e) {
on_cancel();
closeTimer->Stop();
});
Bind(EVT_UPDATE_TEXT_MSG, &InputIpAddressDialog::update_test_msg_event, this);
Bind(EVT_CHECK_IP_ADDRESS_LAYOUT, [this](auto& e) {
int mode = e.GetInt();
switch_input_panel(mode);
Layout();
Fit();
});
}
void InputIpAddressDialog::switch_input_panel(int index)
{
if (index == 0) {
ip_input_top_panel->Show();
ip_input_bot_panel->Hide();
m_step_icon_panel3->Hide();
m_tip3->Hide();
} else {
ip_input_top_panel->Hide();
ip_input_bot_panel->Show();
m_step_icon_panel3->Show();
m_tip3->Show();
m_button_ok->Enable(false);
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
}
current_input_index = index;
}
void InputIpAddressDialog::on_cancel()
{
m_worker->cancel_all();
if (m_result == 0){
this->EndModal(wxID_YES);
}else {
this->EndModal(wxID_CANCEL);
if (m_thread) {
m_thread->interrupt();
m_thread->detach();
delete m_thread;
m_thread = nullptr;
}
EndModal(wxID_CANCEL);
}
@ -1739,9 +1852,7 @@ void InputIpAddressDialog::update_test_msg(wxString msg,bool connected)
m_test_wrong_msg->SetLabelText(msg);
m_test_wrong_msg->SetMinSize(wxSize(FromDIP(352), -1));
m_test_wrong_msg->SetMaxSize(wxSize(FromDIP(352), -1));
}
}
}
Layout();
@ -1768,79 +1879,127 @@ void InputIpAddressDialog::on_ok(wxMouseEvent& evt)
{
m_test_right_msg->Hide();
m_test_wrong_msg->Hide();
m_img_step3->Hide();
m_tip4->Hide();
m_trouble_shoot->Hide();
Layout();
Fit();
wxString ip = m_input_ip->GetTextCtrl()->GetValue();
wxString str_access_code = m_input_access_code->GetTextCtrl()->GetValue();
std::string str_ip = m_input_ip->GetTextCtrl()->GetValue().ToStdString();
std::string str_access_code = m_input_access_code->GetTextCtrl()->GetValue().ToStdString();
std::string str_sn = m_input_sn->GetTextCtrl()->GetValue().ToStdString();
std::string str_model_id = "";
//check support function
if (!m_obj) return;
if (!m_obj->is_support_send_to_sdcard) {
wxString input_str = wxString::Format("%s|%s", ip, str_access_code);
auto event = wxCommandEvent(EVT_ENTER_IP_ADDRESS);
event.SetString(input_str);
event.SetEventObject(this);
wxPostEvent(this, event);
auto event_close = wxCommandEvent(EVT_CLOSE_IPADDRESS_DLG);
event_close.SetEventObject(this);
wxPostEvent(this, event_close);
return;
auto it = m_models_map.right.find(m_input_modelID->GetStringSelection().ToStdString());
if (it != m_models_map.right.end()) {
str_model_id = it->get_left();
}
m_button_ok->Enable(false);
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
m_worker->wait_for_idle();
Refresh();
Layout();
Fit();
m_thread = new boost::thread(boost::bind(&InputIpAddressDialog::workerThreadFunc, this, str_ip, str_access_code, str_sn, str_model_id));
}
m_status_bar->reset();
m_status_bar->set_prog_block();
m_status_bar->set_cancel_callback_fina([this]() {
BOOST_LOG_TRIVIAL(info) << "print_job: enter canceled";
m_worker->cancel_all();
});
void InputIpAddressDialog::update_test_msg_event(wxCommandEvent& evt)
{
wxString text = evt.GetString();
bool beconnect = evt.GetInt();
update_test_msg(text, beconnect);
Layout();
Fit();
}
void InputIpAddressDialog::post_update_test_msg(wxString text, bool beconnect)
{
wxCommandEvent event(EVT_UPDATE_TEXT_MSG);
event.SetEventObject(this);
event.SetString(text);
event.SetInt(beconnect);
wxPostEvent(this, event);
}
auto m_send_job = std::make_unique<SendJob>(m_obj->dev_id);
m_send_job->m_dev_ip = ip.ToStdString();
m_send_job->m_access_code = str_access_code.ToStdString();
void InputIpAddressDialog::workerThreadFunc(std::string str_ip, std::string str_access_code, std::string sn, std::string model_id)
{
post_update_test_msg(_L("connecting..."), true);
detectResult detectData;
auto result = -1;
if (current_input_index == 0) {
#if !BBL_RELEASE_TO_PUBLIC
m_send_job->m_local_use_ssl_for_mqtt = wxGetApp().app_config->get("enable_ssl_for_mqtt") == "true" ? true : false;
m_send_job->m_local_use_ssl_for_ftp = wxGetApp().app_config->get("enable_ssl_for_ftp") == "true" ? true : false;
#ifdef __APPLE__
result = -3;
#else
m_send_job->m_local_use_ssl_for_mqtt = m_obj->local_use_ssl_for_mqtt;
m_send_job->m_local_use_ssl_for_ftp = m_obj->local_use_ssl_for_ftp;
result = wxGetApp().getAgent()->bind_detect(str_ip, "secure", detectData);
#endif
m_send_job->connection_type = m_obj->connection_type();
m_send_job->cloud_print_only = true;
m_send_job->has_sdcard = m_obj->has_sdcard();
m_send_job->set_check_mode();
m_send_job->set_project_name("verify_job");
} else {
result = 0;
detectData.dev_name = sn;
detectData.dev_id = sn;
detectData.connect_type = "lan";
detectData.connect_type = "free";
}
m_send_job->on_check_ip_address_fail([this](int result) {
this->check_ip_address_failed(result);
});
if (result < 0) {
post_update_test_msg(wxEmptyString, true);
if (result == -1) {
post_update_test_msg(_L("Failed to connect to printer."), false);
}
else if (result == -2) {
post_update_test_msg(_L("Failed to publish login request."), false);
}
else if (result == -3) {
wxCommandEvent event(EVT_CHECK_IP_ADDRESS_LAYOUT);
event.SetEventObject(this);
event.SetInt(1);
wxPostEvent(this, event);
}
return;
}
m_send_job->on_check_ip_address_success([this, ip, str_access_code]() {
wxString input_str = wxString::Format("%s|%s", ip, str_access_code);
auto event = wxCommandEvent(EVT_ENTER_IP_ADDRESS);
event.SetString(input_str);
event.SetEventObject(this);
wxPostEvent(this, event);
m_result = 0;
update_test_msg(_L("IP and Access Code Verified! You may close the window"), true);
});
if (detectData.bind_state == "occupied") {
post_update_test_msg(wxEmptyString, true);
post_update_test_msg(_L("The printer has already been bound."), false);
return;
}
replace_job(*m_worker, std::move(m_send_job));
if (detectData.connect_type == "cloud") {
post_update_test_msg(wxEmptyString, true);
post_update_test_msg(_L("The printer mode is incorrect, please switch to LAN Only."), false);
return;
}
DeviceManager* dev = wxGetApp().getDeviceManager();
m_obj = dev->insert_local_device(detectData.dev_name, detectData.dev_id, str_ip, detectData.connect_type, detectData.bind_state, detectData.version, str_access_code);
if (m_obj) {
m_obj->set_user_access_code(str_access_code);
wxGetApp().getDeviceManager()->set_selected_machine(m_obj->dev_id);
}
closeCount = 1;
post_update_test_msg(wxEmptyString, true);
post_update_test_msg(wxString::Format(_L("Connecting to printer... The dialog will close later"), closeCount), true);
#ifdef __APPLE__
wxCommandEvent event(EVT_CLOSE_IPADDRESS_DLG);
wxPostEvent(this, event);
#else
closeTimer->Start(1000);
#endif
}
void InputIpAddressDialog::OnTimer(wxTimerEvent& event) {
if (closeCount > 0) {
closeCount--;
}
else {
closeTimer->Stop();
EndModal(wxID_CLOSE);
}
}
void InputIpAddressDialog::check_ip_address_failed(int result)
@ -1858,9 +2017,6 @@ void InputIpAddressDialog::on_check_ip_address_failed(wxCommandEvent& evt)
}
else {
update_test_msg(_L("Connection failed! If your IP and Access Code is correct, \nplease move to step 3 for troubleshooting network issues"), false);
m_img_step3->Show();
m_tip4->Show();
//m_trouble_shoot->Show();
Layout();
Fit();
}
@ -1872,23 +2028,45 @@ void InputIpAddressDialog::on_check_ip_address_failed(wxCommandEvent& evt)
m_button_ok->SetBackgroundColor(btn_bg_green);
}
void InputIpAddressDialog::on_text(wxCommandEvent& evt)
void InputIpAddressDialog::on_text(wxCommandEvent &evt)
{
auto str_ip = m_input_ip->GetTextCtrl()->GetValue();
auto str_access_code = m_input_access_code->GetTextCtrl()->GetValue();
auto str_ip = m_input_ip->GetTextCtrl()->GetValue();
auto str_access_code = m_input_access_code->GetTextCtrl()->GetValue();
auto str_sn = m_input_sn->GetTextCtrl()->GetValue();
bool invalid_access_code = true;
if (isIp(str_ip.ToStdString()) && str_access_code.Length() == 8) {
for (char c : str_access_code) {
if (!('0' <= c && c <= '9' || 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z')) {
invalid_access_code = false;
return;
}
}
if (isIp(str_ip.ToStdString()) && str_access_code.Length() == 8 && invalid_access_code) {
m_button_ok->Enable(true);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed), std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
m_button_ok->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
m_button_ok->SetBackgroundColor(btn_bg_green);
}
else {
} else {
m_button_ok->Enable(false);
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
}
if (current_input_index == 1){
if (str_sn.length() == 15) {
m_button_ok->Enable(true);
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Pressed), std::pair<wxColour, int>(wxColour(61, 203, 115), StateColor::Hovered),
std::pair<wxColour, int>(AMS_CONTROL_BRAND_COLOUR, StateColor::Normal));
m_button_ok->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
m_button_ok->SetBackgroundColor(btn_bg_green);
} else {
m_button_ok->Enable(false);
m_button_ok->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
m_button_ok->SetBorderColor(wxColour(0x90, 0x90, 0x90));
}
}
}
InputIpAddressDialog::~InputIpAddressDialog()

View file

@ -38,8 +38,6 @@
#include <wx/hashmap.h>
#include <wx/webview.h>
#include "Jobs/Worker.hpp"
namespace Slic3r { namespace GUI {
wxDECLARE_EVENT(EVT_SECONDARY_CHECK_CONFIRM, wxCommandEvent);
@ -52,6 +50,7 @@ wxDECLARE_EVENT(EVT_UPDATE_NOZZLE, wxCommandEvent);
wxDECLARE_EVENT(EVT_LOAD_VAMS_TRAY, wxCommandEvent);
wxDECLARE_EVENT(EVT_JUMP_TO_HMS, wxCommandEvent);
wxDECLARE_EVENT(EVT_JUMP_TO_LIVEVIEW, wxCommandEvent);
wxDECLARE_EVENT(EVT_UPDATE_TEXT_MSG, wxCommandEvent);
class ReleaseNoteDialog : public DPIDialog
{
@ -191,7 +190,7 @@ public:
const wxSize& size = wxDefaultSize,
long style = wxCLOSE_BOX | wxCAPTION
);
void update_text_image(wxString text, wxString image_url);
void update_text_image(const wxString& text, const wxString& error_code,const wxString& image_url);
void on_show();
void on_hide();
void update_title_style(wxString title, std::vector<int> style, wxWindow* parent = nullptr);
@ -208,6 +207,7 @@ public:
wxWebRequest web_request;
wxStaticBitmap* m_error_prompt_pic_static;
Label* m_staticText_release_note{ nullptr };
Label* m_staticText_error_code{ nullptr };
wxBoxSizer* m_sizer_main;
wxBoxSizer* m_sizer_button;
wxScrolledWindow* m_vebview_release_note{ nullptr };
@ -276,8 +276,12 @@ class InputIpAddressDialog : public DPIDialog
public:
wxString comfirm_before_enter_text;
wxString comfirm_after_enter_text;
wxString comfirm_last_enter_text;
boost::thread* m_thread{nullptr};
std::string m_ip;
wxWindow* m_step_icon_panel3{ nullptr };
Label* m_tip1{ nullptr };
Label* m_tip2{ nullptr };
Label* m_tip3{ nullptr };
@ -286,23 +290,33 @@ public:
~InputIpAddressDialog();
MachineObject* m_obj{nullptr};
wxPanel * ip_input_top_panel{ nullptr };
wxPanel * ip_input_bot_panel{ nullptr };
Button* m_button_ok{ nullptr };
Label* m_tips_ip{ nullptr };
Label* m_tips_access_code{ nullptr };
Label* m_tips_sn{nullptr};
Label* m_tips_modelID{nullptr};
Label* m_test_right_msg{ nullptr };
Label* m_test_wrong_msg{ nullptr };
TextInput* m_input_ip{ nullptr };
TextInput* m_input_access_code{ nullptr };
TextInput* m_input_sn{ nullptr };
ComboBox* m_input_modelID{ nullptr };
wxStaticBitmap* m_img_help{ nullptr };
wxStaticBitmap* m_img_step1{ nullptr };
wxStaticBitmap* m_img_step2{ nullptr };
wxStaticBitmap* m_img_step3{ nullptr };
wxHyperlinkCtrl* m_trouble_shoot{ nullptr };
wxTimer* closeTimer{ nullptr };
int closeCount{3};
bool m_show_access_code{ false };
int m_result;
std::shared_ptr<BBLStatusBarSend> m_status_bar;
std::unique_ptr<Worker> m_worker;
int current_input_index {0};
std::shared_ptr<BBLStatusBarSend> m_status_bar;
boost::bimaps::bimap<std::string, std::string> m_models_map;
void switch_input_panel(int index);
void on_cancel();
void update_title(wxString title);
void set_machine_obj(MachineObject* obj);
@ -311,6 +325,10 @@ public:
void check_ip_address_failed(int result);
void on_check_ip_address_failed(wxCommandEvent& evt);
void on_ok(wxMouseEvent& evt);
void update_test_msg_event(wxCommandEvent &evt);
void post_update_test_msg(wxString text, bool beconnect);
void workerThreadFunc(std::string str_ip, std::string str_access_code, std::string sn, std::string model_id);
void OnTimer(wxTimerEvent& event);
void on_text(wxCommandEvent& evt);
void on_dpi_changed(const wxRect& suggested_rect) override;
};
@ -320,6 +338,7 @@ wxDECLARE_EVENT(EVT_CLOSE_IPADDRESS_DLG, wxCommandEvent);
wxDECLARE_EVENT(EVT_CHECKBOX_CHANGE, wxCommandEvent);
wxDECLARE_EVENT(EVT_ENTER_IP_ADDRESS, wxCommandEvent);
wxDECLARE_EVENT(EVT_CHECK_IP_ADDRESS_FAILED, wxCommandEvent);
wxDECLARE_EVENT(EVT_CHECK_IP_ADDRESS_LAYOUT, wxCommandEvent);
}} // namespace Slic3r::GUI

View file

@ -400,11 +400,13 @@ SelectMachinePopup::SelectMachinePopup(wxWindow *parent)
m_sizer_other_devices = new wxBoxSizer(wxVERTICAL);
m_panel_ping_code = new PinCodePanel(m_scrolledWindow, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE);
m_panel_ping_code = new PinCodePanel(m_scrolledWindow, 0, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE);
m_panel_direct_connection = new PinCodePanel(m_scrolledWindow, 1, wxID_ANY, wxDefaultPosition, SELECT_MACHINE_ITEM_SIZE);
m_sizxer_scrolledWindow->Add(own_title, 0, wxEXPAND | wxLEFT, FromDIP(15));
m_sizxer_scrolledWindow->Add(m_sizer_my_devices, 0, wxEXPAND, 0);
m_sizxer_scrolledWindow->Add(m_panel_ping_code, 0, wxEXPAND, 0);
m_sizxer_scrolledWindow->Add(m_panel_direct_connection, 0, wxEXPAND, 0);
m_sizxer_scrolledWindow->Add(other_title, 0, wxEXPAND | wxLEFT, FromDIP(15));
m_sizxer_scrolledWindow->Add(m_sizer_other_devices, 0, wxEXPAND, 0);
@ -879,14 +881,16 @@ void SelectMachinePopup::OnLeftUp(wxMouseEvent &event)
//pin code
auto pc_rect = m_panel_ping_code->ClientToScreen(wxPoint(0, 0));
if (mouse_pos.x > pc_rect.x && mouse_pos.y > pc_rect.y && mouse_pos.x < (pc_rect.x + m_panel_ping_code->GetSize().x) && mouse_pos.y < (pc_rect.y + m_panel_ping_code->GetSize().y)) {
/*wxMouseEvent event(wxEVT_LEFT_UP);
auto tag_pos = m_panel_ping_code->ScreenToClient(mouse_pos);
event.SetPosition(tag_pos);
event.SetEventObject(m_panel_ping_code);
wxPostEvent(m_panel_ping_code, event);*/
wxGetApp().popup_ping_bind_dialog();
}
//bind with access code
auto dc_rect = m_panel_direct_connection->ClientToScreen(wxPoint(0, 0));
if (mouse_pos.x > dc_rect.x && mouse_pos.y > dc_rect.y && mouse_pos.x < (dc_rect.x + m_panel_direct_connection->GetSize().x) && mouse_pos.y < (dc_rect.y + m_panel_direct_connection->GetSize().y)) {
InputIpAddressDialog dlgo;
dlgo.ShowModal();
}
//hyper link
auto h_rect = m_hyperlink->ClientToScreen(wxPoint(0, 0));
if (mouse_pos.x > h_rect.x && mouse_pos.y > h_rect.y && mouse_pos.x < (h_rect.x + m_hyperlink->GetSize().x) && mouse_pos.y < (h_rect.y + m_hyperlink->GetSize().y)) {
@ -1450,30 +1454,6 @@ void SelectMachineDialog::init_bind()
m_comboBox_printer->SetValue(obj->dev_name + "(LAN)");
}
}
/*else if (e.GetInt() == 1 && (m_print_type == PrintFromType::FROM_SDCARD_VIEW)) {
on_send_print();
}
else if (e.GetInt() == -2 && (m_print_type == PrintFromType::FROM_SDCARD_VIEW)) {
show_status(PrintDialogStatus::PrintStatusInit);
prepare_mode();
MessageDialog msg_wingow(nullptr, _L("Printer local connection failed, please try again."), "", wxAPPLY | wxOK);
msg_wingow.ShowModal();
}
else if (e.GetInt() == 5 && (m_print_type == PrintFromType::FROM_SDCARD_VIEW)) {
show_status(PrintDialogStatus::PrintStatusInit);
prepare_mode();
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return;
ConnectPrinterDialog dlg(wxGetApp().mainframe, wxID_ANY, _L("Input access code"));
dlg.go_connect_printer(false);
if (dev->get_selected_machine()) {
dlg.set_machine_object(dev->get_selected_machine());
if (dlg.ShowModal() == wxID_OK) {
this->connect_printer_mqtt();
}
}
}*/
});
m_bitmap_last_plate->Bind(wxEVT_LEFT_DOWN, [this](auto& e) {
@ -4579,16 +4559,21 @@ void SelectMachineDialog::sys_color_changed()
bool SelectMachineDialog::Show(bool show)
{
show_status(PrintDialogStatus::PrintStatusInit);
// set default value when show this dialog
if (show) {
m_refresh_timer->Start(LIST_REFRESH_INTERVAL);
show_status(PrintDialogStatus::PrintStatusInit);
wxGetApp().UpdateDlgDarkUI(this);
wxGetApp().reset_to_active();
set_default();
update_user_machine_list();
Layout();
Fit();
CenterOnParent();
}
else {
m_refresh_timer->Stop();
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (dev) {
MachineObject* obj_ = dev->get_selected_machine();
@ -4600,15 +4585,6 @@ bool SelectMachineDialog::Show(bool show)
}
}
}
if (show) {
m_refresh_timer->Start(LIST_REFRESH_INTERVAL);
} else {
m_refresh_timer->Stop();
}
Layout();
Fit();
if (show) { CenterOnParent(); }
return DPIDialog::Show(show);
}
@ -4854,7 +4830,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
ThumbnailPanel::~ThumbnailPanel() {}
PinCodePanel::PinCodePanel(wxWindow* parent, wxWindowID winid /*= wxID_ANY*/, const wxPoint& pos /*= wxDefaultPosition*/, const wxSize& size /*= wxDefaultSize*/)
PinCodePanel::PinCodePanel(wxWindow* parent, int type, wxWindowID winid /*= wxID_ANY*/, const wxPoint& pos /*= wxDefaultPosition*/, const wxSize& size /*= wxDefaultSize*/)
{
wxPanel::Create(parent, winid, pos, SELECT_MACHINE_ITEM_SIZE);
Bind(wxEVT_PAINT, &PinCodePanel::OnPaint, this);
@ -4862,6 +4838,7 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
SetMaxSize(SELECT_MACHINE_ITEM_SIZE);
SetMinSize(SELECT_MACHINE_ITEM_SIZE);
m_type = type;
m_bitmap = ScalableBitmap(this, "bind_device_ping_code",10);
this->Bind(wxEVT_ENTER_WINDOW, &PinCodePanel::on_mouse_enter, this);
@ -4899,12 +4876,15 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
void PinCodePanel::doRender(wxDC& dc)
{
auto size = GetSize();
dc.DrawBitmap(m_bitmap.bmp(), wxPoint(FromDIP(20), (size.y - m_bitmap.GetBmpSize().y) / 2));
dc.DrawBitmap(m_bitmap.bmp(), wxPoint(FromDIP(12), (size.y - m_bitmap.GetBmpSize().y) / 2));
dc.SetFont(::Label::Head_13);
dc.SetTextForeground(StateColor::darkModeColorFor(wxColour("#262E30"))); // ORCA fix text not visible on dark theme
wxString txt = _L("Bind with Pin Code");
wxString txt;
if (m_type == 0) { txt = _L("Bind with Pin Code"); }
else if (m_type == 1) { txt = _L("Bind with Access Code"); }
auto txt_size = dc.GetTextExtent(txt);
dc.DrawText(txt, wxPoint(FromDIP(40), (size.y - txt_size.y) / 2));
dc.DrawText(txt, wxPoint(FromDIP(28), (size.y - txt_size.y) / 2));
if (m_hover) {
dc.SetPen(SELECT_MACHINE_BRAND);
@ -4927,7 +4907,13 @@ void EditDevNameDialog::on_edit_name(wxCommandEvent &e)
void PinCodePanel::on_mouse_left_up(wxMouseEvent& evt)
{
wxGetApp().popup_ping_bind_dialog();
if (m_type == 0) {
wxGetApp().popup_ping_bind_dialog();
}
else if (m_type == 1) {
InputIpAddressDialog dlgo;
dlgo.ShowModal();
}
}
}} // namespace Slic3r::GUI

View file

@ -195,7 +195,7 @@ protected:
#define SELECT_MACHINE_POPUP_SIZE wxSize(FromDIP(216), FromDIP(364))
#define SELECT_MACHINE_LIST_SIZE wxSize(FromDIP(212), FromDIP(360))
#define SELECT_MACHINE_ITEM_SIZE wxSize(FromDIP(182), FromDIP(35))
#define SELECT_MACHINE_ITEM_SIZE wxSize(FromDIP(190), FromDIP(35))
#define SELECT_MACHINE_GREY900 wxColour(38, 46, 48)
#define SELECT_MACHINE_GREY600 wxColour(144,144,144)
#define SELECT_MACHINE_GREY400 wxColour(206, 206, 206)
@ -214,6 +214,7 @@ class PinCodePanel : public wxPanel
{
public:
PinCodePanel(wxWindow* parent,
int type,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize);
@ -221,6 +222,7 @@ public:
ScalableBitmap m_bitmap;
bool m_hover{false};
int m_type{0};
void OnPaint(wxPaintEvent& event);
void render(wxDC& dc);
@ -254,6 +256,7 @@ private:
int m_my_devices_count{0};
int m_other_devices_count{0};
PinCodePanel* m_panel_ping_code{nullptr};
PinCodePanel* m_panel_direct_connection{nullptr};
wxWindow* m_placeholder_panel{nullptr};
wxHyperlinkCtrl* m_hyperlink{nullptr};
Label* m_ping_code_text{nullptr};

View file

@ -2176,9 +2176,9 @@ void StatusPanel::show_recenter_dialog() {
obj->command_go_home();
}
void StatusPanel::show_error_message(MachineObject* obj, wxString msg, std::string print_error_str, wxString image_url, std::vector<int> used_button)
void StatusPanel::show_error_message(MachineObject *obj, bool is_exist, wxString msg, std::string print_error_str, wxString image_url, std::vector<int> used_button)
{
if (msg.IsEmpty()) {
if (is_exist && msg.IsEmpty()) {
error_info_reset();
} else {
m_project_task_panel->show_error_msg(msg);
@ -2190,7 +2190,7 @@ void StatusPanel::show_error_message(MachineObject* obj, wxString msg, std::stri
}
m_print_error_dlg->update_title_style(_L("Error"), used_button, this);
m_print_error_dlg->update_text_image(msg, image_url);
m_print_error_dlg->update_text_image(msg, print_error_str, image_url);
m_print_error_dlg->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, obj](wxCommandEvent& e) {
if (obj) {
obj->command_clean_print_error(obj->subtask_id_, obj->print_error);
@ -2212,6 +2212,11 @@ void StatusPanel::show_error_message(MachineObject* obj, wxString msg, std::stri
auto it_resume = std::find(message_containing_resume.begin(), message_containing_resume.end(), print_error_str);
BOOST_LOG_TRIVIAL(info) << "show print error! error_msg = " << msg;
wxDateTime now = wxDateTime::Now();
wxString show_time = now.Format("%H%M%d");
wxString error_code_msg = wxString::Format("%S\n[%S %S]", msg, print_error_str, show_time);
if (m_print_error_dlg_no_action == nullptr) {
m_print_error_dlg_no_action = new SecondaryCheckDialog(this->GetParent(), wxID_ANY, _L("Warning"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM);
}
@ -2231,7 +2236,7 @@ void StatusPanel::show_error_message(MachineObject* obj, wxString msg, std::stri
else {
m_print_error_dlg_no_action->update_title_style(_L("Warning"), SecondaryCheckDialog::ButtonStyle::ONLY_CONFIRM, this);
}
m_print_error_dlg_no_action->update_text(msg);
m_print_error_dlg_no_action->update_text(error_code_msg);
m_print_error_dlg_no_action->Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, obj](wxCommandEvent& e) {
if (obj) {
obj->command_clean_print_error(obj->subtask_id_, obj->print_error);
@ -2254,7 +2259,7 @@ void StatusPanel::update_error_message()
{
if (obj->print_error <= 0) {
before_error_code = obj->print_error;
show_error_message(obj, wxEmptyString);
show_error_message(obj, true, wxEmptyString);
return;
} else if (before_error_code != obj->print_error && obj->print_error != skip_print_error) {
before_error_code = obj->print_error;
@ -2263,27 +2268,17 @@ void StatusPanel::update_error_message()
char buf[32];
::sprintf(buf, "%08X", obj->print_error);
std::string print_error_str = std::string(buf);
if (print_error_str.size() > 4) {
print_error_str.insert(4, " ");
}
if (print_error_str.size() > 4) { print_error_str.insert(4, " "); }
wxString error_msg = wxGetApp().get_hms_query()->query_print_error_msg(obj->print_error);
wxString error_msg;
bool is_errocode_exist = wxGetApp().get_hms_query()->query_print_error_msg(obj->print_error, error_msg);
std::vector<int> used_button;
wxString error_image_url = wxGetApp().get_hms_query()->query_print_error_url_action(obj->print_error,obj->dev_id, used_button);
wxString error_image_url = wxGetApp().get_hms_query()->query_print_error_url_action(obj->print_error, obj->dev_id, used_button);
// special case
if (print_error_str == "0300 8003" || print_error_str == "0300 8002" || print_error_str == "0300 800A")
if (print_error_str == "0300 8003" || print_error_str == "0300 8002" || print_error_str == "0300 800A") {
used_button.emplace_back(PrintErrorDialog::PrintErrorButton::JUMP_TO_LIVEVIEW);
if (!error_msg.IsEmpty()) {
wxDateTime now = wxDateTime::Now();
wxString show_time = now.Format("%Y-%m-%d %H:%M:%S");
error_msg = wxString::Format("%s\n[%s %s]",
error_msg,
print_error_str, show_time);
show_error_message(obj, error_msg, print_error_str,error_image_url,used_button);
} else {
BOOST_LOG_TRIVIAL(info) << "show print error! error_msg is empty, print error = " << obj->print_error;
}
show_error_message(obj, is_errocode_exist, error_msg, print_error_str, error_image_url, used_button);
}
}
}
@ -3127,6 +3122,20 @@ void StatusPanel::update_subtask(MachineObject *obj)
} else {
m_project_task_panel->enable_pause_resume_button(true, "pause");
}
// update printing stage
m_project_task_panel->update_left_time(obj->mc_left_time);
if (obj->subtask_) {
m_project_task_panel->update_stage_value(obj->get_curr_stage(), obj->subtask_->task_progress);
m_project_task_panel->update_progress_percent(wxString::Format("%d", obj->subtask_->task_progress), "%");
m_project_task_panel->update_layers_num(true, wxString::Format(_L("Layer: %d/%d"), obj->curr_layer, obj->total_layers));
} else {
m_project_task_panel->update_stage_value(obj->get_curr_stage(), 0);
m_project_task_panel->update_progress_percent(NA_STR, wxEmptyString);
m_project_task_panel->update_layers_num(true, wxString::Format(_L("Layer: %s"), NA_STR));
}
if (obj->is_printing_finished()) {
obj->update_model_task();
m_project_task_panel->enable_abort_button(false);
@ -3171,19 +3180,6 @@ void StatusPanel::update_subtask(MachineObject *obj)
m_project_task_panel->market_scoring_hide();
m_project_task_panel->get_request_failed_panel()->Hide();
}
// update printing stage
m_project_task_panel->update_left_time(obj->mc_left_time);
if (obj->subtask_) {
m_project_task_panel->update_stage_value(obj->get_curr_stage(), obj->subtask_->task_progress);
m_project_task_panel->update_progress_percent(wxString::Format("%d", obj->subtask_->task_progress), "%");
m_project_task_panel->update_layers_num(true, wxString::Format(_L("Layer: %d/%d"), obj->curr_layer, obj->total_layers));
} else {
m_project_task_panel->update_stage_value(obj->get_curr_stage(), 0);
m_project_task_panel->update_progress_percent(NA_STR, wxEmptyString);
m_project_task_panel->update_layers_num(true, wxString::Format(_L("Layer: %s"), NA_STR));
}
}
m_project_task_panel->update_subtask_name(wxString::Format("%s", GUI::from_u8(obj->subtask_name)));
@ -3207,7 +3203,7 @@ void StatusPanel::update_subtask(MachineObject *obj)
reset_printing_values();
}
this->Layout();
Layout();
}
void StatusPanel::update_cloud_subtask(MachineObject *obj)

View file

@ -527,7 +527,8 @@ protected:
void on_subtask_pause_resume(wxCommandEvent &event);
void on_subtask_abort(wxCommandEvent &event);
void on_print_error_clean(wxCommandEvent &event);
void show_error_message(MachineObject* obj, wxString msg, std::string print_error_str = "",wxString image_url="",std::vector<int> used_button=std::vector<int>());
void show_error_message(
MachineObject *obj, bool is_exist, wxString msg, std::string print_error_str = "", wxString image_url = "", std::vector<int> used_button = std::vector<int>());
void error_info_reset();
void show_recenter_dialog();

View file

@ -75,6 +75,8 @@ func_build_logout_cmd NetworkAgent::build_logout_cmd_ptr = nullptr
func_build_login_info NetworkAgent::build_login_info_ptr = nullptr;
func_get_model_id_from_desgin_id NetworkAgent::get_model_id_from_desgin_id_ptr = nullptr;
func_ping_bind NetworkAgent::ping_bind_ptr = nullptr;
func_bind_detect NetworkAgent::bind_detect_ptr = nullptr;
func_set_server_callback NetworkAgent::set_server_callback_ptr = nullptr;
func_bind NetworkAgent::bind_ptr = nullptr;
func_unbind NetworkAgent::unbind_ptr = nullptr;
func_get_bambulab_host NetworkAgent::get_bambulab_host_ptr = nullptr;
@ -145,6 +147,31 @@ NetworkAgent::~NetworkAgent()
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", this %1%, network_agent=%2%, destroy_agent_ptr=%3%, ret %4%")%this %network_agent %destroy_agent_ptr %ret;
}
std::string NetworkAgent::get_libpath_in_current_directory(std::string library_name)
{
std::string lib_path;
#if defined(_MSC_VER) || defined(_WIN32)
wchar_t file_name[512];
DWORD ret = GetModuleFileNameW(NULL, file_name, 512);
if (!ret) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", GetModuleFileNameW return error, can not Load Library for %1%") % library_name;
return lib_path;
}
int size_needed = ::WideCharToMultiByte(0, 0, file_name, wcslen(file_name), nullptr, 0, nullptr, nullptr);
std::string file_name_string(size_needed, 0);
::WideCharToMultiByte(0, 0, file_name, wcslen(file_name), file_name_string.data(), size_needed, nullptr, nullptr);
std::size_t found = file_name_string.find("bambu-studio.exe");
if (found == (file_name_string.size() - 16)) {
lib_path = library_name + ".dll";
lib_path = file_name_string.replace(found, 16, lib_path);
}
#else
#endif
return lib_path;
}
int NetworkAgent::initialize_network_module(bool using_backup)
{
//int ret = -1;
@ -159,7 +186,7 @@ int NetworkAgent::initialize_network_module(bool using_backup)
//first load the library
#if defined(_MSC_VER) || defined(_WIN32)
library = plugin_folder.string() + "/" + 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]));
@ -170,6 +197,19 @@ int NetworkAgent::initialize_network_module(bool using_backup)
::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);
}*/
if (!netwoking_module) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", try load library directly from current directory");
std::string library_path = get_libpath_in_current_directory(std::string(BAMBU_NETWORK_LIBRARY));
if (library_path.empty()) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", can not get path in current directory for %1%") % BAMBU_NETWORK_LIBRARY;
return -1;
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", current path %1%")%library_path;
memset(lib_wstr, 0, sizeof(lib_wstr));
::MultiByteToWideChar(CP_UTF8, NULL, library_path.c_str(), strlen(library_path.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";
@ -246,6 +286,8 @@ int NetworkAgent::initialize_network_module(bool using_backup)
build_logout_cmd_ptr = reinterpret_cast<func_build_logout_cmd>(get_network_function("bambu_network_build_logout_cmd"));
build_login_info_ptr = reinterpret_cast<func_build_login_info>(get_network_function("bambu_network_build_login_info"));
ping_bind_ptr = reinterpret_cast<func_ping_bind>(get_network_function("bambu_network_ping_bind"));
bind_detect_ptr = reinterpret_cast<func_bind_detect>(get_network_function("bambu_network_bind_detect"));
set_server_callback_ptr = reinterpret_cast<func_set_server_callback>(get_network_function("bambu_network_set_server_callback"));
get_model_id_from_desgin_id_ptr = reinterpret_cast<func_get_model_id_from_desgin_id>(get_network_function("bambu_network_get_model_id_from_desgin_id"));
bind_ptr = reinterpret_cast<func_bind>(get_network_function("bambu_network_bind"));
unbind_ptr = reinterpret_cast<func_unbind>(get_network_function("bambu_network_unbind"));
@ -298,7 +340,7 @@ int NetworkAgent::initialize_network_module(bool using_backup)
get_model_mall_rating_result_ptr = reinterpret_cast<func_get_model_mall_rating_result>(get_network_function("bambu_network_get_model_mall_rating"));
get_mw_user_preference_ptr = reinterpret_cast<func_get_mw_user_preference>(get_network_function("bambu_network_get_mw_user_preference"));
get_mw_user_4ulist_ptr = reinterpret_cast<func_get_mw_user_4ulist>(get_network_function("bambu_network_get_mw_user_4ulist"));
get_mw_user_4ulist_ptr = reinterpret_cast<func_get_mw_user_4ulist>(get_network_function("bambu_network_get_mw_user_4ulist"));
return 0;
}
@ -417,7 +459,7 @@ int NetworkAgent::unload_network_module()
put_rating_picture_oss_ptr = nullptr;
put_model_mall_rating_url_ptr = nullptr;
get_model_mall_rating_result_ptr = nullptr;
get_mw_user_preference_ptr = nullptr;
get_mw_user_4ulist_ptr = nullptr;
@ -446,12 +488,18 @@ void* NetworkAgent::get_bambu_source_entry()
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";
if (!source_module) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", try load BambuSource directly from current directory");
std::string library_path = get_libpath_in_current_directory(std::string(BAMBU_SOURCE_LIBRARY));
if (library_path.empty()) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", can not get path in current directory for %1%") % BAMBU_SOURCE_LIBRARY;
return source_module;
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", current path %1%")%library_path;
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]));
::MultiByteToWideChar(CP_UTF8, NULL, library_path.c_str(), strlen(library_path.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";
@ -881,11 +929,11 @@ bool NetworkAgent::is_user_login()
return ret;
}
int NetworkAgent::user_logout()
int NetworkAgent::user_logout(bool request)
{
int ret = 0;
if (network_agent && user_logout_ptr) {
ret = user_logout_ptr(network_agent);
ret = user_logout_ptr(network_agent, request);
if (ret)
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%")%network_agent %ret;
}
@ -979,6 +1027,30 @@ int NetworkAgent::ping_bind(std::string ping_code)
return ret;
}
int NetworkAgent::bind_detect(std::string dev_ip, std::string sec_link, detectResult& detect)
{
int ret = 0;
if (network_agent && bind_detect_ptr) {
ret = bind_detect_ptr(network_agent, dev_ip, sec_link, detect);
if (ret)
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%, dev_ip=%3%")
% network_agent % ret % dev_ip;
}
return ret;
}
int NetworkAgent::set_server_callback(OnServerErrFn fn)
{
int ret = 0;
if (network_agent && set_server_callback_ptr) {
ret = set_server_callback_ptr(network_agent, fn);
if (ret)
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(" error: network_agent=%1%, ret=%2%")
% network_agent % ret;
}
return ret;
}
int NetworkAgent::bind(std::string dev_ip, std::string dev_id, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn)
{
int ret = 0;

View file

@ -45,7 +45,7 @@ typedef int (*func_send_message_to_printer)(void *agent, std::string dev_id, std
typedef bool (*func_start_discovery)(void *agent, bool start, bool sending);
typedef int (*func_change_user)(void *agent, std::string user_info);
typedef bool (*func_is_user_login)(void *agent);
typedef int (*func_user_logout)(void *agent);
typedef int (*func_user_logout)(void *agent, bool request);
typedef std::string (*func_get_user_id)(void *agent);
typedef std::string (*func_get_user_name)(void *agent);
typedef std::string (*func_get_user_avatar)(void *agent);
@ -55,6 +55,8 @@ typedef std::string (*func_build_logout_cmd)(void *agent);
typedef std::string (*func_build_login_info)(void *agent);
typedef int (*func_get_model_id_from_desgin_id)(void *agent, std::string& desgin_id, std::string& model_id);
typedef int (*func_ping_bind)(void *agent, std::string ping_code);
typedef int (*func_bind_detect)(void *agent, std::string dev_ip, std::string sec_link, detectResult& detect);
typedef int (*func_set_server_callback)(void *agent, OnServerErrFn fn);
typedef int (*func_bind)(void *agent, std::string dev_ip, std::string dev_id, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn);
typedef int (*func_unbind)(void *agent, std::string dev_id);
typedef std::string (*func_get_bambulab_host)(void *agent);
@ -115,6 +117,7 @@ class NetworkAgent
{
public:
static std::string get_libpath_in_current_directory(std::string library_name);
static int initialize_network_module(bool using_backup = false);
static int unload_network_module();
#if defined(_MSC_VER) || defined(_WIN32)
@ -161,7 +164,7 @@ public:
bool start_discovery(bool start, bool sending);
int change_user(std::string user_info);
bool is_user_login();
int user_logout();
int user_logout(bool request = false);
std::string get_user_id();
std::string get_user_name();
std::string get_user_avatar();
@ -171,6 +174,8 @@ public:
std::string build_login_info();
int get_model_id_from_desgin_id(std::string& desgin_id, std::string& model_id);
int ping_bind(std::string ping_code);
int bind_detect(std::string dev_ip, std::string sec_link, detectResult& detect);
int set_server_callback(OnServerErrFn fn);
int bind(std::string dev_ip, std::string dev_id, std::string sec_link, std::string timezone, bool improved, OnUpdateStatusFn update_fn);
int unbind(std::string dev_id);
std::string get_bambulab_host();
@ -224,6 +229,7 @@ public:
int get_mw_user_preference(std::function<void(std::string)> callback);
int get_mw_user_4ulist(int seed, int limit, std::function<void(std::string)> callback);
void *get_network_agent() { return network_agent; }
private:
bool enable_track = false;
@ -277,6 +283,8 @@ private:
static func_build_login_info build_login_info_ptr;
static func_get_model_id_from_desgin_id get_model_id_from_desgin_id_ptr;
static func_ping_bind ping_bind_ptr;
static func_bind_detect bind_detect_ptr;
static func_set_server_callback set_server_callback_ptr;
static func_bind bind_ptr;
static func_unbind unbind_ptr;
static func_get_bambulab_host get_bambulab_host_ptr;

View file

@ -95,7 +95,7 @@ namespace BBL {
#define BAMBU_NETWORK_LIBRARY "bambu_networking"
#define BAMBU_NETWORK_AGENT_NAME "bambu_network_agent"
#define BAMBU_NETWORK_AGENT_VERSION "01.09.02.05"
#define BAMBU_NETWORK_AGENT_VERSION "01.10.01.01"
//iot preset type strings
#define IOT_PRINTER_TYPE_STRING "printer"
@ -138,6 +138,9 @@ typedef std::function<void(int result, std::string info)> ResultFn;
typedef std::function<bool()> CancelFn;
typedef std::function<bool(std::map<std::string, std::string> info)> CheckFn;
//err callbacks
typedef std::function<void(std::string url, int status)> OnServerErrFn;
enum SendingPrintJobStage {
PrintingStageCreate = 0,
PrintingStageUpload = 1,
@ -172,6 +175,17 @@ enum ConnectStatus {
ConnectStatusLost = 2,
};
struct detectResult {
std::string result_msg;
std::string command;
std::string dev_id;
std::string model_id;
std::string dev_name;
std::string version;
std::string bind_state;
std::string connect_type;
};
/* print job*/
struct PrintParams {
/* basic info */

View file

@ -17,4 +17,4 @@ set(ORCA_VERSION_MAJOR ${CMAKE_MATCH_1})
set(ORCA_VERSION_MINOR ${CMAKE_MATCH_2})
set(ORCA_VERSION_PATCH ${CMAKE_MATCH_3})
set(SLIC3R_VERSION "01.09.05.51")
set(SLIC3R_VERSION "01.10.01.50")