GCodeTimeEstimator - clean up unused code

This commit is contained in:
Enrico Turri 2017-12-19 09:29:04 +01:00
parent 0fe855cd6d
commit b2eb522f55
2 changed files with 22 additions and 77 deletions

View File

@ -15,10 +15,6 @@ static const float DEFAULT_AXIS_MAX_JERK[] = { 10.0f, 10.0f, 0.2f, 2.5f }; // fr
static const float DEFAULT_MINIMUM_FEEDRATE = 0.0f; // from Prusa Firmware (Configuration_adv.h)
static const float DEFAULT_MINIMUM_TRAVEL_FEEDRATE = 0.0f; // from Prusa Firmware (Configuration_adv.h)
#if USE_CURA_JUNCTION_VMAX
static const float MINIMUM_PLANNER_SPEED = 0.05f; // from Cura <<<<<<<< WHAT IS THIS ???
#endif // USE_CURA_JUNCTION_VMAX
static const float PREVIOUS_FEEDRATE_THRESHOLD = 0.0001f;
namespace Slic3r {
@ -389,11 +385,9 @@ namespace Slic3r {
void GCodeTimeEstimator::_calculate_time()
{
#if ENABLE_BLOCKS_PRE_PROCESSING
forward_pass();
reverse_pass();
recalculate_trapezoids();
#endif // ENABLE_BLOCKS_PRE_PROCESSING
_forward_pass();
_reverse_pass();
_recalculate_trapezoids();
_time = get_additional_time();
@ -601,32 +595,6 @@ namespace Slic3r {
block.feedrate.exit = _curr.safe_feedrate;
// calculates block entry feedrate
#if USE_CURA_JUNCTION_VMAX
float vmax_junction = _curr.safe_feedrate;
if (!_blocks.empty() && (_prev.feedrate > PREVIOUS_FEEDRATE_THRESHOLD))
{
vmax_junction = block.feedrate.cruise;
float vmax_junction_factor = 1.0f;
for (unsigned char a = X; a < Num_Axis; ++a)
{
float abs_delta_axis_feedrate = ::abs(_curr.axis_feedrate[a] - _prev.axis_feedrate[a]);
float axis_max_jerk = get_axis_max_jerk((EAxis)a);
if (abs_delta_axis_feedrate > axis_max_jerk)
vmax_junction_factor = std::min(vmax_junction_factor, axis_max_jerk / abs_delta_axis_feedrate);
}
// limit vmax to not exceed previous feedrate
vmax_junction = std::min(_prev.feedrate, vmax_junction * vmax_junction_factor);
}
#if ENABLE_BLOCKS_PRE_PROCESSING
float v_allowable = Block::max_allowable_speed(-acceleration, MINIMUM_PLANNER_SPEED, distance);
block.feedrate.entry = std::min(vmax_junction, v_allowable);
#else
block.feedrate.entry = std::min(vmax_junction, Block::max_allowable_speed(-acceleration, MINIMUM_PLANNER_SPEED, distance));
#endif // ENABLE_BLOCKS_PRE_PROCESSING
#else
float vmax_junction = _curr.safe_feedrate;
if (!_blocks.empty() && (_prev.feedrate > PREVIOUS_FEEDRATE_THRESHOLD))
{
@ -688,20 +656,13 @@ namespace Slic3r {
vmax_junction = _curr.safe_feedrate;
}
#if ENABLE_BLOCKS_PRE_PROCESSING
float v_allowable = Block::max_allowable_speed(-acceleration, _curr.safe_feedrate, distance);
block.feedrate.entry = std::min(vmax_junction, v_allowable);
#else
block.feedrate.entry = std::min(vmax_junction, Block::max_allowable_speed(-acceleration, _curr.safe_feedrate, distance));
#endif // ENABLE_BLOCKS_PRE_PROCESSING
#endif // USE_CURA_JUNCTION_VMAX
#if ENABLE_BLOCKS_PRE_PROCESSING
block.max_entry_speed = vmax_junction;
block.flags.nominal_length = (block.feedrate.cruise <= v_allowable);
block.flags.recalculate = true;
block.safe_feedrate = _curr.safe_feedrate;
#endif // ENABLE_BLOCKS_PRE_PROCESSING
// calculates block trapezoid
block.calculate_trapezoid();
@ -749,7 +710,7 @@ namespace Slic3r {
void GCodeTimeEstimator::_processG28(const GCodeReader::GCodeLine& line)
{
// todo
// TODO
}
void GCodeTimeEstimator::_processG90(const GCodeReader::GCodeLine& line)
@ -759,7 +720,7 @@ namespace Slic3r {
void GCodeTimeEstimator::_processG91(const GCodeReader::GCodeLine& line)
{
// >>>>>>>> THERE ARE DIALECT VARIANTS
// TODO: THERE ARE DIALECT VARIANTS
set_positioning_xyz_type(Relative);
}
@ -814,7 +775,7 @@ namespace Slic3r {
void GCodeTimeEstimator::_processM109(const GCodeReader::GCodeLine& line)
{
// todo
// TODO
}
void GCodeTimeEstimator::_processM201(const GCodeReader::GCodeLine& line)
@ -910,8 +871,7 @@ namespace Slic3r {
set_axis_max_jerk(E, line.get_float('E') * MMMIN_TO_MMSEC);
}
#if ENABLE_BLOCKS_PRE_PROCESSING
void GCodeTimeEstimator::forward_pass()
void GCodeTimeEstimator::_forward_pass()
{
Block* block[2] = { nullptr, nullptr };
@ -919,13 +879,13 @@ namespace Slic3r {
{
block[0] = block[1];
block[1] = &b;
planner_forward_pass_kernel(block[0], block[1]);
_planner_forward_pass_kernel(block[0], block[1]);
}
planner_forward_pass_kernel(block[1], nullptr);
_planner_forward_pass_kernel(block[1], nullptr);
}
void GCodeTimeEstimator::reverse_pass()
void GCodeTimeEstimator::_reverse_pass()
{
Block* block[2] = { nullptr, nullptr };
@ -933,11 +893,11 @@ namespace Slic3r {
{
block[1] = block[0];
block[0] = &_blocks[i];
planner_reverse_pass_kernel(block[0], block[1]);
_planner_reverse_pass_kernel(block[0], block[1]);
}
}
void GCodeTimeEstimator::planner_forward_pass_kernel(Block* prev, Block* curr)
void GCodeTimeEstimator::_planner_forward_pass_kernel(Block* prev, Block* curr)
{
if (prev == nullptr)
return;
@ -962,7 +922,7 @@ namespace Slic3r {
}
}
void GCodeTimeEstimator::planner_reverse_pass_kernel(Block* curr, Block* next)
void GCodeTimeEstimator::_planner_reverse_pass_kernel(Block* curr, Block* next)
{
if ((curr == nullptr) || (next == nullptr))
return;
@ -983,7 +943,7 @@ namespace Slic3r {
}
}
void GCodeTimeEstimator::recalculate_trapezoids()
void GCodeTimeEstimator::_recalculate_trapezoids()
{
Block* curr = nullptr;
Block* next = nullptr;
@ -1008,20 +968,14 @@ namespace Slic3r {
}
}
// Last/newest block in buffer. Exit speed is set with MINIMUM_PLANNER_SPEED. Always recalculated.
// Last/newest block in buffer. Always recalculated.
if (next != nullptr)
{
Block block = *next;
#if USE_CURA_JUNCTION_VMAX
block.feedrate.exit = MINIMUM_PLANNER_SPEED;
#else
block.feedrate.exit = next->safe_feedrate;
#endif // USE_CURA_JUNCTION_VMAX
block.calculate_trapezoid();
next->trapezoid = block.trapezoid;
next->flags.recalculate = false;
}
}
#endif // ENABLE_BLOCKS_PRE_PROCESSING
}

View File

@ -4,9 +4,6 @@
#include "libslic3r.h"
#include "GCodeReader.hpp"
#define USE_CURA_JUNCTION_VMAX 0
#define ENABLE_BLOCKS_PRE_PROCESSING 1
namespace Slic3r {
class GCodeTimeEstimator
@ -38,7 +35,7 @@ namespace Slic3r {
Num_Dialects
};
enum EPositioningType
enum EPositioningType : unsigned char
{
Absolute,
Relative
@ -107,7 +104,6 @@ namespace Slic3r {
static float speed_from_distance(float initial_feedrate, float distance, float acceleration);
};
#if ENABLE_BLOCKS_PRE_PROCESSING
struct Flags
{
bool recalculate;
@ -115,14 +111,11 @@ namespace Slic3r {
};
Flags flags;
#endif // ENABLE_BLOCKS_PRE_PROCESSING
float delta_pos[Num_Axis]; // mm
float acceleration; // mm/s^2
#if ENABLE_BLOCKS_PRE_PROCESSING
float max_entry_speed; // mm/s
float safe_feedrate; // mm/s
#endif // ENABLE_BLOCKS_PRE_PROCESSING
FeedrateProfile feedrate;
Trapezoid trapezoid;
@ -246,7 +239,7 @@ namespace Slic3r {
// Returns the estimated time, in seconds
float get_time() const;
// Returns the estimated time, in format HH:MM:SS
// Returns the estimated time, in format HHh MMm SSs
std::string get_time_hms() const;
private:
@ -306,15 +299,13 @@ namespace Slic3r {
// Set allowable instantaneous speed change
void _processM566(const GCodeReader::GCodeLine& line);
#if ENABLE_BLOCKS_PRE_PROCESSING
void forward_pass();
void reverse_pass();
void _forward_pass();
void _reverse_pass();
void planner_forward_pass_kernel(Block* prev, Block* curr);
void planner_reverse_pass_kernel(Block* curr, Block* next);
void _planner_forward_pass_kernel(Block* prev, Block* curr);
void _planner_reverse_pass_kernel(Block* curr, Block* next);
void recalculate_trapezoids();
#endif // ENABLE_BLOCKS_PRE_PROCESSING
void _recalculate_trapezoids();
};
} /* namespace Slic3r */