forked from zalohasa/GrblHoming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgcommands.h
88 lines (72 loc) · 2.1 KB
/
gcommands.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
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef GCOMMANDS_H
#define GCOMMANDS_H
#include <exception>
#include <QString>
#include <QMap>
#include "basicgeometry.h"
class CodeCommandException : public std::exception
{
public:
CodeCommandException(const QString &msg) {this->msg = msg; }
virtual ~CodeCommandException() throw () {}
QString getMessage() { return msg; }
private:
QString msg;
};
class CodeCommand
{
public:
enum command_type_t {G_COMMAND, M_COMMAND};
virtual ~CodeCommand() {}
virtual QString toString() const = 0;
virtual command_type_t getType() const = 0;
int getCommand() const { return command; }
protected:
int command;
};
class MCodeCommand : public CodeCommand
{
public:
MCodeCommand(int command, const QString ¶meters);
MCodeCommand(const QString &commandLine) throw (CodeCommandException);
~MCodeCommand(){}
QString toString() const;
command_type_t getType() const {return M_COMMAND;}
QString getParameters() const {return parameters;}
private:
QString parameters;
};
class GCodeCommand : public CodeCommand
{
public:
GCodeCommand(int command, const QString ¶meters, const char fourthName = 'E');
GCodeCommand(const GCodeCommand& command);
~GCodeCommand(){}
command_type_t getType() const {return G_COMMAND;}
QString toString() const;
bool getX(double& x) const;
bool getY(double& y) const;
bool getZ(double& z) const;
bool getX(float& x) const;
bool getY(float& y) const;
bool getZ(float& z) const;
bool getF(double& f) const;
bool getFourth(double &fourth) const;
void setX(double x);
void setY(double y);
void setZ(double z);
void setF(double f);
void setFloatPrecission(int precission) const;
void setPoint(const Point &p);
void setFourth(double fourth);
void setParameter(char param, double value);
bool getParameter(char param, double &value) const;
QString getParameters() const {return parameters;}
private:
double x,y,z,f,fourth;
mutable int floatPrecission;
QString parameters;
const char fourthName;
QMap<char, double> parameterMap;
};
#endif // GCOMMANDS_H