Fix Moonraker Happy Hare AMS filament sync
This commit is contained in:
@@ -3358,6 +3358,10 @@ std::map<int, DynamicPrintConfig> Sidebar::build_filament_ams_list(MachineObject
|
||||
if (obj->ams_support_virtual_tray) {
|
||||
int extruder = 0x10000; // Main (first) extruder at right
|
||||
for (auto & vt_tray : obj->vt_slot) {
|
||||
if (!vt_tray.is_exists && vt_tray.setting_id.empty() && vt_tray.m_fila_type.empty() && vt_tray.color.empty()) {
|
||||
extruder = 0;
|
||||
continue;
|
||||
}
|
||||
filament_ams_list.emplace(extruder + stoi(vt_tray.id), build_tray_config(vt_tray, "Ext",vt_tray.id, "0"));//254 or 255
|
||||
extruder = 0;
|
||||
}
|
||||
@@ -3514,7 +3518,9 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn)
|
||||
p->plater->pop_warning_and_go_to_device_page("", Plater::PrinterWarningType::EMPTY_FILAMENT, _L("Sync printer information"));
|
||||
return;
|
||||
}
|
||||
if (!wxGetApp().plater()->is_same_printer_for_connected_and_selected()) {
|
||||
auto* agent = wxGetApp().getDeviceManager()->get_agent();
|
||||
const bool direct_pull_sync = agent && agent->get_filament_sync_mode() == FilamentSyncMode::pull;
|
||||
if (!direct_pull_sync && !wxGetApp().plater()->is_same_printer_for_connected_and_selected()) {
|
||||
return;
|
||||
}
|
||||
std::string ams_filament_ids = wxGetApp().app_config->get("ams_filament_ids", p->ams_list_device);
|
||||
@@ -3522,31 +3528,39 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn)
|
||||
if (!ams_filament_ids.empty()) {
|
||||
boost::algorithm::split(list2, ams_filament_ids, boost::algorithm::is_any_of(","));
|
||||
}
|
||||
wxGetApp().plater()->update_all_plate_thumbnails(true);//preview thumbnail for sync_dlg
|
||||
SyncAmsInfoDialog::SyncInfo temp_info;
|
||||
temp_info.use_dialog_pos = false;
|
||||
temp_info.cancel_text_to_later = is_from_big_sync_btn;
|
||||
if (m_sync_dlg == nullptr) {
|
||||
m_sync_dlg = new SyncAmsInfoDialog(this, temp_info);
|
||||
SyncAmsInfoDialog::SyncResult sync_result;
|
||||
int dlg_res{(int) wxID_YES};
|
||||
if (direct_pull_sync) {
|
||||
sync_result.direct_sync = true;
|
||||
sync_result.is_same_printer = true;
|
||||
} else {
|
||||
m_sync_dlg->set_info(temp_info);
|
||||
}
|
||||
int dlg_res{(int) wxID_CANCEL};
|
||||
if (m_sync_dlg->is_need_show()) {
|
||||
m_sync_dlg->deal_only_exist_ext_spool(obj);
|
||||
if (m_sync_dlg->is_dirty_filament()) {
|
||||
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->select_preset(wxGetApp().preset_bundle->filament_presets[0], false, "", false, true);
|
||||
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
|
||||
dynamic_filament_list.update();
|
||||
wxGetApp().plater()->update_all_plate_thumbnails(true);//preview thumbnail for sync_dlg
|
||||
SyncAmsInfoDialog::SyncInfo temp_info;
|
||||
temp_info.use_dialog_pos = false;
|
||||
temp_info.cancel_text_to_later = is_from_big_sync_btn;
|
||||
if (m_sync_dlg == nullptr) {
|
||||
m_sync_dlg = new SyncAmsInfoDialog(this, temp_info);
|
||||
} else {
|
||||
m_sync_dlg->set_info(temp_info);
|
||||
}
|
||||
dlg_res = (int) wxID_CANCEL;
|
||||
if (m_sync_dlg->is_need_show()) {
|
||||
m_sync_dlg->deal_only_exist_ext_spool(obj);
|
||||
if (m_sync_dlg->is_dirty_filament()) {
|
||||
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->select_preset(wxGetApp().preset_bundle->filament_presets[0], false, "", false, true);
|
||||
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
|
||||
dynamic_filament_list.update();
|
||||
}
|
||||
m_sync_dlg->set_check_dirty_fialment(false);
|
||||
dlg_res = m_sync_dlg->ShowModal();
|
||||
} else {
|
||||
dlg_res =(int) wxID_YES;
|
||||
}
|
||||
m_sync_dlg->set_check_dirty_fialment(false);
|
||||
dlg_res = m_sync_dlg->ShowModal();
|
||||
} else {
|
||||
dlg_res =(int) wxID_YES;
|
||||
}
|
||||
if (dlg_res == wxID_CANCEL)
|
||||
return;
|
||||
auto sync_result = m_sync_dlg->get_result();
|
||||
if (!direct_pull_sync)
|
||||
sync_result = m_sync_dlg->get_result();
|
||||
if (!sync_result.is_same_printer) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "check error: sync_result.is_same_printer value is false";
|
||||
return;
|
||||
|
||||
@@ -776,6 +776,7 @@ bool MoonrakerPrinterAgent::fetch_moonraker_filament_data(std::vector<AmsTrayDat
|
||||
const auto& value = json["result"]["value"];
|
||||
trays.clear();
|
||||
max_lane_index = 0;
|
||||
bool has_populated_lane = false;
|
||||
|
||||
for (const auto& [lane_key, lane_obj] : value.items()) {
|
||||
if (!lane_obj.is_object()) {
|
||||
@@ -804,6 +805,7 @@ bool MoonrakerPrinterAgent::fetch_moonraker_filament_data(std::vector<AmsTrayDat
|
||||
tray.bed_temp = safe_json_int(lane_obj, "bed_temp");
|
||||
tray.nozzle_temp = safe_json_int(lane_obj, "nozzle_temp");
|
||||
tray.has_filament = !tray.tray_type.empty();
|
||||
has_populated_lane = has_populated_lane || tray.has_filament;
|
||||
auto* bundle = GUI::wxGetApp().preset_bundle;
|
||||
tray.tray_info_idx = bundle
|
||||
? bundle->filaments.filament_id_by_type(tray.tray_type)
|
||||
@@ -818,6 +820,10 @@ bool MoonrakerPrinterAgent::fetch_moonraker_filament_data(std::vector<AmsTrayDat
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!has_populated_lane) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user