-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrtvtmainwindow.h
192 lines (159 loc) · 5.31 KB
/
rtvtmainwindow.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#ifndef RTVTMAINWINDOW_H
#define RTVTMAINWINDOW_H
// RTVTMainWindow is now a controller object for RTVT subsystem
#include <QMainWindow>
#include <QAction>
#include <QMenu>
#include <QMutex>
#include <QtGui>
#include <QFuture>
#include <QFutureWatcher>
#include <QAudioOutput>
#include "rtvtchannelwidget.h"
#include "rtvtdataobject.h"
#ifdef USE_HS_USB
#include "cpshsusbhardwareabstractionlayer.h"
#endif
// Timer
#include "RTVTTimer.h"
#include "universalStructures.h"
// For HUD Plugins
#include "multipagewidget.h"
#include "HUD_Plugins/rtvthudcontrollerview.h"
#include "HUD_Plugins/rtvthudwaveview.h"
#include "data_handling_plugins/bNEVwr.h"
#include "External-Code/audiooutput.h"
#include "rtvtglobaldefinitions.h"
// Filtering
#include "Filtering/FirKernels.h"
#define RTVT_DEBUG
class RTVTMainWindow : public QMainWindow
{
Q_OBJECT
public:
// Variables
RTVTDataObject *dataObject;
int sbWriteEndPtr, sbDrawReadEndPtr, sbAudioReadEndPtr;
QListWidget *dataListWidget;
int playStep,readDataStep;
QFuture<void> *bbFuture, *sbFuture, *abFuture;
QFutureWatcher<void> *bbWatcher, *sbWatcher, *abWatcher;
QTimer *bbTransferTimer, *sbTransferTimer, *playTimer;
QList<RTVTChannelWidget*> channelWidgetList;
int dataSource, dataPath;
bool readAllData;
QAudioOutput* audioOutput;
bool startAudio, useAudio;
bool sbThreadIsRunning;
unsigned int audioChannel;
int missedSynch;
QBuffer *aBuffer;
QTextBrowser *rtvtConsole;
int continuousViewerNeedsDataNumber;
double dFilteredDataArray[DEFAULT_NUM_CHANNELS_IN_DATA][512000]; //was MAX_DATA_TO_FILTER
QByteArray *byteArray;
QFile saveDataFile;
QTextStream streamToWrite;
QDataStream out, binStreamToWrite;
QString rtvtSaveDataPath;
bool rtvtSavingData;
int numberOfFileSaves;
// Views
int numberOfChannelViews;
int channelViewType;
bool squareChannelGrid;
// Data
unsigned int numberOfDataChannels;
int selectedWidgetNumber;
unsigned int sampleFrameLength;
unsigned int systemClockRate;
QByteArray theDataArray;
unsigned char *transferBuf;
unsigned int singleFrameLoss;
// HUD
RTVTHUDControllerView *rtvtControllerView;
RTVTHUDWaveView *rtvtWaveHUD;
MultiPageWidget *hud;
QDockWidget *hudDock;
RTVTTriggerModel *theWaveTableModel;
unsigned int wireAddressing;
// NEV Writer
bNEVwr *nevWriter;
FILE *nevFile;
bool saveNEVState;
// Filtering
FirKernels **firFilters;
int selectedFilterIndex;
int numberOfFiltersCreated;
bool shouldFilter;
// Audio
AudioTest *audioPlayer;
// Functions
RTVTMainWindow();
~RTVTMainWindow();
void initializeVariables();
void centerMainWindow();
void redrawChannelViews();
void makeDataStoreToBackBufferTransfer();
void makeBackToStorageBufferTransfer();
void makeStorageToAudioBufferTransfer();
void loadDataFromSource();
void loadDataToTableOnChannels(int start, int end);
unsigned int findFrameSynchInData(unsigned char *data);
void resetAllBuffers();
void threadedSaveRawData();
void setupChannelGrid();
void setNEVFile(bool state, char* fileName);
void setSelectedWidget(int widgetNumber);
// USB
void setupHSUSB();
public slots:
QString openExistingData();
void chooseFileForSavingData();
void runThreadedDataBBTransfer();
void runThreadedDataSBTransfer();
void bbThreadFinishedRunning();
void sbThreadFinishedRunning();
void runThreadedDataABTransfer();
void abThreadFinishedRunning();
void tellViewsToDraw();
void tellAudioToPlay();
void viewWasDoubleClicked(int channel);
void continuousViewReachedEndOfData(int channel);
void updatePlay();
void resizeSelfAndViews();
void threadedChannelSeparation(unsigned char *);
void setSaveDataPath(QString inPath);
void setSaveDataBool(bool inBool);
void clearWaveformsOnChannels();
void resetTriggersOnChannels();
void propogateSaveNEV(bool state, char* fileName);
void writeWaveformsToFile(waveformDatum datum);
void setSaveNEVState(bool);
void runThreadedAudioPlayer();
void addFilterFromFile();
void updateSelectedFilter(int ind);
void stopFilteringData();
void updateLocalWaveCheckValue(int);
void updateNumberOfChannelViews(int numChannels);
void updateNumberOfDataChannels(int numDataChannels);
void saveSNIFFRToMat(void);
void updateAudioChannel(int index);
void changeChannelDisplayToWavesAndContinuous();
void changeChannelDisplayToWaves();
void playFromController(bool withRecording);
void setAddressingTo(int numWire);
void tellWaveViewsToPropogateChangesWhenDone(bool yesNo);
signals:
void appendToConsole(QString);
private:
QFile openDataFileHandle, saveDataFileHandle;
mutable QMutex bbMutex;
mutable QMutex sbMutex;
void keyPressEvent(QKeyEvent *e);
protected:
void resizeEvent (QResizeEvent * event);
void moveEvent ( QMoveEvent * event );
void mousePressEvent ( QMouseEvent * event );
};
#endif // RTVTMAINWINDOW_H