Apply the print dialog's Box mapping on Qidi printers (#16723)

With printer agents on, the Qidi agent now uses the Box slot picked for each filament in the print dialog. After the upload it writes `SAVE_VARIABLE VARIABLE=value_t<n> VALUE="'slot<m>'"` for each mapped filament, which the firmware's T<n> macros read. Then it starts the print through `/printer/print/start`, because the Max 4, Q2, Q2C and Plus 5 only open prints from the copy that Moonraker's print start makes.

- `MoonrakerPrinterAgent::start_local_print` now ends with a virtual `print_uploaded_file()`. The default still sends `SDCARD_PRINT_FILE`, so other Moonraker agents are unchanged.
- Box units show as "Qidi Box 1", "Qidi Box 2". Agents can set an optional `display_name` on an AMS unit.
- New agent flag `native_device_tab`. Qidi sets it to false, so its native Device and Calibration tabs are hidden and the web page becomes the Device tab.
- The Moonraker agent retries its first connection with the status stream's backoff. A disconnect, a newer connection or closing the app stops the retries.
- The print dialog fetches filament data itself for agents that only send it when asked, so the slot picker shows the Box units without a sidebar sync.
- Agent printers show their address in the print dialog's printer list instead of "(LAN)". Bambu printers keep "(LAN)".
- A single nozzle whose size the printer hasn't reported shows no size instead of "Unknown".

(cherry picked from commit b6ca378b23)
This commit is contained in:
TheLegendTubaGuy authored and SoftFever committed 2026-11-01 09:53:53 +08:00
1 parent dec2b2526d
commit fc409ef862
19 files changed
+331 -44

No files matched your search

+32 -8
View File
@@ -130,7 +130,9 @@
#include "slic3r/GUI/Tabbook.hpp"
#include "slic3r/GUI/Widgets/ComboBox.hpp"
#include "slic3r/GUI/Widgets/PopupWindow.hpp"
#include "slic3r/Utils/IPrinterAgent.hpp"
#include "slic3r/Utils/NetworkAgent.hpp"
#include "slic3r/Utils/NetworkAgentFactory.hpp"
#include <boost/filesystem.hpp>
using json = nlohmann::json;
@@ -181,6 +183,16 @@ std::string get_nozzle_volume_type_cloud_string(NozzleVolumeType nozzle_volume_t
// Throttle so the rack print-dispatch nozzle-mapping request isn't re-sent on every status poll.
static int s_nozzle_mapping_last_request_time = 0;
// Printer agents name a printer after its model, so two printers of one model are told apart by their address.
static wxString get_shown_printer_name(const MachineObject* obj)
{
const wxString name = wxString::FromUTF8(obj->get_dev_name());
if (!obj->printer_agent_id.empty() && obj->printer_agent_id != BBL_PRINTER_AGENT_ID && !obj->get_dev_ip().empty() &&
obj->get_dev_ip() != obj->get_dev_name())
return name + " (" + wxString::FromUTF8(obj->get_dev_ip()) + ")";
return obj->is_lan_mode_printer() ? name + _L("(LAN)") : name;
}
std::vector<wxString> SelectMachineDialog::MACHINE_BED_TYPE_STRING;
std::vector<std::string> SelectMachineDialog::MachineBedTypeString;
void SelectMachineDialog::init_machine_bed_types()
@@ -946,7 +958,7 @@ void SelectMachineDialog::init_bind()
if (!obj) return;
if (obj->get_dev_id() == e.GetString()) {
m_printer_box->SetPrinterName(wxString::FromUTF8(obj->get_dev_name()) + _L("(LAN)"));
m_printer_box->SetPrinterName(get_shown_printer_name(obj));
}
}
});
@@ -3859,6 +3871,7 @@ void SelectMachineDialog::on_refresh(wxCommandEvent &event)
{
BOOST_LOG_TRIVIAL(info) << "m_printer_last_select: on_refresh";
show_status(PrintDialogStatus::PrintStatusRefreshingMachineList);
m_pull_filament_pending = true;
update_user_machine_list();
}
@@ -4288,6 +4301,7 @@ void SelectMachineDialog::on_selection_changed(wxCommandEvent &event)
// Has changed machine unrecoverably
m_check_flag = false;
m_pull_filament_pending = true;
} else {
BOOST_LOG_TRIVIAL(error) << "on_selection_changed dev_id not found";
return;
@@ -4810,6 +4824,18 @@ void SelectMachineDialog::update_show_status(MachineObject* obj_)
reset_timeout();
// Orca: pull-mode agents only refresh their filament data when asked, so ask before the mapping uses it
if (m_pull_filament_pending) {
m_pull_filament_pending = false;
if (agent->get_filament_sync_mode() == FilamentSyncMode::pull) {
wxBusyCursor busy;
if (agent->fetch_filament_info(obj_->get_dev_id())) {
m_ams_mapping_result.clear();
m_check_flag = false;
}
}
}
/*check print all*/
if (!obj_->GetConfig()->SupportPrintAllPlates() && m_print_plate_idx == PLATE_ALL_IDX)
{
@@ -6441,6 +6467,7 @@ bool SelectMachineDialog::Show(bool show)
void SelectMachineDialog::show_init() {
m_ams_mapping_result.clear();
m_pull_filament_pending = true;
}
SelectMachineDialog::~SelectMachineDialog()
@@ -7042,7 +7069,9 @@ static wxString _get_tips(MachineObject* obj_)
wxString ext_diameter;
if (obj_->GetExtderSystem()->GetTotalExtderCount() == 1) {
ext_diameter += format_nozzle_diameter(obj_->GetExtderSystem()->GetNozzleDiameter(0));
// A nozzle the printer hasn't reported shows no size rather than "Unknown"
if (const float diameter = obj_->GetExtderSystem()->GetNozzleDiameter(0); diameter > 0.0f)
ext_diameter += format_nozzle_diameter(diameter);
} else if (obj_->GetExtderSystem()->GetTotalExtderCount() == 2) {
ext_diameter += format_nozzle_diameter(obj_->GetExtderSystem()->GetNozzleDiameter(1));//Left
ext_diameter += "/";
@@ -7066,13 +7095,8 @@ void PrinterInfoBox::SetPrinters(const std::vector<MachineObject*>& sorted_print
std::vector<DropDown::Item> drop_items;
for (MachineObject* obj : sorted_printers)
{
wxString shown_dev_name = wxString::FromUTF8(obj->get_dev_name());
if (obj->is_lan_mode_printer()) {
shown_dev_name += _L("(LAN)");
}
DropDown::Item drop_item;
drop_item.text = shown_dev_name;
drop_item.text = get_shown_printer_name(obj);
drop_item.text_static_tips = _get_tips(obj);
// update image