ENH: add initial layer time to plate_x.json and slice_info.config

Jira: STUDIO-14504
Change-Id: I32460f1c19cce7c729806e35370e8b4b57aa069e
(cherry picked from commit 04a487d210134c28245c1f0f7d0986266a1c66f2)
This commit is contained in:
weizhen.xie 2025-09-16 10:08:44 +08:00 committed by Noisyfox
parent 778874aa01
commit 9f7ff97be6
8 changed files with 17 additions and 1 deletions

View file

@ -317,6 +317,7 @@ static constexpr const char* NOZZLE_TYPE_ATTR = "nozzle_types";
static constexpr const char* NOZZLE_DIAMETERS_ATTR = "nozzle_diameters";
static constexpr const char* SLICE_PREDICTION_ATTR = "prediction";
static constexpr const char* SLICE_WEIGHT_ATTR = "weight";
static constexpr const char* FIRST_LAYER_TIME_ATTR = "first_layer_time";
static constexpr const char* TIMELAPSE_TYPE_ATTR = "timelapse_type";
static constexpr const char* OUTSIDE_ATTR = "outside";
static constexpr const char* SUPPORT_USED_ATTR = "support_used";
@ -7917,6 +7918,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << TIMELAPSE_TYPE_ATTR << "\" " << VALUE_ATTR << "=\"" << timelapse_type << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SLICE_PREDICTION_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->get_gcode_prediction_str() << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SLICE_WEIGHT_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->get_gcode_weight_str() << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << FIRST_LAYER_TIME_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->first_layer_time << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << OUTSIDE_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->toolpath_outside << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << SUPPORT_USED_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->is_support_used << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << LABEL_OBJECT_ENABLED_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->is_label_object_enabled << "\"/>\n";

View file

@ -85,6 +85,7 @@ struct PlateData
std::string pattern_bbox_file;
std::string gcode_prediction;
std::string gcode_weight;
std::string first_layer_time;
std::string plate_name;
std::vector<FilamentInfo> slice_filaments_info;
std::vector<size_t> skipped_objects;

View file

@ -1987,7 +1987,7 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
if(is_BBL_Printer())
result->label_object_enabled = m_enable_exclude_object;
result->initial_layer_time = m_initial_layer_time;
// Write the profiler measurements to file
PROFILE_UPDATE();
PROFILE_OUTPUT(debug_out_path("gcode-export-profile.txt").c_str());
@ -3429,6 +3429,12 @@ void GCode::process_layers(
tbb::parallel_pipeline(12, generator & pressure_equalizer & cooling & fan_mover & pa_processor_filter & output);
else
tbb::parallel_pipeline(12, generator & cooling & fan_mover & pa_processor_filter & output);
for (auto& layer_res : layers_results) {
if (layer_res.layer_id == 0)
m_initial_layer_time = layer_res.layer_time;
}
}
// Process all layers of a single object instance (sequential mode) with a parallel pipeline:

View file

@ -618,6 +618,8 @@ private:
std::vector<const PrintObject*> m_printed_objects;
float m_initial_layer_time;
// Processor
GCodeProcessor m_processor;

View file

@ -161,6 +161,7 @@ class Print;
ConflictResultOpt conflict_result;
GCodeCheckResult gcode_check_result;
FilamentPrintableResult filament_printable_reuslt;
float initial_layer_time;
struct SettingsIds
{

View file

@ -78,6 +78,7 @@ struct PlateBBoxData
int first_extruder = 0;
float nozzle_diameter = 0.4;
std::string bed_type;
float first_layer_time;
// version 1: use view type ColorPrint (filament color)
// version 2: use view type FilamentId (filament id)
int version = 2;
@ -91,6 +92,7 @@ struct PlateBBoxData
j["nozzle_diameter"] = nozzle_diameter;
j["version"] = version;
j["bed_type"] = bed_type;
j["first_layer_time"] = first_layer_time;
for (const auto& bbox : bbox_objs) {
nlohmann::json j_bbox;
bbox.to_json(j_bbox);

View file

@ -5920,6 +5920,7 @@ int PartPlateList::store_to_3mf_structure(PlateDataPtrs& plate_data_list, bool w
plate_data_item->is_label_object_enabled = m_plate_list[i]->m_gcode_result->label_object_enabled;
plate_data_item->limit_filament_maps = m_plate_list[i]->m_gcode_result->limit_filament_maps;
plate_data_item->layer_filaments = m_plate_list[i]->m_gcode_result->layer_filaments;
plate_data_item->first_layer_time = std::to_string(m_plate_list[i]->cali_bboxes_data.first_layer_time);
Print *print = nullptr;
m_plate_list[i]->get_print((PrintBase **) &print, nullptr, nullptr);
if (print) {

View file

@ -9662,6 +9662,7 @@ PlateBBoxData Plater::priv::generate_first_layer_bbox()
bboxdata.is_seq_print = (curr_plate_seq == PrintSequence::ByObject);
bboxdata.first_extruder = print->get_tool_ordering().first_extruder();
bboxdata.bed_type = bed_type_to_gcode_string(print->config().curr_bed_type.value);
bboxdata.first_layer_time = partplate_list.get_curr_plate()->get_slice_result()->initial_layer_time;
// get nozzle diameter
auto opt_nozzle_diameters = print->config().option<ConfigOptionFloats>("nozzle_diameter");
if (opt_nozzle_diameters != nullptr)