-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgcodestreamer.h
76 lines (52 loc) · 1.77 KB
/
gcodestreamer.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
#ifndef GCODESTREAMER_H
#define GCODESTREAMER_H
#include <QObject>
#include <QVector>
#include <QByteArray>
#include "grblinstruction.h"
#include "grblboard.h"
#include "grblstatus.h"
class GCodeStreamer : public QObject
{
Q_OBJECT
public:
enum states {state_clear, state_ready, state_running};
explicit GCodeStreamer(QObject *parent = 0);
states getState(void);
signals:
void fileLoaded(QString filename);
void instructionLoaded(GrblInstruction instruction);
void cleared();
void stateChanged(states state);
void lineCountUpdated(int line);
void currentLineUpdated(int line);
void workCompleted(void);
void instructionToSend(GrblInstruction instruction);
public slots:
//Start or pause instructions streaming
void go(void);
void step(void);
void stop(void);
//open / close file
void loadFile(const QString &m_file);
void clear();
//Move inside file
void rewind(){goToLine(0);}
void goToLine(int line);
//Grbl board related slots
void onInstructionSentToGrbl(const GrblInstruction &acceptedInstruction);
void onInstructionParsedByGrbl(const GrblInstruction &parsedInstruction);
void onGrblStatusUpdated(GrblStatus* const status);
private:
//void bufferizeIntructions(void);
void cleanupLine(QByteArray* code);
void tryToSendNextInstruction();
int getCurrentLineNumber();
int m_lineCount;
int m_lineToSendIndex; //Position of read head in the file
int m_lastLineParsedByGrbl; //Last line accepted in planning buffer by grbl
bool m_run;
QVector<GrblInstruction> m_usefulLinesVector;
static const char *s_gcodeCommentsDelimiters[]; //List of EEPROM related instructions, requiring use of simpler "blocking" protocol
};
#endif // GCODESTREAMER_H