tweak generator info and use local time stamp for better readability

This commit is contained in:
SoftFever 2023-03-14 22:12:33 +08:00
parent f914a36a7f
commit 2895477da4
4 changed files with 15 additions and 10 deletions

View file

@ -1193,6 +1193,9 @@ ConfigSubstitutions ConfigBase::load_from_gcode_file(const std::string &file, Fo
std::string bambuslicer_gcode_header = "; ";
bambuslicer_gcode_header += SLIC3R_APP_NAME;
std::string orcaslicer_gcode_header = std::string("; generated by ");
orcaslicer_gcode_header += Slic3r::header_slic3r_generated();
std::string header;
bool header_found = false;
while (std::getline(ifs, header)) {
@ -1202,7 +1205,8 @@ ConfigSubstitutions ConfigBase::load_from_gcode_file(const std::string &file, Fo
line_c = skip_word(line_c);
line_c = skip_whitespaces(line_c);
// BBS
if (strncmp(bambuslicer_gcode_header.c_str(), line_c, strlen(bambuslicer_gcode_header.c_str())) == 0) {
if (strncmp(bambuslicer_gcode_header.c_str(), line_c, strlen(bambuslicer_gcode_header.c_str())) == 0 ||
strncmp(orcaslicer_gcode_header.c_str(), line_c, strlen(orcaslicer_gcode_header.c_str())) == 0) {
header_found = true;
break;
}

View file

@ -1499,7 +1499,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
file.write_format("; HEADER_BLOCK_START\n");
// Write information on the generator.
file.write_format("; %s\n", Slic3r::header_slic3r_generated().c_str());
file.write_format("; generated by %s on %s\n", Slic3r::header_slic3r_generated().c_str(), Slic3r::Utils::local_timestamp().c_str());
//BBS: total estimated printing time
file.write_format(";%s\n", GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Estimated_Printing_Time_Placeholder).c_str());
//BBS: total layer number
@ -1531,13 +1531,10 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
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 " SoftFever_VERSION " on ") +
Slic3r::Utils::utc_timestamp())
.c_str());
"preprocess_cancellation can process.\n");
file.write_format("; %s\n\n", std::string(std::string("generated by SuperSlicer " SoftFever_VERSION " on ") +
Slic3r::Utils::local_timestamp())
.c_str());
DoExport::export_thumbnails_to_file(
thumbnail_cb, print.get_plate_index(), print.full_print_config().option<ConfigOptionPoints>("thumbnails")->values,

View file

@ -784,7 +784,7 @@ std::string Model::get_backup_path()
std::time_t t = std::time(0);
std::tm* now_time = std::localtime(&t);
std::stringstream buf;
buf << "/bamboo_model/";
buf << "/orcaslicer_model/";
buf << std::put_time(now_time, "%a_%b_%d/%H_%M_%S#");
buf << pid << "#";
buf << this->id().id;

View file

@ -32,6 +32,10 @@ inline std::string utc_timestamp()
return utc_timestamp(get_current_time_utc());
}
inline std::string local_timestamp() {
return time2str(get_current_time_utc(), TimeZone::local, TimeFormat::gcode);
}
// String to time_t function. Returns time_t(-1) if fails to parse the input.
time_t str2time(const std::string &str, TimeZone zone, TimeFormat fmt);