select machine

This commit is contained in:
SoftFever
2026-01-24 15:48:32 +08:00
parent 9703a6b4d7
commit 9c6b8edcb1
6 changed files with 169 additions and 54 deletions

View File

@@ -173,4 +173,49 @@ void NetworkAgentFactory::register_all_agents()
BOOST_LOG_TRIVIAL(info) << "Registered " << get_printer_agents().size() << " printer agents";
}
std::unique_ptr<NetworkAgent> create_agent_from_config(const std::string& log_dir, AppConfig* app_config)
{
// Determine cloud provider from config
bool use_orca_cloud = false;
if (app_config) {
try {
use_orca_cloud = app_config->get("use_orca_cloud") == "true" || app_config->get_bool("use_orca_cloud");
} catch (...) {
use_orca_cloud = false;
}
}
// Create cloud agent
CloudAgentProvider provider = use_orca_cloud ? CloudAgentProvider::Orca : CloudAgentProvider::BBL;
auto cloud_agent = NetworkAgentFactory::create_cloud_agent(provider, log_dir);
// Fall back to Orca if BBL plugin not available
if (!cloud_agent && provider == CloudAgentProvider::BBL) {
BOOST_LOG_TRIVIAL(warning) << "BBL plugin not loaded, falling back to Orca cloud agent";
cloud_agent = NetworkAgentFactory::create_cloud_agent(CloudAgentProvider::Orca, log_dir);
}
if (!cloud_agent) {
BOOST_LOG_TRIVIAL(error) << "Failed to create cloud agent";
return nullptr;
}
// auto bbl_printer_agent = NetworkAgentFactory::create_printer_agent_by_id("bbl", cloud_agent, log_dir);
// Create NetworkAgent with cloud agent only (printer agent added later)
// We will create the printer agent later when the printer is selected, so we pass nullptr for the printer agent here.
auto agent = NetworkAgentFactory::create_from_agents(std::move(cloud_agent), nullptr);
// Configure URL overrides for Orca cloud
if (agent && app_config && use_orca_cloud) {
auto* orca_cloud = dynamic_cast<OrcaCloudServiceAgent*>(agent->get_cloud_agent().get());
if (orca_cloud) {
orca_cloud->configure_urls(app_config);
}
}
BOOST_LOG_TRIVIAL(info) << "Created NetworkAgent with cloud agent";
return agent;
}
} // namespace Slic3r