From 38f6cc41cb7f07de904a522116431a8ce08cdfd6 Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS-DAQ" Date: Thu, 23 Mar 2023 16:36:47 -0400 Subject: [PATCH] use a dumb way to solve the pointer problem in SOLARIS Panel --- SOLARISpanel.cpp | 110 ++++++++++++------------------------------ SOLARISpanel.h | 21 ++++---- digiSettingsPanel.cpp | 57 +++++++++++----------- digiSettingsPanel.h | 2 +- mainwindow.cpp | 85 +++++++++++++++++++++++--------- mainwindow.h | 4 ++ scope.cpp | 10 ++-- scope.h | 2 +- 8 files changed, 143 insertions(+), 148 deletions(-) diff --git a/SOLARISpanel.cpp b/SOLARISpanel.cpp index 50bce5e..8337633 100644 --- a/SOLARISpanel.cpp +++ b/SOLARISpanel.cpp @@ -28,13 +28,6 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi, this->detType = detType; this->detMaxID = detMaxID; - nDigiMapping = mapping.size(); - for( int i = 0; i < nDigiMapping; i++) { - int count = 0; - for( int j = 0; j < (int )mapping[i].size(); j++) if( mapping[i][j] >= 0) count ++; - nChMapping.push_back(count); - } - //Check number of detector type; Array 0-199, Recoil 200-299, other 300- int nDetType = detType.size(); for( int k = 0 ; k < nDetType; k++) nDet.push_back(0); @@ -42,7 +35,7 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi, QList> detIDListTemp; // store { detID, (Digi << 8 ) + ch}, making mapping into 1-D array to be consolidated printf("################################# \n"); - for( int i = 0; i < nDigiMapping ; i++){ + for( int i = 0; i < (int) mapping.size() ; i++){ for( int j = 0; j < (int) mapping[i].size(); j++ ){ printf("%3d,", mapping[i][j]); QList haha ; @@ -88,8 +81,6 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi, return a.at(0) < b.at(0); }); - - //------------- display detector summary //qDebug() << detIDList; printf("---------- num. of det. Type : %d\n", nDetType); @@ -97,33 +88,6 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi, printf(" Type-%d (%6s) : %3d det. (%3d - %3d)\n", i, detType[i].toStdString().c_str(), nDet[i], (i==0 ? 0 : detMaxID[i-1]), detMaxID[i]-1); } - //------------ create Widgets - leDisplay = new QLineEdit ***[(int) SettingItems.size()]; - sbSetting = new RSpinBox ***[(int) SettingItems.size()]; - chkOnOff = new QCheckBox ***[(int) SettingItems.size()]; - for( int k = 0; k < (int) SettingItems.size() ; k ++){ - leDisplay[k] = new QLineEdit **[nDigiMapping]; - sbSetting[k] = new RSpinBox **[nDigiMapping]; - chkOnOff[k] = new QCheckBox **[nDigiMapping]; - for( int i = 0; i < nDigiMapping; i++){ - leDisplay[k][i] = new QLineEdit *[(int) mapping[i].size()]; - sbSetting[k][i] = new RSpinBox *[(int) mapping[i].size()]; - chkOnOff[k][i] = new QCheckBox *[(int) mapping[i].size()]; - for( int j = 0 ; j < (int) mapping[i].size() ; j++){ - leDisplay[k][i][j] = nullptr; - sbSetting[k][i][j] = nullptr; - chkOnOff[k][i][j] = nullptr; - } - } - } - - cbTrigger = new RComboBox ** [nDetType]; - for(int i = 0; i < nDetType; i++){ - cbTrigger[i] = new RComboBox *[nDet[i]]; /// nDet[0] store the number of det. for the Array - for( int j = 0; j < nDet[i]; j ++){ - cbTrigger[i][j] = nullptr; - } - } //---------- Set Panel QGridLayout * mainLayout = new QGridLayout(this); this->setLayout(mainLayout); @@ -137,17 +101,17 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi, QTabWidget * tabWidget = new QTabWidget(this); mainLayout->addWidget(tabWidget, 1, 0, 1, 5); for( int detTypeID = 0; detTypeID < nDetType; detTypeID ++ ){ - QTabWidget * tab2 = new QTabWidget(tabWidget); - tabWidget->addTab(tab2, detType[detTypeID]); + QTabWidget * tabSetting = new QTabWidget(tabWidget); + tabWidget->addTab(tabSetting, detType[detTypeID]); for( int SettingID = 0; SettingID < (int) SettingItems.size(); SettingID ++){ QScrollArea * scrollArea = new QScrollArea(this); scrollArea->setWidgetResizable(true); scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - tab2->addTab(scrollArea, QString::fromStdString(SettingItems[SettingID])); + tabSetting->addTab(scrollArea, QString::fromStdString(SettingItems[SettingID])); - QWidget * tab = new QWidget(tab2); + QWidget * tab = new QWidget(tabSetting); scrollArea->setWidget(tab); QGridLayout * layout = new QGridLayout(tab); @@ -183,45 +147,19 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi, int lowID = (detTypeID == 0 ? 0 : detMaxID[detTypeID-1]); for(int i = 0; i < detIDList.size(); i++){ + if( detIDList[i][0] >= detMaxID[detTypeID] || lowID > detIDList[i][0] ) continue; CreateDetGroup(SettingID, detIDList[i], layout, i/NCOL + 2, i%NCOL); + } } } - //TODO ========== when digiSettingPanel or Scope change setting, reflect in solarisPanel - - //TODO ========== when tab change, update panel - } SOLARISpanel::~SOLARISpanel(){ - printf("%s\n", __func__); - - for( int k = 0; k < (int) SettingItems.size() ; k ++){ - for( int i = 0; i < nDigiMapping; i++){ - delete [] leDisplay[k][i] ; - delete [] sbSetting[k][i] ; - delete [] chkOnOff[k][i] ; - } - delete [] leDisplay[k]; - delete [] sbSetting[k]; - delete [] chkOnOff[k] ; - } - - delete [] leDisplay; - delete [] sbSetting; - delete [] chkOnOff; - - for( int k = 0; k < (int) detType.size() ; k++){ - delete [] cbTrigger[k]; - } - delete [] cbTrigger; - - printf("end of %s\n", __func__); - } //^###################################################################### @@ -305,6 +243,7 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList detID, QGridLayout * SendLogMsg(msg + "|Fail."); spb->setStyleSheet("color:red;"); } + emit UpdateOtherPanels(); }); ///===================== for the OnOff CheckBox @@ -321,6 +260,8 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList detID, QGridLayout * } enableSignalSlot = true; + emit UpdateOtherPanels(); + }); layout0->setColumnStretch(0, 1); @@ -370,7 +311,9 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList detID, QGridLayout * digi[digiID]->WriteValue(PHA::CH::EventTriggerSource, "ChSelfTrigger", chID); digi[digiID]->WriteValue(PHA::CH::WaveTriggerSource, "ChSelfTrigger", chID); - if( i > 1 ) { + if( i == 1 ){ + digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Disabled", chID); + }else { digi[digiID]->WriteValue(PHA::CH::CoincidenceMask, "Ch64Trigger", chID); digi[digiID]->WriteValue(PHA::CH::CoincidenceLength, "100", chID); @@ -395,6 +338,8 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList detID, QGridLayout * } } + UpdateOtherPanels(); + }); } @@ -459,8 +404,12 @@ void SOLARISpanel::UpdatePanel(){ int detTypeID = FindDetTypID(detIDList[k]); //Check the 0-index bool isAcceptableSetting = true; + bool isTriggerE = false; if( eventTriggerSource[0] != waveTriggerSource[0] || coincidentMask[0] != antiCoincidentMask[0] ) isAcceptableSetting = false; + if( antiCoincidentMask[0] != "Disabled") isAcceptableSetting = false; + + if( !(coincidentMask[0] == "Disabled" || coincidentMask[0] == "TRGIN") ) isAcceptableSetting = false; //check 0-index settings if( isAcceptableSetting ){ @@ -470,19 +419,24 @@ void SOLARISpanel::UpdatePanel(){ cbTrigger[detTypeID][detIDList[k][0]]->setCurrentText("Disabled"); }else if( eventTriggerSource[0] == "TRGIN" && coincidentMask[0] == "TRGIN") { cbTrigger[detTypeID][detIDList[k][0]]->setCurrentText("Ext. Trigger"); - }else if( eventTriggerSource[0] == "ChSelfTrigger" && coincidentMask[0] == "Ch64Trigger") { - //Check trigger map - //TODO; - for( int p = 0; p < (int) triggerMap.size(); p ++ ){ - printf("ch-%d, trigger : 0x%s \n", detIDList[k][p+1] & 0xFF, QString::number(triggerMap[p], 16).toStdString().c_str() ); + }else if( eventTriggerSource[0] == "ChSelfTrigger" && coincidentMask[0] == "Disabled") { + + unsigned long mask = 1ULL << (detIDList[k][1] & 0xFF); + + for( int p = 1; p < (int) triggerMap.size(); p ++){ + if( coincidentMask[p] != "Ch64Trigger") isAcceptableSetting = false; + if( triggerMap[p] != mask) isAcceptableSetting = false; + } + if( isAcceptableSetting ) { + cbTrigger[detTypeID][detIDList[k][0]]->setCurrentText("Trigger e"); + isTriggerE = true; } - cbTrigger[detTypeID][detIDList[k][0]]->setCurrentText("Trigger e"); }else{ isAcceptableSetting = false; } } - if( isAcceptableSetting ){ + if( isAcceptableSetting){ //Check if eventTriggerSource or coincidentMask compare to the 0-index for( int h = 2; h < detIDList[k].size(); h++){ if( eventTriggerSource[h-1] != eventTriggerSource[0]){ @@ -493,7 +447,7 @@ void SOLARISpanel::UpdatePanel(){ isAcceptableSetting = false; break; } - if( coincidentMask[h-1] != coincidentMask[0]){ + if( !isTriggerE && coincidentMask[h-1] != coincidentMask[0]){ isAcceptableSetting = false; break; } diff --git a/SOLARISpanel.h b/SOLARISpanel.h index 1b8c235..67ea8ab 100644 --- a/SOLARISpanel.h +++ b/SOLARISpanel.h @@ -22,6 +22,10 @@ #include "CustomWidgets.h" #include "macro.h" +#define MaxSettingItem 3 +#define MaxDetType 10 +#define MaxDetID 60 + class SOLARISpanel : public QWidget{ Q_OBJECT @@ -43,9 +47,7 @@ public slots: signals: - //TODO - void UpdateSettingsPanel(); - void UpdateScopePanel(); + void UpdateOtherPanels(); void SendLogMsg(const QString str); private: @@ -55,25 +57,22 @@ private: unsigned short nDigi; std::vector> mapping; QStringList detType; - std::vector nDet; // number of disting detector + std::vector nDet; // number of distgish detector std::vector detMaxID; QList> detIDList; // 1-D array of { detID, (Digi << 8 ) + ch} int FindDetTypID(QList detIDListElement); - int nDigiMapping; /// mapping.size() - std::vector nChMapping; /// mapping[i].size(), NON -1 - QCheckBox * chkAll; // checkBox for all setting on that tab; QCheckBox * chkAlle; QCheckBox * chkAllxf; QCheckBox * chkAllxn; - QLineEdit **** leDisplay; // [SettingID][DigiID][ChID] - RSpinBox **** sbSetting; - QCheckBox **** chkOnOff; + QLineEdit * leDisplay[MaxSettingItem][MaxNumberOfDigitizer][MaxNumberOfChannel]; // [SettingID][DigiID][ChID] + RSpinBox * sbSetting[MaxSettingItem][MaxNumberOfDigitizer][MaxNumberOfChannel]; + QCheckBox * chkOnOff[MaxSettingItem][MaxNumberOfDigitizer][MaxNumberOfChannel]; - RComboBox *** cbTrigger; //[detTypeID][detID] for array only + RComboBox * cbTrigger[MaxDetType][MaxDetID]; //[detTypeID][detID] for array only bool enableSignalSlot; diff --git a/digiSettingsPanel.cpp b/digiSettingsPanel.cpp index 1854e6e..467e74e 100644 --- a/digiSettingsPanel.cpp +++ b/digiSettingsPanel.cpp @@ -843,32 +843,32 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi } for( int ch = 0; ch < digi[ID]->GetNChannels() + 1; ch++) { - //send UpdateScopeSetting signal - connect(spbDCOffset[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(spbRecordLength[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(spbPreTrigger[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(spbThreshold[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(spbTrapRiseTime[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(spbTrapFlatTop[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(spbTrapPoleZero[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(spbPeaking[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(spbTriggerGuard[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(spbTrapRiseTime[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(spbFineGain[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(spbBaselineGuard[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(spbPileupGuard[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(cbbParity[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(cbbWaveRes[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(cbbPeakingAvg[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(cbbLowFilter[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(cbbBaselineAvg[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting); + //send UpdateOtherPanels signal + connect(spbDCOffset[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(spbRecordLength[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(spbPreTrigger[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(spbThreshold[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(spbTrapRiseTime[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(spbTrapFlatTop[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(spbTrapPoleZero[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(spbPeaking[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(spbTriggerGuard[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(spbTrapRiseTime[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(spbFineGain[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(spbBaselineGuard[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(spbPileupGuard[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(cbbParity[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(cbbWaveRes[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(cbbPeakingAvg[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(cbbLowFilter[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(cbbBaselineAvg[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); - connect(cbbAnaProbe0[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(cbbAnaProbe1[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(cbbDigProbe0[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(cbbDigProbe1[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(cbbDigProbe2[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting); - connect(cbbDigProbe3[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting); + connect(cbbAnaProbe0[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(cbbAnaProbe1[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(cbbDigProbe0[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(cbbDigProbe1[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(cbbDigProbe2[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); + connect(cbbDigProbe3[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); //----- SyncBox connect(cbbOnOff[iDigi][ch], &RComboBox::currentIndexChanged, this, [=](){ SyncComboBox(cbbOnOff, ch);}); @@ -1438,7 +1438,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi DigiSettingsPanel::~DigiSettingsPanel(){ - printf("%s\n", __func__); + //printf("%s\n", __func__); } @@ -1547,7 +1547,7 @@ void DigiSettingsPanel::EnableControl(){ if( digi[ID]->GetFPGAType() != "DPP_PHA" || digi[ID]->GetModelName() != "VX2745" ) VGABox[ID]->setEnabled(false); - QVector tempArray = {inputTab[ID], trapTab[ID], probeTab[ID], otherTab[ID], triggerTab[ID] }; + QVector tempArray = {inputTab[ID], trapTab[ID], probeTab[ID], otherTab[ID] }; for( int k = 0; k < tempArray.size(); k++){ for( int i = 0; i < tempArray[k]->count(); i++) { @@ -1561,7 +1561,8 @@ void DigiSettingsPanel::EnableControl(){ } } } - triggerMapTab[ID]->setEnabled(enable); + + //triggerMapTab[ID]->setEnabled(enable); icBox1->setEnabled(enable); icBox2->setEnabled(enable); diff --git a/digiSettingsPanel.h b/digiSettingsPanel.h index 99e6b22..efbdeaa 100644 --- a/digiSettingsPanel.h +++ b/digiSettingsPanel.h @@ -47,7 +47,7 @@ public slots: signals: void SendLogMsg(const QString &msg); - void UpdateScopeSetting(); + void UpdateOtherPanels(); private: diff --git a/mainwindow.cpp b/mainwindow.cpp index 1f10fd4..3ab1184 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -24,7 +24,7 @@ #include //------ static memeber -Digitizer2Gen ** MainWindow::digi = NULL; +Digitizer2Gen ** MainWindow::digi = nullptr; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ @@ -34,10 +34,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ setWindowIcon(icon); nDigi = 0; - digiSetting = NULL; - influx = NULL; - readDataThread = NULL; - scope = NULL; + digiSetting = nullptr; + influx = nullptr; + readDataThread = nullptr; + runTimer = new QTimer(); needManualComment = true; @@ -58,15 +58,21 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ scalarLayout->setSpacing(0); scalarLayout->setAlignment(Qt::AlignTop); - leTrigger = NULL; - leAccept = NULL; + leTrigger = nullptr; + leAccept = nullptr; scalarThread = new ScalarThread(); connect(scalarThread, &ScalarThread::updataScalar, this, &MainWindow::UpdateScalar); - solarisSetting = nullptr; - } + + solarisSetting = nullptr; + scope = nullptr; + digiSetting = nullptr; + + ConnectScopeAndSetting = false; + ConnectScopeAndSolaris = false; + ConnectSettingAndSolaris = false; QWidget * mainLayoutWidget = new QWidget(this); setCentralWidget(mainLayoutWidget); @@ -262,17 +268,17 @@ MainWindow::~MainWindow(){ remove(DAQLockFile); printf("-------- delete Solaris panel\n"); - if( solarisSetting != NULL ) { + if( solarisSetting ) { delete solarisSetting; solarisSetting = nullptr; } printf("-------- delete scope\n"); - if( scope != NULL ) { + if( scope ) { delete scope; scope = nullptr; } printf("-------- delete digiSetting\n"); - if( digiSetting != NULL ) { + if( digiSetting ) { delete digiSetting; digiSetting = nullptr; } @@ -635,16 +641,18 @@ void MainWindow::CloseDigitizers(){ if( digi == NULL) return; - scalar->close(); - DeleteTriggerLineEdit(); // this use digi->GetNChannels(); + if(scalar ){ // scalar is child of this + scalar->close(); + DeleteTriggerLineEdit(); // this use digi->GetNChannels(); + } - if( scope != NULL ){ + if( scope ){ scope->close(); delete scope; scope = NULL; } - if( digiSetting != NULL ){ + if( digiSetting ){ digiSetting->close(); delete digiSetting; digiSetting = NULL; @@ -719,11 +727,18 @@ void MainWindow::OpenScope(){ influx->WriteData(DatabaseName.toStdString()); } - if( digiSetting ) { - connect(scope, &Scope::UpdateSettingsPanel, digiSetting, &DigiSettingsPanel::ShowSettingsToPanel); + if( digiSetting && ConnectScopeAndSetting ) { + connect(scope, &Scope::UpdateOtherPanels, digiSetting, &DigiSettingsPanel::ShowSettingsToPanel); connect(scope, &Scope::TellSettingsPanelControlOnOff, digiSetting, &DigiSettingsPanel::EnableControl); - connect(digiSetting, &DigiSettingsPanel::UpdateScopeSetting, scope, &Scope::ReadScopeSettings); - digiSetting->EnableControl(); + connect(digiSetting, &DigiSettingsPanel::UpdateOtherPanels, scope, &Scope::ReadScopeSettings); + ConnectScopeAndSetting = true; + } + if( digiSetting) digiSetting->EnableControl(); + + if( solarisSetting && !ConnectScopeAndSolaris ){ + connect(scope, &Scope::UpdateOtherPanels, solarisSetting, &SOLARISpanel::UpdatePanel); + connect(solarisSetting, &SOLARISpanel::UpdateOtherPanels, scope, &Scope::ReadScopeSettings); + ConnectScopeAndSolaris = true; } }else{ @@ -743,10 +758,17 @@ void MainWindow::OpenDigitizersSettings(){ digiSetting = new DigiSettingsPanel(digi, nDigi); connect(digiSetting, &DigiSettingsPanel::SendLogMsg, this, &MainWindow::LogMsg); - if( scope ) { - connect(scope, &Scope::UpdateSettingsPanel, digiSetting, &DigiSettingsPanel::ShowSettingsToPanel); + if( scope && !ConnectScopeAndSetting) { + connect(scope, &Scope::UpdateOtherPanels, digiSetting, &DigiSettingsPanel::ShowSettingsToPanel); connect(scope, &Scope::TellSettingsPanelControlOnOff, digiSetting, &DigiSettingsPanel::EnableControl); - connect(digiSetting, &DigiSettingsPanel::UpdateScopeSetting, scope, &Scope::ReadScopeSettings); + connect(digiSetting, &DigiSettingsPanel::UpdateOtherPanels, scope, &Scope::ReadScopeSettings); + ConnectScopeAndSetting = true; + } + + if( solarisSetting && !ConnectSettingAndSolaris){ + connect(digiSetting, &DigiSettingsPanel::UpdateOtherPanels, solarisSetting, &SOLARISpanel::UpdatePanel); + connect(solarisSetting, &SOLARISpanel::UpdateOtherPanels, digiSetting, &DigiSettingsPanel::ShowSettingsToPanel); + ConnectSettingAndSolaris = true; } }else{ @@ -758,6 +780,19 @@ void MainWindow::OpenDigitizersSettings(){ void MainWindow::OpenSOLARISpanel(){ solarisSetting->show(); solarisSetting->UpdatePanel(); + + if( digiSetting && !ConnectSettingAndSolaris){ + connect(digiSetting, &DigiSettingsPanel::UpdateOtherPanels, solarisSetting, &SOLARISpanel::UpdatePanel); + connect(solarisSetting, &SOLARISpanel::UpdateOtherPanels, digiSetting, &DigiSettingsPanel::ShowSettingsToPanel); + ConnectSettingAndSolaris = true; + } + + if( scope && !ConnectScopeAndSolaris){ + connect(scope, &Scope::UpdateOtherPanels, solarisSetting, &SOLARISpanel::UpdatePanel); + connect(solarisSetting, &SOLARISpanel::UpdateOtherPanels, scope, &Scope::ReadScopeSettings); + ConnectScopeAndSolaris = true; + } + } bool MainWindow::CheckSOLARISpanelOK(){ @@ -855,6 +890,8 @@ bool MainWindow::CheckSOLARISpanelOK(){ solarisSetting = new SOLARISpanel(digi, nDigi, mapping, detType, detMaxID); connect(solarisSetting, &SOLARISpanel::SendLogMsg, this, &MainWindow::LogMsg); + if( solarisSetting == nullptr) return false; + return true; } @@ -932,7 +969,7 @@ void MainWindow::SetUpScalar(){ void MainWindow::DeleteTriggerLineEdit(){ - if( leTrigger == NULL ) return; + if( leTrigger ) return; for( int i = 0; i < nDigi; i++){ for( int ch = 0; ch < digi[i]->GetNChannels(); ch ++){ diff --git a/mainwindow.h b/mainwindow.h index d1f7c93..07ac227 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -182,6 +182,10 @@ private: unsigned long oldSavedCount[MaxNumberOfDigitizer][MaxNumberOfChannel]; unsigned long oldTimeStamp[MaxNumberOfDigitizer][MaxNumberOfChannel]; + //@------ connection between pannels + bool ConnectScopeAndSetting; + bool ConnectScopeAndSolaris; + bool ConnectSettingAndSolaris; }; diff --git a/scope.cpp b/scope.cpp index 1b49bee..dce05b0 100644 --- a/scope.cpp +++ b/scope.cpp @@ -85,7 +85,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "False", -1); digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "True", ch); ReadScopeSettings(); - UpdateSettingsPanel(); + UpdateOtherPanels(); digiMTX[iDigi].unlock(); }); @@ -597,8 +597,8 @@ void Scope::ScopeMakeSpinBox(RSpinBox * &sb, QString str, QGridLayout *layout, i sb->setStyleSheet(""); //TODO digiSettingPanel update setting - printf("UpdateSettingsPanel \n"); - emit UpdateSettingsPanel(); + printf("UpdateOtherPanels \n"); + emit UpdateOtherPanels(); }else{ SendLogMsg(msg + "|Fail."); @@ -633,8 +633,8 @@ void Scope::ScopeMakeComoBox(RComboBox * &cb, QString str, QGridLayout *layout, SendLogMsg(msg + "|OK."); cb->setStyleSheet(""); //TODO digiSettingPanel update setting - printf("UpdateSettingsPanel \n"); - emit UpdateSettingsPanel(); + printf("UpdateOtherPanels \n"); + emit UpdateOtherPanels(); }else{ SendLogMsg(msg + "|Fail."); cb->setStyleSheet("color:red;"); diff --git a/scope.h b/scope.h index ec6f95d..16ee25c 100644 --- a/scope.h +++ b/scope.h @@ -132,7 +132,7 @@ signals: void CloseWindow(); void SendLogMsg(const QString &msg); void UpdateScalar(); - void UpdateSettingsPanel(); + void UpdateOtherPanels(); void TellSettingsPanelControlOnOff(); void TellACQOnOff(const bool onOff);