mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-02 11:50:39 +08:00
Change printer maps data from model to model nozzle pair
This commit is contained in:
parent
b402c42e75
commit
ffeb068452
@ -890,9 +890,11 @@ static std::string get_connect_state_suffix_for_printer(const Preset& printer_pr
|
||||
if (auto printer_state_map = wxGetApp().plater()->get_user_account()->get_printer_state_map();
|
||||
!printer_state_map.empty()) {
|
||||
|
||||
for (const auto& [printer_model_id, states] : printer_state_map) {
|
||||
if (printer_model_id == printer_preset.config.opt_string("printer_model")) {
|
||||
|
||||
for (const auto& [printer_model_nozzle_pair, states] : printer_state_map) {
|
||||
if (printer_model_nozzle_pair.first == printer_preset.config.opt_string("printer_model")
|
||||
&& (printer_model_nozzle_pair.second.empty()
|
||||
|| printer_model_nozzle_pair.second == printer_preset.config.opt_string("nozzle_diamenter"))
|
||||
) {
|
||||
PrinterStatesCount states_cnt = get_printe_states_count(states);
|
||||
|
||||
if (states_cnt.available_cnt > 0)
|
||||
@ -912,9 +914,11 @@ static wxString get_connect_info_line(const Preset& printer_preset)
|
||||
if (auto printer_state_map = wxGetApp().plater()->get_user_account()->get_printer_state_map();
|
||||
!printer_state_map.empty()) {
|
||||
|
||||
for (const auto& [printer_model_id, states] : printer_state_map) {
|
||||
if (printer_model_id == printer_preset.config.opt_string("printer_model")) {
|
||||
|
||||
for (const auto& [printer_model_nozzle_pair, states] : printer_state_map) {
|
||||
if (printer_model_nozzle_pair.first == printer_preset.config.opt_string("printer_model")
|
||||
&& (printer_model_nozzle_pair.second.empty()
|
||||
|| printer_model_nozzle_pair.second == printer_preset.config.opt_string("nozzle_diamenter"))
|
||||
) {
|
||||
PrinterStatesCount states_cnt = get_printe_states_count(states);
|
||||
|
||||
return format_wxstr(_L("Available: %1%, Offline: %2%, Busy: %3%. Total: %4% printers"),
|
||||
|
@ -238,14 +238,15 @@ bool UserAccount::on_connect_printers_success(const std::string& data, AppConfig
|
||||
BOOST_LOG_TRIVIAL(error) << "Missing printer model for printer uuid: " << *printer_uuid;
|
||||
continue;
|
||||
}
|
||||
const std::string printer_model = m_printer_uuid_map[*printer_uuid];
|
||||
if (new_printer_map.find(printer_model) == new_printer_map.end()) {
|
||||
new_printer_map[printer_model].reserve(static_cast<size_t>(ConnectPrinterState::CONNECT_PRINTER_STATE_COUNT));
|
||||
std::pair<std::string, std::string> model_nozzle_pair = m_printer_uuid_map[*printer_uuid];
|
||||
|
||||
if (new_printer_map.find(model_nozzle_pair) == new_printer_map.end()) {
|
||||
new_printer_map[model_nozzle_pair].reserve(static_cast<size_t>(ConnectPrinterState::CONNECT_PRINTER_STATE_COUNT));
|
||||
for (size_t i = 0; i < static_cast<size_t>(ConnectPrinterState::CONNECT_PRINTER_STATE_COUNT); i++) {
|
||||
new_printer_map[printer_model].push_back(0);
|
||||
new_printer_map[model_nozzle_pair].push_back(0);
|
||||
}
|
||||
}
|
||||
new_printer_map[printer_model][static_cast<size_t>(state)] += 1;
|
||||
new_printer_map[model_nozzle_pair][static_cast<size_t>(state)] += 1;
|
||||
}
|
||||
|
||||
// compare new and old printer map and update old map into new
|
||||
@ -293,7 +294,10 @@ bool UserAccount::on_connect_uiid_map_success(const std::string& data, AppConfig
|
||||
if (!printer_model) {
|
||||
continue;
|
||||
}
|
||||
m_printer_uuid_map[*printer_uuid] = *printer_model;
|
||||
const auto nozzle_diameter_opt = printer_tree.second.get_optional<std::string>("nozzle_diameter");
|
||||
const std::string nozzle_diameter = nozzle_diameter_opt ? *nozzle_diameter_opt : std::string();
|
||||
std::pair<std::string, std::string> model_nozzle_pair = { *printer_model, nozzle_diameter };
|
||||
m_printer_uuid_map[*printer_uuid] = model_nozzle_pair;
|
||||
}
|
||||
m_communication->on_uuid_map_success();
|
||||
return on_connect_printers_success(data, app_config, out_printers_changed);
|
||||
|
@ -24,9 +24,9 @@ enum class ConnectPrinterState {
|
||||
CONNECT_PRINTER_ERROR,
|
||||
CONNECT_PRINTER_STATE_COUNT
|
||||
};
|
||||
|
||||
typedef std::map<std::string, std::vector<size_t>> ConnectPrinterStateMap;
|
||||
typedef std::map<std::string, std::string> ConnectUUIDToModelMap;
|
||||
// <std::pair<std::string, std::string> is pair of printer_model and nozzle_diameter. std::vector<size_t> is vector of ConnectPrinterState counters
|
||||
typedef std::map<std::pair<std::string, std::string>, std::vector<size_t>> ConnectPrinterStateMap;
|
||||
typedef std::map< std::string, std::pair<std::string, std::string>> ConnectUUIDToModelNozzleMap;
|
||||
// Class UserAccount should handle every request for entities outside PrusaSlicer like PrusaAuth or PrusaConnect.
|
||||
// Outside communication is implemented in class UserAccountCommunication that runs separate thread. Results come back in events to Plater.
|
||||
// All incoming data shoud be stored in UserAccount.
|
||||
@ -82,7 +82,7 @@ private:
|
||||
std::unique_ptr<Slic3r::GUI::UserAccountCommunication> m_communication;
|
||||
|
||||
ConnectPrinterStateMap m_printer_map;
|
||||
ConnectUUIDToModelMap m_printer_uuid_map;
|
||||
ConnectUUIDToModelNozzleMap m_printer_uuid_map;
|
||||
std::map<std::string, std::string> m_account_user_data;
|
||||
std::string m_username;
|
||||
size_t m_fail_counter { 0 };
|
||||
|
Loading…
x
Reference in New Issue
Block a user