forked from labstreaminglayer/App-BrainAmpSeries
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmainwindow.h
91 lines (79 loc) · 2.46 KB
/
mainwindow.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
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <atomic>
#include <thread>
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#else
using HANDLE = void *;
using ULONG = unsigned long;
#endif
#include "BrainAmpIoCtl.h"
struct ReaderConfig
{
enum Resolution : uint8_t { V_100nV = 0, V_500nV = 1, V_10microV = 2, V_152microV = 3 } resolution;
bool dcCoupling, usePolyBox, useAuxChannels, lowImpedanceMode;
int chunkSize, channelCount, serialNumber;
std::vector<std::string> channelLabels;
int useMRLowPass;
};
struct t_AppVersion
{
int32_t Major;
int32_t Minor;
int32_t Bugfix;
};
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent, const char *config_file);
~MainWindow() noexcept override;
private slots:
// close event (potentially disabled)
void closeEvent(QCloseEvent *ev) override;
// start the BrainAmpSeries connection
void toggleRecording();
void VersionsDialog();
void UpdateChannelLabels();
void UpdateChannelLabelsGUI(int);
void setSamplingRate();
void MRSettingsToggled(int);
private:
// function for loading / saving the config file
QString find_config_file(const char *filename);
void CheckAmpTypeAgainstConfig(BA_SETUP* setup, USHORT* ampTypes, ReaderConfig config);
void CheckGsrChannelsValidity(USHORT* ampTypes, ReaderConfig config);
void SetResolutions(BA_SETUP* setup, USHORT* ampTypes, uint8_t resolution, bool useAuxChannels);
void SetDCCoupling(BA_SETUP* setup, USHORT* ampTypes, bool dcCoupling);
void SetLowPass(BA_SETUP* setup, USHORT* ampTypes, bool useMRLowPass);
bool IsAuxChannel(int c);
// background data reader thread
template <typename T>
void read_thread(const ReaderConfig config);
// raw config file IO
void load_config(const QString &filename);
void save_config(const QString &filename);
std::unique_ptr<std::thread> reader{nullptr};
HANDLE m_hDevice{nullptr};
bool m_bUnsampledMarkers{false};
bool m_bSampledMarkersEEG{false};
bool m_bOverrideAutoUpdate;
//bool m_bPullUpHiBits;
//bool m_bPullUpLowBits;
uint16_t m_nTriggerMask = 0xffff;
bool m_bPassesConfigCheck = false;
uint16_t m_nPullDir;
t_AppVersion m_AppVersion;
Ui::MainWindow *ui;
std::atomic<bool> shutdown{false}; // flag indicating whether the recording thread should quit
std::vector<int> m_vnExGChannelMap;
std::vector<int> m_vnAuxChannelMap;
std::vector<int> m_vnGsrChannelMap;
double m_dCompensatedStreamLag = 0;
};
#endif // MAINWINDOW_H