FIX: sync_ams_list find filament_type

Change-Id: If6d95c26fa128377d8b4414470b07ed5a40f0b09
Github: 6152
This commit is contained in:
chunmao.guo 2025-03-27 10:12:14 +08:00 committed by lane.wei
parent e6e093949d
commit f076d95d88
1 changed files with 11 additions and 6 deletions

View File

@ -1956,11 +1956,13 @@ unsigned int PresetBundle::sync_ams_list(std::vector<std::pair<DynamicPrintConfi
ams_multi_color_filment.push_back(filament_multi_color);
continue;
}
auto iter = std::find_if(filaments.begin(), filaments.end(), [this, &filament_id](auto &f) {
bool has_type = false;
auto filament_type = ams.opt_string("filament_type", 0u);
auto iter = std::find_if(filaments.begin(), filaments.end(), [this, &filament_id, &has_type, filament_type](auto &f) {
has_type |= f.config.opt_string("filament_type", 0u) == filament_type;
return f.is_compatible && filaments.get_preset_base(f) == &f && f.filament_id == filament_id; });
if (iter == filaments.end()) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": filament_id %1% not found or system or compatible") % filament_id;
auto filament_type = ams.opt_string("filament_type", 0u);
if (!filament_type.empty()) {
filament_type = "Generic " + filament_type;
iter = std::find_if(filaments.begin(), filaments.end(), [&filament_type](auto &f) {
@ -1974,7 +1976,8 @@ unsigned int PresetBundle::sync_ams_list(std::vector<std::pair<DynamicPrintConfi
ams_filament_presets.push_back(this->filament_presets[ams_filament_presets.size()]);
ams_filament_colors.push_back(filament_color);
ams_multi_color_filment.push_back(filament_multi_color);
unknowns.emplace_back(&ams, L("The filament model is unknown. Still using the previous filament preset."));
unknowns.emplace_back(&ams, has_type ? L("The filament may not be compatible with the current machine settings. Generic filament presets will be used.") :
L("The filament model is unknown. Still using the previous filament preset."));
continue;
}
iter = std::find_if(filaments.begin(), filaments.end(), [](auto &f) {
@ -1983,9 +1986,11 @@ unsigned int PresetBundle::sync_ams_list(std::vector<std::pair<DynamicPrintConfi
if (iter == filaments.end())
continue;
}
unknowns.emplace_back(&ams, boost::algorithm::starts_with(iter->name, filament_type)
? L("The filament may not be compatible with the current machine settings. Generic filament presets will be used.")
: L("The filament model is unknown. A random filament preset will be used."));
unknowns.emplace_back(&ams, boost::algorithm::starts_with(iter->name, filament_type) ?
(has_type ? L("The filament may not be compatible with the current machine settings. Generic filament presets will be used.") :
L("The filament model is unknown. Generic filament presets will be used.")) :
(has_type ? L("The filament may not be compatible with the current machine settings. A random filament preset will be used.") :
L("The filament model is unknown. A random filament preset will be used.")));
filament_id = iter->filament_id;
}
ams_filament_presets.push_back(iter->name);