FIX: add log for base_id and filament_id

github: #3087

Change-Id: Iebfbd0f224fce49f33fc81c71e6108f6e3abb5ff
This commit is contained in:
maosheng.wei 2023-12-19 20:25:52 +08:00 committed by Lane.Wei
parent eddfd4b7b9
commit dc47541220
7 changed files with 31 additions and 10 deletions

View File

@ -1346,7 +1346,7 @@ int CLI::run(int argc, char **argv)
if (loaded_filament_ids.size() > input_index) {
if (loaded_filament_ids[input_index] > 0) {
if (loaded_filament_ids[input_index] > load_filaments.size()) {
BOOST_LOG_TRIVIAL(error) << boost::format("invalid filament id %1% at index %2%, max %3%")%loaded_filament_ids[input_index] % (input_index + 1) %load_filaments.size();
BOOST_LOG_TRIVIAL(error) << boost::format("invalid filament_id %1% at index %2%, max %3%")%loaded_filament_ids[input_index] % (input_index + 1) %load_filaments.size();
record_exit_reson(outfile_dir, CLI_INVALID_PARAMS, 0, cli_errors[CLI_INVALID_PARAMS], sliced_info);
flush_and_exit(CLI_INVALID_PARAMS);
}

View File

@ -431,6 +431,7 @@ void Preset::load_info(const std::string& file)
}
else if (v.first.compare("base_id") == 0) {
this->base_id = v.second.get_value<std::string>();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " load info from: " << file << " and base_id: " << this->base_id;
if (this->base_id.compare("null") == 0)
this->base_id.clear();
}
@ -530,6 +531,7 @@ void Preset::save(DynamicPrintConfig* parent_config)
} else {
this->config.save_to_json(this->file, this->name, from_str, this->version.to_string(), this->custom_defined);
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " save config for: " << this->name << " and filament_id: " << filament_id << " and base_id: " << this->base_id;
fs::path idx_file(this->file);
idx_file.replace_extension(".info");
@ -1184,6 +1186,7 @@ void PresetCollection::load_presets(
// Find a default preset for the config. The PrintPresetCollection provides different default preset based on the "printer_technology" field.
preset.config = default_preset.config;
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " load preset: " << name << " and filament_id: " << preset.filament_id << " and base_id: " << preset.base_id;
preset.config.apply(std::move(config));
Preset::normalize(preset.config);
// Report configuration fields, which are misplaced into a wrong group.
@ -1306,9 +1309,10 @@ int PresetCollection::get_differed_values_to_update(Preset& preset, std::map<std
key_values.erase(BBL_JSON_KEY_BASE_ID);
if (get_preset_base(preset) == &preset && !preset.filament_id.empty()) {
key_values[BBL_JSON_KEY_FILAMENT_ID] = preset.filament_id;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " uploading user preset name is: " << preset.name << "and create filament id is: " << preset.filament_id;
}
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " uploading user preset name is: " << preset.name << "and create filament_id is: " << preset.filament_id
<< " and base_id is: " << preset.base_id;
key_values[BBL_JSON_KEY_UPDATE_TIME] = std::to_string(preset.updated_time);
key_values[BBL_JSON_KEY_TYPE] = Preset::get_iot_type_string(preset.type);
return 0;
@ -1557,6 +1561,7 @@ void PresetCollection::save_user_presets(const std::string& dir_path, const std:
if (preset->base_id.empty())
preset->base_id = parent_preset->setting_id;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << preset->name << " filament_id: " << preset->filament_id << " base_id: " << preset->base_id;
preset->save(&(parent_preset->config));
}
}
@ -1657,6 +1662,7 @@ bool PresetCollection::load_user_preset(std::string name, std::map<std::string,
std::string cloud_filament_id;
if ((m_type == Preset::TYPE_FILAMENT) && preset_values.find(BBL_JSON_KEY_FILAMENT_ID) != preset_values.end()) {
cloud_filament_id = preset_values[BBL_JSON_KEY_FILAMENT_ID];
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << name << " filament_id: " << cloud_filament_id << " base_id: " << cloud_base_id;
}
DynamicPrintConfig new_config, cloud_config;
@ -1715,8 +1721,8 @@ bool PresetCollection::load_user_preset(std::string name, std::map<std::string,
iter->base_id = cloud_base_id;
iter->filament_id = cloud_filament_id;
//presets_loaded.emplace_back(*it->second);
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(", update the user preset %1% from cloud, type %2%, setting_id %3%, base_id %4%, sync_info %5% inherits %6%")
% iter->name %Preset::get_type_string(m_type) %iter->setting_id %iter->base_id %iter->sync_info %iter->inherits();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", update the user preset %1% from cloud, type %2%, setting_id %3%, base_id %4%, sync_info %5% inherits %6%, filament_id %7%")
% iter->name %Preset::get_type_string(m_type) %iter->setting_id %iter->base_id %iter->sync_info %iter->inherits() % iter->filament_id;
}
else {
//create a new one
@ -1735,8 +1741,8 @@ bool PresetCollection::load_user_preset(std::string name, std::map<std::string,
size_t cur_index = iter - m_presets.begin();
m_presets.insert(iter, preset);
//m_presets.emplace_back (preset);
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(", insert a new user preset %1%, type %2%, setting_id %3%, base_id %4%, sync_info %5% inherits %6%")
%preset.name %Preset::get_type_string(m_type) %preset.setting_id %preset.base_id %preset.sync_info %preset.inherits();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", insert a new user preset %1%, type %2%, setting_id %3%, base_id %4%, sync_info %5% inherits %6%, filament_id %7%")
%preset.name %Preset::get_type_string(m_type) %preset.setting_id %preset.base_id %preset.sync_info %preset.inherits() %preset.filament_id;
if (cur_index <= m_idx_selected) {
m_idx_selected ++;
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(", increase m_idx_selected to %1%, due to user preset inserted")%m_idx_selected;
@ -2062,6 +2068,7 @@ std::pair<Preset*, bool> PresetCollection::load_external_preset(
preset.filament_id = parent->filament_id;
}
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << preset.name << " filament_id: " << preset.filament_id << " base_id: " << preset.base_id;
if (from_project) {
preset.is_project_embedded = true;
}
@ -2140,6 +2147,7 @@ bool PresetCollection::clone_presets(std::vector<Preset const *> const &presets,
auto old_name = this->get_edited_preset().name;
for (auto preset : new_presets) {
preset.alias.clear();
preset.base_id.clear();
auto it = this->find_preset_internal(preset.name);
assert((it == m_presets.end() || it->name != preset.name) || force_rewritten);
if (it == m_presets.end() || it->name != preset.name) {
@ -2180,8 +2188,10 @@ bool PresetCollection::create_presets_from_template_for_printer(std::vector<Pres
auto *compatible_printers = dynamic_cast<ConfigOptionStrings *>(preset.config.option("compatible_printers"));
compatible_printers->values = std::vector<std::string>{printer};
preset.is_visible = true;
if (type == Preset::TYPE_FILAMENT)
if (type == Preset::TYPE_FILAMENT) {
preset.filament_id = create_filament_id(prefix);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << preset.name << " create filament_id: " << preset.filament_id;
}
}, force_rewritten);
}
@ -2200,6 +2210,7 @@ bool PresetCollection::clone_presets_for_filament(Preset const *const & pres
preset.config.apply_only(dynamic_config, {"filament_vendor", "compatible_printers", "filament_type"},true);
preset.filament_id = filament_id;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << preset.name << " is cloned and filament_id: " << filament_id;
}
},
force_rewritten);
@ -2317,6 +2328,7 @@ void PresetCollection::save_current_preset(const std::string &new_name, bool det
parent_preset = this->find_preset(final_inherits, false, true);
if (parent_preset && this->get_selected_preset().base_id.empty()) {
this->get_selected_preset().base_id = parent_preset->setting_id;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " base_id: " << parent_preset->setting_id;
}
}
if (parent_preset)

View File

@ -588,6 +588,7 @@ PresetsConfigSubstitutions PresetBundle::load_user_presets(AppConfig &
std::map<std::string, std::string>::iterator inherits_iter = value_map.find(BBL_JSON_KEY_INHERITS);
if ((pass == 1) == (inherits_iter == value_map.end() || inherits_iter->second.empty()))
continue;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " start load from cloud: " << name;
//get the type first
std::map<std::string, std::string>::iterator type_iter = value_map.find(BBL_JSON_KEY_TYPE);
if (type_iter == value_map.end()) {
@ -807,6 +808,7 @@ bool PresetBundle::import_json_presets(PresetsConfigSubstitutions & s
preset.version = *version;
inherit_preset = collection->find_preset(inherits_value, false, true); // pointer maybe wrong after insert, redo find
if (inherit_preset) preset.base_id = inherit_preset->setting_id;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << preset.name << " have filament_id: " << preset.filament_id << " and base_id: " << preset.base_id;
Preset::normalize(preset.config);
// Report configuration fields, which are misplaced into a wrong group.
const Preset &default_preset = collection->default_preset_for(new_config);
@ -3362,6 +3364,7 @@ std::pair<PresetsConfigSubstitutions, size_t> PresetBundle::load_vendor_configs_
loaded.version = current_vendor_profile->config_version;
loaded.setting_id = setting_id;
loaded.filament_id = filament_id;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " " << __LINE__ << loaded.name << " load filament_id: " << filament_id;
if (presets_collection->type() == Preset::TYPE_FILAMENT) {
if (filament_id.empty() && "Template" != vendor_name) {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__<< ": can not find filament_id for " << preset_name;

View File

@ -460,7 +460,7 @@ static std::string get_filament_id(std::string vendor_typr_serial)
user_filament_id = "P" + calculate_md5(vendor_typr_serial + get_curr_time()).substr(0, 7);
}
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " filament name is: " << vendor_typr_serial << "and create filament id is: " << user_filament_id;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " filament name is: " << vendor_typr_serial << "and create filament_id is: " << user_filament_id;
return user_filament_id;
}
@ -864,7 +864,7 @@ wxBoxSizer *CreateFilamentPresetDialog::create_filament_preset_item()
}
}
} else {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " not find filament id corresponding to the type: and the type is" << filament_type;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " not find filament_id corresponding to the type: and the type is" << filament_type;
}
sort_printer_by_nozzle(printer_name_to_filament_preset);
for (std::pair<std::string, Preset *> printer_to_preset : printer_name_to_filament_preset)
@ -1115,7 +1115,7 @@ wxArrayString CreateFilamentPresetDialog::get_filament_preset_choices()
std::set<wxString> preset_name_set;
for (Preset* filament_preset : preset.second) {
std::string preset_name = filament_preset->name;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " filament id: " << filament_preset->filament_id << " preset name: " << filament_preset->name;
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " filament_id: " << filament_preset->filament_id << " preset name: " << filament_preset->name;
size_t index_at = preset_name.find("@");
if (std::string::npos != index_at) {
std::string cur_preset_name = preset_name.substr(0, index_at - 1);

View File

@ -1025,6 +1025,9 @@ void GUI_App::post_init()
// BOOST_LOG_TRIVIAL(info) << "Loading user presets...";
// scrn->SetText(_L("Loading user presets..."));
if (m_agent) { start_sync_user_preset(); }
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " sync_user_preset: true";
} else {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " sync_user_preset: false";
}
bool switch_to_3d = false;

View File

@ -3756,11 +3756,13 @@ void MainFrame::on_select_default_preset(SimpleEvent& evt)
case wxID_YES: {
wxGetApp().app_config->set_bool("sync_user_preset", true);
wxGetApp().start_sync_user_preset(true);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " sync_user_preset: true";
break;
}
case wxID_NO:
wxGetApp().app_config->set_bool("sync_user_preset", false);
wxGetApp().stop_sync_user_preset();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " sync_user_preset: false";
break;
default:
break;

View File

@ -663,6 +663,7 @@ wxBoxSizer *PreferencesDialog::create_item_checkbox(wxString title, wxWindow *pa
} else {
wxGetApp().stop_sync_user_preset();
}
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " sync_user_preset: " << (sync ? "true" : "false");
}
#ifdef __WXMSW__