mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 12:05:54 +08:00
PrusaLink class
This commit is contained in:
parent
51f33ddf98
commit
725e60d006
@ -1541,18 +1541,20 @@ void PrintConfigDef::init_fff_params()
|
|||||||
def->tooltip = L("Slic3r can upload G-code files to a printer host. This field must contain "
|
def->tooltip = L("Slic3r can upload G-code files to a printer host. This field must contain "
|
||||||
"the kind of the host.");
|
"the kind of the host.");
|
||||||
def->enum_keys_map = &ConfigOptionEnum<PrintHostType>::get_enum_values();
|
def->enum_keys_map = &ConfigOptionEnum<PrintHostType>::get_enum_values();
|
||||||
|
def->enum_values.push_back("prusalink");
|
||||||
def->enum_values.push_back("octoprint");
|
def->enum_values.push_back("octoprint");
|
||||||
def->enum_values.push_back("duet");
|
def->enum_values.push_back("duet");
|
||||||
def->enum_values.push_back("flashair");
|
def->enum_values.push_back("flashair");
|
||||||
def->enum_values.push_back("astrobox");
|
def->enum_values.push_back("astrobox");
|
||||||
def->enum_values.push_back("repetier");
|
def->enum_values.push_back("repetier");
|
||||||
|
def->enum_labels.push_back("PrusaLink");
|
||||||
def->enum_labels.push_back("OctoPrint");
|
def->enum_labels.push_back("OctoPrint");
|
||||||
def->enum_labels.push_back("Duet");
|
def->enum_labels.push_back("Duet");
|
||||||
def->enum_labels.push_back("FlashAir");
|
def->enum_labels.push_back("FlashAir");
|
||||||
def->enum_labels.push_back("AstroBox");
|
def->enum_labels.push_back("AstroBox");
|
||||||
def->enum_labels.push_back("Repetier");
|
def->enum_labels.push_back("Repetier");
|
||||||
def->mode = comAdvanced;
|
def->mode = comAdvanced;
|
||||||
def->set_default_value(new ConfigOptionEnum<PrintHostType>(htOctoPrint));
|
def->set_default_value(new ConfigOptionEnum<PrintHostType>(/*htOctoPrint*/htPrusaLink));
|
||||||
|
|
||||||
def = this->add("only_retract_when_crossing_perimeters", coBool);
|
def = this->add("only_retract_when_crossing_perimeters", coBool);
|
||||||
def->label = L("Only retract when crossing perimeters");
|
def->label = L("Only retract when crossing perimeters");
|
||||||
|
@ -36,7 +36,7 @@ enum class MachineLimitsUsage {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum PrintHostType {
|
enum PrintHostType {
|
||||||
htOctoPrint, htDuet, htFlashAir, htAstroBox, htRepetier
|
htPrusaLink, htOctoPrint, htDuet, htFlashAir, htAstroBox, htRepetier
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AuthorizationType {
|
enum AuthorizationType {
|
||||||
@ -122,11 +122,13 @@ template<> inline const t_config_enum_values& ConfigOptionEnum<MachineLimitsUsag
|
|||||||
template<> inline const t_config_enum_values& ConfigOptionEnum<PrintHostType>::get_enum_values() {
|
template<> inline const t_config_enum_values& ConfigOptionEnum<PrintHostType>::get_enum_values() {
|
||||||
static t_config_enum_values keys_map;
|
static t_config_enum_values keys_map;
|
||||||
if (keys_map.empty()) {
|
if (keys_map.empty()) {
|
||||||
|
keys_map["prusalink"] = htPrusaLink;
|
||||||
keys_map["octoprint"] = htOctoPrint;
|
keys_map["octoprint"] = htOctoPrint;
|
||||||
keys_map["duet"] = htDuet;
|
keys_map["duet"] = htDuet;
|
||||||
keys_map["flashair"] = htFlashAir;
|
keys_map["flashair"] = htFlashAir;
|
||||||
keys_map["astrobox"] = htAstroBox;
|
keys_map["astrobox"] = htAstroBox;
|
||||||
keys_map["repetier"] = htRepetier;
|
keys_map["repetier"] = htRepetier;
|
||||||
|
|
||||||
}
|
}
|
||||||
return keys_map;
|
return keys_map;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,8 @@ PresetForPrinter::PresetForPrinter(PhysicalPrinterDialog* parent, const std::str
|
|||||||
if (preset->name == edited_preset.name)
|
if (preset->name == edited_preset.name)
|
||||||
preset = &edited_preset;
|
preset = &edited_preset;
|
||||||
|
|
||||||
|
m_parent->selected_preset_changed(preset->name);
|
||||||
|
|
||||||
// if created physical printer doesn't have any settings, use the settings from the selected preset
|
// if created physical printer doesn't have any settings, use the settings from the selected preset
|
||||||
if (m_parent->get_printer()->has_empty_config()) {
|
if (m_parent->get_printer()->has_empty_config()) {
|
||||||
// update Print Host upload from the selected preset
|
// update Print Host upload from the selected preset
|
||||||
@ -645,5 +647,12 @@ void PhysicalPrinterDialog::DeletePreset(PresetForPrinter* preset_for_printer)
|
|||||||
this->Fit();
|
this->Fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PhysicalPrinterDialog::selected_preset_changed(std::string preset_name)
|
||||||
|
{
|
||||||
|
if (preset_name.rfind("Original Prusa i3 MK3", 0) == 0)
|
||||||
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(debug) << "Original Prusa i3 MK3";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}} // namespace Slic3r::GUI
|
}} // namespace Slic3r::GUI
|
||||||
|
@ -95,7 +95,7 @@ public:
|
|||||||
PrinterTechnology get_printer_technology();
|
PrinterTechnology get_printer_technology();
|
||||||
|
|
||||||
void DeletePreset(PresetForPrinter* preset_for_printer);
|
void DeletePreset(PresetForPrinter* preset_for_printer);
|
||||||
|
void selected_preset_changed(std::string preset_name);
|
||||||
protected:
|
protected:
|
||||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||||
void on_sys_color_changed() override {};
|
void on_sys_color_changed() override {};
|
||||||
|
@ -213,4 +213,48 @@ void SL1Host::set_auth(Http &http) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PrusaLink
|
||||||
|
PrusaLink::PrusaLink(DynamicPrintConfig* config) :
|
||||||
|
OctoPrint(config),
|
||||||
|
authorization_type(dynamic_cast<const ConfigOptionEnum<AuthorizationType>*>(config->option("printhost_authorization_type"))->value),
|
||||||
|
username(config->opt_string("printhost_user")),
|
||||||
|
password(config->opt_string("printhost_password"))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* PrusaLink::get_name() const { return "PrusaLink"; }
|
||||||
|
|
||||||
|
wxString PrusaLink::get_test_ok_msg() const
|
||||||
|
{
|
||||||
|
return _(L("Connection to PrusaLink works correctly."));
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString PrusaLink::get_test_failed_msg(wxString& msg) const
|
||||||
|
{
|
||||||
|
return GUI::from_u8((boost::format("%s: %s")
|
||||||
|
% _utf8(L("Could not connect to PrusaLink"))
|
||||||
|
% std::string(msg.ToUTF8())).str());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PrusaLink::validate_version_text(const boost::optional<std::string>& version_text) const
|
||||||
|
{
|
||||||
|
return version_text ? boost::starts_with(*version_text, "PrusaLink") : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrusaLink::set_auth(Http& http) const
|
||||||
|
{
|
||||||
|
switch (authorization_type) {
|
||||||
|
case atKeyPassword:
|
||||||
|
http.header("X-Api-Key", get_apikey());
|
||||||
|
break;
|
||||||
|
case atUserPassword:
|
||||||
|
http.auth_digest(username, password);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!get_cafile().empty()) {
|
||||||
|
http.ca_file(get_cafile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,6 +70,31 @@ private:
|
|||||||
std::string password;
|
std::string password;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PrusaLink : public OctoPrint
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PrusaLink(DynamicPrintConfig* config);
|
||||||
|
~PrusaLink() override = default;
|
||||||
|
|
||||||
|
const char* get_name() const override;
|
||||||
|
|
||||||
|
wxString get_test_ok_msg() const override;
|
||||||
|
wxString get_test_failed_msg(wxString& msg) const override;
|
||||||
|
bool can_start_print() const override { return false; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool validate_version_text(const boost::optional<std::string>& version_text) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void set_auth(Http& http) const override;
|
||||||
|
|
||||||
|
// Host authorization type.
|
||||||
|
AuthorizationType authorization_type;
|
||||||
|
// username and password for HTTP Digest Authentization (RFC RFC2617)
|
||||||
|
std::string username;
|
||||||
|
std::string password;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -50,6 +50,7 @@ PrintHost* PrintHost::get_print_host(DynamicPrintConfig *config)
|
|||||||
case htFlashAir: return new FlashAir(config);
|
case htFlashAir: return new FlashAir(config);
|
||||||
case htAstroBox: return new AstroBox(config);
|
case htAstroBox: return new AstroBox(config);
|
||||||
case htRepetier: return new Repetier(config);
|
case htRepetier: return new Repetier(config);
|
||||||
|
case htPrusaLink: return new PrusaLink(config);
|
||||||
default: return nullptr;
|
default: return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user