Start Simulation for Duet
Author: Martin Loidl <martin.loidl@gmail.com> * PrintHost can now return a set of possible actions to be done after a upload is finished * Added new Button for starting a simulation after upload * Duet Hosts are now able to start a simulation after upload instead of starting a print * removed now unneeded config key 'printhost_print'
This commit is contained in:
parent
03a6a46dce
commit
8967ee57ed
@ -6122,11 +6122,12 @@ void Plater::send_gcode()
|
|||||||
upload_job.printhost->get_groups(groups);
|
upload_job.printhost->get_groups(groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintHostSendDialog dlg(default_output_file, upload_job.printhost->can_start_print(), groups);
|
PrintHostSendDialog dlg(default_output_file, upload_job.printhost->get_post_upload_actions(), groups);
|
||||||
if (dlg.ShowModal() == wxID_OK) {
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
upload_job.upload_data.upload_path = dlg.filename();
|
upload_job.upload_data.upload_path = dlg.filename();
|
||||||
upload_job.upload_data.start_print = dlg.start_print();
|
upload_job.upload_data.post_action = dlg.post_action();
|
||||||
upload_job.upload_data.group = dlg.group();
|
upload_job.upload_data.group = dlg.group();
|
||||||
|
|
||||||
p->export_gcode(fs::path(), false, std::move(upload_job));
|
p->export_gcode(fs::path(), false, std::move(upload_job));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
#include "MsgDialog.hpp"
|
#include "MsgDialog.hpp"
|
||||||
#include "I18N.hpp"
|
#include "I18N.hpp"
|
||||||
#include "../Utils/PrintHost.hpp"
|
|
||||||
#include "MainFrame.hpp"
|
#include "MainFrame.hpp"
|
||||||
#include "libslic3r/AppConfig.hpp"
|
#include "libslic3r/AppConfig.hpp"
|
||||||
#include "NotificationManager.hpp"
|
#include "NotificationManager.hpp"
|
||||||
@ -35,13 +34,13 @@ namespace Slic3r {
|
|||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
static const char *CONFIG_KEY_PATH = "printhost_path";
|
static const char *CONFIG_KEY_PATH = "printhost_path";
|
||||||
static const char *CONFIG_KEY_PRINT = "printhost_print";
|
|
||||||
static const char *CONFIG_KEY_GROUP = "printhost_group";
|
static const char *CONFIG_KEY_GROUP = "printhost_group";
|
||||||
|
|
||||||
PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, bool can_start_print, const wxArrayString &groups)
|
PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUploadActions post_actions, const wxArrayString &groups)
|
||||||
: MsgDialog(static_cast<wxWindow*>(wxGetApp().mainframe), _L("Send G-Code to printer host"), _L("Upload to Printer Host with the following filename:"))
|
: MsgDialog(static_cast<wxWindow*>(wxGetApp().mainframe), _L("Send G-Code to printer host"), _L("Upload to Printer Host with the following filename:"))
|
||||||
, txt_filename(new wxTextCtrl(this, wxID_ANY))
|
, txt_filename(new wxTextCtrl(this, wxID_ANY))
|
||||||
, combo_groups(!groups.IsEmpty() ? new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, groups, wxCB_READONLY) : nullptr)
|
, combo_groups(!groups.IsEmpty() ? new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, groups, wxCB_READONLY) : nullptr)
|
||||||
|
, post_upload_action(PrintHostPostUploadAction::None)
|
||||||
{
|
{
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
txt_filename->OSXDisableAllSmartSubstitutions();
|
txt_filename->OSXDisableAllSmartSubstitutions();
|
||||||
@ -77,37 +76,46 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, bool can_start_pr
|
|||||||
txt_filename->SetValue(recent_path);
|
txt_filename->SetValue(recent_path);
|
||||||
txt_filename->SetFocus();
|
txt_filename->SetFocus();
|
||||||
|
|
||||||
wxString suffix = recent_path.substr(recent_path.find_last_of('.'));
|
m_valid_suffix = recent_path.substr(recent_path.find_last_of('.'));
|
||||||
|
// .gcode suffix control
|
||||||
|
auto validate_path = [this](const wxString &path) -> bool {
|
||||||
|
if (! path.Lower().EndsWith(m_valid_suffix.Lower())) {
|
||||||
|
MessageDialog msg_wingow(this, wxString::Format(_L("Upload filename doesn't end with \"%s\". Do you wish to continue?"), m_valid_suffix), wxString(SLIC3R_APP_NAME), wxYES | wxNO);
|
||||||
|
if (msg_wingow.ShowModal() == wxID_NO)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
if (can_start_print) {
|
if (post_actions.has(PrintHostPostUploadAction::StartPrint)) {
|
||||||
auto* btn_print = add_button(wxID_YES, false, _L("Upload and Print"));
|
auto* btn_print = add_button(wxID_YES, false, _L("Upload and Print"));
|
||||||
btn_print->Bind(wxEVT_BUTTON, [this, suffix](wxCommandEvent&) {
|
btn_print->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) {
|
||||||
wxString path = txt_filename->GetValue();
|
if (validate_path(txt_filename->GetValue())) {
|
||||||
// .gcode suffix control
|
post_upload_action = PrintHostPostUploadAction::StartPrint;
|
||||||
if (!path.Lower().EndsWith(suffix.Lower()))
|
EndDialog(wxID_OK);
|
||||||
{
|
|
||||||
MessageDialog msg_wingow(this, wxString::Format(_L("Upload filename doesn't end with \"%s\". Do you wish to continue?"), suffix), wxString(SLIC3R_APP_NAME), wxYES | wxNO);
|
|
||||||
if (msg_wingow.ShowModal() == wxID_NO)
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
start_print_selected = true;
|
});
|
||||||
EndDialog(wxID_OK);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (post_actions.has(PrintHostPostUploadAction::StartSimulation)) {
|
||||||
|
auto* btn_print = add_button(wxID_YES, false, _L("Upload and Simulate"));
|
||||||
|
btn_print->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) {
|
||||||
|
if (validate_path(txt_filename->GetValue())) {
|
||||||
|
post_upload_action = PrintHostPostUploadAction::StartSimulation;
|
||||||
|
EndDialog(wxID_OK);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
add_button(wxID_CANCEL);
|
add_button(wxID_CANCEL);
|
||||||
|
|
||||||
if (auto* btn_ok = get_button(wxID_OK); btn_ok != NULL) {
|
if (auto* btn_ok = get_button(wxID_OK); btn_ok != NULL) {
|
||||||
btn_ok->SetLabel(_L("Upload"));
|
btn_ok->SetLabel(_L("Upload"));
|
||||||
btn_ok->Bind(wxEVT_BUTTON, [this, suffix](wxCommandEvent&) {
|
btn_ok->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) {
|
||||||
wxString path = txt_filename->GetValue();
|
if (validate_path(txt_filename->GetValue())) {
|
||||||
// .gcode suffix control
|
post_upload_action = PrintHostPostUploadAction::None;
|
||||||
if (!path.Lower().EndsWith(suffix.Lower()))
|
EndDialog(wxID_OK);
|
||||||
{
|
|
||||||
MessageDialog msg_wingow(this, wxString::Format(_L("Upload filename doesn't end with \"%s\". Do you wish to continue?"), suffix), wxString(SLIC3R_APP_NAME), wxYES | wxNO);
|
|
||||||
if (msg_wingow.ShowModal() == wxID_NO)
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
EndDialog(wxID_OK);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
finalize();
|
finalize();
|
||||||
@ -137,9 +145,9 @@ fs::path PrintHostSendDialog::filename() const
|
|||||||
return into_path(txt_filename->GetValue());
|
return into_path(txt_filename->GetValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrintHostSendDialog::start_print() const
|
PrintHostPostUploadAction PrintHostSendDialog::post_action() const
|
||||||
{
|
{
|
||||||
return start_print_selected;
|
return post_upload_action;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PrintHostSendDialog::group() const
|
std::string PrintHostSendDialog::group() const
|
||||||
@ -165,7 +173,6 @@ void PrintHostSendDialog::EndModal(int ret)
|
|||||||
|
|
||||||
AppConfig *app_config = wxGetApp().app_config;
|
AppConfig *app_config = wxGetApp().app_config;
|
||||||
app_config->set("recent", CONFIG_KEY_PATH, into_u8(path));
|
app_config->set("recent", CONFIG_KEY_PATH, into_u8(path));
|
||||||
app_config->set("recent", CONFIG_KEY_PRINT, start_print() ? "1" : "0");
|
|
||||||
|
|
||||||
if (combo_groups != nullptr) {
|
if (combo_groups != nullptr) {
|
||||||
wxString group = combo_groups->GetValue();
|
wxString group = combo_groups->GetValue();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef slic3r_PrintHostSendDialog_hpp_
|
#ifndef slic3r_PrintHostSendDialog_hpp_
|
||||||
#define slic3r_PrintHostSendDialog_hpp_
|
#define slic3r_PrintHostSendDialog_hpp_
|
||||||
|
|
||||||
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
@ -10,34 +11,32 @@
|
|||||||
|
|
||||||
#include "GUI_Utils.hpp"
|
#include "GUI_Utils.hpp"
|
||||||
#include "MsgDialog.hpp"
|
#include "MsgDialog.hpp"
|
||||||
|
#include "../Utils/PrintHost.hpp"
|
||||||
|
|
||||||
class wxButton;
|
class wxButton;
|
||||||
class wxTextCtrl;
|
class wxTextCtrl;
|
||||||
|
class wxChoice;
|
||||||
class wxComboBox;
|
class wxComboBox;
|
||||||
class wxCheckBox;
|
|
||||||
class wxDataViewListCtrl;
|
class wxDataViewListCtrl;
|
||||||
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
struct PrintHostJob;
|
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
|
|
||||||
class PrintHostSendDialog : public GUI::MsgDialog
|
class PrintHostSendDialog : public GUI::MsgDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PrintHostSendDialog(const boost::filesystem::path &path, bool can_start_print, const wxArrayString& groups);
|
PrintHostSendDialog(const boost::filesystem::path &path, PrintHostPostUploadActions post_actions, const wxArrayString& groups);
|
||||||
boost::filesystem::path filename() const;
|
boost::filesystem::path filename() const;
|
||||||
bool start_print() const;
|
PrintHostPostUploadAction post_action() const;
|
||||||
std::string group() const;
|
std::string group() const;
|
||||||
|
|
||||||
virtual void EndModal(int ret) override;
|
virtual void EndModal(int ret) override;
|
||||||
private:
|
private:
|
||||||
wxTextCtrl *txt_filename;
|
wxTextCtrl *txt_filename;
|
||||||
wxComboBox *combo_groups;
|
wxComboBox *combo_groups;
|
||||||
bool start_print_selected { false };
|
PrintHostPostUploadAction post_upload_action;
|
||||||
|
wxString m_valid_suffix;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,11 +115,11 @@ bool AstroBox::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error
|
|||||||
% url
|
% url
|
||||||
% upload_filename.string()
|
% upload_filename.string()
|
||||||
% upload_parent_path.string()
|
% upload_parent_path.string()
|
||||||
% upload_data.start_print;
|
% (upload_data.post_action == PrintHostPostUploadAction::StartPrint ? "true" : "false");
|
||||||
|
|
||||||
auto http = Http::post(std::move(url));
|
auto http = Http::post(std::move(url));
|
||||||
set_auth(http);
|
set_auth(http);
|
||||||
http.form_add("print", upload_data.start_print ? "true" : "false")
|
http.form_add("print", upload_data.post_action == PrintHostPostUploadAction::StartPrint ? "true" : "false")
|
||||||
.form_add("path", upload_parent_path.string()) // XXX: slashes on windows ???
|
.form_add("path", upload_parent_path.string()) // XXX: slashes on windows ???
|
||||||
.form_add_file("file", upload_data.source_path.string(), upload_filename.string())
|
.form_add_file("file", upload_data.source_path.string(), upload_filename.string())
|
||||||
.on_complete([&](std::string body, unsigned status) {
|
.on_complete([&](std::string body, unsigned status) {
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||||
bool has_auto_discovery() const override { return true; }
|
bool has_auto_discovery() const override { return true; }
|
||||||
bool can_test() const override { return true; }
|
bool can_test() const override { return true; }
|
||||||
bool can_start_print() const override { return true; }
|
PrintHostPostUploadActions get_post_upload_actions() const { return PrintHostPostUploadAction::StartPrint; }
|
||||||
std::string get_host() const override { return host; }
|
std::string get_host() const override { return host; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -67,10 +67,10 @@ bool Duet::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn e
|
|||||||
bool dsf = (connectionType == ConnectionType::dsf);
|
bool dsf = (connectionType == ConnectionType::dsf);
|
||||||
|
|
||||||
auto upload_cmd = get_upload_url(upload_data.upload_path.string(), connectionType);
|
auto upload_cmd = get_upload_url(upload_data.upload_path.string(), connectionType);
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("Duet: Uploading file %1%, filepath: %2%, print: %3%, command: %4%")
|
BOOST_LOG_TRIVIAL(info) << boost::format("Duet: Uploading file %1%, filepath: %2%, post_action: %3%, command: %4%")
|
||||||
% upload_data.source_path
|
% upload_data.source_path
|
||||||
% upload_data.upload_path
|
% upload_data.upload_path
|
||||||
% upload_data.start_print
|
% int(upload_data.post_action)
|
||||||
% upload_cmd;
|
% upload_cmd;
|
||||||
|
|
||||||
auto http = (dsf ? Http::put(std::move(upload_cmd)) : Http::post(std::move(upload_cmd)));
|
auto http = (dsf ? Http::put(std::move(upload_cmd)) : Http::post(std::move(upload_cmd)));
|
||||||
@ -87,9 +87,15 @@ bool Duet::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn e
|
|||||||
BOOST_LOG_TRIVIAL(error) << boost::format("Duet: Request completed but error code was received: %1%") % err_code;
|
BOOST_LOG_TRIVIAL(error) << boost::format("Duet: Request completed but error code was received: %1%") % err_code;
|
||||||
error_fn(format_error(body, L("Unknown error occured"), 0));
|
error_fn(format_error(body, L("Unknown error occured"), 0));
|
||||||
res = false;
|
res = false;
|
||||||
} else if (upload_data.start_print) {
|
} else if (upload_data.post_action == PrintHostPostUploadAction::StartPrint) {
|
||||||
wxString errormsg;
|
wxString errormsg;
|
||||||
res = start_print(errormsg, upload_data.upload_path.string(), connectionType);
|
res = start_print(errormsg, upload_data.upload_path.string(), connectionType, false);
|
||||||
|
if (! res) {
|
||||||
|
error_fn(std::move(errormsg));
|
||||||
|
}
|
||||||
|
} else if (upload_data.post_action == PrintHostPostUploadAction::StartSimulation) {
|
||||||
|
wxString errormsg;
|
||||||
|
res = start_print(errormsg, upload_data.upload_path.string(), connectionType, true);
|
||||||
if (! res) {
|
if (! res) {
|
||||||
error_fn(std::move(errormsg));
|
error_fn(std::move(errormsg));
|
||||||
}
|
}
|
||||||
@ -230,7 +236,7 @@ std::string Duet::timestamp_str() const
|
|||||||
return std::string(buffer);
|
return std::string(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Duet::start_print(wxString &msg, const std::string &filename, ConnectionType connectionType) const
|
bool Duet::start_print(wxString &msg, const std::string &filename, ConnectionType connectionType, bool simulationMode) const
|
||||||
{
|
{
|
||||||
assert(connectionType != ConnectionType::error);
|
assert(connectionType != ConnectionType::error);
|
||||||
|
|
||||||
@ -240,14 +246,18 @@ bool Duet::start_print(wxString &msg, const std::string &filename, ConnectionTyp
|
|||||||
auto url = dsf
|
auto url = dsf
|
||||||
? (boost::format("%1%machine/code")
|
? (boost::format("%1%machine/code")
|
||||||
% get_base_url()).str()
|
% get_base_url()).str()
|
||||||
: (boost::format("%1%rr_gcode?gcode=M32%%20\"0:/gcodes/%2%\"")
|
: (boost::format(simulationMode
|
||||||
|
? "%1%rr_gcode?gcode=M37%%20P\"0:/gcodes/%2%\""
|
||||||
|
: "%1%rr_gcode?gcode=M32%%20\"0:/gcodes/%2%\"")
|
||||||
% get_base_url()
|
% get_base_url()
|
||||||
% Http::url_encode(filename)).str();
|
% Http::url_encode(filename)).str();
|
||||||
|
|
||||||
auto http = (dsf ? Http::post(std::move(url)) : Http::get(std::move(url)));
|
auto http = (dsf ? Http::post(std::move(url)) : Http::get(std::move(url)));
|
||||||
if (dsf) {
|
if (dsf) {
|
||||||
http.set_post_body(
|
http.set_post_body(
|
||||||
(boost::format("M32 \"0:/gcodes/%1%\"")
|
(boost::format(simulationMode
|
||||||
|
? "M37 P\"0:/gcodes/%1%\""
|
||||||
|
: "M32 \"0:/gcodes/%1%\"")
|
||||||
% filename).str()
|
% filename).str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||||
bool has_auto_discovery() const override { return false; }
|
bool has_auto_discovery() const override { return false; }
|
||||||
bool can_test() const override { return true; }
|
bool can_test() const override { return true; }
|
||||||
bool can_start_print() const override { return true; }
|
PrintHostPostUploadActions get_post_upload_actions() const { return PrintHostPostUploadAction::StartPrint | PrintHostPostUploadAction::StartSimulation; }
|
||||||
std::string get_host() const override { return host; }
|
std::string get_host() const override { return host; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -39,7 +39,7 @@ private:
|
|||||||
std::string timestamp_str() const;
|
std::string timestamp_str() const;
|
||||||
ConnectionType connect(wxString &msg) const;
|
ConnectionType connect(wxString &msg) const;
|
||||||
void disconnect(ConnectionType connectionType) const;
|
void disconnect(ConnectionType connectionType) const;
|
||||||
bool start_print(wxString &msg, const std::string &filename, ConnectionType connectionType) const;
|
bool start_print(wxString &msg, const std::string &filename, ConnectionType connectionType, bool simulationMode) const;
|
||||||
int get_err_code_from_body(const std::string &body) const;
|
int get_err_code_from_body(const std::string &body) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||||
bool has_auto_discovery() const override { return false; }
|
bool has_auto_discovery() const override { return false; }
|
||||||
bool can_test() const override { return true; }
|
bool can_test() const override { return true; }
|
||||||
bool can_start_print() const override { return false; }
|
PrintHostPostUploadActions get_post_upload_actions() const { return PrintHostPostUploadAction::StartPrint; }
|
||||||
std::string get_host() const override { return host; }
|
std::string get_host() const override { return host; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -70,7 +70,7 @@ bool MKS::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn er
|
|||||||
BOOST_LOG_TRIVIAL(info) << boost::format("MKS: Uploading file %1%, filepath: %2%, print: %3%, command: %4%")
|
BOOST_LOG_TRIVIAL(info) << boost::format("MKS: Uploading file %1%, filepath: %2%, print: %3%, command: %4%")
|
||||||
% upload_data.source_path
|
% upload_data.source_path
|
||||||
% upload_data.upload_path
|
% upload_data.upload_path
|
||||||
% upload_data.start_print
|
% (upload_data.post_action == PrintHostPostUploadAction::StartPrint)
|
||||||
% upload_cmd;
|
% upload_cmd;
|
||||||
|
|
||||||
auto http = Http::post(std::move(upload_cmd));
|
auto http = Http::post(std::move(upload_cmd));
|
||||||
@ -85,7 +85,7 @@ bool MKS::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn er
|
|||||||
error_fn(format_error(body, L("Unknown error occured"), 0));
|
error_fn(format_error(body, L("Unknown error occured"), 0));
|
||||||
res = false;
|
res = false;
|
||||||
}
|
}
|
||||||
else if (upload_data.start_print) {
|
else if (upload_data.post_action == PrintHostPostUploadAction::StartPrint) {
|
||||||
wxString errormsg;
|
wxString errormsg;
|
||||||
res = start_print(errormsg, upload_data.upload_path.string());
|
res = start_print(errormsg, upload_data.upload_path.string());
|
||||||
if (!res) {
|
if (!res) {
|
||||||
|
@ -25,7 +25,7 @@ public:
|
|||||||
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||||
bool has_auto_discovery() const override { return false; }
|
bool has_auto_discovery() const override { return false; }
|
||||||
bool can_test() const override { return true; }
|
bool can_test() const override { return true; }
|
||||||
bool can_start_print() const override { return true; }
|
PrintHostPostUploadActions get_post_upload_actions() const { return PrintHostPostUploadAction::StartPrint; }
|
||||||
std::string get_host() const override { return m_host; }
|
std::string get_host() const override { return m_host; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -137,11 +137,11 @@ bool OctoPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Erro
|
|||||||
% url
|
% url
|
||||||
% upload_filename.string()
|
% upload_filename.string()
|
||||||
% upload_parent_path.string()
|
% upload_parent_path.string()
|
||||||
% upload_data.start_print;
|
% (upload_data.post_action == PrintHostPostUploadAction::StartPrint ? "true" : "false");
|
||||||
|
|
||||||
auto http = Http::post(std::move(url));
|
auto http = Http::post(std::move(url));
|
||||||
set_auth(http);
|
set_auth(http);
|
||||||
http.form_add("print", upload_data.start_print ? "true" : "false")
|
http.form_add("print", upload_data.post_action == PrintHostPostUploadAction::StartPrint ? "true" : "false")
|
||||||
.form_add("path", upload_parent_path.string()) // XXX: slashes on windows ???
|
.form_add("path", upload_parent_path.string()) // XXX: slashes on windows ???
|
||||||
.form_add_file("file", upload_data.source_path.string(), upload_filename.string())
|
.form_add_file("file", upload_data.source_path.string(), upload_filename.string())
|
||||||
.on_complete([&](std::string body, unsigned status) {
|
.on_complete([&](std::string body, unsigned status) {
|
||||||
|
@ -28,7 +28,7 @@ public:
|
|||||||
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||||
bool has_auto_discovery() const override { return true; }
|
bool has_auto_discovery() const override { return true; }
|
||||||
bool can_test() const override { return true; }
|
bool can_test() const override { return true; }
|
||||||
bool can_start_print() const override { return true; }
|
PrintHostPostUploadActions get_post_upload_actions() const { return PrintHostPostUploadAction::StartPrint; }
|
||||||
std::string get_host() const override { return m_host; }
|
std::string get_host() const override { return m_host; }
|
||||||
const std::string& get_apikey() const { return m_apikey; }
|
const std::string& get_apikey() const { return m_apikey; }
|
||||||
const std::string& get_cafile() const { return m_cafile; }
|
const std::string& get_cafile() const { return m_cafile; }
|
||||||
@ -57,7 +57,7 @@ public:
|
|||||||
|
|
||||||
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 can_start_print() const override { return false; }
|
PrintHostPostUploadActions get_post_upload_actions() const { return {}; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate_version_text(const boost::optional<std::string> &version_text) const override;
|
bool validate_version_text(const boost::optional<std::string> &version_text) const override;
|
||||||
@ -82,7 +82,7 @@ public:
|
|||||||
|
|
||||||
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 can_start_print() const override { return true; }
|
PrintHostPostUploadActions get_post_upload_actions() const { return PrintHostPostUploadAction::StartPrint; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool validate_version_text(const boost::optional<std::string>& version_text) const override;
|
bool validate_version_text(const boost::optional<std::string>& version_text) const override;
|
||||||
|
@ -2,12 +2,14 @@
|
|||||||
#define slic3r_PrintHost_hpp_
|
#define slic3r_PrintHost_hpp_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
|
||||||
#include <wx/string.h>
|
#include <wx/string.h>
|
||||||
|
|
||||||
|
#include <libslic3r/enum_bitmask.hpp>
|
||||||
#include "Http.hpp"
|
#include "Http.hpp"
|
||||||
|
|
||||||
class wxArrayString;
|
class wxArrayString;
|
||||||
@ -16,6 +18,13 @@ namespace Slic3r {
|
|||||||
|
|
||||||
class DynamicPrintConfig;
|
class DynamicPrintConfig;
|
||||||
|
|
||||||
|
enum class PrintHostPostUploadAction {
|
||||||
|
None,
|
||||||
|
StartPrint,
|
||||||
|
StartSimulation
|
||||||
|
};
|
||||||
|
using PrintHostPostUploadActions = enum_bitmask<PrintHostPostUploadAction>;
|
||||||
|
ENABLE_ENUM_BITMASK_OPERATORS(PrintHostPostUploadAction);
|
||||||
|
|
||||||
struct PrintHostUpload
|
struct PrintHostUpload
|
||||||
{
|
{
|
||||||
@ -24,10 +33,9 @@ struct PrintHostUpload
|
|||||||
|
|
||||||
std::string group;
|
std::string group;
|
||||||
|
|
||||||
bool start_print = false;
|
PrintHostPostUploadAction post_action { PrintHostPostUploadAction::None };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class PrintHost
|
class PrintHost
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -44,7 +52,7 @@ public:
|
|||||||
virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const = 0;
|
virtual bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const = 0;
|
||||||
virtual bool has_auto_discovery() const = 0;
|
virtual bool has_auto_discovery() const = 0;
|
||||||
virtual bool can_test() const = 0;
|
virtual bool can_test() const = 0;
|
||||||
virtual bool can_start_print() const = 0;
|
virtual PrintHostPostUploadActions get_post_upload_actions() const = 0;
|
||||||
// A print host usually does not support multiple printers, with the exception of Repetier server.
|
// A print host usually does not support multiple printers, with the exception of Repetier server.
|
||||||
virtual bool supports_multiple_printers() const { return false; }
|
virtual bool supports_multiple_printers() const { return false; }
|
||||||
virtual std::string get_host() const = 0;
|
virtual std::string get_host() const = 0;
|
||||||
|
@ -107,7 +107,9 @@ bool Repetier::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error
|
|||||||
|
|
||||||
bool res = true;
|
bool res = true;
|
||||||
|
|
||||||
auto url = upload_data.start_print?make_url((boost::format("printer/job/%1%") % port).str()):make_url((boost::format("printer/model/%1%") % port).str());
|
auto url = upload_data.post_action == PrintHostPostUploadAction::StartPrint
|
||||||
|
? make_url((boost::format("printer/job/%1%") % port).str())
|
||||||
|
: make_url((boost::format("printer/model/%1%") % port).str());
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Uploading file %2% at %3%, filename: %4%, path: %5%, print: %6%, group: %7%")
|
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Uploading file %2% at %3%, filename: %4%, path: %5%, print: %6%, group: %7%")
|
||||||
% name
|
% name
|
||||||
@ -115,7 +117,7 @@ bool Repetier::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error
|
|||||||
% url
|
% url
|
||||||
% upload_filename.string()
|
% upload_filename.string()
|
||||||
% upload_parent_path.string()
|
% upload_parent_path.string()
|
||||||
% upload_data.start_print
|
% (upload_data.post_action == PrintHostPostUploadAction::StartPrint ? "true" : "false")
|
||||||
% upload_data.group;
|
% upload_data.group;
|
||||||
|
|
||||||
auto http = Http::post(std::move(url));
|
auto http = Http::post(std::move(url));
|
||||||
@ -125,7 +127,7 @@ bool Repetier::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Error
|
|||||||
http.form_add("group", upload_data.group);
|
http.form_add("group", upload_data.group);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(upload_data.start_print) {
|
if(upload_data.post_action == PrintHostPostUploadAction::StartPrint) {
|
||||||
http.form_add("name", upload_filename.string());
|
http.form_add("name", upload_filename.string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include "PrintHost.hpp"
|
#include "PrintHost.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
class DynamicPrintConfig;
|
class DynamicPrintConfig;
|
||||||
@ -27,7 +26,7 @@ public:
|
|||||||
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
bool upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, ErrorFn error_fn) const override;
|
||||||
bool has_auto_discovery() const override { return false; }
|
bool has_auto_discovery() const override { return false; }
|
||||||
bool can_test() const override { return true; }
|
bool can_test() const override { return true; }
|
||||||
bool can_start_print() const override { return true; }
|
PrintHostPostUploadActions get_post_upload_actions() const { return PrintHostPostUploadAction::StartPrint; }
|
||||||
bool supports_multiple_printers() const override { return true; }
|
bool supports_multiple_printers() const override { return true; }
|
||||||
std::string get_host() const override { return host; }
|
std::string get_host() const override { return host; }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user