From 36906b702c8959e09e19d78fe86c37bd9081f225 Mon Sep 17 00:00:00 2001 From: splitPoleDAQ Date: Wed, 26 Apr 2023 16:39:54 -0400 Subject: [PATCH] added more setting control fro PHA --- DigiSettingsPanel.cpp | 376 ++++++++++++++++++++++++++++++++++-------- DigiSettingsPanel.h | 29 +++- RegisterAddress.h | 43 ++++- 3 files changed, 376 insertions(+), 72 deletions(-) diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index 6f2f682..f33df26 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -5,6 +5,25 @@ #include #include + // bit = 0, bit = 1 +std::vector, unsigned short>> ACQToolTip = {{{"ACQ STOP", "ACQ RUN"}, 2}, + {{"No Event", "Has Events"}, 3}, + {{"No ch is full", "At least 1 ch is full"}, 4}, + {{"Internal Clock", "Ext. Clock"}, 5}, + {{"PLL Unlocked", "PLL locked"}, 7}, + {{"Board NOT readly", "Board Ready"}, 8}, + {{"S-IN/GPI 0 Level", "S-IN/GPI 1 Level"}, 15}, + {{"TRG-IN 0 Level", "TRG-IN 1 Level"}, 16}, + {{"Channels are ON", "Channles are in shutdown"}, 19}}; + +std::vector, unsigned short>> BdFailToolTip = {{{"PLL Lock OK", "PLL Lock loss"}, 4}, + {{"Temperature OK", "Temperature Failure"}, 5}, + {{"ADC Power OK", "ADC Power Down"}, 6}}; + +std::vector, unsigned short>> ReadoutToolTip = {{{"No Data Ready", "Event Ready"}, 0}, + {{"No Bus Error", "Bus Error"}, 2}, + {{"FIFO not empty", "FIFO is empty"}, 3}}; + DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QMainWindow *parent): QMainWindow(parent){ this->digi = digi; @@ -44,26 +63,106 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QMai infoLayout[iDigi] = new QGridLayout(infoBox[iDigi]); tabLayout_V1->addWidget(infoBox[iDigi]); + SetUpInfo( "Model ", digi[ID]->GetModelName(), infoLayout[ID], 0, 0); + SetUpInfo( "DPP Type ", digi[ID]->GetDPPString(), infoLayout[ID], 0, 2); + SetUpInfo("Link Type ", digi[ID]->GetLinkType() == CAEN_DGTZ_USB ? "USB" : "Optical Link" , infoLayout[ID], 0, 4); + + SetUpInfo( "S/N No. ", std::to_string(digi[ID]->GetSerialNumber()), infoLayout[ID], 1, 0); + SetUpInfo( "No. Ch. ", std::to_string(digi[ID]->GetNChannels()), infoLayout[ID], 1, 2); + SetUpInfo("Sampling Rate ", std::to_string(digi[ID]->GetCh2ns()), infoLayout[ID], 1, 4); + + SetUpInfo("ADC bit ", std::to_string(digi[ID]->GetADCBits()), infoLayout[ID], 2, 0); + SetUpInfo("ROC version ", digi[ID]->GetROCVersion(), infoLayout[ID], 2, 2); + SetUpInfo("AMC version ", digi[ID]->GetAMCVersion(), infoLayout[ID], 2, 4); + + uint32_t boardInfo = digi[ID]->GetSettingFromMemory(Register::DPP::BoardInfo_R); + SetUpInfo("Family Code ", (boardInfo & 0xFF) == 0x0E ? "725 Family" : "730 Family", infoLayout[ID], 3, 0); + SetUpInfo("Ch. Mem. Size ", ((boardInfo >> 8 ) & 0xFF) == 0x01 ? "640 kSample" : "5.12 MSample", infoLayout[ID], 3, 2); + SetUpInfo("Board Type ", ((boardInfo >> 16) & 0xFF) == 0x10 ? "16-ch VME" : "DT, NIM, or 8-ch VME", infoLayout[ID], 3, 4); + } {//^======================= Board status QGroupBox * boardStatusBox = new QGroupBox("Board Status", tab); tabLayout_V1->addWidget(boardStatusBox); - //QGridLayout * statusLayout = new QGridLayout(bardStatusBox); + QGridLayout * statusLayout = new QGridLayout(boardStatusBox); + statusLayout->setAlignment(Qt::AlignLeft); + statusLayout->setHorizontalSpacing(0); + + const int boxSize = 20; + + int rowID = 0; //============================== + QLabel * acqLabel = new QLabel("ACQ status : ", boardStatusBox); + acqLabel->setAlignment(Qt::AlignRight | Qt::AlignCenter); + statusLayout->addWidget(acqLabel, rowID, 0); + for( int i = 0; i < 9; i++){ + bnACQStatus[ID][i] = new QPushButton(boardStatusBox); + bnACQStatus[ID][i]->setEnabled(false); + bnACQStatus[ID][i]->setFixedSize(QSize(boxSize,boxSize)); + bnACQStatus[ID][i]->setToolTip(ACQToolTip[i].first.first); + bnACQStatus[ID][i]->setToolTipDuration(-1); + statusLayout->addWidget(bnACQStatus[ID][i], rowID, i + 1); + } + + rowID ++; //============================== + QLabel * bdFailLabel = new QLabel("Board Failure status : ", boardStatusBox); + bdFailLabel->setAlignment(Qt::AlignRight | Qt::AlignCenter); + statusLayout->addWidget(bdFailLabel, rowID, 0); + for( int i = 0; i < 3; i++){ + bnBdFailStatus[ID][i] = new QPushButton(boardStatusBox); + bnBdFailStatus[ID][i]->setEnabled(false); + bnBdFailStatus[ID][i]->setFixedSize(QSize(boxSize,boxSize)); + bnBdFailStatus[ID][i]->setToolTip(BdFailToolTip[i].first.first); + bnBdFailStatus[ID][i]->setToolTipDuration(-1); + statusLayout->addWidget(bnBdFailStatus[ID][i], rowID, i + 1); + } + + QLabel * ReadoutLabel = new QLabel("Readout status : ", boardStatusBox); + ReadoutLabel->setAlignment(Qt::AlignRight | Qt::AlignCenter); + statusLayout->addWidget(ReadoutLabel, rowID, 10); + for( int i = 0; i < 3; i++){ + bnReadOutStatus[ID][i] = new QPushButton(boardStatusBox); + bnReadOutStatus[ID][i]->setEnabled(false); + bnReadOutStatus[ID][i]->setFixedSize(QSize(boxSize,boxSize)); + bnReadOutStatus[ID][i]->setToolTip(ReadoutToolTip[i].first.first); + bnReadOutStatus[ID][i]->setToolTipDuration(-1); + statusLayout->addWidget(bnReadOutStatus[ID][i], rowID, i + 11); + } } {//^======================= Buttons - QGroupBox * buttonsBox = new QGroupBox("Buttons", tab); - tabLayout_V1->addWidget(buttonsBox); - QGridLayout * buttonLayout = new QGridLayout(buttonsBox); + QWidget * buttonsWidget = new QWidget(tab); + tabLayout_V1->addWidget(buttonsWidget); + QGridLayout * buttonLayout = new QGridLayout(buttonsWidget); bnRefreshSetting = new QPushButton("Refresh Settings", this); buttonLayout->addWidget(bnRefreshSetting, 0, 0); connect(bnRefreshSetting, &QPushButton::clicked, this, &DigiSettingsPanel::ReadSettingsFromBoard); + bnProgramPreDefined = new QPushButton("Clear Buffer/FIFO", this); + buttonLayout->addWidget(bnProgramPreDefined, 0, 1); + connect(bnProgramPreDefined, &QPushButton::clicked, this, [=](){ digi[ID]->ProgramPHABoard();}); //TODO for PSD + + bnClearBuffer = new QPushButton("Clear Buffer/FIFO", this); + buttonLayout->addWidget(bnClearBuffer, 0, 2); + connect(bnClearBuffer, &QPushButton::clicked, this, [=](){ digi[ID]->WriteRegister(Register::DPP::SoftwareClear_W, 1);}); + + bnSendSoftwareTriggerSignal = new QPushButton("Send SW Trigger Signal", this); + buttonLayout->addWidget(bnSendSoftwareTriggerSignal, 1, 0); + connect(bnSendSoftwareTriggerSignal, &QPushButton::clicked, this, [=](){ digi[ID]->WriteRegister(Register::DPP::SoftwareTrigger_W, 1);}); + + bnSendSoftwareClockSyncSignal = new QPushButton("Send SW Clock-Sync Signal", this); + buttonLayout->addWidget(bnSendSoftwareClockSyncSignal, 1, 1); + connect(bnSendSoftwareClockSyncSignal, &QPushButton::clicked, this, [=](){ digi[ID]->WriteRegister(Register::DPP::SoftwareClockSync_W, 1);}); + + bnSaveSettings = new QPushButton("Save Settings", this); + buttonLayout->addWidget(bnSaveSettings, 1, 2); + bnLoadSettings = new QPushButton("Load Settings", this); + buttonLayout->addWidget(bnLoadSettings, 1, 3); + } {//^======================= Board Settings @@ -96,7 +195,6 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QMai // CleanUpGroupBox(boardSettingBox[ID]); // if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) SetUpPHABoard(); // if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) SetUpPSDBoard(); - CleanUpGroupBox(infoBox[ID]); UpdatePanelFromMemory(); } }); @@ -139,7 +237,7 @@ void DigiSettingsPanel::SetUpCheckBox(QCheckBox * &chkBox, QString label, QGridL } -void DigiSettingsPanel::SetUpComboBox(RComboBox * &cb, QString label, QGridLayout *gLayout, int row, int col, std::vector> items){ +void DigiSettingsPanel::SetUpComboBoxBit(RComboBox * &cb, QString label, QGridLayout *gLayout, int row, int col, std::vector> items, Register::Reg para, std::pair bit){ QLabel * lab = new QLabel(label, this); lab->setAlignment(Qt::AlignRight | Qt::AlignCenter); @@ -147,10 +245,72 @@ void DigiSettingsPanel::SetUpComboBox(RComboBox * &cb, QString label, QGridLayou cb = new RComboBox(this); gLayout->addWidget(cb, row, col + 1); + for(int i = 0; i < (int) items.size(); i++){ - cb->addItem(items[i].first, items[i].second); + cb->addItem(QString::fromStdString(items[i].first), items[i].second); } + connect(cb, &RComboBox::currentIndexChanged, this, [=](){ + if( !enableSignalSlot ) return; + digi[ID]->SetBits(para, bit, cb->currentData().toUInt(), -1); + }); + +} +void DigiSettingsPanel::SetUpComboBox(RComboBox * &cb, QString label, QGridLayout *gLayout, int row, int col, Register::Reg para){ + + QLabel * lab = new QLabel(label, this); + lab->setAlignment(Qt::AlignRight | Qt::AlignCenter); + gLayout->addWidget(lab, row, col); + cb = new RComboBox(this); + gLayout->addWidget(cb, row, col + 1); + + std::vector> items = para.GetComboList(); + + for(int i = 0; i < (int) items.size(); i++){ + cb->addItem(QString::fromStdString(items[i].first), items[i].second); + } + + connect(cb, &RComboBox::currentIndexChanged, this, [=](){ + if( !enableSignalSlot ) return; + digi[ID]->WriteRegister(para, cb->currentData().toUInt()); + }); + +} + +void DigiSettingsPanel::SetUpSpinBox(RSpinBox * &sb, QString label, QGridLayout *gLayout, int row, int col, Register::Reg para){ + QLabel * lab = new QLabel(label, this); + lab->setAlignment(Qt::AlignRight | Qt::AlignCenter); + gLayout->addWidget(lab, row, col); + + sb = new RSpinBox(this); + gLayout->addWidget(sb, row, col + 1); + + sb->setMinimum(0); + sb->setMaximum(para.GetMax()); + if( para.GetPartialStep() == -1 ) { + sb->setSingleStep(1); + }else{ + sb->setSingleStep(para.GetPartialStep() * digi[ID]->GetCh2ns()); + } + + connect(sb, &RSpinBox::valueChanged, this, [=](){ + if( !enableSignalSlot ) return; + sb->setStyleSheet("color : blue;"); + }); + + connect(sb, &RSpinBox::returnPressed, this, [=](){ + if( !enableSignalSlot ) return; + + if( sb->decimals() == 0 && sb->singleStep() != 1) { + double step = sb->singleStep(); + double value = sb->value(); + sb->setValue( (std::round(value/step)*step)); + } + + digi[ID]->WriteRegister(para, sb->value(), -1); //TODO for each channel + + }); + } void DigiSettingsPanel::CleanUpGroupBox(QGroupBox * & gBox){ @@ -177,49 +337,77 @@ void DigiSettingsPanel::CleanUpGroupBox(QGroupBox * & gBox){ void DigiSettingsPanel::SetUpPHABoard(){ printf("============== %s \n", __func__); - SetUpCheckBox(chkAutoDataFlush[ID], "Auto Data Flush", settingLayout[ID], 0, 0, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::EnableAutoDataFlush); - SetUpCheckBox(chkDecimateTrace[ID], "Decimate Trace", settingLayout[ID], 1, 0, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::DecimateTrace); - SetUpCheckBox(chkTrigPropagation[ID], "Trig. Propagate", settingLayout[ID], 2, 0, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::TrigPropagation); - SetUpCheckBox(chkDualTrace[ID], "Dual Trace", settingLayout[ID], 3, 0, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::DualTrace); - SetUpCheckBox(chkTraceRecording[ID], "Record Trace", settingLayout[ID], 4, 0, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::RecordTrace); - SetUpCheckBox(chkEnableExtra2[ID], "Enable Extra2", settingLayout[ID], 5, 0, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::EnableExtra2); + QLabel * chMaskLabel = new QLabel("Channel Mask : ", this); + chMaskLabel->setAlignment(Qt::AlignRight | Qt::AlignCenter); + settingLayout[ID]->addWidget(chMaskLabel, 0, 0); - SetUpComboBox(cbAnaProbe1[ID], "Ana. Probe 1 ", settingLayout[ID], 0, 1, {{"Input", 0}, - {"RC-CR", 1}, - {"RC-CR2", 2}, - {"Trapezoid", 3}}); - SetUpComboBox(cbAnaProbe2[ID], "Ana. Probe 2 ", settingLayout[ID], 1, 1, {{"Input", 0}, - {"Threshold", 1}, - {"Trap. - Baseline", 2}, - {"Trap. Baseline", 3}}); - SetUpComboBox(cbDigiProbe1[ID], "Digi. Probe 1 ", settingLayout[ID], 2, 1, {{"Peaking", 0}, - {"Armed", 1}, - {"Peak Run", 2}, - {"Pile Up", 3}, - {"peaking", 4}, - {"TRG Valid. Win", 5}, - {"Baseline Freeze", 6}, - {"TRG Holdoff", 7}, - {"TRG Valid.", 8}, - {"ACQ Busy", 9}, - {"Zero Cross", 10}, - {"Ext. TRG", 11}, - {"Budy", 12}}); + QWidget * chWiget = new QWidget(this); + settingLayout[ID]->addWidget(chWiget, 0, 1, 1, 4); - SetUpComboBox(cbDigiProbe2[ID], "Digi. Probe 2 ", settingLayout[ID], 3, 1, {{"trigger", 0}}); + QGridLayout * chLayout = new QGridLayout(chWiget); + chLayout->setAlignment(Qt::AlignLeft); + chLayout->setSpacing(0); + + for( int i = 0; i < MaxNChannels; i++){ + bnChEnableMask[ID][i] = new QPushButton(this); + bnChEnableMask[ID][i]->setFixedSize(QSize(20,20)); + bnChEnableMask[ID][i]->setToolTip("Ch-" + QString::number(i)); + bnChEnableMask[ID][i]->setToolTipDuration(-1); + QLabel * chIDLabel = new QLabel(QString::number(i), this); + chIDLabel->setAlignment(Qt::AlignHCenter); + chLayout->addWidget(chIDLabel, 0, i); + chLayout->addWidget(bnChEnableMask[ID][i], 1, i ); + + connect(bnChEnableMask[ID][i], &QPushButton::clicked, this, [=](){ + if( !enableSignalSlot) return; + + if( bnChEnableMask[ID][i]->styleSheet() == "" ){ + bnChEnableMask[ID][i]->setStyleSheet("background-color : green;"); + digi[ID]->SetBits(Register::DPP::ChannelEnableMask, {1, i}, 1, i); + }else{ + bnChEnableMask[ID][i]->setStyleSheet(""); + digi[ID]->SetBits(Register::DPP::ChannelEnableMask, {1, i}, 0, i); + } + }); + } + + SetUpCheckBox(chkAutoDataFlush[ID], "Auto Data Flush", settingLayout[ID], 1, 0, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::EnableAutoDataFlush); + SetUpCheckBox(chkDecimateTrace[ID], "Decimate Trace", settingLayout[ID], 2, 0, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::DecimateTrace); + SetUpCheckBox(chkTrigPropagation[ID], "Trig. Propagate", settingLayout[ID], 3, 0, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::TrigPropagation); + SetUpCheckBox(chkEnableExternalTrigger[ID], "Enable TRG-IN ", settingLayout[ID], 4, 0, Register::DPP::DisableExternalTrigger, {1, 0}); + + SetUpCheckBox(chkDualTrace[ID], "Dual Trace", settingLayout[ID], 1, 1, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::DualTrace); + SetUpCheckBox(chkTraceRecording[ID], "Record Trace", settingLayout[ID], 2, 1, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::RecordTrace); + SetUpCheckBox(chkEnableExtra2[ID], "Enable Extra2", settingLayout[ID], 3, 1, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::EnableExtra2); + + + SetUpComboBoxBit(cbAnaProbe1[ID], "Ana. Probe 1 ", settingLayout[ID], 1, 2, Register::DPP::Bit_BoardConfig::ListAnaProbe1, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::AnalogProbe1); + SetUpComboBoxBit(cbAnaProbe2[ID], "Ana. Probe 2 ", settingLayout[ID], 2, 2, Register::DPP::Bit_BoardConfig::ListAnaProbe2, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::AnalogProbe2); + SetUpComboBoxBit(cbDigiProbe1[ID], "Digi. Probe 1 ", settingLayout[ID], 3, 2, Register::DPP::Bit_BoardConfig::ListDigiProbe1, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::DigiProbel1); + SetUpComboBoxBit(cbDigiProbe2[ID], "Digi. Probe 2 ", settingLayout[ID], 4, 2, {{"trigger", 0}}, Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::DigiProbel2); cbDigiProbe2[ID]->setEnabled(false); + SetUpSpinBox(sbAggNum[ID], "Agg. Num. / read", settingLayout[ID], 5, 0, Register::DPP::MaxAggregatePerBlockTransfer); + SetUpComboBox(cbAggOrg[ID], "Aggregate Organization ", settingLayout[ID], 6, 0, Register::DPP::AggregateOrganization); + + SetUpComboBoxBit(cbStartStopMode[ID], "Start/Stop Mode ", settingLayout[ID], 7, 0, {{"SW controlled", 0}, + {"S-IN/GPI controlled", 1}, + {"1st Trigger", 2}, + {"LVDS controlled", 3}}, + Register::DPP::AcquisitionControl, Register::DPP::Bit_AcquistionControl::StartStopMode); + + SetUpComboBoxBit(cbAcqStartArm[ID], "Acq Start/Arm ", settingLayout[ID], 8, 0, {{"ACQ STOP", 0}, + {"ACQ RUN", 1}},Register::DPP::AcquisitionControl, Register::DPP::Bit_AcquistionControl::ACQStartArm); + + SetUpComboBoxBit(cbPLLRefClock[ID], "PLL Ref. Clock ", settingLayout[ID], 5, 2, {{"Internal 50 MHz", 0},{"Ext. CLK-IN", 1}}, Register::DPP::AcquisitionControl, Register::DPP::Bit_AcquistionControl::ACQStartArm); + + + SetUpSpinBox(sbRunDelay[ID], "Run Delay [ns] ", settingLayout[ID], 6, 2, Register::DPP::RunStartStopDelay); + + SetUpComboBox(cbAnalogMonitorMode[ID], "Analog Monitor Mode ", settingLayout[ID], 7, 2, Register::DPP::AnalogMonitorMode); + + SetUpSpinBox(sbBufferGain[ID], "Buffer Occup. Gain ", settingLayout[ID], 8, 2, Register::DPP::BufferOccupancyGain); - SetUpComboBox(cbAggOrg[ID], "Aggregate Organization ", settingLayout[ID], 6, 0, {{"Not used", 0}, - {"4", 2}, - {"8", 3}, - {"16", 4}, - {"32", 5}, - {"64", 6}, - {"128", 7}, - {"256", 8}, - {"512", 9}, - {"1024", 10}}); } @@ -231,20 +419,51 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){ printf("============== %s \n", __func__); - SetUpInfo( "Model ", digi[ID]->GetModelName(), infoLayout[ID], 0, 0); - SetUpInfo( "DPP Type ", digi[ID]->GetDPPString(), infoLayout[ID], 0, 2); - SetUpInfo("Link Type ", digi[ID]->GetLinkType() == CAEN_DGTZ_USB ? "USB" : "Optical Link" , infoLayout[ID], 0, 4); - - SetUpInfo( "S/N No. ", std::to_string(digi[ID]->GetSerialNumber()), infoLayout[ID], 1, 0); - SetUpInfo( "No. Ch. ", std::to_string(digi[ID]->GetNChannels()), infoLayout[ID], 1, 2); - SetUpInfo("Sampling Rate ", std::to_string(digi[ID]->GetCh2ns()), infoLayout[ID], 1, 4); - - SetUpInfo("ADC bit ", std::to_string(digi[ID]->GetADCBits()), infoLayout[ID], 2, 0); - SetUpInfo("ROC version ", digi[ID]->GetROCVersion(), infoLayout[ID], 2, 2); - SetUpInfo("AMC version ", digi[ID]->GetAMCVersion(), infoLayout[ID], 2, 4); - enableSignalSlot = false; + uint32_t AcqStatus = digi[ID]->GetSettingFromMemory(Register::DPP::AcquisitionStatus_R); + for( int i = 0; i < 9; i++){ + if( Digitizer::ExtractBits(AcqStatus, {1, ACQToolTip[i].second}) == 0 ){ + bnACQStatus[ID][i]->setStyleSheet(""); + bnACQStatus[ID][i]->setToolTip(ACQToolTip[i].first.first); + if(ACQToolTip[i].second == 19 ) bnACQStatus[ID][i]->setStyleSheet("background-color: green;"); + }else{ + bnACQStatus[ID][i]->setStyleSheet("background-color: green;"); + bnACQStatus[ID][i]->setToolTip(ACQToolTip[i].first.second); + if(ACQToolTip[i].second == 19 ) bnACQStatus[ID][i]->setStyleSheet(""); + } + } + + uint32_t BdFailStatus = digi[ID]->GetSettingFromMemory(Register::DPP::BoardFailureStatus_R); + for( int i = 0; i < 3; i++){ + if( Digitizer::ExtractBits(BdFailStatus, {1, BdFailToolTip[i].second}) == 0 ){ + bnBdFailStatus[ID][i]->setStyleSheet("background-color: green;"); + bnBdFailStatus[ID][i]->setToolTip(BdFailToolTip[i].first.first); + }else{ + bnBdFailStatus[ID][i]->setStyleSheet("background-color: red;"); + bnBdFailStatus[ID][i]->setToolTip(BdFailToolTip[i].first.second); + } + } + + uint32_t ReadoutStatus = digi[ID]->GetSettingFromMemory(Register::DPP::ReadoutStatus_R); + for( int i = 0; i < 3; i++){ + if( Digitizer::ExtractBits(ReadoutStatus, {1, ReadoutToolTip[i].second}) == 0 ){ + if( ReadoutToolTip[i].second != 2 ) { + bnReadOutStatus[ID][i]->setStyleSheet(""); + }else{ + bnReadOutStatus[ID][i]->setStyleSheet("background-color: green;"); + } + bnReadOutStatus[ID][i]->setToolTip(ReadoutToolTip[i].first.first); + }else{ + if( ReadoutToolTip[i].second != 2 ) { + bnReadOutStatus[ID][i]->setStyleSheet("background-color: green;"); + }else{ + bnReadOutStatus[ID][i]->setStyleSheet("background-color: red;"); + } + bnReadOutStatus[ID][i]->setToolTip(ReadoutToolTip[i].first.second); + } + } + uint32_t BdCfg = digi[ID]->GetSettingFromMemory(Register::DPP::BoardConfiguration); chkAutoDataFlush[ID]->setChecked( Digitizer::ExtractBits(BdCfg, Register::DPP::Bit_BoardConfig::EnableAutoDataFlush) ); @@ -254,8 +473,6 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){ chkTraceRecording[ID]->setChecked( Digitizer::ExtractBits(BdCfg, Register::DPP::Bit_BoardConfig::TrigPropagation) ); chkEnableExtra2[ID]->setChecked( Digitizer::ExtractBits(BdCfg, Register::DPP::Bit_BoardConfig::EnableExtra2) ); - //connect(chkAutoDataFlush, &QCheckBox::stateChanged, this, &DigiSettingsPanel::SetAutoDataFlush); - int temp = Digitizer::ExtractBits(BdCfg, Register::DPP::Bit_BoardConfig::AnalogProbe1); for( int i = 0; i < cbAnaProbe1[ID]->count(); i++){ if( cbAnaProbe1[ID]->itemData(i).toInt() == temp) { @@ -279,8 +496,42 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){ } } + uint32_t chMask = digi[ID]->GetSettingFromMemory(Register::DPP::ChannelEnableMask); + for( int i = 0; i < MaxNChannels; i++){ + if( (chMask >> i ) & 0x1 ) { + bnChEnableMask[ID][i]->setStyleSheet("background-color: green;"); + }else{ + bnChEnableMask[ID][i]->setStyleSheet(""); + } + } - enableSignalSlot = false; + uint32_t aggOrg = digi[ID]->GetSettingFromMemory(Register::DPP::AggregateOrganization); + for( int i = 0; i < cbAggOrg[ID]->count(); i++){ + if( cbAggOrg[ID]->itemData(i).toUInt() == aggOrg ){ + cbAggOrg[ID]->setCurrentIndex(i); + break; + } + } + + sbAggNum[ID]->setValue(digi[ID]->GetSettingFromMemory(Register::DPP::MaxAggregatePerBlockTransfer)); + + chkEnableExternalTrigger[ID]->setChecked( ! ( digi[ID]->GetSettingFromMemory(Register::DPP::DisableExternalTrigger) & 0x1) ); + + sbRunDelay[ID]->setValue(digi[ID]->GetSettingFromMemory(Register::DPP::RunStartStopDelay)); + + uint32_t anaMonitor = digi[ID]->GetSettingFromMemory(Register::DPP::AnalogMonitorMode); + for( int i = 0 ; i < cbAnalogMonitorMode[ID]->count(); i++){ + if( cbAnalogMonitorMode[ID]->itemData(i).toUInt() == anaMonitor ){ + cbAnalogMonitorMode[ID]->setCurrentIndex(i); + break; + } + } + + sbBufferGain[ID]->setValue(digi[ID]->GetSettingFromMemory(Register::DPP::BufferOccupancyGain)); + + enableSignalSlot = true; + + printf("============== end of %s \n", __func__); } @@ -295,10 +546,5 @@ void DigiSettingsPanel::ReadSettingsFromBoard(){ //*================================================================ //*================================================================ -void DigiSettingsPanel::SetAutoDataFlush(){ - if( !enableSignalSlot ) return; - digi[ID]->SetBits(Register::DPP::BoardConfiguration, Register::DPP::Bit_BoardConfig::EnableAutoDataFlush, chkAutoDataFlush[ID]->checkState() ? 1 : 0, -1); - -} diff --git a/DigiSettingsPanel.h b/DigiSettingsPanel.h index 9e6c11a..2568ea0 100644 --- a/DigiSettingsPanel.h +++ b/DigiSettingsPanel.h @@ -24,9 +24,6 @@ private slots: void UpdatePanelFromMemory(); void ReadSettingsFromBoard(); - - void SetAutoDataFlush(); - signals: void SendLogMsg(const QString &msg); @@ -35,7 +32,9 @@ private: void SetUpInfo(QString label, std::string value, QGridLayout *gLayout, int row, int col); void SetUpCheckBox(QCheckBox * &chkBox, QString label, QGridLayout *gLayout, int row, int col, Register::Reg para, std::pair bit); - void SetUpComboBox(RComboBox * &cb, QString label, QGridLayout *gLayout, int row, int col, std::vector> items); + void SetUpComboBoxBit(RComboBox * &cb, QString label, QGridLayout *gLayout, int row, int col, std::vector> items, Register::Reg para, std::pair bit); + void SetUpComboBox(RComboBox * &cb, QString label, QGridLayout *gLayout, int row, int col, Register::Reg para); + void SetUpSpinBox(RSpinBox * &sb, QString label, QGridLayout *gLayout, int row, int col, Register::Reg para); void CleanUpGroupBox(QGroupBox * & gBox); void SetUpPHABoard(); @@ -53,6 +52,14 @@ private: QGridLayout * infoLayout[MaxNDigitizer]; QPushButton * bnRefreshSetting; // read setting from board + QPushButton * bnProgramPreDefined; + QPushButton * bnClearBuffer; + + QPushButton * bnSendSoftwareTriggerSignal; + QPushButton * bnSendSoftwareClockSyncSignal; + QPushButton * bnSaveSettings; + QPushButton * bnLoadSettings; + QGroupBox * boardSettingBox[MaxNDigitizer]; QGridLayout * settingLayout[MaxNDigitizer]; @@ -69,7 +76,21 @@ private: RComboBox * cbDigiProbe1[MaxNDigitizer]; RComboBox * cbDigiProbe2[MaxNDigitizer]; + QPushButton * bnChEnableMask[MaxNDigitizer][MaxNChannels]; RComboBox * cbAggOrg[MaxNDigitizer]; + RSpinBox * sbAggNum[MaxNDigitizer]; + QCheckBox * chkEnableExternalTrigger[MaxNDigitizer]; + RSpinBox * sbRunDelay[MaxNDigitizer]; + RComboBox * cbAnalogMonitorMode[MaxNDigitizer]; + RSpinBox * sbBufferGain[MaxNDigitizer]; + + RComboBox * cbStartStopMode[MaxNDigitizer]; + RComboBox * cbAcqStartArm[MaxNDigitizer]; + RComboBox * cbPLLRefClock[MaxNDigitizer]; + + QPushButton * bnACQStatus[MaxNDigitizer][9]; + QPushButton * bnBdFailStatus[MaxNDigitizer][3]; + QPushButton * bnReadOutStatus[MaxNDigitizer][3]; }; diff --git a/RegisterAddress.h b/RegisterAddress.h index 6327be0..da8ed92 100644 --- a/RegisterAddress.h +++ b/RegisterAddress.h @@ -210,6 +210,30 @@ inline uint32_t Reg::CalAddress(unsigned int index){ const std::pair EnableExtra2 = {1, 17} ; const std::pair DigiProbel1 = {4, 20} ; const std::pair DigiProbel2 = {3, 26} ; + + const std::vector> ListAnaProbe1 = {{"Input", 0}, + {"RC-CR", 1}, + {"RC-CR2", 2}, + {"Trapezoid", 3}}; + const std::vector> ListAnaProbe2 = {{"Input", 0}, + {"Threshold", 1}, + {"Trap. - Baseline", 2}, + {"Trap. Baseline", 3}}; + + const std::vector> ListDigiProbe1 = {{"Peaking", 0}, + {"Armed", 1}, + {"Peak Run", 2}, + {"Pile Up", 3}, + {"peaking", 4}, + {"TRG Valid. Win", 5}, + {"Baseline Freeze", 6}, + {"TRG Holdoff", 7}, + {"TRG Valid.", 8}, + {"ACQ Busy", 9}, + {"Zero Cross", 10}, + {"Ext. TRG", 11}, + {"Budy", 12}}; + } namespace Bit_DPPAlgorithmControl { @@ -223,6 +247,7 @@ inline uint32_t Reg::CalAddress(unsigned int index){ const std::pair DisableSelfTrigger = {1, 24}; const std::pair EnableRollOverFlag = {1, 26}; const std::pair EnablePileUpFlag = {1, 27}; + } namespace Bit_AcquistionControl { @@ -246,6 +271,18 @@ inline uint32_t Reg::CalAddress(unsigned int index){ const std::pair ChannelsDown = {1, 19} ; } + namespace Bit_ReadoutControl { + const std::pair VMEInterruptLevel = {3, 0} ; + const std::pair EnableOpticalLinkInpt = {1, 3} ; + const std::pair EnableEventAligned = {1, 4} ; + const std::pair VMEAlign64Mode = {1, 5} ; + const std::pair VMEBaseAddressReclocated = {1, 6} ; + const std::pair InterrupReleaseMode = {1, 7} ; + const std::pair EnableExtendedBlockTransfer = {1, 8} ; + + + } + const Reg RecordLength_G ("RecordLength_G" , 0x1020, RW::ReadWrite, true, 0x3FFF, 8); /// R/W const Reg InputDynamicRange ("InputDynamicRange" , 0x1028, RW::ReadWrite, false, {{"2 Vpp", 0},{"0.5 Vpp", 1}}); /// R/W const Reg NumberEventsPerAggregate_G ("NumberEventsPerAggregate_G" , 0x1034, RW::ReadWrite, true, 0x3FF, -1); /// R/W @@ -295,12 +332,12 @@ inline uint32_t Reg::CalAddress(unsigned int index){ const Reg EventSize_R ("EventSize_R" , 0x814C, RW::ReadONLY , false, {}); /// R const Reg TimeBombDowncounter_R ("TimeBombDowncounter_R" , 0x8158, RW::ReadONLY , false, {}); /// R const Reg FanSpeedControl ("FanSpeedControl" , 0x8168, RW::ReadWrite, false, {}); /// R/W - const Reg RunStartStopDelay ("RunStartStopDelay" , 0x8170, RW::ReadWrite, false, {}); /// R/W + const Reg RunStartStopDelay ("RunStartStopDelay" , 0x8170, RW::ReadWrite, false, 0xFF, 8); /// R/W const Reg BoardFailureStatus_R ("BoardFailureStatus_R" , 0x8178, RW::ReadONLY , false, {}); /// R const Reg DisableExternalTrigger ("DisableExternalTrigger" , 0x817C, RW::ReadWrite, false, {}); /// R/W const Reg FrontPanelLVDSIONewFeatures ("FrontPanelLVDSIONewFeatures" , 0x81A0, RW::ReadWrite, false, {}); /// R/W - const Reg BufferOccupancyGain ("BufferOccupancyGain" , 0x81B4, RW::ReadWrite, false, {}); /// R/W - const Reg ExtendedVetoDelay ("ExtendedVetoDelay" , 0x81C4, RW::ReadWrite, false, {}); /// R/W + const Reg BufferOccupancyGain ("BufferOccupancyGain" , 0x81B4, RW::ReadWrite, false, 0xF, -1); /// R/W + const Reg ExtendedVetoDelay ("ExtendedVetoDelay" , 0x81C4, RW::ReadWrite, false, 0xFFFF, 4); /// R/W const Reg ReadoutControl ("ReadoutControl" , 0xEF00, RW::ReadWrite, false, {}); /// R/W const Reg ReadoutStatus_R ("ReadoutStatus_R" , 0xEF04, RW::ReadONLY , false, {}); /// R const Reg BoardID ("BoardID" , 0xEF08, RW::ReadWrite, false, {}); /// R/W