mirror of
https://github.com/QIDITECH/QIDISlicer.git
synced 2026-02-04 01:48:44 +03:00
Optimize device connectivity, and fix some bug
This commit is contained in:
@@ -5111,14 +5111,16 @@ void Plater::priv::show_action_buttons(const bool ready_to_slice_) const
|
|||||||
DynamicPrintConfig* selected_printer_config = wxGetApp().preset_bundle->physical_printers.get_selected_printer_config();
|
DynamicPrintConfig* selected_printer_config = wxGetApp().preset_bundle->physical_printers.get_selected_printer_config();
|
||||||
const auto print_host_opt = selected_printer_config ? selected_printer_config->option<ConfigOptionString>("print_host") : nullptr;
|
const auto print_host_opt = selected_printer_config ? selected_printer_config->option<ConfigOptionString>("print_host") : nullptr;
|
||||||
const bool send_gcode_shown = print_host_opt != nullptr && !print_host_opt->value.empty();
|
const bool send_gcode_shown = print_host_opt != nullptr && !print_host_opt->value.empty();
|
||||||
|
|
||||||
|
auto m_devices = wxGetApp().get_devices();
|
||||||
|
const bool link_has_machine = m_devices.size() > 0;
|
||||||
|
|
||||||
// when a background processing is ON, export_btn and/or send_btn are showing
|
// when a background processing is ON, export_btn and/or send_btn are showing
|
||||||
if (get_config_bool("background_processing"))
|
if (get_config_bool("background_processing"))
|
||||||
{
|
{
|
||||||
RemovableDriveManager::RemovableDrivesStatus removable_media_status = wxGetApp().removable_drive_manager()->status();
|
RemovableDriveManager::RemovableDrivesStatus removable_media_status = wxGetApp().removable_drive_manager()->status();
|
||||||
if (sidebar->show_reslice(false) |
|
if (sidebar->show_reslice(false) |
|
||||||
sidebar->show_export(true) |
|
sidebar->show_export(true) | sidebar->show_send(send_gcode_shown | link_has_machine) |
|
||||||
sidebar->show_send(send_gcode_shown) |
|
|
||||||
sidebar->show_export_removable(removable_media_status.has_removable_drives))
|
sidebar->show_export_removable(removable_media_status.has_removable_drives))
|
||||||
// sidebar->show_eject(removable_media_status.has_eject))
|
// sidebar->show_eject(removable_media_status.has_eject))
|
||||||
sidebar->Layout();
|
sidebar->Layout();
|
||||||
@@ -5130,7 +5132,7 @@ void Plater::priv::show_action_buttons(const bool ready_to_slice_) const
|
|||||||
removable_media_status = wxGetApp().removable_drive_manager()->status();
|
removable_media_status = wxGetApp().removable_drive_manager()->status();
|
||||||
if (sidebar->show_reslice(ready_to_slice) |
|
if (sidebar->show_reslice(ready_to_slice) |
|
||||||
sidebar->show_export(!ready_to_slice) |
|
sidebar->show_export(!ready_to_slice) |
|
||||||
sidebar->show_send(send_gcode_shown && !ready_to_slice) |
|
sidebar->show_send((send_gcode_shown | link_has_machine) && !ready_to_slice) |
|
||||||
sidebar->show_export_removable(!ready_to_slice && removable_media_status.has_removable_drives))
|
sidebar->show_export_removable(!ready_to_slice && removable_media_status.has_removable_drives))
|
||||||
// sidebar->show_eject(!ready_to_slice && removable_media_status.has_eject))
|
// sidebar->show_eject(!ready_to_slice && removable_media_status.has_eject))
|
||||||
sidebar->Layout();
|
sidebar->Layout();
|
||||||
@@ -8011,11 +8013,10 @@ void Plater::send_gcode()
|
|||||||
{
|
{
|
||||||
// if physical_printer is selected, send gcode for this printer
|
// if physical_printer is selected, send gcode for this printer
|
||||||
DynamicPrintConfig* physical_printer_config = wxGetApp().preset_bundle->physical_printers.get_selected_printer_config();
|
DynamicPrintConfig* physical_printer_config = wxGetApp().preset_bundle->physical_printers.get_selected_printer_config();
|
||||||
if (! physical_printer_config || p->model.objects.empty())
|
auto m_devices = wxGetApp().get_devices();
|
||||||
return;
|
const bool link_has_machine = m_devices.size() > 0;
|
||||||
|
|
||||||
PrintHostJob upload_job(physical_printer_config);
|
if ((!physical_printer_config && !link_has_machine) || p->model.objects.empty())
|
||||||
if (upload_job.empty())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Obtain default output path
|
// Obtain default output path
|
||||||
@@ -8039,25 +8040,30 @@ void Plater::send_gcode()
|
|||||||
|
|
||||||
// Repetier specific: Query the server for the list of file groups.
|
// Repetier specific: Query the server for the list of file groups.
|
||||||
wxArrayString groups;
|
wxArrayString groups;
|
||||||
{
|
|
||||||
wxBusyCursor wait;
|
|
||||||
upload_job.printhost->get_groups(groups);
|
|
||||||
}
|
|
||||||
// QIDILink specific: Query the server for the list of file groups.
|
// QIDILink specific: Query the server for the list of file groups.
|
||||||
wxArrayString storage_paths;
|
wxArrayString storage_paths;
|
||||||
wxArrayString storage_names;
|
wxArrayString storage_names;
|
||||||
{
|
bool only_link = false;
|
||||||
|
if (physical_printer_config) {
|
||||||
|
PrintHostJob upload_job(physical_printer_config);
|
||||||
|
if (upload_job.empty())
|
||||||
|
return;
|
||||||
wxBusyCursor wait;
|
wxBusyCursor wait;
|
||||||
|
upload_job.printhost->get_groups(groups);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
upload_job.printhost->get_storage(storage_paths, storage_names);
|
upload_job.printhost->get_storage(storage_paths, storage_names);
|
||||||
} catch (const Slic3r::IOError& ex) {
|
} catch (const Slic3r::IOError &ex) {
|
||||||
show_error(this, ex.what(), false);
|
show_error(this, ex.what(), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
only_link = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//B61
|
//B61
|
||||||
PrintHostSendDialog dlg(default_output_file, upload_job.printhost->get_post_upload_actions(), groups, storage_paths, storage_names,
|
PrintHostSendDialog dlg(default_output_file, PrintHostPostUploadAction::StartPrint, groups, storage_paths, storage_names, this,
|
||||||
this, (this->fff_print().print_statistics()));
|
(this->fff_print().print_statistics()), only_link);
|
||||||
|
|
||||||
if (dlg.ShowModal() == wxID_OK) {
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
if (printer_technology() == ptFFF) {
|
if (printer_technology() == ptFFF) {
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path & path,
|
|||||||
const wxArrayString & storage_paths,
|
const wxArrayString & storage_paths,
|
||||||
const wxArrayString & storage_names,
|
const wxArrayString & storage_names,
|
||||||
Plater * plater,
|
Plater * plater,
|
||||||
const PrintStatistics & ps)
|
const PrintStatistics & ps,
|
||||||
|
bool onlylink)
|
||||||
: MsgDialog(static_cast<wxWindow *>(wxGetApp().mainframe),
|
: MsgDialog(static_cast<wxWindow *>(wxGetApp().mainframe),
|
||||||
_L("Send G-Code to printer host"),
|
_L("Send G-Code to printer host"),
|
||||||
_L(""),
|
_L(""),
|
||||||
@@ -196,9 +197,15 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path & path,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//y4
|
//y4
|
||||||
PhysicalPrinter selected_printer = ph_printers.get_selected_printer();
|
std::string printer_preset = "";
|
||||||
std::set<std::string> selected_printer_presets = selected_printer.get_preset_names();
|
if (!onlylink) {
|
||||||
std::string printer_preset = *selected_printer_presets.begin();
|
PhysicalPrinter selected_printer = ph_printers.get_selected_printer();
|
||||||
|
std::set<std::string> selected_printer_presets = selected_printer.get_preset_names();
|
||||||
|
printer_preset = *selected_printer_presets.begin();
|
||||||
|
} else {
|
||||||
|
Preset &select_preset = preset_bundle.printers.get_edited_preset();
|
||||||
|
printer_preset = select_preset.name;
|
||||||
|
}
|
||||||
m_presetData = preset_data;
|
m_presetData = preset_data;
|
||||||
for (const PhysicalPrinterPresetData &data : preset_data) {
|
for (const PhysicalPrinterPresetData &data : preset_data) {
|
||||||
//y4
|
//y4
|
||||||
@@ -939,20 +946,20 @@ void PrintHostQueueDialog::on_error(Event &evt)
|
|||||||
wxCHECK_RET(evt.job_id < (size_t)job_list->GetItemCount(), "Out of bounds access to job list");
|
wxCHECK_RET(evt.job_id < (size_t)job_list->GetItemCount(), "Out of bounds access to job list");
|
||||||
|
|
||||||
set_state(evt.job_id, ST_ERROR);
|
set_state(evt.job_id, ST_ERROR);
|
||||||
// y1
|
|
||||||
std::string response_msg = into_u8(evt.status);
|
std::string response_msg = into_u8(evt.status);
|
||||||
size_t pos_404 = evt.status.find("HTTP 404:");
|
|
||||||
wxString code_msg = "";
|
wxString code_msg = "";
|
||||||
if (pos_404 != std::string::npos) {
|
if (response_msg.find("HTTP 404:") != std::string::npos) {
|
||||||
code_msg = _L("Network connection fails.");
|
|
||||||
size_t isAws = response_msg.find("AWS");
|
size_t isAws = response_msg.find("AWS");
|
||||||
if(isAws != std::string::npos)
|
if(isAws != std::string::npos)
|
||||||
code_msg += _L("Unable to get required resources from AWS server, please check your network settings.");
|
code_msg = _L("HTTP 404. Unable to get required resources from AWS server, please check your network settings.");
|
||||||
else
|
else
|
||||||
code_msg += _L("Unable to get required resources from Aliyun server, please check your network settings.");
|
code_msg = _L("HTTP 404. Unable to get required resources from Aliyun server, please check your network settings.");
|
||||||
}
|
}
|
||||||
|
else if (response_msg.find("HTTP 401:") != std::string::npos)
|
||||||
|
code_msg = _L("HTTP 401: Unauthorized. Please check whether your physical printer has added users. If a user exists, add the "
|
||||||
|
"APIKEY when adding/editing the printer.");
|
||||||
else
|
else
|
||||||
code_msg = _L("Network connection times out. Please check the device network Settings.");
|
code_msg = response_msg;
|
||||||
|
|
||||||
auto errormsg = format_wxstr("%1%\n%2%", _L("Error uploading to print host") + ":", code_msg);
|
auto errormsg = format_wxstr("%1%\n%2%", _L("Error uploading to print host") + ":", code_msg);
|
||||||
job_list->SetValue(wxVariant(0), evt.job_id, COL_PROGRESS);
|
job_list->SetValue(wxVariant(0), evt.job_id, COL_PROGRESS);
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ public:
|
|||||||
const wxArrayString & storage_paths,
|
const wxArrayString & storage_paths,
|
||||||
const wxArrayString & storage_names,
|
const wxArrayString & storage_names,
|
||||||
Plater * plater,
|
Plater * plater,
|
||||||
const PrintStatistics & ps);
|
const PrintStatistics & ps,
|
||||||
|
bool onlyLik);
|
||||||
boost::filesystem::path filename() const;
|
boost::filesystem::path filename() const;
|
||||||
PrintHostPostUploadAction post_action() const;
|
PrintHostPostUploadAction post_action() const;
|
||||||
std::string group() const;
|
std::string group() const;
|
||||||
|
|||||||
@@ -281,9 +281,13 @@ void PrinterWebView::CreatThread() {
|
|||||||
if (m_pauseThread)
|
if (m_pauseThread)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
DynamicPrintConfig cfg_t;
|
||||||
|
cfg_t.set_key_value("print_host", new ConfigOptionString(into_u8(button->getIPLabel())));
|
||||||
|
cfg_t.set_key_value("printhost_apikey", new ConfigOptionString(into_u8(button->GetApikey())));
|
||||||
|
cfg_t.set_key_value("printhost_cafile", new ConfigOptionString(""));
|
||||||
|
cfg_t.set_key_value("printhost_ssl_ignore_revoke", new ConfigOptionBool(false));
|
||||||
std::unique_ptr<PrintHost> printhost(
|
std::unique_ptr<PrintHost> printhost(
|
||||||
PrintHost::get_print_host_url((button->getIPLabel()).ToStdString(), (button->getIPLabel()).ToStdString()));
|
PrintHost::get_print_host(&cfg_t));
|
||||||
if (!printhost) {
|
if (!printhost) {
|
||||||
BOOST_LOG_TRIVIAL(error) << ("Could not get a valid Printer Host reference");
|
BOOST_LOG_TRIVIAL(error) << ("Could not get a valid Printer Host reference");
|
||||||
return;
|
return;
|
||||||
@@ -291,13 +295,15 @@ void PrinterWebView::CreatThread() {
|
|||||||
wxString msg;
|
wxString msg;
|
||||||
std::string state = "standby";
|
std::string state = "standby";
|
||||||
float progress = 0;
|
float progress = 0;
|
||||||
state = printhost->get_status(msg);
|
std::pair<std::string, float> state_progress = printhost->get_status_progress(msg);
|
||||||
|
|
||||||
|
state = state_progress.first;
|
||||||
|
|
||||||
if ((button->GetStateText()).ToStdString() != state)
|
if ((button->GetStateText()).ToStdString() != state)
|
||||||
button->SetStateText(state);
|
button->SetStateText(state);
|
||||||
|
|
||||||
if (state == "printing") {
|
if (state == "printing") {
|
||||||
progress = (printhost->get_progress(msg)) * 100;
|
progress = state_progress.second * 100;
|
||||||
int progressInt = static_cast<int>(progress);
|
int progressInt = static_cast<int>(progress);
|
||||||
button->SetProgressText(wxString::Format(wxT("(%d%%)"), progressInt));
|
button->SetProgressText(wxString::Format(wxT("(%d%%)"), progressInt));
|
||||||
}
|
}
|
||||||
@@ -321,13 +327,14 @@ void PrinterWebView::CreatThread() {
|
|||||||
wxString msg;
|
wxString msg;
|
||||||
std::string state = "standby";
|
std::string state = "standby";
|
||||||
float progress = 0;
|
float progress = 0;
|
||||||
state = printhost->get_status(msg);
|
std::pair<std::string, float> state_progress = printhost->get_status_progress(msg);
|
||||||
|
state = state_progress.first;
|
||||||
|
|
||||||
if ((m_net_buttons[count]->GetStateText()).ToStdString() != state)
|
if ((m_net_buttons[count]->GetStateText()).ToStdString() != state)
|
||||||
m_net_buttons[count]->SetStateText(state);
|
m_net_buttons[count]->SetStateText(state);
|
||||||
|
|
||||||
if (state == "printing") {
|
if (state == "printing") {
|
||||||
progress = (printhost->get_progress(msg)) * 100;
|
progress = state_progress.second * 100;
|
||||||
int progressInt = static_cast<int>(progress);
|
int progressInt = static_cast<int>(progress);
|
||||||
m_net_buttons[count]->SetProgressText(wxString::Format(wxT("(%d%%)"), progressInt));
|
m_net_buttons[count]->SetProgressText(wxString::Format(wxT("(%d%%)"), progressInt));
|
||||||
}
|
}
|
||||||
@@ -355,6 +362,7 @@ void PrinterWebView::SetPresetChanged(bool status) {
|
|||||||
PhysicalPrinterCollection &ph_printers = preset_bundle.physical_printers;
|
PhysicalPrinterCollection &ph_printers = preset_bundle.physical_printers;
|
||||||
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
|
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
|
||||||
std::string host = (it->config.opt_string("print_host"));
|
std::string host = (it->config.opt_string("print_host"));
|
||||||
|
wxString apikey = from_u8(it->config.opt_string("printhost_apikey"));
|
||||||
for (const std::string &preset_name : it->get_preset_names()) {
|
for (const std::string &preset_name : it->get_preset_names()) {
|
||||||
Preset * preset = wxGetApp().preset_bundle->printers.find_preset(preset_name);
|
Preset * preset = wxGetApp().preset_bundle->printers.find_preset(preset_name);
|
||||||
std::string full_name = it->get_full_name(preset_name);
|
std::string full_name = it->get_full_name(preset_name);
|
||||||
@@ -385,8 +393,7 @@ void PrinterWebView::SetPresetChanged(bool status) {
|
|||||||
//BOOST_LOG_TRIVIAL(error) << (it->get_short_name(full_name));
|
//BOOST_LOG_TRIVIAL(error) << (it->get_short_name(full_name));
|
||||||
//BOOST_LOG_TRIVIAL(error) << (it->get_preset_name(full_name));
|
//BOOST_LOG_TRIVIAL(error) << (it->get_preset_name(full_name));
|
||||||
//BOOST_LOG_TRIVIAL(error) << model_id;
|
//BOOST_LOG_TRIVIAL(error) << model_id;
|
||||||
AddButton((it->get_short_name(full_name)), host, model_id, full_name, is_selected,
|
AddButton((it->get_short_name(full_name)), host, model_id, full_name, is_selected, (host_type == htMoonraker), apikey);
|
||||||
(host_type == htMoonraker));
|
|
||||||
m_exit_host.insert(host);
|
m_exit_host.insert(host);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -399,47 +406,42 @@ void PrinterWebView::SetPresetChanged(bool status) {
|
|||||||
AddNetButton(device);
|
AddNetButton(device);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (m_isNetMode)
|
||||||
|
ShowNetPrinterButton();
|
||||||
|
else
|
||||||
|
ShowLocalPrinterButton();
|
||||||
//y3
|
//y3
|
||||||
if (webisNetMode == isNetWeb) {
|
if (webisNetMode == isNetWeb) {
|
||||||
ShowNetPrinterButton();
|
|
||||||
for (DeviceButton* button : m_net_buttons) {
|
for (DeviceButton* button : m_net_buttons) {
|
||||||
if (m_ip == (button->getIPLabel())) {
|
if (m_ip == (button->getIPLabel())) {
|
||||||
button->SetIsSelected(true);
|
button->SetIsSelected(true);
|
||||||
wxCommandEvent event(wxEVT_BUTTON, button->GetId());
|
|
||||||
wxPostEvent(button, event);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toggleBar->SetValue(true);
|
}
|
||||||
m_isNetMode = true;
|
else if (webisNetMode == isLocalWeb)
|
||||||
} else if (webisNetMode == isLocalWeb) {
|
{
|
||||||
ShowLocalPrinterButton();
|
|
||||||
if (m_exit_host.find(into_u8(m_ip)) != m_exit_host.end())
|
if (m_exit_host.find(into_u8(m_ip)) != m_exit_host.end())
|
||||||
{
|
{
|
||||||
for (DeviceButton* button : m_buttons) {
|
for (DeviceButton* button : m_buttons)
|
||||||
if (m_ip == (button->getIPLabel())) {
|
{
|
||||||
|
if (m_ip == (button->getIPLabel()))
|
||||||
|
{
|
||||||
button->SetIsSelected(true);
|
button->SetIsSelected(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toggleBar->SetValue(false);
|
|
||||||
m_isNetMode = false;
|
|
||||||
} else {
|
|
||||||
wxString m_host = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
|
|
||||||
load_disconnect_url(m_host);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_isNetMode)
|
if (m_isNetMode)
|
||||||
{
|
{
|
||||||
ShowNetPrinterButton();
|
|
||||||
wxString m_host = wxString::Format("file://%s/web/qidi/link_missing_connection.html", from_u8(resources_dir()));
|
wxString m_host = wxString::Format("file://%s/web/qidi/link_missing_connection.html", from_u8(resources_dir()));
|
||||||
load_disconnect_url(m_host);
|
load_disconnect_url(m_host);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ShowLocalPrinterButton();
|
|
||||||
wxString m_host = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
|
wxString m_host = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
|
||||||
load_disconnect_url(m_host);
|
load_disconnect_url(m_host);
|
||||||
}
|
}
|
||||||
@@ -501,7 +503,8 @@ void PrinterWebView::AddButton(const wxString & device_name,
|
|||||||
const wxString & machine_type,
|
const wxString & machine_type,
|
||||||
const wxString & fullname,
|
const wxString & fullname,
|
||||||
bool isSelected,
|
bool isSelected,
|
||||||
bool isQIDI)
|
bool isQIDI,
|
||||||
|
const wxString & apikey)
|
||||||
{
|
{
|
||||||
wxString Machine_Name = Machine_Name.Format("%s%s", machine_type, "_thumbnail");
|
wxString Machine_Name = Machine_Name.Format("%s%s", machine_type, "_thumbnail");
|
||||||
|
|
||||||
@@ -509,7 +512,7 @@ void PrinterWebView::AddButton(const wxString & device_name,
|
|||||||
std::pair<wxColour, int>(wxColour(76, 76, 80), StateColor::Hovered),
|
std::pair<wxColour, int>(wxColour(76, 76, 80), StateColor::Hovered),
|
||||||
std::pair<wxColour, int>(wxColour(67, 67, 71), StateColor::Normal));
|
std::pair<wxColour, int>(wxColour(67, 67, 71), StateColor::Normal));
|
||||||
|
|
||||||
DeviceButton *machine_button = new DeviceButton(leftScrolledWindow, fullname, Machine_Name, wxBU_LEFT, wxSize(80, 80), device_name, ip);
|
DeviceButton *machine_button = new DeviceButton(leftScrolledWindow, fullname, Machine_Name, wxBU_LEFT, wxSize(80, 80), device_name, ip, apikey);
|
||||||
machine_button->SetBackgroundColor(mac_btn_bg);
|
machine_button->SetBackgroundColor(mac_btn_bg);
|
||||||
machine_button->SetBorderColor(wxColour(67, 67, 71));
|
machine_button->SetBorderColor(wxColour(67, 67, 71));
|
||||||
machine_button->SetCanFocus(false);
|
machine_button->SetCanFocus(false);
|
||||||
@@ -607,23 +610,32 @@ void PrinterWebView::AddNetButton(const Device device)
|
|||||||
machine_button->Bind(wxEVT_BUTTON, [this, device](wxCommandEvent &event) {
|
machine_button->Bind(wxEVT_BUTTON, [this, device](wxCommandEvent &event) {
|
||||||
//y5
|
//y5
|
||||||
std::string formattedHost;
|
std::string formattedHost;
|
||||||
if (wxGetApp().app_config->get("dark_color_mode") == "1")
|
|
||||||
formattedHost = device.link_url + "&theme=dark";
|
|
||||||
else
|
|
||||||
formattedHost = device.link_url + "&theme=light";
|
|
||||||
|
|
||||||
std::string formattedHost1 = "http://fluidd_" + formattedHost;
|
if (device.isSpecialMachine)
|
||||||
std::string formattedHost2 = "http://fluidd2_" + formattedHost;
|
{
|
||||||
if (formattedHost1 == m_web || formattedHost2 == m_web)
|
if (wxGetApp().app_config->get("dark_color_mode") == "1")
|
||||||
return;
|
formattedHost = device.link_url + "&theme=dark";
|
||||||
|
else
|
||||||
|
formattedHost = device.link_url + "&theme=light";
|
||||||
|
|
||||||
if (m_isfluidd_1) {
|
std::string formattedHost1 = "http://fluidd_" + formattedHost;
|
||||||
formattedHost = "http://fluidd_" + formattedHost;
|
std::string formattedHost2 = "http://fluidd2_" + formattedHost;
|
||||||
m_isfluidd_1 = false;
|
if (formattedHost1 == m_web || formattedHost2 == m_web)
|
||||||
} else {
|
return;
|
||||||
formattedHost = "http://fluidd2_" + formattedHost;
|
|
||||||
m_isfluidd_1 = true;
|
if (m_isfluidd_1) {
|
||||||
|
formattedHost = "http://fluidd_" + formattedHost;
|
||||||
|
m_isfluidd_1 = false;
|
||||||
|
} else {
|
||||||
|
formattedHost = "http://fluidd2_" + formattedHost;
|
||||||
|
m_isfluidd_1 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
formattedHost = "http://" + device.link_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
load_net_url(formattedHost, device.local_ip);
|
load_net_url(formattedHost, device.local_ip);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1056,7 +1068,7 @@ void PrinterWebView::load_url(wxString &url)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (DeviceButton *button : m_buttons) {
|
for (DeviceButton *button : m_buttons) {
|
||||||
if (url == (button->getIPLabel()))
|
if ((button->getIPLabel()).find(m_ip) != std::string::npos)
|
||||||
button->SetIsSelected(true);
|
button->SetIsSelected(true);
|
||||||
else
|
else
|
||||||
button->SetIsSelected(false);
|
button->SetIsSelected(false);
|
||||||
|
|||||||
@@ -94,7 +94,8 @@ public:
|
|||||||
const wxString & machine_type,
|
const wxString & machine_type,
|
||||||
const wxString & fullname,
|
const wxString & fullname,
|
||||||
bool isSelected,
|
bool isSelected,
|
||||||
bool isQIDI);
|
bool isQIDI,
|
||||||
|
const wxString & apikey);
|
||||||
void DeleteButton();
|
void DeleteButton();
|
||||||
void UnSelectedButton();
|
void UnSelectedButton();
|
||||||
void ShowNetPrinterButton();
|
void ShowNetPrinterButton();
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ END_EVENT_TABLE()
|
|||||||
* calling Refresh()/Update().
|
* calling Refresh()/Update().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DeviceButton::DeviceButton(wxString name_text, wxString ip_text) : paddingSize(10, 8), m_name_text(name_text), m_ip_text(ip_text)
|
DeviceButton::DeviceButton(wxString name_text, wxString ip_text, wxString api_text) : paddingSize(10, 8), m_name_text(name_text), m_ip_text(ip_text), m_apikey(api_text)
|
||||||
{
|
{
|
||||||
background_color = StateColor(
|
background_color = StateColor(
|
||||||
std::make_pair(0x262629, (int) StateColor::Disabled),
|
std::make_pair(0x262629, (int) StateColor::Disabled),
|
||||||
@@ -37,13 +37,14 @@ DeviceButton::DeviceButton(wxString name_text, wxString ip_text) : paddingSize(1
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeviceButton::DeviceButton(wxWindow *parent,
|
DeviceButton::DeviceButton(wxWindow *parent,
|
||||||
wxString text,
|
wxString text,
|
||||||
wxString icon,
|
wxString icon,
|
||||||
long style,
|
long style,
|
||||||
wxSize iconSize /* = wxSize(16, 16)*/,
|
wxSize iconSize /* = wxSize(16, 16)*/,
|
||||||
wxString name_text,
|
wxString name_text,
|
||||||
wxString ip_text)
|
wxString ip_text,
|
||||||
: DeviceButton(name_text,ip_text)
|
wxString api_text)
|
||||||
|
: DeviceButton(name_text,ip_text, api_text)
|
||||||
{
|
{
|
||||||
m_icon_text = icon;
|
m_icon_text = icon;
|
||||||
Create(parent, text, icon, style, iconSize);
|
Create(parent, text, icon, style, iconSize);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "../wxExtensions.hpp"
|
#include "../wxExtensions.hpp"
|
||||||
#include "StaticBox.hpp"
|
#include "StaticBox.hpp"
|
||||||
|
|
||||||
|
|
||||||
class DeviceButton : public StaticBox
|
class DeviceButton : public StaticBox
|
||||||
{
|
{
|
||||||
wxSize textSize;
|
wxSize textSize;
|
||||||
@@ -22,7 +23,7 @@ class DeviceButton : public StaticBox
|
|||||||
static const int buttonHeight = 50;
|
static const int buttonHeight = 50;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DeviceButton(wxString name_text, wxString ip_text);
|
DeviceButton(wxString name_text, wxString ip_text, wxString api_text);
|
||||||
|
|
||||||
DeviceButton(wxWindow *parent,
|
DeviceButton(wxWindow *parent,
|
||||||
wxString text,
|
wxString text,
|
||||||
@@ -30,7 +31,8 @@ public:
|
|||||||
long style = 0,
|
long style = 0,
|
||||||
wxSize iconSize = wxSize(16, 16),
|
wxSize iconSize = wxSize(16, 16),
|
||||||
wxString name_text = "",
|
wxString name_text = "",
|
||||||
wxString ip_text = "");
|
wxString ip_text = "",
|
||||||
|
wxString api_text = "");
|
||||||
//y3
|
//y3
|
||||||
DeviceButton(wxWindow *parent, wxString icon, long style);
|
DeviceButton(wxWindow *parent, wxString icon, long style);
|
||||||
|
|
||||||
@@ -76,6 +78,7 @@ public:
|
|||||||
|
|
||||||
wxString GetStateText() { return m_state_text; }
|
wxString GetStateText() { return m_state_text; }
|
||||||
|
|
||||||
|
wxString GetApikey() { return m_apikey; };
|
||||||
|
|
||||||
void Rescale();
|
void Rescale();
|
||||||
|
|
||||||
@@ -108,6 +111,7 @@ private:
|
|||||||
wxString m_progress_text = "(0%)";
|
wxString m_progress_text = "(0%)";
|
||||||
bool m_isSimpleMode = true;
|
bool m_isSimpleMode = true;
|
||||||
bool m_isSelected = false;
|
bool m_isSelected = false;
|
||||||
|
wxString m_apikey;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public:
|
|||||||
//B45
|
//B45
|
||||||
virtual std::string get_status(wxString &curl_msg) const override { return "1"; };
|
virtual std::string get_status(wxString &curl_msg) const override { return "1"; };
|
||||||
virtual float get_progress(wxString &curl_msg) const override { return 1; };
|
virtual float get_progress(wxString &curl_msg) const override { return 1; };
|
||||||
|
virtual std::pair<std::string, float> get_status_progress(wxString &curl_msg) const override { return std::make_pair("1", 1); };
|
||||||
|
|
||||||
wxString get_test_ok_msg () const override;
|
wxString get_test_ok_msg () const override;
|
||||||
wxString get_test_failed_msg (wxString &msg) const override;
|
wxString get_test_failed_msg (wxString &msg) const override;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ public:
|
|||||||
//B45
|
//B45
|
||||||
virtual std::string get_status(wxString &curl_msg) const override { return "1"; };
|
virtual std::string get_status(wxString &curl_msg) const override { return "1"; };
|
||||||
virtual float get_progress(wxString &curl_msg) const override { return 1; };
|
virtual float get_progress(wxString &curl_msg) const override { return 1; };
|
||||||
|
virtual std::pair<std::string, float> get_status_progress(wxString &curl_msg) const override { return std::make_pair("1", 1); };
|
||||||
|
|
||||||
wxString get_test_ok_msg() const override;
|
wxString get_test_ok_msg() const override;
|
||||||
wxString get_test_failed_msg(wxString &msg) const override;
|
wxString get_test_failed_msg(wxString &msg) const override;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ public:
|
|||||||
//B45
|
//B45
|
||||||
virtual std::string get_status(wxString &curl_msg) const override { return "1"; };
|
virtual std::string get_status(wxString &curl_msg) const override { return "1"; };
|
||||||
virtual float get_progress(wxString &curl_msg) const override { return 1; };
|
virtual float get_progress(wxString &curl_msg) const override { return 1; };
|
||||||
|
virtual std::pair<std::string, float> get_status_progress(wxString &curl_msg) const override { return std::make_pair("1", 1); };
|
||||||
|
|
||||||
wxString get_test_ok_msg() const override;
|
wxString get_test_ok_msg() const override;
|
||||||
wxString get_test_failed_msg(wxString &msg) const override;
|
wxString get_test_failed_msg(wxString &msg) const override;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public:
|
|||||||
//B45
|
//B45
|
||||||
virtual std::string get_status(wxString &curl_msg) const override { return "1"; };
|
virtual std::string get_status(wxString &curl_msg) const override { return "1"; };
|
||||||
virtual float get_progress(wxString &curl_msg) const override { return 1; };
|
virtual float get_progress(wxString &curl_msg) const override { return 1; };
|
||||||
|
virtual std::pair<std::string, float> get_status_progress(wxString &curl_msg) const override { return std::make_pair("1", 1); };
|
||||||
|
|
||||||
wxString get_test_ok_msg() const override;
|
wxString get_test_ok_msg() const override;
|
||||||
wxString get_test_failed_msg(wxString& msg) const override;
|
wxString get_test_failed_msg(wxString& msg) const override;
|
||||||
|
|||||||
@@ -294,6 +294,82 @@ float Moonraker::get_progress(wxString &msg) const
|
|||||||
return process;
|
return process;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::pair<std::string, float> Moonraker::get_status_progress(wxString &msg) const
|
||||||
|
{
|
||||||
|
// GET /server/info
|
||||||
|
|
||||||
|
// Since the request is performed synchronously here,
|
||||||
|
// it is ok to refer to `msg` from within the closure
|
||||||
|
const char *name = get_name();
|
||||||
|
|
||||||
|
bool res = true;
|
||||||
|
std::string print_state = "standby";
|
||||||
|
float process = 0;
|
||||||
|
auto url = make_url("printer/objects/query?print_stats=state&display_status=progress");
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get version at: %2%") % name % url;
|
||||||
|
|
||||||
|
auto http = Http::get(std::move(url));
|
||||||
|
set_auth(http);
|
||||||
|
// B64 //y6
|
||||||
|
http.timeout_connect(4)
|
||||||
|
.on_error([&](std::string body, std::string error, unsigned status) {
|
||||||
|
// y1
|
||||||
|
if (status == 404) {
|
||||||
|
body = ("Network connection fails.");
|
||||||
|
if (body.find("AWS") != std::string::npos)
|
||||||
|
body += ("Unable to get required resources from AWS server, please check your network settings.");
|
||||||
|
else
|
||||||
|
body += ("Unable to get required resources from Aliyun server, please check your network settings.");
|
||||||
|
}
|
||||||
|
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting version: %2%, HTTP %3%, body: `%4%`") % name % error % status %
|
||||||
|
body;
|
||||||
|
print_state = "offline";
|
||||||
|
msg = format_error(body, error, status);
|
||||||
|
})
|
||||||
|
.on_complete([&](std::string body, unsigned) {
|
||||||
|
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: Got print_stats and process: %2%") % name % body;
|
||||||
|
try {
|
||||||
|
// All successful HTTP requests will return a json encoded object in the form of :
|
||||||
|
// {result: <response data>}
|
||||||
|
std::stringstream ss(body);
|
||||||
|
pt::ptree ptree;
|
||||||
|
pt::read_json(ss, ptree);
|
||||||
|
if (ptree.front().first != "result") {
|
||||||
|
msg = "Could not parse server response";
|
||||||
|
print_state = "offline";
|
||||||
|
process = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!ptree.front().second.get_optional<std::string>("status")) {
|
||||||
|
msg = "Could not parse server response";
|
||||||
|
print_state = "offline";
|
||||||
|
process = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
print_state = ptree.get<std::string>("result.status.print_stats.state");
|
||||||
|
process = std::stof(ptree.get<std::string>("result.status.display_status.progress"));
|
||||||
|
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Got state: %2%") % name % print_state;
|
||||||
|
;
|
||||||
|
} catch (const std::exception &) {
|
||||||
|
print_state = "offline";
|
||||||
|
process = 0;
|
||||||
|
msg = "Could not parse server response";
|
||||||
|
}
|
||||||
|
})
|
||||||
|
#ifdef _WIN32
|
||||||
|
.ssl_revoke_best_effort(m_ssl_revoke_best_effort)
|
||||||
|
.on_ip_resolve([&](std::string address) {
|
||||||
|
// Workaround for Windows 10/11 mDNS resolve issue, where two mDNS resolves in succession fail.
|
||||||
|
// Remember resolved address to be reused at successive REST API call.
|
||||||
|
msg = GUI::from_u8(address);
|
||||||
|
})
|
||||||
|
#endif // _WIN32
|
||||||
|
.perform_sync();
|
||||||
|
|
||||||
|
return std::make_pair(print_state, process);
|
||||||
|
}
|
||||||
|
|
||||||
bool Moonraker::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const
|
bool Moonraker::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const
|
||||||
{
|
{
|
||||||
// POST /server/files/upload
|
// POST /server/files/upload
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ public:
|
|||||||
//B45
|
//B45
|
||||||
virtual std::string get_status(wxString &curl_msg) const override;
|
virtual std::string get_status(wxString &curl_msg) const override;
|
||||||
virtual float get_progress(wxString &curl_msg) const override;
|
virtual float get_progress(wxString &curl_msg) const override;
|
||||||
|
virtual std::pair<std::string, float> get_status_progress(wxString &curl_msg) const override;
|
||||||
|
|
||||||
wxString get_test_ok_msg () const override;
|
wxString get_test_ok_msg () const override;
|
||||||
wxString get_test_failed_msg (wxString &msg) const override;
|
wxString get_test_failed_msg (wxString &msg) const override;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
//B45
|
//B45
|
||||||
virtual std::string get_status(wxString &curl_msg) const override { return "1"; };
|
virtual std::string get_status(wxString &curl_msg) const override { return "1"; };
|
||||||
virtual float get_progress(wxString &curl_msg) const override { return 1; };
|
virtual float get_progress(wxString &curl_msg) const override { return 1; };
|
||||||
|
virtual std::pair<std::string, float> get_status_progress(wxString &curl_msg) const override { return std::make_pair("1", 1); };
|
||||||
|
|
||||||
wxString get_test_ok_msg () const override;
|
wxString get_test_ok_msg () const override;
|
||||||
wxString get_test_failed_msg (wxString &msg) const override;
|
wxString get_test_failed_msg (wxString &msg) const override;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config)
|
|||||||
|
|
||||||
if (tech == ptFFF) {
|
if (tech == ptFFF) {
|
||||||
const auto opt = config->option<ConfigOptionEnum<PrintHostType>>("host_type");
|
const auto opt = config->option<ConfigOptionEnum<PrintHostType>>("host_type");
|
||||||
const auto host_type = opt != nullptr ? opt->value : htOctoPrint;
|
const auto host_type = opt != nullptr ? opt->value : htMoonraker;
|
||||||
|
|
||||||
//B55
|
//B55
|
||||||
switch (host_type) {
|
switch (host_type) {
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
//B45
|
//B45
|
||||||
virtual std::string get_status(wxString &curl_msg) const = 0;
|
virtual std::string get_status(wxString &curl_msg) const = 0;
|
||||||
virtual float get_progress(wxString &curl_msg) const = 0;
|
virtual float get_progress(wxString &curl_msg) const = 0;
|
||||||
|
virtual std::pair<std::string, float> get_status_progress(wxString &curl_msg) const = 0;
|
||||||
virtual wxString get_test_ok_msg () const = 0;
|
virtual wxString get_test_ok_msg () const = 0;
|
||||||
virtual wxString get_test_failed_msg (wxString &msg) const = 0;
|
virtual wxString get_test_failed_msg (wxString &msg) const = 0;
|
||||||
virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const = 0;
|
virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const = 0;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public:
|
|||||||
//B45
|
//B45
|
||||||
virtual std::string get_status(wxString &curl_msg) const override { return "1"; };
|
virtual std::string get_status(wxString &curl_msg) const override { return "1"; };
|
||||||
virtual float get_progress(wxString &curl_msg) const override { return 1; };
|
virtual float get_progress(wxString &curl_msg) const override { return 1; };
|
||||||
|
virtual std::pair<std::string, float> get_status_progress(wxString &curl_msg) const override { return std::make_pair("1", 1); };
|
||||||
wxString get_test_ok_msg () const override;
|
wxString get_test_ok_msg () const override;
|
||||||
wxString get_test_failed_msg (wxString &msg) const override;
|
wxString get_test_failed_msg (wxString &msg) const override;
|
||||||
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const override;
|
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn, InfoFn info_fn) const override;
|
||||||
|
|||||||
Reference in New Issue
Block a user