-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathalarmpanel.h
165 lines (132 loc) · 3.38 KB
/
alarmpanel.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
154
155
156
157
158
159
160
161
162
163
164
165
#ifndef ALARMPANEL_H
#define ALARMPANEL_H
#include <QCheckBox>
#include <QLabel>
#include <QRunnable>
#include <QRadioButton>
#include <QSettings>
#include <QSlider>
#include <QFile>
#include "Utilities/kalman.h"
#include "Utilities/paneldialog.h"
#include "Utilities/numbertextbox.h"
#include "Utilities/filesetter.h"
#include "Utilities/directorysetter.h"
#include "configpanel.h"
#include <chrono>
using namespace std::chrono;
struct AudioData
{
uint8_t *position;
uint32_t length;
int volume;
};
class AlarmPlayer : public QObject, public QRunnable
{
Q_OBJECT
public:
AlarmPlayer(QMainWindow *parent);
void run() override;
void stop();
void mute(bool muted);
static void audioCallback(void *userData, uint8_t *stream, int streamLength);
QMainWindow *mainWindow;
QString filename;
AudioData audio;
bool running = false;
int lastVolume;
signals:
void done();
};
class AlarmCheckBox : public QCheckBox
{
Q_OBJECT
public:
AlarmCheckBox(QString text, QString key, QSettings *settings, bool defaultState);
QString key;
QSettings *settings;
public slots:
void clicked(bool);
};
class AlarmNumberBox : public NumberTextBox
{
Q_OBJECT
public:
AlarmNumberBox(QString key, QSettings *settings, QString defaultText);
QString key;
QSettings *settings;
public slots:
void edited();
};
class AlarmPanel : public Panel
{
Q_OBJECT
public:
AlarmPanel(QMainWindow *parent, int obj_id);
~AlarmPanel();
void autoSave() override;
void feed(int count);
QString key() const;
QString getTimestampFilename() const;
void writeToFile(const QString& str);
int obj_id;
AlarmNumberBox *minLimit;
AlarmNumberBox *maxLimit;
AlarmNumberBox *minLimitTime;
AlarmNumberBox *maxLimitTime;
AlarmCheckBox *chkMin;
AlarmCheckBox *chkMax;
AlarmCheckBox *chkSound;
AlarmCheckBox *chkWrite;
AlarmCheckBox *chkColor;
FileSetter *soundSetter;
DirectorySetter *dirSetter;
QRadioButton *playOnce;
QRadioButton *playContinuous;
QPushButton *btnTest;
QPushButton *btnMute;
QSlider *volumeSlider;
QLabel *filteredCount;
QFile *file = nullptr;
bool minAlarmOn = false;
bool maxAlarmOn = false;
high_resolution_clock::time_point minAlarmStartOn;
high_resolution_clock::time_point minAlarmStartOff;
high_resolution_clock::time_point maxAlarmStartOn;
high_resolution_clock::time_point maxAlarmStartOff;
high_resolution_clock::time_point reference;
Kalman k_count;
bool first_pass = true;
high_resolution_clock::time_point lastTime;
ColorProfile alarmProfile;
ColorProfile storedProfile;
AlarmPlayer *player;
QString soundSetterKey;
QString dirSetterKey;
QString playOnceKey;
QString volumeKey;
bool testing = false;
public slots:
void test();
void setSoundPath(const QString&);
void setDirPath(const QString&);
void playOnceToggled(bool);
void soundPlayFinished();
void chkSoundClicked(bool);
void chkColorClicked(bool);
void chkWriteClicked(bool);
void chkMinClicked(bool);
void chkMaxClicked(bool);
void volumeChanged(int);
void minAlarmOff();
void maxAlarmOff();
void mute();
};
class AlarmDialog : public PanelDialog
{
Q_OBJECT
public:
AlarmDialog(QMainWindow *parent, int obj_id);
AlarmPanel *getPanel();
};
#endif // ALARMPANEL_H