gcode-estimator/TimeCalc.h
2023-06-22 17:32:09 +03:00

57 lines
1.0 KiB
C++

#ifndef TIMECALC_H_
#define TIMECALC_H_
#include <algorithm>
#include <vector>
#include "Point.h"
#define EXTRUDER_COUNT 1
#define AXIS_COUNT (3 + EXTRUDER_COUNT)
class TimeCalc
{
public:
struct PrinterMove
{
PrinterMove();
double dist;
double delta[AXIS_COUNT];
double unit[AXIS_COUNT];
double vel[AXIS_COUNT];
double accel[AXIS_COUNT];
double vel_start[AXIS_COUNT];
double vel_end[AXIS_COUNT];
};
private:
double m_extruder_length[EXTRUDER_COUNT];
double m_time;
double m_pos[AXIS_COUNT];
double m_accel_max[AXIS_COUNT];
double m_vel_max[AXIS_COUNT];
double m_jerk_max[AXIS_COUNT];
std::vector<PrinterMove> m_moves;
public:
TimeCalc();
void reset();
void add_move(Point new_pos, double speed);
void set_pos(Point new_pos);
void flush();
void add_time(double time);
double get_time() const;
double get_extruder_length(int idx) const;
Point get_pos() const;
void set_max_acceleration(int axis, double value);
void set_max_velocity(int axis, double value);
void set_max_jerk(int axis, double value);
};
#endif // TIMECALC_H_