FIX: check with internal filament type

jira: [STUDIO-14216]
Change-Id: I89e0d62b572872d7e2ea8e6e57ac662b64baf92b
(cherry picked from commit 6767c2334bbfcffa41d4d020ee4f2e183a327cee)
This commit is contained in:
xin.zhang
2025-08-25 18:02:54 +08:00
committed by Noisyfox
parent 2339f5a789
commit 1494731eab
8 changed files with 39 additions and 34 deletions

View File

@@ -157,7 +157,7 @@ void TrayListModel::update(MachineObject* obj)
m_titleColValues.push_back(title_text);
wxString color_text = wxString::Format("%s", tray->wx_color.GetAsString());
m_colorColValues.push_back(color_text);
wxString meterial_text = wxString::Format("%s", tray->type);
wxString meterial_text = wxString::Format("%s", tray->m_fila_type);
m_meterialColValues.push_back(meterial_text);
wxString weight_text = wxString::Format("%sg", tray->weight);
m_weightColValues.push_back(weight_text);

View File

@@ -43,7 +43,7 @@ void DevAmsTray::reset()
tag_uid = "";
setting_id = "";
filament_setting_id = "";
type = "";
m_fila_type = "";
sub_brands = "";
color = "";
weight = "";
@@ -67,7 +67,7 @@ void DevAmsTray::reset()
bool DevAmsTray::is_tray_info_ready() const
{
if (color.empty()) return false;
if (type.empty()) return false;
if (m_fila_type.empty()) return false;
//if (setting_id.empty()) return false;
return true;
}
@@ -75,27 +75,27 @@ bool DevAmsTray::is_tray_info_ready() const
bool DevAmsTray::is_unset_third_filament() const
{
if (this->is_bbl) return false;
return (color.empty() || type.empty());
return (color.empty() || m_fila_type.empty());
}
std::string DevAmsTray::get_display_filament_type() const
{
if (type == "PLA-S") return "Sup.PLA";
if (type == "PA-S") return "Sup.PA";
if (type == "ABS-S") return "Sup.ABS";
return type;
if (m_fila_type == "PLA-S") return "Sup.PLA";
if (m_fila_type == "PA-S") return "Sup.PA";
if (m_fila_type == "ABS-S") return "Sup.ABS";
return m_fila_type;
}
std::string DevAmsTray::get_filament_type()
{
if (type == "Sup.PLA") { return "PLA-S"; }
if (type == "Sup.PA") { return "PA-S"; }
if (type == "Sup.ABS") { return "ABS-S"; }
if (type == "Support W") { return "PLA-S"; }
if (type == "Support G") { return "PA-S"; }
if (type == "Support") { if (setting_id == "GFS00") { type = "PLA-S"; } else if (setting_id == "GFS01") { type = "PA-S"; } else { return "PLA-S"; } }
if (m_fila_type == "Sup.PLA") { return "PLA-S"; }
if (m_fila_type == "Sup.PA") { return "PA-S"; }
if (m_fila_type == "Sup.ABS") { return "ABS-S"; }
if (m_fila_type == "Support W") { return "PLA-S"; }
if (m_fila_type == "Support G") { return "PA-S"; }
if (m_fila_type == "Support") { if (setting_id == "GFS00") { m_fila_type = "PLA-S"; } else if (setting_id == "GFS01") { m_fila_type = "PA-S"; } else { return "PLA-S"; } }
return type;
return m_fila_type;
}
@@ -513,21 +513,21 @@ void DevFilaSystemParser::ParseV1_0(const json& jj, MachineObject* obj, DevFilaS
std::string type = MachineObject::setting_id_to_type(curr_tray->setting_id, (*tray_it)["tray_type"].get<std::string>());
if (curr_tray->setting_id == "GFS00")
{
curr_tray->type = "PLA-S";
curr_tray->m_fila_type = "PLA-S";
}
else if (curr_tray->setting_id == "GFS01")
{
curr_tray->type = "PA-S";
curr_tray->m_fila_type = "PA-S";
}
else
{
curr_tray->type = type;
curr_tray->m_fila_type = type;
}
}
else
{
curr_tray->setting_id = "";
curr_tray->type = "";
curr_tray->m_fila_type = "";
}
if (tray_it->contains("tray_sub_brands"))
curr_tray->sub_brands = (*tray_it)["tray_sub_brands"].get<std::string>();

