Merge branch 'main' into fix/opc-support-for-ota

This commit is contained in:
Ian Chua
2026-09-10 15:42:14 +08:00
committed by GitHub
4799 changed files with 57153 additions and 19328 deletions
+2 -2
View File
@@ -323,7 +323,7 @@ bool C3DPrinterOS::login(wxString& msg) const
msg.clear();
std::string token = get_api_auth_token(msg);
if (token.empty()) {
msg = _L("Error. Can't get api token for authorization");
msg = _L("Error. Can't get API token for authorization");
return false;
}
@@ -627,7 +627,7 @@ void C3DPrinterOS::send_form(
responseTree.put("result", false);
responseTree.put("message", error);
})
.on_complete([&, this](std::string body, unsigned) {
.on_complete([&](std::string body, unsigned) {
std::stringstream ss(body);
try {
pt::read_json(ss, responseTree);
+115 -2
View File
@@ -1,11 +1,121 @@
#include "BBLPrinterAgent.hpp"
#include "BBLNetworkPlugin.hpp"
#include "NetworkAgentFactory.hpp"
#include "libslic3r/Utils.hpp"
#include <boost/log/trivial.hpp>
#include <boost/nowide/fstream.hpp>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
#include <unordered_map>
namespace Slic3r {
namespace {
// Bambu's own catalog ids for every filament this app ships, Bambu's own included, since Orca
// content-addresses those too. Keyed both ways so each of the four translation entry points
// below is a single lookup. Loaded once per process, on first use. A missing or malformed file
// logs once and leaves both maps empty, so every translation degrades to identity. Same shape
// as DevFilaBlacklist::load_filaments_blacklist_config.
struct BambuFilamentIdMap { std::unordered_map<std::string, std::string> to_bambu, to_orca; };
const BambuFilamentIdMap& bambu_filament_id_map()
{
static const BambuFilamentIdMap map = [] {
BambuFilamentIdMap m;
const std::string path = resources_dir() + "/printers/bambu_filament_ids.json";
try {
boost::nowide::ifstream file(path);
if (!file.is_open()) {
BOOST_LOG_TRIVIAL(warning) << "Bambu filament id map not found, ids pass through untranslated: " << path;
return m;
}
json doc;
file >> doc;
for (const auto& [orca_filament_id, row] : doc.at("filaments").items()) {
const std::string bambu_id = row.at("bambu_id").get<std::string>();
m.to_bambu.emplace(orca_filament_id, bambu_id);
m.to_orca.emplace(bambu_id, orca_filament_id);
}
} catch (const std::exception& e) {
BOOST_LOG_TRIVIAL(error) << "Bambu filament id map unreadable, ids pass through untranslated: " << e.what();
m = {};
}
return m;
}();
return map;
}
// Rewrites every string under "tray_info_idx", "filament_id" or "filamentId", at any depth, in place.
void rewrite_filament_ids(json& j, const std::unordered_map<std::string, std::string>& map)
{
if (j.is_object()) {
for (auto& [key, value] : j.items()) {
if (value.is_string() && (key == "tray_info_idx" || key == "filament_id" || key == "filamentId")) {
auto it = map.find(value.get_ref<const std::string&>());
if (it != map.end())
value = it->second;
} else
rewrite_filament_ids(value, map);
}
} else if (j.is_array())
for (auto& element : j)
rewrite_filament_ids(element, map);
}
// Text that does not parse as JSON, or that mentions none of the id keys, comes back byte-identical.
std::string rewrite_filament_ids(std::string text, const std::unordered_map<std::string, std::string>& map)
{
if (map.empty() || (text.find("tray_info_idx") == std::string::npos && text.find("filament_id") == std::string::npos &&
text.find("filamentId") == std::string::npos))
return text; // nothing to map, skip the parse (moved, not copied)
try {
json j = json::parse(text);
rewrite_filament_ids(j, map);
return j.dump();
} catch (const std::exception&) {
return text; // not JSON: forward as received
}
}
// Wraps an inbound message callback so every Bambu id it delivers arrives already translated.
// A null fn is a deregistration (see GUI_App.cpp's shutdown phase 1 and NetworkAgent::apply_printer_callbacks
// clearing callbacks with {}), and must stay null rather than become a live wrapper around an empty target.
OnMessageFn to_orca_messages(OnMessageFn fn)
{
if (!fn)
return fn;
return [fn = std::move(fn)](std::string dev_id, std::string msg) { fn(std::move(dev_id), BBLPrinterAgent::to_orca_payload(std::move(msg))); };
}
} // namespace
std::string BBLPrinterAgent::to_orca_filament_id(const std::string& printer_filament_id) const
{
const auto& map = bambu_filament_id_map().to_orca;
auto it = map.find(printer_filament_id);
return it != map.end() ? it->second : printer_filament_id;
}
std::string BBLPrinterAgent::from_orca_filament_id(const std::string& orca_filament_id) const
{
const auto& map = bambu_filament_id_map().to_bambu;
auto it = map.find(orca_filament_id);
return it != map.end() ? it->second : orca_filament_id;
}
std::string BBLPrinterAgent::to_orca_payload(std::string json_text)
{
return rewrite_filament_ids(std::move(json_text), bambu_filament_id_map().to_orca);
}
std::string BBLPrinterAgent::from_orca_payload(std::string json_text)
{
return rewrite_filament_ids(std::move(json_text), bambu_filament_id_map().to_bambu);
}
BBLPrinterAgent::BBLPrinterAgent() = default;
BBLPrinterAgent::~BBLPrinterAgent() = default;
@@ -22,6 +132,7 @@ void BBLPrinterAgent::set_cloud_agent(std::shared_ptr<ICloudServiceAgent> cloud)
int BBLPrinterAgent::send_message(std::string dev_id, std::string json_str, int qos, int flag)
{
json_str = from_orca_payload(std::move(json_str));
auto& plugin = BBLNetworkPlugin::instance();
auto agent = plugin.get_agent();
auto func = plugin.get_send_message();
@@ -67,6 +178,7 @@ int BBLPrinterAgent::disconnect_printer()
int BBLPrinterAgent::send_message_to_printer(std::string dev_id, std::string json_str, int qos, int flag)
{
json_str = from_orca_payload(std::move(json_str));
auto& plugin = BBLNetworkPlugin::instance();
auto agent = plugin.get_agent();
auto func = plugin.get_send_message_to_printer();
@@ -321,6 +433,7 @@ int dispatch_start(CurrentFn func, PrintParams& params, const CallbackFns&... ca
auto agent = plugin.get_agent();
if (!func || !agent)
return -1;
params.ams_mapping_info = BBLPrinterAgent::from_orca_payload(std::move(params.ams_mapping_info));
switch (plugin.network_abi()) {
case NetworkAbi::Legacy:
return reinterpret_cast<LegacyFn>(func)(agent, BBLNetworkPlugin::as_legacy(params), callbacks...);
@@ -408,7 +521,7 @@ int BBLPrinterAgent::set_on_message_fn(OnMessageFn fn)
auto agent = plugin.get_agent();
auto func = plugin.get_set_on_message_fn();
if (func && agent) {
return func(agent, fn);
return func(agent, to_orca_messages(std::move(fn)));
}
return -1;
}
@@ -441,7 +554,7 @@ int BBLPrinterAgent::set_on_local_message_fn(OnMessageFn fn)
auto agent = plugin.get_agent();
auto func = plugin.get_set_on_local_message_fn();
if (func && agent) {
return func(agent, fn);
return func(agent, to_orca_messages(std::move(fn)));
}
return -1;
}
+14
View File
@@ -84,6 +84,20 @@ public:
int set_queue_on_main_fn(QueueOnMainFn fn) override;
FilamentSyncMode get_filament_sync_mode() const override;
// Bambu's own catalog ids. Orca content-addresses every system filament, Bambu's included;
// the printer, the AMS and Bambu's cloud know only Bambu's ids, so this agent translates at
// the boundary through resources/printers/bambu_filament_ids.json (generated by
// scripts/update_bambu_filament_ids.py). An id without a map row is returned as it is.
std::string to_orca_filament_id(const std::string& printer_filament_id) const override;
std::string from_orca_filament_id(const std::string& orca_filament_id) const override;
// Rewrite every string under "tray_info_idx", "filament_id" or "filamentId", at any depth,
// in a JSON document (an MQTT payload or PrintParams::ams_mapping_info). Text that does not
// parse, or contains none of the keys, is returned unchanged.
// Taken by value: most outbound traffic carries no filament id and is moved straight back out.
static std::string to_orca_payload(std::string json_text);
static std::string from_orca_payload(std::string json_text);
private:
std::shared_ptr<ICloudServiceAgent> m_cloud_agent;
};
+1
View File
@@ -115,6 +115,7 @@ class UdpSession
{
public:
UdpSession(Bonjour::ReplyFn rfn);
virtual ~UdpSession() = default;
virtual void handle_receive(const boost::system::error_code& error, size_t bytes) = 0;
std::vector<char> buffer;
boost::asio::ip::udp::endpoint remote_endpoint;
+18 -8
View File
@@ -62,22 +62,29 @@ std::vector<std::string> not_support_auto_pa_cali_filaments = {
void get_default_k_n_value(const std::string &filament_id, float &k, float &n)
{
if (filament_id.compare("GFU01") == 0) {
// filament_id is our OF id; the literals below are the printer's own. An id the agent has
// no mapping for (e.g. a caller still on the old id) passes through unchanged.
auto* agent = wxGetApp().getAgent();
const std::string printer_filament_id = agent ? agent->from_orca_filament_id(filament_id) : filament_id;
if (printer_filament_id.compare("GFU01") == 0) {
/* TPU 95A */
k = 0.25;
n = 1.0;
} else if (filament_id.compare("GFU03") == 0) {
} else if (printer_filament_id.compare("GFU03") == 0) {
/* TPU 90A */
k = 0.35;
n = 1.0;
} else if (filament_id.compare("GFU04") == 0) {
} else if (printer_filament_id.compare("GFU04") == 0) {
/* TPU 85A */
k = 0.65;
n = 1.0;
} else if (filament_id.compare("GFG00") == 0 || filament_id.compare("GFG01") == 0 || filament_id.compare("GFG60") == 0 || filament_id.compare("GFL06") == 0 ||
filament_id.compare("GFL55") == 0 || filament_id.compare("GFG99") == 0 || filament_id.compare("GFG98") == 0 || filament_id.compare("GFG97") == 0 ||
filament_id.compare("GFG50") == 0 || filament_id.compare("GFU02") == 0 || filament_id.compare("GFU98") == 0 || filament_id.compare("GFS00") == 0 ||
filament_id.compare("GFS02") == 0) {
} else if (printer_filament_id.compare("GFG00") == 0 || printer_filament_id.compare("GFG01") == 0 ||
printer_filament_id.compare("GFG60") == 0 || printer_filament_id.compare("GFL06") == 0 ||
printer_filament_id.compare("GFL55") == 0 || printer_filament_id.compare("GFG99") == 0 ||
printer_filament_id.compare("GFG98") == 0 || printer_filament_id.compare("GFG97") == 0 ||
printer_filament_id.compare("GFG50") == 0 || printer_filament_id.compare("GFU02") == 0 ||
printer_filament_id.compare("GFU98") == 0 || printer_filament_id.compare("GFS00") == 0 ||
printer_filament_id.compare("GFS02") == 0) {
/* 0.04 filaments */
k = 0.04;
n = 1.0;
@@ -1393,7 +1400,10 @@ void CalibUtils::calib_retraction(const CalibInfo &calib_info, wxString &error_m
bool CalibUtils::is_support_auto_pa_cali(std::string filament_id)
{
auto iter = std::find(not_support_auto_pa_cali_filaments.begin(), not_support_auto_pa_cali_filaments.end(), filament_id);
// filament_id is our OF id; not_support_auto_pa_cali_filaments holds the printer's own ids.
auto* agent = wxGetApp().getAgent();
const std::string printer_filament_id = agent ? agent->from_orca_filament_id(filament_id) : filament_id;
auto iter = std::find(not_support_auto_pa_cali_filaments.begin(), not_support_auto_pa_cali_filaments.end(), printer_filament_id);
if (iter != not_support_auto_pa_cali_filaments.end()) {
return false;
}
+63 -16
View File
@@ -8,7 +8,9 @@
#include <nlohmann/json.hpp>
#include <algorithm>
#include <cctype>
#include <map>
#include <set>
namespace Slic3r {
@@ -16,6 +18,12 @@ namespace {
constexpr const char* CrealityPrintAgent_VERSION = "0.1.0";
std::string to_lower(std::string s)
{
for (auto& c : s) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
return s;
}
bool has_visible_base_preset(const PresetCollection& filaments, const std::string& filament_id)
{
for (const auto& p : filaments.get_presets()) {
@@ -27,19 +35,47 @@ bool has_visible_base_preset(const PresetCollection& filaments, const std::strin
return false;
}
// Lower-case words of a preset name with the "@scope" suffix dropped:
// "Generic PLA Matte @Creality K2-all" -> {"generic", "pla", "matte"}.
std::vector<std::string> name_words(const std::string& name)
{
std::vector<std::string> words;
std::string word;
for (char c : name.substr(0, name.find('@'))) {
if (std::isalnum(static_cast<unsigned char>(c))) {
word += static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
} else if (!word.empty()) {
words.push_back(word);
word.clear();
}
}
if (!word.empty())
words.push_back(word);
return words;
}
} // namespace
// Score visible compatible filament presets against the CFS spool metadata and
// return the best-matching filament_id. Scoring:
// +20 preset name contains brand_name as a substring
// (e.g. "Hyper PLA" in "Hyper PLA @Creality K2 0.4 nozzle")
// +10 preset name contains the vendor substring (e.g. "Creality")
// Tiebreak: prefer the SYSTEM (shipped) preset over user copies. Brand-
// specific system presets carry their own filament_id; user copies of
// generic presets inherit a generic filament_id from their parent, so
// preferring the user copy can collapse a brand-specific match back to
// "Generic PLA" via the inherited id. Plus: this code targets upstream
// OrcaSlicer where shipping the user's local tuning would be wrong.
// +10 the preset belongs to the spool's vendor - by its owning VendorProfile OR by
// its name. The profile test is what finds the vendor's own generics, which are
// named "Generic <material> @<scope>" and do not repeat the vendor; the name test
// still finds a third party filament shipped inside that vendor's bundle, which
// carries the bundle owner's profile but names its real brand.
// -5 per word of the preset name the spool never mentioned ("generic" excepted -
// it marks the unbranded base product rather than a qualifier), so the least
// specific preset that still explains the spool wins. Without it a spool
// reporting only "PLA" scores "Generic PLA High Speed" and "Generic PLA Matte"
// exactly as high as "Generic PLA"; those are three products with three
// filament_ids, so whichever sorted first won and the printer got the wrong
// one. Applied after the score gate, so it only reorders genuine matches.
// Tiebreak: prefer the SYSTEM (shipped) preset over user copies, then by name so the
// winner never depends on how std::sort leaves equal elements. User copies of generic
// presets inherit a generic filament_id from their parent, so preferring the user copy
// can collapse a brand-specific match back to "Generic PLA" via the inherited id.
// Requires the preset's declared filament_type to equal the spool's base type
// (PLA/PETG/ABS/...) so we never auto-pick a PETG preset for a PLA spool.
// Falls back to filaments.filament_id_by_type(base_type) when nothing scores.
@@ -48,15 +84,17 @@ std::string CrealityPrintAgent::match_filament_preset(const PresetCollection& fi
const std::string& brand_name,
const std::string& base_type)
{
auto to_lower = [](std::string s) {
for (auto& c : s) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
return s;
};
const std::string vendor_lower = to_lower(vendor);
const std::string brand_lower = to_lower(brand_name);
const std::string type_lower = to_lower(base_type);
// Everything the spool told us about itself, as words. A word in a preset's name
// that is not in here is a qualifier the spool never claimed.
std::set<std::string> spool_words{"generic"};
for (const std::string& src : {brand_lower, vendor_lower, type_lower})
for (auto& w : name_words(src))
spool_words.insert(std::move(w));
struct Match {
const Preset* preset;
int score;
@@ -83,11 +121,20 @@ std::string CrealityPrintAgent::match_filament_preset(const PresetCollection& fi
int score = 0;
if (!brand_lower.empty() && name_lower.find(brand_lower) != std::string::npos)
score += 20;
if (!vendor_lower.empty() && name_lower.find(vendor_lower) != std::string::npos)
// Profile OR name - neither alone covers both the vendor's own generics and the
// third party filaments shipped inside its bundle. See the header comment.
if (!vendor_lower.empty()
&& ((p.vendor != nullptr && to_lower(p.vendor->name) == vendor_lower)
|| name_lower.find(vendor_lower) != std::string::npos))
score += 10;
if (score > 0)
matches.push_back({&p, score, !p.is_system && !p.is_default});
if (score == 0) continue;
for (const auto& w : name_words(p.name))
if (spool_words.count(w) == 0)
score -= 5;
matches.push_back({&p, score, !p.is_system && !p.is_default});
}
if (matches.empty()) {
@@ -105,7 +152,7 @@ std::string CrealityPrintAgent::match_filament_preset(const PresetCollection& fi
[](const Match& a, const Match& b) {
if (a.score != b.score) return a.score > b.score;
if (a.is_user != b.is_user) return !a.is_user; // prefer system over user
return false;
return a.preset->name < b.preset->name; // keep the winner deterministic
});
BOOST_LOG_TRIVIAL(info)
+4
View File
@@ -12,6 +12,7 @@
#include "libslic3r/MeshBoolean.hpp"
#include "libslic3r/Model.hpp"
#include "libslic3r/Format/bbs_3mf.hpp"
#include "libslic3r/format.hpp"
#include "libslic3r/Thread.hpp"
#include "../GUI/I18N.hpp"
@@ -69,6 +70,9 @@ public:
// Returns false if fixing was canceled. fix_result contains error message if failed.
bool fix_model_with_cgal_gui(ModelObject &model_object, int volume_idx, GUI::ProgressDialog &progress_dialog, const wxString &msg_header, std::string &fix_result, bool keep_painting)
{
// Hold SaveObjectGaurd to prevent backup manager from racing concurrent mesh mutations (use-after-free).
SaveObjectGaurd backup_gaurd(model_object);
// Orca: Synchronization primitives for progress updates between worker thread and GUI.
std::mutex mtx;
std::condition_variable condition;
+4 -4
View File
@@ -254,10 +254,8 @@ int Http::priv::xfercb(void *userp, curl_off_t dltotal, curl_off_t dlnow, curl_o
bool cb_cancel = false;
if (self->progressfn) {
double speed;
double speed = 0.;
curl_easy_getinfo(self->curl, CURLINFO_SPEED_UPLOAD, &speed);
if (speed > 0.01)
speed = speed;
Progress progress(dltotal, dlnow, ultotal, ulnow, self->buffer, speed);
self->progressfn(progress, cb_cancel);
}
@@ -323,8 +321,10 @@ void Http::priv::form_add_file(const char *name, const fs::path &path, const cha
// We can't use CURLFORM_FILECONTENT, because curl doesn't support Unicode filenames on Windows
// and so we use CURLFORM_STREAM with boost ifstream to read the file.
std::string filename_str;
if (filename == nullptr) {
filename = path.string().c_str();
filename_str = path.string();
filename = filename_str.c_str();
}
form_files.emplace_back(path, offset, length);
+10
View File
@@ -290,6 +290,16 @@ public:
* Populates the MachineObject's DevFilaSystem with fetched filament data.
*/
virtual bool fetch_filament_info(std::string dev_id) { return false; }
/**
* Translate one filament id across the printer boundary.
*
* Orca content-addresses every system filament; a printer, its AMS and its vendor cloud
* know only that vendor's own catalog ids. An agent whose printers already speak Orca's
* ids leaves them alone, and so does an id with no mapping.
*/
virtual std::string to_orca_filament_id(const std::string& printer_filament_id) const { return printer_filament_id; }
virtual std::string from_orca_filament_id(const std::string& orca_filament_id) const { return orca_filament_id; }
};
} // namespace Slic3r
+2 -2
View File
@@ -80,7 +80,7 @@ bool Moonraker::test(wxString &msg) const
res = false;
msg = format_error(body, error, status);
})
.on_complete([&, this](std::string body, unsigned) {
.on_complete([&](std::string body, unsigned) {
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: /server/info body: %2%") % name % body;
try {
std::stringstream ss(body);
@@ -141,7 +141,7 @@ bool Moonraker::get_storage(wxArrayString &storage_path, wxArrayString &storage_
% name % error % status % body;
}
})
.on_complete([&, this](std::string body, unsigned) {
.on_complete([&](std::string body, unsigned) {
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: /server/files/roots body: %2%") % name % body;
try {
std::stringstream ss(body);
+55 -35
View File
@@ -19,6 +19,7 @@
#include <chrono>
#include <cstdint>
#include <cctype>
#include <map>
#include <thread>
namespace {
@@ -619,51 +620,70 @@ std::string MoonrakerPrinterAgent::map_filament_type_to_generic_id(const std::st
{
const std::string upper = trim_and_upper(filament_type);
// Map to OrcaFilamentLibrary preset IDs (compatible with all printers)
// Source: resources/profiles/OrcaFilamentLibrary/filament/
// Normalize reported material names (trimmed, uppercased) to an OrcaFilamentLibrary
// generic family. The family's filament_id is resolved from the loaded system presets
// below rather than hardcoded, so profile id re-mints never require touching this table.
// scripts/test_moonraker_lane_data.py parses this initializer; keep the {"A", "B"} format.
static const std::map<std::string, std::string> type_to_ofl_family = {
// PLA variants
{"PLA", "PLA"},
{"PLA-CF", "PLA-CF"},
{"PLA SILK", "PLA Silk"},
{"PLA-SILK", "PLA Silk"},
{"PLA HIGH SPEED", "PLA High Speed"},
{"PLA-HS", "PLA High Speed"},
{"PLA HS", "PLA High Speed"},
// PLA variants
if (upper == "PLA") return "OGFL99";
if (upper == "PLA-CF") return "OGFL98";
if (upper == "PLA SILK" || upper == "PLA-SILK") return "OGFL96";
if (upper == "PLA HIGH SPEED" || upper == "PLA-HS" || upper == "PLA HS") return "OGFL95";
// ABS/ASA variants
{"ABS", "ABS"},
{"ASA", "ASA"},
// ABS/ASA variants
if (upper == "ABS") return "OGFB99";
if (upper == "ASA") return "OGFB98";
// PETG/PET variants
{"PETG", "PETG"},
{"PET", "PETG"},
{"PCTG", "PCTG"},
// PETG/PET variants
if (upper == "PETG" || upper == "PET") return "OGFG99";
if (upper == "PCTG") return "OGFG97";
// PA/Nylon variants
{"PA", "PA"},
{"NYLON", "PA"},
{"PA-CF", "PA-CF"},
{"PPA", "PPA-CF"},
{"PPA-CF", "PPA-CF"},
{"PPA-GF", "PPA-GF"},
// PA/Nylon variants
if (upper == "PA" || upper == "NYLON") return "OGFN99";
if (upper == "PA-CF") return "OGFN98";
if (upper == "PPA" || upper == "PPA-CF") return "OGFN97";
if (upper == "PPA-GF") return "OGFN96";
// PC variants
{"PC", "PC"},
// PC variants
if (upper == "PC") return "OGFC99";
// PP/PE variants
{"PE", "PE"},
{"PP", "PP"},
// PP/PE variants
if (upper == "PE") return "OGFP99";
if (upper == "PP") return "OGFP97";
// Support materials
{"PVA", "PVA"},
{"HIPS", "HIPS"},
{"BVOH", "BVOH"},
// Support materials
if (upper == "PVA") return "OGFS99";
if (upper == "HIPS") return "OGFS98";
if (upper == "BVOH") return "OGFS97";
// TPU variants
{"TPU", "TPU"},
// TPU variants
if (upper == "TPU") return "OGFU99";
// Other materials
{"EVA", "EVA"},
{"PHA", "PHA"},
{"COPE", "CoPE"},
{"SBS", "SBS"},
};
// Other materials
if (upper == "EVA") return "OGFR99";
if (upper == "PHA") return "OGFR98";
if (upper == "COPE") return "OGFLC99";
if (upper == "SBS") return "OFLSBS99";
auto it = type_to_ofl_family.find(upper);
if (it == type_to_ofl_family.end())
return UNKNOWN_FILAMENT_ID;
// Unknown material
if (auto* bundle = GUI::wxGetApp().preset_bundle) {
const Preset* preset = bundle->filaments.find_preset("Generic " + it->second + " @System");
if (preset != nullptr && preset->is_system && !preset->filament_id.empty())
return preset->filament_id;
}
// Unknown material, or no loaded preset data to resolve against
return UNKNOWN_FILAMENT_ID;
}
+14
View File
@@ -929,6 +929,20 @@ bool NetworkAgent::fetch_filament_info(std::string dev_id)
return false;
}
std::string NetworkAgent::to_orca_filament_id(const std::string& printer_filament_id) const
{
if (m_printer_agent)
return m_printer_agent->to_orca_filament_id(printer_filament_id);
return printer_filament_id;
}
std::string NetworkAgent::from_orca_filament_id(const std::string& orca_filament_id) const
{
if (m_printer_agent)
return m_printer_agent->from_orca_filament_id(orca_filament_id);
return orca_filament_id;
}
int NetworkAgent::request_bind_ticket(std::string* ticket)
{
if (m_printer_agent)
+2
View File
@@ -165,6 +165,8 @@ public:
int start_sdcard_print(PrintParams params, OnUpdateStatusFn update_fn, WasCancelledFn cancel_fn);
FilamentSyncMode get_filament_sync_mode() const;
bool fetch_filament_info(std::string dev_id);
std::string to_orca_filament_id(const std::string& printer_filament_id) const;
std::string from_orca_filament_id(const std::string& orca_filament_id) const;
int request_bind_ticket(std::string* ticket);
int get_hms_snapshot(std::string dev_id, std::string file_name, std::function<void(std::string, int)> callback);
+1 -1
View File
@@ -86,7 +86,7 @@ bool Obico::test(wxString& msg) const
res = false;
msg = format_error(body, error, status);
})
.on_complete([&, this](std::string body, unsigned) {
.on_complete([&](std::string body, unsigned) {
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: Got version: %2%") % name % body;
})
#ifdef WIN32
+5 -3
View File
@@ -859,9 +859,11 @@ std::string OrcaCloudServiceAgent::build_login_cmd()
display_name = "unknown name";
}
json cmd;
cmd["command"] = "orca_userlogin";
cmd["data"]["name"] = display_name;
cmd["data"]["avatar"] = get_user_avatar();
cmd["command"] = "orca_userlogin";
cmd["data"]["name"] = display_name;
cmd["data"]["avatar"] = get_user_avatar();
// The unique handle, shown under the display name in the homepage account menu.
cmd["data"]["account"] = get_user_name();
return cmd.dump();
}
+1 -1
View File
@@ -536,7 +536,7 @@ void PresetUpdater::priv::sync_resources(std::string http_url, std::map<std::str
cancel_http = true;
}
})
.on_complete([this, &resource_list, resources](std::string body, unsigned) {
.on_complete([&resource_list, resources](std::string body, unsigned) {
try {
BOOST_LOG_TRIVIAL(info) << "[Orca Updater]: request_resources, body=" << body;
+1 -1
View File
@@ -73,7 +73,7 @@ bool Repetier::test(wxString &msg) const
res = false;
msg = format_error(body, error, status);
})
.on_complete([&, this](std::string body, unsigned) {
.on_complete([&](std::string body, unsigned) {
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: Got version: %2%") % name % body;
try {
+3 -3
View File
@@ -192,7 +192,7 @@ bool SimplyPrint::do_api_call(std::function<Http(bool)>
bool res = true;
const auto create_request = [this, &build_request, &res, &on_complete](const std::string& access_token, bool is_retry) {
const auto create_request = [&build_request, &res, &on_complete](const std::string& access_token, bool is_retry) {
auto http = build_request(is_retry);
set_auth(http, access_token);
http.header("User-Agent", "SimplyPrint Orca Plugin")
@@ -300,7 +300,7 @@ bool SimplyPrint::do_temp_upload(const boost::filesystem::path& file_path,
return http;
},
[&error_fn, &filename, this](std::string body, unsigned status) {
[&error_fn, &filename](std::string body, unsigned status) {
BOOST_LOG_TRIVIAL(info) << boost::format("SimplyPrint: File uploaded: HTTP %1%: %2%") % status % body;
// Get file UUID
@@ -423,7 +423,7 @@ bool SimplyPrint::do_chunk_upload(const boost::filesystem::path& file_path, cons
return http;
},
[&error_fn, i, chunk_amount, this, &chunk_id, &delete_token](std::string body, unsigned status) {
[&error_fn, i, chunk_amount, &chunk_id, &delete_token](std::string body, unsigned status) {
BOOST_LOG_TRIVIAL(info) << boost::format("SimplyPrint: File chunk [%1%/%2%] uploaded: HTTP %3%: %4%") % (i + 1) % chunk_amount % status % body;
if (i == 0) {
// First chunk, parse chunk id
+1 -1
View File
@@ -39,7 +39,7 @@ std::string find_closest_color_preset_by_vendor_and_type(const PresetCollection&
std::string p_color = p.config.opt_string("default_filament_colour", 0u);
unsigned int p_color_value;
if (!p_color.empty()) {
unsigned int hash_pos = p_color.find("#");
size_t hash_pos = p_color.find("#");
p_color_value = std::stoul(p_color.substr(hash_pos != std::string::npos ? hash_pos + 1 : 0), nullptr, 16);
} else {
// Default to black if no color specified in profile. Assume other profiles might be a closer color match.