FIX: check if the filament is unknown

jira: [STUDIO-12085]
Change-Id: Ibf40d7a5106a40385aff5c769e5b7e5cdb866de0
This commit is contained in:
xin.zhang 2025-05-12 15:05:46 +08:00 committed by lane.wei
parent ad5b73808b
commit 012b6f2395
4 changed files with 61 additions and 0 deletions

View File

@ -4,6 +4,7 @@
#include "../I18N.hpp"
#include "../GUI_App.hpp"
#include "slic3r/GUI/MsgDialog.hpp"
#include "slic3r/GUI/DeviceTab/uiAmsHumidityPopup.h"
#include <wx/simplebook.h>
@ -1649,6 +1650,16 @@ void AMSControl::SetAmsStep(std::string ams_id, std::string canid, AMSPassRoadTy
void AMSControl::on_filament_load(wxCommandEvent &event)
{
/*If the filament is unknown, show warning*/
const auto& filament_id = get_filament_id(m_current_ams, GetCurrentCan(m_current_ams));
if (filament_id.empty())
{
MessageDialog msg_dlg(nullptr, _L("Filament type is unknown which is required to perform this action. Please set target filament's informations."),
wxEmptyString, wxICON_WARNING | wxOK);
msg_dlg.ShowModal();
return;
}
m_button_extruder_back->Disable();
for (auto i = 0; i < m_ams_info.size(); i++) {
if (m_ams_info[i].ams_id == m_current_ams) { m_ams_info[i].current_action = AMSAction::AMS_ACTION_LOAD; }
@ -1700,6 +1711,37 @@ void AMSControl::parse_object(MachineObject* obj) {
}
}
std::string AMSControl::get_filament_id(const std::string& ams_id, const std::string& can_id)
{
for (const auto& ams_info : m_ams_info)
{
if (ams_info.ams_id == m_current_ams)
{
bool found = false;
const auto& can_info = ams_info.get_caninfo(this->GetCurrentCan(m_current_ams), found);
if (found)
{
return can_info.filament_id;
}
}
}
for (const auto& ext_info : m_ext_info)
{
if (ext_info.ams_id == m_current_ams)
{
bool found = false;
const auto& can_info = ext_info.get_caninfo(this->GetCurrentCan(m_current_ams), found);
if (found)
{
return can_info.filament_id;
}
}
}
return std::string();
}
void AMSControl::on_clibration_again_click(wxMouseEvent &event) { post_event(SimpleEvent(EVT_AMS_CLIBRATION_AGAIN)); }
void AMSControl::on_clibration_cancel_click(wxMouseEvent &event) { post_event(SimpleEvent(EVT_AMS_CLIBRATION_CANCEL)); }

View File

@ -194,6 +194,9 @@ public:
virtual bool Enable(bool enable = true);
void parse_object(MachineObject* obj);
private:
std::string get_filament_id(const std::string& ams_id, const std::string& can_id);
public:
std::string m_current_select;
};

View File

@ -178,6 +178,21 @@ void AMSinfo::parse_ext_info(MachineObject* obj, AmsTray tray) {
this->cans.push_back(info);
}
Caninfo AMSinfo::get_caninfo(const std::string& can_id, bool& found) const
{
found = false;
for (const auto& can_info : cans)
{
if (can_info.can_id == can_id)
{
found = true;
return can_info;
}
}
return Caninfo();
};
/*************************************************
Description:AMSExtText
**************************************************/

View File

@ -261,6 +261,7 @@ public:
void parse_ext_info(MachineObject* obj, AmsTray tray);
bool support_drying() const { return (ams_type == AMSModel::N3S_AMS) || (ams_type == AMSModel::N3F_AMS); };
Caninfo get_caninfo(const std::string& can_id, bool& found) const;
};
/*************************************************