chaneg the way to open digitizer, provide option to load settings, fix Single SPrectrum bug

This commit is contained in:
carina@hades 2023-10-26 17:57:06 -04:00
parent b1d0253e4f
commit 05cf434d6e
5 changed files with 70 additions and 19 deletions

View File

@ -504,7 +504,12 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){
unsigned long long t0 = Timestamp[ch][(calIndexes[ch][0]) % MaxNData]; // earlier unsigned long long t0 = Timestamp[ch][(calIndexes[ch][0]) % MaxNData]; // earlier
unsigned long long t1 = Timestamp[ch][(calIndexes[ch][1]) % MaxNData];; // latest unsigned long long t1 = Timestamp[ch][(calIndexes[ch][1]) % MaxNData];; // latest
if( t0 > t1 ) printf("data is not in time order"); if( t0 > t1 ) {
printf("digi-%d, ch-%d | data is not in time order\n", boardSN, ch);
unsigned long long tt = t1;
t1 = t0;
t0 = tt;
}
double sec = ( t1 - t0 ) * tick2ns / 1e9; double sec = ( t1 - t0 ) * tick2ns / 1e9;

View File

@ -50,9 +50,16 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
layoutMain->addWidget(box); layoutMain->addWidget(box);
QGridLayout * layout = new QGridLayout(box); QGridLayout * layout = new QGridLayout(box);
bnOpenDigitizers = new QPushButton("Open Digitizers", this); cbOpenDigitizers = new RComboBox(this);
layout->addWidget(bnOpenDigitizers, 0, 0); cbOpenDigitizers->addItem("Open Digitizers ... ", 0);
connect(bnOpenDigitizers, &QPushButton::clicked, this, &MainWindow::OpenDigitizers); cbOpenDigitizers->addItem("Open Digitizers w/o load Settings", 1);
cbOpenDigitizers->addItem("Open Digitizers + load Settings", 2);
layout->addWidget(cbOpenDigitizers, 0, 0);
connect(cbOpenDigitizers, &RComboBox::currentIndexChanged, this, &MainWindow::OpenDigitizers);
// bnOpenDigitizers = new QPushButton("Open Digitizers", this);
// layout->addWidget(bnOpenDigitizers, 0, 0);
// connect(bnOpenDigitizers, &QPushButton::clicked, this, &MainWindow::OpenDigitizers);
bnCloseDigitizers = new QPushButton("Close Digitizers", this); bnCloseDigitizers = new QPushButton("Close Digitizers", this);
layout->addWidget(bnCloseDigitizers, 1, 0); layout->addWidget(bnCloseDigitizers, 1, 0);
@ -594,6 +601,8 @@ void MainWindow::SaveLastRunFile(){
//*************************************************************** //***************************************************************
void MainWindow::OpenDigitizers(){ void MainWindow::OpenDigitizers(){
if( cbOpenDigitizers->currentIndex() == 0 ) return;
//sereach for digitizers //sereach for digitizers
LogMsg("Searching digitizers via optical link or USB .....Please wait"); LogMsg("Searching digitizers via optical link or USB .....Please wait");
logMsgHTMLMode = false; logMsgHTMLMode = false;
@ -620,11 +629,17 @@ void MainWindow::OpenDigitizers(){
LogMsg(QString("Done seraching. No digitizer found.")); LogMsg(QString("Done seraching. No digitizer found."));
return; return;
}else{ }else{
LogMsg(QString("Done seraching. Found %1 digitizer(s). Opening digitizer(s)....").arg(nDigi));
if( cbOpenDigitizers->currentIndex() == 1 ) {
LogMsg(QString("Done seraching. Found %1 digitizer(s). Opening digitizer(s)....").arg(nDigi));
}else{
LogMsg(QString("Done seraching. Found %1 digitizer(s). Opening digitizer(s) and load settings....").arg(nDigi));
}
} }
digi = new Digitizer * [nDigi]; digi = new Digitizer * [nDigi];
readDataThread = new ReadDataThread * [nDigi]; readDataThread = new ReadDataThread * [nDigi];
for( unsigned int i = 0; i < nDigi; i++){ for( unsigned int i = 0; i < nDigi; i++){
digi[i] = new Digitizer(portList[i].first, portList[i].second); digi[i] = new Digitizer(portList[i].first, portList[i].second);
//digi[i]->Reset(); //digi[i]->Reset();
@ -654,14 +669,14 @@ void MainWindow::OpenDigitizers(){
}else{ }else{
LogMsg("Found <b>" + fileName + "</b> for digitizer settings."); LogMsg("Found <b>" + fileName + "</b> for digitizer settings.");
if( cbOpenDigitizers->currentIndex() == 2 ) {
// if( digi[i]->LoadSettingBinaryToMemory(fileName.toStdString().c_str()) == 0 ){ if( digi[i]->LoadSettingBinaryToMemory(fileName.toStdString().c_str()) == 0 ){
// LogMsg("Loaded settings file <b>" + fileName + "</b> for Digi-" + QString::number(digi[i]->GetSerialNumber())); LogMsg("Loaded settings file <b>" + fileName + "</b> for Digi-" + QString::number(digi[i]->GetSerialNumber()));
// digi[i]->ProgramSettingsToBoard(); digi[i]->ProgramSettingsToBoard();
}else{
// }else{ LogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber()));
// LogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber())); }
// } }
} }
digi[i]->ReadAllSettingsFromBoard(true); digi[i]->ReadAllSettingsFromBoard(true);
@ -695,7 +710,9 @@ void MainWindow::OpenDigitizers(){
SetupScalar(); SetupScalar();
} cbOpenDigitizers->setCurrentIndex(0);
}
void MainWindow::CloseDigitizers(){ void MainWindow::CloseDigitizers(){
@ -767,7 +784,10 @@ void MainWindow::CloseDigitizers(){
void MainWindow::WaitForDigitizersOpen(bool onOff){ void MainWindow::WaitForDigitizersOpen(bool onOff){
bnOpenDigitizers->setEnabled(onOff); // bnOpenDigitizers->setEnabled(onOff);
cbOpenDigitizers->setEnabled(onOff);
bnCloseDigitizers->setEnabled(!onOff); bnCloseDigitizers->setEnabled(!onOff);
bnOpenScope->setEnabled(!onOff); bnOpenScope->setEnabled(!onOff);
bnDigiSettings->setEnabled(!onOff); bnDigiSettings->setEnabled(!onOff);

View File

@ -102,7 +102,9 @@ private:
unsigned int runID; unsigned int runID;
int elogID; int elogID;
QPushButton * bnOpenDigitizers; RComboBox * cbOpenDigitizers;
//QPushButton * bnOpenDigitizers;
QPushButton * bnCloseDigitizers; QPushButton * bnCloseDigitizers;
QPushButton * bnOpenScope; QPushButton * bnOpenScope;
QPushButton * bnDigiSettings; QPushButton * bnDigiSettings;

View File

@ -13,6 +13,8 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
this->nDigi = nDigi; this->nDigi = nDigi;
this->rawDataPath = rawDataPath; this->rawDataPath = rawDataPath;
isSignalSlotActive = true;
setWindowTitle("1-D Histograms"); setWindowTitle("1-D Histograms");
setGeometry(0, 0, 1000, 800); setGeometry(0, 0, 1000, 800);
//setWindowFlags( this->windowFlags() & ~Qt::WindowCloseButtonHint ); //setWindowFlags( this->windowFlags() & ~Qt::WindowCloseButtonHint );
@ -31,10 +33,28 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
cbDigi = new RComboBox(this); cbDigi = new RComboBox(this);
for( unsigned int i = 0; i < nDigi; i++) cbDigi->addItem("Digi-" + QString::number( digi[i]->GetSerialNumber() ), i); for( unsigned int i = 0; i < nDigi; i++) cbDigi->addItem("Digi-" + QString::number( digi[i]->GetSerialNumber() ), i);
ctrlLayout->addWidget(cbDigi, 0, 0, 1, 2); ctrlLayout->addWidget(cbDigi, 0, 0, 1, 2);
connect( cbDigi, &RComboBox::currentIndexChanged, this, &SingleSpectra::ChangeHistView); connect( cbDigi, &RComboBox::currentIndexChanged, this, [=](int index){
isSignalSlotActive = false;
cbCh->clear();
for( int i = 0; i < digi[index]->GetNumInputCh(); i++) cbCh->addItem("ch-" + QString::number( i ), i);
isSignalSlotActive = true;
if( oldCh >= digi[index]->GetNumInputCh()) {
cbCh->setCurrentIndex(0);
}else{
if( oldCh >= 0 ){
cbCh->setCurrentIndex(oldCh);
}else{
cbCh->setCurrentIndex(0);
}
}
ChangeHistView();
});
cbCh = new RComboBox(this); cbCh = new RComboBox(this);
for( int i = 0; i < MaxRegChannel; i++) cbCh->addItem("ch-" + QString::number( i ), i); for( int i = 0; i < digi[0]->GetNumInputCh(); i++) cbCh->addItem("ch-" + QString::number( i ), i);
ctrlLayout->addWidget(cbCh, 0, 2, 1, 2); ctrlLayout->addWidget(cbCh, 0, 2, 1, 2);
connect( cbCh, &RComboBox::currentIndexChanged, this, &SingleSpectra::ChangeHistView); connect( cbCh, &RComboBox::currentIndexChanged, this, &SingleSpectra::ChangeHistView);
@ -42,7 +62,7 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
ctrlLayout->addWidget(bnClearHist, 0, 4, 1, 2); ctrlLayout->addWidget(bnClearHist, 0, 4, 1, 2);
connect(bnClearHist, &QPushButton::clicked, this, [=](){ connect(bnClearHist, &QPushButton::clicked, this, [=](){
for( unsigned int i = 0; i < nDigi; i++){ for( unsigned int i = 0; i < nDigi; i++){
for( int j = 0; j < MaxRegChannel; j++){ for( int j = 0; j < digi[i]->GetNumInputCh(); j++){
if( hist[i][j] ) hist[i][j]->Clear(); if( hist[i][j] ) hist[i][j]->Clear();
lastFilledIndex[i][j] = -1; lastFilledIndex[i][j] = -1;
loopFilledIndex[i][j] = 0; loopFilledIndex[i][j] = 0;
@ -116,6 +136,8 @@ void SingleSpectra::ClearInternalDataCount(){
void SingleSpectra::ChangeHistView(){ void SingleSpectra::ChangeHistView(){
if( !isSignalSlotActive ) return;
if( oldCh >= 0 ) { if( oldCh >= 0 ) {
histLayout->removeWidget(hist[oldBd][oldCh]); histLayout->removeWidget(hist[oldBd][oldCh]);
hist[oldBd][oldCh]->setParent(nullptr); hist[oldBd][oldCh]->setParent(nullptr);

View File

@ -61,5 +61,7 @@ private:
QString rawDataPath; QString rawDataPath;
bool isSignalSlotActive;
}; };
#endif #endif