forked from romixlab/cnc-vision
-
Notifications
You must be signed in to change notification settings - Fork 0
/
automator.h
153 lines (125 loc) · 3.99 KB
/
automator.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#ifndef AUTOMATOR_H
#define AUTOMATOR_H
#include <QObject>
#include <QTimer>
#include <QThread>
#include <QFile>
#include <QTextStream>
#include <QUrl>
#include "rayreceiver.h"
#include "capturecontroller.hpp"
#include "surfacemodel.h"
#include "gcodeplayer.h"
//#include "datatable.h"
//#include "bspline.h"
//#include "bsplinebuilder.h"
class Automator : public QObject
{
Q_OBJECT
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool cutModeEnabled READ cutModeEnabled WRITE setCutModeEnabled)
Q_PROPERTY(bool scanComplited READ scanComplited NOTIFY scanStateChanged)
Q_PROPERTY(QString message READ message NOTIFY messageChanged)
Q_PROPERTY(bool autosendPower READ autosendPower WRITE setAutosendPower)
Q_PROPERTY(float minPower READ minPower WRITE setMinPower)
Q_PROPERTY(float maxPower READ maxPower WRITE setMaxPower)
Q_PROPERTY(float lastSentPower READ lastSentPower NOTIFY changePower)
Q_PROPERTY(SurfaceModel *surfaceModel READ surfaceModel CONSTANT)
Q_PROPERTY(State state READ state NOTIFY stateChanged)
public:
explicit Automator(QObject *parent = nullptr);
~Automator();
enum State {
Disabled,
AutoEngraving,
AutoCutting,
Scanning
};
Q_ENUM(State)
bool working() const;
bool enabled() const;
void setEnabled(bool enabled);
QString message() const;
Q_INVOKABLE float compensate(float dz) const;
bool cutModeEnabled() const;
void setCutModeEnabled(bool cutMode);
bool scanComplited() const;
bool autosendPower() const;
void setAutosendPower(bool autosendPower);
float maxPower() const;
void setMaxPower(float maxPower);
float minPower() const;
void setMinPower(float minPower);
float lastSentPower() const;
Q_INVOKABLE void scanSurface(int width, int height, int step, int leftShit);
Q_INVOKABLE void approveScan();
Q_INVOKABLE void loadLastScan();
Q_INVOKABLE void addMissingEntry(float entry);
SurfaceModel *surfaceModel() const;
Q_INVOKABLE void clearSurface() const;
State state() const;
float interpolateFromSurfaceScan(const SurfacePoint &point);
signals:
void enabledChanged();
void messageChanged();
void sendToMC(const QString &command);
void sendToMCWithAnswer(const QString &command);
void changePower(float power);
void startScan(const QUrl &fileUrl);
void continueScan();
void stateChanged(State s);
void scanStateChanged();
void requestMissingEntry();
public slots:
void ondzChanged(float dz);
void ondzValidChanged(bool valid);
void onMcConnectionStateChanged(bool connected);
void onRayConnectionStateChanged(bool connected);
void onCoordsChanged(float x, float y, float z, float b);
void onMcStateChanged(RayReceiver::State s);
void onCameraFail();
void compensate();
void compensateFromScan();
void scanSnapshot(GcodePlayer::State s);
void scanFinished(GcodePlayer::State s);
void answerFromMCReceived();
private:
void checkWorkingState();
bool m_working;
float m_lastdz;
bool m_lastdzValid;
bool m_lastCoordsValid;
bool m_enabled;
bool m_mcConnected;
bool m_cameraConnected;
float m_mcs_x;
float m_mcs_y;
float m_mcs_x_check_state;
float m_mcs_y_check_state;
float m_mcs_b;
QString m_message;
bool m_autosendPower;
float m_maxPower;
float m_minPower;
float m_lastSentPower;
QTimer m_powerTimer;
bool m_compensatorOneShot;
bool m_cutCompensatorOneShot;
bool m_answerFromMCReceived;
bool m_scanOneShot;
bool m_cutModeEnabled;
bool m_scanComplited;
bool m_scanApprooved;
bool m_entryMissing;
SurfaceModel *m_surfaceModel;
State m_state;
RayReceiver::State m_lastMCState;
//SPLINTER::DataTable m_samples;
//SPLINTER::BSpline *m_surfaceSpline;
//float m_scanWidth;
//float m_scanHeight;
int scanSnapshotNumber;
private slots:
void m_scanSnapshot();
};
#endif // AUTOMATOR_H