ENH: add bed match result after gcode export

1. Add bed macth result after doing gcode export,according to filaments
used in first layer

jira: [NEW]

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: Icf70fce0310b86fffc5276fb8fb3bf4cc14afcb0
This commit is contained in:
xun.zhang 2023-10-10 19:22:01 +08:00 committed by Lane.Wei
parent 76f876a3c6
commit 700c574224
4 changed files with 42 additions and 0 deletions

View File

@ -1184,6 +1184,27 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
}
m_processor.result().timelapse_warning_code = m_timelapse_warning_code;
m_processor.result().support_traditional_timelapse = m_support_traditional_timelapse;
{ //BBS:check bed and filament compatible
const ConfigOptionDef *bed_type_def = print_config_def.get("curr_bed_type");
assert(bed_type_def != nullptr);
const t_config_enum_values *bed_type_keys_map = bed_type_def->enum_keys_map;
const ConfigOptionInts *bed_temp_opt = m_config.option<ConfigOptionInts>(get_bed_temp_key(m_config.curr_bed_type));
for(auto extruder_id : m_initial_layer_extruders){
int cur_bed_temp = bed_temp_opt->get_at(extruder_id);
if (cur_bed_temp == 0 && bed_type_keys_map != nullptr) {
for (auto item : *bed_type_keys_map) {
if (item.second == m_config.curr_bed_type) {
m_processor.result().bed_match_result = BedMatchResult(false, item.first, extruder_id);
break;
}
}
}
if (m_processor.result().bed_match_result.match == false)
break;
}
}
m_processor.finalize(true);
// DoExport::update_print_estimated_times_stats(m_processor, print->m_print_statistics);
DoExport::update_print_estimated_stats(m_processor, m_writer.extruders(), print->m_print_statistics);
@ -3548,6 +3569,12 @@ GCode::LayerResult GCode::process_layer(
}
}
}
if (first_layer) {
for (auto iter = by_extruder.begin(); iter != by_extruder.end(); ++iter) {
if (!iter->second.empty())
m_initial_layer_extruders.insert(iter->first);
}
}
#if 0
// Apply spiral vase post-processing if this layer contains suitable geometry

View File

@ -506,6 +506,7 @@ private:
bool m_need_change_layer_lift_z = false;
int m_start_gcode_filament = -1;
std::set<unsigned int> m_initial_layer_extruders;
// BBS
int get_bed_temperature(const int extruder_id, const bool is_first_layer, const BedType bed_type) const;

View File

@ -844,6 +844,7 @@ void GCodeProcessorResult::reset() {
filament_costs = std::vector<float>(MIN_EXTRUDERS_COUNT, DEFAULT_FILAMENT_COST);
custom_gcode_per_print_z = std::vector<CustomGCode::Item>();
spiral_vase_layers = std::vector<std::pair<float, std::pair<size_t, size_t>>>();
bed_match_result = BedMatchResult(true);
warnings.clear();
//BBS: add mutex for protection of gcode result

View File

@ -111,11 +111,23 @@ namespace Slic3r {
ConflictResult() = default;
};
struct BedMatchResult
{
bool match;
std::string bed_type_name;
int extruder_id;
BedMatchResult():match(true),bed_type_name(""),extruder_id(-1) {}
BedMatchResult(bool _match,const std::string& _bed_type_name="",int _extruder_id=-1)
:match(_match),bed_type_name(_bed_type_name),extruder_id(_extruder_id)
{}
};
using ConflictResultOpt = std::optional<ConflictResult>;
struct GCodeProcessorResult
{
ConflictResultOpt conflict_result;
BedMatchResult bed_match_result;
struct SettingsIds
{
@ -231,6 +243,7 @@ namespace Slic3r {
spiral_vase_layers = other.spiral_vase_layers;
warnings = other.warnings;
bed_type = other.bed_type;
bed_match_result = other.bed_match_result;
#if ENABLE_GCODE_VIEWER_STATISTICS
time = other.time;
#endif