ENH: add tpu check for send print and cali

jira: 8234
Change-Id: I5706071d900079477abc9558461811a8d85fb0ab
This commit is contained in:
zhimin.zeng 2024-09-25 11:58:12 +08:00 committed by lane.wei
parent 4a472a8c6a
commit f0d2ad3dbe
8 changed files with 63 additions and 36 deletions

View File

@ -570,20 +570,19 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
//check is it in the filament blacklist //check is it in the filament blacklist
if (!is_virtual_tray() && wxGetApp().app_config->get("skip_ams_blacklist_check") != "true") { if (wxGetApp().app_config->get("skip_ams_blacklist_check") != "true") {
bool in_blacklist = false; bool in_blacklist = false;
std::string action; std::string action;
std::string info; std::string info;
std::string filamnt_type; std::string filamnt_type;
it->get_filament_type(filamnt_type); it->get_filament_type(filamnt_type);
auto vendor = dynamic_cast<ConfigOptionStrings*> (it->config.option("filament_vendor")); auto vendor = dynamic_cast<ConfigOptionStrings *>(it->config.option("filament_vendor"));
if (vendor && (vendor->values.size() > 0)) { if (vendor && (vendor->values.size() > 0)) {
std::string vendor_name = vendor->values[0]; std::string vendor_name = vendor->values[0];
DeviceManager::check_filaments_in_blacklist(vendor_name, filamnt_type, in_blacklist, action, info); DeviceManager::check_filaments_in_blacklist(vendor_name, filamnt_type, ams_id, in_blacklist, action, info);
} }
if (in_blacklist) { if (in_blacklist) {
if (action == "prohibition") { if (action == "prohibition") {
MessageDialog msg_wingow(nullptr, wxString::FromUTF8(info), _L("Error"), wxICON_WARNING | wxOK); MessageDialog msg_wingow(nullptr, wxString::FromUTF8(info), _L("Error"), wxICON_WARNING | wxOK);

View File

@ -278,13 +278,14 @@ FilamentComboBox::FilamentComboBox(wxWindow* parent, const wxPoint& pos, const w
void FilamentComboBox::ShowPanel() void FilamentComboBox::ShowPanel()
{ {
this->Show(); this->Show();
m_radioBox->Show(); set_select_mode(m_mode);
} }
void FilamentComboBox::HidePanel() void FilamentComboBox::HidePanel()
{ {
this->Hide(); this->Hide();
m_radioBox->Hide(); m_radioBox->Hide();
m_checkBox->Hide();
} }
void FilamentComboBox::set_select_mode(CalibrationFilamentMode mode) void FilamentComboBox::set_select_mode(CalibrationFilamentMode mode)

View File

@ -1249,13 +1249,13 @@ void CalibrationPresetPage::check_filament_compatible()
std::string error_tips; std::string error_tips;
int bed_temp = 0; int bed_temp = 0;
std::vector<Preset*> selected_filaments_list; std::vector<Preset *> selected_filaments_list;
for (auto& item: selected_filaments) for (auto &item : selected_filaments)
selected_filaments_list.push_back(item.second); selected_filaments_list.push_back(item.second);
check_filament_cali_reliability(selected_filaments_list); check_filament_cali_reliability(selected_filaments_list);
if (!is_filaments_compatiable(selected_filaments_list, bed_temp, incompatiable_filament_name, error_tips)) { if (!is_filaments_compatiable(selected_filaments, bed_temp, incompatiable_filament_name, error_tips)) {
m_tips_panel->set_params(0, 0, 0.0f); m_tips_panel->set_params(0, 0, 0.0f);
if (!error_tips.empty()) { if (!error_tips.empty()) {
wxString tips = from_u8(error_tips); wxString tips = from_u8(error_tips);
@ -1276,7 +1276,7 @@ void CalibrationPresetPage::check_filament_compatible()
Layout(); Layout();
} }
bool CalibrationPresetPage::is_filaments_compatiable(const std::vector<Preset*>& prests) bool CalibrationPresetPage::is_filaments_compatiable(const std::map<int, Preset*>& prests)
{ {
std::string incompatiable_filament_name; std::string incompatiable_filament_name;
std::string error_tips; std::string error_tips;
@ -1284,9 +1284,9 @@ bool CalibrationPresetPage::is_filaments_compatiable(const std::vector<Preset*>&
return is_filaments_compatiable(prests, bed_temp, incompatiable_filament_name, error_tips); return is_filaments_compatiable(prests, bed_temp, incompatiable_filament_name, error_tips);
} }
bool CalibrationPresetPage::is_filament_in_blacklist(Preset* preset, std::string& error_tips) bool CalibrationPresetPage::is_filament_in_blacklist(int tray_id, Preset* preset, std::string& error_tips)
{ {
if (m_ams_radiobox->GetValue() && wxGetApp().app_config->get("skip_ams_blacklist_check") != "true") { if (!m_ext_spool_radiobox->GetValue() && wxGetApp().app_config->get("skip_ams_blacklist_check") != "true") {
bool in_blacklist = false; bool in_blacklist = false;
std::string action; std::string action;
std::string info; std::string info;
@ -1296,7 +1296,7 @@ bool CalibrationPresetPage::is_filament_in_blacklist(Preset* preset, std::string
auto vendor = dynamic_cast<ConfigOptionStrings*> (preset->config.option("filament_vendor")); auto vendor = dynamic_cast<ConfigOptionStrings*> (preset->config.option("filament_vendor"));
if (vendor && (vendor->values.size() > 0)) { if (vendor && (vendor->values.size() > 0)) {
std::string vendor_name = vendor->values[0]; std::string vendor_name = vendor->values[0];
DeviceManager::check_filaments_in_blacklist(vendor_name, filamnt_type, in_blacklist, action, info); DeviceManager::check_filaments_in_blacklist(vendor_name, filamnt_type, tray_id, in_blacklist, action, info);
} }
if (in_blacklist) { if (in_blacklist) {
@ -1326,7 +1326,7 @@ bool CalibrationPresetPage::is_filament_in_blacklist(Preset* preset, std::string
return true; return true;
} }
bool CalibrationPresetPage::is_filaments_compatiable(const std::vector<Preset*> &prests, bool CalibrationPresetPage::is_filaments_compatiable(const std::map<int, Preset*> &prests,
int& bed_temp, int& bed_temp,
std::string& incompatiable_filament_name, std::string& incompatiable_filament_name,
std::string& error_tips) std::string& error_tips)
@ -1336,22 +1336,23 @@ bool CalibrationPresetPage::is_filaments_compatiable(const std::vector<Preset*>
bed_temp = 0; bed_temp = 0;
std::vector<std::string> filament_types; std::vector<std::string> filament_types;
for (auto &item : prests) { for (auto &item : prests) {
if (!item) const auto& item_preset = item.second;
if (!item_preset)
continue; continue;
// update bed temperature // update bed temperature
BedType curr_bed_type = BedType(m_comboBox_bed_type->GetSelection() + btDefault + 1); BedType curr_bed_type = BedType(m_comboBox_bed_type->GetSelection() + btDefault + 1);
const ConfigOptionInts *opt_bed_temp_ints = item->config.option<ConfigOptionInts>(get_bed_temp_key(curr_bed_type)); const ConfigOptionInts *opt_bed_temp_ints = item_preset->config.option<ConfigOptionInts>(get_bed_temp_key(curr_bed_type));
int bed_temp_int = 0; int bed_temp_int = 0;
if (opt_bed_temp_ints) { if (opt_bed_temp_ints) {
bed_temp_int = opt_bed_temp_ints->get_at(0); bed_temp_int = opt_bed_temp_ints->get_at(0);
} }
if (bed_temp_int <= 0) { if (bed_temp_int <= 0) {
if (!item->alias.empty()) if (!item_preset->alias.empty())
incompatiable_filament_name = item->alias; incompatiable_filament_name = item_preset->alias;
else else
incompatiable_filament_name = item->name; incompatiable_filament_name = item_preset->name;
return false; return false;
} else { } else {
@ -1360,10 +1361,10 @@ bool CalibrationPresetPage::is_filaments_compatiable(const std::vector<Preset*>
bed_temp = bed_temp_int; bed_temp = bed_temp_int;
} }
std::string display_filament_type; std::string display_filament_type;
filament_types.push_back(item->config.get_filament_type(display_filament_type, 0)); filament_types.push_back(item_preset->config.get_filament_type(display_filament_type, 0));
// check is it in the filament blacklist // check is it in the filament blacklist
if (!is_filament_in_blacklist(item, error_tips)) if (!is_filament_in_blacklist(item.first, item_preset, error_tips))
return false; return false;
} }
@ -2153,14 +2154,16 @@ void CalibrationPresetPage::select_default_compatible_filament()
return; return;
if (m_ams_radiobox->GetValue()) { if (m_ams_radiobox->GetValue()) {
std::vector<Preset*> multi_select_filaments; std::map<int, Preset *> selected_filament;
for (auto &fcb : m_filament_comboBox_list) { for (auto &fcb : m_filament_comboBox_list) {
if (!fcb->GetRadioBox()->IsEnabled()) if (!fcb->GetRadioBox()->IsEnabled())
continue; continue;
int tray_id = fcb->get_tray_id();
Preset* preset = const_cast<Preset *>(fcb->GetComboBox()->get_selected_preset()); Preset* preset = const_cast<Preset *>(fcb->GetComboBox()->get_selected_preset());
if (m_cali_filament_mode == CalibrationFilamentMode::CALI_MODEL_SINGLE) { if (m_cali_filament_mode == CalibrationFilamentMode::CALI_MODEL_SINGLE) {
if (preset && is_filaments_compatiable({preset})) { selected_filament.clear();
selected_filament[tray_id] = preset;
if (preset && is_filaments_compatiable(selected_filament)) {
fcb->GetRadioBox()->SetValue(true); fcb->GetRadioBox()->SetValue(true);
wxCommandEvent event(wxEVT_RADIOBUTTON); wxCommandEvent event(wxEVT_RADIOBUTTON);
event.SetEventObject(this); event.SetEventObject(this);
@ -2174,9 +2177,9 @@ void CalibrationPresetPage::select_default_compatible_filament()
fcb->GetCheckBox()->SetValue(false); fcb->GetCheckBox()->SetValue(false);
continue; continue;
} }
multi_select_filaments.push_back(preset); selected_filament.insert(std::make_pair(tray_id, preset));
if (!is_filaments_compatiable(multi_select_filaments)) { if (!is_filaments_compatiable(selected_filament)) {
multi_select_filaments.pop_back(); selected_filament.erase(tray_id);
fcb->GetCheckBox()->SetValue(false); fcb->GetCheckBox()->SetValue(false);
} }
else else
@ -2190,8 +2193,10 @@ void CalibrationPresetPage::select_default_compatible_filament()
} }
} }
else if (m_ext_spool_radiobox->GetValue()){ else if (m_ext_spool_radiobox->GetValue()){
std::map<int, Preset *> selected_filament;
Preset *preset = const_cast<Preset *>(m_virtual_tray_comboBox->GetComboBox()->get_selected_preset()); Preset *preset = const_cast<Preset *>(m_virtual_tray_comboBox->GetComboBox()->get_selected_preset());
if (preset && is_filaments_compatiable({preset})) { selected_filament[m_virtual_tray_comboBox->get_tray_id()] = preset;
if (preset && is_filaments_compatiable(selected_filament)) {
m_virtual_tray_comboBox->GetRadioBox()->SetValue(true); m_virtual_tray_comboBox->GetRadioBox()->SetValue(true);
} else } else
m_virtual_tray_comboBox->GetRadioBox()->SetValue(false); m_virtual_tray_comboBox->GetRadioBox()->SetValue(false);

View File

@ -245,9 +245,9 @@ protected:
void check_nozzle_diameter_for_auto_cali(); void check_nozzle_diameter_for_auto_cali();
void check_filament_compatible(); void check_filament_compatible();
bool is_filaments_compatiable(const std::vector<Preset*>& prests); bool is_filaments_compatiable(const std::map<int, Preset *>& prests);
bool is_filament_in_blacklist(Preset* preset, std::string& error_tips); bool is_filament_in_blacklist(int tray_id, Preset* preset, std::string& error_tips);
bool is_filaments_compatiable(const std::vector<Preset*>& prests, bool is_filaments_compatiable(const std::map<int, Preset *> &prests,
int& bed_temp, int& bed_temp,
std::string& incompatiable_filament_name, std::string& incompatiable_filament_name,
std::string& error_tips); std::string& error_tips);

View File

@ -257,6 +257,15 @@ PrinterArch get_printer_arch_by_str(std::string arch_str)
return PrinterArch::ARCH_CORE_XY; return PrinterArch::ARCH_CORE_XY;
} }
void check_filaments_for_vt_slot(const std::string &tag_vendor, const std::string &tag_type, int ams_id, bool &in_blacklist, std::string &ac, std::string &info)
{
if (tag_type == "TPU" && ams_id != VIRTUAL_TRAY_MAIN_ID) {
ac = "prohibition";
info = wxString(_L("TPU is not supported by deputy extruder.")).ToUTF8().data();
in_blacklist = true;
}
}
void AmsTray::update_color_from_str(std::string color) void AmsTray::update_color_from_str(std::string color)
{ {
if (color.empty()) return; if (color.empty()) return;
@ -6616,8 +6625,20 @@ bool DeviceManager::load_filaments_blacklist_config()
return true; return true;
} }
void DeviceManager::check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info) bool DeviceManager::is_virtual_slot(int ams_id)
{ {
if (ams_id == VIRTUAL_TRAY_MAIN_ID || ams_id == VIRTUAL_TRAY_DEPUTY_ID)
return true;
return false;
}
void DeviceManager::check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, int ams_id, bool& in_blacklist, std::string& ac, std::string& info)
{
if (DeviceManager::is_virtual_slot(ams_id)) {
check_filaments_for_vt_slot(tag_vendor, tag_type, ams_id, in_blacklist, ac, info);
return;
}
std::unordered_map<std::string, wxString> blacklist_prompt = std::unordered_map<std::string, wxString> blacklist_prompt =
{ {
{"TPU: not supported", _L("TPU is not supported by AMS.")}, {"TPU: not supported", _L("TPU is not supported by AMS.")},

View File

@ -1164,8 +1164,11 @@ public:
static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info); static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, bool& in_blacklist, std::string& ac, std::string& info);
static std::vector<std::string> get_resolution_supported(std::string type_str); static std::vector<std::string> get_resolution_supported(std::string type_str);
static std::vector<std::string> get_compatible_machine(std::string type_str); static std::vector<std::string> get_compatible_machine(std::string type_str);
static bool load_filaments_blacklist_config();
static void check_filaments_in_blacklist(std::string tag_vendor, std::string tag_type, int ams_id, bool &in_blacklist, std::string &ac, std::string &info);
static boost::bimaps::bimap<std::string, std::string> get_all_model_id_with_name(); static boost::bimaps::bimap<std::string, std::string> get_all_model_id_with_name();
static std::string load_gcode(std::string type_str, std::string gcode_file); static std::string load_gcode(std::string type_str, std::string gcode_file);
static bool is_virtual_slot(int ams_id);
}; };
// change the opacity // change the opacity

View File

@ -423,7 +423,7 @@ public:
bool result = m_slice_result_valid; bool result = m_slice_result_valid;
if (result) if (result)
result = m_gcode_result ? result = m_gcode_result ?
(!m_gcode_result->toolpath_outside && !m_gcode_result->filament_printable_reuslt.has_value()) : (!m_gcode_result->toolpath_outside && m_gcode_result->gcode_check_result.error_code == 0 && !m_gcode_result->filament_printable_reuslt.has_value()) :
false;// && !m_gcode_result->conflict_result.has_value() gcode conflict can also print false;// && !m_gcode_result->conflict_result.has_value() gcode conflict can also print
return result; return result;
} }

View File

@ -2767,8 +2767,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
bool in_blacklist = false; bool in_blacklist = false;
std::string action; std::string action;
std::string info; std::string info;
DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, tid, in_blacklist, action, info);
DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, in_blacklist, action, info);
if (in_blacklist && action == "warning") { if (in_blacklist && action == "warning") {
wxString prohibited_error = wxString::FromUTF8(info); wxString prohibited_error = wxString::FromUTF8(info);
@ -2833,8 +2832,7 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
bool in_blacklist = false; bool in_blacklist = false;
std::string action; std::string action;
std::string info; std::string info;
DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, tid, in_blacklist, action, info);
DeviceManager::check_filaments_in_blacklist(filament_brand, filament_type, in_blacklist, action, info);
if (in_blacklist && action == "prohibition") { if (in_blacklist && action == "prohibition") {
has_prohibited_filament = true; has_prohibited_filament = true;