diff --git a/ClassData.h b/ClassData.h
index 358d0fe..ad84196 100644
--- a/ClassData.h
+++ b/ClassData.h
@@ -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 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;
diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp
index 4a861f6..f99e917 100644
--- a/FSUDAQ.cpp
+++ b/FSUDAQ.cpp
@@ -50,9 +50,16 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
layoutMain->addWidget(box);
QGridLayout * layout = new QGridLayout(box);
- bnOpenDigitizers = new QPushButton("Open Digitizers", this);
- layout->addWidget(bnOpenDigitizers, 0, 0);
- connect(bnOpenDigitizers, &QPushButton::clicked, this, &MainWindow::OpenDigitizers);
+ cbOpenDigitizers = new RComboBox(this);
+ cbOpenDigitizers->addItem("Open Digitizers ... ", 0);
+ 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);
layout->addWidget(bnCloseDigitizers, 1, 0);
@@ -594,6 +601,8 @@ void MainWindow::SaveLastRunFile(){
//***************************************************************
void MainWindow::OpenDigitizers(){
+ if( cbOpenDigitizers->currentIndex() == 0 ) return;
+
//sereach for digitizers
LogMsg("Searching digitizers via optical link or USB .....Please wait");
logMsgHTMLMode = false;
@@ -620,11 +629,17 @@ void MainWindow::OpenDigitizers(){
LogMsg(QString("Done seraching. No digitizer found."));
return;
}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];
readDataThread = new ReadDataThread * [nDigi];
+
for( unsigned int i = 0; i < nDigi; i++){
digi[i] = new Digitizer(portList[i].first, portList[i].second);
//digi[i]->Reset();
@@ -654,14 +669,14 @@ void MainWindow::OpenDigitizers(){
}else{
LogMsg("Found " + fileName + " for digitizer settings.");
-
- // if( digi[i]->LoadSettingBinaryToMemory(fileName.toStdString().c_str()) == 0 ){
- // LogMsg("Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber()));
- // digi[i]->ProgramSettingsToBoard();
-
- // }else{
- // LogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber()));
- // }
+ if( cbOpenDigitizers->currentIndex() == 2 ) {
+ if( digi[i]->LoadSettingBinaryToMemory(fileName.toStdString().c_str()) == 0 ){
+ LogMsg("Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber()));
+ digi[i]->ProgramSettingsToBoard();
+ }else{
+ LogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[i]->GetSerialNumber()));
+ }
+ }
}
digi[i]->ReadAllSettingsFromBoard(true);
@@ -695,7 +710,9 @@ void MainWindow::OpenDigitizers(){
SetupScalar();
- }
+ cbOpenDigitizers->setCurrentIndex(0);
+
+}
void MainWindow::CloseDigitizers(){
@@ -767,7 +784,10 @@ void MainWindow::CloseDigitizers(){
void MainWindow::WaitForDigitizersOpen(bool onOff){
- bnOpenDigitizers->setEnabled(onOff);
+ // bnOpenDigitizers->setEnabled(onOff);
+
+ cbOpenDigitizers->setEnabled(onOff);
+
bnCloseDigitizers->setEnabled(!onOff);
bnOpenScope->setEnabled(!onOff);
bnDigiSettings->setEnabled(!onOff);
diff --git a/FSUDAQ.h b/FSUDAQ.h
index 3138f80..e6d5a73 100644
--- a/FSUDAQ.h
+++ b/FSUDAQ.h
@@ -102,7 +102,9 @@ private:
unsigned int runID;
int elogID;
- QPushButton * bnOpenDigitizers;
+ RComboBox * cbOpenDigitizers;
+
+ //QPushButton * bnOpenDigitizers;
QPushButton * bnCloseDigitizers;
QPushButton * bnOpenScope;
QPushButton * bnDigiSettings;
diff --git a/SingleSpectra.cpp b/SingleSpectra.cpp
index 2fb52fc..abbc54a 100644
--- a/SingleSpectra.cpp
+++ b/SingleSpectra.cpp
@@ -13,6 +13,8 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
this->nDigi = nDigi;
this->rawDataPath = rawDataPath;
+ isSignalSlotActive = true;
+
setWindowTitle("1-D Histograms");
setGeometry(0, 0, 1000, 800);
//setWindowFlags( this->windowFlags() & ~Qt::WindowCloseButtonHint );
@@ -31,10 +33,28 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD
cbDigi = new RComboBox(this);
for( unsigned int i = 0; i < nDigi; i++) cbDigi->addItem("Digi-" + QString::number( digi[i]->GetSerialNumber() ), i);
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);
- 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);
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);
connect(bnClearHist, &QPushButton::clicked, this, [=](){
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();
lastFilledIndex[i][j] = -1;
loopFilledIndex[i][j] = 0;
@@ -116,6 +136,8 @@ void SingleSpectra::ClearInternalDataCount(){
void SingleSpectra::ChangeHistView(){
+ if( !isSignalSlotActive ) return;
+
if( oldCh >= 0 ) {
histLayout->removeWidget(hist[oldBd][oldCh]);
hist[oldBd][oldCh]->setParent(nullptr);
diff --git a/SingleSpectra.h b/SingleSpectra.h
index 95fec55..cc0e4b6 100644
--- a/SingleSpectra.h
+++ b/SingleSpectra.h
@@ -61,5 +61,7 @@ private:
QString rawDataPath;
+ bool isSignalSlotActive;
+
};
#endif
\ No newline at end of file