Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2017-12-11 13:11:54 +0300
committerEnrico Turri <enricoturri@seznam.cz>2017-12-11 13:11:54 +0300
commitbea9628be08d9c2be9ba49c7538112d39b1d6fa8 (patch)
tree12aaeffb29fe1cf70c516c9a641f7f193efe5918 /xs/src/libslic3r
parenta0a503e4a884775d21404afd0d2acc019a27a88d (diff)
time estimation shown in GUI after gcode export
Diffstat (limited to 'xs/src/libslic3r')
-rw-r--r--xs/src/libslic3r/GCode.cpp54
-rw-r--r--xs/src/libslic3r/GCode.hpp6
-rw-r--r--xs/src/libslic3r/Print.hpp6
3 files changed, 11 insertions, 55 deletions
diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp
index 018c01b71..cf826ff68 100644
--- a/xs/src/libslic3r/GCode.cpp
+++ b/xs/src/libslic3r/GCode.cpp
@@ -259,7 +259,6 @@ std::string WipeTowerIntegration::finalize(GCode &gcodegen)
#define EXTRUDER_CONFIG(OPT) m_config.OPT.get_at(m_writer.extruder()->id())
-#if ENABLE_TIME_ESTIMATOR
// Helper class for writing to file with/without time estimation
class Write
{
@@ -296,18 +295,12 @@ public:
//std::string Write::s_cache = "";
GCodeTimeEstimator* Write::s_time_estimator = nullptr;
-#endif // ENABLE_TIME_ESTIMATOR
inline void write(FILE *file, const std::string &what)
{
-#if ENABLE_TIME_ESTIMATOR
Write::write(file, what);
-#else
- fwrite(what.data(), 1, what.size(), file);
-#endif // ENABLE_TIME_ESTIMATOR
}
-#if ENABLE_TIME_ESTIMATOR
inline void write_format(FILE* file, const char* format, ...)
{
char buffer[1024];
@@ -319,17 +312,11 @@ inline void write_format(FILE* file, const char* format, ...)
if (res >= 0)
write(file, buffer);
}
-#endif // ENABLE_TIME_ESTIMATOR
inline void writeln(FILE *file, const std::string &what)
{
if (! what.empty()) {
-#if ENABLE_TIME_ESTIMATOR
write_format(file, "%s\n", what.c_str());
-#else
- write(file, what);
- fprintf(file, "\n");
-#endif // ENABLE_TIME_ESTIMATOR
}
}
@@ -436,27 +423,14 @@ bool GCode::do_export(Print *print, const char *path)
if (! result)
boost::nowide::remove(path_tmp.c_str());
- // debug only -> tests time estimator from file
- {
- GCodeTimeEstimator timeEstimator;
- timeEstimator.calculate_time_from_file(path);
- float time = timeEstimator.get_time();
- std::string timeHMS = timeEstimator.get_time_hms();
-
- std::cout << std::endl << "Time estimated from file:" << std::endl;
- std::cout << std::endl << ">>> estimated time: " << timeHMS << " (" << time << " seconds)" << std::endl << std::endl;
- }
-
return result;
}
bool GCode::_do_export(Print &print, FILE *file)
{
-#if ENABLE_TIME_ESTIMATOR
// resets time estimator
m_time_estimator.reset();
Write::set_time_estimator(&m_time_estimator);
-#endif // ENABLE_TIME_ESTIMATOR
// How many times will be change_layer() called?
// change_layer() in turn increments the progress bar status.
@@ -780,28 +754,16 @@ bool GCode::_do_export(Print &print, FILE *file)
bbox_prime.offset(0.5f);
// Beep for 500ms, tone 800Hz. Yet better, play some Morse.
write(file, this->retract());
-#if ENABLE_TIME_ESTIMATOR
- write_format(file, "M300 S800 P500\n");
-#else
- fprintf(file, "M300 S800 P500\n");
-#endif // ENABLE_TIME_ESTIMATOR
+ write(file, "M300 S800 P500\n");
if (bbox_prime.overlap(bbox_print)) {
// Wait for the user to remove the priming extrusions, otherwise they would
// get covered by the print.
-#if ENABLE_TIME_ESTIMATOR
- write_format(file, "M1 Remove priming towers and click button.\n");
-#else
- fprintf(file, "M1 Remove priming towers and click button.\n");
-#endif // ENABLE_TIME_ESTIMATOR
- }
+ write(file, "M1 Remove priming towers and click button.\n");
+ }
else {
// Just wait for a bit to let the user check, that the priming succeeded.
//TODO Add a message explaining what the printer is waiting for. This needs a firmware fix.
-#if ENABLE_TIME_ESTIMATOR
- write_format(file, "M1 S10\n");
-#else
- fprintf(file, "M1 S10\n");
-#endif // ENABLE_TIME_ESTIMATOR
+ write(file, "M1 S10\n");
}
} else
write(file, WipeTowerIntegration::prime_single_color_print(print, initial_extruder_id, *this));
@@ -830,12 +792,16 @@ bool GCode::_do_export(Print &print, FILE *file)
write(file, m_writer.update_progress(m_layer_count, m_layer_count, true)); // 100%
write(file, m_writer.postamble());
+ // calculates estimated printing time
+ m_time_estimator.calculate_time();
+
// Get filament stats.
print.filament_stats.clear();
print.total_used_filament = 0.;
print.total_extruded_volume = 0.;
print.total_weight = 0.;
print.total_cost = 0.;
+ print.estimated_print_time = (double)m_time_estimator.get_time() / 60.0;
for (const Extruder &extruder : m_writer.extruders()) {
double used_filament = extruder.used_filament();
double extruded_volume = extruder.extruded_volume();
@@ -855,11 +821,7 @@ bool GCode::_do_export(Print &print, FILE *file)
print.total_extruded_volume = print.total_extruded_volume + extruded_volume;
}
fprintf(file, "; total filament cost = %.1lf\n", print.total_cost);
-
-#if ENABLE_TIME_ESTIMATOR
- m_time_estimator.calculate_time();
fprintf(file, "; estimated printing time = %s\n", m_time_estimator.get_time_hms());
-#endif // ENABLE_TIME_ESTIMATOR
// Append full config.
fprintf(file, "\n");
diff --git a/xs/src/libslic3r/GCode.hpp b/xs/src/libslic3r/GCode.hpp
index ba5270785..b29a6ed2f 100644
--- a/xs/src/libslic3r/GCode.hpp
+++ b/xs/src/libslic3r/GCode.hpp
@@ -1,8 +1,6 @@
#ifndef slic3r_GCode_hpp_
#define slic3r_GCode_hpp_
-#define ENABLE_TIME_ESTIMATOR 1
-
#include "libslic3r.h"
#include "ExPolygon.hpp"
#include "GCodeWriter.hpp"
@@ -17,9 +15,7 @@
#include "GCode/SpiralVase.hpp"
#include "GCode/ToolOrdering.hpp"
#include "GCode/WipeTower.hpp"
-#if ENABLE_TIME_ESTIMATOR
#include "GCodeTimeEstimator.hpp"
-#endif // ENABLE_TIME_ESTIMATOR
#include "EdgeGrid.hpp"
#include <memory>
@@ -272,10 +268,8 @@ protected:
// Index of a last object copy extruded.
std::pair<const PrintObject*, Point> m_last_obj_copy;
-#if ENABLE_TIME_ESTIMATOR
// Time estimator
GCodeTimeEstimator m_time_estimator;
-#endif // ENABLE_TIME_ESTIMATOR
std::string _extrude(const ExtrusionPath &path, std::string description = "", double speed = -1);
void _print_first_layer_extruder_temperatures(FILE *file, Print &print, unsigned int first_printing_extruder_id, bool wait);
diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp
index c4093b795..bf137924a 100644
--- a/xs/src/libslic3r/Print.hpp
+++ b/xs/src/libslic3r/Print.hpp
@@ -233,14 +233,14 @@ public:
PrintRegionPtrs regions;
PlaceholderParser placeholder_parser;
// TODO: status_cb
- double total_used_filament, total_extruded_volume, total_cost, total_weight;
- std::map<size_t,float> filament_stats;
+ double total_used_filament, total_extruded_volume, total_cost, total_weight, estimated_print_time;
+ std::map<size_t, float> filament_stats;
PrintState<PrintStep, psCount> state;
// ordered collections of extrusion paths to build skirt loops and brim
ExtrusionEntityCollection skirt, brim;
- Print() : total_used_filament(0), total_extruded_volume(0) { restart(); }
+ Print() : total_used_filament(0), total_extruded_volume(0), estimated_print_time(0) { restart(); }
~Print() { clear_objects(); }
// methods for handling objects