mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-09-22 02:03:16 +08:00
feat:add more slice time details to json file
Change-Id: I6c29658a051144dda772b42603db6585ea58816b jira: none (cherry picked from commit d1e4b98db6ed0f8e1e29d7e8bdcdda96948d10dd) (cherry picked from commit 76e3e210e0d22592172e236609f83fcbebea65ea)
This commit is contained in:
parent
55ccb97719
commit
f9bc421651
@ -150,6 +150,9 @@ typedef struct _sliced_plate_info{
|
||||
int plate_id{0};
|
||||
size_t sliced_time {0};
|
||||
size_t sliced_time_with_cache {0};
|
||||
size_t make_perimeters_time {0};
|
||||
size_t infill_time {0};
|
||||
size_t generate_support_material_time {0};
|
||||
size_t triangle_count{0};
|
||||
std::string warning_message;
|
||||
}sliced_plate_info_t;
|
||||
@ -426,6 +429,9 @@ void record_exit_reson(std::string outputdir, int code, int plate_id, std::strin
|
||||
plate_json["id"] = sliced_info.sliced_plates[index].plate_id;
|
||||
plate_json["sliced_time"] = sliced_info.sliced_plates[index].sliced_time;
|
||||
plate_json["sliced_time_with_cache"] = sliced_info.sliced_plates[index].sliced_time_with_cache;
|
||||
plate_json["make_perimeters_time"] = sliced_info.sliced_plates[index].make_perimeters_time;
|
||||
plate_json["infill_time"] = sliced_info.sliced_plates[index].infill_time;
|
||||
plate_json["generate_support_material_time"] = sliced_info.sliced_plates[index].generate_support_material_time;
|
||||
plate_json["triangle_count"] = sliced_info.sliced_plates[index].triangle_count;
|
||||
plate_json["warning_message"] = sliced_info.sliced_plates[index].warning_message;
|
||||
j["sliced_plates"].push_back(plate_json);
|
||||
@ -4783,7 +4789,14 @@ int CLI::run(int argc, char **argv)
|
||||
|
||||
model.curr_plate_index = index;
|
||||
BOOST_LOG_TRIVIAL(info) << boost::format("Plate %1%: pre_check %2%, start")%(index+1)%pre_check;
|
||||
long long start_time = 0, end_time = 0, temp_time = 0, time_using_cache = 0;
|
||||
long long start_time = 0, end_time = 0, temp_time = 0;
|
||||
|
||||
std::unordered_map<std::string, long long> slice_time;
|
||||
slice_time[TIME_USING_CACHE] = 0;
|
||||
slice_time[TIME_MAKE_PERIMETERS] = 0;
|
||||
slice_time[TIME_INFILL] = 0;
|
||||
slice_time[TIME_GENERATE_SUPPORT] = 0;
|
||||
|
||||
start_time = (long long)Slic3r::Utils::get_current_milliseconds_time_utc();
|
||||
//get the current partplate
|
||||
Slic3r::GUI::PartPlate* part_plate = partplate_list.get_plate(index);
|
||||
@ -5019,8 +5032,8 @@ int CLI::run(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
else {
|
||||
print->process(&time_using_cache);
|
||||
BOOST_LOG_TRIVIAL(info) << "print::process: first time_using_cache is " << time_using_cache << " secs.";
|
||||
print->process(&slice_time);
|
||||
BOOST_LOG_TRIVIAL(info) << "print::process: first time_using_cache is " << slice_time[TIME_USING_CACHE] << " secs.";
|
||||
}
|
||||
if (printer_technology == ptFFF) {
|
||||
std::string conflict_result = print_fff->get_conflict_string();
|
||||
@ -5074,8 +5087,8 @@ int CLI::run(int argc, char **argv)
|
||||
BOOST_LOG_TRIVIAL(info) << "process finished, will export gcode temporily to " << outfile << std::endl;
|
||||
temp_time = (long long)Slic3r::Utils::get_current_milliseconds_time_utc();
|
||||
outfile = print_fff->export_gcode(outfile, gcode_result, nullptr);
|
||||
time_using_cache = time_using_cache + ((long long)Slic3r::Utils::get_current_milliseconds_time_utc() - temp_time);
|
||||
BOOST_LOG_TRIVIAL(info) << "export_gcode finished: time_using_cache update to " << time_using_cache << " secs.";
|
||||
slice_time[TIME_USING_CACHE] = slice_time[TIME_USING_CACHE] + ((long long)Slic3r::Utils::get_current_milliseconds_time_utc() - temp_time);
|
||||
BOOST_LOG_TRIVIAL(info) << "export_gcode finished: time_using_cache update to " << slice_time[TIME_USING_CACHE] << " secs.";
|
||||
|
||||
//outfile_final = (dynamic_cast<Print*>(print))->print_statistics().finalize_output_path(outfile);
|
||||
//m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, [this](const ThumbnailsParams& params) { return this->render_thumbnails(params); });
|
||||
@ -5119,12 +5132,16 @@ int CLI::run(int argc, char **argv)
|
||||
}
|
||||
end_time = (long long)Slic3r::Utils::get_current_milliseconds_time_utc();
|
||||
sliced_plate_info.sliced_time = end_time - start_time;
|
||||
sliced_plate_info.sliced_time_with_cache = time_using_cache;
|
||||
sliced_plate_info.sliced_time_with_cache = slice_time[TIME_USING_CACHE];
|
||||
sliced_plate_info.make_perimeters_time = slice_time[TIME_MAKE_PERIMETERS];
|
||||
sliced_plate_info.infill_time = slice_time[TIME_INFILL];
|
||||
sliced_plate_info.generate_support_material_time = slice_time[TIME_GENERATE_SUPPORT];
|
||||
|
||||
|
||||
if (max_slicing_time_per_plate != 0) {
|
||||
long long time_cost = end_time - start_time;
|
||||
if (time_cost > max_slicing_time_per_plate) {
|
||||
sliced_plate_info.warning_message = (boost::format("plate %1%'s slice time %2% exceeds the limit %3%, return error.")%(index+1) %time_cost %max_slicing_time_per_plate).str();
|
||||
if (time_cost > max_slicing_time_per_plate * 1000) {
|
||||
sliced_plate_info.warning_message = (boost::format("plate %1%'s slice time %2% exceeds the limit %3%, return error.")%(index+1) %time_cost %(max_slicing_time_per_plate * 1000)).str();
|
||||
BOOST_LOG_TRIVIAL(error) << sliced_plate_info.warning_message;
|
||||
sliced_info.sliced_plates.push_back(sliced_plate_info);
|
||||
record_exit_reson(outfile_dir, CLI_SLICING_TIME_EXCEEDS_LIMIT, index+1, cli_errors[CLI_SLICING_TIME_EXCEEDS_LIMIT], sliced_info);
|
||||
|
@ -1547,11 +1547,16 @@ std::map<ObjectID, unsigned int> getObjectExtruderMap(const Print& print) {
|
||||
}
|
||||
|
||||
// Slicing process, running at a background thread.
|
||||
void Print::process(long long *time_cost_with_cache, bool use_cache)
|
||||
void Print::process(std::unordered_map<std::string, long long>* slice_time, bool use_cache)
|
||||
{
|
||||
long long start_time = 0, end_time = 0;
|
||||
if (time_cost_with_cache)
|
||||
*time_cost_with_cache = 0;
|
||||
if (slice_time) {
|
||||
(*slice_time)[TIME_USING_CACHE] = 0;
|
||||
(*slice_time)[TIME_MAKE_PERIMETERS] = 0;
|
||||
(*slice_time)[TIME_INFILL] = 0;
|
||||
(*slice_time)[TIME_GENERATE_SUPPORT] = 0;
|
||||
}
|
||||
|
||||
|
||||
name_tbb_thread_pool_threads_set_locale();
|
||||
|
||||
@ -1657,8 +1662,16 @@ void Print::process(long long *time_cost_with_cache, bool use_cache)
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": total object counts %1% in current print, need to slice %2%")%m_objects.size()%need_slicing_objects.size();
|
||||
BOOST_LOG_TRIVIAL(info) << "Starting the slicing process." << log_memory_info();
|
||||
|
||||
|
||||
if (!use_cache) {
|
||||
for (PrintObject *obj : m_objects) {
|
||||
|
||||
if (slice_time) {
|
||||
start_time = (long long)Slic3r::Utils::get_current_milliseconds_time_utc();
|
||||
}
|
||||
|
||||
|
||||
for (PrintObject* obj : m_objects) {
|
||||
if (need_slicing_objects.count(obj) != 0) {
|
||||
obj->make_perimeters();
|
||||
}
|
||||
@ -1669,6 +1682,13 @@ void Print::process(long long *time_cost_with_cache, bool use_cache)
|
||||
obj->set_done(posPerimeters);
|
||||
}
|
||||
}
|
||||
|
||||
if (slice_time) {
|
||||
end_time = (long long)Slic3r::Utils::get_current_milliseconds_time_utc();
|
||||
(*slice_time)[TIME_MAKE_PERIMETERS] = (*slice_time)[TIME_MAKE_PERIMETERS] + end_time - start_time;
|
||||
start_time = (long long)Slic3r::Utils::get_current_milliseconds_time_utc();
|
||||
}
|
||||
|
||||
for (PrintObject *obj : m_objects) {
|
||||
if (need_slicing_objects.count(obj) != 0) {
|
||||
obj->infill();
|
||||
@ -1680,6 +1700,12 @@ void Print::process(long long *time_cost_with_cache, bool use_cache)
|
||||
obj->set_done(posInfill);
|
||||
}
|
||||
}
|
||||
|
||||
if (slice_time) {
|
||||
end_time = (long long)Slic3r::Utils::get_current_milliseconds_time_utc();
|
||||
(*slice_time)[TIME_INFILL] = (*slice_time)[TIME_INFILL] + end_time - start_time;
|
||||
}
|
||||
|
||||
for (PrintObject *obj : m_objects) {
|
||||
if (need_slicing_objects.count(obj) != 0) {
|
||||
obj->ironing();
|
||||
@ -1690,6 +1716,10 @@ void Print::process(long long *time_cost_with_cache, bool use_cache)
|
||||
}
|
||||
}
|
||||
|
||||
if (slice_time) {
|
||||
start_time = (long long)Slic3r::Utils::get_current_milliseconds_time_utc();
|
||||
}
|
||||
|
||||
tbb::parallel_for(tbb::blocked_range<int>(0, int(m_objects.size())),
|
||||
[this, need_slicing_objects](const tbb::blocked_range<int>& range) {
|
||||
for (int i = range.begin(); i < range.end(); i++) {
|
||||
@ -1705,6 +1735,11 @@ void Print::process(long long *time_cost_with_cache, bool use_cache)
|
||||
}
|
||||
);
|
||||
|
||||
if (slice_time) {
|
||||
end_time = (long long)Slic3r::Utils::get_current_milliseconds_time_utc();
|
||||
(*slice_time)[TIME_GENERATE_SUPPORT] = (*slice_time)[TIME_GENERATE_SUPPORT] + end_time - start_time;
|
||||
}
|
||||
|
||||
for (PrintObject* obj : m_objects) {
|
||||
if (need_slicing_objects.count(obj) != 0) {
|
||||
obj->detect_overhangs_for_lift();
|
||||
@ -1767,8 +1802,9 @@ void Print::process(long long *time_cost_with_cache, bool use_cache)
|
||||
if (this->set_started(psSkirtBrim)) {
|
||||
this->set_status(70, L("Generating skirt & brim"));
|
||||
|
||||
if (time_cost_with_cache)
|
||||
start_time = (long long)Slic3r::Utils::get_current_time_utc();
|
||||
if (slice_time) {
|
||||
start_time = (long long)Slic3r::Utils::get_current_milliseconds_time_utc();
|
||||
}
|
||||
|
||||
m_skirt.clear();
|
||||
m_skirt_convex_hull.clear();
|
||||
@ -1855,9 +1891,9 @@ void Print::process(long long *time_cost_with_cache, bool use_cache)
|
||||
this->finalize_first_layer_convex_hull();
|
||||
this->set_done(psSkirtBrim);
|
||||
|
||||
if (time_cost_with_cache) {
|
||||
end_time = (long long)Slic3r::Utils::get_current_time_utc();
|
||||
*time_cost_with_cache = *time_cost_with_cache + end_time - start_time;
|
||||
if (slice_time) {
|
||||
end_time = (long long)Slic3r::Utils::get_current_milliseconds_time_utc();
|
||||
(*slice_time)[TIME_USING_CACHE] = (*slice_time)[TIME_USING_CACHE] + end_time - start_time;
|
||||
}
|
||||
}
|
||||
//BBS
|
||||
|
@ -39,6 +39,11 @@ class TreeSupport;
|
||||
|
||||
#define MARGIN_HEIGHT 1.5
|
||||
#define MAX_OUTER_NOZZLE_RADIUS 4
|
||||
#define TIME_USING_CACHE "time_using_cache"
|
||||
#define TIME_MAKE_PERIMETERS "make_perimeters_time"
|
||||
#define TIME_INFILL "infill_time"
|
||||
#define TIME_GENERATE_SUPPORT "generate_support_material_time"
|
||||
|
||||
// BBS: move from PrintObjectSlice.cpp
|
||||
struct VolumeSlices
|
||||
{
|
||||
@ -717,7 +722,7 @@ public:
|
||||
|
||||
ApplyStatus apply(const Model &model, DynamicPrintConfig config) override;
|
||||
|
||||
void process(long long *time_cost_with_cache = nullptr, bool use_cache = false) override;
|
||||
void process(std::unordered_map<std::string, long long>* slice_time = nullptr, bool use_cache = false) override;
|
||||
// Exports G-code into a file name based on the path_template, returns the file path of the generated G-code file.
|
||||
// If preview_data is not null, the preview_data is filled in for the G-code visualization (not used by the command line Slic3r).
|
||||
std::string export_gcode(const std::string& path_template, GCodeProcessorResult* result, ThumbnailsGeneratorCallback thumbnail_cb = nullptr);
|
||||
|
@ -423,7 +423,7 @@ public:
|
||||
// After calling the apply() function, call set_task() to limit the task to be processed by process().
|
||||
virtual void set_task(const TaskParams ¶ms) {}
|
||||
// Perform the calculation. This is the only method that is to be called at a worker thread.
|
||||
virtual void process(long long *time_cost_with_cache = nullptr, bool use_cache = false) = 0;
|
||||
virtual void process(std::unordered_map<std::string, long long>* slice_time = nullptr, bool use_cache = false) = 0;
|
||||
virtual int export_cached_data(const std::string& dir_path, bool with_space=false) { return 0;}
|
||||
virtual int load_cached_data(const std::string& directory) { return 0;}
|
||||
// Clean up after process() finished, either with success, error or if canceled.
|
||||
|
@ -686,7 +686,7 @@ bool SLAPrint::invalidate_step(SLAPrintStep step)
|
||||
return invalidated;
|
||||
}
|
||||
|
||||
void SLAPrint::process(long long *time_cost_with_cache, bool use_cache)
|
||||
void SLAPrint::process(std::unordered_map<std::string, long long>* slice_time, bool use_cache)
|
||||
{
|
||||
if (m_objects.empty())
|
||||
return;
|
||||
|
@ -451,7 +451,7 @@ public:
|
||||
std::vector<ObjectID> print_object_ids() const override;
|
||||
ApplyStatus apply(const Model &model, DynamicPrintConfig config) override;
|
||||
void set_task(const TaskParams ¶ms) override;
|
||||
void process(long long *time_cost_with_cache = nullptr, bool use_cache = false) override;
|
||||
void process(std::unordered_map<std::string, long long>* slice_time = nullptr, bool use_cache = false) override;
|
||||
void finalize() override;
|
||||
// Returns true if an object step is done on all objects and there's at least one object.
|
||||
bool is_step_done(SLAPrintObjectStep step) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user