Omit BBL specific gcodes for other machines

This commit is contained in:
SoftFever 2022-10-22 00:19:08 +08:00
parent bab4f443e2
commit b7572b9004
4 changed files with 134 additions and 49 deletions

View file

@ -908,6 +908,11 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
BOOST_LOG_TRIVIAL(info) << boost::format("Will export G-code to %1% soon")%path;
print->set_started(psGCodeExport);
if (print->is_BBL_printer())
gcode_label_objects = false;
else
gcode_label_objects = true;
// check if any custom gcode contains keywords used by the gcode processor to
// produce time estimation and gcode toolpaths
std::vector<std::pair<std::string, std::string>> validation_res = DoExport::validate_custom_gcode(*print);
@ -1285,7 +1290,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
// modifies m_silent_time_estimator_enabled
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
const bool is_bbl_printers = print.is_BBL_printer();
// resets analyzer's tracking data
m_last_height = 0.f;
m_last_layer_z = 0.f;
@ -1349,18 +1354,49 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder).c_str());
file.write_format("; HEADER_BLOCK_END\n\n");
//BBS: write global config at the beginning of gcode file because printer need these config information
// Append full config, delimited by two 'phony' configuration keys CONFIG_BLOCK_START and CONFIG_BLOCK_END.
// The delimiters are structured as configuration key / value pairs to be parsable by older versions of PrusaSlicer G-code viewer.
// BBS: write global config at the beginning of gcode file because printer
// need these config information
// Append full config, delimited by two 'phony' configuration keys
// CONFIG_BLOCK_START and CONFIG_BLOCK_END. The delimiters are structured
// as configuration key / value pairs to be parsable by older versions of
// PrusaSlicer G-code viewer.
{
file.write_format("; hack-fix: write fake slicer info here so that Moonraker will extract thumbs.\n");
file.write_format("; %s\n\n",std::string(std::string("generated by SuperSlicer " SLIC3R_VERSION " on " ) + Slic3r::Utils::utc_timestamp()).c_str());
}
if (is_bbl_printers) {
file.write("; CONFIG_BLOCK_START\n");
std::string full_config;
append_full_config(print, full_config);
if (!full_config.empty())
file.write(full_config);
// SoftFever: write compatiple image
std::vector<int> temps_per_bed;
int first_layer_bed_temperature = 0;
get_bed_temperature(0, true, temps_per_bed,
first_layer_bed_temperature);
file.write_format("; first_layer_bed_temperature = %d\n",
first_layer_bed_temperature);
file.write_format(
"; first_layer_temperature = %d\n",
print.config().nozzle_temperature_initial_layer.get_at(0));
file.write("; CONFIG_BLOCK_END\n\n");
} else {
file.write_format("; hack-fix: write fake slicer info here so that "
"Moonraker will extract thumbs.\n");
file.write_format(
"; %s\n\n",
std::string(
std::string("generated by SuperSlicer " SLIC3R_VERSION " on ") +
Slic3r::Utils::utc_timestamp())
.c_str());
// BBS: add plate id into thumbnail render logic
DoExport::export_thumbnails_to_file(thumbnail_cb, print.get_plate_index(), { Vec2d(300, 300) },
DoExport::export_thumbnails_to_file(
thumbnail_cb, print.get_plate_index(), {Vec2d(300, 300)},
[&file](const char *sz) { file.write(sz); },
[&print]() { print.throw_if_canceled(); });
}
}
// Write some terse information on the slicing parameters.
@ -1504,7 +1540,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
m_placeholder_parser.set("first_layer_print_max", new ConfigOptionFloats({ bbox.max.x(), bbox.max.y() }));
m_placeholder_parser.set("first_layer_print_size", new ConfigOptionFloats({ bbox.size().x(), bbox.size().y() }));
}
float outer_wall_volumetric_speed = 0.0f;
{
int curr_bed_type = m_config.curr_bed_type.getInt();
@ -1528,7 +1564,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
}
Flow outer_wall_flow = Flow(outer_wall_line_width, m_config.layer_height, m_config.nozzle_diameter.get_at(initial_extruder_id));
float outer_wall_speed = print.default_region_config().outer_wall_speed.value;
float outer_wall_volumetric_speed = outer_wall_speed * outer_wall_flow.mm3_per_mm();
outer_wall_volumetric_speed = outer_wall_speed * outer_wall_flow.mm3_per_mm();
if (outer_wall_volumetric_speed > filament_max_volumetric_speed)
outer_wall_volumetric_speed = filament_max_volumetric_speed;
m_placeholder_parser.set("outer_wall_volumetric_speed", new ConfigOptionFloat(outer_wall_volumetric_speed));
@ -1591,12 +1627,20 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
if (this->m_objsWithBrim.empty() && this->m_objSupportsWithBrim.empty()) m_brim_done = true;
//BBS: open spaghetti detector
if (is_bbl_printers) {
// if (print.config().spaghetti_detector.value)
file.write("M981 S1 P20000 ;open spaghetti detector\n");
if(m_config.enable_pressure_advance.value)
{
file.write_format("M900 K%.3f ; Override pressure advance value\n",m_config.pressure_advance.values.front());
file.write_format("M900 K%.3f M%0.3f ; Override pressure advance value\n",
m_config.pressure_advance.values.front(),
outer_wall_volumetric_speed / (1.75 * 1.75 / 4 * 3.14) *
m_config.pressure_advance.values.front());
} else {
if (m_config.enable_pressure_advance.value) {
file.write_format("M900 K%.3f ; Override pressure advance value\n",
m_config.pressure_advance.values.front());
}
}
// Do all objects for each layer.
if (print.config().print_sequence == PrintSequence::ByObject) {
size_t finished_objects = 0;
@ -1659,7 +1703,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
this->process_layers(print, tool_ordering, collect_layers_to_print(object), *print_object_instance_sequential_active - object.instances().data(), file, prime_extruder);
//BBS: close powerlost recovery
{
if (m_second_layer_things_done) {
if (is_bbl_printers && m_second_layer_things_done) {
file.write("; close powerlost recovery\n");
file.write("M1003 S0\n");
}
@ -1730,7 +1774,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
this->process_layers(print, tool_ordering, print_object_instances_ordering, layers_to_print, file);
//BBS: close powerlost recovery
{
if (m_second_layer_things_done) {
if (is_bbl_printers && m_second_layer_things_done) {
file.write("; close powerlost recovery\n");
file.write("M1003 S0\n");
}
@ -1796,6 +1840,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
m_writer.extruders(),
// Modifies
print.m_print_statistics));
if (!is_bbl_printers) {
file.write("\n");
file.write("; CONFIG_BLOCK_START\n");
std::string full_config;
@ -1803,20 +1848,32 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
if (!full_config.empty())
file.write(full_config);
// SoftFever: write compatiple image
// SoftFever: write compatiple info
std::vector<int> temps_per_bed;
int first_layer_bed_temperature = 0;
get_bed_temperature(0, true, temps_per_bed, first_layer_bed_temperature);
file.write_format("; first_layer_bed_temperature = %d\n", first_layer_bed_temperature);
file.write_format("; first_layer_temperature = %d\n", print.config().nozzle_temperature_initial_layer.get_at(0));
file.write_format("; first_layer_bed_temperature = %d\n",
first_layer_bed_temperature);
file.write_format(
"; first_layer_temperature = %d\n",
print.config().nozzle_temperature_initial_layer.get_at(0));
file.write("; CONFIG_BLOCK_END\n\n");
file.write_format("; total filament used [g] = %.2lf\n", print.m_print_statistics.total_weight);
file.write_format("; total filament cost = %.2lf\n", print.m_print_statistics.total_cost);
file.write_format("; total filament used [g] = %.2lf\n",
print.m_print_statistics.total_weight);
file.write_format("; total filament cost = %.2lf\n",
print.m_print_statistics.total_cost);
if (print.m_print_statistics.total_toolchanges > 0)
file.write_format("; total filament change = %i\n", print.m_print_statistics.total_toolchanges);
file.write_format("; total filament change = %i\n",
print.m_print_statistics.total_toolchanges);
file.write_format("; total layers count = %i\n", m_layer_count);
file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder).c_str());
file.write_format(
";%s\n",
GCodeProcessor::reserved_tag(
GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder)
.c_str());
}
print.throw_if_canceled();
}
@ -2522,6 +2579,7 @@ GCode::LayerResult GCode::process_layer(
}
if (! first_layer && ! m_second_layer_things_done) {
if (print.is_BBL_printer()) {
// BBS: open powerlost recovery
{
gcode += "; open powerlost recovery\n";
@ -2535,7 +2593,7 @@ GCode::LayerResult GCode::process_layer(
gcode += "M400 P100\n";
gcode += this->unretract();
}
}
//BBS: reset acceleration at sencond layer
if (m_config.default_acceleration.value > 0 && m_config.initial_layer_acceleration.value > 0) {
double acceleration = m_config.default_acceleration.value;

View file

@ -728,6 +728,10 @@ public:
// Return 4 wipe tower corners in the world coordinates (shifted and rotated), including the wipe tower brim.
std::vector<Point> first_layer_wipe_tower_corners(bool check_wipe_tower_existance=true) const;
//SoftFever
bool &is_BBL_printer() { return m_isBBLPrinter; }
const bool is_BBL_printer() const { return m_isBBLPrinter; }
protected:
// Invalidates the step, and its depending steps in Print.
bool invalidate_step(PrintStep step);
@ -751,6 +755,9 @@ private:
PrintObjectPtrs m_objects;
PrintRegionPtrs m_print_regions;
//SoftFever
bool m_isBBLPrinter;
// Ordered collections of extrusion paths to build skirt loops and brim.
ExtrusionEntityCollection m_skirt;
// BBS: collecting extrusion paths to build brim by objs

View file

@ -183,6 +183,13 @@ std::string BackgroundSlicingProcess::output_filepath_for_project(const boost::f
void BackgroundSlicingProcess::process_fff()
{
assert(m_print == m_fff_print);
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
m_fff_print->is_BBL_printer() =
preset_bundle.printers.get_edited_preset().is_bbl_vendor_preset(
&preset_bundle);
//BBS: add the logic to process from an existed gcode file
if (m_print->finished()) {
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%: skip slicing, to process previous gcode file")%__LINE__;

View file

@ -918,10 +918,23 @@ void Sidebar::update_all_preset_comboboxes()
ams_btn->Show();
//update print button default value for bbl or third-party printer
wxGetApp().mainframe->set_print_button_to_default(MainFrame::PrintSelectType::ePrintPlate);
MonitorPanel *curr_monitor = wxGetApp().mainframe->m_monitor;
if(wxGetApp().mainframe->m_tabpanel->GetPage(3) !=
curr_monitor){
wxGetApp().mainframe->m_tabpanel->InsertPage(3,
curr_monitor, _L("Device"),
std::string("tab_monitor_active"),
std::string("tab_monitor_active"));
}
} else {
connection_btn->Show();
ams_btn->Hide();
wxGetApp().mainframe->set_print_button_to_default(MainFrame::PrintSelectType::eSendGcode);
MonitorPanel *curr_monitor = wxGetApp().mainframe->m_monitor;
if (wxGetApp().mainframe->m_tabpanel->GetPage(3) == curr_monitor) {
wxGetApp().mainframe->m_tabpanel->RemovePage(3);
}
}
// Update the print choosers to only contain the compatible presets, update the dirty flags.