SOLARIS_QT6_DAQ/mainwindow.h

174 lines
3.5 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-02-01 16:38:02 -05:00
2023-01-31 18:59:12 -05:00
void ProgramSettings();
2023-02-01 16:38:02 -05:00
bool OpenProgramSettings();
void SaveProgramSettings();
void OpenDirectory(int id);
void SetupNewExp();
bool OpenExpSettings();
void CreateNewExperiment();
void ChangeExperiment();
2023-01-31 18:59:12 -05:00
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;
2023-02-01 16:38:02 -05:00
QPushButton * bnNewExp;
QLineEdit * leExpName;
2023-02-01 16:38:02 -05:00
2023-01-25 14:59:48 -05:00
QPushButton * bnOpenDigitizers;
QPushButton * bnCloseDigitizers;
QPushButton * bnDigiSettings;
QPushButton * bnStartACQ;
QPushButton * bnStopACQ;
QLineEdit * leRunID;
2023-01-31 18:59:12 -05:00
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-02-01 16:38:02 -05:00
bool logMsgHTMLMode = true;
2023-01-31 18:59:12 -05:00
2023-02-01 16:38:02 -05:00
//---------------- Program settings
QLineEdit * lSaveSettingPath; // only live in ProgramSettigns()
QLineEdit * lAnalysisPath; // only live in ProgramSettigns()
QLineEdit * lDataPath; // only live in ProgramSettigns()
QLineEdit * lIPDomain;
QLineEdit * lDatbaseIP;
QLineEdit * lDatbaseName;
QLineEdit * lElogIP;
QString settingFilePath;
2023-01-31 18:59:12 -05:00
QString analysisPath;
2023-02-01 16:38:02 -05:00
QString dataPath;
QString IPDomain;
QString DatabaseIP;
QString DatabaseName;
QString ElogIP;
//------------- experiment settings
bool isGitExist;
2023-02-01 16:38:02 -05:00
QString expName;
unsigned int runID;
unsigned int elogID;
2023-01-25 14:59:48 -05:00
};
#endif // MAINWINDOW_H