-
Notifications
You must be signed in to change notification settings - Fork 1
/
grblboard.h
97 lines (64 loc) · 2.75 KB
/
grblboard.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
89
90
91
92
93
94
95
96
97
#ifndef GRBLBOARD_H
#define GRBLBOARD_H
#include <QObject>
#include <QSerialPort>
#include <QVector3D>
#include <QTimer>
#include "grblstatus.h"
#include "grblconfiguration.h"
#include "grblinstruction.h"
class GrblBoard : public QObject
{
Q_OBJECT
public:
explicit GrblBoard(QObject *parent = nullptr);
void setSerialSettings(const QString &portName, const qint32 &baudRate);
void setStatusRequestInterval(const int &interval);
const GrblStatus *getLastStatus(void) const;
QMap<int,GrblConfiguration> *getParametersMap(void);
signals:
//Board responded to periodic status request
void statusUpdated(GrblStatus* const status);
//Board sent hello message after a reset
void boardStartup(const QString &versionString, const QList<GrblInstruction> &startupRelatedInstructions);
//Instruction has been processed, board sent response. After one of these we can iterate to the next command
void ok(const GrblInstruction &instruction);
void error(const GrblInstruction &instruction,const QString &errorMessage); //Remember to freeze on this if processsing a file
//Informative messages, does not indicate that instruction was completed or anything. Do not base sequencing on theses !
void alarm(const GrblInstruction &instruction, const QString &alarmMessage);
void feedback(const GrblInstruction instruction, const QString &feedbackMessage);
void text(const GrblInstruction &instruction, const QString &textMessage);
//Parameters have been updated
void parametersMapUpdated(QMap<int,GrblConfiguration> *updatedMap);
//Emitted when instruction is placed in char buffer
void instructionSent(const GrblInstruction &instruction);
public slots:
//Open / close serial link
void toggleSerial(void);
//Board real time commands
void rtCmdPauseCycle(void);
void rtCmdResumeCycle(void);
void rtCmdRequestStatus(void);
void rtCmdSoftReset(void);
void rtCmdSafetyDoor(void);
//Send an instruction
void sendInstruction(const GrblInstruction &instruction);
private slots:
void onSerialDataAvailable(void);
void sendStartupInstructions(void);
private:
int getAvailableSpaceInCharBuffer();
bool isBlockingInstructionInBuffer(void);
void addErrorTranslation(QString* errorString);
QList<GrblInstruction> m_boardCharBuffer;
QByteArray m_bufferFromBoard;
QSerialPort *m_serialPort;
QTimer* m_statusTimer;
GrblStatus m_status;
QMap<int,GrblConfiguration> m_parametersMapComplete;
QMap<int,GrblConfiguration> m_parametersMapBeingFilled;
QList<GrblInstruction> m_startupInstructionList;
static const QMap<int,QString> errorTranslationMap;
static QMap<int,QString> generateErrorTranslationMap();
};
#endif // GRBLBOARD_H