PrintHost: Basic SL1 support
This commit is contained in:
parent
59b01b4908
commit
66b5deccf5
@ -36,7 +36,7 @@ enum GCodeFlavor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum PrintHostType {
|
enum PrintHostType {
|
||||||
htOctoPrint, htDuet,
|
htOctoPrint, htDuet, htSL1,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum InfillPattern {
|
enum InfillPattern {
|
||||||
|
@ -3244,6 +3244,8 @@ void Plater::on_config_change(const DynamicPrintConfig &config)
|
|||||||
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
|
#endif // ENABLE_REMOVE_TABS_FROM_PLATER
|
||||||
if (p->preview) p->preview->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values);
|
if (p->preview) p->preview->set_bed_shape(p->config->option<ConfigOptionPoints>("bed_shape")->values);
|
||||||
update_scheduled = true;
|
update_scheduled = true;
|
||||||
|
} else if (opt_key == "host_type" && this->p->printer_technology == ptSLA) {
|
||||||
|
p->config->option<ConfigOptionEnum<PrintHostType>>(opt_key)->value = htSL1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,6 +456,7 @@ const std::vector<std::string>& Preset::sla_printer_options()
|
|||||||
"display_width", "display_height", "display_pixels_x", "display_pixels_y",
|
"display_width", "display_height", "display_pixels_x", "display_pixels_y",
|
||||||
"display_orientation",
|
"display_orientation",
|
||||||
"printer_correction",
|
"printer_correction",
|
||||||
|
"print_host", "printhost_apikey", "printhost_cafile",
|
||||||
"printer_notes",
|
"printer_notes",
|
||||||
"inherits"
|
"inherits"
|
||||||
};
|
};
|
||||||
|
@ -1538,6 +1538,108 @@ bool Tab::current_preset_is_dirty()
|
|||||||
return m_presets->current_is_dirty();
|
return m_presets->current_is_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TabPrinter::build_printhost(ConfigOptionsGroup *optgroup)
|
||||||
|
{
|
||||||
|
const bool sla = m_presets->get_selected_preset().printer_technology() == ptSLA;
|
||||||
|
|
||||||
|
// Only offer the host type selection for FFF, for SLA it's always the SL1 printer (at the moment)
|
||||||
|
if (! sla) {
|
||||||
|
optgroup->append_single_option_line("host_type");
|
||||||
|
} else {
|
||||||
|
m_config->option<ConfigOptionEnum<PrintHostType>>("host_type", true)->value = htSL1;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto printhost_browse = [this, optgroup] (wxWindow* parent) {
|
||||||
|
|
||||||
|
// TODO: SLA
|
||||||
|
|
||||||
|
auto btn = m_printhost_browse_btn = new wxButton(parent, wxID_ANY, _(L(" Browse "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
|
||||||
|
btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("zoom.png")), wxBITMAP_TYPE_PNG));
|
||||||
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
sizer->Add(btn);
|
||||||
|
|
||||||
|
btn->Bind(wxEVT_BUTTON, [this, parent, optgroup](wxCommandEvent e) {
|
||||||
|
BonjourDialog dialog(parent);
|
||||||
|
if (dialog.show_and_lookup()) {
|
||||||
|
optgroup->set_value("print_host", std::move(dialog.get_selected()), true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return sizer;
|
||||||
|
};
|
||||||
|
|
||||||
|
auto print_host_test = [this](wxWindow* parent) {
|
||||||
|
auto btn = m_print_host_test_btn = new wxButton(parent, wxID_ANY, _(L("Test")),
|
||||||
|
wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
||||||
|
btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("wrench.png")), wxBITMAP_TYPE_PNG));
|
||||||
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
sizer->Add(btn);
|
||||||
|
|
||||||
|
btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent e) {
|
||||||
|
std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config));
|
||||||
|
if (! host) {
|
||||||
|
const auto text = wxString::Format("%s",
|
||||||
|
_(L("Could not get a valid Printer Host reference")));
|
||||||
|
show_error(this, text);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wxString msg;
|
||||||
|
if (host->test(msg)) {
|
||||||
|
show_info(this, host->get_test_ok_msg(), _(L("Success!")));
|
||||||
|
} else {
|
||||||
|
show_error(this, host->get_test_failed_msg(msg));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return sizer;
|
||||||
|
};
|
||||||
|
|
||||||
|
Line host_line = optgroup->create_single_option_line("print_host");
|
||||||
|
host_line.append_widget(printhost_browse);
|
||||||
|
host_line.append_widget(print_host_test);
|
||||||
|
optgroup->append_line(host_line);
|
||||||
|
optgroup->append_single_option_line("printhost_apikey");
|
||||||
|
|
||||||
|
if (Http::ca_file_supported()) {
|
||||||
|
|
||||||
|
Line cafile_line = optgroup->create_single_option_line("printhost_cafile");
|
||||||
|
|
||||||
|
auto printhost_cafile_browse = [this, optgroup] (wxWindow* parent) {
|
||||||
|
auto btn = new wxButton(parent, wxID_ANY, _(L(" Browse "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
|
||||||
|
btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("zoom.png")), wxBITMAP_TYPE_PNG));
|
||||||
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
sizer->Add(btn);
|
||||||
|
|
||||||
|
btn->Bind(wxEVT_BUTTON, [this, optgroup] (wxCommandEvent e) {
|
||||||
|
static const auto filemasks = _(L("Certificate files (*.crt, *.pem)|*.crt;*.pem|All files|*.*"));
|
||||||
|
wxFileDialog openFileDialog(this, _(L("Open CA certificate file")), "", "", filemasks, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||||
|
if (openFileDialog.ShowModal() != wxID_CANCEL) {
|
||||||
|
optgroup->set_value("printhost_cafile", std::move(openFileDialog.GetPath()), true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return sizer;
|
||||||
|
};
|
||||||
|
|
||||||
|
cafile_line.append_widget(printhost_cafile_browse);
|
||||||
|
optgroup->append_line(cafile_line);
|
||||||
|
|
||||||
|
auto printhost_cafile_hint = [this, optgroup] (wxWindow* parent) {
|
||||||
|
auto txt = new wxStaticText(parent, wxID_ANY,
|
||||||
|
_(L("HTTPS CA file is optional. It is only needed if you use HTTPS with a self-signed certificate.")));
|
||||||
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
sizer->Add(txt);
|
||||||
|
return sizer;
|
||||||
|
};
|
||||||
|
|
||||||
|
Line cafile_hint { "", "" };
|
||||||
|
cafile_hint.full_width = 1;
|
||||||
|
cafile_hint.widget = std::move(printhost_cafile_hint);
|
||||||
|
optgroup->append_line(cafile_hint);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TabPrinter::build()
|
void TabPrinter::build()
|
||||||
{
|
{
|
||||||
m_presets = &m_preset_bundle->printers;
|
m_presets = &m_preset_bundle->printers;
|
||||||
@ -1665,96 +1767,8 @@ void TabPrinter::build_fff()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
optgroup = page->new_optgroup(_(L("Printer Host upload")));
|
optgroup = page->new_optgroup(_(L("Print Host upload")));
|
||||||
|
build_printhost(optgroup.get());
|
||||||
optgroup->append_single_option_line("host_type");
|
|
||||||
|
|
||||||
auto printhost_browse = [this, optgroup] (wxWindow* parent) {
|
|
||||||
auto btn = m_printhost_browse_btn = new wxButton(parent, wxID_ANY, _(L(" Browse "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
|
|
||||||
btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("zoom.png")), wxBITMAP_TYPE_PNG));
|
|
||||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
||||||
sizer->Add(btn);
|
|
||||||
|
|
||||||
btn->Bind(wxEVT_BUTTON, [this, parent, optgroup](wxCommandEvent e) {
|
|
||||||
BonjourDialog dialog(parent);
|
|
||||||
if (dialog.show_and_lookup()) {
|
|
||||||
optgroup->set_value("print_host", std::move(dialog.get_selected()), true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return sizer;
|
|
||||||
};
|
|
||||||
|
|
||||||
auto print_host_test = [this](wxWindow* parent) {
|
|
||||||
auto btn = m_print_host_test_btn = new wxButton(parent, wxID_ANY, _(L("Test")),
|
|
||||||
wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
|
|
||||||
btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("wrench.png")), wxBITMAP_TYPE_PNG));
|
|
||||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
||||||
sizer->Add(btn);
|
|
||||||
|
|
||||||
btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent e) {
|
|
||||||
std::unique_ptr<PrintHost> host(PrintHost::get_print_host(m_config));
|
|
||||||
if (! host) {
|
|
||||||
const auto text = wxString::Format("%s",
|
|
||||||
_(L("Could not get a valid Printer Host reference")));
|
|
||||||
show_error(this, text);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
wxString msg;
|
|
||||||
if (host->test(msg)) {
|
|
||||||
show_info(this, host->get_test_ok_msg(), _(L("Success!")));
|
|
||||||
} else {
|
|
||||||
show_error(this, host->get_test_failed_msg(msg));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return sizer;
|
|
||||||
};
|
|
||||||
|
|
||||||
Line host_line = optgroup->create_single_option_line("print_host");
|
|
||||||
host_line.append_widget(printhost_browse);
|
|
||||||
host_line.append_widget(print_host_test);
|
|
||||||
optgroup->append_line(host_line);
|
|
||||||
optgroup->append_single_option_line("printhost_apikey");
|
|
||||||
|
|
||||||
if (Http::ca_file_supported()) {
|
|
||||||
|
|
||||||
Line cafile_line = optgroup->create_single_option_line("printhost_cafile");
|
|
||||||
|
|
||||||
auto printhost_cafile_browse = [this, optgroup] (wxWindow* parent) {
|
|
||||||
auto btn = new wxButton(parent, wxID_ANY, _(L(" Browse "))+dots, wxDefaultPosition, wxDefaultSize, wxBU_LEFT);
|
|
||||||
btn->SetBitmap(wxBitmap(from_u8(Slic3r::var("zoom.png")), wxBITMAP_TYPE_PNG));
|
|
||||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
||||||
sizer->Add(btn);
|
|
||||||
|
|
||||||
btn->Bind(wxEVT_BUTTON, [this, optgroup] (wxCommandEvent e) {
|
|
||||||
static const auto filemasks = _(L("Certificate files (*.crt, *.pem)|*.crt;*.pem|All files|*.*"));
|
|
||||||
wxFileDialog openFileDialog(this, _(L("Open CA certificate file")), "", "", filemasks, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
|
||||||
if (openFileDialog.ShowModal() != wxID_CANCEL) {
|
|
||||||
optgroup->set_value("printhost_cafile", std::move(openFileDialog.GetPath()), true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return sizer;
|
|
||||||
};
|
|
||||||
|
|
||||||
cafile_line.append_widget(printhost_cafile_browse);
|
|
||||||
optgroup->append_line(cafile_line);
|
|
||||||
|
|
||||||
auto printhost_cafile_hint = [this, optgroup] (wxWindow* parent) {
|
|
||||||
auto txt = new wxStaticText(parent, wxID_ANY,
|
|
||||||
_(L("HTTPS CA file is optional. It is only needed if you use HTTPS with a self-signed certificate.")));
|
|
||||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
|
||||||
sizer->Add(txt);
|
|
||||||
return sizer;
|
|
||||||
};
|
|
||||||
|
|
||||||
Line cafile_hint { "", "" };
|
|
||||||
cafile_hint.full_width = 1;
|
|
||||||
cafile_hint.widget = std::move(printhost_cafile_hint);
|
|
||||||
optgroup->append_line(cafile_hint);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
optgroup = page->new_optgroup(_(L("Firmware")));
|
optgroup = page->new_optgroup(_(L("Firmware")));
|
||||||
optgroup->append_single_option_line("gcode_flavor");
|
optgroup->append_single_option_line("gcode_flavor");
|
||||||
@ -1897,6 +1911,9 @@ void TabPrinter::build_sla()
|
|||||||
}
|
}
|
||||||
optgroup->append_line(line);
|
optgroup->append_line(line);
|
||||||
|
|
||||||
|
optgroup = page->new_optgroup(_(L("Print Host upload")));
|
||||||
|
build_printhost(optgroup.get());
|
||||||
|
|
||||||
page = add_options_page(_(L("Notes")), "note.png");
|
page = add_options_page(_(L("Notes")), "note.png");
|
||||||
optgroup = page->new_optgroup(_(L("Notes")), 0);
|
optgroup = page->new_optgroup(_(L("Notes")), 0);
|
||||||
option = optgroup->get_option("printer_notes");
|
option = optgroup->get_option("printer_notes");
|
||||||
|
@ -325,6 +325,8 @@ class TabPrinter : public Tab
|
|||||||
|
|
||||||
std::vector<PageShp> m_pages_fff;
|
std::vector<PageShp> m_pages_fff;
|
||||||
std::vector<PageShp> m_pages_sla;
|
std::vector<PageShp> m_pages_sla;
|
||||||
|
|
||||||
|
void build_printhost(ConfigOptionsGroup *optgroup);
|
||||||
public:
|
public:
|
||||||
wxButton* m_serial_test_btn = nullptr;
|
wxButton* m_serial_test_btn = nullptr;
|
||||||
wxButton* m_print_host_test_btn = nullptr;
|
wxButton* m_print_host_test_btn = nullptr;
|
||||||
|
@ -43,6 +43,9 @@ bool OctoPrint::test(wxString &msg) const
|
|||||||
})
|
})
|
||||||
.on_complete([&](std::string body, unsigned) {
|
.on_complete([&](std::string body, unsigned) {
|
||||||
BOOST_LOG_TRIVIAL(debug) << boost::format("Octoprint: Got version: %1%") % body;
|
BOOST_LOG_TRIVIAL(debug) << boost::format("Octoprint: Got version: %1%") % body;
|
||||||
|
|
||||||
|
// TODO: parse body, call validate_version_text
|
||||||
|
|
||||||
})
|
})
|
||||||
.perform_sync();
|
.perform_sync();
|
||||||
|
|
||||||
@ -122,6 +125,12 @@ bool OctoPrint::can_test() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OctoPrint::validate_version_text(const std::string &version_text)
|
||||||
|
{
|
||||||
|
// FIXME
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void OctoPrint::set_auth(Http &http) const
|
void OctoPrint::set_auth(Http &http) const
|
||||||
{
|
{
|
||||||
http.header("X-Api-Key", apikey);
|
http.header("X-Api-Key", apikey);
|
||||||
@ -155,4 +164,15 @@ wxString OctoPrint::format_error(const std::string &body, const std::string &err
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// SL1
|
||||||
|
|
||||||
|
SL1Host::~SL1Host() {}
|
||||||
|
|
||||||
|
bool SL1Host::validate_version_text(const std::string &version_text)
|
||||||
|
{
|
||||||
|
// FIXME
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,10 @@ public:
|
|||||||
bool has_auto_discovery() const;
|
bool has_auto_discovery() const;
|
||||||
bool can_test() const;
|
bool can_test() const;
|
||||||
virtual std::string get_host() const { return host; }
|
virtual std::string get_host() const { return host; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool validate_version_text(const std::string &version_text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string host;
|
std::string host;
|
||||||
std::string apikey;
|
std::string apikey;
|
||||||
@ -37,6 +41,17 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class SL1Host: public OctoPrint
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SL1Host(DynamicPrintConfig *config) : OctoPrint(config) {}
|
||||||
|
virtual ~SL1Host();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool validate_version_text(const std::string &version_text);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,13 +24,15 @@ PrintHost::~PrintHost() {}
|
|||||||
|
|
||||||
PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config)
|
PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config)
|
||||||
{
|
{
|
||||||
PrintHostType kind = config->option<ConfigOptionEnum<PrintHostType>>("host_type")->value;
|
const auto opt = config->option<ConfigOptionEnum<PrintHostType>>("host_type");
|
||||||
if (kind == htOctoPrint) {
|
if (opt == nullptr) { return nullptr; }
|
||||||
return new OctoPrint(config);
|
|
||||||
} else if (kind == htDuet) {
|
switch (opt->value) {
|
||||||
return new Duet(config);
|
case htOctoPrint: return new OctoPrint(config);
|
||||||
|
case htSL1: return new SL1Host(config);
|
||||||
|
case htDuet: return new Duet(config);
|
||||||
|
default: return nullptr;
|
||||||
}
|
}
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user