FIX: use extruder list to decide chamber temp

As title.Use the same way to decide exhaust fan.
Removes end print exhaust fan control.

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: Id14f3d91171b81239b336ef879061c6de7d68edf
This commit is contained in:
xun.zhang 2023-08-14 19:59:45 +08:00 committed by Lane.Wei
parent 9b20cad55e
commit 8d2a5dedc1
10 changed files with 44 additions and 112 deletions

View file

@ -3,6 +3,7 @@
"name": "fdm_machine_common",
"from": "system",
"instantiation": "false",
"support_chamber_temp_control": "0",
"printer_technology": "FFF",
"deretraction_speed": [
"40"

View file

@ -571,15 +571,6 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
check_add_eol(start_filament_gcode_str);
}
// deal exhaust fan speed
{
const bool activate_air_filtration = gcodegen.config().activate_air_filtration.get_at(new_extruder_id);
if (activate_air_filtration&&gcodegen.config().support_air_filtration.getBool()) {
start_filament_gcode_str += GCodeWriter::set_exhaust_fan(gcodegen.config().during_print_exhaust_fan_speed.get_at(new_extruder_id),false);
((start_filament_gcode_str +=';')+=GCodeProcessor::reserved_tag(GCodeProcessor::ETags::During_Print_Exhaust_Fan)) += '\n';
}
}
// Insert the end filament, toolchange, and start filament gcode into the generated gcode.
DynamicConfig config;
config.set_key_value("filament_end_gcode", new ConfigOptionString(end_filament_gcode_str));
@ -1782,12 +1773,12 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
m_placeholder_parser.set("first_layer_print_size", new ConfigOptionFloats({ bbox.size().x(), bbox.size().y() }));
}
auto chamber_temp_vec = m_config.option<ConfigOptionInts>("chamber_temperatures")->values;
int max_chamber_temp = *std::max_element(chamber_temp_vec.begin(), chamber_temp_vec.end());
int max_chamber_temp = 0;
{
int curr_bed_type = m_config.curr_bed_type.getInt();
int max_chamber_temp = *std::max_element(m_config.chamber_temperatures.values.begin(), m_config.chamber_temperatures.values.end());
for (const auto& extruder : m_writer.extruders())
max_chamber_temp = std::max(max_chamber_temp, m_config.chamber_temperatures.get_at(extruder.id()));
std::string first_layer_bed_temp_str;
const ConfigOptionInts* first_bed_temp_opt = m_config.option<ConfigOptionInts>(get_bed_temp_1st_layer_key((BedType)curr_bed_type));
@ -1798,6 +1789,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
m_placeholder_parser.set("bed_temperature_initial_layer_single", new ConfigOptionInt(first_bed_temp_opt->get_at(initial_extruder_id)));
m_placeholder_parser.set("bed_temperature_initial_layer_vector", new ConfigOptionString(""));
m_placeholder_parser.set("chamber_temperature", new ConfigOptionInts({max_chamber_temp}));
m_placeholder_parser.set("chamber_temperatures", new ConfigOptionInts({ max_chamber_temp }));
//support variables `first_layer_temperature` and `first_layer_bed_temperature`
m_placeholder_parser.set("first_layer_bed_temperature", new ConfigOptionInts(*first_bed_temp_opt));
@ -1805,6 +1797,13 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
m_placeholder_parser.set("max_print_height", new ConfigOptionInt(m_config.printable_height));
m_placeholder_parser.set("z_offset", new ConfigOptionFloat(0.0f));
m_placeholder_parser.set("plate_name", new ConfigOptionString(print.get_plate_name()));
//add during_print_exhaust_fan_speed
std::vector<int> during_print_exhaust_fan_speed_num;
during_print_exhaust_fan_speed_num.reserve(m_config.during_print_exhaust_fan_speed.size());
for (const auto& item : m_config.during_print_exhaust_fan_speed.values)
during_print_exhaust_fan_speed_num.emplace_back((int)(item / 100.0 * 255));
m_placeholder_parser.set("during_print_exhaust_fan_speed_num",new ConfigOptionInts(during_print_exhaust_fan_speed_num));
//BBS: calculate the volumetric speed of outer wall. Ignore pre-object setting and multi-filament, and just use the default setting
{
float filament_max_volumetric_speed = m_config.option<ConfigOptionFloats>("filament_max_volumetric_speed")->get_at(initial_non_support_extruder_id);
@ -1826,9 +1825,6 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
if (print.config().gcode_flavor != gcfKlipper) {
// Set bed temperature if the start G-code does not contain any bed temp control G-codes.
this->_print_first_layer_bed_temperature(file, print, machine_start_gcode, initial_extruder_id, true);
if (m_config.option<ConfigOptionBool>("chamber_temp_control")->getBool()) {
this->_print_chamber_temperature(file, print, machine_start_gcode,max_chamber_temp, true);
}
// Set extruder(s) temperature before and after start G-code.
this->_print_first_layer_extruder_temperatures(file, print, machine_start_gcode, initial_extruder_id, false);
}
@ -1853,9 +1849,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
*/
this->_print_first_layer_extruder_temperatures(file, print, machine_start_gcode, initial_extruder_id, true);
bool activate_air_filtration = *std::max_element(m_config.activate_air_filtration.values.begin(), m_config.activate_air_filtration.values.end()) && m_config.support_air_filtration.getBool();
if (activate_air_filtration && m_config.activate_air_filtration.get_at(initial_extruder_id)) {
if (m_config.support_air_filtration.getBool() && m_config.activate_air_filtration.get_at(initial_extruder_id)) {
file.write(m_writer.set_exhaust_fan(m_config.during_print_exhaust_fan_speed.get_at(initial_extruder_id), true));
}
@ -2128,13 +2122,6 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
file.write(m_writer.set_chamber_temperature(0, false)); //close chamber_temperature
if (activate_air_filtration) {
int complete_print_exhaust_fan_speed = 0;
for (size_t i = 0; i < m_config.activate_air_filtration.size(); ++i)
if (m_config.activate_air_filtration.get_at(i))
complete_print_exhaust_fan_speed = std::max(complete_print_exhaust_fan_speed, m_config.complete_print_exhaust_fan_speed.get_at(i));
file.write(m_writer.set_exhaust_fan(complete_print_exhaust_fan_speed,true));
}
// adds tags for time estimators
file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Last_Line_M73_Placeholder).c_str());
file.write_format("; EXECUTABLE_BLOCK_END\n\n");
@ -2154,6 +2141,19 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
//if (print.m_print_statistics.total_toolchanges > 0)
// file.write_format("; total filament change = %i\n", print.m_print_statistics.total_toolchanges);
bool activate_air_filtration = false;
for (const auto& extruder : m_writer.extruders())
activate_air_filtration |= m_config.activate_air_filtration.get_at(extruder.id());
activate_air_filtration &= m_config.support_air_filtration.getBool();
if (activate_air_filtration) {
int complete_print_exhaust_fan_speed = 0;
for (const auto& extruder : m_writer.extruders())
if (m_config.activate_air_filtration.get_at(extruder.id()))
complete_print_exhaust_fan_speed = std::max(complete_print_exhaust_fan_speed, m_config.complete_print_exhaust_fan_speed.get_at(extruder.id()));
file.write(m_writer.set_exhaust_fan(complete_print_exhaust_fan_speed, true));
}
print.throw_if_canceled();
}
@ -2399,15 +2399,6 @@ int GCode::get_bed_temperature(const int extruder_id, const bool is_first_layer,
return bed_temp_opt->get_at(extruder_id);
}
void GCode::_print_chamber_temperature(GCodeOutputStream &file, Print &print, const std::string &gcode,int chamber_temperature, bool wait)
{
int temp_by_gcode = -1;
bool temp_set_by_gcode = custom_gcode_sets_temperature(gcode, 141, 191, false, temp_by_gcode);
std::string set_chamber_temp_gcode = m_writer.set_chamber_temperature(chamber_temperature, wait);
if (!temp_set_by_gcode)
file.write(set_chamber_temp_gcode);
}
// Write 1st layer bed temperatures into the G-code.
// Only do that if the start G-code does not already contain any M-code controlling an extruder temperature.

