2023-02-23 16:08:47 -05:00
# include "digiSettingsPanel.h"
2023-01-25 17:16:14 -05:00
# include <QLabel>
2023-02-23 16:08:47 -05:00
# include <QFileDialog>
2023-03-02 18:18:02 -05:00
# include <QStyledItemDelegate>
2023-03-03 18:53:59 -05:00
# include <QToolTip>
# include <QPoint>
2023-02-23 16:08:47 -05:00
2023-03-14 16:17:22 -04:00
std : : vector < std : : pair < std : : string , Reg > > infoIndex = { { " Serial Num : " , PHA : : DIG : : SerialNumber } ,
{ " IP : " , PHA : : DIG : : IPAddress } ,
{ " Model Name : " , PHA : : DIG : : ModelName } ,
{ " FPGA version : " , PHA : : DIG : : FPGA_firmwareVersion } ,
{ " DPP Type : " , PHA : : DIG : : FirmwareType } ,
{ " CUP version : " , PHA : : DIG : : CupVer } ,
{ " ADC bits : " , PHA : : DIG : : ADC_bit } ,
{ " ADC rate [Msps] : " , PHA : : DIG : : ADC_SampleRate } ,
{ " Num. of Channel : " , PHA : : DIG : : NumberOfChannel } ,
{ " Input range [Vpp] : " , PHA : : DIG : : InputDynamicRange } ,
{ " Input Type : " , PHA : : DIG : : InputType } ,
{ " Input Impedance [Ohm] : " , PHA : : DIG : : InputImpedance }
2023-02-23 16:08:47 -05:00
} ;
2023-03-03 18:53:59 -05:00
QStringList LEDToolTip = { " LED_JESD_Y_PASS " ,
" LED_JESD_H_PASS " ,
" LED_DDR4_0_PASS " ,
" LED_DDR4_1_PASS " ,
" LED_DDR4_2_PASS " ,
" LEDFP_FAIL " ,
" LEDFP_NIM " ,
" LEDFP_TTL " ,
" LEDFP_DTLOSS " ,
" LEDFP_DTRDY " ,
" LEDFP_TRG " ,
" LEDFP_RUN " ,
" LEDFP_PLL_LOCK " ,
" LEDFP_CLKOUT " ,
" LEDFP_CLKIN " ,
" LEDFP_USB " ,
" LEDFP_SFP_SD " ,
" LEDFP_SFP_ACT " ,
" LEDFP_ACT " } ;
QStringList ACQToolTip = { " Armed " ,
" Run " ,
" Run_mw " ,
" Jesd_Clk_Valid " ,
" Busy " ,
" PreTriggerReady " ,
" LicenceFail " } ;
QStringList chToolTip = { " Channel signal delay initialization status (1 = initial delay done) " ,
" Channel time filter initialization status (1 = time filter initialization done) " ,
" Channel energy filter initialization status (1 = energy filter initialization done) " ,
" Channel full initialization status (1 = initialization done) " ,
" Reserved " ,
" Channel enable acquisition status (1 = acq enabled) " ,
" Channel inner run status (1 = run active) " ,
" Time-energy event free space status (1 = time-energy can be written) " ,
" Waveform event free space status (1 = waveform can be written) " } ;
2023-02-23 16:08:47 -05:00
DigiSettingsPanel : : DigiSettingsPanel ( Digitizer2Gen * * digi , unsigned short nDigi , QWidget * parent ) : QWidget ( parent ) {
qDebug ( ) < < " DigiSettingsPanel constructor " ;
2023-01-25 17:16:14 -05:00
setWindowTitle ( " Digitizers Settings " ) ;
2023-03-03 15:23:26 -05:00
setGeometry ( 0 , 0 , 1850 , 1000 ) ;
2023-01-25 18:27:05 -05:00
//setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
2023-01-25 17:16:14 -05:00
this - > digi = digi ;
this - > nDigi = nDigi ;
2023-02-23 16:08:47 -05:00
if ( nDigi > MaxNumberOfDigitizer ) {
this - > nDigi = MaxNumberOfChannel ;
qDebug ( ) < < " Please increase the MaxNumberOfChannel " ;
}
2023-01-25 17:16:14 -05:00
2023-02-23 16:08:47 -05:00
ID = 0 ;
2023-02-24 19:21:27 -05:00
enableSignalSlot = false ;
2023-01-25 17:16:14 -05:00
2023-01-30 18:40:24 -05:00
QVBoxLayout * mainLayout = new QVBoxLayout ( this ) ; this - > setLayout ( mainLayout ) ;
QTabWidget * tabWidget = new QTabWidget ( this ) ; mainLayout - > addWidget ( tabWidget ) ;
2023-02-23 16:08:47 -05:00
connect ( tabWidget , & QTabWidget : : currentChanged , this , [ = ] ( int index ) { ID = index ; } ) ;
2023-01-25 17:16:14 -05:00
2023-02-22 20:07:39 -05:00
//@========================== Tab for each digitizer
2023-01-30 18:40:24 -05:00
for ( unsigned short iDigi = 0 ; iDigi < this - > nDigi ; iDigi + + ) {
2023-01-25 17:16:14 -05:00
2023-02-23 16:08:47 -05:00
QScrollArea * scrollArea = new QScrollArea ( this ) ;
2023-01-25 17:16:14 -05:00
scrollArea - > setWidgetResizable ( true ) ;
scrollArea - > setSizePolicy ( QSizePolicy : : Expanding , QSizePolicy : : Expanding ) ;
2023-02-02 19:01:10 -05:00
tabWidget - > addTab ( scrollArea , " Digi- " + QString : : number ( digi [ iDigi ] - > GetSerialNumber ( ) ) ) ;
2023-02-23 16:08:47 -05:00
QWidget * tab = new QWidget ( tabWidget ) ;
scrollArea - > setWidget ( tab ) ;
2023-01-27 18:52:03 -05:00
2023-02-23 16:08:47 -05:00
QHBoxLayout * tabLayout_H = new QHBoxLayout ( tab ) ; //tab->setLayout(tabLayout_H);
QVBoxLayout * tabLayout_V1 = new QVBoxLayout ( ) ; tabLayout_H - > addLayout ( tabLayout_V1 ) ;
QVBoxLayout * tabLayout_V2 = new QVBoxLayout ( ) ; tabLayout_H - > addLayout ( tabLayout_V2 ) ;
2023-01-25 17:16:14 -05:00
2023-02-22 20:07:39 -05:00
{ //^====================== Group of Digitizer Info
2023-01-27 18:52:03 -05:00
QGroupBox * infoBox = new QGroupBox ( " Board Info " , tab ) ;
2023-02-28 13:28:30 -05:00
//infoBox->setSizePolicy(sizePolicy);
2023-01-27 18:52:03 -05:00
QGridLayout * infoLayout = new QGridLayout ( infoBox ) ;
2023-02-23 16:08:47 -05:00
tabLayout_V1 - > addWidget ( infoBox ) ;
2023-01-27 18:52:03 -05:00
const unsigned short nRow = 4 ;
2023-02-23 16:08:47 -05:00
for ( unsigned short j = 0 ; j < ( unsigned short ) infoIndex . size ( ) ; j + + ) {
QLabel * lab = new QLabel ( QString : : fromStdString ( infoIndex [ j ] . first ) , tab ) ;
2023-02-28 17:08:34 -05:00
lab - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
2023-02-23 16:08:47 -05:00
leInfo [ iDigi ] [ j ] = new QLineEdit ( tab ) ;
leInfo [ iDigi ] [ j ] - > setReadOnly ( true ) ;
2023-02-28 17:08:34 -05:00
leInfo [ iDigi ] [ j ] - > setText ( QString : : fromStdString ( digi [ iDigi ] - > ReadValue ( infoIndex [ j ] . second ) ) ) ;
2023-01-27 18:52:03 -05:00
infoLayout - > addWidget ( lab , j % nRow , 2 * ( j / nRow ) ) ;
2023-02-23 16:08:47 -05:00
infoLayout - > addWidget ( leInfo [ iDigi ] [ j ] , j % nRow , 2 * ( j / nRow ) + 1 ) ;
2023-01-27 18:52:03 -05:00
}
2023-01-25 17:16:14 -05:00
}
2023-01-27 18:52:03 -05:00
2023-02-22 20:07:39 -05:00
{ //^====================== Group Board status
2023-01-27 18:52:03 -05:00
QGroupBox * statusBox = new QGroupBox ( " Board Status " , tab ) ;
QGridLayout * statusLayout = new QGridLayout ( statusBox ) ;
2023-02-28 13:28:30 -05:00
statusLayout - > setAlignment ( Qt : : AlignLeft ) ;
2023-02-22 20:07:39 -05:00
statusLayout - > setHorizontalSpacing ( 0 ) ;
2023-02-23 16:08:47 -05:00
tabLayout_V1 - > addWidget ( statusBox ) ;
2023-02-22 20:07:39 -05:00
//------- LED Status
QLabel * lbLED = new QLabel ( " LED status : " ) ;
lbLED - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
statusLayout - > addWidget ( lbLED , 0 , 0 ) ;
for ( int i = 0 ; i < 19 ; i + + ) {
2023-02-23 16:08:47 -05:00
LEDStatus [ iDigi ] [ i ] = new QPushButton ( tab ) ;
LEDStatus [ iDigi ] [ i ] - > setEnabled ( false ) ;
LEDStatus [ iDigi ] [ i ] - > setFixedSize ( QSize ( 30 , 30 ) ) ;
2023-03-03 18:53:59 -05:00
LEDStatus [ iDigi ] [ i ] - > setToolTip ( LEDToolTip [ i ] ) ;
LEDStatus [ iDigi ] [ i ] - > setToolTipDuration ( - 1 ) ;
2023-03-11 18:35:15 -05:00
//TODO set tooltip position on top
2023-03-03 18:53:59 -05:00
statusLayout - > addWidget ( LEDStatus [ iDigi ] [ i ] , 0 , 1 + 19 - i ) ;
2023-02-22 20:07:39 -05:00
}
//------- ACD Status
QLabel * lbACQ = new QLabel ( " ACQ status : " ) ;
lbACQ - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
statusLayout - > addWidget ( lbACQ , 1 , 0 ) ;
for ( int i = 0 ; i < 7 ; i + + ) {
2023-02-23 16:08:47 -05:00
ACQStatus [ iDigi ] [ i ] = new QPushButton ( tab ) ;
ACQStatus [ iDigi ] [ i ] - > setEnabled ( false ) ;
ACQStatus [ iDigi ] [ i ] - > setFixedSize ( QSize ( 30 , 30 ) ) ;
2023-03-03 18:53:59 -05:00
ACQStatus [ iDigi ] [ i ] - > setToolTip ( ACQToolTip [ i ] ) ;
ACQStatus [ iDigi ] [ i ] - > setToolTipDuration ( - 1 ) ;
statusLayout - > addWidget ( ACQStatus [ iDigi ] [ i ] , 1 , 1 + 7 - i ) ;
2023-02-22 20:07:39 -05:00
}
//------- Temperatures
QLabel * lbTemp = new QLabel ( " ADC Temperature [C] : " ) ;
lbTemp - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
statusLayout - > addWidget ( lbTemp , 2 , 0 ) ;
2023-02-24 19:21:27 -05:00
for ( int i = 0 ; i < 8 ; i + + ) {
leTemp [ iDigi ] [ i ] = new QLineEdit ( tab ) ;
leTemp [ iDigi ] [ i ] - > setReadOnly ( true ) ;
leTemp [ iDigi ] [ i ] - > setAlignment ( Qt : : AlignHCenter ) ;
statusLayout - > addWidget ( leTemp [ iDigi ] [ i ] , 2 , 1 + 2 * i , 1 , 2 ) ;
2023-02-22 20:07:39 -05:00
}
2023-02-28 13:28:30 -05:00
for ( int i = 0 ; i < statusLayout - > columnCount ( ) ; i + + ) statusLayout - > setColumnStretch ( i , 0 ) ;
2023-01-27 18:52:03 -05:00
}
2023-02-23 16:08:47 -05:00
{ //^====================== Board Setting Buttons
QGridLayout * bnLayout = new QGridLayout ( ) ;
2023-02-28 13:28:30 -05:00
tabLayout_V1 - > addLayout ( bnLayout ) ;
2023-01-25 18:27:05 -05:00
int rowId = 0 ;
//-------------------------------------
2023-02-23 16:08:47 -05:00
QLabel * lbSettingFile = new QLabel ( " Setting File : " , tab ) ;
lbSettingFile - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
bnLayout - > addWidget ( lbSettingFile , rowId , 0 ) ;
leSettingFile [ iDigi ] = new QLineEdit ( tab ) ;
leSettingFile [ iDigi ] - > setReadOnly ( true ) ;
2023-03-03 18:53:59 -05:00
leSettingFile [ iDigi ] - > setText ( QString : : fromStdString ( digi [ iDigi ] - > GetSettingFileName ( ) ) ) ;
2023-02-23 16:08:47 -05:00
bnLayout - > addWidget ( leSettingFile [ iDigi ] , rowId , 1 , 1 , 9 ) ;
//-------------------------------------
rowId + + ;
2023-03-10 17:28:02 -05:00
bnReadSettngs [ iDigi ] = new QPushButton ( " Refresh Settings " , tab ) ;
bnLayout - > addWidget ( bnReadSettngs [ iDigi ] , rowId , 0 , 1 , 2 ) ;
connect ( bnReadSettngs [ iDigi ] , & QPushButton : : clicked , this , & DigiSettingsPanel : : RefreshSettings ) ;
2023-02-23 16:08:47 -05:00
2023-03-10 17:28:02 -05:00
bnResetBd [ iDigi ] = new QPushButton ( " Reset Board " , tab ) ;
bnLayout - > addWidget ( bnResetBd [ iDigi ] , rowId , 2 , 1 , 2 ) ;
connect ( bnResetBd [ iDigi ] , & QPushButton : : clicked , this , [ = ] ( ) {
SendLogMsg ( " Reset Digitizer- " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ) ;
2023-02-27 15:23:28 -05:00
digi [ ID ] - > Reset ( ) ;
} ) ;
2023-01-26 19:12:18 -05:00
2023-03-11 18:35:15 -05:00
bnDefaultSetting [ iDigi ] = new QPushButton ( " Set Default PHA Settings " , tab ) ;
2023-03-10 17:28:02 -05:00
bnLayout - > addWidget ( bnDefaultSetting [ iDigi ] , rowId , 4 , 1 , 2 ) ;
2023-03-11 18:35:15 -05:00
connect ( bnDefaultSetting [ iDigi ] , & QPushButton : : clicked , this , & DigiSettingsPanel : : SetDefaultPHASettigns ) ;
2023-01-26 19:12:18 -05:00
2023-03-10 17:28:02 -05:00
bnSaveSettings [ iDigi ] = new QPushButton ( " Save Settings " , tab ) ;
bnLayout - > addWidget ( bnSaveSettings [ iDigi ] , rowId , 6 , 1 , 2 ) ;
connect ( bnSaveSettings [ iDigi ] , & QPushButton : : clicked , this , & DigiSettingsPanel : : SaveSettings ) ;
2023-02-23 16:08:47 -05:00
2023-03-10 17:28:02 -05:00
bnLoadSettings [ iDigi ] = new QPushButton ( " Load Settings " , tab ) ;
bnLayout - > addWidget ( bnLoadSettings [ iDigi ] , rowId , 8 , 1 , 2 ) ;
connect ( bnLoadSettings [ iDigi ] , & QPushButton : : clicked , this , & DigiSettingsPanel : : LoadSettings ) ;
2023-02-22 20:07:39 -05:00
2023-02-27 15:23:28 -05:00
//---------------------------------------
rowId + + ;
2023-03-10 17:28:02 -05:00
bnClearData [ iDigi ] = new QPushButton ( " Clear Data " , tab ) ;
bnLayout - > addWidget ( bnClearData [ iDigi ] , rowId , 0 , 1 , 2 ) ;
2023-03-14 16:17:22 -04:00
connect ( bnClearData [ iDigi ] , & QPushButton : : clicked , this , [ = ] ( ) { digi [ ID ] - > SendCommand ( PHA : : DIG : : ClearData ) ; } ) ;
2023-02-27 15:23:28 -05:00
2023-03-10 17:28:02 -05:00
bnArmACQ [ iDigi ] = new QPushButton ( " Arm ACQ " , tab ) ;
bnLayout - > addWidget ( bnArmACQ [ iDigi ] , rowId , 2 , 1 , 2 ) ;
2023-03-14 16:17:22 -04:00
connect ( bnArmACQ [ iDigi ] , & QPushButton : : clicked , this , [ = ] ( ) { digi [ ID ] - > SendCommand ( PHA : : DIG : : ArmACQ ) ; } ) ;
2023-02-27 15:23:28 -05:00
2023-03-10 17:28:02 -05:00
bnDisarmACQ [ iDigi ] = new QPushButton ( " Disarm ACQ " , tab ) ;
bnLayout - > addWidget ( bnDisarmACQ [ iDigi ] , rowId , 4 , 1 , 2 ) ;
2023-03-14 16:17:22 -04:00
connect ( bnDisarmACQ [ iDigi ] , & QPushButton : : clicked , this , [ = ] ( ) { digi [ ID ] - > SendCommand ( PHA : : DIG : : DisarmACQ ) ; } ) ;
2023-02-27 15:23:28 -05:00
2023-03-10 17:28:02 -05:00
bnSoftwareStart [ iDigi ] = new QPushButton ( " Software Start ACQ " , tab ) ;
bnLayout - > addWidget ( bnSoftwareStart [ iDigi ] , rowId , 6 , 1 , 2 ) ;
2023-03-14 16:17:22 -04:00
connect ( bnSoftwareStart [ iDigi ] , & QPushButton : : clicked , this , [ = ] ( ) { digi [ ID ] - > SendCommand ( PHA : : DIG : : SoftwareStartACQ ) ; } ) ;
2023-02-27 15:23:28 -05:00
2023-03-10 17:28:02 -05:00
bnSoftwareStop [ iDigi ] = new QPushButton ( " Software Stop ACQ " , tab ) ;
bnLayout - > addWidget ( bnSoftwareStop [ iDigi ] , rowId , 8 , 1 , 2 ) ;
2023-03-14 16:17:22 -04:00
connect ( bnSoftwareStop [ iDigi ] , & QPushButton : : clicked , this , [ = ] ( ) { digi [ ID ] - > SendCommand ( PHA : : DIG : : SoftwareStopACQ ) ; } ) ;
2023-02-27 15:23:28 -05:00
2023-02-28 13:28:30 -05:00
//---------------
if ( digi [ iDigi ] - > IsDummy ( ) ) {
2023-03-10 17:28:02 -05:00
bnReadSettngs [ iDigi ] - > setEnabled ( false ) ;
bnResetBd [ iDigi ] - > setEnabled ( false ) ;
bnDefaultSetting [ iDigi ] - > setEnabled ( false ) ;
bnClearData [ iDigi ] - > setEnabled ( false ) ;
bnArmACQ [ iDigi ] - > setEnabled ( false ) ;
bnDisarmACQ [ iDigi ] - > setEnabled ( false ) ;
bnSoftwareStart [ iDigi ] - > setEnabled ( false ) ;
bnSoftwareStop [ iDigi ] - > setEnabled ( false ) ;
2023-02-28 13:28:30 -05:00
}
2023-02-23 16:08:47 -05:00
}
{ //^====================== Group Board settings
2023-03-10 17:28:02 -05:00
digiBox = new QGroupBox ( " Board Settings " , tab ) ;
2023-02-28 13:28:30 -05:00
//digiBox->setSizePolicy(sizePolicy);
2023-02-23 16:08:47 -05:00
QGridLayout * boardLayout = new QGridLayout ( digiBox ) ;
2023-02-28 13:28:30 -05:00
tabLayout_V1 - > addWidget ( digiBox ) ;
2023-02-23 16:08:47 -05:00
int rowId = 0 ;
2023-01-27 18:52:03 -05:00
//-------------------------------------
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbClockSource [ iDigi ] , PHA : : DIG : : ClockSource , - 1 , true , " Clock Source : " , boardLayout , rowId , 0 , 1 , 2 ) ;
2023-01-27 18:52:03 -05:00
2023-01-26 19:12:18 -05:00
//-------------------------------------
rowId + + ;
2023-01-25 18:27:05 -05:00
QLabel * lbStartSource = new QLabel ( " Start Source : " , tab ) ;
lbStartSource - > setAlignment ( Qt : : AlignRight ) ;
boardLayout - > addWidget ( lbStartSource , rowId , 0 ) ;
2023-03-14 16:17:22 -04:00
for ( int i = 0 ; i < ( int ) PHA : : DIG : : StartSource . GetAnswers ( ) . size ( ) ; i + + ) {
ckbStartSource [ iDigi ] [ i ] = new QCheckBox ( QString : : fromStdString ( ( PHA : : DIG : : StartSource . GetAnswers ( ) ) [ i ] . second ) , tab ) ;
2023-02-27 15:23:28 -05:00
boardLayout - > addWidget ( ckbStartSource [ iDigi ] [ i ] , rowId , 1 + i ) ;
2023-03-01 12:26:37 -05:00
connect ( ckbStartSource [ iDigi ] [ i ] , & QCheckBox : : stateChanged , this , & DigiSettingsPanel : : SetStartSource ) ;
2023-02-24 19:21:27 -05:00
}
2023-01-25 18:27:05 -05:00
//-------------------------------------
rowId + + ;
QLabel * lbGlobalTrgSource = new QLabel ( " Global Trigger Source : " , tab ) ;
lbGlobalTrgSource - > setAlignment ( Qt : : AlignRight ) ;
boardLayout - > addWidget ( lbGlobalTrgSource , rowId , 0 ) ;
2023-03-14 16:17:22 -04:00
for ( int i = 0 ; i < ( int ) PHA : : DIG : : GlobalTriggerSource . GetAnswers ( ) . size ( ) ; i + + ) {
ckbGlbTrgSource [ iDigi ] [ i ] = new QCheckBox ( QString : : fromStdString ( ( PHA : : DIG : : GlobalTriggerSource . GetAnswers ( ) ) [ i ] . second ) , tab ) ;
2023-02-27 15:23:28 -05:00
boardLayout - > addWidget ( ckbGlbTrgSource [ iDigi ] [ i ] , rowId , 1 + i ) ;
2023-03-02 18:18:02 -05:00
connect ( ckbGlbTrgSource [ iDigi ] [ i ] , & QCheckBox : : stateChanged , this , & DigiSettingsPanel : : SetGlobalTriggerSource ) ;
2023-02-27 15:23:28 -05:00
}
2023-01-25 18:27:05 -05:00
//-------------------------------------
rowId + + ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbTrgOut [ iDigi ] , PHA : : DIG : : TrgOutMode , - 1 , true , " Trg-OUT Mode : " , boardLayout , rowId , 0 , 1 , 2 ) ;
2023-02-27 15:23:28 -05:00
2023-01-25 18:27:05 -05:00
//-------------------------------------
rowId + + ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbGPIO [ iDigi ] , PHA : : DIG : : GPIOMode , - 1 , true , " GPIO Mode : " , boardLayout , rowId , 0 , 1 , 2 ) ;
2023-01-25 18:27:05 -05:00
2023-02-22 20:07:39 -05:00
//-------------------------------------
QLabel * lbAutoDisarmAcq = new QLabel ( " Auto disarm ACQ : " , tab ) ;
lbAutoDisarmAcq - > setAlignment ( Qt : : AlignRight ) ;
boardLayout - > addWidget ( lbAutoDisarmAcq , rowId , 4 , 1 , 2 ) ;
2023-03-03 15:23:26 -05:00
cbbAutoDisarmAcq [ iDigi ] = new RComboBox ( tab ) ;
2023-02-27 15:23:28 -05:00
boardLayout - > addWidget ( cbbAutoDisarmAcq [ iDigi ] , rowId , 6 ) ;
2023-03-14 16:17:22 -04:00
SetupShortComboBox ( cbbAutoDisarmAcq [ iDigi ] , PHA : : DIG : : EnableAutoDisarmACQ ) ;
2023-03-03 16:19:39 -05:00
connect ( cbbAutoDisarmAcq [ iDigi ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) {
if ( ! enableSignalSlot ) return ;
//printf("%s %d %s \n", para.GetPara().c_str(), ch_index, cbb->currentData().toString().toStdString().c_str());
QString msg ;
2023-03-14 16:17:22 -04:00
msg = QString : : fromStdString ( PHA : : DIG : : EnableAutoDisarmACQ . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
2023-03-03 16:19:39 -05:00
msg + = " = " + cbbAutoDisarmAcq [ ID ] - > currentData ( ) . toString ( ) ;
2023-03-14 16:17:22 -04:00
if ( digi [ ID ] - > WriteValue ( PHA : : DIG : : EnableAutoDisarmACQ , cbbAutoDisarmAcq [ ID ] - > currentData ( ) . toString ( ) . toStdString ( ) ) ) {
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |OK. " ) ;
2023-03-03 16:19:39 -05:00
cbbAutoDisarmAcq [ ID ] - > setStyleSheet ( " " ) ;
} else {
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |Fail. " ) ;
2023-03-03 16:19:39 -05:00
cbbAutoDisarmAcq [ ID ] - > setStyleSheet ( " color:red; " ) ;
}
} ) ;
2023-02-22 20:07:39 -05:00
2023-01-25 18:27:05 -05:00
//-------------------------------------
rowId + + ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbBusyIn [ iDigi ] , PHA : : DIG : : BusyInSource , - 1 , true , " Busy In Source : " , boardLayout , rowId , 0 , 1 , 2 ) ;
2023-02-27 15:23:28 -05:00
2023-02-22 20:07:39 -05:00
QLabel * lbStatEvents = new QLabel ( " Stat. Event : " , tab ) ;
lbStatEvents - > setAlignment ( Qt : : AlignRight ) ;
boardLayout - > addWidget ( lbStatEvents , rowId , 4 , 1 , 2 ) ;
2023-03-03 15:23:26 -05:00
cbbStatEvents [ iDigi ] = new RComboBox ( tab ) ;
2023-02-27 15:23:28 -05:00
boardLayout - > addWidget ( cbbStatEvents [ iDigi ] , rowId , 6 ) ;
2023-03-14 16:17:22 -04:00
SetupShortComboBox ( cbbStatEvents [ iDigi ] , PHA : : DIG : : EnableStatisticEvents ) ;
2023-03-03 15:23:26 -05:00
connect ( cbbStatEvents [ iDigi ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) {
2023-03-01 12:26:37 -05:00
if ( ! enableSignalSlot ) return ;
2023-03-03 16:19:39 -05:00
QString msg ;
2023-03-14 16:17:22 -04:00
msg = QString : : fromStdString ( PHA : : DIG : : EnableStatisticEvents . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
2023-03-03 16:19:39 -05:00
msg + = " = " + cbbStatEvents [ ID ] - > currentData ( ) . toString ( ) ;
2023-03-14 16:17:22 -04:00
if ( digi [ ID ] - > WriteValue ( PHA : : DIG : : EnableStatisticEvents , cbbStatEvents [ ID ] - > currentData ( ) . toString ( ) . toStdString ( ) ) ) {
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |OK. " ) ;
2023-03-03 16:19:39 -05:00
cbbStatEvents [ ID ] - > setStyleSheet ( " " ) ;
} else {
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |Fail. " ) ;
2023-03-03 16:19:39 -05:00
cbbStatEvents [ ID ] - > setStyleSheet ( " color:red " ) ;
}
2023-03-01 12:26:37 -05:00
} ) ;
2023-01-25 18:27:05 -05:00
//-------------------------------------
rowId + + ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbSyncOut [ iDigi ] , PHA : : DIG : : SyncOutMode , - 1 , true , " Sync Out mode : " , boardLayout , rowId , 0 , 1 , 2 ) ;
2023-01-25 17:16:14 -05:00
2023-01-25 18:27:05 -05:00
//-------------------------------------
rowId + + ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbBoardVetoSource [ iDigi ] , PHA : : DIG : : BoardVetoSource , - 1 , true , " Board Veto Source : " , boardLayout , rowId , 0 , 1 , 2 ) ;
2023-02-27 15:23:28 -05:00
QLabel * lbBdVetoWidth = new QLabel ( " Board Veto Width [ns] : " , tab ) ;
2023-01-25 18:27:05 -05:00
lbBdVetoWidth - > setAlignment ( Qt : : AlignRight ) ;
boardLayout - > addWidget ( lbBdVetoWidth , rowId , 3 , 1 , 2 ) ;
2023-03-03 15:23:26 -05:00
dsbBdVetoWidth [ iDigi ] = new RSpinBox ( tab , 0 ) ; // may be QDoubleSpinBox
2023-03-02 18:18:02 -05:00
dsbBdVetoWidth [ iDigi ] - > setMinimum ( 0 ) ;
dsbBdVetoWidth [ iDigi ] - > setMaximum ( 34359738360 ) ;
dsbBdVetoWidth [ iDigi ] - > setSingleStep ( 20 ) ;
boardLayout - > addWidget ( dsbBdVetoWidth [ iDigi ] , rowId , 5 ) ;
2023-03-03 15:23:26 -05:00
connect ( dsbBdVetoWidth [ iDigi ] , & RSpinBox : : valueChanged , this , [ = ] ( ) {
2023-03-03 16:19:39 -05:00
if ( ! enableSignalSlot ) return ;
dsbBdVetoWidth [ ID ] - > setStyleSheet ( " color:blue; " ) ;
} ) ;
connect ( dsbBdVetoWidth [ iDigi ] , & RSpinBox : : returnPressed , this , [ = ] ( ) {
2023-03-01 18:27:17 -05:00
if ( ! enableSignalSlot ) return ;
//printf("%s %d %d \n", para.GetPara().c_str(), ch_index, spb->value());
2023-03-03 16:19:39 -05:00
QString msg ;
2023-03-14 16:17:22 -04:00
msg = QString : : fromStdString ( PHA : : DIG : : BoardVetoWidth . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
2023-03-03 16:19:39 -05:00
msg + = " = " + QString : : number ( dsbBdVetoWidth [ iDigi ] - > value ( ) ) ;
2023-03-14 16:17:22 -04:00
if ( digi [ ID ] - > WriteValue ( PHA : : DIG : : BoardVetoWidth , std : : to_string ( dsbBdVetoWidth [ iDigi ] - > value ( ) ) , - 1 ) ) {
2023-03-03 16:19:39 -05:00
dsbBdVetoWidth [ ID ] - > setStyleSheet ( " " ) ;
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |OK. " ) ;
2023-03-03 16:19:39 -05:00
} else {
dsbBdVetoWidth [ ID ] - > setStyleSheet ( " color:red; " ) ;
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |Fail. " ) ;
2023-03-03 16:19:39 -05:00
}
2023-03-01 18:27:17 -05:00
} ) ;
2023-01-25 18:27:05 -05:00
2023-03-03 15:23:26 -05:00
cbbBdVetoPolarity [ iDigi ] = new RComboBox ( tab ) ;
2023-02-27 15:23:28 -05:00
boardLayout - > addWidget ( cbbBdVetoPolarity [ iDigi ] , rowId , 6 ) ;
2023-03-14 16:17:22 -04:00
SetupShortComboBox ( cbbBdVetoPolarity [ iDigi ] , PHA : : DIG : : BoardVetoPolarity ) ;
2023-01-25 18:27:05 -05:00
//-------------------------------------
rowId + + ;
2023-03-14 16:17:22 -04:00
SetupSpinBox ( spbRunDelay [ iDigi ] , PHA : : DIG : : RunDelay , - 1 , false , " Run Delay [ns] : " , boardLayout , rowId , 0 ) ;
2023-01-25 18:27:05 -05:00
//-------------------------------------
2023-02-27 15:23:28 -05:00
QLabel * lbClockOutDelay = new QLabel ( " Temp. Clock Out Delay [ps] : " , tab ) ;
2023-01-25 18:27:05 -05:00
lbClockOutDelay - > setAlignment ( Qt : : AlignRight ) ;
2023-02-22 20:07:39 -05:00
boardLayout - > addWidget ( lbClockOutDelay , rowId , 3 , 1 , 2 ) ;
2023-01-25 18:27:05 -05:00
2023-03-03 15:23:26 -05:00
dsbVolatileClockOutDelay [ iDigi ] = new RSpinBox ( tab , 3 ) ;
2023-02-27 15:23:28 -05:00
dsbVolatileClockOutDelay [ iDigi ] - > setMinimum ( - 18888.888 ) ;
dsbVolatileClockOutDelay [ iDigi ] - > setMaximum ( 18888.888 ) ;
2023-03-03 16:19:39 -05:00
dsbVolatileClockOutDelay [ iDigi ] - > setSingleStep ( 74.074 ) ;
2023-02-27 15:23:28 -05:00
dsbVolatileClockOutDelay [ iDigi ] - > setValue ( 0 ) ;
boardLayout - > addWidget ( dsbVolatileClockOutDelay [ iDigi ] , rowId , 5 ) ;
2023-03-03 16:19:39 -05:00
connect ( dsbVolatileClockOutDelay [ iDigi ] , & RSpinBox : : valueChanged , this , [ = ] ( ) {
if ( ! enableSignalSlot ) return ;
dsbVolatileClockOutDelay [ ID ] - > setStyleSheet ( " color:blue; " ) ;
} ) ;
connect ( dsbVolatileClockOutDelay [ iDigi ] , & RSpinBox : : returnPressed , this , [ = ] ( ) {
2023-03-01 18:27:17 -05:00
if ( ! enableSignalSlot ) return ;
//printf("%s %d %d \n", para.GetPara().c_str(), ch_index, spb->value());
2023-03-03 16:19:39 -05:00
double step = dsbVolatileClockOutDelay [ ID ] - > singleStep ( ) ;
double value = dsbVolatileClockOutDelay [ ID ] - > value ( ) ;
dsbVolatileClockOutDelay [ ID ] - > setValue ( ( std : : round ( value / step ) * step ) ) ;
QString msg ;
2023-03-14 16:17:22 -04:00
msg = QString : : fromStdString ( PHA : : DIG : : VolatileClockOutDelay . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
2023-03-03 16:19:39 -05:00
msg + = " = " + QString : : number ( dsbVolatileClockOutDelay [ iDigi ] - > value ( ) ) ;
2023-03-14 16:17:22 -04:00
if ( digi [ ID ] - > WriteValue ( PHA : : DIG : : VolatileClockOutDelay , std : : to_string ( dsbVolatileClockOutDelay [ ID ] - > value ( ) ) , - 1 ) ) {
2023-03-03 16:19:39 -05:00
dsbVolatileClockOutDelay [ ID ] - > setStyleSheet ( " " ) ;
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |OK. " ) ;
2023-03-03 16:19:39 -05:00
} else {
dsbVolatileClockOutDelay [ ID ] - > setStyleSheet ( " color:red; " ) ;
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |Fail. " ) ;
2023-03-03 16:19:39 -05:00
}
2023-03-01 18:27:17 -05:00
} ) ;
2023-01-25 18:27:05 -05:00
//-------------------------------------
rowId + + ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbIOLevel [ iDigi ] , PHA : : DIG : : IO_Level , - 1 , true , " IO Level : " , boardLayout , rowId , 0 , 1 , 2 ) ;
2023-01-25 18:27:05 -05:00
2023-02-27 15:23:28 -05:00
QLabel * lbClockOutDelay2 = new QLabel ( " Perm. Clock Out Delay [ps] : " , tab ) ;
lbClockOutDelay2 - > setAlignment ( Qt : : AlignRight ) ;
boardLayout - > addWidget ( lbClockOutDelay2 , rowId , 3 , 1 , 2 ) ;
2023-03-03 15:23:26 -05:00
dsbClockOutDelay [ iDigi ] = new RSpinBox ( tab , 3 ) ;
2023-02-27 15:23:28 -05:00
dsbClockOutDelay [ iDigi ] - > setMinimum ( - 18888.888 ) ;
dsbClockOutDelay [ iDigi ] - > setMaximum ( 18888.888 ) ;
dsbClockOutDelay [ iDigi ] - > setValue ( 0 ) ;
2023-03-03 16:19:39 -05:00
dsbClockOutDelay [ iDigi ] - > setSingleStep ( 74.074 ) ;
2023-02-27 15:23:28 -05:00
boardLayout - > addWidget ( dsbClockOutDelay [ iDigi ] , rowId , 5 ) ;
2023-03-03 16:19:39 -05:00
connect ( dsbClockOutDelay [ iDigi ] , & RSpinBox : : valueChanged , this , [ = ] ( ) {
if ( ! enableSignalSlot ) return ;
dsbClockOutDelay [ ID ] - > setStyleSheet ( " color:blue; " ) ;
} ) ;
connect ( dsbClockOutDelay [ iDigi ] , & RSpinBox : : returnPressed , this , [ = ] ( ) {
2023-03-01 18:27:17 -05:00
if ( ! enableSignalSlot ) return ;
//printf("%s %d %d \n", para.GetPara().c_str(), ch_index, spb->value());
2023-03-03 16:19:39 -05:00
double step = dsbClockOutDelay [ ID ] - > singleStep ( ) ;
double value = dsbClockOutDelay [ ID ] - > value ( ) ;
dsbClockOutDelay [ ID ] - > setValue ( ( std : : round ( value / step ) * step ) ) ;
QString msg ;
2023-03-14 16:17:22 -04:00
msg = QString : : fromStdString ( PHA : : DIG : : PermanentClockOutDelay . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
2023-03-03 16:19:39 -05:00
msg + = " = " + QString : : number ( dsbClockOutDelay [ iDigi ] - > value ( ) ) ;
2023-03-14 16:17:22 -04:00
if ( digi [ ID ] - > WriteValue ( PHA : : DIG : : PermanentClockOutDelay , std : : to_string ( dsbClockOutDelay [ ID ] - > value ( ) ) , - 1 ) ) {
2023-03-03 16:19:39 -05:00
dsbClockOutDelay [ ID ] - > setStyleSheet ( " " ) ;
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |OK. " ) ;
2023-03-03 16:19:39 -05:00
} else {
dsbClockOutDelay [ ID ] - > setStyleSheet ( " color:red; " ) ;
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |Fail. " ) ;
2023-03-03 16:19:39 -05:00
}
2023-03-01 18:27:17 -05:00
} ) ;
2023-01-25 18:27:05 -05:00
}
2023-03-01 18:27:17 -05:00
2023-02-27 15:23:28 -05:00
{ //^====================== Test Pulse settings
testPulseBox = new QGroupBox ( " Test Pulse Settings " , tab ) ;
2023-02-28 13:28:30 -05:00
tabLayout_V1 - > addWidget ( testPulseBox ) ;
2023-02-27 15:23:28 -05:00
QGridLayout * testPulseLayout = new QGridLayout ( testPulseBox ) ;
2023-02-28 13:28:30 -05:00
testPulseLayout - > setAlignment ( Qt : : AlignLeft ) ;
2023-03-02 18:18:02 -05:00
testPulseLayout - > setVerticalSpacing ( 0 ) ;
2023-03-14 16:17:22 -04:00
SetupSpinBox ( dsbTestPuslePeriod [ iDigi ] , PHA : : DIG : : TestPulsePeriod , - 1 , false , " Period [ns] : " , testPulseLayout , 0 , 0 ) ;
SetupSpinBox ( dsbTestPusleWidth [ iDigi ] , PHA : : DIG : : TestPulseWidth , - 1 , false , " Width [ns] : " , testPulseLayout , 0 , 2 ) ;
SetupSpinBox ( spbTestPusleLowLevel [ iDigi ] , PHA : : DIG : : TestPulseLowLevel , - 1 , false , " Low Lvl. [LSB] : " , testPulseLayout , 0 , 4 ) ;
SetupSpinBox ( spbTestPusleHighLevel [ iDigi ] , PHA : : DIG : : TestPulseHighLevel , - 1 , false , " High Lvl. [LSB] : " , testPulseLayout , 0 , 6 ) ;
2023-02-27 15:23:28 -05:00
2023-03-02 18:18:02 -05:00
dsbTestPuslePeriod [ iDigi ] - > setFixedSize ( 110 , 30 ) ;
dsbTestPuslePeriod [ iDigi ] - > setDecimals ( 0 ) ;
dsbTestPusleWidth [ iDigi ] - > setFixedSize ( 110 , 30 ) ;
dsbTestPusleWidth [ iDigi ] - > setDecimals ( 0 ) ;
for ( int i = 0 ; i < testPulseLayout - > columnCount ( ) ; i + + ) testPulseLayout - > setColumnStretch ( i , 0 ) ;
2023-02-27 15:23:28 -05:00
}
2023-03-02 18:18:02 -05:00
{ //^====================== VGA settings
VGABox = new QGroupBox ( " Gain Amplifier Settings " , tab ) ;
tabLayout_V1 - > addWidget ( VGABox ) ;
QGridLayout * vgaLayout = new QGridLayout ( VGABox ) ;
vgaLayout - > setVerticalSpacing ( 0 ) ;
//vgaLayout->setAlignment(Qt::AlignLeft);
for ( int k = 0 ; k < 4 ; k + + ) {
QLabel * lb = new QLabel ( " VGA- " + QString : : number ( k ) + " [dB] : " , tab ) ;
lb - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
vgaLayout - > addWidget ( lb , 0 , 2 * k ) ;
2023-03-03 15:23:26 -05:00
VGA [ iDigi ] [ k ] = new RSpinBox ( tab , 1 ) ;
2023-03-02 18:18:02 -05:00
VGA [ iDigi ] [ k ] - > setMinimum ( 0 ) ;
VGA [ iDigi ] [ k ] - > setMaximum ( 40 ) ;
VGA [ iDigi ] [ k ] - > setSingleStep ( 0.5 ) ;
vgaLayout - > addWidget ( VGA [ iDigi ] [ k ] , 0 , 2 * k + 1 ) ;
2023-03-03 16:19:39 -05:00
connect ( VGA [ iDigi ] [ k ] , & RSpinBox : : valueChanged , this , [ = ] ( ) {
if ( ! enableSignalSlot ) return ;
VGA [ ID ] [ k ] - > setStyleSheet ( " color:blue; " ) ;
} ) ;
connect ( VGA [ iDigi ] [ k ] , & RSpinBox : : returnPressed , this , [ = ] ( ) {
if ( ! enableSignalSlot ) return ;
//printf("%s %d %d \n", para.GetPara().c_str(), ch_index, spb->value());
double step = VGA [ ID ] [ k ] - > singleStep ( ) ;
double value = VGA [ ID ] [ k ] - > value ( ) ;
VGA [ ID ] [ k ] - > setValue ( ( std : : round ( value / step ) * step ) ) ;
QString msg ;
2023-03-14 16:17:22 -04:00
msg = QString : : fromStdString ( PHA : : VGA : : VGAGain . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
if ( PHA : : VGA : : VGAGain . GetType ( ) = = TYPE : : VGA ) msg + = " ,VGA: " + QString : : number ( k ) ;
2023-03-03 16:19:39 -05:00
msg + = " = " + QString : : number ( VGA [ ID ] [ k ] - > value ( ) ) ;
2023-03-14 16:17:22 -04:00
if ( digi [ ID ] - > WriteValue ( PHA : : VGA : : VGAGain , std : : to_string ( VGA [ ID ] [ k ] - > value ( ) ) , k ) ) {
2023-03-03 16:19:39 -05:00
VGA [ ID ] [ k ] - > setStyleSheet ( " " ) ;
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |OK. " ) ;
2023-03-03 16:19:39 -05:00
} else {
VGA [ ID ] [ k ] - > setStyleSheet ( " color:red; " ) ;
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |Fail. " ) ;
2023-03-03 16:19:39 -05:00
}
} ) ;
2023-03-02 18:18:02 -05:00
}
}
if ( digi [ iDigi ] - > GetFPGATyep ( ) ! = " DPP_PHA " ) VGABox - > setEnabled ( false ) ;
2023-02-22 20:07:39 -05:00
{ //^====================== Group channel settings
2023-02-23 16:08:47 -05:00
QGroupBox * chBox = new QGroupBox ( " Channel Settings " , tab ) ;
2023-02-28 13:28:30 -05:00
//chBox->setSizePolicy(sizePolicy);
2023-02-23 16:08:47 -05:00
tabLayout_V2 - > addWidget ( chBox ) ;
2023-01-30 18:40:24 -05:00
QGridLayout * chLayout = new QGridLayout ( chBox ) ; //chBox->setLayout(chLayout);
2023-02-27 15:23:28 -05:00
QTabWidget * chTabWidget = new QTabWidget ( tab ) ; chLayout - > addWidget ( chTabWidget ) ;
2023-01-30 18:40:24 -05:00
2023-02-28 13:28:30 -05:00
{ //@.......... All Settings tab
2023-01-30 18:40:24 -05:00
QWidget * tab_All = new QWidget ( tab ) ;
2023-02-27 15:23:28 -05:00
//tab_All->setStyleSheet("background-color: #EEEEEE");
2023-03-13 16:51:11 -04:00
chTabWidget - > addTab ( tab_All , " All/Single Ch. " ) ;
2023-01-30 18:40:24 -05:00
QGridLayout * allLayout = new QGridLayout ( tab_All ) ;
2023-02-28 13:28:30 -05:00
allLayout - > setAlignment ( Qt : : AlignTop ) ;
2023-01-30 18:40:24 -05:00
2023-02-02 19:01:10 -05:00
unsigned short ch = digi [ iDigi ] - > GetNChannels ( ) ;
2023-01-30 18:40:24 -05:00
2023-03-13 16:51:11 -04:00
{ //*--------- Group 0
box0 = new QGroupBox ( " Channel Selection " , tab ) ;
allLayout - > addWidget ( box0 ) ;
QGridLayout * layout0 = new QGridLayout ( box0 ) ;
layout0 - > setAlignment ( Qt : : AlignLeft ) ;
QLabel * lbCh = new QLabel ( " Channel : " , tab ) ;
lbCh - > setAlignment ( Qt : : AlignCenter | Qt : : AlignRight ) ;
layout0 - > addWidget ( lbCh , 0 , 0 ) ;
cbChPick [ iDigi ] = new RComboBox ( tab ) ;
cbChPick [ iDigi ] - > addItem ( " All " , - 1 ) ;
2023-03-13 19:23:14 -04:00
for ( int i = 0 ; i < ch ; i + + ) cbChPick [ iDigi ] - > addItem ( " Ch- " + QString : : number ( i ) , i ) ;
2023-03-13 16:51:11 -04:00
layout0 - > addWidget ( cbChPick [ iDigi ] , 0 , 1 ) ;
2023-03-13 19:23:14 -04:00
connect ( cbChPick [ iDigi ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) {
int index = cbChPick [ ID ] - > currentData ( ) . toInt ( ) ;
if ( index = = - 1 ) {
ShowSettingsToPanel ( ) ;
return ;
} else {
enableSignalSlot = false ;
unsigned short ch = digi [ iDigi ] - > GetNChannels ( ) ;
printf ( " index = %d, ch = %d \n " , index , ch ) ;
2023-03-14 16:17:22 -04:00
FillComboBoxValueFromMemory ( cbbOnOff [ ID ] [ ch ] , PHA : : CH : : ChannelEnable , index ) ;
FillSpinBoxValueFromMemory ( spbDCOffset [ ID ] [ ch ] , PHA : : CH : : DC_Offset , index ) ;
FillSpinBoxValueFromMemory ( spbThreshold [ ID ] [ ch ] , PHA : : CH : : TriggerThreshold , index ) ;
FillComboBoxValueFromMemory ( cbbParity [ ID ] [ ch ] , PHA : : CH : : Polarity , index ) ;
FillSpinBoxValueFromMemory ( spbRecordLength [ ID ] [ ch ] , PHA : : CH : : RecordLength , index ) ;
FillSpinBoxValueFromMemory ( spbPreTrigger [ ID ] [ ch ] , PHA : : CH : : PreTrigger , index ) ;
FillSpinBoxValueFromMemory ( spbInputRiseTime [ ID ] [ ch ] , PHA : : CH : : TimeFilterRiseTime , index ) ;
FillSpinBoxValueFromMemory ( spbTriggerGuard [ ID ] [ ch ] , PHA : : CH : : TimeFilterRetriggerGuard , index ) ;
FillComboBoxValueFromMemory ( cbbLowFilter [ ID ] [ ch ] , PHA : : CH : : EnergyFilterLowFreqFilter , index ) ;
FillComboBoxValueFromMemory ( cbbWaveSource [ ID ] [ ch ] , PHA : : CH : : WaveDataSource , index ) ;
FillComboBoxValueFromMemory ( cbbWaveRes [ ID ] [ ch ] , PHA : : CH : : WaveResolution , index ) ;
FillComboBoxValueFromMemory ( cbbWaveSave [ ID ] [ ch ] , PHA : : CH : : WaveSaving , index ) ;
FillSpinBoxValueFromMemory ( spbTrapRiseTime [ ID ] [ ch ] , PHA : : CH : : EnergyFilterRiseTime , index ) ;
FillSpinBoxValueFromMemory ( spbTrapFlatTop [ ID ] [ ch ] , PHA : : CH : : EnergyFilterFlatTop , index ) ;
FillSpinBoxValueFromMemory ( spbTrapPoleZero [ ID ] [ ch ] , PHA : : CH : : EnergyFilterPoleZero , index ) ;
FillSpinBoxValueFromMemory ( spbPeaking [ ID ] [ ch ] , PHA : : CH : : EnergyFilterPeakingPosition , index ) ;
FillComboBoxValueFromMemory ( cbbPeakingAvg [ ID ] [ ch ] , PHA : : CH : : EnergyFilterPeakingAvg , index ) ;
FillComboBoxValueFromMemory ( cbbBaselineAvg [ ID ] [ ch ] , PHA : : CH : : EnergyFilterBaselineAvg , index ) ;
FillSpinBoxValueFromMemory ( spbFineGain [ ID ] [ ch ] , PHA : : CH : : EnergyFilterFineGain , index ) ;
FillSpinBoxValueFromMemory ( spbBaselineGuard [ ID ] [ ch ] , PHA : : CH : : EnergyFilterBaselineGuard , index ) ;
FillSpinBoxValueFromMemory ( spbPileupGuard [ ID ] [ ch ] , PHA : : CH : : EnergyFilterPileUpGuard , index ) ;
FillComboBoxValueFromMemory ( cbbAnaProbe0 [ ID ] [ ch ] , PHA : : CH : : WaveAnalogProbe0 , index ) ;
FillComboBoxValueFromMemory ( cbbAnaProbe1 [ ID ] [ ch ] , PHA : : CH : : WaveAnalogProbe1 , index ) ;
FillComboBoxValueFromMemory ( cbbDigProbe0 [ ID ] [ ch ] , PHA : : CH : : WaveDigitalProbe0 , index ) ;
FillComboBoxValueFromMemory ( cbbDigProbe1 [ ID ] [ ch ] , PHA : : CH : : WaveDigitalProbe1 , index ) ;
FillComboBoxValueFromMemory ( cbbDigProbe2 [ ID ] [ ch ] , PHA : : CH : : WaveDigitalProbe2 , index ) ;
FillComboBoxValueFromMemory ( cbbDigProbe3 [ ID ] [ ch ] , PHA : : CH : : WaveDigitalProbe3 , index ) ;
FillComboBoxValueFromMemory ( cbbEventSelector [ ID ] [ ch ] , PHA : : CH : : EventSelector , index ) ;
FillComboBoxValueFromMemory ( cbbWaveSelector [ ID ] [ ch ] , PHA : : CH : : WaveSelector , index ) ;
FillSpinBoxValueFromMemory ( spbEnergySkimLow [ ID ] [ ch ] , PHA : : CH : : EnergySkimLowDiscriminator , index ) ;
FillSpinBoxValueFromMemory ( spbEnergySkimHigh [ ID ] [ ch ] , PHA : : CH : : EnergySkimHighDiscriminator , index ) ;
FillComboBoxValueFromMemory ( cbbEvtTrigger [ ID ] [ ch ] , PHA : : CH : : EventTriggerSource , index ) ;
FillComboBoxValueFromMemory ( cbbWaveTrigger [ ID ] [ ch ] , PHA : : CH : : WaveTriggerSource , index ) ;
FillComboBoxValueFromMemory ( cbbChVetoSrc [ ID ] [ ch ] , PHA : : CH : : ChannelVetoSource , index ) ;
FillComboBoxValueFromMemory ( cbbCoinMask [ ID ] [ ch ] , PHA : : CH : : CoincidenceMask , index ) ;
FillComboBoxValueFromMemory ( cbbAntiCoinMask [ ID ] [ ch ] , PHA : : CH : : AntiCoincidenceMask , index ) ;
FillSpinBoxValueFromMemory ( spbCoinLength [ ID ] [ ch ] , PHA : : CH : : CoincidenceLength , index ) ;
FillSpinBoxValueFromMemory ( spbADCVetoWidth [ ID ] [ ch ] , PHA : : CH : : ADCVetoWidth , index ) ;
2023-03-13 19:23:14 -04:00
enableSignalSlot = true ;
}
} ) ;
2023-03-13 16:51:11 -04:00
}
2023-02-27 15:23:28 -05:00
int rowID = 0 ;
2023-02-28 13:28:30 -05:00
{ //*--------- Group 1
2023-03-10 17:28:02 -05:00
box1 = new QGroupBox ( " Input Settings " , tab ) ;
2023-02-28 13:28:30 -05:00
allLayout - > addWidget ( box1 ) ;
QGridLayout * layout1 = new QGridLayout ( box1 ) ;
rowID = 0 ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbOnOff [ iDigi ] [ ch ] , PHA : : CH : : ChannelEnable , - 1 , true , " On/Off " , layout1 , rowID , 0 ) ;
SetupComboBox ( cbbWaveSource [ iDigi ] [ ch ] , PHA : : CH : : WaveDataSource , - 1 , true , " Wave Data Source " , layout1 , rowID , 2 ) ;
2023-02-28 13:28:30 -05:00
rowID + + ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbWaveRes [ iDigi ] [ ch ] , PHA : : CH : : WaveResolution , - 1 , true , " Wave Resol. " , layout1 , rowID , 0 ) ;
SetupComboBox ( cbbWaveSave [ iDigi ] [ ch ] , PHA : : CH : : WaveSaving , - 1 , true , " Wave Save " , layout1 , rowID , 2 ) ;
2023-03-01 18:27:17 -05:00
rowID + + ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbParity [ iDigi ] [ ch ] , PHA : : CH : : Polarity , - 1 , true , " Parity " , layout1 , rowID , 0 ) ;
SetupComboBox ( cbbLowFilter [ iDigi ] [ ch ] , PHA : : CH : : EnergyFilterLowFreqFilter , - 1 , true , " Low Freq. Filter " , layout1 , rowID , 2 ) ;
2023-02-28 13:28:30 -05:00
rowID + + ;
2023-03-14 16:17:22 -04:00
SetupSpinBox ( spbDCOffset [ iDigi ] [ ch ] , PHA : : CH : : DC_Offset , - 1 , false , " DC Offset [%] " , layout1 , rowID , 0 ) ;
SetupSpinBox ( spbThreshold [ iDigi ] [ ch ] , PHA : : CH : : TriggerThreshold , - 1 , false , " Threshold [LSB] " , layout1 , rowID , 2 ) ;
2023-02-28 13:28:30 -05:00
rowID + + ;
2023-03-14 16:17:22 -04:00
SetupSpinBox ( spbInputRiseTime [ iDigi ] [ ch ] , PHA : : CH : : TimeFilterRiseTime , - 1 , false , " Input Rise Time [ns] " , layout1 , rowID , 0 ) ;
SetupSpinBox ( spbTriggerGuard [ iDigi ] [ ch ] , PHA : : CH : : TimeFilterRetriggerGuard , - 1 , false , " Trigger Guard [ns] " , layout1 , rowID , 2 ) ;
2023-02-28 13:28:30 -05:00
rowID + + ;
2023-03-14 16:17:22 -04:00
SetupSpinBox ( spbRecordLength [ iDigi ] [ ch ] , PHA : : CH : : RecordLength , - 1 , false , " Record Length [ns] " , layout1 , rowID , 0 ) ;
SetupSpinBox ( spbPreTrigger [ iDigi ] [ ch ] , PHA : : CH : : PreTrigger , - 1 , false , " Pre Trigger [ns] " , layout1 , rowID , 2 ) ;
2023-02-28 13:28:30 -05:00
}
2023-02-27 15:23:28 -05:00
2023-02-28 13:28:30 -05:00
{ //*--------- Group 3
2023-03-10 17:28:02 -05:00
box3 = new QGroupBox ( " Trap. Settings " , tab ) ;
2023-02-28 13:28:30 -05:00
allLayout - > addWidget ( box3 ) ;
QGridLayout * layout3 = new QGridLayout ( box3 ) ;
//------------------------------
2023-03-01 12:26:37 -05:00
rowID = 0 ;
2023-03-14 16:17:22 -04:00
SetupSpinBox ( spbTrapRiseTime [ iDigi ] [ ch ] , PHA : : CH : : EnergyFilterRiseTime , - 1 , false , " Trap. Rise Time [ns] " , layout3 , rowID , 0 ) ;
SetupSpinBox ( spbTrapFlatTop [ iDigi ] [ ch ] , PHA : : CH : : EnergyFilterFlatTop , - 1 , false , " Trap. Flat Top [ns] " , layout3 , rowID , 2 ) ;
SetupSpinBox ( spbTrapPoleZero [ iDigi ] [ ch ] , PHA : : CH : : EnergyFilterPoleZero , - 1 , false , " Trap. Pole Zero [ns] " , layout3 , rowID , 4 ) ;
2023-02-28 13:28:30 -05:00
//------------------------------
rowID + + ;
2023-03-14 16:17:22 -04:00
SetupSpinBox ( spbPeaking [ iDigi ] [ ch ] , PHA : : CH : : EnergyFilterPeakingPosition , - 1 , false , " Peaking [%] " , layout3 , rowID , 0 ) ;
SetupSpinBox ( spbBaselineGuard [ iDigi ] [ ch ] , PHA : : CH : : EnergyFilterBaselineGuard , - 1 , false , " Baseline Guard [ns] " , layout3 , rowID , 2 ) ;
SetupSpinBox ( spbPileupGuard [ iDigi ] [ ch ] , PHA : : CH : : EnergyFilterPileUpGuard , - 1 , false , " Pile-up Guard [ns] " , layout3 , rowID , 4 ) ;
2023-02-28 13:28:30 -05:00
//------------------------------
rowID + + ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbPeakingAvg [ iDigi ] [ ch ] , PHA : : CH : : EnergyFilterPeakingAvg , - 1 , true , " Peak Avg " , layout3 , rowID , 0 ) ;
SetupComboBox ( cbbBaselineAvg [ iDigi ] [ ch ] , PHA : : CH : : EnergyFilterBaselineAvg , - 1 , true , " Baseline Avg " , layout3 , rowID , 2 ) ;
SetupSpinBox ( spbFineGain [ iDigi ] [ ch ] , PHA : : CH : : EnergyFilterFineGain , - 1 , false , " Fine Gain " , layout3 , rowID , 4 ) ;
2023-02-28 13:28:30 -05:00
}
{ //*--------- Group 4
2023-03-10 17:28:02 -05:00
box4 = new QGroupBox ( " Probe Settings " , tab ) ;
2023-02-28 13:28:30 -05:00
allLayout - > addWidget ( box4 ) ;
QGridLayout * layout4 = new QGridLayout ( box4 ) ;
//------------------------------
rowID = 0 ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbAnaProbe0 [ iDigi ] [ ch ] , PHA : : CH : : WaveAnalogProbe0 , - 1 , true , " Analog Prob. 0 " , layout4 , rowID , 0 , 1 , 2 ) ;
SetupComboBox ( cbbAnaProbe1 [ iDigi ] [ ch ] , PHA : : CH : : WaveAnalogProbe1 , - 1 , true , " Analog Prob. 1 " , layout4 , rowID , 3 , 1 , 2 ) ;
2023-02-28 13:28:30 -05:00
//------------------------------
rowID + + ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbDigProbe0 [ iDigi ] [ ch ] , PHA : : CH : : WaveDigitalProbe0 , - 1 , true , " Digitial Prob. 0 " , layout4 , rowID , 0 , 1 , 2 ) ;
SetupComboBox ( cbbDigProbe1 [ iDigi ] [ ch ] , PHA : : CH : : WaveDigitalProbe1 , - 1 , true , " Digitial Prob. 1 " , layout4 , rowID , 3 , 1 , 2 ) ;
2023-02-28 13:28:30 -05:00
//------------------------------
rowID + + ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbDigProbe2 [ iDigi ] [ ch ] , PHA : : CH : : WaveDigitalProbe2 , - 1 , true , " Digitial Prob. 2 " , layout4 , rowID , 0 , 1 , 2 ) ;
SetupComboBox ( cbbDigProbe3 [ iDigi ] [ ch ] , PHA : : CH : : WaveDigitalProbe3 , - 1 , true , " Digitial Prob. 3 " , layout4 , rowID , 3 , 1 , 2 ) ;
2023-02-28 13:28:30 -05:00
}
{ //*--------- Group 5
2023-03-10 17:28:02 -05:00
box5 = new QGroupBox ( " Trigger Settings " , tab ) ;
2023-02-28 13:28:30 -05:00
allLayout - > addWidget ( box5 ) ;
QGridLayout * layout5 = new QGridLayout ( box5 ) ;
//------------------------------
rowID = 0 ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbEvtTrigger [ iDigi ] [ ch ] , PHA : : CH : : EventTriggerSource , - 1 , true , " Event Trig. Source " , layout5 , rowID , 0 ) ;
SetupComboBox ( cbbWaveTrigger [ iDigi ] [ ch ] , PHA : : CH : : WaveTriggerSource , - 1 , true , " Wave Trig. Source " , layout5 , rowID , 2 ) ;
2023-02-28 13:28:30 -05:00
//------------------------------
rowID + + ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbChVetoSrc [ iDigi ] [ ch ] , PHA : : CH : : ChannelVetoSource , - 1 , true , " Veto Source " , layout5 , rowID , 0 ) ;
2023-02-28 13:28:30 -05:00
//------------------------------
rowID + + ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbCoinMask [ iDigi ] [ ch ] , PHA : : CH : : CoincidenceMask , - 1 , true , " Coin. Mask " , layout5 , rowID , 0 ) ;
SetupComboBox ( cbbAntiCoinMask [ iDigi ] [ ch ] , PHA : : CH : : AntiCoincidenceMask , - 1 , true , " Anti-Coin. Mask " , layout5 , rowID , 2 ) ;
2023-02-28 13:28:30 -05:00
//------------------------------
rowID + + ;
2023-03-14 16:17:22 -04:00
SetupSpinBox ( spbCoinLength [ iDigi ] [ ch ] , PHA : : CH : : CoincidenceLength , - 1 , false , " Coin. Length [ns] " , layout5 , rowID , 0 ) ;
SetupSpinBox ( spbADCVetoWidth [ iDigi ] [ ch ] , PHA : : CH : : ADCVetoWidth , - 1 , false , " ADC Veto Length [ns] " , layout5 , rowID , 2 ) ;
2023-02-28 17:08:34 -05:00
for ( int i = 0 ; i < layout5 - > columnCount ( ) ; i + + ) layout5 - > setColumnStretch ( i , 1 ) ;
}
{ //*--------- Group 6
2023-03-10 17:28:02 -05:00
box6 = new QGroupBox ( " Other Settings " , tab ) ;
2023-02-28 17:08:34 -05:00
allLayout - > addWidget ( box6 ) ;
QGridLayout * layout6 = new QGridLayout ( box6 ) ;
//------------------------------
rowID = 0 ;
2023-03-14 16:17:22 -04:00
SetupComboBox ( cbbEventSelector [ iDigi ] [ ch ] , PHA : : CH : : EventSelector , - 1 , true , " Event Selector " , layout6 , rowID , 0 ) ;
SetupComboBox ( cbbWaveSelector [ iDigi ] [ ch ] , PHA : : CH : : WaveSelector , - 1 , true , " Wave Selector " , layout6 , rowID , 2 ) ;
2023-02-28 17:08:34 -05:00
2023-02-28 13:28:30 -05:00
//------------------------------
rowID + + ;
2023-03-14 16:17:22 -04:00
SetupSpinBox ( spbEnergySkimLow [ iDigi ] [ ch ] , PHA : : CH : : EnergySkimLowDiscriminator , - 1 , false , " Energy Skim Low " , layout6 , rowID , 0 ) ;
SetupSpinBox ( spbEnergySkimHigh [ iDigi ] [ ch ] , PHA : : CH : : EnergySkimHighDiscriminator , - 1 , false , " Energy Skim High " , layout6 , rowID , 2 ) ;
2023-02-28 17:08:34 -05:00
}
}
{ //@============== Status tab
QTabWidget * statusTab = new QTabWidget ( tab ) ;
chTabWidget - > addTab ( statusTab , " Status " ) ;
2023-03-03 18:53:59 -05:00
QGridLayout * layout = new QGridLayout ( statusTab ) ;
layout - > setAlignment ( Qt : : AlignTop ) ;
layout - > setSpacing ( 0 ) ;
QLabel * lb0x = new QLabel ( " 9-bit status " , statusTab ) ; lb0x - > setAlignment ( Qt : : AlignHCenter ) ; layout - > addWidget ( lb0x , 0 , 1 , 1 , 9 ) ;
QLabel * lb0a = new QLabel ( " Gain Fact. " , statusTab ) ; lb0a - > setAlignment ( Qt : : AlignHCenter ) ; layout - > addWidget ( lb0a , 0 , 10 ) ;
QLabel * lb1a = new QLabel ( " ADC->Volt " , statusTab ) ; lb1a - > setAlignment ( Qt : : AlignHCenter ) ; layout - > addWidget ( lb1a , 0 , 11 ) ;
QLabel * lb1x = new QLabel ( " 9-bit status " , statusTab ) ; lb1x - > setAlignment ( Qt : : AlignHCenter ) ; layout - > addWidget ( lb1x , 0 , 13 , 1 , 9 ) ;
QLabel * lb0b = new QLabel ( " Gain Fact. " , statusTab ) ; lb0b - > setAlignment ( Qt : : AlignHCenter ) ; layout - > addWidget ( lb0b , 0 , 22 ) ;
QLabel * lb1b = new QLabel ( " ADC->Volt " , statusTab ) ; lb1b - > setAlignment ( Qt : : AlignHCenter ) ; layout - > addWidget ( lb1b , 0 , 23 ) ;
for ( int ch = 0 ; ch < digi [ iDigi ] - > GetNChannels ( ) ; ch + + ) {
QLabel * lb = new QLabel ( " ch- " + QString : : number ( ch ) + " " , statusTab ) ;
lb - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
layout - > addWidget ( lb , 1 + ch / 2 , ch % 2 * 12 ) ;
for ( int k = 0 ; k < 9 ; k + + ) {
chStatus [ iDigi ] [ ch ] [ k ] = new QPushButton ( statusTab ) ;
chStatus [ iDigi ] [ ch ] [ k ] - > setEnabled ( false ) ;
chStatus [ iDigi ] [ ch ] [ k ] - > setFixedSize ( QSize ( 10 , 25 ) ) ;
chStatus [ iDigi ] [ ch ] [ k ] - > setToolTip ( chToolTip [ k ] ) ;
chStatus [ iDigi ] [ ch ] [ k ] - > setToolTipDuration ( - 1 ) ;
layout - > addWidget ( chStatus [ iDigi ] [ ch ] [ k ] , 1 + ch / 2 , ch % 2 * 12 + 9 - k ) ; // arrange backward, so that it is like a bit-wise
}
chGainFactor [ iDigi ] [ ch ] = new QLineEdit ( statusTab ) ;
chGainFactor [ iDigi ] [ ch ] - > setFixedWidth ( 100 ) ;
layout - > addWidget ( chGainFactor [ iDigi ] [ ch ] , 1 + ch / 2 , ch % 2 * 12 + 10 ) ;
chADCToVolts [ iDigi ] [ ch ] = new QLineEdit ( statusTab ) ;
chADCToVolts [ iDigi ] [ ch ] - > setFixedWidth ( 100 ) ;
layout - > addWidget ( chADCToVolts [ iDigi ] [ ch ] , 1 + ch / 2 , ch % 2 * 12 + 11 ) ;
}
2023-02-28 13:28:30 -05:00
}
2023-03-01 12:26:37 -05:00
2023-02-28 13:28:30 -05:00
{ //@============== input tab
2023-03-10 17:28:02 -05:00
inputTab = new QTabWidget ( tab ) ;
2023-02-28 13:28:30 -05:00
chTabWidget - > addTab ( inputTab , " Input " ) ;
2023-02-27 15:23:28 -05:00
2023-03-14 16:17:22 -04:00
SetupComboBoxTab ( cbbOnOff , PHA : : CH : : ChannelEnable , " On/Off " , inputTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbDCOffset , PHA : : CH : : DC_Offset , " DC Offset [%] " , inputTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbThreshold , PHA : : CH : : TriggerThreshold , " Threshold [LSB] " , inputTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupComboBoxTab ( cbbParity , PHA : : CH : : Polarity , " Parity " , inputTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbRecordLength , PHA : : CH : : RecordLength , " Record Length [ns] " , inputTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbPreTrigger , PHA : : CH : : PreTrigger , " PreTrigger [ns] " , inputTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbInputRiseTime , PHA : : CH : : TimeFilterRiseTime , " Input Rise Time [ns] " , inputTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbTriggerGuard , PHA : : CH : : TimeFilterRetriggerGuard , " Trigger Guard [ns] " , inputTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupComboBoxTab ( cbbLowFilter , PHA : : CH : : EnergyFilterLowFreqFilter , " Low Freq. Filter " , inputTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupComboBoxTab ( cbbWaveSource , PHA : : CH : : WaveDataSource , " Wave Data Dource " , inputTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) , 2 ) ;
SetupComboBoxTab ( cbbWaveRes , PHA : : CH : : WaveResolution , " Wave Resol. " , inputTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupComboBoxTab ( cbbWaveSave , PHA : : CH : : WaveSaving , " Wave Save " , inputTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
2023-03-02 18:18:02 -05:00
for ( int ch = 0 ; ch < digi [ iDigi ] - > GetNChannels ( ) ; ch + + ) {
2023-03-10 17:28:02 -05:00
//Set color of some combox
2023-03-03 16:19:39 -05:00
cbbOnOff [ iDigi ] [ ch ] - > setItemData ( 1 , QBrush ( Qt : : green ) , Qt : : ForegroundRole ) ;
2023-03-10 18:09:25 -05:00
connect ( cbbOnOff [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( int index ) { cbbOnOff [ ID ] [ ch ] - > setStyleSheet ( index = = 1 ? " color : green; " : " " ) ; } ) ;
2023-03-03 16:19:39 -05:00
cbbParity [ iDigi ] [ ch ] - > setItemData ( 1 , QBrush ( Qt : : green ) , Qt : : ForegroundRole ) ;
2023-03-10 18:09:25 -05:00
connect ( cbbParity [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( int index ) { cbbParity [ ID ] [ ch ] - > setStyleSheet ( index = = 1 ? " color : green; " : " " ) ; } ) ;
2023-03-03 16:19:39 -05:00
cbbLowFilter [ iDigi ] [ ch ] - > setItemData ( 1 , QBrush ( Qt : : green ) , Qt : : ForegroundRole ) ;
2023-03-10 18:09:25 -05:00
connect ( cbbLowFilter [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( int index ) { cbbLowFilter [ ID ] [ ch ] - > setStyleSheet ( index = = 1 ? " color : green; " : " " ) ; } ) ;
2023-03-02 18:18:02 -05:00
}
2023-01-30 18:40:24 -05:00
}
2023-03-01 12:26:37 -05:00
2023-02-28 13:28:30 -05:00
{ //@============== Trap tab
2023-03-10 17:28:02 -05:00
trapTab = new QTabWidget ( tab ) ;
2023-02-28 13:28:30 -05:00
chTabWidget - > addTab ( trapTab , " Trapezoid " ) ;
2023-01-30 18:40:24 -05:00
2023-03-14 16:17:22 -04:00
SetupSpinBoxTab ( spbTrapRiseTime , PHA : : CH : : EnergyFilterRiseTime , " Trap. Rise Time [ns] " , trapTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbTrapFlatTop , PHA : : CH : : EnergyFilterFlatTop , " Trap. Flat Top [ns] " , trapTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbTrapPoleZero , PHA : : CH : : EnergyFilterPoleZero , " Trap. Pole Zero [ns] " , trapTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbPeaking , PHA : : CH : : EnergyFilterPeakingPosition , " Peaking [%] " , trapTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupComboBoxTab ( cbbPeakingAvg , PHA : : CH : : EnergyFilterPeakingAvg , " Peak Avg. " , trapTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupComboBoxTab ( cbbBaselineAvg , PHA : : CH : : EnergyFilterBaselineAvg , " Baseline Avg. " , trapTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbFineGain , PHA : : CH : : EnergyFilterFineGain , " Fine Gain " , trapTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbBaselineGuard , PHA : : CH : : EnergyFilterBaselineGuard , " Baseline Guard [ns] " , trapTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbPileupGuard , PHA : : CH : : EnergyFilterPileUpGuard , " Pile-up Guard [ns] " , trapTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
2023-01-30 18:40:24 -05:00
}
2023-01-27 18:52:03 -05:00
2023-02-28 13:28:30 -05:00
{ //@============== Probe tab
2023-03-10 17:28:02 -05:00
probeTab = new QTabWidget ( tab ) ;
2023-02-28 13:28:30 -05:00
chTabWidget - > addTab ( probeTab , " Probe " ) ;
2023-03-14 16:17:22 -04:00
SetupComboBoxTab ( cbbAnaProbe0 , PHA : : CH : : WaveAnalogProbe0 , " Analog Prob. 0 " , probeTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) , 4 ) ;
SetupComboBoxTab ( cbbAnaProbe1 , PHA : : CH : : WaveAnalogProbe1 , " Analog Prob. 1 " , probeTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) , 4 ) ;
SetupComboBoxTab ( cbbDigProbe0 , PHA : : CH : : WaveDigitalProbe0 , " Digital Prob. 0 " , probeTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) , 4 ) ;
SetupComboBoxTab ( cbbDigProbe1 , PHA : : CH : : WaveDigitalProbe1 , " Digital Prob. 1 " , probeTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) , 4 ) ;
SetupComboBoxTab ( cbbDigProbe2 , PHA : : CH : : WaveDigitalProbe2 , " Digital Prob. 2 " , probeTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) , 4 ) ;
SetupComboBoxTab ( cbbDigProbe3 , PHA : : CH : : WaveDigitalProbe3 , " Digital Prob. 3 " , probeTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) , 4 ) ;
2023-02-28 13:28:30 -05:00
}
2023-02-28 17:08:34 -05:00
{ //@============== Other tab
2023-03-10 17:28:02 -05:00
otherTab = new QTabWidget ( tab ) ;
2023-02-28 17:08:34 -05:00
chTabWidget - > addTab ( otherTab , " Others " ) ;
2023-03-14 16:17:22 -04:00
SetupComboBoxTab ( cbbEventSelector , PHA : : CH : : EventSelector , " Event Selector " , otherTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupComboBoxTab ( cbbWaveSelector , PHA : : CH : : WaveSelector , " Wave Selector " , otherTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) , 2 ) ;
SetupSpinBoxTab ( spbEnergySkimLow , PHA : : CH : : EnergySkimLowDiscriminator , " Energy Skim Low " , otherTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbEnergySkimHigh , PHA : : CH : : EnergySkimHighDiscriminator , " Energy Skim High " , otherTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
2023-02-28 17:08:34 -05:00
}
2023-02-28 13:28:30 -05:00
{ //@============== Trigger tab
2023-03-10 17:28:02 -05:00
triggerTab = new QTabWidget ( tab ) ;
2023-02-28 13:28:30 -05:00
chTabWidget - > addTab ( triggerTab , " Trigger " ) ;
2023-03-14 16:17:22 -04:00
SetupComboBoxTab ( cbbEvtTrigger , PHA : : CH : : EventTriggerSource , " Event Trig. Source " , triggerTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) , 2 ) ;
SetupComboBoxTab ( cbbWaveTrigger , PHA : : CH : : WaveTriggerSource , " Wave Trig. Source " , triggerTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) , 2 ) ;
SetupComboBoxTab ( cbbChVetoSrc , PHA : : CH : : ChannelVetoSource , " Veto Source " , triggerTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) , 2 ) ;
SetupComboBoxTab ( cbbCoinMask , PHA : : CH : : CoincidenceMask , " Coin. Mask " , triggerTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupComboBoxTab ( cbbAntiCoinMask , PHA : : CH : : AntiCoincidenceMask , " Anti-Coin. Mask " , triggerTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbCoinLength , PHA : : CH : : CoincidenceLength , " Coin. Length [ns] " , triggerTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
SetupSpinBoxTab ( spbADCVetoWidth , PHA : : CH : : ADCVetoWidth , " ADC Veto Length [ns] " , triggerTab , iDigi , digi [ iDigi ] - > GetNChannels ( ) ) ;
2023-02-28 17:08:34 -05:00
}
2023-01-26 19:12:18 -05:00
2023-03-01 18:27:17 -05:00
for ( int ch = 0 ; ch < digi [ ID ] - > GetNChannels ( ) + 1 ; ch + + ) {
2023-03-10 17:28:02 -05:00
//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 ) ;
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 ) ;
//----- SyncBox
2023-03-03 15:23:26 -05:00
connect ( cbbOnOff [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbOnOff , ch ) ; } ) ;
connect ( spbDCOffset [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbDCOffset , ch ) ; } ) ;
connect ( spbThreshold [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbThreshold , ch ) ; } ) ;
connect ( cbbParity [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbParity , ch ) ; } ) ;
connect ( spbRecordLength [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbRecordLength , ch ) ; } ) ;
connect ( spbPreTrigger [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbPreTrigger , ch ) ; } ) ;
connect ( spbInputRiseTime [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbInputRiseTime , ch ) ; } ) ;
connect ( spbTriggerGuard [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbTriggerGuard , ch ) ; } ) ;
connect ( cbbLowFilter [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbLowFilter , ch ) ; } ) ;
connect ( cbbWaveSource [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbWaveSource , ch ) ; } ) ;
connect ( cbbWaveRes [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbWaveRes , ch ) ; } ) ;
connect ( cbbWaveSave [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbWaveSave , ch ) ; } ) ;
connect ( spbTrapRiseTime [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbTrapRiseTime , ch ) ; } ) ;
connect ( spbTrapFlatTop [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbTrapFlatTop , ch ) ; } ) ;
connect ( spbTrapPoleZero [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbTrapPoleZero , ch ) ; } ) ;
connect ( spbPeaking [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbPeaking , ch ) ; } ) ;
connect ( cbbPeakingAvg [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbPeakingAvg , ch ) ; } ) ;
connect ( cbbBaselineAvg [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbBaselineAvg , ch ) ; } ) ;
connect ( spbFineGain [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbFineGain , ch ) ; } ) ;
spbFineGain [ iDigi ] [ ch ] - > setSingleStep ( 0.001 ) ;
spbFineGain [ iDigi ] [ ch ] - > setDecimals ( 3 ) ;
connect ( spbBaselineGuard [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbBaselineGuard , ch ) ; } ) ;
connect ( spbPileupGuard [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbPileupGuard , ch ) ; } ) ;
2023-03-01 18:27:17 -05:00
2023-03-03 15:23:26 -05:00
connect ( cbbAnaProbe0 [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbAnaProbe0 , ch ) ; } ) ;
connect ( cbbAnaProbe1 [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbAnaProbe1 , ch ) ; } ) ;
connect ( cbbDigProbe0 [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbDigProbe0 , ch ) ; } ) ;
connect ( cbbDigProbe1 [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbDigProbe1 , ch ) ; } ) ;
connect ( cbbDigProbe2 [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbDigProbe2 , ch ) ; } ) ;
connect ( cbbDigProbe3 [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbDigProbe3 , ch ) ; } ) ;
connect ( cbbEventSelector [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbEventSelector , ch ) ; } ) ;
connect ( cbbWaveSelector [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbWaveSelector , ch ) ; } ) ;
connect ( spbEnergySkimLow [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbEnergySkimLow , ch ) ; } ) ;
connect ( spbEnergySkimHigh [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbEnergySkimHigh , ch ) ; } ) ;
connect ( cbbEvtTrigger [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbEvtTrigger , ch ) ; } ) ;
connect ( cbbWaveTrigger [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbWaveTrigger , ch ) ; } ) ;
connect ( cbbChVetoSrc [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbChVetoSrc , ch ) ; } ) ;
connect ( cbbCoinMask [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbCoinMask , ch ) ; } ) ;
connect ( cbbAntiCoinMask [ iDigi ] [ ch ] , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { SyncComboBox ( cbbAntiCoinMask , ch ) ; } ) ;
connect ( spbCoinLength [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbCoinLength , ch ) ; } ) ;
connect ( spbADCVetoWidth [ iDigi ] [ ch ] , & RSpinBox : : returnPressed , this , [ = ] ( ) { SyncSpinBox ( spbADCVetoWidth , ch ) ; } ) ;
2023-03-01 18:27:17 -05:00
}
2023-01-25 17:16:14 -05:00
2023-03-01 18:27:17 -05:00
2023-03-03 15:23:26 -05:00
{ //@============== Trigger Mask/Map tab
//TODO==========================
2023-03-10 17:28:02 -05:00
triggerMapTab = new QTabWidget ( tab ) ;
2023-02-28 17:08:34 -05:00
chTabWidget - > addTab ( triggerMapTab , " Trigger Map " ) ;
2023-01-26 19:12:18 -05:00
2023-02-28 17:08:34 -05:00
QGridLayout * triggerLayout = new QGridLayout ( triggerMapTab ) ;
2023-03-14 16:17:22 -04:00
triggerLayout - > setAlignment ( Qt : : AlignTop ) ;
int rowID = 0 ;
//----------------------------
SetupComboBox ( cbAllEvtTrigger , PHA : : CH : : EventTriggerSource , - 1 , false , " Event Trigger Source (all ch.) " , triggerLayout , rowID , 0 ) ;
SetupComboBox ( cbAllWaveTrigger , PHA : : CH : : WaveTriggerSource , - 1 , false , " Wave Trigger Source (all ch.) " , triggerLayout , rowID , 2 ) ;
//----------------------------
rowID + + ;
SetupComboBox ( cbAllCoinMask , PHA : : CH : : CoincidenceMask , - 1 , false , " Coincident Mask (all ch.) " , triggerLayout , rowID , 0 ) ;
SetupSpinBox ( sbAllCoinLength , PHA : : CH : : CoincidenceLength , - 1 , false , " Coincident Length [ns] (all ch.) " , triggerLayout , rowID , 2 ) ;
2023-01-26 19:12:18 -05:00
2023-02-28 17:08:34 -05:00
QSignalMapper * triggerMapper = new QSignalMapper ( tab ) ;
connect ( triggerMapper , & QSignalMapper : : mappedInt , this , & DigiSettingsPanel : : onTriggerClick ) ;
2023-01-26 19:12:18 -05:00
2023-03-14 16:17:22 -04:00
//----------------------------
rowID + + ;
QGroupBox * triggerBox = new QGroupBox ( " Trigger Mask " , tab ) ;
triggerLayout - > addWidget ( triggerBox , rowID , 0 , 1 , 4 ) ;
QGridLayout * tbLayout = new QGridLayout ( triggerBox ) ;
tbLayout - > setAlignment ( Qt : : AlignCenter ) ;
tbLayout - > setSpacing ( 0 ) ;
//----------------------------
rowID = 0 ;
QLabel * instr = new QLabel ( " Reading: Column (C) represents a trigger channel for Row (R) channel. \n For example, R3C1 = ch-3 trigger source is ch-1. \n " , tab ) ;
instr - > setAlignment ( Qt : : AlignLeft ) ;
tbLayout - > addWidget ( instr , rowID , 0 , 1 , 64 + 15 ) ;
rowID + + ;
2023-02-28 17:08:34 -05:00
int colID = 0 ;
for ( int i = 0 ; i < digi [ iDigi ] - > GetNChannels ( ) ; i + + ) {
2023-03-14 16:17:22 -04:00
colID = 1 ;
if ( i % 4 = = 0 ) {
QLabel * lllba = new QLabel ( QString : : number ( i ) , tab ) ;
lllba - > setAlignment ( Qt : : AlignTop | Qt : : AlignRight ) ;
tbLayout - > addWidget ( lllba , i + 2 + i / 4 , 0 , 4 , 1 ) ;
}
if ( i = = 0 ) {
for ( int j = 0 ; j < digi [ iDigi ] - > GetNChannels ( ) ; j + + ) {
if ( j % 4 = = 0 ) {
QLabel * lllb = new QLabel ( QString : : number ( j ) , tab ) ;
lllb - > setAlignment ( Qt : : AlignLeft ) ;
tbLayout - > addWidget ( lllb , rowID , 1 + j + j / 4 , 1 , 4 ) ;
}
}
rowID + + ;
}
2023-02-28 17:08:34 -05:00
for ( int j = 0 ; j < digi [ iDigi ] - > GetNChannels ( ) ; j + + ) {
2023-03-14 16:17:22 -04:00
trgMap [ i ] [ j ] = new QPushButton ( tab ) ;
trgMap [ i ] [ j ] - > setFixedSize ( QSize ( 10 , 10 ) ) ;
trgMapClickStatus [ i ] [ j ] = false ;
tbLayout - > addWidget ( trgMap [ i ] [ j ] , rowID , colID ) ;
2023-02-28 17:08:34 -05:00
2023-03-14 16:17:22 -04:00
triggerMapper - > setMapping ( trgMap [ i ] [ j ] , ( iDigi < < 16 ) + ( i < < 8 ) + j ) ;
connect ( trgMap [ i ] [ j ] , SIGNAL ( clicked ( ) ) , triggerMapper , SLOT ( map ( ) ) ) ;
2023-02-28 17:08:34 -05:00
colID + + ;
if ( j % 4 = = 3 & & j ! = digi [ iDigi ] - > GetNChannels ( ) - 1 ) {
QFrame * vSeparator = new QFrame ( tab ) ;
vSeparator - > setFrameShape ( QFrame : : VLine ) ;
2023-03-14 16:17:22 -04:00
tbLayout - > addWidget ( vSeparator , rowID , colID ) ;
2023-02-28 17:08:34 -05:00
colID + + ;
}
}
2023-01-26 19:12:18 -05:00
2023-02-28 17:08:34 -05:00
rowID + + ;
if ( i % 4 = = 3 & & i ! = digi [ iDigi ] - > GetNChannels ( ) - 1 ) {
QFrame * hSeparator = new QFrame ( tab ) ;
hSeparator - > setFrameShape ( QFrame : : HLine ) ;
2023-03-14 16:17:22 -04:00
tbLayout - > addWidget ( hSeparator , rowID , 1 , 1 , digi [ iDigi ] - > GetNChannels ( ) + 15 ) ;
2023-02-28 17:08:34 -05:00
rowID + + ;
}
}
}
2023-03-11 18:35:15 -05:00
2023-02-28 17:08:34 -05:00
} //=== end of channel group
2023-03-01 18:27:17 -05:00
2023-01-26 19:12:18 -05:00
} //=== end of tab
2023-01-25 17:16:14 -05:00
2023-03-13 16:51:11 -04:00
{ //^============================================== Inquiry / Copy Tab
2023-03-11 18:35:15 -05:00
ICTab = new QTabWidget ( this ) ;
tabWidget - > addTab ( ICTab , " Inquiry / Copy " ) ;
QVBoxLayout * layout1 = new QVBoxLayout ( ICTab ) ;
layout1 - > setAlignment ( Qt : : AlignTop | Qt : : AlignLeft ) ;
{ //@============== low level inquiry
2023-03-13 18:31:10 -04:00
icBox1 = new QGroupBox ( " Low Level Settings " , ICTab ) ;
2023-03-11 18:35:15 -05:00
layout1 - > addWidget ( icBox1 ) ;
QGridLayout * inquiryLayout = new QGridLayout ( icBox1 ) ;
inquiryLayout - > setAlignment ( Qt : : AlignTop | Qt : : AlignLeft ) ;
//inquiryLayout->setSpacing(0);
int rowID = 0 ;
2023-03-13 16:51:11 -04:00
QLabel * info1 = new QLabel ( " This will read from the digitizer, save the setting to memory. " , icBox1 ) ;
inquiryLayout - > addWidget ( info1 , rowID , 0 , 1 , 6 ) ;
rowID + + ;
QLabel * info2 = new QLabel ( " The settings from Digitizer Tab will not reflect immedinately in here. " , icBox1 ) ;
inquiryLayout - > addWidget ( info2 , rowID , 0 , 1 , 6 ) ;
2023-03-11 18:35:15 -05:00
///=========== header
rowID + + ;
QLabel * hd0 = new QLabel ( " Digi. Value " , icBox1 ) ;
hd0 - > setAlignment ( Qt : : AlignCenter ) ;
inquiryLayout - > addWidget ( hd0 , rowID , 3 ) ;
2023-03-13 16:51:11 -04:00
QLabel * hd1 = new QLabel ( " Unit " , icBox1 ) ;
2023-03-11 18:35:15 -05:00
hd1 - > setAlignment ( Qt : : AlignCenter ) ;
2023-03-13 16:51:11 -04:00
inquiryLayout - > addWidget ( hd1 , rowID , 4 ) ;
QLabel * hd2 = new QLabel ( " <---------------------- Set Value ----------------------> " , icBox1 ) ;
hd2 - > setAlignment ( Qt : : AlignCenter ) ;
inquiryLayout - > addWidget ( hd2 , rowID , 6 , 1 , 3 ) ;
2023-03-11 18:35:15 -05:00
2023-03-13 16:51:11 -04:00
///========================== board settings
2023-03-11 18:35:15 -05:00
rowID + + ;
2023-03-13 16:51:11 -04:00
cbIQDigi = new RComboBox ( ICTab ) ;
2023-03-11 18:35:15 -05:00
for ( int i = 0 ; i < nDigi ; i + + ) cbIQDigi - > addItem ( " Digi- " + QString : : number ( digi [ i ] - > GetSerialNumber ( ) ) , i ) ;
inquiryLayout - > addWidget ( cbIQDigi , rowID , 0 ) ;
2023-03-13 16:51:11 -04:00
connect ( cbIQDigi , & RComboBox : : currentIndexChanged , this , [ = ] ( int index ) {
enableSignalSlot = false ;
ID = index ;
cbIQCh - > clear ( ) ;
for ( int i = 0 ; i < digi [ index ] - > GetNChannels ( ) ; i + + ) cbIQCh - > addItem ( " Ch- " + QString : : number ( i ) , i ) ;
enableSignalSlot = true ;
} ) ;
2023-03-11 18:35:15 -05:00
2023-03-13 16:51:11 -04:00
cbBdSettings = new RComboBox ( ICTab ) ;
2023-03-14 16:17:22 -04:00
for ( int i = 0 ; i < ( int ) PHA : : DIG : : AllSettings . size ( ) ; i + + ) {
cbBdSettings - > addItem ( QString : : fromStdString ( PHA : : DIG : : AllSettings [ i ] . GetPara ( ) ) , i ) ;
2023-03-11 18:35:15 -05:00
}
inquiryLayout - > addWidget ( cbBdSettings , rowID , 1 ) ;
2023-03-13 16:51:11 -04:00
connect ( cbBdSettings , & RComboBox : : currentIndexChanged , this , & DigiSettingsPanel : : ReadBoardSetting ) ;
2023-03-11 18:35:15 -05:00
leBdSettingsType = new QLineEdit ( " Read Only " , ICTab ) ;
2023-03-13 16:51:11 -04:00
leBdSettingsType - > setAlignment ( Qt : : AlignHCenter ) ;
2023-03-11 18:35:15 -05:00
leBdSettingsType - > setFixedWidth ( 150 ) ;
leBdSettingsType - > setReadOnly ( true ) ;
inquiryLayout - > addWidget ( leBdSettingsType , rowID , 2 ) ;
leBdSettingsRead = new QLineEdit ( ICTab ) ;
2023-03-13 16:51:11 -04:00
leBdSettingsRead - > setAlignment ( Qt : : AlignRight ) ;
2023-03-11 18:35:15 -05:00
leBdSettingsRead - > setFixedWidth ( 200 ) ;
leBdSettingsRead - > setReadOnly ( true ) ;
inquiryLayout - > addWidget ( leBdSettingsRead , rowID , 3 ) ;
2023-03-13 16:51:11 -04:00
leBdSettingsUnit = new QLineEdit ( " " , ICTab ) ;
leBdSettingsUnit - > setAlignment ( Qt : : AlignHCenter ) ;
leBdSettingsUnit - > setFixedWidth ( 50 ) ;
leBdSettingsUnit - > setReadOnly ( true ) ;
inquiryLayout - > addWidget ( leBdSettingsUnit , rowID , 4 ) ;
QPushButton * bnRead = new QPushButton ( " Read " , ICTab ) ;
inquiryLayout - > addWidget ( bnRead , rowID , 5 , 2 , 1 ) ;
connect ( bnRead , & QPushButton : : clicked , this , [ = ] ( ) { ReadBoardSetting ( cbBdSettings - > currentIndex ( ) ) ; ReadChannelSetting ( cbChSettings - > currentIndex ( ) ) ; } ) ;
2023-03-11 18:35:15 -05:00
cbBdAns = new RComboBox ( ICTab ) ;
cbBdAns - > setFixedWidth ( 200 ) ;
2023-03-13 16:51:11 -04:00
inquiryLayout - > addWidget ( cbBdAns , rowID , 6 ) ;
connect ( cbBdAns , & RComboBox : : currentIndexChanged , this , [ = ] ( ) {
if ( ! enableSignalSlot ) return ;
std : : string value = cbBdAns - > currentData ( ) . toString ( ) . toStdString ( ) ;
leBdSettingsWrite - > setText ( QString : : fromStdString ( value ) ) ;
leBdSettingsWrite - > setStyleSheet ( " " ) ;
2023-03-14 16:17:22 -04:00
Reg para = PHA : : DIG : : AllSettings [ cbBdSettings - > currentIndex ( ) ] ;
2023-03-13 16:51:11 -04:00
ID = cbIQDigi - > currentIndex ( ) ;
QString msg ;
msg = QString : : fromStdString ( para . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
msg + = " = " + cbBdAns - > currentData ( ) . toString ( ) ;
if ( digi [ ID ] - > WriteValue ( para , value ) ) {
leBdSettingsRead - > setText ( QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( para ) ) ) ;
SendLogMsg ( msg + " |OK. " ) ;
cbBdAns - > setStyleSheet ( " " ) ;
ShowSettingsToPanel ( ) ;
} else {
leBdSettingsRead - > setText ( " fail write value " ) ;
SendLogMsg ( msg + " |Fail. " ) ;
cbBdAns - > setStyleSheet ( " color:red; " ) ;
}
} ) ;
2023-03-11 18:35:15 -05:00
sbBdSettingsWrite = new RSpinBox ( ICTab ) ;
sbBdSettingsWrite - > setFixedWidth ( 200 ) ;
2023-03-13 16:51:11 -04:00
inquiryLayout - > addWidget ( sbBdSettingsWrite , rowID , 7 ) ;
connect ( sbBdSettingsWrite , & RSpinBox : : valueChanged , this , [ = ] ( ) { sbBdSettingsWrite - > setStyleSheet ( " color: green; " ) ; } ) ;
connect ( sbBdSettingsWrite , & RSpinBox : : returnPressed , this , [ = ] ( ) {
if ( ! enableSignalSlot ) return ;
if ( sbBdSettingsWrite - > decimals ( ) = = 0 & & sbBdSettingsWrite - > singleStep ( ) ! = 1 ) {
double step = sbBdSettingsWrite - > singleStep ( ) ;
double value = sbBdSettingsWrite - > value ( ) ;
sbBdSettingsWrite - > setValue ( ( std : : round ( value / step ) * step ) ) ;
}
2023-03-14 16:17:22 -04:00
Reg para = PHA : : DIG : : AllSettings [ cbBdSettings - > currentIndex ( ) ] ;
2023-03-13 16:51:11 -04:00
ID = cbIQDigi - > currentIndex ( ) ;
QString msg ;
msg = QString : : fromStdString ( para . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
msg + = " = " + QString : : number ( sbBdSettingsWrite - > value ( ) ) ;
if ( digi [ ID ] - > WriteValue ( para , std : : to_string ( sbBdSettingsWrite - > value ( ) ) ) ) {
leBdSettingsRead - > setText ( QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( para ) ) ) ;
SendLogMsg ( msg + " |OK. " ) ;
sbBdSettingsWrite - > setStyleSheet ( " " ) ;
ShowSettingsToPanel ( ) ;
} else {
leBdSettingsRead - > setText ( " fail write value " ) ;
SendLogMsg ( msg + " |Fail. " ) ;
sbBdSettingsWrite - > setStyleSheet ( " color:red; " ) ;
}
} ) ;
leBdSettingsWrite = new QLineEdit ( ICTab ) ;
leBdSettingsWrite - > setAlignment ( Qt : : AlignRight ) ;
leBdSettingsWrite - > setFixedWidth ( 200 ) ;
inquiryLayout - > addWidget ( leBdSettingsWrite , rowID , 8 ) ;
connect ( leBdSettingsWrite , & QLineEdit : : textChanged , this , [ = ] ( ) { leBdSettingsWrite - > setStyleSheet ( " color: green; " ) ; } ) ;
connect ( leBdSettingsWrite , & QLineEdit : : returnPressed , this , [ = ] ( ) {
if ( ! enableSignalSlot ) return ;
std : : string value = leBdSettingsWrite - > text ( ) . toStdString ( ) ;
2023-03-14 16:17:22 -04:00
Reg para = PHA : : DIG : : AllSettings [ cbBdSettings - > currentIndex ( ) ] ;
2023-03-13 16:51:11 -04:00
ID = cbIQDigi - > currentIndex ( ) ;
QString msg ;
msg = QString : : fromStdString ( para . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
msg + = " = " + QString : : number ( sbBdSettingsWrite - > value ( ) ) ;
if ( digi [ ID ] - > WriteValue ( para , value ) ) {
leBdSettingsRead - > setText ( QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( para ) ) ) ;
SendLogMsg ( msg + " |OK. " ) ;
sbBdSettingsWrite - > setStyleSheet ( " " ) ;
ShowSettingsToPanel ( ) ;
} else {
leBdSettingsRead - > setText ( " fail write value " ) ;
SendLogMsg ( msg + " |Fail. " ) ;
sbBdSettingsWrite - > setStyleSheet ( " color:red; " ) ;
}
} ) ;
2023-03-11 18:35:15 -05:00
2023-03-13 16:51:11 -04:00
///========================== Channels settings
2023-03-11 18:35:15 -05:00
rowID + + ;
2023-03-13 16:51:11 -04:00
cbIQCh = new RComboBox ( ICTab ) ;
cbIQCh - > clear ( ) ;
2023-03-11 18:35:15 -05:00
for ( int i = 0 ; i < digi [ 0 ] - > GetNChannels ( ) ; i + + ) cbIQCh - > addItem ( " Ch- " + QString : : number ( i ) , i ) ;
inquiryLayout - > addWidget ( cbIQCh , rowID , 0 ) ;
2023-03-13 16:51:11 -04:00
connect ( cbIQCh , & RComboBox : : currentIndexChanged , this , [ = ] ( ) { ReadChannelSetting ( cbChSettings - > currentIndex ( ) ) ; } ) ;
2023-03-11 18:35:15 -05:00
2023-03-13 16:51:11 -04:00
cbChSettings = new RComboBox ( ICTab ) ;
2023-03-14 16:17:22 -04:00
for ( int i = 0 ; i < ( int ) PHA : : CH : : AllSettings . size ( ) ; i + + ) {
cbChSettings - > addItem ( QString : : fromStdString ( PHA : : CH : : AllSettings [ i ] . GetPara ( ) ) , i ) ;
2023-03-11 18:35:15 -05:00
}
inquiryLayout - > addWidget ( cbChSettings , rowID , 1 ) ;
2023-03-13 16:51:11 -04:00
connect ( cbChSettings , & RComboBox : : currentIndexChanged , this , & DigiSettingsPanel : : ReadChannelSetting ) ;
2023-03-11 18:35:15 -05:00
2023-03-13 16:51:11 -04:00
leChSettingsType = new QLineEdit ( " Read Only " , ICTab ) ;
leChSettingsType - > setAlignment ( Qt : : AlignHCenter ) ;
2023-03-11 18:35:15 -05:00
leChSettingsType - > setFixedWidth ( 150 ) ;
leChSettingsType - > setReadOnly ( true ) ;
inquiryLayout - > addWidget ( leChSettingsType , rowID , 2 ) ;
2023-03-13 16:51:11 -04:00
leChSettingsRead = new QLineEdit ( ICTab ) ;
leChSettingsRead - > setAlignment ( Qt : : AlignRight ) ;
leChSettingsRead - > setFixedWidth ( 200 ) ;
2023-03-11 18:35:15 -05:00
leChSettingsRead - > setReadOnly ( true ) ;
inquiryLayout - > addWidget ( leChSettingsRead , rowID , 3 ) ;
2023-03-13 16:51:11 -04:00
leChSettingsUnit = new QLineEdit ( ICTab ) ;
leChSettingsUnit - > setAlignment ( Qt : : AlignHCenter ) ;
leChSettingsUnit - > setFixedWidth ( 50 ) ;
leChSettingsUnit - > setReadOnly ( true ) ;
inquiryLayout - > addWidget ( leChSettingsUnit , rowID , 4 ) ;
2023-03-11 18:35:15 -05:00
2023-03-13 16:51:11 -04:00
cbChAns = new RComboBox ( ICTab ) ;
2023-03-11 18:35:15 -05:00
cbChAns - > setFixedWidth ( 200 ) ;
2023-03-13 16:51:11 -04:00
inquiryLayout - > addWidget ( cbChAns , rowID , 6 ) ;
connect ( cbChAns , & RComboBox : : currentIndexChanged , this , [ = ] ( ) {
if ( ! enableSignalSlot ) return ;
std : : string value = cbChAns - > currentData ( ) . toString ( ) . toStdString ( ) ;
leChSettingsWrite - > setText ( QString : : fromStdString ( value ) ) ;
leChSettingsWrite - > setStyleSheet ( " " ) ;
2023-03-14 16:17:22 -04:00
Reg para = PHA : : CH : : AllSettings [ cbChSettings - > currentIndex ( ) ] ;
2023-03-13 16:51:11 -04:00
ID = cbIQDigi - > currentIndex ( ) ;
int ch_index = cbIQCh - > currentIndex ( ) ;
QString msg ;
msg = QString : : fromStdString ( para . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
msg + = " ,CH: " + QString : : number ( ch_index ) ;
msg + = " = " + cbChAns - > currentData ( ) . toString ( ) ;
if ( digi [ ID ] - > WriteValue ( para , value , ch_index ) ) {
leChSettingsRead - > setText ( QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( para ) ) ) ;
SendLogMsg ( msg + " |OK. " ) ;
cbChAns - > setStyleSheet ( " " ) ;
ShowSettingsToPanel ( ) ;
} else {
leChSettingsRead - > setText ( " fail write value " ) ;
SendLogMsg ( msg + " |Fail. " ) ;
cbChAns - > setStyleSheet ( " color:red; " ) ;
}
} ) ;
sbChSettingsWrite = new RSpinBox ( ICTab ) ;
sbChSettingsWrite - > setFixedWidth ( 200 ) ;
inquiryLayout - > addWidget ( sbChSettingsWrite , rowID , 7 ) ;
connect ( sbChSettingsWrite , & RSpinBox : : valueChanged , this , [ = ] ( ) { sbChSettingsWrite - > setStyleSheet ( " color: green; " ) ; } ) ;
connect ( sbChSettingsWrite , & RSpinBox : : returnPressed , this , [ = ] ( ) {
if ( ! enableSignalSlot ) return ;
if ( sbChSettingsWrite - > decimals ( ) = = 0 & & sbChSettingsWrite - > singleStep ( ) ! = 1 ) {
double step = sbChSettingsWrite - > singleStep ( ) ;
double value = sbChSettingsWrite - > value ( ) ;
sbChSettingsWrite - > setValue ( ( std : : round ( value / step ) * step ) ) ;
}
2023-03-11 18:35:15 -05:00
2023-03-14 16:17:22 -04:00
Reg para = PHA : : CH : : AllSettings [ cbBdSettings - > currentIndex ( ) ] ;
2023-03-13 16:51:11 -04:00
ID = cbIQDigi - > currentIndex ( ) ;
int ch_index = cbIQCh - > currentIndex ( ) ;
QString msg ;
msg = QString : : fromStdString ( para . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
msg + = " ,CH: " + QString : : number ( ch_index ) ;
msg + = " = " + QString : : number ( sbChSettingsWrite - > value ( ) ) ;
if ( digi [ ID ] - > WriteValue ( para , std : : to_string ( sbChSettingsWrite - > value ( ) ) , ch_index ) ) {
leChSettingsRead - > setText ( QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( para ) ) ) ;
SendLogMsg ( msg + " |OK. " ) ;
sbChSettingsWrite - > setStyleSheet ( " " ) ;
ShowSettingsToPanel ( ) ;
} else {
leChSettingsRead - > setText ( " fail write value " ) ;
SendLogMsg ( msg + " |Fail. " ) ;
sbChSettingsWrite - > setStyleSheet ( " color:red; " ) ;
}
} ) ;
leChSettingsWrite = new QLineEdit ( ICTab ) ;
2023-03-11 18:35:15 -05:00
leChSettingsWrite - > setFixedWidth ( 200 ) ;
2023-03-13 16:51:11 -04:00
inquiryLayout - > addWidget ( leChSettingsWrite , rowID , 8 ) ;
connect ( leChSettingsWrite , & QLineEdit : : textChanged , this , [ = ] ( ) { leChSettingsWrite - > setStyleSheet ( " color: green; " ) ; } ) ;
connect ( leChSettingsWrite , & QLineEdit : : returnPressed , this , [ = ] ( ) {
if ( ! enableSignalSlot ) return ;
std : : string value = leChSettingsWrite - > text ( ) . toStdString ( ) ;
2023-03-14 16:17:22 -04:00
Reg para = PHA : : CH : : AllSettings [ cbChSettings - > currentIndex ( ) ] ;
2023-03-13 16:51:11 -04:00
ID = cbIQDigi - > currentIndex ( ) ;
int ch_index = cbIQCh - > currentIndex ( ) ;
QString msg ;
msg = QString : : fromStdString ( para . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
msg + = " = " + QString : : number ( sbChSettingsWrite - > value ( ) ) ;
if ( digi [ ID ] - > WriteValue ( para , value , ch_index ) ) {
leChSettingsRead - > setText ( QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( para ) ) ) ;
SendLogMsg ( msg + " |OK. " ) ;
sbChSettingsWrite - > setStyleSheet ( " " ) ;
ShowSettingsToPanel ( ) ;
} else {
leChSettingsRead - > setText ( " fail write value " ) ;
SendLogMsg ( msg + " |Fail. " ) ;
sbChSettingsWrite - > setStyleSheet ( " color:red; " ) ;
}
} ) ;
2023-03-11 18:35:15 -05:00
2023-03-13 16:51:11 -04:00
for ( int i = 0 ; i < inquiryLayout - > count ( ) ; i + + ) inquiryLayout - > setColumnStretch ( i , 1 ) ;
2023-03-11 18:35:15 -05:00
}
{ //@============== Copy setting
2023-03-13 18:31:10 -04:00
icBox2 = new QGroupBox ( " Copy Settings " , ICTab ) ;
2023-03-11 18:35:15 -05:00
layout1 - > addWidget ( icBox2 ) ;
2023-03-13 18:31:10 -04:00
QGridLayout * cpLayout = new QGridLayout ( icBox2 ) ;
cpLayout - > setAlignment ( Qt : : AlignCenter | Qt : : AlignLeft ) ;
2023-03-11 18:35:15 -05:00
///================
QGroupBox * icBox2a = new QGroupBox ( " Copy From " , icBox2 ) ;
2023-03-13 18:31:10 -04:00
cpLayout - > addWidget ( icBox2a , 0 , 0 , 5 , 1 ) ;
2023-03-11 18:35:15 -05:00
QGridLayout * lo1 = new QGridLayout ( icBox2a ) ;
2023-03-13 18:31:10 -04:00
cbCopyDigiFrom = new RComboBox ( ICTab ) ;
2023-03-11 18:35:15 -05:00
for ( int i = 0 ; i < nDigi ; i + + ) cbCopyDigiFrom - > addItem ( " Digi- " + QString : : number ( digi [ i ] - > GetSerialNumber ( ) ) , i ) ;
2023-03-13 18:31:10 -04:00
lo1 - > addWidget ( cbCopyDigiFrom , 0 , 0 , 1 , 8 ) ;
connect ( cbCopyDigiFrom , & RComboBox : : currentIndexChanged , this , [ = ] ( int index ) {
if ( index = = cbCopyDigiTo - > currentIndex ( ) ) {
pbCopyBoard - > setEnabled ( false ) ;
pbCopyDigi - > setEnabled ( false ) ;
} else {
pbCopyBoard - > setEnabled ( true ) ;
pbCopyDigi - > setEnabled ( true ) ;
}
} ) ;
2023-03-11 18:35:15 -05:00
2023-03-13 18:31:10 -04:00
int rowID = 0 ;
for ( int i = 0 ; i < digi [ 0 ] - > GetNChannels ( ) ; i + + ) {
if ( i % 8 = = 0 ) rowID + + ;
rbCopyChFrom [ i ] = new QRadioButton ( " Ch- " + QString : : number ( i ) , ICTab ) ;
lo1 - > addWidget ( rbCopyChFrom [ i ] , rowID , i % 8 ) ;
connect ( rbCopyChFrom [ i ] , & QRadioButton : : clicked , this , & DigiSettingsPanel : : CheckRadioAndCheckedButtons ) ;
}
2023-03-11 18:35:15 -05:00
///================
2023-03-13 18:31:10 -04:00
pbCopyChannel = new QPushButton ( " Copy Ch. Setting " , ICTab ) ;
pbCopyChannel - > setFixedSize ( 200 , 50 ) ;
cpLayout - > addWidget ( pbCopyChannel , 1 , 1 ) ;
pbCopyChannel - > setEnabled ( false ) ;
2023-03-14 16:17:22 -04:00
connect ( pbCopyChannel , & QPushButton : : clicked , this , [ = ] ( ) {
int chFromIndex = - 1 ;
for ( int i = 0 ; i < MaxNumberOfChannel ; i + + ) {
if ( rbCopyChFrom [ i ] - > isChecked ( ) ) {
chFromIndex = i ;
break ;
}
}
if ( chFromIndex < 0 ) return ;
for ( int i = 0 ; i < MaxNumberOfChannel ; i + + ) {
if ( chkChTo [ i ] - > isChecked ( ) ) CopyChannelSettings ( cbCopyDigiFrom - > currentIndex ( ) , chFromIndex , cbCopyDigiTo - > currentIndex ( ) , i ) ;
}
SendLogMsg ( " ------ done " ) ;
ID = cbCopyDigiTo - > currentIndex ( ) ;
ShowSettingsToPanel ( ) ;
} ) ;
2023-03-13 18:31:10 -04:00
pbCopyBoard = new QPushButton ( " Copy Board Settings " , ICTab ) ;
pbCopyBoard - > setFixedSize ( 200 , 50 ) ;
cpLayout - > addWidget ( pbCopyBoard , 2 , 1 ) ;
pbCopyBoard - > setEnabled ( false ) ;
connect ( pbCopyBoard , & QPushButton : : clicked , this , & DigiSettingsPanel : : CopyBoardSettings ) ;
pbCopyDigi = new QPushButton ( " Copy Digitizer " , ICTab ) ;
pbCopyDigi - > setFixedSize ( 200 , 50 ) ;
cpLayout - > addWidget ( pbCopyDigi , 3 , 1 ) ;
pbCopyDigi - > setEnabled ( false ) ;
connect ( pbCopyDigi , & QPushButton : : clicked , this , & DigiSettingsPanel : : CopyWholeDigitizer ) ;
2023-03-11 18:35:15 -05:00
///================
QGroupBox * icBox2b = new QGroupBox ( " Copy To " , icBox2 ) ;
2023-03-13 18:31:10 -04:00
cpLayout - > addWidget ( icBox2b , 0 , 2 , 5 , 1 ) ;
2023-03-11 18:35:15 -05:00
QGridLayout * lo2 = new QGridLayout ( icBox2b ) ;
2023-03-13 18:31:10 -04:00
cbCopyDigiTo = new RComboBox ( ICTab ) ;
2023-03-11 18:35:15 -05:00
for ( int i = 0 ; i < nDigi ; i + + ) cbCopyDigiTo - > addItem ( " Digi- " + QString : : number ( digi [ i ] - > GetSerialNumber ( ) ) , i ) ;
2023-03-13 18:31:10 -04:00
lo2 - > addWidget ( cbCopyDigiTo , 0 , 0 , 1 , 8 ) ;
connect ( cbCopyDigiTo , & RComboBox : : currentIndexChanged , this , [ = ] ( int index ) {
if ( index = = cbCopyDigiFrom - > currentIndex ( ) ) {
pbCopyBoard - > setEnabled ( false ) ;
pbCopyDigi - > setEnabled ( false ) ;
} else {
pbCopyBoard - > setEnabled ( true ) ;
pbCopyDigi - > setEnabled ( true ) ;
}
} ) ;
2023-03-11 18:35:15 -05:00
2023-03-13 18:31:10 -04:00
rowID = 0 ;
for ( int i = 0 ; i < digi [ 0 ] - > GetNChannels ( ) ; i + + ) {
if ( i % 8 = = 0 ) rowID + + ;
chkChTo [ i ] = new QCheckBox ( " ch- " + QString : : number ( i ) , ICTab ) ;
lo2 - > addWidget ( chkChTo [ i ] , rowID , i % 8 ) ;
connect ( chkChTo [ i ] , & QCheckBox : : clicked , this , & DigiSettingsPanel : : CheckRadioAndCheckedButtons ) ;
}
2023-03-11 18:35:15 -05:00
2023-03-13 18:31:10 -04:00
cpLayout - > setColumnStretch ( 0 , 4 ) ;
cpLayout - > setColumnStretch ( 1 , 1 ) ;
cpLayout - > setColumnStretch ( 2 , 4 ) ;
2023-03-11 18:35:15 -05:00
}
}
2023-03-10 18:09:25 -05:00
EnableControl ( ) ;
2023-01-25 17:16:14 -05:00
2023-03-13 16:51:11 -04:00
cbBdSettings - > setCurrentText ( " ModelName " ) ;
cbChSettings - > setCurrentIndex ( 10 ) ;
2023-03-10 17:28:02 -05:00
show ( ) ;
2023-03-10 18:09:25 -05:00
enableSignalSlot = true ;
2023-01-25 17:16:14 -05:00
}
2023-02-23 16:08:47 -05:00
DigiSettingsPanel : : ~ DigiSettingsPanel ( ) {
2023-01-25 17:16:14 -05:00
2023-01-27 18:52:03 -05:00
printf ( " %s \n " , __func__ ) ;
2023-02-23 16:08:47 -05:00
}
//^================================================================
void DigiSettingsPanel : : onTriggerClick ( int haha ) {
2023-03-14 16:17:22 -04:00
unsigned short iDig = haha > > 16 ;
unsigned short ch = ( haha > > 8 ) & 0xFF ;
2023-02-23 16:08:47 -05:00
unsigned short ch2 = haha & 0xFF ;
qDebug ( ) < < " Digi- " < < iDig < < " , Ch- " < < ch < < " , " < < ch2 ;
2023-03-14 16:17:22 -04:00
if ( trgMapClickStatus [ ch ] [ ch2 ] ) {
trgMap [ ch ] [ ch2 ] - > setStyleSheet ( " " ) ;
trgMapClickStatus [ ch ] [ ch2 ] = false ;
2023-02-23 16:08:47 -05:00
} else {
2023-03-14 16:17:22 -04:00
trgMap [ ch ] [ ch2 ] - > setStyleSheet ( " background-color: red; " ) ;
trgMapClickStatus [ ch ] [ ch2 ] = true ;
}
//format triggermask for ch;
unsigned long mask = 0 ;
for ( int i = 0 ; i < digi [ ID ] - > GetNChannels ( ) ; i + + ) {
if ( trgMapClickStatus [ ch ] [ i ] ) mask + = ( 1 < < i ) ;
2023-02-23 16:08:47 -05:00
}
2023-03-14 16:17:22 -04:00
QString kaka = " 0x " + QString : : number ( mask , 16 ) ;
QString msg ;
msg = QString : : fromStdString ( PHA : : CH : : ChannelsTriggerMask . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ iDig ] - > GetNChannels ( ) ) + " ,CH: " + QString : : number ( ch ) + " = " + kaka ;
if ( digi [ iDig ] - > WriteValue ( PHA : : CH : : ChannelsTriggerMask , kaka . toStdString ( ) , ch ) ) {
SendLogMsg ( msg + " |OK. " ) ;
} else {
SendLogMsg ( msg + " |Fail. " ) ;
digi [ iDig ] - > ReadValue ( PHA : : CH : : ChannelsTriggerMask , ch ) ;
ShowSettingsToPanel ( ) ;
}
}
void DigiSettingsPanel : : ReadTriggerMap ( ) {
enableSignalSlot = false ;
cbAllEvtTrigger - > setCurrentIndex ( cbbEvtTrigger [ ID ] [ MaxNumberOfChannel ] - > currentIndex ( ) ) ;
cbAllWaveTrigger - > setCurrentIndex ( cbbWaveTrigger [ ID ] [ MaxNumberOfChannel ] - > currentIndex ( ) ) ;
cbAllCoinMask - > setCurrentIndex ( cbbCoinMask [ ID ] [ MaxNumberOfChannel ] - > currentIndex ( ) ) ;
sbAllCoinLength - > setValue ( spbCoinLength [ ID ] [ MaxNumberOfChannel ] - > value ( ) ) ;
for ( int ch = 0 ; ch < ( int ) digi [ ID ] - > GetNChannels ( ) ; ch + + ) {
unsigned long mask = std : : stoul ( digi [ ID ] - > GetSettingValue ( PHA : : CH : : ChannelsTriggerMask , ch ) ) ;
for ( int k = 0 ; k < ( int ) digi [ ID ] - > GetNChannels ( ) ; k + + ) {
trgMapClickStatus [ ch ] [ k ] = ( ( mask > > k ) & 0x1 ) ;
if ( ( mask > > k ) & 0x1 ) {
trgMap [ ch ] [ k ] - > setStyleSheet ( " background-color: red; " ) ;
} else {
trgMap [ ch ] [ k ] - > setStyleSheet ( " " ) ;
}
}
}
enableSignalSlot = true ;
2023-02-23 16:08:47 -05:00
}
//^================================================================
void DigiSettingsPanel : : RefreshSettings ( ) {
digi [ ID ] - > ReadAllSettings ( ) ;
ShowSettingsToPanel ( ) ;
}
2023-03-10 17:28:02 -05:00
void DigiSettingsPanel : : EnableControl ( ) {
2023-03-10 18:09:25 -05:00
ShowSettingsToPanel ( ) ;
2023-03-10 17:28:02 -05:00
bool enable = ! digi [ ID ] - > IsAcqOn ( ) ;
digiBox - > setEnabled ( enable ) ;
if ( digi [ ID ] - > GetFPGATyep ( ) = = " DPP_PHA " ) VGABox - > setEnabled ( enable ) ;
if ( ckbGlbTrgSource [ ID ] [ 3 ] - > isChecked ( ) ) testPulseBox - > setEnabled ( enable ) ;
box1 - > setEnabled ( enable ) ;
box3 - > setEnabled ( enable ) ;
box4 - > setEnabled ( enable ) ;
box5 - > setEnabled ( enable ) ;
box6 - > setEnabled ( enable ) ;
for ( int i = 0 ; i < nDigi ; i + + ) {
bnReadSettngs [ i ] - > setEnabled ( enable ) ;
bnResetBd [ i ] - > setEnabled ( enable ) ;
bnDefaultSetting [ i ] - > setEnabled ( enable ) ;
bnSaveSettings [ i ] - > setEnabled ( enable ) ;
bnLoadSettings [ i ] - > setEnabled ( enable ) ;
bnClearData [ i ] - > setEnabled ( enable ) ;
bnArmACQ [ i ] - > setEnabled ( enable ) ;
bnDisarmACQ [ i ] - > setEnabled ( enable ) ;
bnSoftwareStart [ i ] - > setEnabled ( enable ) ;
bnSoftwareStop [ i ] - > setEnabled ( enable ) ;
}
QVector < QTabWidget * > tempArray = { inputTab , trapTab , probeTab , otherTab , triggerTab } ;
for ( int k = 0 ; k < tempArray . size ( ) ; k + + ) {
for ( int i = 0 ; i < tempArray [ k ] - > count ( ) ; i + + ) {
QWidget * currentTab = tempArray [ k ] - > widget ( i ) ;
if ( currentTab ) {
QList < QWidget * > childWidgets = currentTab - > findChildren < QWidget * > ( ) ;
for ( int j = 0 ; j < childWidgets . count ( ) ; j + + ) {
childWidgets [ j ] - > setEnabled ( enable ) ;
}
}
}
}
triggerMapTab - > setEnabled ( enable ) ;
}
2023-02-23 16:08:47 -05:00
void DigiSettingsPanel : : SaveSettings ( ) {
2023-03-03 18:53:59 -05:00
//TODO default file Path
2023-03-02 15:00:59 -05:00
QString filePath = QFileDialog : : getSaveFileName ( this , " Save Settings File " , " " , " Data file (*.dat);;Text files (*.txt);;All files (*.*) " ) ;
if ( ! filePath . isEmpty ( ) ) {
QFileInfo fileInfo ( filePath ) ;
QString ext = fileInfo . suffix ( ) ;
if ( ext = = " " ) filePath + = " .dat " ;
int flag = digi [ ID ] - > SaveSettingsToFile ( filePath . toStdString ( ) . c_str ( ) ) ;
switch ( flag ) {
case 1 : {
leSettingFile [ ID ] - > setText ( filePath ) ;
2023-03-10 17:28:02 -05:00
SendLogMsg ( " Saved setting file <b> " + filePath + " </b>. " ) ;
2023-03-02 15:00:59 -05:00
} ; break ;
case 0 : {
leSettingFile [ ID ] - > setText ( " fail to write setting file. " ) ;
2023-03-10 17:28:02 -05:00
SendLogMsg ( " <font style= \" color:red; \" > Fail to write setting file.</font> " ) ;
2023-03-02 15:00:59 -05:00
} ; break ;
case - 1 : {
leSettingFile [ ID ] - > setText ( " fail to save setting file, same settings are empty. " ) ;
2023-03-10 17:28:02 -05:00
SendLogMsg ( " <font style= \" color:red; \" > Fail to save setting file, same settings are empty.</font> " ) ;
2023-03-02 15:00:59 -05:00
} ; break ;
} ;
}
2023-02-23 16:08:47 -05:00
}
void DigiSettingsPanel : : LoadSettings ( ) {
QFileDialog fileDialog ( this ) ;
fileDialog . setFileMode ( QFileDialog : : ExistingFile ) ;
fileDialog . setNameFilter ( " Data file (*.dat);;Text file (*.txt);;All file (*.*) " ) ;
fileDialog . exec ( ) ;
QString fileName = fileDialog . selectedFiles ( ) . at ( 0 ) ;
leSettingFile [ ID ] - > setText ( fileName ) ;
//TODO ==== check is the file valid;
if ( digi [ ID ] - > LoadSettingsFromFile ( fileName . toStdString ( ) . c_str ( ) ) ) {
2023-03-10 17:28:02 -05:00
SendLogMsg ( " Loaded settings file " + fileName + " for Digi- " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ) ;
2023-02-23 16:08:47 -05:00
} else {
2023-03-10 17:28:02 -05:00
SendLogMsg ( " Fail to Loaded settings file " + fileName + " for Digi- " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ) ;
2023-02-23 16:08:47 -05:00
}
ShowSettingsToPanel ( ) ;
}
2023-03-11 18:35:15 -05:00
void DigiSettingsPanel : : SetDefaultPHASettigns ( ) {
SendLogMsg ( " Program Digitizer- " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) + " to default PHA. " ) ;
digi [ ID ] - > ProgramPHA ( ) ;
RefreshSettings ( ) ;
}
2023-02-23 16:08:47 -05:00
void DigiSettingsPanel : : ShowSettingsToPanel ( ) {
2023-02-24 19:21:27 -05:00
enableSignalSlot = false ;
2023-03-13 18:31:10 -04:00
printf ( " %s Digi-%d \n " , __func__ , digi [ ID ] - > GetSerialNumber ( ) ) ;
2023-03-10 17:28:02 -05:00
2023-02-23 16:08:47 -05:00
for ( unsigned short j = 0 ; j < ( unsigned short ) infoIndex . size ( ) ; j + + ) {
2023-02-28 17:08:34 -05:00
leInfo [ ID ] [ j ] - > setText ( QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( infoIndex [ j ] . second ) ) ) ;
2023-02-23 16:08:47 -05:00
}
//--------- LED Status
2023-03-14 16:17:22 -04:00
unsigned int ledStatus = atoi ( digi [ ID ] - > GetSettingValue ( PHA : : DIG : : LED_status ) . c_str ( ) ) ;
2023-02-23 16:08:47 -05:00
for ( int i = 0 ; i < 19 ; i + + ) {
if ( ( ledStatus > > i ) & 0x1 ) {
LEDStatus [ ID ] [ i ] - > setStyleSheet ( " background-color:green; " ) ;
} else {
LEDStatus [ ID ] [ i ] - > setStyleSheet ( " " ) ;
}
}
//--------- ACQ Status
2023-03-14 16:17:22 -04:00
unsigned int acqStatus = atoi ( digi [ ID ] - > GetSettingValue ( PHA : : DIG : : ACQ_status ) . c_str ( ) ) ;
2023-02-23 16:08:47 -05:00
for ( int i = 0 ; i < 7 ; i + + ) {
if ( ( acqStatus > > i ) & 0x1 ) {
ACQStatus [ ID ] [ i ] - > setStyleSheet ( " background-color:green; " ) ;
} else {
ACQStatus [ ID ] [ i ] - > setStyleSheet ( " " ) ;
}
}
2023-02-24 19:21:27 -05:00
//-------- temperature
for ( int i = 0 ; i < 8 ; i + + ) {
2023-03-14 16:17:22 -04:00
leTemp [ ID ] [ i ] - > setText ( QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( PHA : : DIG : : TempSensADC [ i ] ) ) ) ;
2023-02-24 19:21:27 -05:00
}
//-------- board settings
2023-03-14 16:17:22 -04:00
FillComboBoxValueFromMemory ( cbbClockSource [ ID ] , PHA : : DIG : : ClockSource ) ;
2023-02-24 19:21:27 -05:00
2023-03-14 16:17:22 -04:00
QString result = QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( PHA : : DIG : : StartSource ) ) ;
2023-02-24 19:21:27 -05:00
QStringList resultList = result . remove ( QChar ( ' ' ) ) . split ( " | " ) ;
2023-02-27 15:23:28 -05:00
//qDebug() << resultList << "," << resultList.count();
2023-03-14 16:17:22 -04:00
for ( int j = 0 ; j < ( int ) PHA : : DIG : : StartSource . GetAnswers ( ) . size ( ) ; j + + ) {
2023-02-27 15:23:28 -05:00
ckbStartSource [ ID ] [ j ] - > setChecked ( false ) ;
for ( int i = 0 ; i < resultList . count ( ) ; i + + ) {
//qDebug() << resultList[i] << ", " << QString::fromStdString((DIGIPARA::DIG::StartSource.GetAnswers())[j].first);
2023-03-14 16:17:22 -04:00
if ( resultList [ i ] = = QString : : fromStdString ( ( PHA : : DIG : : StartSource . GetAnswers ( ) ) [ j ] . first ) ) ckbStartSource [ ID ] [ j ] - > setChecked ( true ) ;
2023-02-27 15:23:28 -05:00
}
}
2023-03-14 16:17:22 -04:00
result = QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( PHA : : DIG : : GlobalTriggerSource ) ) ;
2023-02-27 15:23:28 -05:00
resultList = result . remove ( QChar ( ' ' ) ) . split ( " | " ) ;
2023-03-02 18:18:02 -05:00
testPulseBox - > setEnabled ( false ) ;
2023-03-14 16:17:22 -04:00
for ( int j = 0 ; j < ( int ) PHA : : DIG : : StartSource . GetAnswers ( ) . size ( ) ; j + + ) {
2023-02-27 15:23:28 -05:00
ckbGlbTrgSource [ ID ] [ j ] - > setChecked ( false ) ;
for ( int i = 0 ; i < resultList . count ( ) ; i + + ) {
2023-03-14 16:17:22 -04:00
if ( resultList [ i ] = = QString : : fromStdString ( ( PHA : : DIG : : GlobalTriggerSource . GetAnswers ( ) ) [ j ] . first ) ) {
2023-03-02 18:18:02 -05:00
ckbGlbTrgSource [ ID ] [ j ] - > setChecked ( true ) ;
if ( resultList [ i ] = = " TestPulse " ) testPulseBox - > setEnabled ( true ) ;
}
2023-02-27 15:23:28 -05:00
}
}
2023-02-23 16:08:47 -05:00
2023-03-14 16:17:22 -04:00
FillComboBoxValueFromMemory ( cbbTrgOut [ ID ] , PHA : : DIG : : TrgOutMode ) ;
FillComboBoxValueFromMemory ( cbbGPIO [ ID ] , PHA : : DIG : : GPIOMode ) ;
FillComboBoxValueFromMemory ( cbbBusyIn [ ID ] , PHA : : DIG : : BusyInSource ) ;
FillComboBoxValueFromMemory ( cbbSyncOut [ ID ] , PHA : : DIG : : SyncOutMode ) ;
FillComboBoxValueFromMemory ( cbbAutoDisarmAcq [ ID ] , PHA : : DIG : : EnableAutoDisarmACQ ) ;
FillComboBoxValueFromMemory ( cbbStatEvents [ ID ] , PHA : : DIG : : EnableStatisticEvents ) ;
FillComboBoxValueFromMemory ( cbbBdVetoPolarity [ ID ] , PHA : : DIG : : BoardVetoPolarity ) ;
FillComboBoxValueFromMemory ( cbbBoardVetoSource [ ID ] , PHA : : DIG : : BoardVetoSource ) ;
FillComboBoxValueFromMemory ( cbbIOLevel [ ID ] , PHA : : DIG : : IO_Level ) ;
FillSpinBoxValueFromMemory ( dsbBdVetoWidth [ ID ] , PHA : : DIG : : BoardVetoWidth ) ;
FillSpinBoxValueFromMemory ( spbRunDelay [ ID ] , PHA : : DIG : : RunDelay ) ;
FillSpinBoxValueFromMemory ( dsbVolatileClockOutDelay [ ID ] , PHA : : DIG : : VolatileClockOutDelay ) ;
FillSpinBoxValueFromMemory ( dsbClockOutDelay [ ID ] , PHA : : DIG : : PermanentClockOutDelay ) ;
2023-02-27 15:23:28 -05:00
//------------- test pulse
2023-03-14 16:17:22 -04:00
FillSpinBoxValueFromMemory ( dsbTestPuslePeriod [ ID ] , PHA : : DIG : : TestPulsePeriod ) ;
FillSpinBoxValueFromMemory ( dsbTestPusleWidth [ ID ] , PHA : : DIG : : TestPulseWidth ) ;
FillSpinBoxValueFromMemory ( spbTestPusleLowLevel [ ID ] , PHA : : DIG : : TestPulseLowLevel ) ;
FillSpinBoxValueFromMemory ( spbTestPusleHighLevel [ ID ] , PHA : : DIG : : TestPulseHighLevel ) ;
2023-03-02 15:00:59 -05:00
2023-03-03 18:53:59 -05:00
//@============================== Channel setting/ status
2023-03-02 15:00:59 -05:00
for ( int ch = 0 ; ch < digi [ ID ] - > GetNChannels ( ) ; ch + + ) {
2023-03-14 16:17:22 -04:00
unsigned int status = atoi ( digi [ ID ] - > GetSettingValue ( PHA : : CH : : ChannelStatus ) . c_str ( ) ) ;
2023-03-03 18:53:59 -05:00
for ( int i = 0 ; i < 9 ; i + + ) {
if ( ( status > > i ) & 0x1 ) {
chStatus [ ID ] [ ch ] [ i ] - > setStyleSheet ( " background-color:green; " ) ;
} else {
chStatus [ ID ] [ ch ] [ i ] - > setStyleSheet ( " " ) ;
}
}
2023-03-14 16:17:22 -04:00
chGainFactor [ ID ] [ ch ] - > setText ( QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( PHA : : CH : : GainFactor , ch ) ) ) ;
chADCToVolts [ ID ] [ ch ] - > setText ( QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( PHA : : CH : : ADCToVolts , ch ) ) ) ;
FillComboBoxValueFromMemory ( cbbOnOff [ ID ] [ ch ] , PHA : : CH : : ChannelEnable , ch ) ;
FillSpinBoxValueFromMemory ( spbDCOffset [ ID ] [ ch ] , PHA : : CH : : DC_Offset , ch ) ;
FillSpinBoxValueFromMemory ( spbThreshold [ ID ] [ ch ] , PHA : : CH : : TriggerThreshold , ch ) ;
FillComboBoxValueFromMemory ( cbbParity [ ID ] [ ch ] , PHA : : CH : : Polarity , ch ) ;
FillSpinBoxValueFromMemory ( spbRecordLength [ ID ] [ ch ] , PHA : : CH : : RecordLength , ch ) ;
FillSpinBoxValueFromMemory ( spbPreTrigger [ ID ] [ ch ] , PHA : : CH : : PreTrigger , ch ) ;
FillSpinBoxValueFromMemory ( spbInputRiseTime [ ID ] [ ch ] , PHA : : CH : : TimeFilterRiseTime , ch ) ;
FillSpinBoxValueFromMemory ( spbTriggerGuard [ ID ] [ ch ] , PHA : : CH : : TimeFilterRetriggerGuard , ch ) ;
FillComboBoxValueFromMemory ( cbbLowFilter [ ID ] [ ch ] , PHA : : CH : : EnergyFilterLowFreqFilter , ch ) ;
FillComboBoxValueFromMemory ( cbbWaveSource [ ID ] [ ch ] , PHA : : CH : : WaveDataSource , ch ) ;
FillComboBoxValueFromMemory ( cbbWaveRes [ ID ] [ ch ] , PHA : : CH : : WaveResolution , ch ) ;
FillComboBoxValueFromMemory ( cbbWaveSave [ ID ] [ ch ] , PHA : : CH : : WaveSaving , ch ) ;
FillSpinBoxValueFromMemory ( spbTrapRiseTime [ ID ] [ ch ] , PHA : : CH : : EnergyFilterRiseTime , ch ) ;
FillSpinBoxValueFromMemory ( spbTrapFlatTop [ ID ] [ ch ] , PHA : : CH : : EnergyFilterFlatTop , ch ) ;
FillSpinBoxValueFromMemory ( spbTrapPoleZero [ ID ] [ ch ] , PHA : : CH : : EnergyFilterPoleZero , ch ) ;
FillSpinBoxValueFromMemory ( spbPeaking [ ID ] [ ch ] , PHA : : CH : : EnergyFilterPeakingPosition , ch ) ;
FillComboBoxValueFromMemory ( cbbPeakingAvg [ ID ] [ ch ] , PHA : : CH : : EnergyFilterPeakingAvg , ch ) ;
FillComboBoxValueFromMemory ( cbbBaselineAvg [ ID ] [ ch ] , PHA : : CH : : EnergyFilterBaselineAvg , ch ) ;
FillSpinBoxValueFromMemory ( spbFineGain [ ID ] [ ch ] , PHA : : CH : : EnergyFilterFineGain , ch ) ;
FillSpinBoxValueFromMemory ( spbBaselineGuard [ ID ] [ ch ] , PHA : : CH : : EnergyFilterBaselineGuard , ch ) ;
FillSpinBoxValueFromMemory ( spbPileupGuard [ ID ] [ ch ] , PHA : : CH : : EnergyFilterPileUpGuard , ch ) ;
FillComboBoxValueFromMemory ( cbbAnaProbe0 [ ID ] [ ch ] , PHA : : CH : : WaveAnalogProbe0 , ch ) ;
FillComboBoxValueFromMemory ( cbbAnaProbe1 [ ID ] [ ch ] , PHA : : CH : : WaveAnalogProbe1 , ch ) ;
FillComboBoxValueFromMemory ( cbbDigProbe0 [ ID ] [ ch ] , PHA : : CH : : WaveDigitalProbe0 , ch ) ;
FillComboBoxValueFromMemory ( cbbDigProbe1 [ ID ] [ ch ] , PHA : : CH : : WaveDigitalProbe1 , ch ) ;
FillComboBoxValueFromMemory ( cbbDigProbe2 [ ID ] [ ch ] , PHA : : CH : : WaveDigitalProbe2 , ch ) ;
FillComboBoxValueFromMemory ( cbbDigProbe3 [ ID ] [ ch ] , PHA : : CH : : WaveDigitalProbe3 , ch ) ;
FillComboBoxValueFromMemory ( cbbEventSelector [ ID ] [ ch ] , PHA : : CH : : EventSelector , ch ) ;
FillComboBoxValueFromMemory ( cbbWaveSelector [ ID ] [ ch ] , PHA : : CH : : WaveSelector , ch ) ;
FillSpinBoxValueFromMemory ( spbEnergySkimLow [ ID ] [ ch ] , PHA : : CH : : EnergySkimLowDiscriminator , ch ) ;
FillSpinBoxValueFromMemory ( spbEnergySkimHigh [ ID ] [ ch ] , PHA : : CH : : EnergySkimHighDiscriminator , ch ) ;
FillComboBoxValueFromMemory ( cbbEvtTrigger [ ID ] [ ch ] , PHA : : CH : : EventTriggerSource , ch ) ;
FillComboBoxValueFromMemory ( cbbWaveTrigger [ ID ] [ ch ] , PHA : : CH : : WaveTriggerSource , ch ) ;
FillComboBoxValueFromMemory ( cbbChVetoSrc [ ID ] [ ch ] , PHA : : CH : : ChannelVetoSource , ch ) ;
FillComboBoxValueFromMemory ( cbbCoinMask [ ID ] [ ch ] , PHA : : CH : : CoincidenceMask , ch ) ;
FillComboBoxValueFromMemory ( cbbAntiCoinMask [ ID ] [ ch ] , PHA : : CH : : AntiCoincidenceMask , ch ) ;
FillSpinBoxValueFromMemory ( spbCoinLength [ ID ] [ ch ] , PHA : : CH : : CoincidenceLength , ch ) ;
FillSpinBoxValueFromMemory ( spbADCVetoWidth [ ID ] [ ch ] , PHA : : CH : : ADCVetoWidth , ch ) ;
2023-03-02 15:00:59 -05:00
}
2023-02-27 15:23:28 -05:00
2023-02-24 19:21:27 -05:00
enableSignalSlot = true ;
2023-03-13 16:51:11 -04:00
2023-03-13 19:23:14 -04:00
if ( cbChPick [ ID ] - > currentData ( ) . toInt ( ) > = 0 ) return ;
2023-03-02 15:00:59 -05:00
SyncComboBox ( cbbOnOff , - 1 ) ;
SyncComboBox ( cbbParity , - 1 ) ;
SyncComboBox ( cbbLowFilter , - 1 ) ;
SyncComboBox ( cbbWaveSource , - 1 ) ;
SyncComboBox ( cbbWaveRes , - 1 ) ;
SyncComboBox ( cbbWaveSave , - 1 ) ;
SyncComboBox ( cbbPeakingAvg , - 1 ) ;
SyncComboBox ( cbbBaselineAvg , - 1 ) ;
SyncComboBox ( cbbAnaProbe0 , - 1 ) ;
SyncComboBox ( cbbAnaProbe1 , - 1 ) ;
SyncComboBox ( cbbDigProbe0 , - 1 ) ;
SyncComboBox ( cbbDigProbe1 , - 1 ) ;
SyncComboBox ( cbbDigProbe2 , - 1 ) ;
SyncComboBox ( cbbDigProbe3 , - 1 ) ;
SyncComboBox ( cbbEventSelector , - 1 ) ;
SyncComboBox ( cbbWaveSelector , - 1 ) ;
SyncComboBox ( cbbEvtTrigger , - 1 ) ;
SyncComboBox ( cbbWaveTrigger , - 1 ) ;
SyncComboBox ( cbbChVetoSrc , - 1 ) ;
SyncComboBox ( cbbCoinMask , - 1 ) ;
SyncComboBox ( cbbAntiCoinMask , - 1 ) ;
SyncSpinBox ( spbDCOffset , - 1 ) ;
SyncSpinBox ( spbThreshold , - 1 ) ;
SyncSpinBox ( spbRecordLength , - 1 ) ;
SyncSpinBox ( spbPreTrigger , - 1 ) ;
SyncSpinBox ( spbInputRiseTime , - 1 ) ;
SyncSpinBox ( spbTriggerGuard , - 1 ) ;
SyncSpinBox ( spbTrapRiseTime , - 1 ) ;
SyncSpinBox ( spbTrapFlatTop , - 1 ) ;
SyncSpinBox ( spbTrapPoleZero , - 1 ) ;
SyncSpinBox ( spbPeaking , - 1 ) ;
SyncSpinBox ( spbFineGain , - 1 ) ;
SyncSpinBox ( spbBaselineGuard , - 1 ) ;
SyncSpinBox ( spbPileupGuard , - 1 ) ;
SyncSpinBox ( spbEnergySkimHigh , - 1 ) ;
SyncSpinBox ( spbEnergySkimLow , - 1 ) ;
SyncSpinBox ( spbCoinLength , - 1 ) ;
SyncSpinBox ( spbADCVetoWidth , - 1 ) ;
2023-02-23 16:08:47 -05:00
2023-03-14 16:17:22 -04:00
ReadTriggerMap ( ) ;
2023-03-01 12:26:37 -05:00
}
//^###########################################################################
void DigiSettingsPanel : : SetStartSource ( ) {
if ( ! enableSignalSlot ) return ;
std : : string value = " " ;
2023-03-14 16:17:22 -04:00
for ( int i = 0 ; i < ( int ) PHA : : DIG : : StartSource . GetAnswers ( ) . size ( ) ; i + + ) {
2023-03-01 12:26:37 -05:00
if ( ckbStartSource [ ID ] [ i ] - > isChecked ( ) ) {
//printf("----- %s \n", DIGIPARA::DIG::StartSource.GetAnswers()[i].first.c_str());
if ( value ! = " " ) value + = " | " ;
2023-03-14 16:17:22 -04:00
value + = PHA : : DIG : : StartSource . GetAnswers ( ) [ i ] . first ;
2023-03-01 12:26:37 -05:00
}
}
2023-03-02 18:18:02 -05:00
//printf("================ %s\n", value.c_str());
2023-03-03 16:19:39 -05:00
QString msg ;
2023-03-14 16:17:22 -04:00
msg = QString : : fromStdString ( PHA : : DIG : : StartSource . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
2023-03-03 16:19:39 -05:00
msg + = " = " + QString : : fromStdString ( value ) ;
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg ) ;
2023-03-01 12:26:37 -05:00
2023-03-14 16:17:22 -04:00
digi [ ID ] - > WriteValue ( PHA : : DIG : : StartSource , value ) ;
2023-03-01 12:26:37 -05:00
}
void DigiSettingsPanel : : SetGlobalTriggerSource ( ) {
if ( ! enableSignalSlot ) return ;
std : : string value = " " ;
2023-03-02 18:18:02 -05:00
testPulseBox - > setEnabled ( false ) ;
2023-03-14 16:17:22 -04:00
for ( int i = 0 ; i < ( int ) PHA : : DIG : : GlobalTriggerSource . GetAnswers ( ) . size ( ) ; i + + ) {
2023-03-01 12:26:37 -05:00
if ( ckbGlbTrgSource [ ID ] [ i ] - > isChecked ( ) ) {
//printf("----- %s \n", DIGIPARA::DIG::StartSource.GetAnswers()[i].first.c_str());
if ( value ! = " " ) value + = " | " ;
2023-03-14 16:17:22 -04:00
value + = PHA : : DIG : : GlobalTriggerSource . GetAnswers ( ) [ i ] . first ;
if ( PHA : : DIG : : GlobalTriggerSource . GetAnswers ( ) [ i ] . first = = " TestPulse " ) testPulseBox - > setEnabled ( true ) ;
2023-03-01 12:26:37 -05:00
}
}
2023-03-02 18:18:02 -05:00
//printf("================ %s\n", value.c_str());
2023-03-03 16:19:39 -05:00
QString msg ;
2023-03-14 16:17:22 -04:00
msg = QString : : fromStdString ( PHA : : DIG : : GlobalTriggerSource . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
2023-03-03 16:19:39 -05:00
msg + = " = " + QString : : fromStdString ( value ) ;
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg ) ;
2023-03-03 16:19:39 -05:00
2023-03-14 16:17:22 -04:00
digi [ ID ] - > WriteValue ( PHA : : DIG : : GlobalTriggerSource , value ) ;
2023-03-01 12:26:37 -05:00
2023-02-23 16:08:47 -05:00
}
2023-02-24 19:21:27 -05:00
2023-03-01 12:26:37 -05:00
//^###########################################################################
2023-03-03 16:19:39 -05:00
void DigiSettingsPanel : : SetupShortComboBox ( RComboBox * & cbb , Reg para ) {
2023-02-27 15:23:28 -05:00
for ( int i = 0 ; i < ( int ) para . GetAnswers ( ) . size ( ) ; i + + ) {
cbb - > addItem ( QString : : fromStdString ( ( para . GetAnswers ( ) ) [ i ] . second ) ,
QString : : fromStdString ( ( para . GetAnswers ( ) ) [ i ] . first ) ) ;
}
}
2023-03-03 15:23:26 -05:00
void DigiSettingsPanel : : SetupComboBox ( RComboBox * & cbb , const Reg para , int ch_index , bool isMaster , QString labelTxt , QGridLayout * layout , int row , int col , int srow , int scol ) {
2023-02-28 13:28:30 -05:00
QLabel * lb = new QLabel ( labelTxt , this ) ;
2023-02-27 15:23:28 -05:00
layout - > addWidget ( lb , row , col ) ;
lb - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
2023-03-03 15:23:26 -05:00
cbb = new RComboBox ( this ) ;
2023-02-27 15:23:28 -05:00
layout - > addWidget ( cbb , row , col + 1 , srow , scol ) ;
for ( int i = 0 ; i < ( int ) para . GetAnswers ( ) . size ( ) ; i + + ) {
2023-02-28 13:28:30 -05:00
cbb - > addItem ( QString : : fromStdString ( ( para . GetAnswers ( ) ) [ i ] . second ) , QString : : fromStdString ( ( para . GetAnswers ( ) ) [ i ] . first ) ) ;
2023-02-27 15:23:28 -05:00
}
2023-03-14 16:17:22 -04:00
if ( ch_index = = - 1 & & para . GetType ( ) = = TYPE : : CH ) cbb - > addItem ( " " ) ;
2023-03-03 15:23:26 -05:00
connect ( cbb , & RComboBox : : currentIndexChanged , this , [ = ] ( ) {
2023-03-01 12:26:37 -05:00
if ( ! enableSignalSlot ) return ;
2023-03-14 16:17:22 -04:00
int index = ( ch_index = = - 1 & & isMaster ? cbChPick [ ID ] - > currentData ( ) . toInt ( ) : ch_index ) ;
2023-03-13 19:23:14 -04:00
//int index = ch_index;
//printf("%s %d %s \n", para.GetPara().c_str(), index, cbb->currentData().toString().toStdString().c_str());
2023-03-03 16:19:39 -05:00
QString msg ;
msg = QString : : fromStdString ( para . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
2023-03-14 16:17:22 -04:00
if ( para . GetType ( ) = = TYPE : : CH ) msg + = " ,CH: " + ( index = = - 1 ? " All " : QString : : number ( index ) ) ;
2023-03-13 19:23:14 -04:00
if ( para . GetType ( ) = = TYPE : : VGA ) msg + = " ,VGA: " + QString : : number ( index ) ;
2023-03-03 16:19:39 -05:00
msg + = " = " + cbb - > currentData ( ) . toString ( ) ;
2023-03-13 19:23:14 -04:00
if ( digi [ ID ] - > WriteValue ( para , cbb - > currentData ( ) . toString ( ) . toStdString ( ) , index ) ) {
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |OK. " ) ;
2023-03-03 16:19:39 -05:00
cbb - > setStyleSheet ( " " ) ;
2023-03-13 19:23:14 -04:00
ShowSettingsToPanel ( ) ;
2023-03-03 16:19:39 -05:00
} else {
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |Fail. " ) ;
2023-03-03 16:19:39 -05:00
cbb - > setStyleSheet ( " color:red; " ) ;
}
2023-03-01 12:26:37 -05:00
} ) ;
2023-02-28 13:28:30 -05:00
}
2023-03-14 16:17:22 -04:00
void DigiSettingsPanel : : SetupSpinBox ( RSpinBox * & spb , const Reg para , int ch_index , bool isMaster , QString labelTxt , QGridLayout * layout , int row , int col , int srow , int scol ) {
2023-02-28 13:28:30 -05:00
QLabel * lb = new QLabel ( labelTxt , this ) ;
layout - > addWidget ( lb , row , col ) ;
lb - > setAlignment ( Qt : : AlignRight | Qt : : AlignCenter ) ;
2023-03-13 19:23:14 -04:00
spb = new RSpinBox ( this ) ;
2023-03-14 16:17:22 -04:00
if ( isMaster ) {
2023-03-02 18:18:02 -05:00
spb - > setMinimum ( qMin ( - 1.0 , atof ( para . GetAnswers ( ) [ 0 ] . first . c_str ( ) ) ) ) ;
2023-03-14 16:17:22 -04:00
} else {
spb - > setMinimum ( atof ( para . GetAnswers ( ) [ 0 ] . first . c_str ( ) ) ) ;
2023-03-02 18:18:02 -05:00
}
spb - > setMaximum ( atof ( para . GetAnswers ( ) [ 1 ] . first . c_str ( ) ) ) ;
2023-03-03 15:23:26 -05:00
if ( para . GetAnswers ( ) . size ( ) > = 3 ) {
spb - > setSingleStep ( atof ( para . GetAnswers ( ) [ 2 ] . first . c_str ( ) ) ) ;
} else {
printf ( " --- missed. %s \n " , para . GetPara ( ) . c_str ( ) ) ;
}
2023-02-28 13:28:30 -05:00
layout - > addWidget ( spb , row , col + 1 , srow , scol ) ;
2023-03-13 19:23:14 -04:00
2023-03-03 15:23:26 -05:00
connect ( spb , & RSpinBox : : valueChanged , this , [ = ] ( ) {
if ( ! enableSignalSlot ) return ;
spb - > setStyleSheet ( " color:blue; " ) ;
} ) ;
connect ( spb , & RSpinBox : : returnPressed , this , [ = ] ( ) {
2023-03-01 12:26:37 -05:00
if ( ! enableSignalSlot ) return ;
2023-03-13 19:23:14 -04:00
//printf("%s %d %d \n", para.GetPara().c_str(), index, spb->value());
2023-03-03 15:23:26 -05:00
if ( spb - > decimals ( ) = = 0 & & spb - > singleStep ( ) ! = 1 ) {
double step = spb - > singleStep ( ) ;
double value = spb - > value ( ) ;
spb - > setValue ( ( std : : round ( value / step ) * step ) ) ;
}
2023-03-14 16:17:22 -04:00
int index = ( ch_index = = - 1 & & isMaster ? cbChPick [ ID ] - > currentData ( ) . toInt ( ) : ch_index ) ;
2023-03-03 16:19:39 -05:00
QString msg ;
msg = QString : : fromStdString ( para . GetPara ( ) ) + " |DIG: " + QString : : number ( digi [ ID ] - > GetSerialNumber ( ) ) ;
2023-03-13 19:23:14 -04:00
if ( para . GetType ( ) = = TYPE : : CH ) msg + = " ,CH: " + ( index = = - 1 ? " All " : QString : : number ( index ) ) ;
2023-03-03 16:19:39 -05:00
msg + = " = " + QString : : number ( spb - > value ( ) ) ;
2023-03-13 19:23:14 -04:00
if ( digi [ ID ] - > WriteValue ( para , std : : to_string ( spb - > value ( ) ) , index ) ) {
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |OK. " ) ;
2023-03-03 16:19:39 -05:00
spb - > setStyleSheet ( " " ) ;
2023-03-13 19:23:14 -04:00
ShowSettingsToPanel ( ) ;
2023-03-03 16:19:39 -05:00
} else {
2023-03-10 17:28:02 -05:00
SendLogMsg ( msg + " |Fail. " ) ;
2023-03-03 16:19:39 -05:00
spb - > setStyleSheet ( " color:red; " ) ;
}
2023-03-01 12:26:37 -05:00
} ) ;
2023-02-28 13:28:30 -05:00
}
2023-02-27 15:23:28 -05:00
2023-03-03 15:23:26 -05:00
void DigiSettingsPanel : : SyncComboBox ( RComboBox * ( & cbb ) [ ] [ MaxNumberOfChannel + 1 ] , int ch ) {
2023-03-01 18:27:17 -05:00
if ( ! enableSignalSlot ) return ;
2023-03-13 19:23:14 -04:00
if ( cbChPick [ ID ] - > currentData ( ) . toInt ( ) > = 0 ) return ;
2023-03-01 18:27:17 -05:00
const int nCh = digi [ ID ] - > GetNChannels ( ) ;
if ( ch = = nCh ) {
const int index = cbb [ ID ] [ nCh ] - > currentIndex ( ) ;
if ( cbb [ ID ] [ nCh ] - > currentText ( ) = = " " ) return ;
enableSignalSlot = false ;
for ( int i = 0 ; i < nCh ; i + + ) cbb [ ID ] [ i ] - > setCurrentIndex ( index ) ;
enableSignalSlot = true ;
} else {
//check is all ComboBox has same index;
int count = 1 ;
const int index = cbb [ ID ] [ 0 ] - > currentIndex ( ) ;
for ( int i = 1 ; i < nCh ; i + + ) {
if ( cbb [ ID ] [ i ] - > currentIndex ( ) = = index ) count + + ;
}
enableSignalSlot = false ;
if ( count ! = nCh ) {
cbb [ ID ] [ nCh ] - > setCurrentText ( " " ) ;
} else {
cbb [ ID ] [ nCh ] - > setCurrentIndex ( index ) ;
}
enableSignalSlot = true ;
}
}
2023-03-03 15:23:26 -05:00
void DigiSettingsPanel : : SyncSpinBox ( RSpinBox * ( & spb ) [ ] [ MaxNumberOfChannel + 1 ] , int ch ) {
2023-03-01 18:27:17 -05:00
if ( ! enableSignalSlot ) return ;
const int nCh = digi [ ID ] - > GetNChannels ( ) ;
if ( ch = = nCh ) {
const int value = spb [ ID ] [ nCh ] - > value ( ) ;
if ( spb [ ID ] [ nCh ] - > value ( ) = = - 999 ) return ;
enableSignalSlot = false ;
for ( int i = 0 ; i < nCh ; i + + ) spb [ ID ] [ i ] - > setValue ( value ) ;
enableSignalSlot = true ;
} else {
//check is all ComboBox has same index;
int count = 1 ;
const int value = spb [ ID ] [ 0 ] - > value ( ) ;
for ( int i = 1 ; i < nCh ; i + + ) {
if ( spb [ ID ] [ i ] - > value ( ) = = value ) count + + ;
}
2023-03-02 15:00:59 -05:00
//printf("%d =? %d \n", count, nCh);
2023-03-01 18:27:17 -05:00
enableSignalSlot = false ;
if ( count ! = nCh ) {
2023-03-02 15:00:59 -05:00
spb [ ID ] [ nCh ] - > setValue ( - 1 ) ;
2023-03-01 18:27:17 -05:00
} else {
spb [ ID ] [ nCh ] - > setValue ( value ) ;
}
enableSignalSlot = true ;
}
}
2023-03-03 15:23:26 -05:00
void DigiSettingsPanel : : SetupSpinBoxTab ( RSpinBox * ( & spb ) [ ] [ MaxNumberOfChannel + 1 ] , const Reg para , QString text , QTabWidget * tabWidget , int iDigi , int nChannel ) {
2023-02-28 13:28:30 -05:00
QWidget * tabPage = new QWidget ( this ) ; tabWidget - > addTab ( tabPage , text ) ;
QGridLayout * allLayout = new QGridLayout ( tabPage ) ;
2023-02-28 17:08:34 -05:00
//allLayout->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
2023-02-28 13:28:30 -05:00
allLayout - > setAlignment ( Qt : : AlignTop ) ;
2023-02-28 17:08:34 -05:00
allLayout - > setHorizontalSpacing ( 10 ) ;
2023-02-28 13:28:30 -05:00
allLayout - > setVerticalSpacing ( 0 ) ;
for ( int ch = 0 ; ch < nChannel ; ch + + ) {
2023-03-14 16:17:22 -04:00
SetupSpinBox ( spb [ iDigi ] [ ch ] , para , ch , false , " ch- " + QString : : number ( ch ) + " " , allLayout , ch / 4 , ch % 4 * 2 ) ;
2023-02-28 13:28:30 -05:00
}
}
2023-03-03 15:23:26 -05:00
void DigiSettingsPanel : : SetupComboBoxTab ( RComboBox * ( & cbb ) [ ] [ MaxNumberOfChannel + 1 ] , const Reg para , QString text , QTabWidget * tabWidget , int iDigi , int nChannel , int nCol ) {
2023-02-28 13:28:30 -05:00
QWidget * tabPage = new QWidget ( this ) ; tabWidget - > addTab ( tabPage , text ) ;
QGridLayout * allLayout = new QGridLayout ( tabPage ) ;
2023-02-28 17:08:34 -05:00
//allLayout->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
2023-02-28 13:28:30 -05:00
allLayout - > setAlignment ( Qt : : AlignTop ) ;
2023-02-28 17:08:34 -05:00
allLayout - > setHorizontalSpacing ( 10 ) ;
2023-02-28 13:28:30 -05:00
allLayout - > setVerticalSpacing ( 0 ) ;
for ( int ch = 0 ; ch < nChannel ; ch + + ) {
2023-03-01 18:27:17 -05:00
SetupComboBox ( cbb [ iDigi ] [ ch ] , para , ch , false , " ch- " + QString : : number ( ch ) + " " , allLayout , ch / nCol , ch % nCol * 3 ) ;
2023-02-28 13:28:30 -05:00
}
2023-02-27 15:23:28 -05:00
}
2023-03-03 15:23:26 -05:00
void DigiSettingsPanel : : FillComboBoxValueFromMemory ( RComboBox * & cbb , const Reg para , int ch_index ) {
2023-03-02 15:00:59 -05:00
QString result = QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( para , ch_index ) ) ;
2023-02-28 13:28:30 -05:00
//printf("%s === %s, %d, %p\n", __func__, result.toStdString().c_str(), ID, cbb);
2023-02-27 15:23:28 -05:00
int index = cbb - > findData ( result ) ;
if ( index > = 0 & & index < cbb - > count ( ) ) {
cbb - > setCurrentIndex ( index ) ;
2023-02-24 19:21:27 -05:00
} else {
2023-03-10 18:09:25 -05:00
//printf("%s %s\n", para.GetPara().c_str(), result.toStdString().c_str());
2023-02-24 19:21:27 -05:00
}
}
2023-03-02 15:00:59 -05:00
2023-03-03 15:23:26 -05:00
void DigiSettingsPanel : : FillSpinBoxValueFromMemory ( RSpinBox * & spb , const Reg para , int ch_index ) {
2023-03-02 15:00:59 -05:00
QString result = QString : : fromStdString ( digi [ ID ] - > GetSettingValue ( para , ch_index ) ) ;
//printf("%s === %s, %d, %p\n", __func__, result.toStdString().c_str(), ID, spb);
spb - > setValue ( result . toDouble ( ) ) ;
}
2023-03-13 16:51:11 -04:00
void DigiSettingsPanel : : ReadBoardSetting ( int cbIndex ) {
enableSignalSlot = false ;
QString type ;
2023-03-14 16:17:22 -04:00
switch ( PHA : : DIG : : AllSettings [ cbIndex ] . ReadWrite ( ) ) {
2023-03-13 16:51:11 -04:00
case RW : : ReadOnly : type = " Read Only " ; break ;
case RW : : WriteOnly : type = " Write Only " ; break ;
case RW : : ReadWrite : type = " Read/Write " ; break ;
}
leBdSettingsType - > setText ( type ) ;
2023-03-14 16:17:22 -04:00
leBdSettingsRead - > setText ( QString : : fromStdString ( digi [ cbIQDigi - > currentIndex ( ) ] - > ReadValue ( PHA : : DIG : : AllSettings [ cbIndex ] ) ) ) ;
leBdSettingsUnit - > setText ( QString : : fromStdString ( PHA : : DIG : : AllSettings [ cbIndex ] . GetUnit ( ) ) ) ;
2023-03-13 16:51:11 -04:00
2023-03-14 16:17:22 -04:00
ANSTYPE haha = PHA : : DIG : : AllSettings [ cbIndex ] . GetAnswerType ( ) ;
if ( PHA : : DIG : : AllSettings [ cbIndex ] . ReadWrite ( ) ! = RW : : ReadOnly & & haha ! = ANSTYPE : : NONE ) {
2023-03-13 16:51:11 -04:00
if ( haha = = ANSTYPE : : FLOAT | | haha = = ANSTYPE : : INTEGER ) {
cbBdAns - > clear ( ) ;
cbBdAns - > setEnabled ( false ) ;
leBdSettingsWrite - > setEnabled ( false ) ;
leBdSettingsWrite - > clear ( ) ;
sbBdSettingsWrite - > setEnabled ( true ) ;
2023-03-14 16:17:22 -04:00
sbBdSettingsWrite - > setMinimum ( atof ( PHA : : DIG : : AllSettings [ cbIndex ] . GetAnswers ( ) [ 0 ] . first . c_str ( ) ) ) ;
sbBdSettingsWrite - > setMaximum ( atof ( PHA : : DIG : : AllSettings [ cbIndex ] . GetAnswers ( ) [ 1 ] . first . c_str ( ) ) ) ;
sbBdSettingsWrite - > setSingleStep ( atof ( PHA : : DIG : : AllSettings [ cbIndex ] . GetAnswers ( ) [ 2 ] . first . c_str ( ) ) ) ;
2023-03-13 16:51:11 -04:00
sbBdSettingsWrite - > setValue ( 00 ) ;
sbBdSettingsWrite - > setDecimals ( 0 ) ;
}
if ( haha = = ANSTYPE : : FLOAT ) sbBdSettingsWrite - > setDecimals ( 3 ) ;
if ( haha = = ANSTYPE : : LIST ) {
cbBdAns - > setEnabled ( true ) ;
cbBdAns - > clear ( ) ;
2023-03-14 16:17:22 -04:00
for ( int i = 0 ; i < ( int ) PHA : : DIG : : AllSettings [ cbIndex ] . GetAnswers ( ) . size ( ) ; i + + ) {
cbBdAns - > addItem ( QString : : fromStdString ( PHA : : DIG : : AllSettings [ cbIndex ] . GetAnswers ( ) [ i ] . second ) ,
QString : : fromStdString ( PHA : : DIG : : AllSettings [ cbIndex ] . GetAnswers ( ) [ i ] . first ) ) ;
2023-03-13 16:51:11 -04:00
}
sbBdSettingsWrite - > setEnabled ( false ) ;
sbBdSettingsWrite - > setValue ( 0 ) ;
leBdSettingsWrite - > setEnabled ( false ) ;
leBdSettingsWrite - > clear ( ) ;
}
if ( haha = = ANSTYPE : : STR ) {
cbBdAns - > clear ( ) ;
cbBdAns - > setEnabled ( false ) ;
leBdSettingsWrite - > setEnabled ( true ) ;
leBdSettingsWrite - > clear ( ) ;
sbBdSettingsWrite - > setEnabled ( false ) ;
sbBdSettingsWrite - > setValue ( 0 ) ;
}
} else {
cbBdAns - > clear ( ) ;
cbBdAns - > setEnabled ( false ) ;
sbBdSettingsWrite - > setEnabled ( false ) ;
sbBdSettingsWrite - > cleanText ( ) ;
leBdSettingsWrite - > setEnabled ( false ) ;
leBdSettingsWrite - > clear ( ) ;
}
2023-03-14 16:17:22 -04:00
if ( PHA : : DIG : : AllSettings [ cbIndex ] . GetPara ( ) = = PHA : : DIG : : StartSource . GetPara ( )
| | PHA : : DIG : : AllSettings [ cbIndex ] . GetPara ( ) = = PHA : : DIG : : GlobalTriggerSource . GetPara ( ) ) {
2023-03-13 16:51:11 -04:00
leBdSettingsWrite - > setEnabled ( true ) ;
leBdSettingsWrite - > clear ( ) ;
}
enableSignalSlot = true ;
}
void DigiSettingsPanel : : ReadChannelSetting ( int cbIndex ) {
enableSignalSlot = false ;
QString type ;
2023-03-14 16:17:22 -04:00
switch ( PHA : : CH : : AllSettings [ cbIndex ] . ReadWrite ( ) ) {
2023-03-13 16:51:11 -04:00
case RW : : ReadOnly : type = " Read Only " ; break ;
case RW : : WriteOnly : type = " Write Only " ; break ;
case RW : : ReadWrite : type = " Read/Write " ; break ;
}
leChSettingsType - > setText ( type ) ;
2023-03-14 16:17:22 -04:00
leChSettingsRead - > setText ( QString : : fromStdString ( digi [ cbIQDigi - > currentIndex ( ) ] - > ReadValue ( PHA : : CH : : AllSettings [ cbIndex ] , cbIQCh - > currentData ( ) . toInt ( ) ) ) ) ;
leChSettingsUnit - > setText ( QString : : fromStdString ( PHA : : CH : : AllSettings [ cbIndex ] . GetUnit ( ) ) ) ;
2023-03-13 16:51:11 -04:00
2023-03-14 16:17:22 -04:00
ANSTYPE haha = PHA : : CH : : AllSettings [ cbIndex ] . GetAnswerType ( ) ;
2023-03-13 16:51:11 -04:00
2023-03-14 16:17:22 -04:00
if ( PHA : : CH : : AllSettings [ cbIndex ] . ReadWrite ( ) ! = RW : : ReadOnly & & haha ! = ANSTYPE : : NONE ) {
2023-03-13 16:51:11 -04:00
if ( haha = = ANSTYPE : : FLOAT | | haha = = ANSTYPE : : INTEGER ) {
cbChAns - > clear ( ) ;
cbChAns - > setEnabled ( false ) ;
leChSettingsWrite - > setEnabled ( false ) ;
leChSettingsWrite - > clear ( ) ;
sbChSettingsWrite - > setEnabled ( true ) ;
2023-03-14 16:17:22 -04:00
sbChSettingsWrite - > setMinimum ( atof ( PHA : : CH : : AllSettings [ cbIndex ] . GetAnswers ( ) [ 0 ] . first . c_str ( ) ) ) ;
sbChSettingsWrite - > setMaximum ( atof ( PHA : : CH : : AllSettings [ cbIndex ] . GetAnswers ( ) [ 1 ] . first . c_str ( ) ) ) ;
sbChSettingsWrite - > setSingleStep ( atof ( PHA : : CH : : AllSettings [ cbIndex ] . GetAnswers ( ) [ 2 ] . first . c_str ( ) ) ) ;
2023-03-13 16:51:11 -04:00
sbChSettingsWrite - > setValue ( 00 ) ;
sbChSettingsWrite - > setDecimals ( 0 ) ;
}
if ( haha = = ANSTYPE : : FLOAT ) sbBdSettingsWrite - > setDecimals ( 3 ) ;
if ( haha = = ANSTYPE : : LIST ) {
cbChAns - > setEnabled ( true ) ;
cbChAns - > clear ( ) ;
2023-03-14 16:17:22 -04:00
for ( int i = 0 ; i < ( int ) PHA : : CH : : AllSettings [ cbIndex ] . GetAnswers ( ) . size ( ) ; i + + ) {
cbChAns - > addItem ( QString : : fromStdString ( PHA : : CH : : AllSettings [ cbIndex ] . GetAnswers ( ) [ i ] . second ) ,
QString : : fromStdString ( PHA : : CH : : AllSettings [ cbIndex ] . GetAnswers ( ) [ i ] . first ) ) ;
2023-03-13 16:51:11 -04:00
}
sbChSettingsWrite - > setEnabled ( false ) ;
sbChSettingsWrite - > setValue ( 0 ) ;
leChSettingsWrite - > setEnabled ( false ) ;
leChSettingsWrite - > clear ( ) ;
}
if ( haha = = ANSTYPE : : STR ) {
cbChAns - > clear ( ) ;
cbChAns - > setEnabled ( false ) ;
leChSettingsWrite - > setEnabled ( true ) ;
leChSettingsWrite - > clear ( ) ;
sbChSettingsWrite - > setEnabled ( false ) ;
sbChSettingsWrite - > setValue ( 0 ) ;
}
} else {
cbChAns - > clear ( ) ;
cbChAns - > setEnabled ( false ) ;
sbChSettingsWrite - > setEnabled ( false ) ;
sbChSettingsWrite - > cleanText ( ) ;
leChSettingsWrite - > setEnabled ( false ) ;
leChSettingsWrite - > clear ( ) ;
}
enableSignalSlot = true ;
}
2023-03-13 18:31:10 -04:00
void DigiSettingsPanel : : CheckRadioAndCheckedButtons ( ) {
int chFromIndex = - 1 ;
for ( int i = 0 ; i < MaxNumberOfChannel ; i + + ) {
2023-03-14 16:17:22 -04:00
rbCopyChFrom [ i ] - > setStyleSheet ( " " ) ;
2023-03-13 18:31:10 -04:00
if ( rbCopyChFrom [ i ] - > isChecked ( ) ) {
chFromIndex = i ;
2023-03-14 16:17:22 -04:00
rbCopyChFrom [ i ] - > setStyleSheet ( " color : red; " ) ;
chkChTo [ i ] - > setChecked ( false ) ;
chkChTo [ i ] - > setStyleSheet ( " " ) ;
2023-03-13 18:31:10 -04:00
}
}
2023-03-14 16:17:22 -04:00
for ( int i = 0 ; i < MaxNumberOfChannel ; i + + ) chkChTo [ i ] - > setEnabled ( true ) ;
2023-03-13 18:31:10 -04:00
if ( chFromIndex > = 0 ) chkChTo [ chFromIndex ] - > setEnabled ( false ) ;
bool isToIndexCleicked = false ;
for ( int i = 0 ; i < MaxNumberOfChannel ; i + + ) {
if ( chkChTo [ i ] - > isChecked ( ) ) {
isToIndexCleicked = true ;
2023-03-14 16:17:22 -04:00
chkChTo [ i ] - > setStyleSheet ( " color : red; " ) ;
} else {
chkChTo [ i ] - > setStyleSheet ( " " ) ;
2023-03-13 18:31:10 -04:00
}
}
2023-03-14 16:17:22 -04:00
pbCopyChannel - > setEnabled ( chFromIndex > = 0 & & isToIndexCleicked ) ;
2023-03-13 18:31:10 -04:00
}
2023-03-14 16:17:22 -04:00
bool DigiSettingsPanel : : CopyChannelSettings ( int digiFrom , int chFrom , int digiTo , int chTo ) {
2023-03-13 18:31:10 -04:00
2023-03-14 16:17:22 -04:00
SendLogMsg ( " Copy Settings from DIG: " + QString : : number ( digi [ digiFrom ] - > GetSerialNumber ( ) ) + " , CH: " + QString : : number ( chFrom ) + " ---> DIG: " + QString : : number ( digi [ digiTo ] - > GetSerialNumber ( ) ) + " , CH: " + QString : : number ( chTo ) ) ;
for ( int k = 0 ; k < ( int ) PHA : : CH : : AllSettings . size ( ) ; k + + ) {
if ( PHA : : CH : : AllSettings [ k ] . ReadWrite ( ) ! = RW : : ReadWrite ) continue ;
if ( ! digi [ digiTo ] - > WriteValue ( PHA : : CH : : AllSettings [ k ] , digi [ digiFrom ] - > GetSettingValue ( PHA : : CH : : AllSettings [ k ] , chFrom ) , chTo ) ) {
SendLogMsg ( " something wrong when copying setting : " + QString : : fromStdString ( PHA : : CH : : AllSettings [ k ] . GetPara ( ) ) ) ;
return false ;
2023-03-13 18:31:10 -04:00
break ;
}
}
return true ;
}
bool DigiSettingsPanel : : CopyBoardSettings ( ) {
int digiFromIndex = cbCopyDigiFrom - > currentIndex ( ) ;
int digiToIndex = cbCopyDigiTo - > currentIndex ( ) ;
SendLogMsg ( " Copy Settings from DIG: " + QString : : number ( digi [ digiFromIndex ] - > GetSerialNumber ( ) ) + " to DIG: " + QString : : number ( digi [ digiToIndex ] - > GetSerialNumber ( ) ) ) ;
for ( int i = 0 ; i < MaxNumberOfChannel ; i + + ) {
if ( chkChTo [ i ] - > isChecked ( ) ) {
//Copy setting
2023-03-14 16:17:22 -04:00
for ( int k = 0 ; k < ( int ) PHA : : DIG : : AllSettings . size ( ) ; k + + ) {
if ( PHA : : DIG : : AllSettings [ k ] . ReadWrite ( ) ! = RW : : ReadWrite ) continue ;
if ( ! digi [ digiToIndex ] - > WriteValue ( PHA : : DIG : : AllSettings [ k ] , digi [ digiFromIndex ] - > GetSettingValue ( PHA : : DIG : : AllSettings [ k ] ) ) ) {
SendLogMsg ( " something wrong when copying setting : " + QString : : fromStdString ( PHA : : DIG : : AllSettings [ k ] . GetPara ( ) ) ) ;
2023-03-13 18:31:10 -04:00
return false ;
break ;
}
}
}
}
SendLogMsg ( " ------ done " ) ;
ID = digiToIndex ;
ShowSettingsToPanel ( ) ;
return true ;
}
bool DigiSettingsPanel : : CopyWholeDigitizer ( ) {
2023-03-14 16:17:22 -04:00
if ( ! CopyBoardSettings ( ) ) return false ;
int digiTo = cbCopyDigiTo - > currentIndex ( ) ;
for ( int ch = 0 ; ch < digi [ ID ] - > GetNChannels ( ) ; ch + + ) {
if ( ! CopyChannelSettings ( cbCopyDigiFrom - > currentIndex ( ) , ch , digiTo , ch ) ) return false ;
}
return true ;
2023-03-13 18:31:10 -04:00
}