mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-13 00:49:01 +08:00
Printer_model reading when uploading to Connect.
This commit is contained in:
parent
403a3ec095
commit
5e48e0a5a6
@ -3683,7 +3683,7 @@ bool GUI_App::select_printer_from_connect(const std::string& msg)
|
|||||||
std::string model_name = plater()->get_user_account()->get_keyword_from_json(msg, "printer_model");
|
std::string model_name = plater()->get_user_account()->get_keyword_from_json(msg, "printer_model");
|
||||||
if (model_name.empty()) {
|
if (model_name.empty()) {
|
||||||
std::vector<std::string> compatible_printers;
|
std::vector<std::string> compatible_printers;
|
||||||
plater()->get_user_account()->fill_compatible_printers_from_json(msg, compatible_printers);
|
plater()->get_user_account()->fill_supported_printer_models_from_json(msg, compatible_printers);
|
||||||
if (!compatible_printers.empty()) {
|
if (!compatible_printers.empty()) {
|
||||||
model_name = compatible_printers.front();
|
model_name = compatible_printers.front();
|
||||||
}
|
}
|
||||||
|
@ -5874,7 +5874,7 @@ void Plater::connect_gcode()
|
|||||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||||
// Connect data
|
// Connect data
|
||||||
std::vector<std::string> compatible_printers;
|
std::vector<std::string> compatible_printers;
|
||||||
p->user_account->fill_compatible_printers_from_json_old(dialog_msg, compatible_printers);
|
p->user_account->fill_supported_printer_models_from_json(dialog_msg, compatible_printers);
|
||||||
std::string connect_nozzle = p->user_account->get_nozzle_from_json(dialog_msg);
|
std::string connect_nozzle = p->user_account->get_nozzle_from_json(dialog_msg);
|
||||||
|
|
||||||
std::vector<std::string> connect_materials;
|
std::vector<std::string> connect_materials;
|
||||||
|
@ -365,41 +365,27 @@ std::string UserAccount::get_keyword_from_json(const std::string& json, const st
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserAccount::fill_compatible_printers_from_json(const std::string& json, std::vector<std::string>& result) const
|
void UserAccount::fill_supported_printer_models_from_json(const std::string& json, std::vector<std::string>& result) const
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
std::stringstream ss(json);
|
std::stringstream ss(json);
|
||||||
pt::ptree ptree;
|
pt::ptree ptree;
|
||||||
pt::read_json(ss, ptree);
|
pt::read_json(ss, ptree);
|
||||||
|
|
||||||
|
std::string printer_model = parse_tree_for_param(ptree, "printer_model");
|
||||||
|
if (!printer_model.empty()) {
|
||||||
|
result.emplace_back(printer_model);
|
||||||
|
}
|
||||||
pt::ptree out = parse_tree_for_subtree(ptree, "supported_printer_models");
|
pt::ptree out = parse_tree_for_subtree(ptree, "supported_printer_models");
|
||||||
if (out.empty()) {
|
if (out.empty()) {
|
||||||
BOOST_LOG_TRIVIAL(error) << "Failed to find compatible_printer_type in printer detail.";
|
BOOST_LOG_TRIVIAL(error) << "Failed to find compatible_printer_type in printer detail.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (const auto& sub : out) {
|
for (const auto& sub : out) {
|
||||||
|
if (printer_model != sub.second.data()) {
|
||||||
result.emplace_back(sub.second.data());
|
result.emplace_back(sub.second.data());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (const std::exception& e) {
|
|
||||||
BOOST_LOG_TRIVIAL(error) << "Could not parse prusaconnect message. " << e.what();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UserAccount::fill_compatible_printers_from_json_old(const std::string& json, std::vector<std::string>& result) const
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
std::stringstream ss(json);
|
|
||||||
pt::ptree ptree;
|
|
||||||
pt::read_json(ss, ptree);
|
|
||||||
|
|
||||||
pt::ptree out = parse_tree_for_subtree(ptree, "printer_type_compatible");
|
|
||||||
if (out.empty()) {
|
|
||||||
BOOST_LOG_TRIVIAL(error) << "Failed to find compatible_printer_type in printer detail.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (const auto& sub : out) {
|
|
||||||
result.emplace_back(sub.second.data());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
|
@ -68,8 +68,7 @@ public:
|
|||||||
std::string get_model_from_json(const std::string& message) const;
|
std::string get_model_from_json(const std::string& message) const;
|
||||||
std::string get_nozzle_from_json(const std::string& message) const;
|
std::string get_nozzle_from_json(const std::string& message) const;
|
||||||
std::string get_keyword_from_json(const std::string& json, const std::string& keyword) const;
|
std::string get_keyword_from_json(const std::string& json, const std::string& keyword) const;
|
||||||
void fill_compatible_printers_from_json(const std::string& json, std::vector<std::string>& result) const;
|
void fill_supported_printer_models_from_json(const std::string& json, std::vector<std::string>& result) const;
|
||||||
void fill_compatible_printers_from_json_old(const std::string& json, std::vector<std::string>& result) const;
|
|
||||||
void fill_material_from_json(const std::string& json, std::vector<std::string>& result) const;
|
void fill_material_from_json(const std::string& json, std::vector<std::string>& result) const;
|
||||||
|
|
||||||
const std::map<std::string, ConnectPrinterState>& get_printer_state_table() const { return printer_state_table; }
|
const std::map<std::string, ConnectPrinterState>& get_printer_state_table() const { return printer_state_table; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user