-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgcodeparser.h
75 lines (49 loc) · 2 KB
/
gcodeparser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef GCODEPARSER_H
#define GCODEPARSER_H
#include <QObject>
#include <QVector3D>
#include <QMultiMap>
#include "grblinstruction.h"
class GCodeParser : public QObject
{
Q_OBJECT
public:
enum G0_NonModalActions{NON_MODAL_NO_ACTION = 0, NON_MODAL_DWELL, NON_MODAL_SET_COORDINATE_DATA, NON_MODAL_GO_HOME_0,
NON_MODAL_SET_HOME_0, NON_MODAL_GO_HOME_1, NON_MODAL_SET_HOME_1, NON_MODAL_ABSOLUTE_OVERRIDE,
NON_MODAL_SET_COORDINATE_OFFSET, NON_MODAL_RESET_COORDINATE_OFFSET};
enum G1_MotionModes{MOTION_MODE_SEEK = 0, MOTION_MODE_LINEAR, MOTION_MODE_CW_ARC, MOTION_MODE_CCW_ARC,
MOTION_MODE_PROBE, MOTION_MODE_NONE};
enum G2_PlaneSelect{PLANE_SELECT_XY = 0, PLANE_SELECT_ZX, PLANE_SELECT_YZ};
enum G3_DistanceMode{DISTANCE_MODE_ABSOLUTE = 0, DISTANCE_MODE_INCREMENTAL};
enum G6_UnitsMode{UNITS_MODE_MM = 0, UNITS_MODE_INCHES};
explicit GCodeParser(QObject *parent = 0);
uint32_t getMachineTime() const;
signals:
void parsedPrimitive(int line, QVector<QVector3D> geometry, bool isWork);
public slots:
void parseInstruction(GrblInstruction instruction);
void reset();
private:
void computeMovement(int line);
QVector<QVector3D> buildLinePointsVector(QVector3D target);
QVector<QVector3D> buildArcPointsVector(QVector3D target);
QVector2D computeArcCenter(QVector3D target);
void computeMachineTime(QVector<QVector3D> pointsVector);
void processGValues();
QVector3D processXYZValues();
bool isMotionWork();
const int *getAxisMap();
G0_NonModalActions m_g0NonModal;
G1_MotionModes m_g1Motion;
G2_PlaneSelect m_g2Plane;
G3_DistanceMode m_g3Distance;
G6_UnitsMode m_g6Units;
uint32_t m_machineTime; // ms
float m_machineSpeed; // mm/m
int axes[3];
QVector3D m_currentPos; //in mm
bool m_isCurrentPosValid;
QMultiMap<char,float> m_wordMap;
static const int s_axisArray[3][3];
};
#endif // GCODEPARSER_H