View File

@@ -28,7 +28,7 @@ public:
std::string tag_uid; // tag_uid
std::string setting_id; // tray_info_idx
std::string filament_setting_id; // setting_id
std::string type;
std::string m_fila_type;
std::string sub_brands;
std::string color;
std::vector<std::string> cols;
@@ -57,7 +57,7 @@ public:
// operators
bool operator==(DevAmsTray const& o) const
{
return id == o.id && type == o.type && filament_setting_id == o.filament_setting_id && color == o.color;
return id == o.id && m_fila_type == o.m_fila_type && filament_setting_id == o.filament_setting_id && color == o.color;
}
bool operator!=(DevAmsTray const& o) const { return !operator==(o); }

View File

@@ -650,7 +650,11 @@ std::string MachineObject::get_filament_id(std::string ams_id, std::string tray_
}
std::string MachineObject::get_filament_type(const std::string& ams_id, const std::string& tray_id) const {
return this->get_tray(ams_id, tray_id).type;
return this->get_tray(ams_id, tray_id).get_filament_type();
}
std::string MachineObject::get_filament_display_type(const std::string& ams_id, const std::string& tray_id) const {
return this->get_tray(ams_id, tray_id).get_display_filament_type();
}
void MachineObject::_parse_ams_status(int ams_status)
@@ -3726,7 +3730,7 @@ int MachineObject::parse_json(std::string tunnel, std::string payload, bool key_
vt_slot[0].color = jj["tray_color"].get<std::string>();
vt_slot[0].setting_id = jj["tray_info_idx"].get<std::string>();
//vt_tray.type = jj["tray_type"].get<std::string>();
vt_slot[0].type = setting_id_to_type(vt_slot[0].setting_id, jj["tray_type"].get<std::string>());
vt_slot[0].m_fila_type = setting_id_to_type(vt_slot[0].setting_id, jj["tray_type"].get<std::string>());
// delay update
vt_slot[0].set_hold_count();
} else {
@@ -3751,7 +3755,7 @@ int MachineObject::parse_json(std::string tunnel, std::string payload, bool key_
}*/
tray_it->second->setting_id = jj["tray_info_idx"].get<std::string>();
tray_it->second->type = setting_id_to_type(tray_it->second->setting_id, jj["tray_type"].get<std::string>());
tray_it->second->m_fila_type = setting_id_to_type(tray_it->second->setting_id, jj["tray_type"].get<std::string>());
// delay update
tray_it->second->set_hold_count();
} else {
@@ -4632,18 +4636,18 @@ DevAmsTray MachineObject::parse_vt_tray(json vtray)
//std::string type = vtray["tray_type"].get<std::string>();
std::string type = setting_id_to_type(vt_tray.setting_id, vtray["tray_type"].get<std::string>());
if (vt_tray.setting_id == "GFS00") {
vt_tray.type = "PLA-S";
vt_tray.m_fila_type = "PLA-S";
}
else if (vt_tray.setting_id == "GFS01") {
vt_tray.type = "PA-S";
vt_tray.m_fila_type = "PA-S";
}
else {
vt_tray.type = type;
vt_tray.m_fila_type = type;
}
}
else {
vt_tray.setting_id = "";
vt_tray.type = "";
vt_tray.m_fila_type = "";
}
if (vtray.contains("tray_sub_brands"))
vt_tray.sub_brands = vtray["tray_sub_brands"].get<std::string>();
@@ -5157,7 +5161,7 @@ void MachineObject::check_ams_filament_valid()
<< slot_id << "filament_id: " << curr_tray->setting_id;
command_ams_filament_settings(std::stoi(ams_id), std::stoi(slot_id), curr_tray->setting_id, preset_setting_id, curr_tray->color, curr_tray->type,
command_ams_filament_settings(std::stoi(ams_id), std::stoi(slot_id), curr_tray->setting_id, preset_setting_id, curr_tray->color, curr_tray->m_fila_type,
std::stoi(curr_tray->nozzle_temp_min), std::stoi(curr_tray->nozzle_temp_max));
}
continue;
@@ -5218,7 +5222,7 @@ void MachineObject::check_ams_filament_valid()
if (!is_equation) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__
<< " vt_tray filament is not match min max temp and reset, filament_id: " << vt_tray.setting_id;
command_ams_filament_settings(vt_id, 0, vt_tray.setting_id, preset_setting_id, vt_tray.color, vt_tray.type, std::stoi(vt_tray.nozzle_temp_min),
command_ams_filament_settings(vt_id, 0, vt_tray.setting_id, preset_setting_id, vt_tray.color, vt_tray.m_fila_type, std::stoi(vt_tray.nozzle_temp_min),
std::stoi(vt_tray.nozzle_temp_max));
}

