SlicedInfo: Removed secondes from estimated times

This commit is contained in:
YuSanka 2020-02-10 11:56:49 +01:00
parent d491a38fd7
commit d81f7d8465
3 changed files with 36 additions and 4 deletions

View File

@ -1031,8 +1031,8 @@ namespace DoExport {
std::string filament_stats_string_out;
print_statistics.clear();
print_statistics.estimated_normal_print_time = normal_time_estimator.get_time_dhms();
print_statistics.estimated_silent_print_time = silent_time_estimator_enabled ? silent_time_estimator.get_time_dhms() : "N/A";
print_statistics.estimated_normal_print_time = normal_time_estimator.get_time_dhm/*s*/();
print_statistics.estimated_silent_print_time = silent_time_estimator_enabled ? silent_time_estimator.get_time_dhm/*s*/() : "N/A";
print_statistics.estimated_normal_color_print_times = normal_time_estimator.get_color_times_dhms(true);
if (silent_time_estimator_enabled)
print_statistics.estimated_silent_color_print_times = silent_time_estimator.get_color_times_dhms(true);
@ -1528,9 +1528,9 @@ void GCode::_do_export(Print& print, FILE* file)
_write_format(file, "; total filament cost = %.1lf\n", print.m_print_statistics.total_cost);
if (print.m_print_statistics.total_toolchanges > 0)
_write_format(file, "; total toolchanges = %i\n", print.m_print_statistics.total_toolchanges);
_write_format(file, "; estimated printing time (normal mode) = %s\n", m_normal_time_estimator.get_time_dhms().c_str());
_write_format(file, "; estimated printing time (normal mode) = %s\n", m_normal_time_estimator.get_time_dhm/*s*/().c_str());
if (m_silent_time_estimator_enabled)
_write_format(file, "; estimated printing time (silent mode) = %s\n", m_silent_time_estimator.get_time_dhms().c_str());
_write_format(file, "; estimated printing time (silent mode) = %s\n", m_silent_time_estimator.get_time_dhm/*s*/().c_str());
// Append full config.
_write(file, "\n");

View File

@ -707,6 +707,11 @@ namespace Slic3r {
return _get_time_dhms(get_time());
}
std::string GCodeTimeEstimator::get_time_dhm() const
{
return _get_time_dhm(get_time());
}
std::string GCodeTimeEstimator::get_time_minutes() const
{
return _get_time_minutes(get_time());
@ -1616,6 +1621,28 @@ namespace Slic3r {
return buffer;
}
std::string GCodeTimeEstimator::_get_time_dhm(float time_in_secs)
{
int days = (int)(time_in_secs / 86400.0f);
time_in_secs -= (float)days * 86400.0f;
int hours = (int)(time_in_secs / 3600.0f);
time_in_secs -= (float)hours * 3600.0f;
int minutes = (int)(time_in_secs / 60.0f);
time_in_secs -= (float)minutes * 60.0f;
char buffer[64];
if (days > 0)
::sprintf(buffer, "%dd %dh %dm", days, hours, minutes);
else if (hours > 0)
::sprintf(buffer, "%dh %dm", hours, minutes);
else if (minutes > 0)
::sprintf(buffer, "%dm", minutes);
else
::sprintf(buffer, "%ds", (int)time_in_secs);
return buffer;
}
std::string GCodeTimeEstimator::_get_time_minutes(float time_in_secs)
{
return std::to_string((int)(::roundf(time_in_secs / 60.0f)));

View File

@ -363,6 +363,9 @@ namespace Slic3r {
// Returns the estimated time, in format DDd HHh MMm SSs
std::string get_time_dhms() const;
// Returns the estimated time, in format DDd HHh MMm
std::string get_time_dhm() const;
// Returns the estimated time, in minutes (integer)
std::string get_time_minutes() const;
@ -473,6 +476,8 @@ namespace Slic3r {
// Returns the given time is seconds in format DDd HHh MMm SSs
static std::string _get_time_dhms(float time_in_secs);
// Returns the given time is minutes in format DDd HHh MMm
static std::string _get_time_dhm(float time_in_secs);
// Returns the given, in minutes (integer)
static std::string _get_time_minutes(float time_in_secs);