SOLARIS_QT6_DAQ/mainwindow.h

144 lines
2.7 KiB
C
Raw Normal View History

2023-01-25 14:59:48 -05:00
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QWidget>
#include <QMainWindow>
#include <QTabWidget>
#include <QPlainTextEdit>
#include <QThread>
#include <qdebug.h>
#include <QDateTime>
#include <QScrollBar>
#include <QPushButton>
2023-01-30 18:40:24 -05:00
#include <QMutex>
2023-01-25 14:59:48 -05:00
2023-01-25 17:16:14 -05:00
#include <vector>
2023-01-30 18:40:24 -05:00
#include <time.h> // time in nano-sec
2023-01-25 17:16:14 -05:00
#include "digiSettings.h"
2023-01-25 14:59:48 -05:00
2023-01-30 18:40:24 -05:00
#include "ClassDigitizer2Gen.h"
#include "influxdb.h"
static QMutex digiMTX;
class ReadDataThread : public QThread{
Q_OBJECT
public:
ReadDataThread(Digitizer2Gen * dig, QObject * parent = 0) : QThread(parent){
stop = false;
this->digi = dig;
readCount = 0;
}
void Stop() {stop = true;}
void run(){
clock_gettime(CLOCK_REALTIME, &ta);
readCount = 0;
//for( int i = 0; i < 10; i ++){
// emit sendMsg(QString::number(i));
// if( stop ) break;
//}
while(true){
digiMTX.lock();
int ret = digi->ReadData();
digiMTX.unlock();
if( ret == CAEN_FELib_Success){
digi->SaveDataToFile();
}else if(ret == CAEN_FELib_Stop){
digi->ErrorMsg("No more data");
break;
}else{
digi->ErrorMsg("ReadDataLoop()");
}
2023-01-31 18:59:12 -05:00
clock_gettime(CLOCK_REALTIME, &tb);
//if( readCount % 1000 == 0 ) {
if( tb.tv_sec - ta.tv_sec > 2 ) {
emit sendMsg("FileSize : " + QString::number(digi->GetFileSize()/1024./1024.) + " MB");
2023-01-30 18:40:24 -05:00
//double duration = tb.tv_nsec-ta.tv_nsec + tb.tv_sec*1e+9 - ta.tv_sec*1e+9;
//printf("%4d, duration : %10.0f, %6.1f\n", readCount, duration, 1e9/duration);
ta = tb;
}
readCount++;
}
}
signals:
void sendMsg(const QString &msg);
private:
bool stop;
Digitizer2Gen * digi;
timespec ta, tb;
unsigned int readCount;
};
//=================================================
2023-01-25 14:59:48 -05:00
class MainWindow : public QMainWindow{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
2023-01-30 18:40:24 -05:00
2023-01-25 14:59:48 -05:00
private slots:
void bnOpenDigitizers_clicked();
void bnCloseDigitizers_clicked();
2023-01-25 17:16:14 -05:00
void OpenDigitizersSettings();
2023-01-31 18:59:12 -05:00
void SetupNewExp();
void ProgramSettings();
2023-01-25 14:59:48 -05:00
signals :
private:
2023-01-30 18:40:24 -05:00
2023-01-25 14:59:48 -05:00
QPushButton * bnProgramSettings;
QPushButton * bnOpenDigitizers;
QPushButton * bnCloseDigitizers;
QPushButton * bnDigiSettings;
QPushButton * bnStartACQ;
QPushButton * bnStopACQ;
2023-01-31 18:59:12 -05:00
QPushButton * bnNewExp;
2023-01-25 17:16:14 -05:00
DigiSettings * digiSetting;
2023-01-25 14:59:48 -05:00
QPlainTextEdit * logInfo;
2023-01-30 18:40:24 -05:00
static Digitizer2Gen * digi;
2023-01-25 14:59:48 -05:00
unsigned short nDigi;
2023-01-25 17:16:14 -05:00
std::vector<unsigned short> digiSerialNum;
2023-01-25 14:59:48 -05:00
2023-01-30 18:40:24 -05:00
void StartACQ();
void StopACQ();
ReadDataThread * readDataThread;
2023-01-25 14:59:48 -05:00
void LogMsg(QString msg);
2023-01-31 18:59:12 -05:00
QString expName;
QString dataPath;
QString analysisPath;
int runID;
2023-01-25 14:59:48 -05:00
};
#endif // MAINWINDOW_H