View File

@@ -274,6 +274,7 @@ public:
std::string get_filament_id(std::string ams_id, std::string tray_id) const;
std::string get_filament_type(const std::string& ams_id, const std::string& tray_id) const;
std::string get_filament_display_type(const std::string& ams_id, const std::string& tray_id) const;
// parse amsStatusMain and ams_status_sub
void _parse_ams_status(int ams_status);

View File

@@ -2943,13 +2943,13 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
auto build_tray_config = [](DevAmsTray const &tray, std::string const &name, std::string ams_id, std::string slot_id) {
BOOST_LOG_TRIVIAL(info) << boost::format("build_filament_ams_list: name %1% setting_id %2% type %3% color %4%")
% name % tray.setting_id % tray.type % tray.color;
% name % tray.setting_id % tray.m_fila_type % tray.color;
DynamicPrintConfig tray_config;
tray_config.set_key_value("filament_id", new ConfigOptionStrings{tray.setting_id});
tray_config.set_key_value("tag_uid", new ConfigOptionStrings{tray.tag_uid});
tray_config.set_key_value("ams_id", new ConfigOptionStrings{ams_id});
tray_config.set_key_value("slot_id", new ConfigOptionStrings{slot_id});
tray_config.set_key_value("filament_type", new ConfigOptionStrings{tray.type});
tray_config.set_key_value("filament_type", new ConfigOptionStrings{tray.m_fila_type});
tray_config.set_key_value("tray_name", new ConfigOptionStrings{ name });
tray_config.set_key_value("filament_colour", new ConfigOptionStrings{into_u8(wxColour("#" + tray.color).GetAsString(wxC2S_HTML_SYNTAX))});
tray_config.set_key_value("filament_multi_colour", new ConfigOptionStrings{});

View File

@@ -1368,7 +1368,7 @@ void SelectMachineDialog::auto_supply_with_ext(std::vector<DevAmsTray> slots) {
if (slot.id.empty()) continue;
m_ams_mapping_result[i].ams_id = slot.id;
m_ams_mapping_result[i].color = slot.color;
m_ams_mapping_result[i].type = slot.type;
m_ams_mapping_result[i].type = slot.m_fila_type;
m_ams_mapping_result[i].colors = slot.cols;
m_ams_mapping_result[i].tray_id = atoi(slot.id.c_str());
m_ams_mapping_result[i].slot_id = "0";

View File

@@ -1497,7 +1497,7 @@ void SyncAmsInfoDialog::auto_supply_with_ext(std::vector<DevAmsTray> slots)
if (slot.id.empty()) continue;
m_ams_mapping_result[i].ams_id = slot.id;
m_ams_mapping_result[i].color = slot.color;
m_ams_mapping_result[i].type = slot.type;
m_ams_mapping_result[i].type = slot.m_fila_type;
m_ams_mapping_result[i].colors = slot.cols;
m_ams_mapping_result[i].tray_id = atoi(slot.id.c_str());
m_ams_mapping_result[i].slot_id = "0";