2017-04-26 12:24:31 +00:00
|
|
|
#ifndef slic3r_GCodeTimeEstimator_hpp_
|
|
|
|
#define slic3r_GCodeTimeEstimator_hpp_
|
|
|
|
|
|
|
|
#include "libslic3r.h"
|
2018-01-06 17:49:28 +00:00
|
|
|
#include "PrintConfig.hpp"
|
2017-04-26 12:24:31 +00:00
|
|
|
#include "GCodeReader.hpp"
|
2020-02-20 16:32:46 +00:00
|
|
|
#include "CustomGCode.hpp"
|
2017-04-26 12:24:31 +00:00
|
|
|
|
2018-01-30 12:18:21 +00:00
|
|
|
#define ENABLE_MOVE_STATS 0
|
|
|
|
|
2017-04-26 12:24:31 +00:00
|
|
|
namespace Slic3r {
|
|
|
|
|
2018-01-08 11:27:18 +00:00
|
|
|
//
|
|
|
|
// Some of the algorithms used by class GCodeTimeEstimator were inpired by
|
|
|
|
// Cura Engine's class TimeEstimateCalculator
|
|
|
|
// https://github.com/Ultimaker/CuraEngine/blob/master/src/timeEstimate.h
|
|
|
|
//
|
2018-01-05 08:46:09 +00:00
|
|
|
class GCodeTimeEstimator
|
2017-12-06 13:12:10 +00:00
|
|
|
{
|
2018-01-05 08:46:09 +00:00
|
|
|
public:
|
2018-09-07 14:05:10 +00:00
|
|
|
static const std::string Normal_First_M73_Output_Placeholder_Tag;
|
|
|
|
static const std::string Silent_First_M73_Output_Placeholder_Tag;
|
2019-04-08 09:54:58 +00:00
|
|
|
static const std::string Normal_Last_M73_Output_Placeholder_Tag;
|
|
|
|
static const std::string Silent_Last_M73_Output_Placeholder_Tag;
|
2018-09-07 14:05:10 +00:00
|
|
|
|
2019-08-21 12:43:14 +00:00
|
|
|
static const std::string Color_Change_Tag;
|
2020-02-20 16:32:46 +00:00
|
|
|
static const std::string Pause_Print_Tag;
|
2019-08-21 12:43:14 +00:00
|
|
|
|
2018-05-30 10:08:03 +00:00
|
|
|
enum EMode : unsigned char
|
|
|
|
{
|
2018-06-27 13:35:47 +00:00
|
|
|
Normal,
|
2018-05-30 10:08:03 +00:00
|
|
|
Silent
|
|
|
|
};
|
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
enum EUnits : unsigned char
|
|
|
|
{
|
|
|
|
Millimeters,
|
|
|
|
Inches
|
|
|
|
};
|
|
|
|
|
|
|
|
enum EAxis : unsigned char
|
|
|
|
{
|
|
|
|
X,
|
|
|
|
Y,
|
|
|
|
Z,
|
|
|
|
E,
|
|
|
|
Num_Axis
|
|
|
|
};
|
|
|
|
|
|
|
|
enum EPositioningType : unsigned char
|
|
|
|
{
|
|
|
|
Absolute,
|
|
|
|
Relative
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Axis
|
|
|
|
{
|
|
|
|
float position; // mm
|
2019-10-01 07:48:42 +00:00
|
|
|
float origin; // mm
|
2018-01-05 08:46:09 +00:00
|
|
|
float max_feedrate; // mm/s
|
|
|
|
float max_acceleration; // mm/s^2
|
|
|
|
float max_jerk; // mm/s
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Feedrates
|
|
|
|
{
|
|
|
|
float feedrate; // mm/s
|
|
|
|
float axis_feedrate[Num_Axis]; // mm/s
|
|
|
|
float abs_axis_feedrate[Num_Axis]; // mm/s
|
|
|
|
float safe_feedrate; // mm/s
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct State
|
|
|
|
{
|
2018-01-06 17:49:28 +00:00
|
|
|
GCodeFlavor dialect;
|
2018-01-05 08:46:09 +00:00
|
|
|
EUnits units;
|
2018-03-29 12:46:11 +00:00
|
|
|
EPositioningType global_positioning_type;
|
|
|
|
EPositioningType e_local_positioning_type;
|
2018-01-05 08:46:09 +00:00
|
|
|
Axis axis[Num_Axis];
|
|
|
|
float feedrate; // mm/s
|
|
|
|
float acceleration; // mm/s^2
|
2018-07-18 09:58:02 +00:00
|
|
|
// hard limit for the acceleration, to which the firmware will clamp.
|
|
|
|
float max_acceleration; // mm/s^2
|
2018-01-05 08:46:09 +00:00
|
|
|
float retract_acceleration; // mm/s^2
|
|
|
|
float minimum_feedrate; // mm/s
|
|
|
|
float minimum_travel_feedrate; // mm/s
|
2018-07-13 09:32:50 +00:00
|
|
|
float extrude_factor_override_percentage;
|
2018-08-04 15:38:25 +00:00
|
|
|
// Additional load / unload times for a filament exchange sequence.
|
|
|
|
std::vector<float> filament_load_times;
|
|
|
|
std::vector<float> filament_unload_times;
|
2018-06-27 13:35:47 +00:00
|
|
|
unsigned int g1_line_id;
|
2018-08-04 15:38:25 +00:00
|
|
|
// 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 id (-1) means no filament is loaded yet, all the filaments are parked in the MK3 MMU2 unit.
|
|
|
|
static const unsigned int extruder_id_unloaded = (unsigned int)-1;
|
2018-07-30 10:08:26 +00:00
|
|
|
unsigned int extruder_id;
|
2018-01-05 08:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
struct Block
|
|
|
|
{
|
2018-01-30 12:18:21 +00:00
|
|
|
#if ENABLE_MOVE_STATS
|
|
|
|
enum EMoveType : unsigned char
|
|
|
|
{
|
|
|
|
Noop,
|
|
|
|
Retract,
|
|
|
|
Unretract,
|
|
|
|
Tool_change,
|
|
|
|
Move,
|
|
|
|
Extrude,
|
|
|
|
Num_Types
|
|
|
|
};
|
|
|
|
#endif // ENABLE_MOVE_STATS
|
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
struct FeedrateProfile
|
|
|
|
{
|
|
|
|
float entry; // mm/s
|
|
|
|
float cruise; // mm/s
|
|
|
|
float exit; // mm/s
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Trapezoid
|
|
|
|
{
|
|
|
|
float accelerate_until; // mm
|
|
|
|
float decelerate_after; // mm
|
2020-03-05 11:16:58 +00:00
|
|
|
float cruise_feedrate; // mm/sec
|
2018-01-05 08:46:09 +00:00
|
|
|
|
2020-03-05 11:16:58 +00:00
|
|
|
float acceleration_time(float entry_feedrate, float acceleration) const;
|
2018-01-05 08:46:09 +00:00
|
|
|
float cruise_time() const;
|
2020-03-05 11:16:58 +00:00
|
|
|
float deceleration_time(float distance, float acceleration) const;
|
2018-01-05 08:46:09 +00:00
|
|
|
float cruise_distance() const;
|
|
|
|
|
|
|
|
// This function gives the time needed to accelerate from an initial speed to reach a final distance.
|
|
|
|
static float acceleration_time_from_distance(float initial_feedrate, float distance, float acceleration);
|
|
|
|
|
|
|
|
// This function gives the final speed while accelerating at the given constant acceleration from the given initial speed along the given distance.
|
|
|
|
static float speed_from_distance(float initial_feedrate, float distance, float acceleration);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Flags
|
|
|
|
{
|
|
|
|
bool recalculate;
|
|
|
|
bool nominal_length;
|
|
|
|
};
|
|
|
|
|
2018-01-30 12:18:21 +00:00
|
|
|
#if ENABLE_MOVE_STATS
|
|
|
|
EMoveType move_type;
|
|
|
|
#endif // ENABLE_MOVE_STATS
|
2018-01-05 08:46:09 +00:00
|
|
|
Flags flags;
|
|
|
|
|
2020-03-05 13:58:03 +00:00
|
|
|
float distance; // mm
|
2018-01-05 08:46:09 +00:00
|
|
|
float acceleration; // mm/s^2
|
|
|
|
float max_entry_speed; // mm/s
|
|
|
|
float safe_feedrate; // mm/s
|
|
|
|
|
|
|
|
FeedrateProfile feedrate;
|
|
|
|
Trapezoid trapezoid;
|
2020-04-01 11:42:26 +00:00
|
|
|
|
|
|
|
// Ordnary index of this G1 line in the file.
|
|
|
|
int g1_line_id { -1 };
|
2018-01-05 08:46:09 +00:00
|
|
|
|
|
|
|
// Returns the time spent accelerating toward cruise speed, in seconds
|
|
|
|
float acceleration_time() const;
|
|
|
|
|
|
|
|
// Returns the time spent at cruise speed, in seconds
|
|
|
|
float cruise_time() const;
|
|
|
|
|
|
|
|
// Returns the time spent decelerating from cruise speed, in seconds
|
|
|
|
float deceleration_time() const;
|
|
|
|
|
|
|
|
// Returns the distance covered at cruise speed, in mm
|
|
|
|
float cruise_distance() const;
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Calculates this block's trapezoid
|
|
|
|
void calculate_trapezoid();
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// 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);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the given acceleration:
|
|
|
|
static float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// This function gives you the point at which you must start braking (at the rate of -acceleration) if
|
|
|
|
// you started at speed initial_rate and accelerated until this point and want to end at the final_rate after
|
|
|
|
// a total travel of distance. This can be used to compute the intersection point between acceleration and
|
|
|
|
// deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed)
|
|
|
|
static float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance);
|
|
|
|
};
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
typedef std::vector<Block> BlocksList;
|
2017-12-08 09:50:36 +00:00
|
|
|
|
2018-01-30 12:18:21 +00:00
|
|
|
#if ENABLE_MOVE_STATS
|
|
|
|
struct MoveStats
|
|
|
|
{
|
|
|
|
unsigned int count;
|
|
|
|
float time;
|
|
|
|
|
|
|
|
MoveStats();
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::map<Block::EMoveType, MoveStats> MovesStatsMap;
|
|
|
|
#endif // ENABLE_MOVE_STATS
|
|
|
|
|
2019-09-05 07:54:44 +00:00
|
|
|
public:
|
2020-04-01 11:42:26 +00:00
|
|
|
typedef std::pair<int, float> G1LineIdTime;
|
|
|
|
typedef std::vector<G1LineIdTime> G1LineIdsTimes;
|
2018-06-28 11:57:28 +00:00
|
|
|
|
2019-09-05 07:54:44 +00:00
|
|
|
struct PostProcessData
|
|
|
|
{
|
2020-04-01 11:42:26 +00:00
|
|
|
const G1LineIdsTimes& g1_times;
|
2019-09-05 07:54:44 +00:00
|
|
|
float time;
|
|
|
|
};
|
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
private:
|
2019-07-08 06:40:20 +00:00
|
|
|
EMode m_mode;
|
|
|
|
GCodeReader m_parser;
|
|
|
|
State m_state;
|
|
|
|
Feedrates m_curr;
|
|
|
|
Feedrates m_prev;
|
|
|
|
BlocksList m_blocks;
|
2020-04-01 11:42:26 +00:00
|
|
|
// 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 planner_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 planner_refresh_if_larger = planner_queue_size * 4;
|
|
|
|
// Map from g1 line id to its elapsed time from the start of the print.
|
|
|
|
G1LineIdsTimes m_g1_times;
|
2019-07-08 06:40:20 +00:00
|
|
|
float m_time; // s
|
|
|
|
|
2020-02-20 16:32:46 +00:00
|
|
|
// data to calculate custom code times
|
|
|
|
bool m_needs_custom_gcode_times;
|
|
|
|
std::vector<std::pair<CustomGcodeType, float>> m_custom_gcode_times;
|
|
|
|
float m_custom_gcode_time_cache;
|
2018-05-30 10:08:03 +00:00
|
|
|
|
2018-01-30 12:18:21 +00:00
|
|
|
#if ENABLE_MOVE_STATS
|
|
|
|
MovesStatsMap _moves_stats;
|
|
|
|
#endif // ENABLE_MOVE_STATS
|
2017-12-08 09:50:36 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
public:
|
2018-05-30 10:08:03 +00:00
|
|
|
explicit GCodeTimeEstimator(EMode mode);
|
|
|
|
|
|
|
|
// Adds the given gcode line
|
|
|
|
void add_gcode_line(const std::string& gcode_line);
|
|
|
|
|
|
|
|
void add_gcode_block(const char *ptr);
|
|
|
|
void add_gcode_block(const std::string &str) { this->add_gcode_block(str.c_str()); }
|
|
|
|
|
|
|
|
// Calculates the time estimate from the gcode lines added using add_gcode_line() or add_gcode_block()
|
2018-07-20 10:05:08 +00:00
|
|
|
// start_from_beginning:
|
|
|
|
// if set to true all blocks will be used to calculate the time estimate,
|
|
|
|
// if set to false only the blocks not yet processed will be used and the calculated time will be added to the current calculated time
|
|
|
|
void calculate_time(bool start_from_beginning);
|
2017-12-08 09:50:36 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Calculates the time estimate from the given gcode in string format
|
2020-04-01 11:42:26 +00:00
|
|
|
//void calculate_time_from_text(const std::string& gcode);
|
2017-12-08 09:50:36 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Calculates the time estimate from the gcode contained in the file with the given filename
|
2020-04-01 11:42:26 +00:00
|
|
|
//void calculate_time_from_file(const std::string& file);
|
2017-12-08 09:50:36 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Calculates the time estimate from the gcode contained in given list of gcode lines
|
2020-04-01 11:42:26 +00:00
|
|
|
//void calculate_time_from_lines(const std::vector<std::string>& gcode_lines);
|
2017-12-08 09:50:36 +00:00
|
|
|
|
2018-06-27 13:35:47 +00:00
|
|
|
// Process the gcode contained in the file with the given filename,
|
2019-09-05 07:54:44 +00:00
|
|
|
// replacing placeholders with correspondent new lines M73
|
|
|
|
// placing new lines M73 (containing the remaining time) where needed (in dependence of the given interval in seconds)
|
|
|
|
// and removing working tags (as those used for color changes)
|
|
|
|
// if normal_mode == nullptr no M73 line will be added for normal mode
|
|
|
|
// if silent_mode == nullptr no M73 line will be added for silent mode
|
|
|
|
static bool post_process(const std::string& filename, float interval_sec, const PostProcessData* const normal_mode, const PostProcessData* const silent_mode);
|
2017-12-08 09:50:36 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Set current position on the given axis with the given value
|
|
|
|
void set_axis_position(EAxis axis, float position);
|
2019-10-01 07:48:42 +00:00
|
|
|
// Set current origin on the given axis with the given value
|
|
|
|
void set_axis_origin(EAxis axis, float position);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
void set_axis_max_feedrate(EAxis axis, float feedrate_mm_sec);
|
|
|
|
void set_axis_max_acceleration(EAxis axis, float acceleration);
|
|
|
|
void set_axis_max_jerk(EAxis axis, float jerk);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Returns current position on the given axis
|
|
|
|
float get_axis_position(EAxis axis) const;
|
2019-10-01 07:48:42 +00:00
|
|
|
// Returns current origin on the given axis
|
|
|
|
float get_axis_origin(EAxis axis) const;
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
float get_axis_max_feedrate(EAxis axis) const;
|
|
|
|
float get_axis_max_acceleration(EAxis axis) const;
|
|
|
|
float get_axis_max_jerk(EAxis axis) const;
|
2017-12-12 12:44:52 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
void set_feedrate(float feedrate_mm_sec);
|
|
|
|
float get_feedrate() const;
|
2017-12-12 12:44:52 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
void set_acceleration(float acceleration_mm_sec2);
|
|
|
|
float get_acceleration() const;
|
2017-12-08 09:50:36 +00:00
|
|
|
|
2018-07-18 09:58:02 +00:00
|
|
|
// Maximum acceleration for the machine. The firmware simulator will clamp the M204 Sxxx to this maximum.
|
|
|
|
void set_max_acceleration(float acceleration_mm_sec2);
|
|
|
|
float get_max_acceleration() const;
|
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
void set_retract_acceleration(float acceleration_mm_sec2);
|
|
|
|
float get_retract_acceleration() const;
|
2017-12-08 09:50:36 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
void set_minimum_feedrate(float feedrate_mm_sec);
|
|
|
|
float get_minimum_feedrate() const;
|
2017-12-08 09:50:36 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
void set_minimum_travel_feedrate(float feedrate_mm_sec);
|
|
|
|
float get_minimum_travel_feedrate() const;
|
2017-12-08 09:50:36 +00:00
|
|
|
|
2018-08-04 15:38:25 +00:00
|
|
|
void set_filament_load_times(const std::vector<double> &filament_load_times);
|
|
|
|
void set_filament_unload_times(const std::vector<double> &filament_unload_times);
|
|
|
|
float get_filament_load_time(unsigned int id_extruder);
|
|
|
|
float get_filament_unload_time(unsigned int id_extruder);
|
|
|
|
|
2018-01-05 09:35:04 +00:00
|
|
|
void set_extrude_factor_override_percentage(float percentage);
|
|
|
|
float get_extrude_factor_override_percentage() const;
|
|
|
|
|
2018-01-06 17:49:28 +00:00
|
|
|
void set_dialect(GCodeFlavor dialect);
|
|
|
|
GCodeFlavor get_dialect() const;
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
void set_units(EUnits units);
|
|
|
|
EUnits get_units() const;
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-03-29 12:46:11 +00:00
|
|
|
void set_global_positioning_type(EPositioningType type);
|
|
|
|
EPositioningType get_global_positioning_type() const;
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-03-29 12:46:11 +00:00
|
|
|
void set_e_local_positioning_type(EPositioningType type);
|
|
|
|
EPositioningType get_e_local_positioning_type() const;
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-06-27 13:35:47 +00:00
|
|
|
int get_g1_line_id() const;
|
|
|
|
void increment_g1_line_id();
|
|
|
|
void reset_g1_line_id();
|
|
|
|
|
2019-12-09 10:40:26 +00:00
|
|
|
void set_extrusion_axis(char axis) { m_parser.set_extrusion_axis(axis); }
|
|
|
|
|
2018-07-30 10:08:26 +00:00
|
|
|
void set_extruder_id(unsigned int id);
|
|
|
|
unsigned int get_extruder_id() const;
|
|
|
|
void reset_extruder_id();
|
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
void set_default();
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Call this method before to start adding lines using add_gcode_line() when reusing an instance of GCodeTimeEstimator
|
|
|
|
void reset();
|
2017-12-14 08:18:28 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Returns the estimated time, in seconds
|
|
|
|
float get_time() const;
|
2017-12-11 08:06:29 +00:00
|
|
|
|
2018-05-30 10:08:03 +00:00
|
|
|
// Returns the estimated time, in format DDd HHh MMm SSs
|
|
|
|
std::string get_time_dhms() const;
|
2018-01-03 16:29:49 +00:00
|
|
|
|
2020-02-10 10:56:49 +00:00
|
|
|
// Returns the estimated time, in format DDd HHh MMm
|
|
|
|
std::string get_time_dhm() const;
|
|
|
|
|
2018-06-06 09:00:36 +00:00
|
|
|
// Returns the estimated time, in minutes (integer)
|
|
|
|
std::string get_time_minutes() const;
|
|
|
|
|
2020-02-20 16:32:46 +00:00
|
|
|
// Returns the estimated time, in seconds, for each custom gcode
|
|
|
|
std::vector<std::pair<CustomGcodeType, float>> get_custom_gcode_times() const;
|
2019-07-08 06:40:20 +00:00
|
|
|
|
|
|
|
// Returns the estimated time, in format DDd HHh MMm SSs, for each color
|
2019-08-03 06:51:03 +00:00
|
|
|
// 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_dhms(bool include_remaining) const;
|
2019-07-08 06:40:20 +00:00
|
|
|
|
|
|
|
// Returns the estimated time, in minutes (integer), for each color
|
2019-08-03 06:51:03 +00:00
|
|
|
// 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;
|
2019-07-08 06:40:20 +00:00
|
|
|
|
2020-02-20 16:32:46 +00:00
|
|
|
// 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)"
|
|
|
|
std::vector<std::pair<CustomGcodeType, std::string>> get_custom_gcode_times_dhm(bool include_remaining) const;
|
|
|
|
|
2018-12-18 13:10:31 +00:00
|
|
|
// Return an estimate of the memory consumed by the time estimator.
|
|
|
|
size_t memory_used() const;
|
|
|
|
|
2020-04-01 11:42:26 +00:00
|
|
|
PostProcessData get_post_process_data() const { return PostProcessData{ m_g1_times, m_time }; }
|
2019-09-05 07:54:44 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
private:
|
|
|
|
void _reset();
|
2018-05-30 10:08:03 +00:00
|
|
|
void _reset_time();
|
2018-01-08 12:23:54 +00:00
|
|
|
void _reset_blocks();
|
2017-12-11 08:06:29 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Calculates the time estimate
|
2020-04-01 11:42:26 +00:00
|
|
|
void _calculate_time(size_t keep_last_n_blocks);
|
2017-12-11 13:03:29 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Processes the given gcode line
|
|
|
|
void _process_gcode_line(GCodeReader&, const GCodeReader::GCodeLine& line);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Move
|
|
|
|
void _processG1(const GCodeReader::GCodeLine& line);
|
2017-12-11 13:03:29 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Dwell
|
|
|
|
void _processG4(const GCodeReader::GCodeLine& line);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Set Units to Inches
|
|
|
|
void _processG20(const GCodeReader::GCodeLine& line);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Set Units to Millimeters
|
|
|
|
void _processG21(const GCodeReader::GCodeLine& line);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Move to Origin (Home)
|
|
|
|
void _processG28(const GCodeReader::GCodeLine& line);
|
2017-12-12 12:44:52 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Set to Absolute Positioning
|
|
|
|
void _processG90(const GCodeReader::GCodeLine& line);
|
2017-12-08 09:50:36 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Set to Relative Positioning
|
|
|
|
void _processG91(const GCodeReader::GCodeLine& line);
|
2017-12-12 12:44:52 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Set Position
|
|
|
|
void _processG92(const GCodeReader::GCodeLine& line);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Sleep or Conditional stop
|
|
|
|
void _processM1(const GCodeReader::GCodeLine& line);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Set extruder to absolute mode
|
|
|
|
void _processM82(const GCodeReader::GCodeLine& line);
|
2017-12-11 13:03:29 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Set extruder to relative mode
|
|
|
|
void _processM83(const GCodeReader::GCodeLine& line);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Set Extruder Temperature and Wait
|
|
|
|
void _processM109(const GCodeReader::GCodeLine& line);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Set max printing acceleration
|
|
|
|
void _processM201(const GCodeReader::GCodeLine& line);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Set maximum feedrate
|
|
|
|
void _processM203(const GCodeReader::GCodeLine& line);
|
2017-12-11 08:06:29 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Set default acceleration
|
|
|
|
void _processM204(const GCodeReader::GCodeLine& line);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Advanced settings
|
|
|
|
void _processM205(const GCodeReader::GCodeLine& line);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 09:35:04 +00:00
|
|
|
// Set extrude factor override percentage
|
|
|
|
void _processM221(const GCodeReader::GCodeLine& line);
|
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Set allowable instantaneous speed change
|
|
|
|
void _processM566(const GCodeReader::GCodeLine& line);
|
2019-07-08 06:40:20 +00:00
|
|
|
|
2018-08-04 15:38:25 +00:00
|
|
|
// Unload the current filament into the MK3 MMU2 unit at the end of print.
|
|
|
|
void _processM702(const GCodeReader::GCodeLine& line);
|
|
|
|
|
2018-07-30 10:08:26 +00:00
|
|
|
// Processes T line (Select Tool)
|
|
|
|
void _processT(const GCodeReader::GCodeLine& line);
|
|
|
|
|
2019-08-21 12:43:14 +00:00
|
|
|
// Processes the tags
|
|
|
|
// Returns true if any tag has been processed
|
|
|
|
bool _process_tags(const GCodeReader::GCodeLine& line);
|
|
|
|
|
2020-02-20 16:32:46 +00:00
|
|
|
// Processes ColorChangeTag and PausePrintTag
|
|
|
|
void _process_custom_gcode_tag(CustomGcodeType code);
|
2019-08-21 12:43:14 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
// Simulates firmware st_synchronize() call
|
2020-04-01 11:42:26 +00:00
|
|
|
void _simulate_st_synchronize(float additional_time);
|
2017-12-08 09:50:36 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
void _forward_pass();
|
|
|
|
void _reverse_pass();
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
void _planner_forward_pass_kernel(Block& prev, Block& curr);
|
|
|
|
void _planner_reverse_pass_kernel(Block& curr, Block& next);
|
2017-12-06 13:12:10 +00:00
|
|
|
|
2018-01-05 08:46:09 +00:00
|
|
|
void _recalculate_trapezoids();
|
2018-01-30 12:18:21 +00:00
|
|
|
|
2018-05-30 10:08:03 +00:00
|
|
|
// Returns the given time is seconds in format DDd HHh MMm SSs
|
|
|
|
static std::string _get_time_dhms(float time_in_secs);
|
2020-02-10 10:56:49 +00:00
|
|
|
// Returns the given time is minutes in format DDd HHh MMm
|
|
|
|
static std::string _get_time_dhm(float time_in_secs);
|
2018-05-30 10:08:03 +00:00
|
|
|
|
2018-06-06 09:00:36 +00:00
|
|
|
// Returns the given, in minutes (integer)
|
|
|
|
static std::string _get_time_minutes(float time_in_secs);
|
|
|
|
|
2018-01-30 12:18:21 +00:00
|
|
|
#if ENABLE_MOVE_STATS
|
|
|
|
void _log_moves_stats() const;
|
|
|
|
#endif // ENABLE_MOVE_STATS
|
2018-01-05 08:46:09 +00:00
|
|
|
};
|
2017-04-26 12:24:31 +00:00
|
|
|
|
|
|
|
} /* namespace Slic3r */
|
|
|
|
|
|
|
|
#endif /* slic3r_GCodeTimeEstimator_hpp_ */
|