polishing
This commit is contained in:
parent
31d6346151
commit
802596af78
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -9,6 +9,7 @@ screenshot.*
|
||||||
*settings*.txt
|
*settings*.txt
|
||||||
*settings*.dat
|
*settings*.dat
|
||||||
*.dat
|
*.dat
|
||||||
|
Logs
|
||||||
|
|
||||||
*~
|
*~
|
||||||
*.autosave
|
*.autosave
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
#define NCOL 10 // number of column
|
#define NCOL 10 // number of column
|
||||||
|
|
||||||
|
@ -12,6 +13,7 @@ std::vector<Reg> SettingItems = {PHA::CH::TriggerThreshold, PHA::CH::DC_Offset};
|
||||||
const std::vector<QString> arrayLabel = {"e", "xf", "xn"};
|
const std::vector<QString> arrayLabel = {"e", "xf", "xn"};
|
||||||
|
|
||||||
SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
|
SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
|
||||||
|
QString analysisPath,
|
||||||
std::vector<std::vector<int>> mapping,
|
std::vector<std::vector<int>> mapping,
|
||||||
QStringList detType,
|
QStringList detType,
|
||||||
std::vector<int> detMaxID,
|
std::vector<int> detMaxID,
|
||||||
|
@ -22,9 +24,14 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
|
||||||
|
|
||||||
this->digi = digi;
|
this->digi = digi;
|
||||||
this->nDigi = nDigi;
|
this->nDigi = nDigi;
|
||||||
|
if( this->nDigi > MaxNumberOfDigitizer ) {
|
||||||
|
this->nDigi = MaxNumberOfChannel;
|
||||||
|
qDebug() << "Please increase the MaxNumberOfChannel";
|
||||||
|
}
|
||||||
this->mapping = mapping;
|
this->mapping = mapping;
|
||||||
this->detType = detType;
|
this->detType = detType;
|
||||||
this->detMaxID = detMaxID;
|
this->detMaxID = detMaxID;
|
||||||
|
this->digiSettingPath = analysisPath + "/Settings/";
|
||||||
|
|
||||||
//Check number of detector type; Array 0-199, Recoil 200-299, other 300-
|
//Check number of detector type; Array 0-199, Recoil 200-299, other 300-
|
||||||
int nDetType = detType.size();
|
int nDetType = detType.size();
|
||||||
|
@ -90,22 +97,22 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
|
||||||
QGridLayout * mainLayout = new QGridLayout(this); this->setLayout(mainLayout);
|
QGridLayout * mainLayout = new QGridLayout(this); this->setLayout(mainLayout);
|
||||||
|
|
||||||
///=================================
|
///=================================
|
||||||
int rowIndex = 0;
|
int rowIndex = 0 ;
|
||||||
QPushButton * bnRefresh = new QPushButton("Refresh Settings", this);
|
QPushButton * bnRefresh = new QPushButton("Refresh Settings", this);
|
||||||
connect(bnRefresh, &QPushButton::clicked, this, &SOLARISpanel::RefreshSettings );
|
connect(bnRefresh, &QPushButton::clicked, this, &SOLARISpanel::RefreshSettings );
|
||||||
mainLayout->addWidget(bnRefresh, rowIndex, 0);
|
mainLayout->addWidget(bnRefresh, rowIndex, 0, 1, 2);
|
||||||
|
|
||||||
QPushButton * bnSaveSetting = new QPushButton("Save Settings", this);
|
QPushButton * bnSaveSetting = new QPushButton("Save Settings", this);
|
||||||
connect(bnSaveSetting, &QPushButton::clicked, this, &SOLARISpanel::SaveSettings);
|
connect(bnSaveSetting, &QPushButton::clicked, this, &SOLARISpanel::SaveSettings);
|
||||||
mainLayout->addWidget(bnSaveSetting, rowIndex, 1);
|
mainLayout->addWidget(bnSaveSetting, rowIndex, 2, 1, 2);
|
||||||
|
|
||||||
QPushButton * bnLoadSetting = new QPushButton("Load Settings", this);
|
QPushButton * bnLoadSetting = new QPushButton("Load Settings", this);
|
||||||
connect(bnLoadSetting, &QPushButton::clicked, this, &SOLARISpanel::LoadSettings);
|
connect(bnLoadSetting, &QPushButton::clicked, this, &SOLARISpanel::LoadSettings);
|
||||||
mainLayout->addWidget(bnLoadSetting, rowIndex, 2);
|
mainLayout->addWidget(bnLoadSetting, rowIndex, 4, 1, 2);
|
||||||
|
|
||||||
QLabel * lbCoinTime = new QLabel("Coin. Time (all ch.) [ns]", this);
|
QLabel * lbCoinTime = new QLabel("Coin. Time (all ch.) [ns]", this);
|
||||||
lbCoinTime->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
lbCoinTime->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
||||||
mainLayout->addWidget(lbCoinTime, rowIndex, 3);
|
mainLayout->addWidget(lbCoinTime, rowIndex, 6, 1, 2);
|
||||||
|
|
||||||
sbCoinTime = new RSpinBox(this);
|
sbCoinTime = new RSpinBox(this);
|
||||||
sbCoinTime->setMinimum(-1);
|
sbCoinTime->setMinimum(-1);
|
||||||
|
@ -113,7 +120,7 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
|
||||||
sbCoinTime->setSingleStep(atof(PHA::CH::CoincidenceLength.GetAnswers()[2].first.c_str()));
|
sbCoinTime->setSingleStep(atof(PHA::CH::CoincidenceLength.GetAnswers()[2].first.c_str()));
|
||||||
sbCoinTime->setDecimals(0);
|
sbCoinTime->setDecimals(0);
|
||||||
sbCoinTime->SetToolTip(atof(PHA::CH::CoincidenceLength.GetAnswers()[1].first.c_str()));
|
sbCoinTime->SetToolTip(atof(PHA::CH::CoincidenceLength.GetAnswers()[1].first.c_str()));
|
||||||
mainLayout->addWidget(sbCoinTime, rowIndex, 4);
|
mainLayout->addWidget(sbCoinTime, rowIndex, 8, 1, 2);
|
||||||
|
|
||||||
connect(sbCoinTime, &RSpinBox::valueChanged, this, [=](){
|
connect(sbCoinTime, &RSpinBox::valueChanged, this, [=](){
|
||||||
if( !enableSignalSlot ) return;
|
if( !enableSignalSlot ) return;
|
||||||
|
@ -152,7 +159,7 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
|
||||||
|
|
||||||
///=================================
|
///=================================
|
||||||
rowIndex ++;
|
rowIndex ++;
|
||||||
QTabWidget * tabWidget = new QTabWidget(this); mainLayout->addWidget(tabWidget, rowIndex, 0, 1, 5);
|
QTabWidget * tabWidget = new QTabWidget(this); mainLayout->addWidget(tabWidget, rowIndex, 0, 1, 10);
|
||||||
for( int detTypeID = 0; detTypeID < nDetType; detTypeID ++ ){
|
for( int detTypeID = 0; detTypeID < nDetType; detTypeID ++ ){
|
||||||
|
|
||||||
QTabWidget * tabSetting = new QTabWidget(tabWidget);
|
QTabWidget * tabSetting = new QTabWidget(tabWidget);
|
||||||
|
@ -441,7 +448,7 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
|
||||||
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Disabled", chID);
|
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Disabled", chID);
|
||||||
}else {
|
}else {
|
||||||
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Ch64Trigger", chID);
|
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Ch64Trigger", chID);
|
||||||
digi[digiID]->WriteValue(PHA::CH::CoincidenceLength, "100", chID);
|
digi[digiID]->WriteValue(PHA::CH::CoincidenceLength, "100");
|
||||||
|
|
||||||
//Form the trigger bit
|
//Form the trigger bit
|
||||||
unsigned long mask = 1ULL << (detID[1] & 0xFF ); // trigger by energy
|
unsigned long mask = 1ULL << (detID[1] & 0xFF ); // trigger by energy
|
||||||
|
@ -454,7 +461,7 @@ void SOLARISpanel::CreateDetGroup(int detTypeID, int SettingID, QList<int> detID
|
||||||
digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "TRGIN", chID);
|
digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "TRGIN", chID);
|
||||||
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "TRGIN", chID);
|
digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "TRGIN", chID);
|
||||||
|
|
||||||
digi[digiID]->WriteValue(PHA::CH::CoincidenceLength, "100", chID);
|
digi[digiID]->WriteValue(PHA::CH::CoincidenceLength, "100");
|
||||||
}; break;
|
}; break;
|
||||||
case 3 : { /// disbaled
|
case 3 : { /// disbaled
|
||||||
digi[digiID]->WriteValue(PHA::CH::EventTriggerSource, "Disabled", chID);
|
digi[digiID]->WriteValue(PHA::CH::EventTriggerSource, "Disabled", chID);
|
||||||
|
@ -676,10 +683,48 @@ void SOLARISpanel::UpdateThreshold(){
|
||||||
//^#########################################
|
//^#########################################
|
||||||
void SOLARISpanel::SaveSettings(){
|
void SOLARISpanel::SaveSettings(){
|
||||||
|
|
||||||
|
for(int i = 0; i < nDigi; i++){
|
||||||
|
|
||||||
|
//*------ search for settings_XXXX.dat
|
||||||
|
|
||||||
|
//Check path exist
|
||||||
|
QDir dir(digiSettingPath);
|
||||||
|
if( !dir.exists() ) dir.mkpath(".");
|
||||||
|
|
||||||
|
QString settingFile = digiSettingPath + "/setting_" + QString::number(digi[i]->GetSerialNumber()) + "_" + QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss") + ".dat";
|
||||||
|
|
||||||
|
|
||||||
|
int flag = digi[i]->SaveSettingsToFile(settingFile.toStdString().c_str());
|
||||||
|
|
||||||
|
switch (flag) {
|
||||||
|
case 1 : {
|
||||||
|
SendLogMsg("Saved setting file <b>" + settingFile + "</b>.");
|
||||||
|
}; break;
|
||||||
|
case 0 : {
|
||||||
|
SendLogMsg("<font style=\"color:red;\"> Fail to write setting file. <b> " + settingFile + " </b></font>");
|
||||||
|
}; break;
|
||||||
|
case -1 : {
|
||||||
|
SendLogMsg("<font style=\"color:red;\"> Fail to save setting file <b> " + settingFile + " </b>, same settings are empty.</font>");
|
||||||
|
}; break;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SOLARISpanel::LoadSettings(){
|
void SOLARISpanel::LoadSettings(){
|
||||||
|
for(int i = 0; i < nDigi; i++){
|
||||||
|
|
||||||
|
//*------ search for settings_XXXX.dat
|
||||||
|
QString settingFile = digiSettingPath + "/settings_" + QString::number(digi[i]->GetSerialNumber()) + ".dat";
|
||||||
|
if( digi[i]->LoadSettingsFromFile( settingFile.toStdString().c_str() ) ){
|
||||||
|
SendLogMsg("Found setting file <b>" + settingFile + "</b> and loading. please wait.");
|
||||||
|
digi[i]->SetSettingFileName(settingFile.toStdString());
|
||||||
|
SendLogMsg("done settings.");
|
||||||
|
}else{
|
||||||
|
SendLogMsg("<font style=\"color: red;\">Unable to found setting file <b>" + settingFile + "</b>. </font>");
|
||||||
|
digi[i]->SetSettingFileName("");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -32,6 +32,7 @@ class SOLARISpanel : public QWidget{
|
||||||
public:
|
public:
|
||||||
SOLARISpanel(Digitizer2Gen ** digi,
|
SOLARISpanel(Digitizer2Gen ** digi,
|
||||||
unsigned short nDigi,
|
unsigned short nDigi,
|
||||||
|
QString analysisPath,
|
||||||
std::vector<std::vector<int>> mapping,
|
std::vector<std::vector<int>> mapping,
|
||||||
QStringList detType,
|
QStringList detType,
|
||||||
std::vector<int> detMaxID,
|
std::vector<int> detMaxID,
|
||||||
|
@ -64,13 +65,14 @@ private:
|
||||||
std::vector<int> detMaxID;
|
std::vector<int> detMaxID;
|
||||||
QList<QList<int>> detIDList; // 1-D array of { detID, (Digi << 8 ) + ch}
|
QList<QList<int>> detIDList; // 1-D array of { detID, (Digi << 8 ) + ch}
|
||||||
|
|
||||||
|
QString digiSettingPath;
|
||||||
|
|
||||||
int FindDetTypeID(QList<int> detIDListElement);
|
int FindDetTypeID(QList<int> detIDListElement);
|
||||||
|
|
||||||
RSpinBox * sbCoinTime;
|
RSpinBox * sbCoinTime;
|
||||||
|
|
||||||
QCheckBox * chkAll[MaxDetType][MaxSettingItem]; // checkBox for all setting on that tab;
|
QCheckBox * chkAll[MaxDetType][MaxSettingItem]; // checkBox for all setting on that tab;
|
||||||
|
|
||||||
|
|
||||||
QGroupBox * groupBox[MaxDetType][MaxSettingItem][MaxDetID];
|
QGroupBox * groupBox[MaxDetType][MaxSettingItem][MaxDetID];
|
||||||
|
|
||||||
QLineEdit * leDisplay[MaxSettingItem][MaxNumberOfDigitizer][MaxNumberOfChannel]; // [SettingID][DigiID][ChID]
|
QLineEdit * leDisplay[MaxSettingItem][MaxNumberOfDigitizer][MaxNumberOfChannel]; // [SettingID][DigiID][ChID]
|
||||||
|
|
|
@ -58,7 +58,7 @@ QStringList chToolTip = { "Channel signal delay initialization status (1 = initi
|
||||||
"Time-energy event free space status (1 = time-energy can be written)",
|
"Time-energy event free space status (1 = time-energy can be written)",
|
||||||
"Waveform event free space status (1 = waveform can be written)"};
|
"Waveform event free space status (1 = waveform can be written)"};
|
||||||
|
|
||||||
DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi, QWidget * parent) : QWidget(parent){
|
DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi, QString analysisPath, QWidget * parent) : QWidget(parent){
|
||||||
|
|
||||||
setWindowTitle("Digitizers Settings");
|
setWindowTitle("Digitizers Settings");
|
||||||
setGeometry(0, 0, 1850, 1000);
|
setGeometry(0, 0, 1850, 1000);
|
||||||
|
@ -70,6 +70,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
|
||||||
this->nDigi = MaxNumberOfChannel;
|
this->nDigi = MaxNumberOfChannel;
|
||||||
qDebug() << "Please increase the MaxNumberOfChannel";
|
qDebug() << "Please increase the MaxNumberOfChannel";
|
||||||
}
|
}
|
||||||
|
this->digiSettingPath = analysisPath + "/Settings/";
|
||||||
|
|
||||||
ID = 0;
|
ID = 0;
|
||||||
enableSignalSlot = false;
|
enableSignalSlot = false;
|
||||||
|
@ -1623,8 +1624,11 @@ void DigiSettingsPanel::EnableControl(){
|
||||||
|
|
||||||
void DigiSettingsPanel::SaveSettings(){
|
void DigiSettingsPanel::SaveSettings(){
|
||||||
|
|
||||||
//TODO default file Path
|
//Check path exist
|
||||||
QString filePath = QFileDialog::getSaveFileName(this, "Save Settings File", "", "Data file (*.dat);;Text files (*.txt);;All files (*.*)");
|
QDir dir(digiSettingPath);
|
||||||
|
if( !dir.exists() ) dir.mkpath(".");
|
||||||
|
|
||||||
|
QString filePath = QFileDialog::getSaveFileName(this, "Save Settings File", digiSettingPath, "Data file (*.dat);;Text files (*.txt);;All files (*.*)");
|
||||||
|
|
||||||
if (!filePath.isEmpty()) {
|
if (!filePath.isEmpty()) {
|
||||||
|
|
||||||
|
@ -1641,12 +1645,12 @@ void DigiSettingsPanel::SaveSettings(){
|
||||||
}; break;
|
}; break;
|
||||||
case 0 : {
|
case 0 : {
|
||||||
leSettingFile[ID]->setText("fail to write setting file.");
|
leSettingFile[ID]->setText("fail to write setting file.");
|
||||||
SendLogMsg("<font style=\"color:red;\"> Fail to write setting file.</font>");
|
SendLogMsg("<font style=\"color:red;\"> Fail to write setting file. <b>" + filePath + "</b></font>");
|
||||||
}; break;
|
}; break;
|
||||||
|
|
||||||
case -1 : {
|
case -1 : {
|
||||||
leSettingFile[ID]->setText("fail to save setting file, same settings are empty.");
|
leSettingFile[ID]->setText("fail to save setting file, same settings are empty.");
|
||||||
SendLogMsg("<font style=\"color:red;\"> Fail to save setting file, same settings are empty.</font>");
|
SendLogMsg("<font style=\"color:red;\"> Fail to save setting file <b>" + filePath + "</b>, same settings are empty.</font>");
|
||||||
}; break;
|
}; break;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1656,6 +1660,7 @@ void DigiSettingsPanel::SaveSettings(){
|
||||||
|
|
||||||
void DigiSettingsPanel::LoadSettings(){
|
void DigiSettingsPanel::LoadSettings(){
|
||||||
QFileDialog fileDialog(this);
|
QFileDialog fileDialog(this);
|
||||||
|
fileDialog.setDirectory(digiSettingPath);
|
||||||
fileDialog.setFileMode(QFileDialog::ExistingFile);
|
fileDialog.setFileMode(QFileDialog::ExistingFile);
|
||||||
fileDialog.setNameFilter("Data file (*.dat);;Text file (*.txt);;All file (*.*)");
|
fileDialog.setNameFilter("Data file (*.dat);;Text file (*.txt);;All file (*.*)");
|
||||||
fileDialog.exec();
|
fileDialog.exec();
|
||||||
|
|
|
@ -27,7 +27,7 @@ class DigiSettingsPanel : public QWidget{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi, QWidget * parent = nullptr);
|
DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi, QString analysisPath, QWidget * parent = nullptr);
|
||||||
~DigiSettingsPanel();
|
~DigiSettingsPanel();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -54,6 +54,8 @@ private:
|
||||||
unsigned short nDigi;
|
unsigned short nDigi;
|
||||||
unsigned short ID; // index for digitizer;
|
unsigned short ID; // index for digitizer;
|
||||||
|
|
||||||
|
QString digiSettingPath;
|
||||||
|
|
||||||
//------------ Layout/GroupBox
|
//------------ Layout/GroupBox
|
||||||
QGroupBox * digiBox[MaxNumberOfDigitizer];
|
QGroupBox * digiBox[MaxNumberOfDigitizer];
|
||||||
QGroupBox * VGABox[MaxNumberOfDigitizer];
|
QGroupBox * VGABox[MaxNumberOfDigitizer];
|
||||||
|
|
117
mainwindow.cpp
117
mainwindow.cpp
|
@ -194,9 +194,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
||||||
|
|
||||||
bnStartACQ->setEnabled(true);
|
bnStartACQ->setEnabled(true);
|
||||||
bnStopACQ->setEnabled(false);
|
bnStopACQ->setEnabled(false);
|
||||||
|
bnComment->setEnabled(false);
|
||||||
bnOpenScope->setEnabled(true);
|
bnOpenScope->setEnabled(true);
|
||||||
chkSaveRun->setEnabled(true);
|
chkSaveRun->setEnabled(true);
|
||||||
cbAutoRun->setEnabled(true);
|
if(chkSaveRun->isChecked() ) cbAutoRun->setEnabled(true);
|
||||||
|
|
||||||
if( digiSetting ) digiSetting->EnableControl();
|
if( digiSetting ) digiSetting->EnableControl();
|
||||||
|
|
||||||
|
@ -208,6 +209,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
||||||
leRunComment->setReadOnly(true);
|
leRunComment->setReadOnly(true);
|
||||||
leRunComment->setStyleSheet("background-color: #F3F3F3;");
|
leRunComment->setStyleSheet("background-color: #F3F3F3;");
|
||||||
|
|
||||||
|
bnComment = new QPushButton("Append Comment", this);
|
||||||
|
connect(bnComment, &QPushButton::clicked, this, &MainWindow::AppendComment);
|
||||||
|
bnComment->setEnabled(false);
|
||||||
|
|
||||||
layout2->addWidget(lbRawDataPath, 0, 0);
|
layout2->addWidget(lbRawDataPath, 0, 0);
|
||||||
layout2->addWidget(leRawDataPath, 0, 1, 1, 4);
|
layout2->addWidget(leRawDataPath, 0, 1, 1, 4);
|
||||||
layout2->addWidget(bnOpenScalar, 0, 5);
|
layout2->addWidget(bnOpenScalar, 0, 5);
|
||||||
|
@ -220,7 +225,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
||||||
layout2->addWidget(bnStopACQ, 1, 5);
|
layout2->addWidget(bnStopACQ, 1, 5);
|
||||||
|
|
||||||
layout2->addWidget(lbRunComment, 2, 0);
|
layout2->addWidget(lbRunComment, 2, 0);
|
||||||
layout2->addWidget(leRunComment, 2, 1, 1, 5);
|
layout2->addWidget(leRunComment, 2, 1, 1, 4);
|
||||||
|
layout2->addWidget(bnComment, 2, 5);
|
||||||
|
|
||||||
layout2->setColumnStretch(0, 2);
|
layout2->setColumnStretch(0, 2);
|
||||||
layout2->setColumnStretch(1, 1);
|
layout2->setColumnStretch(1, 1);
|
||||||
|
@ -260,6 +266,16 @@ MainWindow::~MainWindow(){
|
||||||
|
|
||||||
printf("- %s\n", __func__);
|
printf("- %s\n", __func__);
|
||||||
|
|
||||||
|
LogMsg("Closing SOLARIS DAQ.");
|
||||||
|
|
||||||
|
QFile file(analysisPath + "/working/Log_" + QDateTime::currentDateTime().toString("yyyyMMdd_hhmmss") + ".dat");
|
||||||
|
printf("-------- Save log msg to %s\n", file.fileName().toStdString().c_str());
|
||||||
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
QTextStream stream(&file);
|
||||||
|
stream << logInfo->toPlainText();
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
printf("-------- remove %s\n", DAQLockFile);
|
printf("-------- remove %s\n", DAQLockFile);
|
||||||
remove(DAQLockFile);
|
remove(DAQLockFile);
|
||||||
|
|
||||||
|
@ -342,8 +358,8 @@ void MainWindow::StartACQ(){
|
||||||
|
|
||||||
if(result == QDialog::Accepted ){
|
if(result == QDialog::Accepted ){
|
||||||
startComment = lineEdit->text();
|
startComment = lineEdit->text();
|
||||||
if( startComment == "") startComment = "No commet was typed.";
|
if( startComment == "") startComment = "Start Comment: No commet was typed.";
|
||||||
leRunComment->setText(startComment);
|
leRunComment->setText("Start Comment: " + startComment);
|
||||||
}else{
|
}else{
|
||||||
LogMsg("Start Run aborted. ");
|
LogMsg("Start Run aborted. ");
|
||||||
return;
|
return;
|
||||||
|
@ -371,6 +387,7 @@ void MainWindow::StartACQ(){
|
||||||
//============================= start digitizer
|
//============================= start digitizer
|
||||||
for( int i = 0 ; i < nDigi; i ++){
|
for( int i = 0 ; i < nDigi; i ++){
|
||||||
if( digi[i]->IsDummy () ) continue;
|
if( digi[i]->IsDummy () ) continue;
|
||||||
|
|
||||||
for( int ch = 0; ch < (int) digi[i]->GetNChannels(); ch ++) oldTimeStamp[i][ch] = 0;
|
for( int ch = 0; ch < (int) digi[i]->GetNChannels(); ch ++) oldTimeStamp[i][ch] = 0;
|
||||||
|
|
||||||
digi[i]->SetPHADataFormat(1);// only save 1 trace
|
digi[i]->SetPHADataFormat(1);// only save 1 trace
|
||||||
|
@ -378,8 +395,13 @@ void MainWindow::StartACQ(){
|
||||||
//Additional settings
|
//Additional settings
|
||||||
digi[i]->WriteValue("/ch/0..63/par/WaveAnalogProbe0", "ADCInput");
|
digi[i]->WriteValue("/ch/0..63/par/WaveAnalogProbe0", "ADCInput");
|
||||||
|
|
||||||
|
|
||||||
if( chkSaveRun->isChecked() ){
|
if( chkSaveRun->isChecked() ){
|
||||||
QString outFileName = rawDataFolder + "/" + expName + "_" + runIDStr+ "_" + QString::number(digi[i]->GetSerialNumber());
|
//Save setting to raw data with run ID
|
||||||
|
QString fileSetting = rawDataFolder + "/" + expName + "_" + runIDStr + "XSetting_" + QString::number(digi[i]->GetSerialNumber()) + ".dat";
|
||||||
|
digi[i]->SaveSettingsToFile(fileSetting.toStdString().c_str());
|
||||||
|
|
||||||
|
QString outFileName = rawDataFolder + "/" + expName + "_" + runIDStr + "_" + QString::number(digi[i]->GetSerialNumber());
|
||||||
qDebug() << outFileName;
|
qDebug() << outFileName;
|
||||||
digi[i]->OpenOutFile(outFileName.toStdString());// overwrite
|
digi[i]->OpenOutFile(outFileName.toStdString());// overwrite
|
||||||
}
|
}
|
||||||
|
@ -434,8 +456,8 @@ void MainWindow::StopACQ(){
|
||||||
|
|
||||||
if(result == QDialog::Accepted ){
|
if(result == QDialog::Accepted ){
|
||||||
stopComment = lineEdit->text();
|
stopComment = lineEdit->text();
|
||||||
if( stopComment == "") stopComment = "No commet was typed.";
|
if( stopComment == "") stopComment = "Stop Comment: No commet was typed.";
|
||||||
leRunComment->setText(stopComment);
|
leRunComment->setText("Stop Comment: " + stopComment);
|
||||||
}else{
|
}else{
|
||||||
LogMsg("Cancel Run aborted. ");
|
LogMsg("Cancel Run aborted. ");
|
||||||
return;
|
return;
|
||||||
|
@ -503,6 +525,7 @@ void MainWindow::AutoRun(){
|
||||||
StartACQ();
|
StartACQ();
|
||||||
bnStartACQ->setEnabled(false);
|
bnStartACQ->setEnabled(false);
|
||||||
bnStopACQ->setEnabled(true);
|
bnStopACQ->setEnabled(true);
|
||||||
|
bnComment->setEnabled(false);
|
||||||
bnOpenScope->setEnabled(false);
|
bnOpenScope->setEnabled(false);
|
||||||
chkSaveRun->setEnabled(false);
|
chkSaveRun->setEnabled(false);
|
||||||
cbAutoRun->setEnabled(false);
|
cbAutoRun->setEnabled(false);
|
||||||
|
@ -524,6 +547,7 @@ void MainWindow::AutoRun(){
|
||||||
if( cbAutoRun->currentData().toInt() > 0 ) {
|
if( cbAutoRun->currentData().toInt() > 0 ) {
|
||||||
bnStartACQ->setEnabled(true);
|
bnStartACQ->setEnabled(true);
|
||||||
bnStopACQ->setEnabled(false);
|
bnStopACQ->setEnabled(false);
|
||||||
|
bnComment->setEnabled(false);
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
StartACQ();
|
StartACQ();
|
||||||
|
@ -550,6 +574,7 @@ void MainWindow::AutoRun(){
|
||||||
|
|
||||||
bnStartACQ->setEnabled(false);
|
bnStartACQ->setEnabled(false);
|
||||||
bnStopACQ->setEnabled(true);
|
bnStopACQ->setEnabled(true);
|
||||||
|
if(chkSaveRun->isChecked()) bnComment->setEnabled(true);
|
||||||
bnOpenScope->setEnabled(false);
|
bnOpenScope->setEnabled(false);
|
||||||
chkSaveRun->setEnabled(false);
|
chkSaveRun->setEnabled(false);
|
||||||
cbAutoRun->setEnabled(false);
|
cbAutoRun->setEnabled(false);
|
||||||
|
@ -567,6 +592,10 @@ void MainWindow::OpenDigitizers(){
|
||||||
|
|
||||||
int nDigiConnected = 0;
|
int nDigiConnected = 0;
|
||||||
|
|
||||||
|
//Check path exist
|
||||||
|
QDir dir(analysisPath + "/Settings/");
|
||||||
|
if( !dir.exists() ) dir.mkpath(".");
|
||||||
|
|
||||||
for( int i = 0; i < nDigi; i++){
|
for( int i = 0; i < nDigi; i++){
|
||||||
|
|
||||||
LogMsg("IP : " + IPList[i] + " | " + QString::number(i+1) + "/" + QString::number(nDigi));
|
LogMsg("IP : " + IPList[i] + " | " + QString::number(i+1) + "/" + QString::number(nDigi));
|
||||||
|
@ -580,11 +609,9 @@ void MainWindow::OpenDigitizers(){
|
||||||
|
|
||||||
readDataThread[i] = new ReadDataThread(digi[i], i, this);
|
readDataThread[i] = new ReadDataThread(digi[i], i, this);
|
||||||
connect(readDataThread[i], &ReadDataThread::sendMsg, this, &MainWindow::LogMsg);
|
connect(readDataThread[i], &ReadDataThread::sendMsg, this, &MainWindow::LogMsg);
|
||||||
//connect(readDataThread[i], &ReadDataThread::checkFileSize, this, &MainWindow::CheckOutFileSize);
|
|
||||||
//connect(readDataThread[i], &ReadDataThread::endOfLastData, this, &MainWindow::CheckOutFileSize);
|
|
||||||
|
|
||||||
//*------ search for settings_XXXX.dat
|
//*------ search for settings_XXXX.dat
|
||||||
QString settingFile = analysisPath + "/settings_" + QString::number(digi[i]->GetSerialNumber()) + ".dat";
|
QString settingFile = analysisPath + "/Settings/setting_" + QString::number(digi[i]->GetSerialNumber()) + ".dat";
|
||||||
if( digi[i]->LoadSettingsFromFile( settingFile.toStdString().c_str() ) ){
|
if( digi[i]->LoadSettingsFromFile( settingFile.toStdString().c_str() ) ){
|
||||||
LogMsg("Found setting file <b>" + settingFile + "</b> and loading. please wait.");
|
LogMsg("Found setting file <b>" + settingFile + "</b> and loading. please wait.");
|
||||||
digi[i]->SetSettingFileName(settingFile.toStdString());
|
digi[i]->SetSettingFileName(settingFile.toStdString());
|
||||||
|
@ -618,6 +645,7 @@ void MainWindow::OpenDigitizers(){
|
||||||
SetUpScalar();
|
SetUpScalar();
|
||||||
bnStartACQ->setEnabled(true);
|
bnStartACQ->setEnabled(true);
|
||||||
bnStopACQ->setEnabled(false);
|
bnStopACQ->setEnabled(false);
|
||||||
|
bnComment->setEnabled(false);
|
||||||
bnOpenScope->setEnabled(true);
|
bnOpenScope->setEnabled(true);
|
||||||
chkSaveRun->setEnabled(true);
|
chkSaveRun->setEnabled(true);
|
||||||
bnOpenDigitizers->setEnabled(false);
|
bnOpenDigitizers->setEnabled(false);
|
||||||
|
@ -692,6 +720,7 @@ void MainWindow::CloseDigitizers(){
|
||||||
bnSOLSettings->setEnabled(false);
|
bnSOLSettings->setEnabled(false);
|
||||||
bnStartACQ->setEnabled(false);
|
bnStartACQ->setEnabled(false);
|
||||||
bnStopACQ->setEnabled(false);
|
bnStopACQ->setEnabled(false);
|
||||||
|
bnComment->setEnabled(false);
|
||||||
bnOpenScope->setEnabled(false);
|
bnOpenScope->setEnabled(false);
|
||||||
bnOpenScalar->setEnabled(false);
|
bnOpenScalar->setEnabled(false);
|
||||||
chkSaveRun->setEnabled(false);
|
chkSaveRun->setEnabled(false);
|
||||||
|
@ -745,7 +774,7 @@ void MainWindow::OpenDigitizersSettings(){
|
||||||
LogMsg("Open digitizers Settings Panel");
|
LogMsg("Open digitizers Settings Panel");
|
||||||
|
|
||||||
if( digiSetting == NULL){
|
if( digiSetting == NULL){
|
||||||
digiSetting = new DigiSettingsPanel(digi, nDigi);
|
digiSetting = new DigiSettingsPanel(digi, nDigi, analysisPath);
|
||||||
connect(digiSetting, &DigiSettingsPanel::SendLogMsg, this, &MainWindow::LogMsg);
|
connect(digiSetting, &DigiSettingsPanel::SendLogMsg, this, &MainWindow::LogMsg);
|
||||||
connect(digiSetting, &DigiSettingsPanel::UpdateOtherPanels, this, [=](){ UpdateAllPanel(1);});
|
connect(digiSetting, &DigiSettingsPanel::UpdateOtherPanels, this, [=](){ UpdateAllPanel(1);});
|
||||||
|
|
||||||
|
@ -757,15 +786,16 @@ void MainWindow::OpenDigitizersSettings(){
|
||||||
|
|
||||||
//^###################################################################### Open SOLARIS setting panel
|
//^###################################################################### Open SOLARIS setting panel
|
||||||
void MainWindow::OpenSOLARISpanel(){
|
void MainWindow::OpenSOLARISpanel(){
|
||||||
|
LogMsg("Open SOLARIS Panel.");
|
||||||
solarisSetting->show();
|
solarisSetting->show();
|
||||||
solarisSetting->UpdatePanelFromMemory();
|
solarisSetting->UpdatePanelFromMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MainWindow::CheckSOLARISpanelOK(){
|
bool MainWindow::CheckSOLARISpanelOK(){
|
||||||
|
|
||||||
QFile file(analysisPath + "/Mapping.h");
|
QFile file(analysisPath + "/working/Mapping.h");
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
LogMsg("Fail to open <b>" + analysisPath + "/Mapping.h </b>. SOLARIS panel disabled.");
|
LogMsg("Fail to open <b>" + file.fileName() + "</b>. SOLARIS panel disabled.");
|
||||||
|
|
||||||
//TODO ----- Create a template of the mapping
|
//TODO ----- Create a template of the mapping
|
||||||
|
|
||||||
|
@ -848,7 +878,7 @@ bool MainWindow::CheckSOLARISpanelOK(){
|
||||||
}
|
}
|
||||||
|
|
||||||
//@============= Create SOLAIRS panel
|
//@============= Create SOLAIRS panel
|
||||||
solarisSetting = new SOLARISpanel(digi, nDigi, mapping, detType, detMaxID);
|
solarisSetting = new SOLARISpanel(digi, nDigi, analysisPath, mapping, detType, detMaxID);
|
||||||
connect(solarisSetting, &SOLARISpanel::SendLogMsg, this, &MainWindow::LogMsg);
|
connect(solarisSetting, &SOLARISpanel::SendLogMsg, this, &MainWindow::LogMsg);
|
||||||
connect(solarisSetting, &SOLARISpanel::UpdateOtherPanels, this, [=](){ UpdateAllPanel(2);});
|
connect(solarisSetting, &SOLARISpanel::UpdateOtherPanels, this, [=](){ UpdateAllPanel(2);});
|
||||||
|
|
||||||
|
@ -1601,7 +1631,7 @@ bool MainWindow::LoadExpSettings(){
|
||||||
|
|
||||||
if( analysisPath == "") return false;
|
if( analysisPath == "") return false;
|
||||||
|
|
||||||
QString settingFile = analysisPath + "/expName.sh";
|
QString settingFile = analysisPath + "/working/expName.sh";
|
||||||
|
|
||||||
LogMsg("Loading <b>" + settingFile + "</b> for Experiment.");
|
LogMsg("Loading <b>" + settingFile + "</b> for Experiment.");
|
||||||
|
|
||||||
|
@ -1723,8 +1753,12 @@ void MainWindow::ChangeExperiment(const QString newExpName){
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::WriteExpNameSh(){
|
void MainWindow::WriteExpNameSh(){
|
||||||
|
|
||||||
|
QDir dir(analysisPath + "/working/");
|
||||||
|
if( !dir.exists() ) dir.mkpath(".");
|
||||||
|
|
||||||
//----- create the expName.sh
|
//----- create the expName.sh
|
||||||
QFile file2(analysisPath + "/expName.sh");
|
QFile file2(analysisPath + "/working/expName.sh");
|
||||||
|
|
||||||
file2.open(QIODevice::Text | QIODevice::WriteOnly);
|
file2.open(QIODevice::Text | QIODevice::WriteOnly);
|
||||||
file2.write(("expName="+ expName + "\n").toStdString().c_str());
|
file2.write(("expName="+ expName + "\n").toStdString().c_str());
|
||||||
|
@ -1733,7 +1767,7 @@ void MainWindow::WriteExpNameSh(){
|
||||||
file2.write(("elogID="+std::to_string(elogID)+"\n").c_str());
|
file2.write(("elogID="+std::to_string(elogID)+"\n").c_str());
|
||||||
file2.write("//------------end of file.");
|
file2.write("//------------end of file.");
|
||||||
file2.close();
|
file2.close();
|
||||||
LogMsg("Saved expName.sh to <b>"+ analysisPath + "/expName.sh<b>.");
|
LogMsg("Saved expName.sh to <b>"+ analysisPath + "/working/expName.sh<b>.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1899,3 +1933,52 @@ void MainWindow::WriteRunTimeStampDat(bool isStartRun){
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::AppendComment(){
|
||||||
|
|
||||||
|
//if Started ACQ, append Comment, if ACQ stopped, disbale
|
||||||
|
|
||||||
|
if( !chkSaveRun->isChecked() ) return;
|
||||||
|
|
||||||
|
QDialog * dOpen = new QDialog(this);
|
||||||
|
dOpen->setWindowTitle("Append Run Comment");
|
||||||
|
dOpen->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
|
||||||
|
dOpen->setMinimumWidth(600);
|
||||||
|
connect(dOpen, &QDialog::finished, dOpen, &QDialog::deleteLater);
|
||||||
|
|
||||||
|
QGridLayout * vlayout = new QGridLayout(dOpen);
|
||||||
|
QLabel *label = new QLabel("Enter Append Run comment for <font style=\"color : red;\">Run-" + runIDStr + "</font> : ", dOpen);
|
||||||
|
QLineEdit *lineEdit = new QLineEdit(dOpen);
|
||||||
|
QPushButton *button1 = new QPushButton("OK", dOpen);
|
||||||
|
QPushButton *button2 = new QPushButton("Cancel", dOpen);
|
||||||
|
|
||||||
|
vlayout->addWidget(label, 0, 0, 1, 2);
|
||||||
|
vlayout->addWidget(lineEdit, 1, 0, 1, 2);
|
||||||
|
vlayout->addWidget(button1, 2, 0);
|
||||||
|
vlayout->addWidget(button2, 2, 1);
|
||||||
|
|
||||||
|
connect(button1, &QPushButton::clicked, dOpen, &QDialog::accept);
|
||||||
|
connect(button2, &QPushButton::clicked, dOpen, &QDialog::reject);
|
||||||
|
int result = dOpen->exec();
|
||||||
|
|
||||||
|
if(result == QDialog::Accepted ){
|
||||||
|
appendComment = lineEdit->text();
|
||||||
|
if( appendComment == "") return;
|
||||||
|
|
||||||
|
appendComment = QDateTime::currentDateTime().toString("[MM.dd hh:mm:ss]") + appendComment;
|
||||||
|
|
||||||
|
AppendElog(appendComment);
|
||||||
|
|
||||||
|
leRunComment->setText("Append Comment: " + appendComment);
|
||||||
|
|
||||||
|
if( influx ){
|
||||||
|
influx->ClearDataPointsBuffer();
|
||||||
|
influx->AddDataPoint("RunID,start=1 value=" + std::to_string(runID) + ",expName=\"" + expName.toStdString()+ + "\",comment=\"" + appendComment.replace(' ', '_').toStdString() + "\"");
|
||||||
|
influx->WriteData(DatabaseName.toStdString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -135,6 +135,7 @@ private:
|
||||||
ReadDataThread ** readDataThread;
|
ReadDataThread ** readDataThread;
|
||||||
QString startComment;
|
QString startComment;
|
||||||
QString stopComment;
|
QString stopComment;
|
||||||
|
QString appendComment;
|
||||||
bool needManualComment;
|
bool needManualComment;
|
||||||
bool isRunning;
|
bool isRunning;
|
||||||
QTimer * runTimer;
|
QTimer * runTimer;
|
||||||
|
@ -184,6 +185,9 @@ private:
|
||||||
//@------ connection between pannels
|
//@------ connection between pannels
|
||||||
void UpdateAllPanel(int panelID);
|
void UpdateAllPanel(int panelID);
|
||||||
|
|
||||||
|
//@------ custom comment;
|
||||||
|
QPushButton * bnComment;
|
||||||
|
void AppendComment();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,10 @@
|
||||||
Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow *parent) : QMainWindow(parent){
|
Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow *parent) : QMainWindow(parent){
|
||||||
this->digi = digi;
|
this->digi = digi;
|
||||||
this->nDigi = nDigi;
|
this->nDigi = nDigi;
|
||||||
|
if( nDigi > MaxNumberOfDigitizer ) {
|
||||||
|
this->nDigi = MaxNumberOfChannel;
|
||||||
|
qDebug() << "Please increase the MaxNumberOfChannel";
|
||||||
|
}
|
||||||
this->readDataThread = readDataThread;
|
this->readDataThread = readDataThread;
|
||||||
|
|
||||||
setWindowTitle("Scope");
|
setWindowTitle("Scope");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user