View file

@ -507,7 +507,6 @@ private:
std::string _extrude(const ExtrusionPath &path, std::string description = "", double speed = -1);
void print_machine_envelope(GCodeOutputStream &file, Print &print);
void _print_chamber_temperature(GCodeOutputStream &file, Print &print, const std::string &gcode,int chamber_temperature, bool wait);
void _print_first_layer_bed_temperature(GCodeOutputStream &file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
void _print_first_layer_extruder_temperatures(GCodeOutputStream &file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait);
// On the first printing layer. This flag triggers first layer speeds.

View file

@ -364,10 +364,6 @@ void GCodeProcessor::TimeProcessor::reset()
filament_load_times = 0.0f;
filament_unload_times = 0.0f;
exhaust_fan_info.activate = false;
exhaust_fan_info.print_end_exhaust_fan_speed = 0;
exhaust_fan_info.print_end_exhaust_fan_time = 0;
insert_fan_control_flag = false;
for (size_t i = 0; i < static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count); ++i) {
machines[i].reset();
@ -551,13 +547,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
std::pair<int, int> to_export_main = { int(100.0f * it->elapsed_time / machine.time),
time_in_minutes(machine.time - it->elapsed_time) };
if (self.exhaust_fan_info.activate && !self.insert_fan_control_flag && machine.time - it->elapsed_time < self.exhaust_fan_info.print_end_exhaust_fan_time ) {
//insert fan
self.insert_fan_control_flag = true;
export_line += format_line_exhaust_fan_control("M106 P%s S%s ;open exhaust fan before print end \n", 3, self.exhaust_fan_info.print_end_exhaust_fan_speed);
++exported_lines_count;
}
if (last_exported_main[i] != to_export_main) {
export_line += format_line_M73_main(machine.line_m73_main_mask.c_str(),
to_export_main.first, to_export_main.second);
@ -652,9 +641,6 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
gcode_line.insert(gcode_line.end(), it, it_end);
if (eol) {
++line_id;
// disable origin exhaust_fan_speed during print
if (insert_fan_control_flag&&gcode_line.find(reserved_tag(ETags::During_Print_Exhaust_Fan)) != std::string::npos)
gcode_line.clear();
gcode_line += "\n";
// replace placeholder lines
@ -990,16 +976,6 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
m_spiral_vase_active = spiral_vase->value;
for (size_t i = 0; i < config.activate_air_filtration.values.size(); ++i) {
if (config.activate_air_filtration.get_at(i)) {
m_exhaust_fan_info.print_end_exhaust_fan_speed = std::max(m_exhaust_fan_info.print_end_exhaust_fan_speed, config.end_print_exhaust_fan_speed.get_at(i));
m_exhaust_fan_info.print_end_exhaust_fan_time = std::max(m_exhaust_fan_info.print_end_exhaust_fan_time, config.end_print_exhaust_fan_time.get_at(i));
}
}
const ConfigOptionBools* activate_air_filtration = config.option<ConfigOptionBools>("activate_air_filtration");
if (activate_air_filtration != nullptr)
m_exhaust_fan_info.activate = *std::max_element(activate_air_filtration->values.begin(), activate_air_filtration->values.end())&&config.support_air_filtration.getBool();
}
void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
@ -1498,8 +1474,6 @@ void GCodeProcessor::finalize(bool post_process)
m_width_compare.output();
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
if (post_process){
//control chamber fan
m_time_processor.exhaust_fan_info = m_exhaust_fan_info;
m_time_processor.post_process(m_result.filename, m_result.moves, m_result.lines_ends, m_layer_id);
}
#if ENABLE_GCODE_VIEWER_STATISTICS

View file

@ -354,11 +354,6 @@ namespace Slic3r {
float time() const;
};
struct ExhaustFanInfo {
bool activate{ false };
int print_end_exhaust_fan_speed{0};
int print_end_exhaust_fan_time{0};
};
private:
struct TimeMachine
@ -456,10 +451,6 @@ namespace Slic3r {
float filament_load_times;
float filament_unload_times;
// start fan x second before print complete
ExhaustFanInfo exhaust_fan_info;
mutable bool insert_fan_control_flag{false};
std::array<TimeMachine, static_cast<size_t>(PrintEstimatedStatistics::ETimeMode::Count)> machines;
void reset();
@ -625,7 +616,6 @@ namespace Slic3r {
private:
GCodeReader m_parser;
ExhaustFanInfo m_exhaust_fan_info;
EUnits m_units;
EPositioningType m_global_positioning_type;
EPositioningType m_e_local_positioning_type;

View file

@ -822,7 +822,7 @@ static std::vector<std::string> s_Preset_filament_options {
"fan_max_speed", "enable_overhang_bridge_fan", "overhang_fan_speed", "overhang_fan_threshold", "close_fan_the_first_x_layers", "full_fan_speed_layer", "fan_cooling_layer_time", "slow_down_layer_time", "slow_down_min_speed",
"filament_start_gcode", "filament_end_gcode",
//exhaust fan control
"activate_air_filtration","during_print_exhaust_fan_speed","end_print_exhaust_fan_speed","end_print_exhaust_fan_time","complete_print_exhaust_fan_speed",
"activate_air_filtration","during_print_exhaust_fan_speed","complete_print_exhaust_fan_speed",
// Retract overrides
"filament_retraction_length", "filament_z_hop", "filament_z_hop_types", "filament_retraction_speed", "filament_deretraction_speed", "filament_retract_restart_extra", "filament_retraction_minimum_travel",
"filament_retract_when_changing_layer", "filament_wipe", "filament_retract_before_wipe",
@ -852,7 +852,7 @@ static std::vector<std::string> s_Preset_printer_options {
"silent_mode",
// BBS
"scan_first_layer", "machine_load_filament_time", "machine_unload_filament_time", "machine_pause_gcode", "template_custom_gcode",
"nozzle_type","auxiliary_fan", "nozzle_volume","upward_compatible_machine", "z_hop_types","chamber_temp_control","support_air_filtration",
"nozzle_type","auxiliary_fan", "nozzle_volume","upward_compatible_machine", "z_hop_types","support_chamber_temp_control","support_air_filtration",
//OrcaSlicer
"host_type", "print_host", "printhost_apikey",
"print_host_webui",

View file

@ -166,8 +166,6 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
"use_relative_e_distances",
"activate_air_filtration",
"during_print_exhaust_fan_speed",
"end_print_exhaust_fan_speed",
"end_print_exhaust_fan_time",
"complete_print_exhaust_fan_speed"
};
@ -205,7 +203,6 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
osteps.emplace_back(posSlice);
} else if (
opt_key == "print_sequence"
|| opt_key == "chamber_temperatures"
|| opt_key == "filament_type"
|| opt_key == "nozzle_temperature_initial_layer"
|| opt_key == "filament_minimal_purge_on_wipe_tower"

View file

@ -968,23 +968,6 @@ void PrintConfigDef::init_fff_params()
def->mode = comSimple;
def->set_default_value(new ConfigOptionInts{60});
def = this->add("end_print_exhaust_fan_speed", coInts);
def->label = L("Fan speed");
def->tooltip=L("Speed of exhuast fan before printing completes");
def->sidetext = L("%");
def->min=0;
def->max=100;
def->mode = comSimple;
def->set_default_value(new ConfigOptionInts{60});
def = this->add("end_print_exhaust_fan_time", coInts);
def->label = L("Time");
def->tooltip=L("open exhuast fan x seconds before printing completes");
def->sidetext = L("s");
def->mode = comSimple;
def->set_default_value(new ConfigOptionInts{300});
def = this->add("complete_print_exhaust_fan_speed", coInts);
def->label = L("Fan speed");
def->sidetext = L("%");
@ -1745,9 +1728,9 @@ void PrintConfigDef::init_fff_params()
def->mode = comDevelop;
def->set_default_value(new ConfigOptionBool(false));
def =this->add("chamber_temp_control",coBool);
def =this->add("support_chamber_temp_control",coBool);
def->label=L("Support control chamber temperature");
def->tooltip=L("Enable this option if machine support controlling chamber temperature");
def->tooltip=L("This option is enabled if machine support controlling chamber temperature");
def->mode=comDevelop;
def->set_default_value(new ConfigOptionBool(false));
def->readonly=false;
@ -3144,11 +3127,12 @@ void PrintConfigDef::init_fff_params()
def = this->add("chamber_temperatures", coInts);
def->label = L("Chamber temperature");
def->tooltip = L("Target chamber temperature");
def->tooltip = L("By opening chamber_temperature compensation, the heating components will operate to elevate the chamber temperature."
"This can help suppress or reduce warping for high-temperature materials and potentially lead to higher interlayer bonding strength");
def->sidetext = L("°C");
def->full_label = L("Chamber temperature");
def->full_label = L("Chamber temperature during print.0 means do not open compensation.Don't open it for low-temperature filaments like PLA, PETG, TPU");
def->min = 0;
def->max = 60;
def->max = 70;
def->set_default_value(new ConfigOptionInts{0});
def = this->add("nozzle_temperature", coInts);

View file

@ -876,7 +876,7 @@ PRINT_CONFIG_CLASS_DEFINE(
//BBS
((ConfigOptionEnum<NozzleType>, nozzle_type))
((ConfigOptionBool, auxiliary_fan))
((ConfigOptionBool, chamber_temp_control))
((ConfigOptionBool, support_chamber_temp_control))
((ConfigOptionBool, support_air_filtration))
((ConfigOptionBool, accel_to_decel_enable))
((ConfigOptionPercent, accel_to_decel_factor))
@ -916,8 +916,6 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
((ConfigOptionFloatOrPercent, sparse_infill_acceleration))
((ConfigOptionBools, activate_air_filtration))
((ConfigOptionInts, during_print_exhaust_fan_speed))
((ConfigOptionInts, end_print_exhaust_fan_speed))
((ConfigOptionInts, end_print_exhaust_fan_time))
((ConfigOptionInts, complete_print_exhaust_fan_speed))
((ConfigOptionInts, close_fan_the_first_x_layers))
((ConfigOptionEnum<DraftShield>, draft_shield))

View file

@ -2752,10 +2752,6 @@ void TabFilament::build()
line.append_option(optgroup->get_option("during_print_exhaust_fan_speed"));
optgroup->append_line(line);
line = {L("End of print"), L("")};
line.append_option(optgroup->get_option("end_print_exhaust_fan_speed"));
line.append_option(optgroup->get_option("end_print_exhaust_fan_time"));
optgroup->append_line(line);
line = {L("Complete print"), L("")};
line.append_option(optgroup->get_option("complete_print_exhaust_fan_speed"));
@ -2867,12 +2863,11 @@ void TabFilament::toggle_options()
bool has_enable_overhang_bridge_fan = m_config->opt_bool("enable_overhang_bridge_fan", 0);
for (auto el : { "overhang_fan_speed", "overhang_fan_threshold" })
toggle_option(el, has_enable_overhang_bridge_fan);
bool support_air_filtration = this->m_preset_bundle->printers.get_selected_preset().config.opt_bool("support_air_filtration");
//this->m_preset_bundle.
//toggle_line("activate_air_filtration",support_air_filtration);
//m_config;
for (auto elem : { "during_print_exhaust_fan_speed","end_print_exhaust_fan_speed","end_print_exhaust_fan_time","complete_print_exhaust_fan_speed" })
//toggle_line(elem, m_config->opt_bool("activate_air_filtration",0)&&support_air_filtration);
toggle_line("activate_air_filtration",support_air_filtration);
for (auto elem : { "during_print_exhaust_fan_speed","complete_print_exhaust_fan_speed" })
toggle_line(elem, m_config->opt_bool("activate_air_filtration",0));
}
@ -2887,6 +2882,9 @@ void TabFilament::toggle_options()
toggle_option("pressure_advance", m_config->opt_bool("enable_pressure_advance", 0));
}
bool support_chamber_temp_control = this->m_preset_bundle->printers.get_selected_preset().config.opt_bool("support_chamber_temp_control");
toggle_line("chamber_temperatures", support_chamber_temp_control);
for (auto el :
{"cool_plate_temp", "cool_plate_temp_initial_layer", "eng_plate_temp", "eng_plate_temp_initial_layer", "textured_plate_temp", "textured_plate_temp_initial_layer"})
toggle_line(el, is_BBL_printer);
@ -3105,7 +3103,7 @@ void TabPrinter::build_fff()
optgroup = page->new_optgroup(L("Accessory") /*, L"param_accessory"*/);
optgroup->append_single_option_line("nozzle_type");
optgroup->append_single_option_line("auxiliary_fan");
optgroup->append_single_option_line("chamber_temp_control");
optgroup->append_single_option_line("support_chamber_temp_control");
optgroup->append_single_option_line("support_air_filtration");
const int gcode_field_height = 15; // 150
@ -3663,7 +3661,7 @@ void TabPrinter::toggle_options()
toggle_option("gcode_flavor", !is_BBL_printer);
toggle_option("use_relative_e_distances", !is_BBL_printer);
toggle_option("chamber_temp_control",!is_BBL_printer);
toggle_option("support_chamber_temp_control",!is_BBL_printer);
toggle_option("support_air_filtration",!is_BBL_printer);
auto flavor = m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value;
bool is_marlin_flavor = flavor == gcfMarlinLegacy || flavor == gcfMarlinFirmware;