mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
ENABLE_GCODE_VIEWER -> Integration of time estimator into GCodeProcessor
This commit is contained in:
parent
755fdb5ab4
commit
3a88e69896
9 changed files with 1631 additions and 704 deletions
|
@ -48,32 +48,32 @@ using namespace std::literals::string_view_literals;
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
//! macro used to mark string used at localization,
|
//! macro used to mark string used at localization,
|
||||||
//! return same string
|
//! return same string
|
||||||
#define L(s) (s)
|
#define L(s) (s)
|
||||||
#define _(s) Slic3r::I18N::translate(s)
|
#define _(s) Slic3r::I18N::translate(s)
|
||||||
|
|
||||||
// Only add a newline in case the current G-code does not end with a newline.
|
// Only add a newline in case the current G-code does not end with a newline.
|
||||||
static inline void check_add_eol(std::string &gcode)
|
static inline void check_add_eol(std::string& gcode)
|
||||||
{
|
{
|
||||||
if (! gcode.empty() && gcode.back() != '\n')
|
if (!gcode.empty() && gcode.back() != '\n')
|
||||||
gcode += '\n';
|
gcode += '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Return true if tch_prefix is found in custom_gcode
|
// Return true if tch_prefix is found in custom_gcode
|
||||||
static bool custom_gcode_changes_tool(const std::string& custom_gcode, const std::string& tch_prefix, unsigned next_extruder)
|
static bool custom_gcode_changes_tool(const std::string& custom_gcode, const std::string& tch_prefix, unsigned next_extruder)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
size_t from_pos = 0;
|
size_t from_pos = 0;
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
while ((pos = custom_gcode.find(tch_prefix, from_pos)) != std::string::npos) {
|
while ((pos = custom_gcode.find(tch_prefix, from_pos)) != std::string::npos) {
|
||||||
if (pos+1 == custom_gcode.size())
|
if (pos + 1 == custom_gcode.size())
|
||||||
break;
|
break;
|
||||||
from_pos = pos+1;
|
from_pos = pos + 1;
|
||||||
// only whitespace is allowed before the command
|
// only whitespace is allowed before the command
|
||||||
while (--pos < custom_gcode.size() && custom_gcode[pos] != '\n') {
|
while (--pos < custom_gcode.size() && custom_gcode[pos] != '\n') {
|
||||||
if (! std::isspace(custom_gcode[pos]))
|
if (!std::isspace(custom_gcode[pos]))
|
||||||
goto NEXT;
|
goto NEXT;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -83,21 +83,21 @@ static bool custom_gcode_changes_tool(const std::string& custom_gcode, const std
|
||||||
if (ss >> num)
|
if (ss >> num)
|
||||||
ok = (num == next_extruder);
|
ok = (num == next_extruder);
|
||||||
}
|
}
|
||||||
NEXT: ;
|
NEXT:;
|
||||||
}
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvoidCrossingPerimeters::init_external_mp(const Print &print)
|
void AvoidCrossingPerimeters::init_external_mp(const Print& print)
|
||||||
{
|
{
|
||||||
m_external_mp = Slic3r::make_unique<MotionPlanner>(union_ex(this->collect_contours_all_layers(print.objects())));
|
m_external_mp = Slic3r::make_unique<MotionPlanner>(union_ex(this->collect_contours_all_layers(print.objects())));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plan a travel move while minimizing the number of perimeter crossings.
|
// Plan a travel move while minimizing the number of perimeter crossings.
|
||||||
// point is in unscaled coordinates, in the coordinate system of the current active object
|
// point is in unscaled coordinates, in the coordinate system of the current active object
|
||||||
// (set by gcodegen.set_origin()).
|
// (set by gcodegen.set_origin()).
|
||||||
Polyline AvoidCrossingPerimeters::travel_to(const GCode &gcodegen, const Point &point)
|
Polyline AvoidCrossingPerimeters::travel_to(const GCode& gcodegen, const Point& point)
|
||||||
{
|
{
|
||||||
// If use_external, then perform the path planning in the world coordinate system (correcting for the gcodegen offset).
|
// If use_external, then perform the path planning in the world coordinate system (correcting for the gcodegen offset).
|
||||||
// Otherwise perform the path planning in the coordinate system of the active object.
|
// Otherwise perform the path planning in the coordinate system of the active object.
|
||||||
bool use_external = this->use_external_mp || this->use_external_mp_once;
|
bool use_external = this->use_external_mp || this->use_external_mp_once;
|
||||||
|
@ -105,41 +105,41 @@ Polyline AvoidCrossingPerimeters::travel_to(const GCode &gcodegen, const Point &
|
||||||
Polyline result = (use_external ? m_external_mp.get() : m_layer_mp.get())->
|
Polyline result = (use_external ? m_external_mp.get() : m_layer_mp.get())->
|
||||||
shortest_path(gcodegen.last_pos() + scaled_origin, point + scaled_origin);
|
shortest_path(gcodegen.last_pos() + scaled_origin, point + scaled_origin);
|
||||||
if (use_external)
|
if (use_external)
|
||||||
result.translate(- scaled_origin);
|
result.translate(-scaled_origin);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect outer contours of all objects over all layers.
|
// Collect outer contours of all objects over all layers.
|
||||||
// Discard objects only containing thin walls (offset would fail on an empty polygon).
|
// Discard objects only containing thin walls (offset would fail on an empty polygon).
|
||||||
// Used by avoid crossing perimeters feature.
|
// Used by avoid crossing perimeters feature.
|
||||||
Polygons AvoidCrossingPerimeters::collect_contours_all_layers(const PrintObjectPtrs& objects)
|
Polygons AvoidCrossingPerimeters::collect_contours_all_layers(const PrintObjectPtrs& objects)
|
||||||
{
|
{
|
||||||
Polygons islands;
|
Polygons islands;
|
||||||
for (const PrintObject *object : objects) {
|
for (const PrintObject* object : objects) {
|
||||||
// Reducing all the object slices into the Z projection in a logarithimc fashion.
|
// Reducing all the object slices into the Z projection in a logarithimc fashion.
|
||||||
// First reduce to half the number of layers.
|
// First reduce to half the number of layers.
|
||||||
std::vector<Polygons> polygons_per_layer((object->layers().size() + 1) / 2);
|
std::vector<Polygons> polygons_per_layer((object->layers().size() + 1) / 2);
|
||||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, object->layers().size() / 2),
|
tbb::parallel_for(tbb::blocked_range<size_t>(0, object->layers().size() / 2),
|
||||||
[&object, &polygons_per_layer](const tbb::blocked_range<size_t> &range) {
|
[&object, &polygons_per_layer](const tbb::blocked_range<size_t>& range) {
|
||||||
for (size_t i = range.begin(); i < range.end(); ++ i) {
|
for (size_t i = range.begin(); i < range.end(); ++i) {
|
||||||
const Layer* layer1 = object->layers()[i * 2];
|
const Layer* layer1 = object->layers()[i * 2];
|
||||||
const Layer* layer2 = object->layers()[i * 2 + 1];
|
const Layer* layer2 = object->layers()[i * 2 + 1];
|
||||||
Polygons polys;
|
Polygons polys;
|
||||||
polys.reserve(layer1->lslices.size() + layer2->lslices.size());
|
polys.reserve(layer1->lslices.size() + layer2->lslices.size());
|
||||||
for (const ExPolygon &expoly : layer1->lslices)
|
for (const ExPolygon& expoly : layer1->lslices)
|
||||||
//FIXME no holes?
|
//FIXME no holes?
|
||||||
polys.emplace_back(expoly.contour);
|
polys.emplace_back(expoly.contour);
|
||||||
for (const ExPolygon &expoly : layer2->lslices)
|
for (const ExPolygon& expoly : layer2->lslices)
|
||||||
//FIXME no holes?
|
//FIXME no holes?
|
||||||
polys.emplace_back(expoly.contour);
|
polys.emplace_back(expoly.contour);
|
||||||
polygons_per_layer[i] = union_(polys);
|
polygons_per_layer[i] = union_(polys);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (object->layers().size() & 1) {
|
if (object->layers().size() & 1) {
|
||||||
const Layer *layer = object->layers().back();
|
const Layer* layer = object->layers().back();
|
||||||
Polygons polys;
|
Polygons polys;
|
||||||
polys.reserve(layer->lslices.size());
|
polys.reserve(layer->lslices.size());
|
||||||
for (const ExPolygon &expoly : layer->lslices)
|
for (const ExPolygon& expoly : layer->lslices)
|
||||||
//FIXME no holes?
|
//FIXME no holes?
|
||||||
polys.emplace_back(expoly.contour);
|
polys.emplace_back(expoly.contour);
|
||||||
polygons_per_layer.back() = union_(polys);
|
polygons_per_layer.back() = union_(polys);
|
||||||
|
@ -148,8 +148,8 @@ Polygons AvoidCrossingPerimeters::collect_contours_all_layers(const PrintObjectP
|
||||||
size_t cnt = polygons_per_layer.size();
|
size_t cnt = polygons_per_layer.size();
|
||||||
while (cnt > 1) {
|
while (cnt > 1) {
|
||||||
tbb::parallel_for(tbb::blocked_range<size_t>(0, cnt / 2),
|
tbb::parallel_for(tbb::blocked_range<size_t>(0, cnt / 2),
|
||||||
[&polygons_per_layer](const tbb::blocked_range<size_t> &range) {
|
[&polygons_per_layer](const tbb::blocked_range<size_t>& range) {
|
||||||
for (size_t i = range.begin(); i < range.end(); ++ i) {
|
for (size_t i = range.begin(); i < range.end(); ++i) {
|
||||||
Polygons polys;
|
Polygons polys;
|
||||||
polys.reserve(polygons_per_layer[i * 2].size() + polygons_per_layer[i * 2 + 1].size());
|
polys.reserve(polygons_per_layer[i * 2].size() + polygons_per_layer[i * 2 + 1].size());
|
||||||
polygons_append(polys, polygons_per_layer[i * 2]);
|
polygons_append(polys, polygons_per_layer[i * 2]);
|
||||||
|
@ -157,26 +157,26 @@ Polygons AvoidCrossingPerimeters::collect_contours_all_layers(const PrintObjectP
|
||||||
polygons_per_layer[i * 2] = union_(polys);
|
polygons_per_layer[i * 2] = union_(polys);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
for (size_t i = 0; i < cnt / 2; ++ i)
|
for (size_t i = 0; i < cnt / 2; ++i)
|
||||||
polygons_per_layer[i] = std::move(polygons_per_layer[i * 2]);
|
polygons_per_layer[i] = std::move(polygons_per_layer[i * 2]);
|
||||||
if (cnt & 1)
|
if (cnt & 1)
|
||||||
polygons_per_layer[cnt / 2] = std::move(polygons_per_layer[cnt - 1]);
|
polygons_per_layer[cnt / 2] = std::move(polygons_per_layer[cnt - 1]);
|
||||||
cnt = (cnt + 1) / 2;
|
cnt = (cnt + 1) / 2;
|
||||||
}
|
}
|
||||||
// And collect copies of the objects.
|
// And collect copies of the objects.
|
||||||
for (const PrintInstance &instance : object->instances()) {
|
for (const PrintInstance& instance : object->instances()) {
|
||||||
// All the layers were reduced to the 1st item of polygons_per_layer.
|
// All the layers were reduced to the 1st item of polygons_per_layer.
|
||||||
size_t i = islands.size();
|
size_t i = islands.size();
|
||||||
polygons_append(islands, polygons_per_layer.front());
|
polygons_append(islands, polygons_per_layer.front());
|
||||||
for (; i < islands.size(); ++ i)
|
for (; i < islands.size(); ++i)
|
||||||
islands[i].translate(instance.shift);
|
islands[i].translate(instance.shift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return islands;
|
return islands;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string OozePrevention::pre_toolchange(GCode &gcodegen)
|
std::string OozePrevention::pre_toolchange(GCode& gcodegen)
|
||||||
{
|
{
|
||||||
std::string gcode;
|
std::string gcode;
|
||||||
|
|
||||||
// move to the nearest standby point
|
// move to the nearest standby point
|
||||||
|
@ -203,25 +203,25 @@ std::string OozePrevention::pre_toolchange(GCode &gcodegen)
|
||||||
}
|
}
|
||||||
|
|
||||||
return gcode;
|
return gcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string OozePrevention::post_toolchange(GCode &gcodegen)
|
std::string OozePrevention::post_toolchange(GCode& gcodegen)
|
||||||
{
|
{
|
||||||
return (gcodegen.config().standby_temperature_delta.value != 0) ?
|
return (gcodegen.config().standby_temperature_delta.value != 0) ?
|
||||||
gcodegen.writer().set_temperature(this->_get_temp(gcodegen), true, gcodegen.writer().extruder()->id()) :
|
gcodegen.writer().set_temperature(this->_get_temp(gcodegen), true, gcodegen.writer().extruder()->id()) :
|
||||||
std::string();
|
std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
OozePrevention::_get_temp(GCode &gcodegen)
|
OozePrevention::_get_temp(GCode& gcodegen)
|
||||||
{
|
{
|
||||||
return (gcodegen.layer() != NULL && gcodegen.layer()->id() == 0)
|
return (gcodegen.layer() != NULL && gcodegen.layer()->id() == 0)
|
||||||
? gcodegen.config().first_layer_temperature.get_at(gcodegen.writer().extruder()->id())
|
? gcodegen.config().first_layer_temperature.get_at(gcodegen.writer().extruder()->id())
|
||||||
: gcodegen.config().temperature.get_at(gcodegen.writer().extruder()->id());
|
: gcodegen.config().temperature.get_at(gcodegen.writer().extruder()->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Wipe::wipe(GCode &gcodegen, bool toolchange)
|
std::string Wipe::wipe(GCode& gcodegen, bool toolchange)
|
||||||
{
|
{
|
||||||
std::string gcode;
|
std::string gcode;
|
||||||
|
|
||||||
/* Reduce feedrate a bit; travel speed is often too high to move on existing material.
|
/* Reduce feedrate a bit; travel speed is often too high to move on existing material.
|
||||||
|
@ -253,15 +253,15 @@ std::string Wipe::wipe(GCode &gcodegen, bool toolchange)
|
||||||
wipe_path.clip_end(wipe_path.length() - wipe_dist);
|
wipe_path.clip_end(wipe_path.length() - wipe_dist);
|
||||||
|
|
||||||
// subdivide the retraction in segments
|
// subdivide the retraction in segments
|
||||||
if (! wipe_path.empty()) {
|
if (!wipe_path.empty()) {
|
||||||
for (const Line &line : wipe_path.lines()) {
|
for (const Line& line : wipe_path.lines()) {
|
||||||
double segment_length = line.length();
|
double segment_length = line.length();
|
||||||
/* Reduce retraction length a bit to avoid effective retraction speed to be greater than the configured one
|
/* Reduce retraction length a bit to avoid effective retraction speed to be greater than the configured one
|
||||||
due to rounding (TODO: test and/or better math for this) */
|
due to rounding (TODO: test and/or better math for this) */
|
||||||
double dE = length * (segment_length / wipe_dist) * 0.95;
|
double dE = length * (segment_length / wipe_dist) * 0.95;
|
||||||
//FIXME one shall not generate the unnecessary G1 Fxxx commands, here wipe_speed is a constant inside this cycle.
|
//FIXME one shall not generate the unnecessary G1 Fxxx commands, here wipe_speed is a constant inside this cycle.
|
||||||
// Is it here for the cooling markers? Or should it be outside of the cycle?
|
// Is it here for the cooling markers? Or should it be outside of the cycle?
|
||||||
gcode += gcodegen.writer().set_speed(wipe_speed*60, "", gcodegen.enable_cooling_markers() ? ";_WIPE" : "");
|
gcode += gcodegen.writer().set_speed(wipe_speed * 60, "", gcodegen.enable_cooling_markers() ? ";_WIPE" : "");
|
||||||
gcode += gcodegen.writer().extrude_to_xy(
|
gcode += gcodegen.writer().extrude_to_xy(
|
||||||
gcodegen.point_to_gcode(line.b),
|
gcodegen.point_to_gcode(line.b),
|
||||||
-dE,
|
-dE,
|
||||||
|
@ -276,15 +276,15 @@ std::string Wipe::wipe(GCode &gcodegen, bool toolchange)
|
||||||
}
|
}
|
||||||
|
|
||||||
return gcode;
|
return gcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Point wipe_tower_point_to_object_point(GCode &gcodegen, const Vec2f &wipe_tower_pt)
|
static inline Point wipe_tower_point_to_object_point(GCode& gcodegen, const Vec2f& wipe_tower_pt)
|
||||||
{
|
{
|
||||||
return Point(scale_(wipe_tower_pt.x() - gcodegen.origin()(0)), scale_(wipe_tower_pt.y() - gcodegen.origin()(1)));
|
return Point(scale_(wipe_tower_pt.x() - gcodegen.origin()(0)), scale_(wipe_tower_pt.y() - gcodegen.origin()(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string WipeTowerIntegration::append_tcr(GCode &gcodegen, const WipeTower::ToolChangeResult &tcr, int new_extruder_id, double z) const
|
std::string WipeTowerIntegration::append_tcr(GCode& gcodegen, const WipeTower::ToolChangeResult& tcr, int new_extruder_id, double z) const
|
||||||
{
|
{
|
||||||
if (new_extruder_id != -1 && new_extruder_id != tcr.new_tool)
|
if (new_extruder_id != -1 && new_extruder_id != tcr.new_tool)
|
||||||
throw std::invalid_argument("Error: WipeTowerIntegration::append_tcr was asked to do a toolchange it didn't expect.");
|
throw std::invalid_argument("Error: WipeTowerIntegration::append_tcr was asked to do a toolchange it didn't expect.");
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ std::string WipeTowerIntegration::append_tcr(GCode &gcodegen, const WipeTower::T
|
||||||
|
|
||||||
// Toolchangeresult.gcode assumes the wipe tower corner is at the origin (except for priming lines)
|
// Toolchangeresult.gcode assumes the wipe tower corner is at the origin (except for priming lines)
|
||||||
// We want to rotate and shift all extrusions (gcode postprocessing) and starting and ending position
|
// We want to rotate and shift all extrusions (gcode postprocessing) and starting and ending position
|
||||||
float alpha = m_wipe_tower_rotation/180.f * float(M_PI);
|
float alpha = m_wipe_tower_rotation / 180.f * float(M_PI);
|
||||||
Vec2f start_pos = tcr.start_pos;
|
Vec2f start_pos = tcr.start_pos;
|
||||||
Vec2f end_pos = tcr.end_pos;
|
Vec2f end_pos = tcr.end_pos;
|
||||||
if (!tcr.priming) {
|
if (!tcr.priming) {
|
||||||
|
@ -322,7 +322,7 @@ std::string WipeTowerIntegration::append_tcr(GCode &gcodegen, const WipeTower::T
|
||||||
double current_z = gcodegen.writer().get_position().z();
|
double current_z = gcodegen.writer().get_position().z();
|
||||||
if (z == -1.) // in case no specific z was provided, print at current_z pos
|
if (z == -1.) // in case no specific z was provided, print at current_z pos
|
||||||
z = current_z;
|
z = current_z;
|
||||||
if (! is_approx(z, current_z)) {
|
if (!is_approx(z, current_z)) {
|
||||||
gcode += gcodegen.writer().retract();
|
gcode += gcodegen.writer().retract();
|
||||||
gcode += gcodegen.writer().travel_to_z(z, "Travel down to the last wipe tower layer.");
|
gcode += gcodegen.writer().travel_to_z(z, "Travel down to the last wipe tower layer.");
|
||||||
gcode += gcodegen.writer().unretract();
|
gcode += gcodegen.writer().unretract();
|
||||||
|
@ -334,8 +334,8 @@ std::string WipeTowerIntegration::append_tcr(GCode &gcodegen, const WipeTower::T
|
||||||
if (gcodegen.writer().extruder() != nullptr) {
|
if (gcodegen.writer().extruder() != nullptr) {
|
||||||
// Process the custom end_filament_gcode in case of single_extruder_multi_material.
|
// Process the custom end_filament_gcode in case of single_extruder_multi_material.
|
||||||
unsigned int old_extruder_id = gcodegen.writer().extruder()->id();
|
unsigned int old_extruder_id = gcodegen.writer().extruder()->id();
|
||||||
const std::string &end_filament_gcode = gcodegen.config().end_filament_gcode.get_at(old_extruder_id);
|
const std::string& end_filament_gcode = gcodegen.config().end_filament_gcode.get_at(old_extruder_id);
|
||||||
if (gcodegen.writer().extruder() != nullptr && ! end_filament_gcode.empty()) {
|
if (gcodegen.writer().extruder() != nullptr && !end_filament_gcode.empty()) {
|
||||||
end_filament_gcode_str = gcodegen.placeholder_parser_process("end_filament_gcode", end_filament_gcode, old_extruder_id);
|
end_filament_gcode_str = gcodegen.placeholder_parser_process("end_filament_gcode", end_filament_gcode, old_extruder_id);
|
||||||
check_add_eol(end_filament_gcode_str);
|
check_add_eol(end_filament_gcode_str);
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ std::string WipeTowerIntegration::append_tcr(GCode &gcodegen, const WipeTower::T
|
||||||
std::string toolchange_command;
|
std::string toolchange_command;
|
||||||
if (tcr.priming || (new_extruder_id >= 0 && gcodegen.writer().need_toolchange(new_extruder_id)))
|
if (tcr.priming || (new_extruder_id >= 0 && gcodegen.writer().need_toolchange(new_extruder_id)))
|
||||||
toolchange_command = gcodegen.writer().toolchange(new_extruder_id);
|
toolchange_command = gcodegen.writer().toolchange(new_extruder_id);
|
||||||
if (! custom_gcode_changes_tool(toolchange_gcode_str, gcodegen.writer().toolchange_prefix(), new_extruder_id))
|
if (!custom_gcode_changes_tool(toolchange_gcode_str, gcodegen.writer().toolchange_prefix(), new_extruder_id))
|
||||||
toolchange_gcode_str += toolchange_command;
|
toolchange_gcode_str += toolchange_command;
|
||||||
else {
|
else {
|
||||||
// We have informed the m_writer about the current extruder_id, we can ignore the generated G-code.
|
// We have informed the m_writer about the current extruder_id, we can ignore the generated G-code.
|
||||||
|
@ -371,8 +371,8 @@ std::string WipeTowerIntegration::append_tcr(GCode &gcodegen, const WipeTower::T
|
||||||
|
|
||||||
// Process the start filament gcode.
|
// Process the start filament gcode.
|
||||||
std::string start_filament_gcode_str;
|
std::string start_filament_gcode_str;
|
||||||
const std::string &start_filament_gcode = gcodegen.config().start_filament_gcode.get_at(new_extruder_id);
|
const std::string& start_filament_gcode = gcodegen.config().start_filament_gcode.get_at(new_extruder_id);
|
||||||
if (! start_filament_gcode.empty()) {
|
if (!start_filament_gcode.empty()) {
|
||||||
// Process the start_filament_gcode for the active filament only.
|
// Process the start_filament_gcode for the active filament only.
|
||||||
DynamicConfig config;
|
DynamicConfig config;
|
||||||
config.set_key_value("filament_extruder_id", new ConfigOptionInt(new_extruder_id));
|
config.set_key_value("filament_extruder_id", new ConfigOptionInt(new_extruder_id));
|
||||||
|
@ -394,7 +394,7 @@ std::string WipeTowerIntegration::append_tcr(GCode &gcodegen, const WipeTower::T
|
||||||
// A phony move to the end position at the wipe tower.
|
// A phony move to the end position at the wipe tower.
|
||||||
gcodegen.writer().travel_to_xy(end_pos.cast<double>());
|
gcodegen.writer().travel_to_xy(end_pos.cast<double>());
|
||||||
gcodegen.set_last_pos(wipe_tower_point_to_object_point(gcodegen, end_pos));
|
gcodegen.set_last_pos(wipe_tower_point_to_object_point(gcodegen, end_pos));
|
||||||
if (! is_approx(z, current_z)) {
|
if (!is_approx(z, current_z)) {
|
||||||
gcode += gcodegen.writer().retract();
|
gcode += gcodegen.writer().retract();
|
||||||
gcode += gcodegen.writer().travel_to_z(current_z, "Travel back up to the topmost object layer.");
|
gcode += gcodegen.writer().travel_to_z(current_z, "Travel back up to the topmost object layer.");
|
||||||
gcode += gcodegen.writer().unretract();
|
gcode += gcodegen.writer().unretract();
|
||||||
|
@ -416,12 +416,12 @@ std::string WipeTowerIntegration::append_tcr(GCode &gcodegen, const WipeTower::T
|
||||||
// Let the planner know we are traveling between objects.
|
// Let the planner know we are traveling between objects.
|
||||||
gcodegen.m_avoid_crossing_perimeters.use_external_mp_once = true;
|
gcodegen.m_avoid_crossing_perimeters.use_external_mp_once = true;
|
||||||
return gcode;
|
return gcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function postprocesses gcode_original, rotates and moves all G1 extrusions and returns resulting gcode
|
// This function postprocesses gcode_original, rotates and moves all G1 extrusions and returns resulting gcode
|
||||||
// Starting position has to be supplied explicitely (otherwise it would fail in case first G1 command only contained one coordinate)
|
// Starting position has to be supplied explicitely (otherwise it would fail in case first G1 command only contained one coordinate)
|
||||||
std::string WipeTowerIntegration::post_process_wipe_tower_moves(const WipeTower::ToolChangeResult& tcr, const Vec2f& translation, float angle) const
|
std::string WipeTowerIntegration::post_process_wipe_tower_moves(const WipeTower::ToolChangeResult& tcr, const Vec2f& translation, float angle) const
|
||||||
{
|
{
|
||||||
Vec2f extruder_offset = m_extruder_offsets[tcr.initial_tool].cast<float>();
|
Vec2f extruder_offset = m_extruder_offsets[tcr.initial_tool].cast<float>();
|
||||||
|
|
||||||
std::istringstream gcode_str(tcr.gcode);
|
std::istringstream gcode_str(tcr.gcode);
|
||||||
|
@ -443,14 +443,14 @@ std::string WipeTowerIntegration::post_process_wipe_tower_moves(const WipeTower:
|
||||||
if (it != std::string::npos) {
|
if (it != std::string::npos) {
|
||||||
// remove the tag and remember we saw it
|
// remove the tag and remember we saw it
|
||||||
never_skip = true;
|
never_skip = true;
|
||||||
line.erase(it, it+WipeTower::never_skip_tag().size());
|
line.erase(it, it + WipeTower::never_skip_tag().size());
|
||||||
}
|
}
|
||||||
std::ostringstream line_out;
|
std::ostringstream line_out;
|
||||||
std::istringstream line_str(line);
|
std::istringstream line_str(line);
|
||||||
line_str >> std::noskipws; // don't skip whitespace
|
line_str >> std::noskipws; // don't skip whitespace
|
||||||
char ch = 0;
|
char ch = 0;
|
||||||
while (line_str >> ch) {
|
while (line_str >> ch) {
|
||||||
if (ch == 'X' || ch =='Y')
|
if (ch == 'X' || ch == 'Y')
|
||||||
line_str >> (ch == 'X' ? pos.x() : pos.y());
|
line_str >> (ch == 'X' ? pos.x() : pos.y());
|
||||||
else
|
else
|
||||||
line_out << ch;
|
line_out << ch;
|
||||||
|
@ -490,11 +490,11 @@ std::string WipeTowerIntegration::post_process_wipe_tower_moves(const WipeTower:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return gcode_out;
|
return gcode_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string WipeTowerIntegration::prime(GCode &gcodegen)
|
std::string WipeTowerIntegration::prime(GCode& gcodegen)
|
||||||
{
|
{
|
||||||
assert(m_layer_idx == 0);
|
assert(m_layer_idx == 0);
|
||||||
std::string gcode;
|
std::string gcode;
|
||||||
|
|
||||||
|
@ -530,15 +530,15 @@ std::string WipeTowerIntegration::prime(GCode &gcodegen)
|
||||||
m_priming.back().end_pos.y)));*/
|
m_priming.back().end_pos.y)));*/
|
||||||
|
|
||||||
return gcode;
|
return gcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string WipeTowerIntegration::tool_change(GCode &gcodegen, int extruder_id, bool finish_layer)
|
std::string WipeTowerIntegration::tool_change(GCode& gcodegen, int extruder_id, bool finish_layer)
|
||||||
{
|
{
|
||||||
std::string gcode;
|
std::string gcode;
|
||||||
assert(m_layer_idx >= 0);
|
assert(m_layer_idx >= 0);
|
||||||
if (! m_brim_done || gcodegen.writer().need_toolchange(extruder_id) || finish_layer) {
|
if (!m_brim_done || gcodegen.writer().need_toolchange(extruder_id) || finish_layer) {
|
||||||
if (m_layer_idx < (int)m_tool_changes.size()) {
|
if (m_layer_idx < (int)m_tool_changes.size()) {
|
||||||
if (! (size_t(m_tool_change_idx) < m_tool_changes[m_layer_idx].size()))
|
if (!(size_t(m_tool_change_idx) < m_tool_changes[m_layer_idx].size()))
|
||||||
throw std::runtime_error("Wipe tower generation failed, possibly due to empty first layer.");
|
throw std::runtime_error("Wipe tower generation failed, possibly due to empty first layer.");
|
||||||
|
|
||||||
|
|
||||||
|
@ -549,11 +549,11 @@ std::string WipeTowerIntegration::tool_change(GCode &gcodegen, int extruder_id,
|
||||||
if (gcodegen.config().wipe_tower_no_sparse_layers.value) {
|
if (gcodegen.config().wipe_tower_no_sparse_layers.value) {
|
||||||
wipe_tower_z = m_last_wipe_tower_print_z;
|
wipe_tower_z = m_last_wipe_tower_print_z;
|
||||||
ignore_sparse = (m_brim_done && m_tool_changes[m_layer_idx].size() == 1 && m_tool_changes[m_layer_idx].front().initial_tool == m_tool_changes[m_layer_idx].front().new_tool);
|
ignore_sparse = (m_brim_done && m_tool_changes[m_layer_idx].size() == 1 && m_tool_changes[m_layer_idx].front().initial_tool == m_tool_changes[m_layer_idx].front().new_tool);
|
||||||
if (m_tool_change_idx == 0 && ! ignore_sparse)
|
if (m_tool_change_idx == 0 && !ignore_sparse)
|
||||||
wipe_tower_z = m_last_wipe_tower_print_z + m_tool_changes[m_layer_idx].front().layer_height;
|
wipe_tower_z = m_last_wipe_tower_print_z + m_tool_changes[m_layer_idx].front().layer_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! ignore_sparse) {
|
if (!ignore_sparse) {
|
||||||
gcode += append_tcr(gcodegen, m_tool_changes[m_layer_idx][m_tool_change_idx++], extruder_id, wipe_tower_z);
|
gcode += append_tcr(gcodegen, m_tool_changes[m_layer_idx][m_tool_change_idx++], extruder_id, wipe_tower_z);
|
||||||
m_last_wipe_tower_print_z = wipe_tower_z;
|
m_last_wipe_tower_print_z = wipe_tower_z;
|
||||||
}
|
}
|
||||||
|
@ -561,28 +561,28 @@ std::string WipeTowerIntegration::tool_change(GCode &gcodegen, int extruder_id,
|
||||||
m_brim_done = true;
|
m_brim_done = true;
|
||||||
}
|
}
|
||||||
return gcode;
|
return gcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print is finished. Now it remains to unload the filament safely with ramming over the wipe tower.
|
// Print is finished. Now it remains to unload the filament safely with ramming over the wipe tower.
|
||||||
std::string WipeTowerIntegration::finalize(GCode &gcodegen)
|
std::string WipeTowerIntegration::finalize(GCode& gcodegen)
|
||||||
{
|
{
|
||||||
std::string gcode;
|
std::string gcode;
|
||||||
if (std::abs(gcodegen.writer().get_position()(2) - m_final_purge.print_z) > EPSILON)
|
if (std::abs(gcodegen.writer().get_position()(2) - m_final_purge.print_z) > EPSILON)
|
||||||
gcode += gcodegen.change_layer(m_final_purge.print_z);
|
gcode += gcodegen.change_layer(m_final_purge.print_z);
|
||||||
gcode += append_tcr(gcodegen, m_final_purge, -1);
|
gcode += append_tcr(gcodegen, m_final_purge, -1);
|
||||||
return gcode;
|
return gcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
const std::vector<std::string> ColorPrintColors::Colors = { "#C0392B", "#E67E22", "#F1C40F", "#27AE60", "#1ABC9C", "#2980B9", "#9B59B6" };
|
const std::vector<std::string> ColorPrintColors::Colors = { "#C0392B", "#E67E22", "#F1C40F", "#27AE60", "#1ABC9C", "#2980B9", "#9B59B6" };
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
|
||||||
#define EXTRUDER_CONFIG(OPT) m_config.OPT.get_at(m_writer.extruder()->id())
|
#define EXTRUDER_CONFIG(OPT) m_config.OPT.get_at(m_writer.extruder()->id())
|
||||||
|
|
||||||
// Collect pairs of object_layer + support_layer sorted by print_z.
|
// Collect pairs of object_layer + support_layer sorted by print_z.
|
||||||
// object_layer & support_layer are considered to be on the same print_z, if they are not further than EPSILON.
|
// object_layer & support_layer are considered to be on the same print_z, if they are not further than EPSILON.
|
||||||
std::vector<GCode::LayerToPrint> GCode::collect_layers_to_print(const PrintObject &object)
|
std::vector<GCode::LayerToPrint> GCode::collect_layers_to_print(const PrintObject& object)
|
||||||
{
|
{
|
||||||
std::vector<GCode::LayerToPrint> layers_to_print;
|
std::vector<GCode::LayerToPrint> layers_to_print;
|
||||||
layers_to_print.reserve(object.layers().size() + object.support_layers().size());
|
layers_to_print.reserve(object.layers().size() + object.support_layers().size());
|
||||||
|
|
||||||
|
@ -591,7 +591,7 @@ std::vector<GCode::LayerToPrint> GCode::collect_layers_to_print(const PrintObjec
|
||||||
//FIXME should we use the printing extruders instead?
|
//FIXME should we use the printing extruders instead?
|
||||||
double gap_over_supports = object.config().support_material_contact_distance;
|
double gap_over_supports = object.config().support_material_contact_distance;
|
||||||
// FIXME should we test object.config().support_material_synchronize_layers ? Currently the support layers are synchronized with object layers iff soluble supports.
|
// FIXME should we test object.config().support_material_synchronize_layers ? Currently the support layers are synchronized with object layers iff soluble supports.
|
||||||
assert(! object.config().support_material || gap_over_supports != 0. || object.config().support_material_synchronize_layers);
|
assert(!object.config().support_material || gap_over_supports != 0. || object.config().support_material_synchronize_layers);
|
||||||
if (gap_over_supports != 0.) {
|
if (gap_over_supports != 0.) {
|
||||||
gap_over_supports = std::max(0., gap_over_supports);
|
gap_over_supports = std::max(0., gap_over_supports);
|
||||||
// Not a soluble support,
|
// Not a soluble support,
|
||||||
|
@ -607,15 +607,16 @@ std::vector<GCode::LayerToPrint> GCode::collect_layers_to_print(const PrintObjec
|
||||||
const LayerToPrint* last_extrusion_layer = nullptr;
|
const LayerToPrint* last_extrusion_layer = nullptr;
|
||||||
while (idx_object_layer < object.layers().size() || idx_support_layer < object.support_layers().size()) {
|
while (idx_object_layer < object.layers().size() || idx_support_layer < object.support_layers().size()) {
|
||||||
LayerToPrint layer_to_print;
|
LayerToPrint layer_to_print;
|
||||||
layer_to_print.object_layer = (idx_object_layer < object.layers().size()) ? object.layers()[idx_object_layer ++] : nullptr;
|
layer_to_print.object_layer = (idx_object_layer < object.layers().size()) ? object.layers()[idx_object_layer++] : nullptr;
|
||||||
layer_to_print.support_layer = (idx_support_layer < object.support_layers().size()) ? object.support_layers()[idx_support_layer ++] : nullptr;
|
layer_to_print.support_layer = (idx_support_layer < object.support_layers().size()) ? object.support_layers()[idx_support_layer++] : nullptr;
|
||||||
if (layer_to_print.object_layer && layer_to_print.support_layer) {
|
if (layer_to_print.object_layer && layer_to_print.support_layer) {
|
||||||
if (layer_to_print.object_layer->print_z < layer_to_print.support_layer->print_z - EPSILON) {
|
if (layer_to_print.object_layer->print_z < layer_to_print.support_layer->print_z - EPSILON) {
|
||||||
layer_to_print.support_layer = nullptr;
|
layer_to_print.support_layer = nullptr;
|
||||||
-- idx_support_layer;
|
--idx_support_layer;
|
||||||
} else if (layer_to_print.support_layer->print_z < layer_to_print.object_layer->print_z - EPSILON) {
|
}
|
||||||
|
else if (layer_to_print.support_layer->print_z < layer_to_print.object_layer->print_z - EPSILON) {
|
||||||
layer_to_print.object_layer = nullptr;
|
layer_to_print.object_layer = nullptr;
|
||||||
-- idx_object_layer;
|
--idx_object_layer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,13 +651,13 @@ std::vector<GCode::LayerToPrint> GCode::collect_layers_to_print(const PrintObjec
|
||||||
}
|
}
|
||||||
|
|
||||||
return layers_to_print;
|
return layers_to_print;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare for non-sequential printing of multiple objects: Support resp. object layers with nearly identical print_z
|
// Prepare for non-sequential printing of multiple objects: Support resp. object layers with nearly identical print_z
|
||||||
// will be printed for all objects at once.
|
// will be printed for all objects at once.
|
||||||
// Return a list of <print_z, per object LayerToPrint> items.
|
// Return a list of <print_z, per object LayerToPrint> items.
|
||||||
std::vector<std::pair<coordf_t, std::vector<GCode::LayerToPrint>>> GCode::collect_layers_to_print(const Print &print)
|
std::vector<std::pair<coordf_t, std::vector<GCode::LayerToPrint>>> GCode::collect_layers_to_print(const Print& print)
|
||||||
{
|
{
|
||||||
struct OrderingItem {
|
struct OrderingItem {
|
||||||
coordf_t print_z;
|
coordf_t print_z;
|
||||||
size_t object_idx;
|
size_t object_idx;
|
||||||
|
@ -670,15 +671,15 @@ std::vector<std::pair<coordf_t, std::vector<GCode::LayerToPrint>>> GCode::collec
|
||||||
OrderingItem ordering_item;
|
OrderingItem ordering_item;
|
||||||
ordering_item.object_idx = i;
|
ordering_item.object_idx = i;
|
||||||
ordering.reserve(ordering.size() + per_object[i].size());
|
ordering.reserve(ordering.size() + per_object[i].size());
|
||||||
const LayerToPrint &front = per_object[i].front();
|
const LayerToPrint& front = per_object[i].front();
|
||||||
for (const LayerToPrint <p : per_object[i]) {
|
for (const LayerToPrint& ltp : per_object[i]) {
|
||||||
ordering_item.print_z = ltp.print_z();
|
ordering_item.print_z = ltp.print_z();
|
||||||
ordering_item.layer_idx = <p - &front;
|
ordering_item.layer_idx = <p - &front;
|
||||||
ordering.emplace_back(ordering_item);
|
ordering.emplace_back(ordering_item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(ordering.begin(), ordering.end(), [](const OrderingItem &oi1, const OrderingItem &oi2) { return oi1.print_z < oi2.print_z; });
|
std::sort(ordering.begin(), ordering.end(), [](const OrderingItem& oi1, const OrderingItem& oi2) { return oi1.print_z < oi2.print_z; });
|
||||||
|
|
||||||
std::vector<std::pair<coordf_t, std::vector<LayerToPrint>>> layers_to_print;
|
std::vector<std::pair<coordf_t, std::vector<LayerToPrint>>> layers_to_print;
|
||||||
// Merge numerically very close Z values.
|
// Merge numerically very close Z values.
|
||||||
|
@ -686,14 +687,14 @@ std::vector<std::pair<coordf_t, std::vector<GCode::LayerToPrint>>> GCode::collec
|
||||||
// Find the last layer with roughly the same print_z.
|
// Find the last layer with roughly the same print_z.
|
||||||
size_t j = i + 1;
|
size_t j = i + 1;
|
||||||
coordf_t zmax = ordering[i].print_z + EPSILON;
|
coordf_t zmax = ordering[i].print_z + EPSILON;
|
||||||
for (; j < ordering.size() && ordering[j].print_z <= zmax; ++ j) ;
|
for (; j < ordering.size() && ordering[j].print_z <= zmax; ++j);
|
||||||
// Merge into layers_to_print.
|
// Merge into layers_to_print.
|
||||||
std::pair<coordf_t, std::vector<LayerToPrint>> merged;
|
std::pair<coordf_t, std::vector<LayerToPrint>> merged;
|
||||||
// Assign an average print_z to the set of layers with nearly equal print_z.
|
// Assign an average print_z to the set of layers with nearly equal print_z.
|
||||||
merged.first = 0.5 * (ordering[i].print_z + ordering[j-1].print_z);
|
merged.first = 0.5 * (ordering[i].print_z + ordering[j - 1].print_z);
|
||||||
merged.second.assign(print.objects().size(), LayerToPrint());
|
merged.second.assign(print.objects().size(), LayerToPrint());
|
||||||
for (; i < j; ++i) {
|
for (; i < j; ++i) {
|
||||||
const OrderingItem &oi = ordering[i];
|
const OrderingItem& oi = ordering[i];
|
||||||
assert(merged.second[oi.object_idx].layer() == nullptr);
|
assert(merged.second[oi.object_idx].layer() == nullptr);
|
||||||
merged.second[oi.object_idx] = std::move(per_object[oi.object_idx][oi.layer_idx]);
|
merged.second[oi.object_idx] = std::move(per_object[oi.object_idx][oi.layer_idx]);
|
||||||
}
|
}
|
||||||
|
@ -701,9 +702,30 @@ std::vector<std::pair<coordf_t, std::vector<GCode::LayerToPrint>>> GCode::collec
|
||||||
}
|
}
|
||||||
|
|
||||||
return layers_to_print;
|
return layers_to_print;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
// free functions called by GCode::do_export()
|
||||||
|
namespace DoExport {
|
||||||
|
static void update_print_stats_estimated_times(
|
||||||
|
const GCodeProcessor& processor,
|
||||||
|
const bool silent_time_estimator_enabled,
|
||||||
|
PrintStatistics& print_statistics)
|
||||||
|
{
|
||||||
|
print_statistics.estimated_normal_print_time = processor.get_time_dhm(GCodeProcessor::ETimeMode::Normal);
|
||||||
|
print_statistics.estimated_normal_custom_gcode_print_times = processor.get_custom_gcode_times(GCodeProcessor::ETimeMode::Normal, true);
|
||||||
|
if (silent_time_estimator_enabled) {
|
||||||
|
print_statistics.estimated_silent_print_time = processor.get_time_dhm(GCodeProcessor::ETimeMode::Stealth);
|
||||||
|
print_statistics.estimated_silent_custom_gcode_print_times = processor.get_custom_gcode_times(GCodeProcessor::ETimeMode::Stealth, true);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print_statistics.estimated_silent_print_time = "N/A";
|
||||||
|
print_statistics.estimated_silent_custom_gcode_print_times.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace DoExport
|
||||||
|
|
||||||
void GCode::do_export(Print* print, const char* path, GCodeProcessor::Result* result, ThumbnailsGeneratorCallback thumbnail_cb)
|
void GCode::do_export(Print* print, const char* path, GCodeProcessor::Result* result, ThumbnailsGeneratorCallback thumbnail_cb)
|
||||||
#else
|
#else
|
||||||
void GCode::do_export(Print* print, const char* path, GCodePreviewData* preview_data, ThumbnailsGeneratorCallback thumbnail_cb)
|
void GCode::do_export(Print* print, const char* path, GCodePreviewData* preview_data, ThumbnailsGeneratorCallback thumbnail_cb)
|
||||||
|
@ -768,6 +790,8 @@ void GCode::do_export(Print* print, const char* path, GCodePreviewData* preview_
|
||||||
m_processor.process_file(path_tmp);
|
m_processor.process_file(path_tmp);
|
||||||
if (result != nullptr)
|
if (result != nullptr)
|
||||||
*result = std::move(m_processor.extract_result());
|
*result = std::move(m_processor.extract_result());
|
||||||
|
|
||||||
|
DoExport::update_print_stats_estimated_times(m_processor, m_silent_time_estimator_enabled, print->m_print_statistics);
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
|
||||||
GCodeTimeEstimator::PostProcessData normal_data = m_normal_time_estimator.get_post_process_data();
|
GCodeTimeEstimator::PostProcessData normal_data = m_normal_time_estimator.get_post_process_data();
|
||||||
|
@ -883,10 +907,11 @@ namespace DoExport {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
static void init_gcode_processor(const PrintConfig& config, GCodeProcessor& processor)
|
static void init_gcode_processor(const PrintConfig& config, GCodeProcessor& processor, bool silent_time_estimator_enabled)
|
||||||
{
|
{
|
||||||
processor.reset();
|
processor.reset();
|
||||||
processor.apply_config(config);
|
processor.apply_config(config);
|
||||||
|
processor.enable_stealth_time_estimator(silent_time_estimator_enabled);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static void init_gcode_analyzer(const PrintConfig &config, GCodeAnalyzer &analyzer)
|
static void init_gcode_analyzer(const PrintConfig &config, GCodeAnalyzer &analyzer)
|
||||||
|
@ -1048,16 +1073,15 @@ namespace DoExport {
|
||||||
std::string filament_stats_string_out;
|
std::string filament_stats_string_out;
|
||||||
|
|
||||||
print_statistics.clear();
|
print_statistics.clear();
|
||||||
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
print_statistics.estimated_normal_print_time_str = normal_time_estimator.get_time_dhm/*s*/();
|
||||||
|
print_statistics.estimated_silent_print_time_str = silent_time_estimator_enabled ? silent_time_estimator.get_time_dhm/*s*/() : "N/A";
|
||||||
|
print_statistics.estimated_normal_custom_gcode_print_times_str = normal_time_estimator.get_custom_gcode_times_dhm(true);
|
||||||
|
if (silent_time_estimator_enabled)
|
||||||
|
print_statistics.estimated_silent_custom_gcode_print_times_str = silent_time_estimator.get_custom_gcode_times_dhm(true);
|
||||||
|
#else
|
||||||
print_statistics.estimated_normal_print_time = normal_time_estimator.get_time_dhm/*s*/();
|
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_silent_print_time = silent_time_estimator_enabled ? silent_time_estimator.get_time_dhm/*s*/() : "N/A";
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
print_statistics.estimated_normal_custom_gcode_print_times_str = normal_time_estimator.get_custom_gcode_times_dhm(true);
|
|
||||||
print_statistics.estimated_normal_custom_gcode_print_times = normal_time_estimator.get_custom_gcode_times(true);
|
|
||||||
if (silent_time_estimator_enabled) {
|
|
||||||
print_statistics.estimated_silent_custom_gcode_print_times_str = silent_time_estimator.get_custom_gcode_times_dhm(true);
|
|
||||||
print_statistics.estimated_silent_custom_gcode_print_times = silent_time_estimator.get_custom_gcode_times(true);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
print_statistics.estimated_normal_custom_gcode_print_times = normal_time_estimator.get_custom_gcode_times_dhm(true);
|
print_statistics.estimated_normal_custom_gcode_print_times = normal_time_estimator.get_custom_gcode_times_dhm(true);
|
||||||
if (silent_time_estimator_enabled)
|
if (silent_time_estimator_enabled)
|
||||||
print_statistics.estimated_silent_custom_gcode_print_times = silent_time_estimator.get_custom_gcode_times_dhm(true);
|
print_statistics.estimated_silent_custom_gcode_print_times = silent_time_estimator.get_custom_gcode_times_dhm(true);
|
||||||
|
@ -1156,7 +1180,7 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
|
||||||
// modifies the following:
|
// modifies the following:
|
||||||
m_normal_time_estimator, m_silent_time_estimator, m_silent_time_estimator_enabled);
|
m_normal_time_estimator, m_silent_time_estimator, m_silent_time_estimator_enabled);
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
DoExport::init_gcode_processor(print.config(), m_processor);
|
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
|
||||||
#else
|
#else
|
||||||
DoExport::init_gcode_analyzer(print.config(), m_analyzer);
|
DoExport::init_gcode_analyzer(print.config(), m_analyzer);
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#include "libslic3r/libslic3r.h"
|
#include "libslic3r/libslic3r.h"
|
||||||
|
#include "libslic3r/Utils.hpp"
|
||||||
#include "GCodeProcessor.hpp"
|
#include "GCodeProcessor.hpp"
|
||||||
|
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
|
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
|
||||||
|
@ -14,20 +16,65 @@
|
||||||
static const float INCHES_TO_MM = 25.4f;
|
static const float INCHES_TO_MM = 25.4f;
|
||||||
static const float MMMIN_TO_MMSEC = 1.0f / 60.0f;
|
static const float MMMIN_TO_MMSEC = 1.0f / 60.0f;
|
||||||
|
|
||||||
static bool is_valid_extrusion_role(int value)
|
static const float DEFAULT_ACCELERATION = 1500.0f; // Prusa Firmware 1_75mm_MK2
|
||||||
{
|
|
||||||
return ((int)Slic3r::erNone <= value) && (value <= (int)Slic3r::erMixed);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
const std::string GCodeProcessor::Extrusion_Role_Tag = "_PROCESSOR_EXTRUSION_ROLE:";
|
const std::string GCodeProcessor::Extrusion_Role_Tag = "PrusaSlicer__EXTRUSION_ROLE:";
|
||||||
const std::string GCodeProcessor::Width_Tag = "_PROCESSOR_WIDTH:";
|
const std::string GCodeProcessor::Width_Tag = "PrusaSlicer__WIDTH:";
|
||||||
const std::string GCodeProcessor::Height_Tag = "_PROCESSOR_HEIGHT:";
|
const std::string GCodeProcessor::Height_Tag = "PrusaSlicer__HEIGHT:";
|
||||||
const std::string GCodeProcessor::Mm3_Per_Mm_Tag = "_PROCESSOR_MM3_PER_MM:";
|
const std::string GCodeProcessor::Mm3_Per_Mm_Tag = "PrusaSlicer__MM3_PER_MM:";
|
||||||
const std::string GCodeProcessor::Color_Change_Tag = "_PROCESSOR_COLOR_CHANGE";
|
const std::string GCodeProcessor::Color_Change_Tag = "PrusaSlicer__COLOR_CHANGE";
|
||||||
const std::string GCodeProcessor::Pause_Print_Tag = "_PROCESSOR_PAUSE_PRINT";
|
const std::string GCodeProcessor::Pause_Print_Tag = "PrusaSlicer__PAUSE_PRINT";
|
||||||
const std::string GCodeProcessor::Custom_Code_Tag = "_PROCESSOR_CUSTOM_CODE";
|
const std::string GCodeProcessor::Custom_Code_Tag = "PrusaSlicer__CUSTOM_CODE";
|
||||||
|
|
||||||
|
static bool is_valid_extrusion_role(int value)
|
||||||
|
{
|
||||||
|
return (static_cast<int>(erNone) <= value) && (value <= static_cast<int>(erMixed));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_option_value(ConfigOptionFloats& option, size_t id, float value)
|
||||||
|
{
|
||||||
|
if (id < option.values.size())
|
||||||
|
option.values[id] = static_cast<double>(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
static float get_option_value(const ConfigOptionFloats& option, size_t id)
|
||||||
|
{
|
||||||
|
return option.values.empty() ? 0.0f :
|
||||||
|
((id < option.values.size()) ? static_cast<float>(option.values[id]) : static_cast<float>(option.values.back()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static float estimated_acceleration_distance(float initial_rate, float target_rate, float acceleration)
|
||||||
|
{
|
||||||
|
return (acceleration == 0.0f) ? 0.0f : (sqr(target_rate) - sqr(initial_rate)) / (2.0f * acceleration);
|
||||||
|
}
|
||||||
|
|
||||||
|
static float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance)
|
||||||
|
{
|
||||||
|
return (acceleration == 0.0f) ? 0.0f : (2.0f * acceleration * distance - sqr(initial_rate) + sqr(final_rate)) / (4.0f * acceleration);
|
||||||
|
}
|
||||||
|
|
||||||
|
static float speed_from_distance(float initial_feedrate, float distance, float acceleration)
|
||||||
|
{
|
||||||
|
// to avoid invalid negative numbers due to numerical errors
|
||||||
|
float value = std::max(0.0f, sqr(initial_feedrate) + 2.0f * acceleration * distance);
|
||||||
|
return ::sqrt(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the
|
||||||
|
// acceleration within the allotted distance.
|
||||||
|
static float max_allowable_speed(float acceleration, float target_velocity, float distance)
|
||||||
|
{
|
||||||
|
// to avoid invalid negative numbers due to numerical errors
|
||||||
|
float value = std::max(0.0f, sqr(target_velocity) - 2.0f * acceleration * distance);
|
||||||
|
return std::sqrt(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static float acceleration_time_from_distance(float initial_feedrate, float distance, float acceleration)
|
||||||
|
{
|
||||||
|
return (acceleration != 0.0f) ? (speed_from_distance(initial_feedrate, distance, acceleration) - initial_feedrate) / acceleration : 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
void GCodeProcessor::CachedPosition::reset()
|
void GCodeProcessor::CachedPosition::reset()
|
||||||
{
|
{
|
||||||
|
@ -41,6 +88,208 @@ void GCodeProcessor::CpColor::reset()
|
||||||
current = 0;
|
current = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::Trapezoid::acceleration_time(float entry_feedrate, float acceleration) const
|
||||||
|
{
|
||||||
|
return acceleration_time_from_distance(entry_feedrate, accelerate_until, acceleration);
|
||||||
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::Trapezoid::cruise_time() const
|
||||||
|
{
|
||||||
|
return (cruise_feedrate != 0.0f) ? cruise_distance() / cruise_feedrate : 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::Trapezoid::deceleration_time(float distance, float acceleration) const
|
||||||
|
{
|
||||||
|
return acceleration_time_from_distance(cruise_feedrate, (distance - decelerate_after), -acceleration);
|
||||||
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::Trapezoid::cruise_distance() const
|
||||||
|
{
|
||||||
|
return decelerate_after - accelerate_until;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::TimeBlock::calculate_trapezoid()
|
||||||
|
{
|
||||||
|
trapezoid.cruise_feedrate = feedrate_profile.cruise;
|
||||||
|
|
||||||
|
float accelerate_distance = std::max(0.0f, estimated_acceleration_distance(feedrate_profile.entry, feedrate_profile.cruise, acceleration));
|
||||||
|
float decelerate_distance = std::max(0.0f, estimated_acceleration_distance(feedrate_profile.cruise, feedrate_profile.exit, -acceleration));
|
||||||
|
float cruise_distance = distance - accelerate_distance - decelerate_distance;
|
||||||
|
|
||||||
|
// Not enough space to reach the nominal feedrate.
|
||||||
|
// This means no cruising, and we'll have to use intersection_distance() to calculate when to abort acceleration
|
||||||
|
// and start braking in order to reach the exit_feedrate exactly at the end of this block.
|
||||||
|
if (cruise_distance < 0.0f) {
|
||||||
|
accelerate_distance = std::clamp(intersection_distance(feedrate_profile.entry, feedrate_profile.exit, acceleration, distance), 0.0f, distance);
|
||||||
|
cruise_distance = 0.0f;
|
||||||
|
trapezoid.cruise_feedrate = speed_from_distance(feedrate_profile.entry, accelerate_distance, acceleration);
|
||||||
|
}
|
||||||
|
|
||||||
|
trapezoid.accelerate_until = accelerate_distance;
|
||||||
|
trapezoid.decelerate_after = accelerate_distance + cruise_distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::TimeBlock::time() const
|
||||||
|
{
|
||||||
|
return trapezoid.acceleration_time(feedrate_profile.entry, acceleration)
|
||||||
|
+ trapezoid.cruise_time()
|
||||||
|
+ trapezoid.deceleration_time(distance, acceleration);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::TimeMachine::State::reset()
|
||||||
|
{
|
||||||
|
feedrate = 0.0f;
|
||||||
|
safe_feedrate = 0.0f;
|
||||||
|
axis_feedrate = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
|
abs_axis_feedrate = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::TimeMachine::CustomGCodeTime::reset()
|
||||||
|
{
|
||||||
|
needed = false;
|
||||||
|
cache = 0.0f;
|
||||||
|
times = std::vector<std::pair<CustomGCode::Type, float>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::TimeMachine::reset()
|
||||||
|
{
|
||||||
|
enabled = false;
|
||||||
|
acceleration = 0.0f;
|
||||||
|
extrude_factor_override_percentage = 1.0f;
|
||||||
|
time = 0.0f;
|
||||||
|
curr.reset();
|
||||||
|
prev.reset();
|
||||||
|
gcode_time.reset();
|
||||||
|
blocks = std::vector<TimeBlock>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::TimeMachine::simulate_st_synchronize(float additional_time)
|
||||||
|
{
|
||||||
|
if (!enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
|
time += additional_time;
|
||||||
|
gcode_time.cache += additional_time;
|
||||||
|
calculate_time();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void planner_forward_pass_kernel(GCodeProcessor::TimeBlock& prev, GCodeProcessor::TimeBlock& curr)
|
||||||
|
{
|
||||||
|
// If the previous block is an acceleration block, but it is not long enough to complete the
|
||||||
|
// full speed change within the block, we need to adjust the entry speed accordingly. Entry
|
||||||
|
// speeds have already been reset, maximized, and reverse planned by reverse planner.
|
||||||
|
// If nominal length is true, max junction speed is guaranteed to be reached. No need to recheck.
|
||||||
|
if (!prev.flags.nominal_length) {
|
||||||
|
if (prev.feedrate_profile.entry < curr.feedrate_profile.entry) {
|
||||||
|
float entry_speed = std::min(curr.feedrate_profile.entry, max_allowable_speed(-prev.acceleration, prev.feedrate_profile.entry, prev.distance));
|
||||||
|
|
||||||
|
// Check for junction speed change
|
||||||
|
if (curr.feedrate_profile.entry != entry_speed) {
|
||||||
|
curr.feedrate_profile.entry = entry_speed;
|
||||||
|
curr.flags.recalculate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void planner_reverse_pass_kernel(GCodeProcessor::TimeBlock& curr, GCodeProcessor::TimeBlock& next)
|
||||||
|
{
|
||||||
|
// If entry speed is already at the maximum entry speed, no need to recheck. Block is cruising.
|
||||||
|
// If not, block in state of acceleration or deceleration. Reset entry speed to maximum and
|
||||||
|
// check for maximum allowable speed reductions to ensure maximum possible planned speed.
|
||||||
|
if (curr.feedrate_profile.entry != curr.max_entry_speed) {
|
||||||
|
// If nominal length true, max junction speed is guaranteed to be reached. Only compute
|
||||||
|
// for max allowable speed if block is decelerating and nominal length is false.
|
||||||
|
if (!curr.flags.nominal_length && curr.max_entry_speed > next.feedrate_profile.entry)
|
||||||
|
curr.feedrate_profile.entry = std::min(curr.max_entry_speed, max_allowable_speed(-curr.acceleration, next.feedrate_profile.entry, curr.distance));
|
||||||
|
else
|
||||||
|
curr.feedrate_profile.entry = curr.max_entry_speed;
|
||||||
|
|
||||||
|
curr.flags.recalculate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void recalculate_trapezoids(std::vector<GCodeProcessor::TimeBlock>& blocks)
|
||||||
|
{
|
||||||
|
GCodeProcessor::TimeBlock* curr = nullptr;
|
||||||
|
GCodeProcessor::TimeBlock* next = nullptr;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < blocks.size(); ++i) {
|
||||||
|
GCodeProcessor::TimeBlock& b = blocks[i];
|
||||||
|
|
||||||
|
curr = next;
|
||||||
|
next = &b;
|
||||||
|
|
||||||
|
if (curr != nullptr) {
|
||||||
|
// Recalculate if current block entry or exit junction speed has changed.
|
||||||
|
if (curr->flags.recalculate || next->flags.recalculate) {
|
||||||
|
// NOTE: Entry and exit factors always > 0 by all previous logic operations.
|
||||||
|
GCodeProcessor::TimeBlock block = *curr;
|
||||||
|
block.feedrate_profile.exit = next->feedrate_profile.entry;
|
||||||
|
block.calculate_trapezoid();
|
||||||
|
curr->trapezoid = block.trapezoid;
|
||||||
|
curr->flags.recalculate = false; // Reset current only to ensure next trapezoid is computed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Last/newest block in buffer. Always recalculated.
|
||||||
|
if (next != nullptr) {
|
||||||
|
GCodeProcessor::TimeBlock block = *next;
|
||||||
|
block.feedrate_profile.exit = next->safe_feedrate;
|
||||||
|
block.calculate_trapezoid();
|
||||||
|
next->trapezoid = block.trapezoid;
|
||||||
|
next->flags.recalculate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::TimeMachine::calculate_time(size_t keep_last_n_blocks)
|
||||||
|
{
|
||||||
|
if (!enabled || blocks.size() < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
assert(keep_last_n_blocks <= blocks.size());
|
||||||
|
|
||||||
|
// forward_pass
|
||||||
|
for (size_t i = 0; i + 1 < blocks.size(); ++i) {
|
||||||
|
planner_forward_pass_kernel(blocks[i], blocks[i + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// reverse_pass
|
||||||
|
for (int i = static_cast<int>(blocks.size()) - 1; i > 0; --i)
|
||||||
|
planner_reverse_pass_kernel(blocks[i - 1], blocks[i]);
|
||||||
|
|
||||||
|
recalculate_trapezoids(blocks);
|
||||||
|
|
||||||
|
size_t n_blocks_process = blocks.size() - keep_last_n_blocks;
|
||||||
|
// m_g1_times.reserve(m_g1_times.size() + n_blocks_process);
|
||||||
|
for (size_t i = 0; i < n_blocks_process; ++i) {
|
||||||
|
float block_time = blocks[i].time();
|
||||||
|
time += block_time;
|
||||||
|
gcode_time.cache += block_time;
|
||||||
|
|
||||||
|
// if (block.g1_line_id >= 0)
|
||||||
|
// m_g1_times.emplace_back(block.g1_line_id, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keep_last_n_blocks)
|
||||||
|
blocks.erase(blocks.begin(), blocks.begin() + n_blocks_process);
|
||||||
|
else
|
||||||
|
blocks.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::TimeProcessor::reset()
|
||||||
|
{
|
||||||
|
extruder_unloaded = true;
|
||||||
|
machine_limits = MachineEnvelopeConfig();
|
||||||
|
filament_load_times = std::vector<float>();
|
||||||
|
filament_unload_times = std::vector<float>();
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) {
|
||||||
|
machines[i].reset();
|
||||||
|
}
|
||||||
|
machines[static_cast<size_t>(ETimeMode::Normal)].enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int GCodeProcessor::s_result_id = 0;
|
unsigned int GCodeProcessor::s_result_id = 0;
|
||||||
|
|
||||||
void GCodeProcessor::apply_config(const PrintConfig& config)
|
void GCodeProcessor::apply_config(const PrintConfig& config)
|
||||||
|
@ -61,6 +310,28 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
|
||||||
for (size_t id = 0; id < extruders_count; ++id) {
|
for (size_t id = 0; id < extruders_count; ++id) {
|
||||||
m_extruders_color[id] = static_cast<unsigned int>(id);
|
m_extruders_color[id] = static_cast<unsigned int>(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_time_processor.machine_limits = reinterpret_cast<const MachineEnvelopeConfig&>(config);
|
||||||
|
// Filament load / unload times are not specific to a firmware flavor. Let anybody use it if they find it useful.
|
||||||
|
// As of now the fields are shown at the UI dialog in the same combo box as the ramming values, so they
|
||||||
|
// are considered to be active for the single extruder multi-material printers only.
|
||||||
|
m_time_processor.filament_load_times.clear();
|
||||||
|
for (double d : config.filament_load_time.values) {
|
||||||
|
m_time_processor.filament_load_times.push_back(static_cast<float>(d));
|
||||||
|
}
|
||||||
|
m_time_processor.filament_unload_times.clear();
|
||||||
|
for (double d : config.filament_unload_time.values) {
|
||||||
|
m_time_processor.filament_unload_times.push_back(static_cast<float>(d));
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) {
|
||||||
|
float max_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_extruding, i);
|
||||||
|
m_time_processor.machines[i].acceleration = (max_acceleration > 0.0f) ? max_acceleration : DEFAULT_ACCELERATION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::enable_stealth_time_estimator(bool enabled)
|
||||||
|
{
|
||||||
|
m_time_processor.machines[static_cast<size_t>(ETimeMode::Stealth)].enabled = enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GCodeProcessor::reset()
|
void GCodeProcessor::reset()
|
||||||
|
@ -71,9 +342,9 @@ void GCodeProcessor::reset()
|
||||||
m_extruder_offsets = std::vector<Vec3f>(1, Vec3f::Zero());
|
m_extruder_offsets = std::vector<Vec3f>(1, Vec3f::Zero());
|
||||||
m_flavor = gcfRepRap;
|
m_flavor = gcfRepRap;
|
||||||
|
|
||||||
std::fill(m_start_position.begin(), m_start_position.end(), 0.0f);
|
m_start_position = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
std::fill(m_end_position.begin(), m_end_position.end(), 0.0f);
|
m_end_position = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
std::fill(m_origin.begin(), m_origin.end(), 0.0f);
|
m_origin = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
m_cached_position.reset();
|
m_cached_position.reset();
|
||||||
|
|
||||||
m_feedrate = 0.0f;
|
m_feedrate = 0.0f;
|
||||||
|
@ -87,6 +358,8 @@ void GCodeProcessor::reset()
|
||||||
m_extruders_color = ExtrudersColor();
|
m_extruders_color = ExtrudersColor();
|
||||||
m_cp_color.reset();
|
m_cp_color.reset();
|
||||||
|
|
||||||
|
m_time_processor.reset();
|
||||||
|
|
||||||
m_result.reset();
|
m_result.reset();
|
||||||
m_result.id = ++s_result_id;
|
m_result.id = ++s_result_id;
|
||||||
}
|
}
|
||||||
|
@ -101,11 +374,43 @@ void GCodeProcessor::process_file(const std::string& filename)
|
||||||
m_result.moves.emplace_back(MoveVertex());
|
m_result.moves.emplace_back(MoveVertex());
|
||||||
m_parser.parse_file(filename, [this](GCodeReader& reader, const GCodeReader::GCodeLine& line) { process_gcode_line(line); });
|
m_parser.parse_file(filename, [this](GCodeReader& reader, const GCodeReader::GCodeLine& line) { process_gcode_line(line); });
|
||||||
|
|
||||||
|
// process the remaining time blocks
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) {
|
||||||
|
TimeMachine& machine = m_time_processor.machines[i];
|
||||||
|
TimeMachine::CustomGCodeTime& gcode_time = machine.gcode_time;
|
||||||
|
machine.calculate_time();
|
||||||
|
if (gcode_time.needed && gcode_time.cache != 0.0f)
|
||||||
|
gcode_time.times.push_back({ CustomGCode::ColorChange, gcode_time.cache });
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
m_result.time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - start_time).count();
|
m_result.time = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - start_time).count();
|
||||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GCodeProcessor::get_time_dhm(ETimeMode mode) const
|
||||||
|
{
|
||||||
|
std::string ret = "N/A";
|
||||||
|
if (mode < ETimeMode::Count)
|
||||||
|
ret = short_time(get_time_dhms(m_time_processor.machines[static_cast<size_t>(mode)].time));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> GCodeProcessor::get_custom_gcode_times(ETimeMode mode, bool include_remaining) const
|
||||||
|
{
|
||||||
|
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> ret;
|
||||||
|
if (mode < ETimeMode::Count) {
|
||||||
|
const TimeMachine& machine = m_time_processor.machines[static_cast<size_t>(mode)];
|
||||||
|
float total_time = 0.0f;
|
||||||
|
for (const auto& [type, time] : machine.gcode_time.times) {
|
||||||
|
float remaining = include_remaining ? machine.time - total_time : 0.0f;
|
||||||
|
ret.push_back({ type, { time, remaining } });
|
||||||
|
total_time += time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line)
|
void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line)
|
||||||
{
|
{
|
||||||
/* std::cout << line.raw() << std::endl; */
|
/* std::cout << line.raw() << std::endl; */
|
||||||
|
@ -126,6 +431,8 @@ void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line)
|
||||||
case 1: { process_G1(line); break; } // Move
|
case 1: { process_G1(line); break; } // Move
|
||||||
case 10: { process_G10(line); break; } // Retract
|
case 10: { process_G10(line); break; } // Retract
|
||||||
case 11: { process_G11(line); break; } // Unretract
|
case 11: { process_G11(line); break; } // Unretract
|
||||||
|
case 20: { process_G20(line); break; } // Set Units to Inches
|
||||||
|
case 21: { process_G21(line); break; } // Set Units to Millimeters
|
||||||
case 22: { process_G22(line); break; } // Firmware controlled retract
|
case 22: { process_G22(line); break; } // Firmware controlled retract
|
||||||
case 23: { process_G23(line); break; } // Firmware controlled unretract
|
case 23: { process_G23(line); break; } // Firmware controlled unretract
|
||||||
case 90: { process_G90(line); break; } // Set to Absolute Positioning
|
case 90: { process_G90(line); break; } // Set to Absolute Positioning
|
||||||
|
@ -139,6 +446,7 @@ void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line)
|
||||||
{
|
{
|
||||||
switch (::atoi(&cmd[1]))
|
switch (::atoi(&cmd[1]))
|
||||||
{
|
{
|
||||||
|
case 1: { process_M1(line); break; } // Sleep or Conditional stop
|
||||||
case 82: { process_M82(line); break; } // Set extruder to absolute mode
|
case 82: { process_M82(line); break; } // Set extruder to absolute mode
|
||||||
case 83: { process_M83(line); break; } // Set extruder to relative mode
|
case 83: { process_M83(line); break; } // Set extruder to relative mode
|
||||||
case 106: { process_M106(line); break; } // Set fan speed
|
case 106: { process_M106(line); break; } // Set fan speed
|
||||||
|
@ -146,8 +454,15 @@ void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line)
|
||||||
case 108: { process_M108(line); break; } // Set tool (Sailfish)
|
case 108: { process_M108(line); break; } // Set tool (Sailfish)
|
||||||
case 132: { process_M132(line); break; } // Recall stored home offsets
|
case 132: { process_M132(line); break; } // Recall stored home offsets
|
||||||
case 135: { process_M135(line); break; } // Set tool (MakerWare)
|
case 135: { process_M135(line); break; } // Set tool (MakerWare)
|
||||||
|
case 201: { process_M201(line); break; } // Set max printing acceleration
|
||||||
|
case 203: { process_M203(line); break; } // Set maximum feedrate
|
||||||
|
case 204: { process_M204(line); break; } // Set default acceleration
|
||||||
|
case 205: { process_M205(line); break; } // Advanced settings
|
||||||
|
case 221: { process_M221(line); break; } // Set extrude factor override percentage
|
||||||
case 401: { process_M401(line); break; } // Repetier: Store x, y and z position
|
case 401: { process_M401(line); break; } // Repetier: Store x, y and z position
|
||||||
case 402: { process_M402(line); break; } // Repetier: Go to stored position
|
case 402: { process_M402(line); break; } // Repetier: Go to stored position
|
||||||
|
case 566: { process_M566(line); break; } // Set allowable instantaneous speed change
|
||||||
|
case 702: { process_M702(line); break; } // Unload the current filament into the MK3 MMU2 unit at the end of print.
|
||||||
default: { break; }
|
default: { break; }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -160,8 +475,7 @@ void GCodeProcessor::process_gcode_line(const GCodeReader::GCodeLine& line)
|
||||||
default: { break; }
|
default: { break; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
std::string comment = line.comment();
|
std::string comment = line.comment();
|
||||||
if (comment.length() > 1)
|
if (comment.length() > 1)
|
||||||
// process tags embedded into comments
|
// process tags embedded into comments
|
||||||
|
@ -179,8 +493,7 @@ void GCodeProcessor::process_tags(const std::string& comment)
|
||||||
int role = std::stoi(comment.substr(pos + Extrusion_Role_Tag.length()));
|
int role = std::stoi(comment.substr(pos + Extrusion_Role_Tag.length()));
|
||||||
if (is_valid_extrusion_role(role))
|
if (is_valid_extrusion_role(role))
|
||||||
m_extrusion_role = static_cast<ExtrusionRole>(role);
|
m_extrusion_role = static_cast<ExtrusionRole>(role);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
// todo: show some error ?
|
// todo: show some error ?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,11 +560,12 @@ void GCodeProcessor::process_tags(const std::string& comment)
|
||||||
if (m_cp_color.counter == UCHAR_MAX)
|
if (m_cp_color.counter == UCHAR_MAX)
|
||||||
m_cp_color.counter = 0;
|
m_cp_color.counter = 0;
|
||||||
|
|
||||||
if (m_extruder_id == extruder_id)
|
if (m_extruder_id == extruder_id) {
|
||||||
{
|
|
||||||
m_cp_color.current = m_extruders_color[extruder_id];
|
m_cp_color.current = m_extruders_color[extruder_id];
|
||||||
store_move_vertex(EMoveType::Color_change);
|
store_move_vertex(EMoveType::Color_change);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process_custom_gcode_time(CustomGCode::ColorChange);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
|
@ -265,6 +579,7 @@ void GCodeProcessor::process_tags(const std::string& comment)
|
||||||
pos = comment.find(Pause_Print_Tag);
|
pos = comment.find(Pause_Print_Tag);
|
||||||
if (pos != comment.npos) {
|
if (pos != comment.npos) {
|
||||||
store_move_vertex(EMoveType::Pause_Print);
|
store_move_vertex(EMoveType::Pause_Print);
|
||||||
|
process_custom_gcode_time(CustomGCode::PausePrint);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,12 +621,14 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
|
||||||
type = EMoveType::Travel;
|
type = EMoveType::Travel;
|
||||||
else
|
else
|
||||||
type = EMoveType::Retract;
|
type = EMoveType::Retract;
|
||||||
} else if (delta_pos[E] > 0.0f) {
|
}
|
||||||
|
else if (delta_pos[E] > 0.0f) {
|
||||||
if (delta_pos[X] == 0.0f && delta_pos[Y] == 0.0f && delta_pos[Z] == 0.0f)
|
if (delta_pos[X] == 0.0f && delta_pos[Y] == 0.0f && delta_pos[Z] == 0.0f)
|
||||||
type = EMoveType::Unretract;
|
type = EMoveType::Unretract;
|
||||||
else if ((delta_pos[X] != 0.0f) || (delta_pos[Y] != 0.0f))
|
else if ((delta_pos[X] != 0.0f) || (delta_pos[Y] != 0.0f))
|
||||||
type = EMoveType::Extrude;
|
type = EMoveType::Extrude;
|
||||||
} else if (delta_pos[X] != 0.0f || delta_pos[Y] != 0.0f || delta_pos[Z] != 0.0f)
|
}
|
||||||
|
else if (delta_pos[X] != 0.0f || delta_pos[Y] != 0.0f || delta_pos[Z] != 0.0f)
|
||||||
type = EMoveType::Travel;
|
type = EMoveType::Travel;
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER_AS_STATE
|
#if ENABLE_GCODE_VIEWER_AS_STATE
|
||||||
|
@ -351,7 +668,165 @@ void GCodeProcessor::process_G1(const GCodeReader::GCodeLine& line)
|
||||||
if (max_abs_delta == 0.0f)
|
if (max_abs_delta == 0.0f)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// store g1 move
|
// time estimate section
|
||||||
|
auto move_length = [](const AxisCoords& delta_pos) {
|
||||||
|
float sq_xyz_length = sqr(delta_pos[X]) + sqr(delta_pos[Y]) + sqr(delta_pos[Z]);
|
||||||
|
return (sq_xyz_length > 0.0f) ? std::sqrt(sq_xyz_length) : std::abs(delta_pos[E]);
|
||||||
|
};
|
||||||
|
|
||||||
|
auto is_extruder_only_move = [](const AxisCoords& delta_pos) {
|
||||||
|
return (delta_pos[X] == 0.0f) && (delta_pos[Y] == 0.0f) && (delta_pos[Z] == 0.0f) && (delta_pos[E] != 0.0f);
|
||||||
|
};
|
||||||
|
|
||||||
|
float distance = move_length(delta_pos);
|
||||||
|
assert(distance != 0.0f);
|
||||||
|
float inv_distance = 1.0f / distance;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) {
|
||||||
|
TimeMachine& machine = m_time_processor.machines[i];
|
||||||
|
if (!machine.enabled)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
TimeMachine::State& curr = machine.curr;
|
||||||
|
TimeMachine::State& prev = machine.prev;
|
||||||
|
std::vector<TimeBlock>& blocks = machine.blocks;
|
||||||
|
|
||||||
|
curr.feedrate = (delta_pos[E] == 0.0f) ?
|
||||||
|
minimum_travel_feedrate(static_cast<ETimeMode>(i), m_feedrate) :
|
||||||
|
minimum_feedrate(static_cast<ETimeMode>(i), m_feedrate);
|
||||||
|
|
||||||
|
TimeBlock block;
|
||||||
|
block.distance = distance;
|
||||||
|
|
||||||
|
// calculates block cruise feedrate
|
||||||
|
float min_feedrate_factor = 1.0f;
|
||||||
|
for (unsigned char a = X; a <= E; ++a) {
|
||||||
|
curr.axis_feedrate[a] = curr.feedrate * delta_pos[a] * inv_distance;
|
||||||
|
if (a == E)
|
||||||
|
curr.axis_feedrate[a] *= machine.extrude_factor_override_percentage;
|
||||||
|
|
||||||
|
curr.abs_axis_feedrate[a] = std::abs(curr.axis_feedrate[a]);
|
||||||
|
if (curr.abs_axis_feedrate[a] != 0.0f) {
|
||||||
|
float axis_max_feedrate = get_axis_max_feedrate(static_cast<ETimeMode>(i), static_cast<Axis>(a));
|
||||||
|
if (axis_max_feedrate != 0.0f)
|
||||||
|
min_feedrate_factor = std::min(min_feedrate_factor, axis_max_feedrate / curr.abs_axis_feedrate[a]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
block.feedrate_profile.cruise = min_feedrate_factor * curr.feedrate;
|
||||||
|
|
||||||
|
if (min_feedrate_factor < 1.0f) {
|
||||||
|
for (unsigned char a = X; a <= E; ++a) {
|
||||||
|
curr.axis_feedrate[a] *= min_feedrate_factor;
|
||||||
|
curr.abs_axis_feedrate[a] *= min_feedrate_factor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// calculates block acceleration
|
||||||
|
float acceleration = is_extruder_only_move(delta_pos) ?
|
||||||
|
get_retract_acceleration(static_cast<ETimeMode>(i)) :
|
||||||
|
get_acceleration(static_cast<ETimeMode>(i));
|
||||||
|
|
||||||
|
for (unsigned char a = X; a <= E; ++a) {
|
||||||
|
float axis_max_acceleration = get_axis_max_acceleration(static_cast<ETimeMode>(i), static_cast<Axis>(a));
|
||||||
|
if (acceleration * std::abs(delta_pos[a]) * inv_distance > axis_max_acceleration)
|
||||||
|
acceleration = axis_max_acceleration;
|
||||||
|
}
|
||||||
|
|
||||||
|
block.acceleration = acceleration;
|
||||||
|
|
||||||
|
// calculates block exit feedrate
|
||||||
|
curr.safe_feedrate = block.feedrate_profile.cruise;
|
||||||
|
|
||||||
|
for (unsigned char a = X; a <= E; ++a) {
|
||||||
|
float axis_max_jerk = get_axis_max_jerk(static_cast<ETimeMode>(i), static_cast<Axis>(a));
|
||||||
|
if (curr.abs_axis_feedrate[a] > axis_max_jerk)
|
||||||
|
curr.safe_feedrate = std::min(curr.safe_feedrate, axis_max_jerk);
|
||||||
|
}
|
||||||
|
|
||||||
|
block.feedrate_profile.exit = curr.safe_feedrate;
|
||||||
|
|
||||||
|
static const float PREVIOUS_FEEDRATE_THRESHOLD = 0.0001f;
|
||||||
|
|
||||||
|
// calculates block entry feedrate
|
||||||
|
float vmax_junction = curr.safe_feedrate;
|
||||||
|
if (!blocks.empty() && prev.feedrate > PREVIOUS_FEEDRATE_THRESHOLD) {
|
||||||
|
bool prev_speed_larger = prev.feedrate > block.feedrate_profile.cruise;
|
||||||
|
float smaller_speed_factor = prev_speed_larger ? (block.feedrate_profile.cruise / prev.feedrate) : (prev.feedrate / block.feedrate_profile.cruise);
|
||||||
|
// Pick the smaller of the nominal speeds. Higher speed shall not be achieved at the junction during coasting.
|
||||||
|
vmax_junction = prev_speed_larger ? block.feedrate_profile.cruise : prev.feedrate;
|
||||||
|
|
||||||
|
float v_factor = 1.0f;
|
||||||
|
bool limited = false;
|
||||||
|
|
||||||
|
for (unsigned char a = X; a <= E; ++a) {
|
||||||
|
// Limit an axis. We have to differentiate coasting from the reversal of an axis movement, or a full stop.
|
||||||
|
float v_exit = prev.axis_feedrate[a];
|
||||||
|
float v_entry = curr.axis_feedrate[a];
|
||||||
|
|
||||||
|
if (prev_speed_larger)
|
||||||
|
v_exit *= smaller_speed_factor;
|
||||||
|
|
||||||
|
if (limited) {
|
||||||
|
v_exit *= v_factor;
|
||||||
|
v_entry *= v_factor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate the jerk depending on whether the axis is coasting in the same direction or reversing a direction.
|
||||||
|
float jerk =
|
||||||
|
(v_exit > v_entry) ?
|
||||||
|
(((v_entry > 0.0f) || (v_exit < 0.0f)) ?
|
||||||
|
// coasting
|
||||||
|
(v_exit - v_entry) :
|
||||||
|
// axis reversal
|
||||||
|
std::max(v_exit, -v_entry)) :
|
||||||
|
// v_exit <= v_entry
|
||||||
|
(((v_entry < 0.0f) || (v_exit > 0.0f)) ?
|
||||||
|
// coasting
|
||||||
|
(v_entry - v_exit) :
|
||||||
|
// axis reversal
|
||||||
|
std::max(-v_exit, v_entry));
|
||||||
|
|
||||||
|
float axis_max_jerk = get_axis_max_jerk(static_cast<ETimeMode>(i), static_cast<Axis>(a));
|
||||||
|
if (jerk > axis_max_jerk) {
|
||||||
|
v_factor *= axis_max_jerk / jerk;
|
||||||
|
limited = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (limited)
|
||||||
|
vmax_junction *= v_factor;
|
||||||
|
|
||||||
|
// Now the transition velocity is known, which maximizes the shared exit / entry velocity while
|
||||||
|
// respecting the jerk factors, it may be possible, that applying separate safe exit / entry velocities will achieve faster prints.
|
||||||
|
float vmax_junction_threshold = vmax_junction * 0.99f;
|
||||||
|
|
||||||
|
// Not coasting. The machine will stop and start the movements anyway, better to start the segment from start.
|
||||||
|
if ((prev.safe_feedrate > vmax_junction_threshold) && (curr.safe_feedrate > vmax_junction_threshold))
|
||||||
|
vmax_junction = curr.safe_feedrate;
|
||||||
|
}
|
||||||
|
|
||||||
|
float v_allowable = max_allowable_speed(-acceleration, curr.safe_feedrate, block.distance);
|
||||||
|
block.feedrate_profile.entry = std::min(vmax_junction, v_allowable);
|
||||||
|
|
||||||
|
block.max_entry_speed = vmax_junction;
|
||||||
|
block.flags.nominal_length = (block.feedrate_profile.cruise <= v_allowable);
|
||||||
|
block.flags.recalculate = true;
|
||||||
|
block.safe_feedrate = curr.safe_feedrate;
|
||||||
|
|
||||||
|
// calculates block trapezoid
|
||||||
|
block.calculate_trapezoid();
|
||||||
|
|
||||||
|
// updates previous
|
||||||
|
prev = curr;
|
||||||
|
|
||||||
|
blocks.push_back(block);
|
||||||
|
|
||||||
|
if (blocks.size() > TimeProcessor::Planner::refresh_threshold)
|
||||||
|
machine.calculate_time(TimeProcessor::Planner::queue_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// store move
|
||||||
store_move_vertex(move_type(delta_pos));
|
store_move_vertex(move_type(delta_pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,6 +842,16 @@ void GCodeProcessor::process_G11(const GCodeReader::GCodeLine& line)
|
||||||
store_move_vertex(EMoveType::Unretract);
|
store_move_vertex(EMoveType::Unretract);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::process_G20(const GCodeReader::GCodeLine& line)
|
||||||
|
{
|
||||||
|
m_units = EUnits::Inches;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::process_G21(const GCodeReader::GCodeLine& line)
|
||||||
|
{
|
||||||
|
m_units = EUnits::Millimeters;
|
||||||
|
}
|
||||||
|
|
||||||
void GCodeProcessor::process_G22(const GCodeReader::GCodeLine& line)
|
void GCodeProcessor::process_G22(const GCodeReader::GCodeLine& line)
|
||||||
{
|
{
|
||||||
// stores retract move
|
// stores retract move
|
||||||
|
@ -391,32 +876,34 @@ void GCodeProcessor::process_G91(const GCodeReader::GCodeLine& line)
|
||||||
|
|
||||||
void GCodeProcessor::process_G92(const GCodeReader::GCodeLine& line)
|
void GCodeProcessor::process_G92(const GCodeReader::GCodeLine& line)
|
||||||
{
|
{
|
||||||
float lengthsScaleFactor = (m_units == EUnits::Inches) ? INCHES_TO_MM : 1.0f;
|
float lengths_scale_factor = (m_units == EUnits::Inches) ? INCHES_TO_MM : 1.0f;
|
||||||
bool anyFound = false;
|
bool any_found = false;
|
||||||
|
|
||||||
if (line.has_x()) {
|
if (line.has_x()) {
|
||||||
m_origin[X] = m_end_position[X] - line.x() * lengthsScaleFactor;
|
m_origin[X] = m_end_position[X] - line.x() * lengths_scale_factor;
|
||||||
anyFound = true;
|
any_found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.has_y()) {
|
if (line.has_y()) {
|
||||||
m_origin[Y] = m_end_position[Y] - line.y() * lengthsScaleFactor;
|
m_origin[Y] = m_end_position[Y] - line.y() * lengths_scale_factor;
|
||||||
anyFound = true;
|
any_found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.has_z()) {
|
if (line.has_z()) {
|
||||||
m_origin[Z] = m_end_position[Z] - line.z() * lengthsScaleFactor;
|
m_origin[Z] = m_end_position[Z] - line.z() * lengths_scale_factor;
|
||||||
anyFound = true;
|
any_found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.has_e()) {
|
if (line.has_e()) {
|
||||||
// extruder coordinate can grow to the point where its float representation does not allow for proper addition with small increments,
|
// extruder coordinate can grow to the point where its float representation does not allow for proper addition with small increments,
|
||||||
// we set the value taken from the G92 line as the new current position for it
|
// we set the value taken from the G92 line as the new current position for it
|
||||||
m_end_position[E] = line.e() * lengthsScaleFactor;
|
m_end_position[E] = line.e() * lengths_scale_factor;
|
||||||
anyFound = true;
|
any_found = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
simulate_st_synchronize();
|
||||||
|
|
||||||
if (!anyFound && !line.has_unknown_axis()) {
|
if (!any_found && !line.has_unknown_axis()) {
|
||||||
// The G92 may be called for axes that PrusaSlicer does not recognize, for example see GH issue #3510,
|
// The G92 may be called for axes that PrusaSlicer does not recognize, for example see GH issue #3510,
|
||||||
// where G92 A0 B0 is called although the extruder axis is till E.
|
// where G92 A0 B0 is called although the extruder axis is till E.
|
||||||
for (unsigned char a = X; a <= E; ++a) {
|
for (unsigned char a = X; a <= E; ++a) {
|
||||||
|
@ -425,6 +912,11 @@ void GCodeProcessor::process_G92(const GCodeReader::GCodeLine& line)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::process_M1(const GCodeReader::GCodeLine& line)
|
||||||
|
{
|
||||||
|
simulate_st_synchronize();
|
||||||
|
}
|
||||||
|
|
||||||
void GCodeProcessor::process_M82(const GCodeReader::GCodeLine& line)
|
void GCodeProcessor::process_M82(const GCodeReader::GCodeLine& line)
|
||||||
{
|
{
|
||||||
m_e_local_positioning_type = EPositioningType::Absolute;
|
m_e_local_positioning_type = EPositioningType::Absolute;
|
||||||
|
@ -501,6 +993,117 @@ void GCodeProcessor::process_M135(const GCodeReader::GCodeLine& line)
|
||||||
process_T(cmd.substr(pos));
|
process_T(cmd.substr(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::process_M201(const GCodeReader::GCodeLine& line)
|
||||||
|
{
|
||||||
|
// see http://reprap.org/wiki/G-code#M201:_Set_max_printing_acceleration
|
||||||
|
float factor = (m_flavor != gcfRepRap && m_units == EUnits::Inches) ? INCHES_TO_MM : 1.0f;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) {
|
||||||
|
if (line.has_x())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_acceleration_x, i, line.x() * factor);
|
||||||
|
|
||||||
|
if (line.has_y() && i < m_time_processor.machine_limits.machine_max_acceleration_y.values.size())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_acceleration_y, i, line.y() * factor);
|
||||||
|
|
||||||
|
if (line.has_z() && i < m_time_processor.machine_limits.machine_max_acceleration_z.values.size())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_acceleration_z, i, line.z() * factor);
|
||||||
|
|
||||||
|
if (line.has_e() && i < m_time_processor.machine_limits.machine_max_acceleration_e.values.size())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_acceleration_e, i, line.e() * factor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::process_M203(const GCodeReader::GCodeLine& line)
|
||||||
|
{
|
||||||
|
// see http://reprap.org/wiki/G-code#M203:_Set_maximum_feedrate
|
||||||
|
if (m_flavor == gcfRepetier)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// see http://reprap.org/wiki/G-code#M203:_Set_maximum_feedrate
|
||||||
|
// http://smoothieware.org/supported-g-codes
|
||||||
|
float factor = (m_flavor == gcfMarlin || m_flavor == gcfSmoothie) ? 1.0f : MMMIN_TO_MMSEC;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) {
|
||||||
|
if (line.has_x())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_feedrate_x, i, line.x() * factor);
|
||||||
|
|
||||||
|
if (line.has_y())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_feedrate_y, i, line.y() * factor);
|
||||||
|
|
||||||
|
if (line.has_z())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_feedrate_z, i, line.z() * factor);
|
||||||
|
|
||||||
|
if (line.has_e())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_feedrate_e, i, line.e() * factor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::process_M204(const GCodeReader::GCodeLine& line)
|
||||||
|
{
|
||||||
|
float value;
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) {
|
||||||
|
if (line.has_value('S', value)) {
|
||||||
|
// Legacy acceleration format. This format is used by the legacy Marlin, MK2 or MK3 firmware,
|
||||||
|
// and it is also generated by Slic3r to control acceleration per extrusion type
|
||||||
|
// (there is a separate acceleration settings in Slicer for perimeter, first layer etc).
|
||||||
|
set_acceleration(static_cast<ETimeMode>(i), value);
|
||||||
|
if (line.has_value('T', value))
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_acceleration_retracting, i, value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// New acceleration format, compatible with the upstream Marlin.
|
||||||
|
if (line.has_value('P', value))
|
||||||
|
set_acceleration(static_cast<ETimeMode>(i), value);
|
||||||
|
if (line.has_value('R', value))
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_acceleration_retracting, i, value);
|
||||||
|
if (line.has_value('T', value)) {
|
||||||
|
// Interpret the T value as the travel acceleration in the new Marlin format.
|
||||||
|
//FIXME Prusa3D firmware currently does not support travel acceleration value independent from the extruding acceleration value.
|
||||||
|
// set_travel_acceleration(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::process_M205(const GCodeReader::GCodeLine& line)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) {
|
||||||
|
if (line.has_x()) {
|
||||||
|
float max_jerk = line.x();
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_jerk_x, i, max_jerk);
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_jerk_y, i, max_jerk);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (line.has_y())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_jerk_y, i, line.y());
|
||||||
|
|
||||||
|
if (line.has_z())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_jerk_z, i, line.z());
|
||||||
|
|
||||||
|
if (line.has_e())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_jerk_e, i, line.e());
|
||||||
|
|
||||||
|
float value;
|
||||||
|
if (line.has_value('S', value))
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_min_extruding_rate, i, value);
|
||||||
|
|
||||||
|
if (line.has_value('T', value))
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_min_travel_rate, i, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::process_M221(const GCodeReader::GCodeLine& line)
|
||||||
|
{
|
||||||
|
float value_s;
|
||||||
|
float value_t;
|
||||||
|
if (line.has_value('S', value_s) && !line.has_value('T', value_t)) {
|
||||||
|
value_s *= 0.01f;
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) {
|
||||||
|
m_time_processor.machines[i].extrude_factor_override_percentage = value_s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GCodeProcessor::process_M401(const GCodeReader::GCodeLine& line)
|
void GCodeProcessor::process_M401(const GCodeReader::GCodeLine& line)
|
||||||
{
|
{
|
||||||
if (m_flavor != gcfRepetier)
|
if (m_flavor != gcfRepetier)
|
||||||
|
@ -544,6 +1147,34 @@ void GCodeProcessor::process_M402(const GCodeReader::GCodeLine& line)
|
||||||
m_feedrate = p;
|
m_feedrate = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::process_M566(const GCodeReader::GCodeLine& line)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) {
|
||||||
|
if (line.has_x())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_jerk_x, i, line.x() * MMMIN_TO_MMSEC);
|
||||||
|
|
||||||
|
if (line.has_y())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_jerk_y, i, line.y() * MMMIN_TO_MMSEC);
|
||||||
|
|
||||||
|
if (line.has_z())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_jerk_z, i, line.z() * MMMIN_TO_MMSEC);
|
||||||
|
|
||||||
|
if (line.has_e())
|
||||||
|
set_option_value(m_time_processor.machine_limits.machine_max_jerk_e, i, line.e() * MMMIN_TO_MMSEC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::process_M702(const GCodeReader::GCodeLine& line)
|
||||||
|
{
|
||||||
|
if (line.has('C')) {
|
||||||
|
// MK3 MMU2 specific M code:
|
||||||
|
// M702 C is expected to be sent by the custom end G-code when finalizing a print.
|
||||||
|
// The MK3 unit shall unload and park the active filament into the MMU2 unit.
|
||||||
|
m_time_processor.extruder_unloaded = true;
|
||||||
|
simulate_st_synchronize(get_filament_unload_time(m_extruder_id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GCodeProcessor::process_T(const GCodeReader::GCodeLine& line)
|
void GCodeProcessor::process_T(const GCodeReader::GCodeLine& line)
|
||||||
{
|
{
|
||||||
process_T(line.cmd());
|
process_T(line.cmd());
|
||||||
|
@ -560,8 +1191,16 @@ void GCodeProcessor::process_T(const std::string& command)
|
||||||
if (id >= extruders_count)
|
if (id >= extruders_count)
|
||||||
BOOST_LOG_TRIVIAL(error) << "GCodeProcessor encountered an invalid toolchange, maybe from a custom gcode.";
|
BOOST_LOG_TRIVIAL(error) << "GCodeProcessor encountered an invalid toolchange, maybe from a custom gcode.";
|
||||||
else {
|
else {
|
||||||
|
unsigned char old_extruder_id = m_extruder_id;
|
||||||
m_extruder_id = id;
|
m_extruder_id = id;
|
||||||
m_cp_color.current = m_extruders_color[id];
|
m_cp_color.current = m_extruders_color[id];
|
||||||
|
// Specific to the MK3 MMU2:
|
||||||
|
// The initial value of extruder_unloaded is set to true indicating
|
||||||
|
// that the filament is parked in the MMU2 unit and there is nothing to be unloaded yet.
|
||||||
|
float extra_time = get_filament_unload_time(static_cast<size_t>(old_extruder_id));
|
||||||
|
m_time_processor.extruder_unloaded = false;
|
||||||
|
extra_time += get_filament_load_time(static_cast<size_t>(m_extruder_id));
|
||||||
|
simulate_st_synchronize(extra_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
// store tool change move
|
// store tool change move
|
||||||
|
@ -593,6 +1232,120 @@ void GCodeProcessor::store_move_vertex(EMoveType type)
|
||||||
m_result.moves.emplace_back(vertex);
|
m_result.moves.emplace_back(vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::minimum_feedrate(ETimeMode mode, float feedrate) const
|
||||||
|
{
|
||||||
|
if (m_time_processor.machine_limits.machine_min_extruding_rate.empty())
|
||||||
|
return feedrate;
|
||||||
|
|
||||||
|
return std::max(feedrate, get_option_value(m_time_processor.machine_limits.machine_min_extruding_rate, static_cast<size_t>(mode)));
|
||||||
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::minimum_travel_feedrate(ETimeMode mode, float feedrate) const
|
||||||
|
{
|
||||||
|
if (m_time_processor.machine_limits.machine_min_travel_rate.empty())
|
||||||
|
return feedrate;
|
||||||
|
|
||||||
|
return std::max(feedrate, get_option_value(m_time_processor.machine_limits.machine_min_travel_rate, static_cast<size_t>(mode)));
|
||||||
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::get_axis_max_feedrate(ETimeMode mode, Axis axis) const
|
||||||
|
{
|
||||||
|
switch (axis)
|
||||||
|
{
|
||||||
|
case X: { return get_option_value(m_time_processor.machine_limits.machine_max_feedrate_x, static_cast<size_t>(mode)); }
|
||||||
|
case Y: { return get_option_value(m_time_processor.machine_limits.machine_max_feedrate_y, static_cast<size_t>(mode)); }
|
||||||
|
case Z: { return get_option_value(m_time_processor.machine_limits.machine_max_feedrate_z, static_cast<size_t>(mode)); }
|
||||||
|
case E: { return get_option_value(m_time_processor.machine_limits.machine_max_feedrate_e, static_cast<size_t>(mode)); }
|
||||||
|
default: { return 0.0f; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::get_axis_max_acceleration(ETimeMode mode, Axis axis) const
|
||||||
|
{
|
||||||
|
switch (axis)
|
||||||
|
{
|
||||||
|
case X: { return get_option_value(m_time_processor.machine_limits.machine_max_acceleration_x, static_cast<size_t>(mode)); }
|
||||||
|
case Y: { return get_option_value(m_time_processor.machine_limits.machine_max_acceleration_y, static_cast<size_t>(mode)); }
|
||||||
|
case Z: { return get_option_value(m_time_processor.machine_limits.machine_max_acceleration_z, static_cast<size_t>(mode)); }
|
||||||
|
case E: { return get_option_value(m_time_processor.machine_limits.machine_max_acceleration_e, static_cast<size_t>(mode)); }
|
||||||
|
default: { return 0.0f; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::get_axis_max_jerk(ETimeMode mode, Axis axis) const
|
||||||
|
{
|
||||||
|
switch (axis)
|
||||||
|
{
|
||||||
|
case X: { return get_option_value(m_time_processor.machine_limits.machine_max_jerk_x, static_cast<size_t>(mode)); }
|
||||||
|
case Y: { return get_option_value(m_time_processor.machine_limits.machine_max_jerk_y, static_cast<size_t>(mode)); }
|
||||||
|
case Z: { return get_option_value(m_time_processor.machine_limits.machine_max_jerk_z, static_cast<size_t>(mode)); }
|
||||||
|
case E: { return get_option_value(m_time_processor.machine_limits.machine_max_jerk_e, static_cast<size_t>(mode)); }
|
||||||
|
default: { return 0.0f; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::get_retract_acceleration(ETimeMode mode) const
|
||||||
|
{
|
||||||
|
return get_option_value(m_time_processor.machine_limits.machine_max_acceleration_retracting, static_cast<size_t>(mode));
|
||||||
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::get_acceleration(ETimeMode mode) const
|
||||||
|
{
|
||||||
|
size_t id = static_cast<size_t>(mode);
|
||||||
|
return (id < m_time_processor.machines.size()) ? m_time_processor.machines[id].acceleration : DEFAULT_ACCELERATION;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::set_acceleration(ETimeMode mode, float value)
|
||||||
|
{
|
||||||
|
size_t id = static_cast<size_t>(mode);
|
||||||
|
if (id < m_time_processor.machines.size()) {
|
||||||
|
float max_acceleration = get_option_value(m_time_processor.machine_limits.machine_max_acceleration_extruding, id);
|
||||||
|
m_time_processor.machines[id].acceleration = (max_acceleration == 0.0f) ? value : std::min(value, max_acceleration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::get_filament_load_time(size_t extruder_id)
|
||||||
|
{
|
||||||
|
return (m_time_processor.filament_load_times.empty() || m_time_processor.extruder_unloaded) ?
|
||||||
|
0.0f :
|
||||||
|
((extruder_id < m_time_processor.filament_load_times.size()) ?
|
||||||
|
m_time_processor.filament_load_times[extruder_id] : m_time_processor.filament_load_times.front());
|
||||||
|
}
|
||||||
|
|
||||||
|
float GCodeProcessor::get_filament_unload_time(size_t extruder_id)
|
||||||
|
{
|
||||||
|
return (m_time_processor.filament_unload_times.empty() || m_time_processor.extruder_unloaded) ?
|
||||||
|
0.0f :
|
||||||
|
((extruder_id < m_time_processor.filament_unload_times.size()) ?
|
||||||
|
m_time_processor.filament_unload_times[extruder_id] : m_time_processor.filament_unload_times.front());
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::process_custom_gcode_time(CustomGCode::Type code)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) {
|
||||||
|
TimeMachine& machine = m_time_processor.machines[i];
|
||||||
|
if (!machine.enabled)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
TimeMachine::CustomGCodeTime& gcode_time = machine.gcode_time;
|
||||||
|
gcode_time.needed = true;
|
||||||
|
//FIXME this simulates st_synchronize! is it correct?
|
||||||
|
// The estimated time may be longer than the real print time.
|
||||||
|
machine.simulate_st_synchronize();
|
||||||
|
if (gcode_time.cache != 0.0f) {
|
||||||
|
gcode_time.times.push_back({ code, gcode_time.cache });
|
||||||
|
gcode_time.cache = 0.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GCodeProcessor::simulate_st_synchronize(float additional_time)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < static_cast<size_t>(ETimeMode::Count); ++i) {
|
||||||
|
m_time_processor.machines[i].simulate_st_synchronize(additional_time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace Slic3r */
|
} /* namespace Slic3r */
|
||||||
|
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include "libslic3r/GCodeReader.hpp"
|
#include "libslic3r/GCodeReader.hpp"
|
||||||
#include "libslic3r/Point.hpp"
|
#include "libslic3r/Point.hpp"
|
||||||
#include "libslic3r/ExtrusionEntity.hpp"
|
#include "libslic3r/ExtrusionEntity.hpp"
|
||||||
|
#include "libslic3r/PrintConfig.hpp"
|
||||||
|
#include "libslic3r/CustomGCode.hpp"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -54,6 +56,118 @@ namespace Slic3r {
|
||||||
void reset();
|
void reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct FeedrateProfile
|
||||||
|
{
|
||||||
|
float entry{ 0.0f }; // mm/s
|
||||||
|
float cruise{ 0.0f }; // mm/s
|
||||||
|
float exit{ 0.0f }; // mm/s
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Trapezoid
|
||||||
|
{
|
||||||
|
float accelerate_until{ 0.0f }; // mm
|
||||||
|
float decelerate_after{ 0.0f }; // mm
|
||||||
|
float cruise_feedrate{ 0.0f }; // mm/sec
|
||||||
|
|
||||||
|
float acceleration_time(float entry_feedrate, float acceleration) const;
|
||||||
|
float cruise_time() const;
|
||||||
|
float deceleration_time(float distance, float acceleration) const;
|
||||||
|
float cruise_distance() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TimeBlock
|
||||||
|
{
|
||||||
|
struct Flags
|
||||||
|
{
|
||||||
|
bool recalculate{ false };
|
||||||
|
bool nominal_length{ false };
|
||||||
|
};
|
||||||
|
|
||||||
|
float distance{ 0.0f }; // mm
|
||||||
|
float acceleration{ 0.0f }; // mm/s^2
|
||||||
|
float max_entry_speed{ 0.0f }; // mm/s
|
||||||
|
float safe_feedrate{ 0.0f }; // mm/s
|
||||||
|
Flags flags;
|
||||||
|
FeedrateProfile feedrate_profile;
|
||||||
|
Trapezoid trapezoid;
|
||||||
|
|
||||||
|
// Calculates this block's trapezoid
|
||||||
|
void calculate_trapezoid();
|
||||||
|
|
||||||
|
float time() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ETimeMode : unsigned char
|
||||||
|
{
|
||||||
|
Normal,
|
||||||
|
Stealth,
|
||||||
|
Count
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct TimeMachine
|
||||||
|
{
|
||||||
|
struct State
|
||||||
|
{
|
||||||
|
float feedrate; // mm/s
|
||||||
|
float safe_feedrate; // mm/s
|
||||||
|
AxisCoords axis_feedrate; // mm/s
|
||||||
|
AxisCoords abs_axis_feedrate; // mm/s
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CustomGCodeTime
|
||||||
|
{
|
||||||
|
bool needed;
|
||||||
|
float cache;
|
||||||
|
std::vector<std::pair<CustomGCode::Type, float>> times;
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
};
|
||||||
|
|
||||||
|
bool enabled;
|
||||||
|
float acceleration; // mm/s^2
|
||||||
|
float extrude_factor_override_percentage;
|
||||||
|
float time; // s
|
||||||
|
State curr;
|
||||||
|
State prev;
|
||||||
|
CustomGCodeTime gcode_time;
|
||||||
|
std::vector<TimeBlock> blocks;
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
// Simulates firmware st_synchronize() call
|
||||||
|
void simulate_st_synchronize(float additional_time = 0.0f);
|
||||||
|
void calculate_time(size_t keep_last_n_blocks = 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TimeProcessor
|
||||||
|
{
|
||||||
|
struct Planner
|
||||||
|
{
|
||||||
|
// Size of the firmware planner queue. The old 8-bit Marlins usually just managed 16 trapezoidal blocks.
|
||||||
|
// Let's be conservative and plan for newer boards with more memory.
|
||||||
|
static constexpr size_t queue_size = 64;
|
||||||
|
// The firmware recalculates last planner_queue_size trapezoidal blocks each time a new block is added.
|
||||||
|
// We are not simulating the firmware exactly, we calculate a sequence of blocks once a reasonable number of blocks accumulate.
|
||||||
|
static constexpr size_t refresh_threshold = queue_size * 4;
|
||||||
|
};
|
||||||
|
|
||||||
|
// extruder_id is currently used to correctly calculate filament load / unload times into the total print time.
|
||||||
|
// This is currently only really used by the MK3 MMU2:
|
||||||
|
// extruder_unloaded = true means no filament is loaded yet, all the filaments are parked in the MK3 MMU2 unit.
|
||||||
|
bool extruder_unloaded;
|
||||||
|
MachineEnvelopeConfig machine_limits;
|
||||||
|
// Additional load / unload times for a filament exchange sequence.
|
||||||
|
std::vector<float> filament_load_times;
|
||||||
|
std::vector<float> filament_unload_times;
|
||||||
|
std::array<TimeMachine, static_cast<size_t>(ETimeMode::Count)> machines;
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class EMoveType : unsigned char
|
enum class EMoveType : unsigned char
|
||||||
{
|
{
|
||||||
|
@ -85,21 +199,6 @@ namespace Slic3r {
|
||||||
float time{ 0.0f }; // s
|
float time{ 0.0f }; // s
|
||||||
|
|
||||||
float volumetric_rate() const { return feedrate * mm3_per_mm; }
|
float volumetric_rate() const { return feedrate * mm3_per_mm; }
|
||||||
|
|
||||||
std::string to_string() const
|
|
||||||
{
|
|
||||||
std::string str = std::to_string((int)type);
|
|
||||||
str += ", " + std::to_string((int)extrusion_role);
|
|
||||||
str += ", " + Slic3r::to_string((Vec3d)position.cast<double>());
|
|
||||||
str += ", " + std::to_string(extruder_id);
|
|
||||||
str += ", " + std::to_string(cp_color_id);
|
|
||||||
str += ", " + std::to_string(feedrate);
|
|
||||||
str += ", " + std::to_string(width);
|
|
||||||
str += ", " + std::to_string(height);
|
|
||||||
str += ", " + std::to_string(mm3_per_mm);
|
|
||||||
str += ", " + std::to_string(fan_speed);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Result
|
struct Result
|
||||||
|
@ -138,6 +237,8 @@ namespace Slic3r {
|
||||||
ExtrudersColor m_extruders_color;
|
ExtrudersColor m_extruders_color;
|
||||||
CpColor m_cp_color;
|
CpColor m_cp_color;
|
||||||
|
|
||||||
|
TimeProcessor m_time_processor;
|
||||||
|
|
||||||
Result m_result;
|
Result m_result;
|
||||||
static unsigned int s_result_id;
|
static unsigned int s_result_id;
|
||||||
|
|
||||||
|
@ -145,6 +246,7 @@ namespace Slic3r {
|
||||||
GCodeProcessor() { reset(); }
|
GCodeProcessor() { reset(); }
|
||||||
|
|
||||||
void apply_config(const PrintConfig& config);
|
void apply_config(const PrintConfig& config);
|
||||||
|
void enable_stealth_time_estimator(bool enabled);
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
const Result& get_result() const { return m_result; }
|
const Result& get_result() const { return m_result; }
|
||||||
|
@ -153,6 +255,9 @@ namespace Slic3r {
|
||||||
// Process the gcode contained in the file with the given filename
|
// Process the gcode contained in the file with the given filename
|
||||||
void process_file(const std::string& filename);
|
void process_file(const std::string& filename);
|
||||||
|
|
||||||
|
std::string get_time_dhm(ETimeMode mode) const;
|
||||||
|
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> get_custom_gcode_times(ETimeMode mode, bool include_remaining) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void process_gcode_line(const GCodeReader::GCodeLine& line);
|
void process_gcode_line(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
@ -169,6 +274,12 @@ namespace Slic3r {
|
||||||
// Unretract
|
// Unretract
|
||||||
void process_G11(const GCodeReader::GCodeLine& line);
|
void process_G11(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
// Set Units to Inches
|
||||||
|
void process_G20(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
// Set Units to Millimeters
|
||||||
|
void process_G21(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
// Firmware controlled Retract
|
// Firmware controlled Retract
|
||||||
void process_G22(const GCodeReader::GCodeLine& line);
|
void process_G22(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
@ -184,6 +295,9 @@ namespace Slic3r {
|
||||||
// Set Position
|
// Set Position
|
||||||
void process_G92(const GCodeReader::GCodeLine& line);
|
void process_G92(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
// Sleep or Conditional stop
|
||||||
|
void process_M1(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
// Set extruder to absolute mode
|
// Set extruder to absolute mode
|
||||||
void process_M82(const GCodeReader::GCodeLine& line);
|
void process_M82(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
@ -205,17 +319,54 @@ namespace Slic3r {
|
||||||
// Set tool (MakerWare)
|
// Set tool (MakerWare)
|
||||||
void process_M135(const GCodeReader::GCodeLine& line);
|
void process_M135(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
// Set max printing acceleration
|
||||||
|
void process_M201(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
// Set maximum feedrate
|
||||||
|
void process_M203(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
// Set default acceleration
|
||||||
|
void process_M204(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
// Advanced settings
|
||||||
|
void process_M205(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
// Set extrude factor override percentage
|
||||||
|
void process_M221(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
// Repetier: Store x, y and z position
|
// Repetier: Store x, y and z position
|
||||||
void process_M401(const GCodeReader::GCodeLine& line);
|
void process_M401(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
// Repetier: Go to stored position
|
// Repetier: Go to stored position
|
||||||
void process_M402(const GCodeReader::GCodeLine& line);
|
void process_M402(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
// Set allowable instantaneous speed change
|
||||||
|
void process_M566(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
|
// Unload the current filament into the MK3 MMU2 unit at the end of print.
|
||||||
|
void process_M702(const GCodeReader::GCodeLine& line);
|
||||||
|
|
||||||
// Processes T line (Select Tool)
|
// Processes T line (Select Tool)
|
||||||
void process_T(const GCodeReader::GCodeLine& line);
|
void process_T(const GCodeReader::GCodeLine& line);
|
||||||
void process_T(const std::string& command);
|
void process_T(const std::string& command);
|
||||||
|
|
||||||
void store_move_vertex(EMoveType type);
|
void store_move_vertex(EMoveType type);
|
||||||
|
|
||||||
|
float minimum_feedrate(ETimeMode mode, float feedrate) const;
|
||||||
|
float minimum_travel_feedrate(ETimeMode mode, float feedrate) const;
|
||||||
|
float get_axis_max_feedrate(ETimeMode mode, Axis axis) const;
|
||||||
|
float get_axis_max_acceleration(ETimeMode mode, Axis axis) const;
|
||||||
|
float get_axis_max_jerk(ETimeMode mode, Axis axis) const;
|
||||||
|
float get_retract_acceleration(ETimeMode mode) const;
|
||||||
|
float get_acceleration(ETimeMode mode) const;
|
||||||
|
void set_acceleration(ETimeMode mode, float value);
|
||||||
|
float get_filament_load_time(size_t extruder_id);
|
||||||
|
float get_filament_unload_time(size_t extruder_id);
|
||||||
|
|
||||||
|
void process_custom_gcode_time(CustomGCode::Type code);
|
||||||
|
|
||||||
|
// Simulates firmware st_synchronize() call
|
||||||
|
void simulate_st_synchronize(float additional_time = 0.0f);
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace Slic3r */
|
} /* namespace Slic3r */
|
||||||
|
|
|
@ -678,21 +678,6 @@ namespace Slic3r {
|
||||||
return _get_time_minutes(get_time());
|
return _get_time_minutes(get_time());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> GCodeTimeEstimator::get_custom_gcode_times(bool include_remaining) const
|
|
||||||
{
|
|
||||||
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> ret;
|
|
||||||
|
|
||||||
float total_time = 0.0f;
|
|
||||||
for (const auto& [type, time] : m_custom_gcode_times) {
|
|
||||||
float remaining = include_remaining ? m_time - total_time : 0.0f;
|
|
||||||
ret.push_back({ type, { time, remaining } });
|
|
||||||
total_time += time;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
std::vector<std::pair<CustomGCode::Type, float>> GCodeTimeEstimator::get_custom_gcode_times() const
|
std::vector<std::pair<CustomGCode::Type, float>> GCodeTimeEstimator::get_custom_gcode_times() const
|
||||||
{
|
{
|
||||||
return m_custom_gcode_times;
|
return m_custom_gcode_times;
|
||||||
|
@ -736,7 +721,6 @@ namespace Slic3r {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
std::vector<std::pair<CustomGCode::Type, std::pair<std::string, std::string>>> GCodeTimeEstimator::get_custom_gcode_times_dhm(bool include_remaining) const
|
std::vector<std::pair<CustomGCode::Type, std::pair<std::string, std::string>>> GCodeTimeEstimator::get_custom_gcode_times_dhm(bool include_remaining) const
|
||||||
|
|
|
@ -358,9 +358,6 @@ namespace Slic3r {
|
||||||
std::string get_time_minutes() const;
|
std::string get_time_minutes() const;
|
||||||
|
|
||||||
// Returns the estimated time, in seconds, for each custom gcode
|
// Returns the estimated time, in seconds, for each custom gcode
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> get_custom_gcode_times(bool include_remaining) const;
|
|
||||||
#else
|
|
||||||
std::vector<std::pair<CustomGCode::Type, float>> get_custom_gcode_times() const;
|
std::vector<std::pair<CustomGCode::Type, float>> get_custom_gcode_times() const;
|
||||||
|
|
||||||
// Returns the estimated time, in format DDd HHh MMm SSs, for each color
|
// Returns the estimated time, in format DDd HHh MMm SSs, for each color
|
||||||
|
@ -370,7 +367,6 @@ namespace Slic3r {
|
||||||
// Returns the estimated time, in minutes (integer), for each color
|
// Returns the estimated time, in minutes (integer), for each color
|
||||||
// If include_remaining==true the strings will be formatted as: "time for color (remaining time at color start)"
|
// If include_remaining==true the strings will be formatted as: "time for color (remaining time at color start)"
|
||||||
std::vector<std::string> get_color_times_minutes(bool include_remaining) const;
|
std::vector<std::string> get_color_times_minutes(bool include_remaining) const;
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
|
|
||||||
// Returns the estimated time, in format DDd HHh MMm, for each custom_gcode
|
// Returns the estimated time, in format DDd HHh MMm, for each custom_gcode
|
||||||
// If include_remaining==true the strings will be formatted as: "time for custom_gcode (remaining time at color start)"
|
// If include_remaining==true the strings will be formatted as: "time for custom_gcode (remaining time at color start)"
|
||||||
|
|
|
@ -2190,18 +2190,24 @@ std::string Print::output_filename(const std::string &filename_base) const
|
||||||
DynamicConfig PrintStatistics::config() const
|
DynamicConfig PrintStatistics::config() const
|
||||||
{
|
{
|
||||||
DynamicConfig config;
|
DynamicConfig config;
|
||||||
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
config.set_key_value("print_time", new ConfigOptionString(this->estimated_normal_print_time_str));
|
||||||
|
config.set_key_value("normal_print_time", new ConfigOptionString(this->estimated_normal_print_time_str));
|
||||||
|
config.set_key_value("silent_print_time", new ConfigOptionString(this->estimated_silent_print_time_str));
|
||||||
|
#else
|
||||||
std::string normal_print_time = short_time(this->estimated_normal_print_time);
|
std::string normal_print_time = short_time(this->estimated_normal_print_time);
|
||||||
std::string silent_print_time = short_time(this->estimated_silent_print_time);
|
std::string silent_print_time = short_time(this->estimated_silent_print_time);
|
||||||
config.set_key_value("print_time", new ConfigOptionString(normal_print_time));
|
config.set_key_value("print_time", new ConfigOptionString(normal_print_time));
|
||||||
config.set_key_value("normal_print_time", new ConfigOptionString(normal_print_time));
|
config.set_key_value("normal_print_time", new ConfigOptionString(normal_print_time));
|
||||||
config.set_key_value("silent_print_time", new ConfigOptionString(silent_print_time));
|
config.set_key_value("silent_print_time", new ConfigOptionString(silent_print_time));
|
||||||
config.set_key_value("used_filament", new ConfigOptionFloat (this->total_used_filament / 1000.));
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
config.set_key_value("extruded_volume", new ConfigOptionFloat (this->total_extruded_volume));
|
config.set_key_value("used_filament", new ConfigOptionFloat(this->total_used_filament / 1000.));
|
||||||
config.set_key_value("total_cost", new ConfigOptionFloat (this->total_cost));
|
config.set_key_value("extruded_volume", new ConfigOptionFloat(this->total_extruded_volume));
|
||||||
|
config.set_key_value("total_cost", new ConfigOptionFloat(this->total_cost));
|
||||||
config.set_key_value("total_toolchanges", new ConfigOptionInt(this->total_toolchanges));
|
config.set_key_value("total_toolchanges", new ConfigOptionInt(this->total_toolchanges));
|
||||||
config.set_key_value("total_weight", new ConfigOptionFloat (this->total_weight));
|
config.set_key_value("total_weight", new ConfigOptionFloat(this->total_weight));
|
||||||
config.set_key_value("total_wipe_tower_cost", new ConfigOptionFloat (this->total_wipe_tower_cost));
|
config.set_key_value("total_wipe_tower_cost", new ConfigOptionFloat(this->total_wipe_tower_cost));
|
||||||
config.set_key_value("total_wipe_tower_filament", new ConfigOptionFloat (this->total_wipe_tower_filament));
|
config.set_key_value("total_wipe_tower_filament", new ConfigOptionFloat(this->total_wipe_tower_filament));
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -303,14 +303,18 @@ private:
|
||||||
struct PrintStatistics
|
struct PrintStatistics
|
||||||
{
|
{
|
||||||
PrintStatistics() { clear(); }
|
PrintStatistics() { clear(); }
|
||||||
|
#if ENABLE_GCODE_VIEWER
|
||||||
std::string estimated_normal_print_time;
|
std::string estimated_normal_print_time;
|
||||||
std::string estimated_silent_print_time;
|
std::string estimated_silent_print_time;
|
||||||
#if ENABLE_GCODE_VIEWER
|
std::string estimated_normal_print_time_str;
|
||||||
|
std::string estimated_silent_print_time_str;
|
||||||
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> estimated_normal_custom_gcode_print_times;
|
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> estimated_normal_custom_gcode_print_times;
|
||||||
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> estimated_silent_custom_gcode_print_times;
|
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> estimated_silent_custom_gcode_print_times;
|
||||||
std::vector<std::pair<CustomGCode::Type, std::pair<std::string, std::string>>> estimated_normal_custom_gcode_print_times_str;
|
std::vector<std::pair<CustomGCode::Type, std::pair<std::string, std::string>>> estimated_normal_custom_gcode_print_times_str;
|
||||||
std::vector<std::pair<CustomGCode::Type, std::pair<std::string, std::string>>> estimated_silent_custom_gcode_print_times_str;
|
std::vector<std::pair<CustomGCode::Type, std::pair<std::string, std::string>>> estimated_silent_custom_gcode_print_times_str;
|
||||||
#else
|
#else
|
||||||
|
std::string estimated_normal_print_time;
|
||||||
|
std::string estimated_silent_print_time;
|
||||||
std::vector<std::pair<CustomGCode::Type, std::string>> estimated_normal_custom_gcode_print_times;
|
std::vector<std::pair<CustomGCode::Type, std::string>> estimated_normal_custom_gcode_print_times;
|
||||||
std::vector<std::pair<CustomGCode::Type, std::string>> estimated_silent_custom_gcode_print_times;
|
std::vector<std::pair<CustomGCode::Type, std::string>> estimated_silent_custom_gcode_print_times;
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
|
@ -331,14 +335,12 @@ struct PrintStatistics
|
||||||
std::string finalize_output_path(const std::string &path_in) const;
|
std::string finalize_output_path(const std::string &path_in) const;
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
estimated_normal_print_time.clear();
|
|
||||||
estimated_silent_print_time.clear();
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
estimated_normal_custom_gcode_print_times_str.clear();
|
estimated_normal_custom_gcode_print_times_str.clear();
|
||||||
estimated_silent_custom_gcode_print_times_str.clear();
|
estimated_silent_custom_gcode_print_times_str.clear();
|
||||||
estimated_normal_custom_gcode_print_times.clear();
|
|
||||||
estimated_silent_custom_gcode_print_times.clear();
|
|
||||||
#else
|
#else
|
||||||
|
estimated_normal_print_time.clear();
|
||||||
|
estimated_silent_print_time.clear();
|
||||||
estimated_normal_custom_gcode_print_times.clear();
|
estimated_normal_custom_gcode_print_times.clear();
|
||||||
estimated_silent_custom_gcode_print_times.clear();
|
estimated_silent_custom_gcode_print_times.clear();
|
||||||
#endif //ENABLE_GCODE_VIEWER
|
#endif //ENABLE_GCODE_VIEWER
|
||||||
|
|
|
@ -1720,6 +1720,9 @@ void GCodeViewer::render_time_estimate() const
|
||||||
if (ps.estimated_normal_print_time == "N/A" && ps.estimated_silent_print_time == "N/A")
|
if (ps.estimated_normal_print_time == "N/A" && ps.estimated_silent_print_time == "N/A")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (ps.estimated_normal_print_time.empty() && ps.estimated_silent_print_time.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||||
|
|
||||||
using Time = std::pair<float, float>;
|
using Time = std::pair<float, float>;
|
||||||
|
|
|
@ -1322,7 +1322,11 @@ void Sidebar::update_sliced_info_sizer()
|
||||||
wxString::Format("%.2f", ps.total_cost);
|
wxString::Format("%.2f", ps.total_cost);
|
||||||
p->sliced_info->SetTextAndShow(siCost, info_text, new_label);
|
p->sliced_info->SetTextAndShow(siCost, info_text, new_label);
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
if (ps.estimated_normal_print_time_str == "N/A" && ps.estimated_silent_print_time_str == "N/A")
|
||||||
|
#else
|
||||||
if (ps.estimated_normal_print_time == "N/A" && ps.estimated_silent_print_time == "N/A")
|
if (ps.estimated_normal_print_time == "N/A" && ps.estimated_silent_print_time == "N/A")
|
||||||
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
p->sliced_info->SetTextAndShow(siEstimatedTime, "N/A");
|
p->sliced_info->SetTextAndShow(siEstimatedTime, "N/A");
|
||||||
else {
|
else {
|
||||||
new_label = _L("Estimated printing time") +":";
|
new_label = _L("Estimated printing time") +":";
|
||||||
|
@ -1360,21 +1364,25 @@ void Sidebar::update_sliced_info_sizer()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
if (ps.estimated_normal_print_time_str != "N/A") {
|
||||||
|
new_label += format_wxstr("\n - %1%", _L("normal mode"));
|
||||||
|
info_text += format_wxstr("\n%1%", ps.estimated_normal_print_time_str);
|
||||||
|
fill_labels(ps.estimated_normal_custom_gcode_print_times_str, new_label, info_text);
|
||||||
|
}
|
||||||
|
if (ps.estimated_silent_print_time_str != "N/A") {
|
||||||
|
new_label += format_wxstr("\n - %1%", _L("stealth mode"));
|
||||||
|
info_text += format_wxstr("\n%1%", ps.estimated_silent_print_time_str);
|
||||||
|
fill_labels(ps.estimated_silent_custom_gcode_print_times_str, new_label, info_text);
|
||||||
|
#else
|
||||||
if (ps.estimated_normal_print_time != "N/A") {
|
if (ps.estimated_normal_print_time != "N/A") {
|
||||||
new_label += format_wxstr("\n - %1%", _L("normal mode"));
|
new_label += format_wxstr("\n - %1%", _L("normal mode"));
|
||||||
info_text += format_wxstr("\n%1%", ps.estimated_normal_print_time);
|
info_text += format_wxstr("\n%1%", ps.estimated_normal_print_time);
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
fill_labels(ps.estimated_normal_custom_gcode_print_times_str, new_label, info_text);
|
|
||||||
#else
|
|
||||||
fill_labels(ps.estimated_normal_custom_gcode_print_times, new_label, info_text);
|
fill_labels(ps.estimated_normal_custom_gcode_print_times, new_label, info_text);
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
|
||||||
}
|
}
|
||||||
if (ps.estimated_silent_print_time != "N/A") {
|
if (ps.estimated_silent_print_time != "N/A") {
|
||||||
new_label += format_wxstr("\n - %1%", _L("stealth mode"));
|
new_label += format_wxstr("\n - %1%", _L("stealth mode"));
|
||||||
info_text += format_wxstr("\n%1%", ps.estimated_silent_print_time);
|
info_text += format_wxstr("\n%1%", ps.estimated_silent_print_time);
|
||||||
#if ENABLE_GCODE_VIEWER
|
|
||||||
fill_labels(ps.estimated_silent_custom_gcode_print_times_str, new_label, info_text);
|
|
||||||
#else
|
|
||||||
fill_labels(ps.estimated_silent_custom_gcode_print_times, new_label, info_text);
|
fill_labels(ps.estimated_silent_custom_gcode_print_times, new_label, info_text);
|
||||||
#endif // ENABLE_GCODE_VIEWER
|
#endif // ENABLE_GCODE_VIEWER
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue