Read filament from MMU tools

This commit is contained in:
David Kocik 2024-12-23 16:16:47 +01:00 committed by Lukas Matena
parent 63573a923c
commit c862ecf8e4
3 changed files with 17 additions and 3 deletions

View File

@ -4119,7 +4119,7 @@ void GUI_App::select_filament_from_connect(const std::string& msg)
} }
// test if currently selected is same type // test if currently selected is same type
size_t extruder_count = preset_bundle->extruders_filaments.size(); size_t extruder_count = preset_bundle->extruders_filaments.size();
if (extruder_count != materials.size()) { if (extruder_count < materials.size()) {
BOOST_LOG_TRIVIAL(error) << format("Failed to select filament from Connect. Selected printer has %1% extruders while data from Connect contains %2% materials.", extruder_count, materials.size()); BOOST_LOG_TRIVIAL(error) << format("Failed to select filament from Connect. Selected printer has %1% extruders while data from Connect contains %2% materials.", extruder_count, materials.size());
plater()->get_notification_manager()->close_notification_of_type(NotificationType::SelectFilamentFromConnect); plater()->get_notification_manager()->close_notification_of_type(NotificationType::SelectFilamentFromConnect);
// TRN: Notification text. // TRN: Notification text.
@ -4127,7 +4127,7 @@ void GUI_App::select_filament_from_connect(const std::string& msg)
return; return;
} }
std::string notification_text; std::string notification_text;
for (size_t i = 0; i < extruder_count; i++) { for (size_t i = 0; i < materials.size(); i++) {
search_and_select_filaments(materials[i], avoid_abrasive.size() > i ? avoid_abrasive[i] : false, i, notification_text); search_and_select_filaments(materials[i], avoid_abrasive.size() > i ? avoid_abrasive[i] : false, i, notification_text);
} }

View File

@ -104,6 +104,7 @@ private:
{"READY" , ConnectPrinterState::CONNECT_PRINTER_READY}, {"READY" , ConnectPrinterState::CONNECT_PRINTER_READY},
{"ATTENTION", ConnectPrinterState::CONNECT_PRINTER_ATTENTION}, {"ATTENTION", ConnectPrinterState::CONNECT_PRINTER_ATTENTION},
{"BUSY" , ConnectPrinterState::CONNECT_PRINTER_BUSY}, {"BUSY" , ConnectPrinterState::CONNECT_PRINTER_BUSY},
{"ERROR" , ConnectPrinterState::CONNECT_PRINTER_ERROR},
}; };
}; };
}} // namespace slic3r::GUI }} // namespace slic3r::GUI

View File

@ -113,7 +113,14 @@ void fill_config_options_from_json_inner(const boost::property_tree::ptree& ptre
for (const auto &subtree : slots) { for (const auto &subtree : slots) {
size_t slot_id; size_t slot_id;
try { try {
slot_id = boost::lexical_cast<std::size_t>(subtree.first); // id could "1" for extruder
// or "1.1" for MMU (than we need number after dot as id)
size_t dot_pos = subtree.first.find('.');
if (dot_pos != std::string::npos) {
slot_id = boost::lexical_cast<size_t>(subtree.first.substr(dot_pos + 1));
} else {
slot_id = boost::lexical_cast<std::size_t>(subtree.first);
}
} catch (const boost::bad_lexical_cast&) { } catch (const boost::bad_lexical_cast&) {
continue; continue;
} }
@ -286,6 +293,12 @@ void fill_material_from_json(const std::string& json, std::vector<std::string>&
for (const std::string& val : result_map["hardened"]) { for (const std::string& val : result_map["hardened"]) {
avoid_abrasive_result.emplace_back(val == "0" ? 1 : 0); avoid_abrasive_result.emplace_back(val == "0" ? 1 : 0);
} }
// MMU has "hardened" only under tool 1
if (avoid_abrasive_result.size() == 1 && material_result.size() > avoid_abrasive_result.size()) {
for (size_t i = 1; i < material_result.size(); i++) {
avoid_abrasive_result.emplace_back(avoid_abrasive_result[0]);
}
}
} }
} }