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-02-06 15:58:21 -05:00
|
|
|
#include <QComboBox>
|
2023-01-30 18:40:24 -05:00
|
|
|
#include <QMutex>
|
2023-02-03 16:58:27 -05:00
|
|
|
#include <QChart>
|
2023-02-03 17:44:36 -05:00
|
|
|
#include <QLineSeries>
|
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;
|
|
|
|
|
2023-02-03 18:58:35 -05:00
|
|
|
//^#===================================================== ReadData Thread
|
|
|
|
class ReadDataThread : public QThread {
|
2023-01-30 18:40:24 -05:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ReadDataThread(Digitizer2Gen * dig, QObject * parent = 0) : QThread(parent){
|
|
|
|
this->digi = dig;
|
2023-02-06 15:58:21 -05:00
|
|
|
isScopeRun = false;
|
2023-01-30 18:40:24 -05:00
|
|
|
}
|
2023-02-06 15:58:21 -05:00
|
|
|
void SetScopeRun(bool onOff) {this->isScopeRun = onOff;}
|
2023-01-30 18:40:24 -05:00
|
|
|
void run(){
|
|
|
|
clock_gettime(CLOCK_REALTIME, &ta);
|
|
|
|
while(true){
|
|
|
|
digiMTX.lock();
|
|
|
|
int ret = digi->ReadData();
|
|
|
|
digiMTX.unlock();
|
|
|
|
|
|
|
|
if( ret == CAEN_FELib_Success){
|
2023-02-06 15:58:21 -05:00
|
|
|
if( !isScopeRun) digi->SaveDataToFile();
|
2023-01-30 18:40:24 -05:00
|
|
|
}else if(ret == CAEN_FELib_Stop){
|
|
|
|
digi->ErrorMsg("No more data");
|
|
|
|
break;
|
|
|
|
}else{
|
|
|
|
digi->ErrorMsg("ReadDataLoop()");
|
|
|
|
}
|
|
|
|
|
2023-02-06 15:58:21 -05:00
|
|
|
if( !isScopeRun ){
|
|
|
|
clock_gettime(CLOCK_REALTIME, &tb);
|
|
|
|
if( tb.tv_sec - ta.tv_sec > 2 ) {
|
|
|
|
emit sendMsg("FileSize : " + QString::number(digi->GetFileSize()/1024./1024.) + " MB");
|
|
|
|
|
|
|
|
//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;
|
|
|
|
}
|
2023-01-30 18:40:24 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
signals:
|
|
|
|
void sendMsg(const QString &msg);
|
|
|
|
private:
|
|
|
|
Digitizer2Gen * digi;
|
|
|
|
timespec ta, tb;
|
2023-02-06 15:58:21 -05:00
|
|
|
bool isScopeRun;
|
2023-02-03 18:58:35 -05:00
|
|
|
};
|
2023-01-30 18:40:24 -05:00
|
|
|
|
2023-02-03 18:58:35 -05:00
|
|
|
//^#===================================================== UpdateTrace Thread
|
|
|
|
class UpdateTraceThread : public QThread {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
UpdateTraceThread(QObject * parent = 0) : QThread(parent){
|
|
|
|
waitTime = 5;
|
|
|
|
stop = false;
|
|
|
|
}
|
|
|
|
void Stop() {this->stop = true;}
|
|
|
|
void run(){
|
|
|
|
unsigned int count = 0;
|
|
|
|
stop = false;
|
|
|
|
do{
|
|
|
|
usleep(100000);
|
|
|
|
count ++;
|
|
|
|
if( count % waitTime == 0){
|
|
|
|
emit updateTrace();
|
|
|
|
}
|
|
|
|
}while(!stop);
|
|
|
|
}
|
|
|
|
signals:
|
|
|
|
void updateTrace();
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool stop;
|
|
|
|
unsigned int waitTime; //100 of milisec
|
2023-01-30 18:40:24 -05:00
|
|
|
};
|
|
|
|
|
2023-01-25 14:59:48 -05:00
|
|
|
|
2023-02-03 18:58:35 -05:00
|
|
|
//^#===================================================== MainWindow
|
2023-01-25 14:59:48 -05:00
|
|
|
class MainWindow : public QMainWindow{
|
2023-02-03 16:58:27 -05:00
|
|
|
Q_OBJECT
|
2023-01-25 14:59:48 -05:00
|
|
|
|
|
|
|
public:
|
2023-02-03 16:58:27 -05:00
|
|
|
MainWindow(QWidget *parent = nullptr);
|
|
|
|
~MainWindow();
|
2023-01-25 14:59:48 -05:00
|
|
|
|
2023-01-30 18:40:24 -05:00
|
|
|
|
2023-01-25 14:59:48 -05:00
|
|
|
private slots:
|
|
|
|
|
2023-02-03 16:58:27 -05:00
|
|
|
void OpenDigitizers();
|
|
|
|
void CloseDigitizers();
|
|
|
|
|
|
|
|
void OpenScope();
|
2023-02-03 17:44:36 -05:00
|
|
|
void SetUpPlot();
|
|
|
|
void UpdateScope();
|
2023-01-25 14:59:48 -05:00
|
|
|
|
2023-02-03 16:58:27 -05:00
|
|
|
void OpenDigitizersSettings();
|
2023-01-25 17:16:14 -05:00
|
|
|
|
2023-02-03 16:58:27 -05:00
|
|
|
void ProgramSettings();
|
|
|
|
bool OpenProgramSettings();
|
|
|
|
void SaveProgramSettings();
|
|
|
|
void OpenDirectory(int id);
|
2023-02-01 16:38:02 -05:00
|
|
|
|
2023-02-03 16:58:27 -05:00
|
|
|
void SetupNewExp();
|
|
|
|
bool OpenExpSettings();
|
|
|
|
void CreateNewExperiment(const QString newExpName);
|
|
|
|
void ChangeExperiment(const QString newExpName);
|
|
|
|
void CreateRawDataFolderAndLink(const QString newExpName);
|
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-02-03 16:58:27 -05:00
|
|
|
QPushButton * bnProgramSettings;
|
|
|
|
QPushButton * bnNewExp;
|
|
|
|
QLineEdit * leExpName;
|
|
|
|
|
|
|
|
QPushButton * bnOpenDigitizers;
|
|
|
|
QPushButton * bnCloseDigitizers;
|
|
|
|
|
|
|
|
QPushButton * bnDigiSettings;
|
|
|
|
QPushButton * bnSOLSettings;
|
|
|
|
|
2023-02-06 15:58:21 -05:00
|
|
|
//@------ scope things
|
2023-02-03 18:58:35 -05:00
|
|
|
QMainWindow * scope;
|
2023-02-03 16:58:27 -05:00
|
|
|
QPushButton * bnOpenScope;
|
|
|
|
QChart * plot;
|
2023-02-03 17:44:36 -05:00
|
|
|
QLineSeries * dataTrace;
|
2023-02-03 18:58:35 -05:00
|
|
|
UpdateTraceThread * updateTraceThread;
|
2023-02-06 15:58:21 -05:00
|
|
|
QComboBox * cbScopeDigi;
|
|
|
|
QComboBox * cbScopeCh;
|
|
|
|
QComboBox * cbAnaProbe[2];
|
|
|
|
QComboBox * cbDigProbe[4];
|
|
|
|
void ProbeChange(QComboBox * cb[], const int size);
|
2023-02-03 16:58:27 -05:00
|
|
|
|
2023-02-06 15:58:21 -05:00
|
|
|
//@------ ACQ things
|
2023-02-03 16:58:27 -05:00
|
|
|
QPushButton * bnStartACQ;
|
|
|
|
QPushButton * bnStopACQ;
|
|
|
|
QLineEdit * leRunID;
|
|
|
|
QLineEdit * leRawDataPath;
|
|
|
|
|
|
|
|
DigiSettings * digiSetting;
|
|
|
|
|
|
|
|
QPlainTextEdit * logInfo;
|
|
|
|
|
|
|
|
static Digitizer2Gen ** digi;
|
|
|
|
unsigned short nDigi;
|
|
|
|
std::vector<unsigned short> digiSerialNum;
|
|
|
|
|
|
|
|
void StartACQ();
|
|
|
|
void StopACQ();
|
|
|
|
|
|
|
|
ReadDataThread ** readDataThread;
|
|
|
|
|
|
|
|
void LogMsg(QString msg);
|
|
|
|
bool logMsgHTMLMode = true;
|
|
|
|
|
|
|
|
//---------------- 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;
|
|
|
|
QString analysisPath;
|
|
|
|
QString dataPath;
|
|
|
|
QString IPListStr;
|
|
|
|
QStringList IPList;
|
|
|
|
QString DatabaseIP;
|
|
|
|
QString DatabaseName;
|
|
|
|
QString ElogIP;
|
|
|
|
|
|
|
|
//------------- experiment settings
|
|
|
|
bool isGitExist;
|
|
|
|
bool useGit;
|
|
|
|
QString expName;
|
|
|
|
QString rawDataFolder;
|
|
|
|
unsigned int runID;
|
|
|
|
unsigned int elogID;
|
2023-01-25 14:59:48 -05:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // MAINWINDOW_H
|