snapshot, before making MutliBuilder to be independent of Digitizer class

This commit is contained in:
carina@hades 2023-10-05 12:26:17 -04:00
parent f7502d1c1c
commit 8cf46f6c5f
7 changed files with 514 additions and 411 deletions

View File

@ -22,6 +22,7 @@ void Digitizer::Initalization(){
boardID = -1; boardID = -1;
handle = -1; handle = -1;
NChannel = 16; NChannel = 16;
NCoupledCh = 8;
ADCbits = 1; ADCbits = 1;
DPPType = 0; DPPType = 0;
ADCFullSize = 0; ADCFullSize = 0;
@ -103,9 +104,9 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
NChannel = BoardInfo.Channels; NChannel = BoardInfo.Channels;
channelMask = pow(2, NChannel)-1; channelMask = pow(2, NChannel)-1;
switch(BoardInfo.Model){ switch(BoardInfo.Model){
case CAEN_DGTZ_V1730: tick2ns = 2.0; break; ///ns -> 500 MSamples/s case CAEN_DGTZ_V1730: tick2ns = 2.0; NCoupledCh = 8; break; ///ns -> 500 MSamples/s
case CAEN_DGTZ_V1725: tick2ns = 4.0; break; ///ns -> 250 MSamples/s case CAEN_DGTZ_V1725: tick2ns = 4.0; NCoupledCh = 8; break; ///ns -> 250 MSamples/s
case CAEN_DGTZ_V1740: tick2ns = 16.0; break; ///ns -> 62.5 MSamples/s case CAEN_DGTZ_V1740: tick2ns = 16.0; NCoupledCh = 8; break; ///ns -> 62.5 MSamples/s
default : tick2ns = 4.0; break; default : tick2ns = 4.0; break;
} }
data->tick2ns = tick2ns; data->tick2ns = tick2ns;
@ -603,9 +604,9 @@ Reg Digitizer::FindRegister(uint32_t address){
Reg tempReg; Reg tempReg;
///========= Find Match Register ///========= Find Match Register
for( int p = 0; p < (int) RegisterDPPList[p]; p++){ for( int p = 0; p < (int) RegisterPHAPSDBoardList[p]; p++){
if( address == RegisterDPPList[p].GetAddress() ) { if( address == RegisterPHAPSDBoardList[p].GetAddress() ) {
tempReg = RegisterDPPList[p]; tempReg = RegisterPHAPSDBoardList[p];
break; break;
} }
} }
@ -639,9 +640,9 @@ void Digitizer::ReadAllSettingsFromBoard(bool force){
printf("===== Digitizer::%s \n", __func__); printf("===== Digitizer::%s \n", __func__);
/// board setting /// board setting
for( int p = 0; p < (int) RegisterDPPList.size(); p++){ for( int p = 0; p < (int) RegisterPHAPSDBoardList.size(); p++){
if( RegisterDPPList[p].GetRWType() == RW::WriteONLY) continue; if( RegisterPHAPSDBoardList[p].GetRWType() == RW::WriteONLY) continue;
ReadRegister(RegisterDPPList[p]); ReadRegister(RegisterPHAPSDBoardList[p]);
} }
channelMask = GetSettingFromMemory(DPP::ChannelEnableMask); channelMask = GetSettingFromMemory(DPP::ChannelEnableMask);
@ -673,9 +674,9 @@ void Digitizer::ProgramSettingsToBoard(){
Reg haha; Reg haha;
/// board setting /// board setting
for( int p = 0; p < (int) RegisterDPPList.size(); p++){ for( int p = 0; p < (int) RegisterPHAPSDBoardList.size(); p++){
if( RegisterDPPList[p].GetRWType() == RW::ReadWrite) { if( RegisterPHAPSDBoardList[p].GetRWType() == RW::ReadWrite) {
haha = RegisterDPPList[p]; haha = RegisterPHAPSDBoardList[p];
WriteRegister(haha, GetSettingFromMemory(haha), -1, false); WriteRegister(haha, GetSettingFromMemory(haha), -1, false);
usleep(1 * 1000); usleep(1 * 1000);
} }
@ -850,8 +851,8 @@ void Digitizer::SaveAllSettingsAsText(std::string fileName){
uint32_t actualAddress = haha.CalAddress(i); uint32_t actualAddress = haha.CalAddress(i);
///printf("%7d--- 0x%04X, 0x%04X\n", i, haha->GetAddress(), haha->ActualAddress()); ///printf("%7d--- 0x%04X, 0x%04X\n", i, haha->GetAddress(), haha->ActualAddress());
for( int p = 0; p < (int) RegisterDPPList.size(); p++){ for( int p = 0; p < (int) RegisterPHAPSDBoardList.size(); p++){
if( haha.GetAddress() == (uint32_t) RegisterDPPList[p] ) haha = RegisterDPPList[p]; if( haha.GetAddress() == (uint32_t) RegisterPHAPSDBoardList[p] ) haha = RegisterPHAPSDBoardList[p];
} }
if( DPPType == V1730_DPP_PHA_CODE) { if( DPPType == V1730_DPP_PHA_CODE) {
for( int p = 0; p < (int) RegisterPHAList.size(); p++){ for( int p = 0; p < (int) RegisterPHAList.size(); p++){

View File

@ -28,6 +28,7 @@ class Digitizer{
int boardID; /// board identity int boardID; /// board identity
int handle; /// i don't know why, but better separete the handle from boardID int handle; /// i don't know why, but better separete the handle from boardID
int NChannel; /// number of channel int NChannel; /// number of channel
int NCoupledCh; /// number of Coupled channel
int ADCbits; /// ADC bit int ADCbits; /// ADC bit
int DPPType; /// DPP verion int DPPType; /// DPP verion
unsigned int ADCFullSize; /// pow(2, ADCbits) - 1 unsigned int ADCFullSize; /// pow(2, ADCbits) - 1
@ -108,7 +109,7 @@ class Digitizer{
bool GetChannelOnOff(unsigned ch) { channelMask = GetSettingFromMemory(DPP::ChannelEnableMask); return (channelMask & ( 1 << ch) );} bool GetChannelOnOff(unsigned ch) { channelMask = GetSettingFromMemory(DPP::ChannelEnableMask); return (channelMask & ( 1 << ch) );}
float GetTick2ns() const {return tick2ns;} float GetTick2ns() const {return tick2ns;}
int GetNChannels() const {return NChannel;} int GetNChannels() const {return NChannel;}
int GetNCoupledCh() const { return DPPType != DPPType::DPP_QDC_CODE ? NChannel/2 : NChannel/8;} int GetNCoupledCh() const {return NCoupledCh;}
int GetHandle() const {return handle;} int GetHandle() const {return handle;}
int GetDPPType() const {return DPPType;} int GetDPPType() const {return DPPType;}
std::string GetDPPString(int DPPType = 0); /// if no input, use digitizer DPPType std::string GetDPPString(int DPPType = 0); /// if no input, use digitizer DPPType

View File

@ -262,7 +262,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr
QLabel * lbLVDSInfo = new QLabel(" LDVS settings will be implement later. ", bdLVDS); QLabel * lbLVDSInfo = new QLabel(" LDVS settings will be implement later. ", bdLVDS);
bdLVDSLayout[iDigi]->addWidget(lbLVDSInfo); bdLVDSLayout[iDigi]->addWidget(lbLVDSInfo);
SetUpChannelMask(); SetUpChannelMask(iDigi);
if( digi[iDigi]->GetDPPType() == V1730_DPP_PHA_CODE ) SetUpPHABoard(); if( digi[iDigi]->GetDPPType() == V1730_DPP_PHA_CODE ) SetUpPHABoard();
if( digi[iDigi]->GetDPPType() == V1730_DPP_PSD_CODE ) SetUpPSDBoard(); if( digi[iDigi]->GetDPPType() == V1730_DPP_PSD_CODE ) SetUpPSDBoard();
@ -288,340 +288,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr
} }
//TODO ----- Copy settings tab SetUpInquiryCopyTab();
{//*##################################### Inquiry / Copy Tab
QWidget * inquiryTab = new QWidget(this);
tabWidget->addTab(inquiryTab, "Inquiry / Copy");
QGridLayout * layout = new QGridLayout(inquiryTab);
layout->setAlignment(Qt::AlignTop);
{//^================ Inquiry
QGroupBox * inquiryBox = new QGroupBox("Register Settings", inquiryTab);
layout->addWidget(inquiryBox);
QGridLayout * regLayout = new QGridLayout(inquiryBox);
regLayout->setAlignment(Qt::AlignLeft);
QLabel * lb1 = new QLabel("Register", inquiryBox); lb1->setAlignment(Qt::AlignCenter); regLayout->addWidget(lb1, 0, 1);
QLabel * lb2 = new QLabel("R/W", inquiryBox); lb2->setAlignment(Qt::AlignCenter); regLayout->addWidget(lb2, 0, 2);
QLabel * lb3 = new QLabel("Present Value", inquiryBox); lb3->setAlignment(Qt::AlignCenter); regLayout->addWidget(lb3, 0, 3);
QLabel * lb4 = new QLabel("Set Value", inquiryBox); lb4->setAlignment(Qt::AlignCenter); regLayout->addWidget(lb4, 0, 4);
///--------------- board
RComboBox * cbDigi = new RComboBox(inquiryBox);
cbDigi->setFixedWidth(120);
for( int i = 0; i < (int) nDigi; i++) cbDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
regLayout->addWidget(cbDigi, 1, 0);
RComboBox * cbBdReg = new RComboBox(inquiryBox);
cbBdReg->setFixedWidth(300);
for( int i = 0; i < (int) RegisterDPPList.size() ; i++ ){
cbBdReg->addItem( QString::fromStdString(RegisterDPPList[i].GetName()) + " [0x" + QString::number(RegisterDPPList[i].GetAddress(), 16).toUpper() + "]", RegisterDPPList[i].GetAddress());
}
regLayout->addWidget(cbBdReg, 1, 1);
QLineEdit * leBdRegRW = new QLineEdit(inquiryBox);
leBdRegRW->setReadOnly(true);
leBdRegRW->setFixedWidth(120);
regLayout->addWidget(leBdRegRW, 1, 2);
QLineEdit * leBdRegValue = new QLineEdit(inquiryBox);
leBdRegValue->setReadOnly(true);
leBdRegValue->setFixedWidth(120);
regLayout->addWidget(leBdRegValue, 1, 3);
QLineEdit * leBdRegSet = new QLineEdit(inquiryBox);
leBdRegSet->setFixedWidth(120);
regLayout->addWidget(leBdRegSet, 1, 4);
///--------------- channel
RComboBox * cbCh = new RComboBox(inquiryBox);
cbCh->setFixedWidth(120);
regLayout->addWidget(cbCh, 2, 0);
RComboBox * cbChReg = new RComboBox(inquiryBox);
cbChReg->setFixedWidth(300);
regLayout->addWidget(cbChReg, 2, 1);
QLineEdit * leChRegRW = new QLineEdit(inquiryBox);
leChRegRW->setFixedWidth(120);
leChRegRW->setReadOnly(true);
regLayout->addWidget(leChRegRW, 2, 2);
QLineEdit * leChRegValue = new QLineEdit(inquiryBox);
leChRegValue->setReadOnly(true);
leChRegValue->setFixedWidth(120);
regLayout->addWidget(leChRegValue, 2, 3);
QLineEdit * leChRegSet = new QLineEdit(inquiryBox);
leChRegSet->setFixedWidth(120);
regLayout->addWidget(leChRegSet, 2, 4);
connect(cbDigi, &RComboBox::currentIndexChanged, this, [=](int index){
enableSignalSlot = false;
cbCh->clear();
for( int i = 0; i < digi[index]->GetNChannels(); i ++ ) cbCh->addItem("Ch-" + QString::number(i), i);
if( digi[index]->GetDPPType() == V1730_DPP_PHA_CODE ) chRegList = RegisterPHAList;
if( digi[index]->GetDPPType() == V1730_DPP_PSD_CODE ) chRegList = RegisterPSDList;
cbChReg->clear();
for( int i = 0; i < (int) chRegList.size(); i++ ){
cbChReg->addItem(QString::fromStdString(chRegList[i].GetName()) + " [0x" + QString::number(chRegList[i].GetAddress(), 16).toUpper() + "]", chRegList[i].GetAddress());
}
enableSignalSlot = true;
});
cbDigi->currentIndexChanged(0);
connect(cbBdReg, &RComboBox::currentIndexChanged, this, [=](int index){
if( !enableSignalSlot ) return;
if( RegisterDPPList[index].GetRWType() == RW::WriteONLY ) {
leBdRegRW->setText("Write ONLY" );
leBdRegValue->setText("");
leBdRegSet->setEnabled(true);
return;
}
uint32_t value = digi[ cbDigi->currentIndex() ] ->ReadRegister(RegisterDPPList[index]);
leBdRegValue->setText( "0x" + QString::number(value, 16).toUpper());
if( RegisterDPPList[index].GetRWType() == RW::ReadONLY ) {
leBdRegRW->setText("Read ONLY" );
leBdRegSet->setEnabled(false);
return;
}
if( RegisterDPPList[index].GetRWType() == RW::ReadWrite ) {
leBdRegRW->setText("Read/Write" );
leBdRegSet->setEnabled(true);
}
});
cbBdReg->currentIndexChanged(0);
connect(cbCh, &RComboBox::currentIndexChanged, this, [=](int index){
if( !enableSignalSlot ) return;
int regIndex = cbChReg->currentIndex();
uint32_t value = digi[ cbDigi->currentIndex() ] ->ReadRegister(chRegList[regIndex], cbCh->currentIndex(), index);
leChRegValue->setText( "0x" + QString::number(value, 16).toUpper());
});
connect(cbChReg, &RComboBox::currentIndexChanged, this, [=](int index){
if( !enableSignalSlot ) return;
if( chRegList[index].GetRWType() == RW::WriteONLY ) {
leChRegRW->setText("Write ONLY" );
leChRegValue->setText("");
leChRegSet->setEnabled(true);
return;
}
uint32_t value = digi[ cbDigi->currentIndex() ] ->ReadRegister(chRegList[index], cbCh->currentIndex());
leChRegValue->setText( "0x" + QString::number(value, 16).toUpper());
if( chRegList[index].GetRWType() == RW::ReadONLY ) {
leChRegRW->setText("Read ONLY" );
leChRegSet->setEnabled(false);
return;
}
if( chRegList[index].GetRWType() == RW::ReadWrite ) {
leChRegRW->setText("Read/Write" );
leChRegSet->setEnabled(true);
}
});
cbChReg->currentIndexChanged(0);
connect( leBdRegSet, &QLineEdit::textChanged, this, [=](){
if( !enableSignalSlot ) return;
leBdRegSet->setStyleSheet("color : blue;");
});
connect( leBdRegSet, &QLineEdit::returnPressed, this, [=](){
if( !enableSignalSlot ) return;
QString text = leBdRegSet->text();
if( text.contains("0x") ){
uint32_t value = std::stoul(text.toStdString(), nullptr, 16);
int index = cbDigi->currentIndex();
int regID = cbBdReg->currentIndex();
digi[index]->WriteRegister(RegisterDPPList[regID], value);
leBdRegSet->setStyleSheet("");
cbBdReg->currentIndexChanged(regID);
}else{
leBdRegSet->setText("use Hex 0xAB123");
leBdRegSet->setStyleSheet("color : red;");
}
});
connect( leChRegSet, &QLineEdit::textChanged, this, [=](){
if( !enableSignalSlot ) return;
leChRegSet->setStyleSheet("color : blue;");
});
connect( leChRegSet, &QLineEdit::returnPressed, this, [=](){
if( !enableSignalSlot ) return;
QString text = leChRegSet->text();
if( text.contains("0x") ){
uint32_t value = std::stoul(text.toStdString(), nullptr, 16);
int index = cbDigi->currentIndex();
int regID = cbChReg->currentIndex();
int ch = cbCh->currentIndex();
digi[index]->WriteRegister(chRegList[regID], value, ch);
leChRegSet->setStyleSheet("");
cbChReg->currentIndexChanged(regID);
}else{
leChRegSet->setText("use Hex 0xAB123");
leChRegSet->setStyleSheet("color : red;");
}
});
}
{//^================ Copy
QGroupBox * copyBox = new QGroupBox("Copy Settings", inquiryTab);
layout->addWidget(copyBox);
QGridLayout * copyLayout = new QGridLayout(copyBox);
copyLayout->setAlignment(Qt::AlignLeft);
//---------- copy from
QGroupBox * copyFromBox = new QGroupBox("Copy From", copyBox);
copyFromBox->setFixedWidth(400);
copyLayout->addWidget(copyFromBox, 0, 0, 8 + 1, 2);
QGridLayout * copyFromLayout = new QGridLayout(copyFromBox);
cbFromBoard = new RComboBox(copyFromBox);
for( unsigned int i = 0; i < nDigi; i++) cbFromBoard->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
copyFromLayout->addWidget(cbFromBoard, 0, 0, 1, 16);
connect(cbFromBoard, &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::CheckRadioAndCheckedButtons);
for( int i = 0 ; i < MaxNChannels; i++ ){
QLabel * leCh = new QLabel(QString::number(i), copyFromBox);
leCh->setAlignment(Qt::AlignRight);
copyFromLayout->addWidget(leCh, i%8 + 1, 2*(i/8));
rbCh[i] = new QRadioButton(copyFromBox);
copyFromLayout->addWidget(rbCh[i], i%8 + 1, 2*(i/8) + 1);
connect(rbCh[i], &QRadioButton::clicked, this, &DigiSettingsPanel::CheckRadioAndCheckedButtons);
int id1 = cbFromBoard->currentIndex();
if( i >= digi[id1]->GetNChannels() ) rbCh[i]->setEnabled(false);
}
//---------- Acton buttons
bnCopyBoard = new QPushButton("Copy Board",copyBox);
bnCopyBoard->setFixedSize(120, 50);
copyLayout->addWidget(bnCopyBoard, 2, 2);
bnCopyChannel = new QPushButton("Copy Channel(s)", copyBox);
bnCopyChannel->setFixedSize(120, 50);
copyLayout->addWidget(bnCopyChannel, 3, 2);
//---------- copy to
QGroupBox * copyToBox = new QGroupBox("Copy To", copyBox);
copyToBox->setFixedWidth(400);
copyLayout->addWidget(copyToBox, 0, 3, 8 + 1, 2);
QGridLayout * copyToLayout = new QGridLayout(copyToBox);
cbToBoard = new RComboBox(copyToBox);
for( unsigned int i = 0; i < nDigi; i++) cbToBoard->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
copyToLayout->addWidget(cbToBoard, 0, 0, 1, 16);
connect(cbToBoard, &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::CheckRadioAndCheckedButtons);
for( int i = 0 ; i < MaxNChannels; i++ ){
QLabel * leCh = new QLabel(QString::number(i), copyToBox);
leCh->setAlignment(Qt::AlignRight);
copyToLayout->addWidget(leCh, i%8 + 1, 2*(i/8));
chkCh[i] = new QCheckBox(copyToBox);
copyToLayout->addWidget(chkCh[i], i%8 + 1, 2*(i/8) + 1);
connect(chkCh[i], &QCheckBox::clicked, this, &DigiSettingsPanel::CheckRadioAndCheckedButtons);
int id1 = cbToBoard->currentIndex();
if( i >= digi[id1]->GetNChannels() ) chkCh[i]->setEnabled(false);
}
bnCopyBoard->setEnabled(false);
bnCopyChannel->setEnabled(false);
connect(bnCopyBoard, &QPushButton::clicked, this, [=](){
int fromIndex = cbFromBoard->currentIndex();
int toIndex = cbToBoard->currentIndex();
SendLogMsg("Copy Settings from DIG:" + QString::number(digi[fromIndex]->GetSerialNumber()) + " to DIG:" + QString::number(digi[toIndex]->GetSerialNumber()));
//Copy Board Setting
for( int i = 0; i < (int) RegisterDPPList.size(); i++){
if( RegisterDPPList[i].GetRWType() != RW::WriteONLY ) continue;
uint32_t value = digi[fromIndex]->GetSettingFromMemory(RegisterDPPList[i]);
digi[toIndex]->WriteRegister(RegisterDPPList[i], value);
}
std::vector<Reg> regList;
if( digi[fromIndex]->GetDPPType() == V1730_DPP_PHA_CODE ) regList = RegisterPHAList;
if( digi[fromIndex]->GetDPPType() == V1730_DPP_PSD_CODE ) regList = RegisterPSDList;
for( int i = 0; i < digi[toIndex]->GetNChannels() ; i++){
//Copy setting
for( int k = 0; k < (int) regList.size(); k ++){
if( regList[k].GetRWType() != RW::ReadWrite ) continue;
uint32_t value = digi[fromIndex]->GetSettingFromMemory(regList[k], i);
digi[toIndex]->WriteRegister(regList[k], value, i);
usleep(10000); // wait for 10 milisec
}
}
SendLogMsg("------ done");
return true;
});
connect(bnCopyChannel, &QPushButton::clicked, this, [=](){
int fromIndex = cbFromBoard->currentIndex();
int toIndex = cbToBoard->currentIndex();
std::vector<Reg> regList;
if( digi[fromIndex]->GetDPPType() == V1730_DPP_PHA_CODE ) regList = RegisterPHAList;
if( digi[fromIndex]->GetDPPType() == V1730_DPP_PSD_CODE ) regList = RegisterPSDList;
int fromCh = -1;
for( int i = 0; i < MaxNChannels; i++) {
if( rbCh[i]->isChecked() ) {
fromCh = i;
break;
}
}
if( fromCh == -1 ) return;
for( int i = 0; i < MaxNChannels; i++){
if( ! chkCh[i]->isChecked() ) return;
//Copy setting
for( int k = 0; k < (int) regList.size(); k ++){
if( regList[k].GetRWType() != RW::ReadWrite ) continue;
uint32_t value = digi[fromIndex]->GetSettingFromMemory(regList[k], fromCh);
digi[toIndex]->WriteRegister(regList[k], value, i);
}
}
});
}
}
connect(tabWidget, &QTabWidget::currentChanged, this, [=](int index){ connect(tabWidget, &QTabWidget::currentChanged, this, [=](int index){
if( index < (int) nDigi) { if( index < (int) nDigi) {
@ -631,7 +298,6 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr
} }
}); });
ID = 0; ID = 0;
UpdatePanelFromMemory(); UpdatePanelFromMemory();
@ -901,7 +567,7 @@ void DigiSettingsPanel::SetUpGlobalTriggerMaskAndFrontPanelMask(QGridLayout * &
cbTRINMezzanines[ID]->setEnabled(state); cbTRINMezzanines[ID]->setEnabled(state);
}); });
SetUpComboBox(cbAnalogMonitorMode[ID], "Analog Monitor Mode ", gLayout, 4, 0, DPP::AnalogMonitorMode, 0); SetUpComboBox(cbAnalogMonitorMode[ID], "Analog Monitor Mode ", gLayout, 4, 0, DPP::AnalogMonitorMode, 0);
connect(cbAnalogMonitorMode[ID], &RComboBox::currentIndexChanged, this, [=](int index){ connect(cbAnalogMonitorMode[ID], &RComboBox::currentIndexChanged, this, [=](int index){
if( index < 2) { if( index < 2) {
@ -1198,43 +864,394 @@ SetUpComboBox(cbAnalogMonitorMode[ID], "Analog Monitor Mode ", gLayout, 4, 0, DP
} }
//&########################################################### void DigiSettingsPanel::SetUpInquiryCopyTab(){
void DigiSettingsPanel::SetUpChannelMask(){
QLabel * chMaskLabel = new QLabel("Channel Mask : ", this); //*##################################### Inquiry / Copy Tab
QWidget * inquiryTab = new QWidget(this);
tabWidget->addTab(inquiryTab, "Inquiry / Copy");
QGridLayout * layout = new QGridLayout(inquiryTab);
layout->setAlignment(Qt::AlignTop);
{//^================ Inquiry
QGroupBox * inquiryBox = new QGroupBox("Register Settings", inquiryTab);
layout->addWidget(inquiryBox);
QGridLayout * regLayout = new QGridLayout(inquiryBox);
regLayout->setAlignment(Qt::AlignLeft);
QLabel * lb1 = new QLabel("Register", inquiryBox); lb1->setAlignment(Qt::AlignCenter); regLayout->addWidget(lb1, 0, 1);
QLabel * lb2 = new QLabel("R/W", inquiryBox); lb2->setAlignment(Qt::AlignCenter); regLayout->addWidget(lb2, 0, 2);
QLabel * lb3 = new QLabel("Present Value", inquiryBox); lb3->setAlignment(Qt::AlignCenter); regLayout->addWidget(lb3, 0, 3);
QLabel * lb4 = new QLabel("Set Value", inquiryBox); lb4->setAlignment(Qt::AlignCenter); regLayout->addWidget(lb4, 0, 4);
///--------------- board
RComboBox * cbDigi = new RComboBox(inquiryBox);
cbDigi->setFixedWidth(120);
for( int i = 0; i < (int) nDigi; i++) cbDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
regLayout->addWidget(cbDigi, 1, 0);
RComboBox * cbBdReg = new RComboBox(inquiryBox);
cbBdReg->setFixedWidth(300);
for( int i = 0; i < (int) RegisterPHAPSDBoardList.size() ; i++ ){
cbBdReg->addItem( QString::fromStdString(RegisterPHAPSDBoardList[i].GetName()) + " [0x" + QString::number(RegisterPHAPSDBoardList[i].GetAddress(), 16).toUpper() + "]", RegisterPHAPSDBoardList[i].GetAddress());
}
regLayout->addWidget(cbBdReg, 1, 1);
QLineEdit * leBdRegRW = new QLineEdit(inquiryBox);
leBdRegRW->setReadOnly(true);
leBdRegRW->setFixedWidth(120);
regLayout->addWidget(leBdRegRW, 1, 2);
QLineEdit * leBdRegValue = new QLineEdit(inquiryBox);
leBdRegValue->setReadOnly(true);
leBdRegValue->setFixedWidth(120);
regLayout->addWidget(leBdRegValue, 1, 3);
QLineEdit * leBdRegSet = new QLineEdit(inquiryBox);
leBdRegSet->setFixedWidth(120);
regLayout->addWidget(leBdRegSet, 1, 4);
///--------------- channel
RComboBox * cbCh = new RComboBox(inquiryBox);
cbCh->setFixedWidth(120);
regLayout->addWidget(cbCh, 2, 0);
RComboBox * cbChReg = new RComboBox(inquiryBox);
cbChReg->setFixedWidth(300);
regLayout->addWidget(cbChReg, 2, 1);
QLineEdit * leChRegRW = new QLineEdit(inquiryBox);
leChRegRW->setFixedWidth(120);
leChRegRW->setReadOnly(true);
regLayout->addWidget(leChRegRW, 2, 2);
QLineEdit * leChRegValue = new QLineEdit(inquiryBox);
leChRegValue->setReadOnly(true);
leChRegValue->setFixedWidth(120);
regLayout->addWidget(leChRegValue, 2, 3);
QLineEdit * leChRegSet = new QLineEdit(inquiryBox);
leChRegSet->setFixedWidth(120);
regLayout->addWidget(leChRegSet, 2, 4);
connect(cbDigi, &RComboBox::currentIndexChanged, this, [=](int index){
enableSignalSlot = false;
cbCh->clear();
for( int i = 0; i < digi[index]->GetNChannels(); i ++ ) cbCh->addItem("Ch-" + QString::number(i), i);
if( digi[index]->GetDPPType() == V1730_DPP_PHA_CODE ) chRegList = RegisterPHAList;
if( digi[index]->GetDPPType() == V1730_DPP_PSD_CODE ) chRegList = RegisterPSDList;
cbChReg->clear();
for( int i = 0; i < (int) chRegList.size(); i++ ){
cbChReg->addItem(QString::fromStdString(chRegList[i].GetName()) + " [0x" + QString::number(chRegList[i].GetAddress(), 16).toUpper() + "]", chRegList[i].GetAddress());
}
enableSignalSlot = true;
});
cbDigi->currentIndexChanged(0);
connect(cbBdReg, &RComboBox::currentIndexChanged, this, [=](int index){
if( !enableSignalSlot ) return;
if( RegisterPHAPSDBoardList[index].GetRWType() == RW::WriteONLY ) {
leBdRegRW->setText("Write ONLY" );
leBdRegValue->setText("");
leBdRegSet->setEnabled(true);
return;
}
uint32_t value = digi[ cbDigi->currentIndex() ] ->ReadRegister(RegisterPHAPSDBoardList[index]);
leBdRegValue->setText( "0x" + QString::number(value, 16).toUpper());
if( RegisterPHAPSDBoardList[index].GetRWType() == RW::ReadONLY ) {
leBdRegRW->setText("Read ONLY" );
leBdRegSet->setEnabled(false);
return;
}
if( RegisterPHAPSDBoardList[index].GetRWType() == RW::ReadWrite ) {
leBdRegRW->setText("Read/Write" );
leBdRegSet->setEnabled(true);
}
});
cbBdReg->currentIndexChanged(0);
connect(cbCh, &RComboBox::currentIndexChanged, this, [=](int index){
if( !enableSignalSlot ) return;
int regIndex = cbChReg->currentIndex();
uint32_t value = digi[ cbDigi->currentIndex() ] ->ReadRegister(chRegList[regIndex], cbCh->currentIndex(), index);
leChRegValue->setText( "0x" + QString::number(value, 16).toUpper());
});
connect(cbChReg, &RComboBox::currentIndexChanged, this, [=](int index){
if( !enableSignalSlot ) return;
if( chRegList[index].GetRWType() == RW::WriteONLY ) {
leChRegRW->setText("Write ONLY" );
leChRegValue->setText("");
leChRegSet->setEnabled(true);
return;
}
uint32_t value = digi[ cbDigi->currentIndex() ] ->ReadRegister(chRegList[index], cbCh->currentIndex());
leChRegValue->setText( "0x" + QString::number(value, 16).toUpper());
if( chRegList[index].GetRWType() == RW::ReadONLY ) {
leChRegRW->setText("Read ONLY" );
leChRegSet->setEnabled(false);
return;
}
if( chRegList[index].GetRWType() == RW::ReadWrite ) {
leChRegRW->setText("Read/Write" );
leChRegSet->setEnabled(true);
}
});
cbChReg->currentIndexChanged(0);
connect( leBdRegSet, &QLineEdit::textChanged, this, [=](){
if( !enableSignalSlot ) return;
leBdRegSet->setStyleSheet("color : blue;");
});
connect( leBdRegSet, &QLineEdit::returnPressed, this, [=](){
if( !enableSignalSlot ) return;
QString text = leBdRegSet->text();
if( text.contains("0x") ){
uint32_t value = std::stoul(text.toStdString(), nullptr, 16);
int index = cbDigi->currentIndex();
int regID = cbBdReg->currentIndex();
digi[index]->WriteRegister(RegisterPHAPSDBoardList[regID], value);
leBdRegSet->setStyleSheet("");
cbBdReg->currentIndexChanged(regID);
}else{
leBdRegSet->setText("use Hex 0xAB123");
leBdRegSet->setStyleSheet("color : red;");
}
});
connect( leChRegSet, &QLineEdit::textChanged, this, [=](){
if( !enableSignalSlot ) return;
leChRegSet->setStyleSheet("color : blue;");
});
connect( leChRegSet, &QLineEdit::returnPressed, this, [=](){
if( !enableSignalSlot ) return;
QString text = leChRegSet->text();
if( text.contains("0x") ){
uint32_t value = std::stoul(text.toStdString(), nullptr, 16);
int index = cbDigi->currentIndex();
int regID = cbChReg->currentIndex();
int ch = cbCh->currentIndex();
digi[index]->WriteRegister(chRegList[regID], value, ch);
leChRegSet->setStyleSheet("");
cbChReg->currentIndexChanged(regID);
}else{
leChRegSet->setText("use Hex 0xAB123");
leChRegSet->setStyleSheet("color : red;");
}
});
}
{//^================ Copy
const int div = 8;
QGroupBox * copyBox = new QGroupBox("Copy Settings", inquiryTab);
layout->addWidget(copyBox);
QGridLayout * copyLayout = new QGridLayout(copyBox);
copyLayout->setAlignment(Qt::AlignLeft);
//---------- copy from
QGroupBox * copyFromBox = new QGroupBox("Copy From", copyBox);
copyFromBox->setFixedWidth(400);
copyLayout->addWidget(copyFromBox, 0, 0, div + 1, 2);
QGridLayout * copyFromLayout = new QGridLayout(copyFromBox);
cbFromBoard = new RComboBox(copyFromBox);
for( unsigned int i = 0; i < nDigi; i++) cbFromBoard->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
copyFromLayout->addWidget(cbFromBoard, 0, 0, 1, 2*div);
connect(cbFromBoard, &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::CheckRadioAndCheckedButtons);
for( int i = 0 ; i < MaxNChannels; i++ ){
QLabel * leCh = new QLabel(QString::number(i), copyFromBox);
leCh->setAlignment(Qt::AlignRight);
copyFromLayout->addWidget(leCh, i%div + 1, 2*(i/div));
rbCh[i] = new QRadioButton(copyFromBox);
copyFromLayout->addWidget(rbCh[i], i%div + 1, 2*(i/div) + 1);
connect(rbCh[i], &QRadioButton::clicked, this, &DigiSettingsPanel::CheckRadioAndCheckedButtons);
int id1 = cbFromBoard->currentIndex();
if( i >= digi[id1]->GetNChannels() ) rbCh[i]->setEnabled(false);
}
//---------- Acton buttons
bnCopyBoard = new QPushButton("Copy Board",copyBox);
bnCopyBoard->setFixedSize(120, 50);
copyLayout->addWidget(bnCopyBoard, 2, 2);
bnCopyChannel = new QPushButton("Copy Channel(s)", copyBox);
bnCopyChannel->setFixedSize(120, 50);
copyLayout->addWidget(bnCopyChannel, 3, 2);
//---------- copy to
QGroupBox * copyToBox = new QGroupBox("Copy To", copyBox);
copyToBox->setFixedWidth(400);
copyLayout->addWidget(copyToBox, 0, 3, div + 1, 2);
QGridLayout * copyToLayout = new QGridLayout(copyToBox);
cbToBoard = new RComboBox(copyToBox);
for( unsigned int i = 0; i < nDigi; i++) cbToBoard->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
copyToLayout->addWidget(cbToBoard, 0, 0, 1, 2*div);
connect(cbToBoard, &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::CheckRadioAndCheckedButtons);
for( int i = 0 ; i < MaxNChannels; i++ ){
QLabel * leCh = new QLabel(QString::number(i), copyToBox);
leCh->setAlignment(Qt::AlignRight);
copyToLayout->addWidget(leCh, i%div + 1, 2*(i/div));
chkCh[i] = new QCheckBox(copyToBox);
copyToLayout->addWidget(chkCh[i], i%div + 1, 2*(i/div) + 1);
connect(chkCh[i], &QCheckBox::clicked, this, &DigiSettingsPanel::CheckRadioAndCheckedButtons);
int id1 = cbToBoard->currentIndex();
if( i >= digi[id1]->GetNChannels() ) chkCh[i]->setEnabled(false);
}
bnCopyBoard->setEnabled(false);
bnCopyChannel->setEnabled(false);
connect(bnCopyBoard, &QPushButton::clicked, this, [=](){
int fromIndex = cbFromBoard->currentIndex();
int toIndex = cbToBoard->currentIndex();
SendLogMsg("Copy Settings from DIG:" + QString::number(digi[fromIndex]->GetSerialNumber()) + " to DIG:" + QString::number(digi[toIndex]->GetSerialNumber()));
//Copy Board Setting
for( int i = 0; i < (int) RegisterPHAPSDBoardList.size(); i++){
if( RegisterPHAPSDBoardList[i].GetRWType() != RW::WriteONLY ) continue;
uint32_t value = digi[fromIndex]->GetSettingFromMemory(RegisterPHAPSDBoardList[i]);
digi[toIndex]->WriteRegister(RegisterPHAPSDBoardList[i], value);
}
std::vector<Reg> regList;
if( digi[fromIndex]->GetDPPType() == V1730_DPP_PHA_CODE ) regList = RegisterPHAList;
if( digi[fromIndex]->GetDPPType() == V1730_DPP_PSD_CODE ) regList = RegisterPSDList;
for( int i = 0; i < digi[toIndex]->GetNChannels() ; i++){
//Copy setting
for( int k = 0; k < (int) regList.size(); k ++){
if( regList[k].GetRWType() != RW::ReadWrite ) continue;
uint32_t value = digi[fromIndex]->GetSettingFromMemory(regList[k], i);
digi[toIndex]->WriteRegister(regList[k], value, i);
usleep(10000); // wait for 10 milisec
}
}
SendLogMsg("------ done");
return true;
});
connect(bnCopyChannel, &QPushButton::clicked, this, [=](){
int fromIndex = cbFromBoard->currentIndex();
int toIndex = cbToBoard->currentIndex();
std::vector<Reg> regList;
if( digi[fromIndex]->GetDPPType() == V1730_DPP_PHA_CODE ) regList = RegisterPHAList;
if( digi[fromIndex]->GetDPPType() == V1730_DPP_PSD_CODE ) regList = RegisterPSDList;
int fromCh = -1;
for( int i = 0; i < MaxNChannels; i++) {
if( rbCh[i]->isChecked() ) {
fromCh = i;
break;
}
}
if( fromCh == -1 ) return;
for( int i = 0; i < MaxNChannels; i++){
if( ! chkCh[i]->isChecked() ) return;
//Copy setting
for( int k = 0; k < (int) regList.size(); k ++){
if( regList[k].GetRWType() != RW::ReadWrite ) continue;
uint32_t value = digi[fromIndex]->GetSettingFromMemory(regList[k], fromCh);
digi[toIndex]->WriteRegister(regList[k], value, i);
}
}
});
}
}
//&###########################################################
void DigiSettingsPanel::SetUpChannelMask(unsigned int digiID){
QString lbStr = "Channel Mask :";
if( digi[digiID]->GetDPPType() == DPPType::DPP_QDC_CODE ) lbStr = "Group Mask :";
QLabel * chMaskLabel = new QLabel(lbStr, this);
chMaskLabel->setAlignment(Qt::AlignRight | Qt::AlignCenter); chMaskLabel->setAlignment(Qt::AlignRight | Qt::AlignCenter);
bdCfgLayout[ID]->addWidget(chMaskLabel, 0, 0); bdCfgLayout[digiID]->addWidget(chMaskLabel, 0, 0);
QWidget * chWiget = new QWidget(this); QWidget * chWiget = new QWidget(this);
bdCfgLayout[ID]->addWidget(chWiget, 0, 1, 1, 3); bdCfgLayout[digiID]->addWidget(chWiget, 0, 1, 1, 3);
QGridLayout * chLayout = new QGridLayout(chWiget); QGridLayout * chLayout = new QGridLayout(chWiget);
chLayout->setAlignment(Qt::AlignLeft); chLayout->setAlignment(Qt::AlignLeft);
chLayout->setSpacing(0); chLayout->setSpacing(0);
for( int i = 0; i < digi[ID]->GetNChannels(); i++){ int nChGrp = digi[digiID]->GetNChannels();
bnChEnableMask[ID][i] = new QPushButton(this); if( digi[digiID]->GetDPPType() == DPPType::DPP_QDC_CODE ) nChGrp = digi[digiID]->GetNCoupledCh();
bnChEnableMask[ID][i]->setFixedSize(QSize(20,20));
bnChEnableMask[ID][i]->setToolTip("Ch-" + QString::number(i)); for( int i = 0; i < nChGrp; i++){
bnChEnableMask[ID][i]->setToolTipDuration(-1); bnChEnableMask[digiID][i] = new QPushButton(this);
bnChEnableMask[digiID][i]->setFixedSize(QSize(20,20));
bnChEnableMask[digiID][i]->setToolTip("Ch-" + QString::number(i));
bnChEnableMask[digiID][i]->setToolTipDuration(-1);
QLabel * chIDLabel = new QLabel(QString::number(i), this); QLabel * chIDLabel = new QLabel(QString::number(i), this);
chIDLabel->setAlignment(Qt::AlignBottom | Qt::AlignHCenter); chIDLabel->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
chLayout->addWidget(chIDLabel, 0, i); chLayout->addWidget(chIDLabel, 0, i);
chLayout->addWidget(bnChEnableMask[ID][i], 1, i ); chLayout->addWidget(bnChEnableMask[digiID][i], 1, i );
connect(bnChEnableMask[ID][i], &QPushButton::clicked, this, [=](){ connect(bnChEnableMask[digiID][i], &QPushButton::clicked, this, [=](){
if( !enableSignalSlot) return; if( !enableSignalSlot) return;
if( bnChEnableMask[ID][i]->styleSheet() == "" ){ if( bnChEnableMask[digiID][i]->styleSheet() == "" ){
bnChEnableMask[ID][i]->setStyleSheet("background-color : green;"); bnChEnableMask[digiID][i]->setStyleSheet("background-color : green;");
digi[ID]->SetBits(DPP::ChannelEnableMask, {1, i}, 1, i);
if( digi[digiID]->GetDPPType() == DPPType::DPP_QDC_CODE ){
digi[digiID]->SetBits(DPP::QDC::GroupEnableMask, {1, i}, 1, i);
}else{
digi[digiID]->SetBits(DPP::ChannelEnableMask, {1, i}, 1, i);
}
}else{ }else{
bnChEnableMask[ID][i]->setStyleSheet(""); bnChEnableMask[digiID][i]->setStyleSheet("");
digi[ID]->SetBits(DPP::ChannelEnableMask, {1, i}, 0, i); if( digi[digiID]->GetDPPType() == DPPType::DPP_QDC_CODE ){
digi[digiID]->SetBits(DPP::QDC::GroupEnableMask, {1, i}, 0, i);
}else{
digi[digiID]->SetBits(DPP::ChannelEnableMask, {1, i}, 0, i);
}
} }
if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) UpdatePHASetting(); if( digi[digiID]->GetDPPType() == V1730_DPP_PHA_CODE ) UpdateSettings_PHA();
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) UpdatePSDSetting(); if( digi[digiID]->GetDPPType() == V1730_DPP_PSD_CODE ) UpdateSettings_PSD();
if( digi[digiID]->GetDPPType() == V1740_DPP_QDC_CODE ) UpdateSettings_QDC();
emit UpdateOtherPanels(); emit UpdateOtherPanels();
}); });
@ -1763,9 +1780,9 @@ void DigiSettingsPanel::SetUpPSDBoard(){
SetUpCheckBox(chkTraceRecording[ID], "Record Trace", bdCfgLayout[ID], 2, 1, DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace); SetUpCheckBox(chkTraceRecording[ID], "Record Trace", bdCfgLayout[ID], 2, 1, DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace);
SetUpCheckBox(chkEnableExtra2[ID], "Enable Extra", bdCfgLayout[ID], 3, 1, DPP::BoardConfiguration, DPP::Bit_BoardConfig::EnableExtra2); SetUpCheckBox(chkEnableExtra2[ID], "Enable Extra", bdCfgLayout[ID], 3, 1, DPP::BoardConfiguration, DPP::Bit_BoardConfig::EnableExtra2);
SetUpComboBoxBit(cbAnaProbe1[ID], "Ana. Probe ", bdCfgLayout[ID], 1, 2, DPP::Bit_BoardConfig::ListAnaProbe_PSD, DPP::BoardConfiguration, DPP::Bit_BoardConfig::AnaProbe_PSD, 1, 0); SetUpComboBoxBit(cbAnaProbe1[ID], "Ana. Probe ", bdCfgLayout[ID], 1, 2, DPP::Bit_BoardConfig::ListAnaProbe_PSD, DPP::BoardConfiguration, DPP::Bit_BoardConfig::AnalogProbe1, 1, 0);
SetUpComboBoxBit(cbDigiProbe1[ID], "Digi. Probe 1 ", bdCfgLayout[ID], 3, 2, DPP::Bit_BoardConfig::ListDigiProbe1_PSD, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1_PHA, 1, 0); SetUpComboBoxBit(cbDigiProbe1[ID], "Digi. Probe 1 ", bdCfgLayout[ID], 3, 2, DPP::Bit_BoardConfig::ListDigiProbe1_PSD, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1_PSD, 1, 0);
SetUpComboBoxBit(cbDigiProbe2[ID], "Digi. Probe 2 ", bdCfgLayout[ID], 4, 2, DPP::Bit_BoardConfig::ListDigiProbe2_PSD, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel2_PHA, 1, 0); SetUpComboBoxBit(cbDigiProbe2[ID], "Digi. Probe 2 ", bdCfgLayout[ID], 4, 2, DPP::Bit_BoardConfig::ListDigiProbe2_PSD, DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel2_PSD, 1, 0);
} }
@ -2457,7 +2474,7 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) { if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) {
chkDecimateTrace[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DisableDigiTrace_PSD) ); chkDecimateTrace[ID]->setChecked( Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DisableDigiTrace_PSD) );
int temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnaProbe_PSD); int temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnalogProbe1);
for( int i = 0; i < cbAnaProbe1[ID]->count(); i++){ for( int i = 0; i < cbAnaProbe1[ID]->count(); i++){
if( cbAnaProbe1[ID]->itemData(i).toInt() == temp) { if( cbAnaProbe1[ID]->itemData(i).toInt() == temp) {
cbAnaProbe1[ID]->setCurrentIndex(i); cbAnaProbe1[ID]->setCurrentIndex(i);
@ -2607,8 +2624,8 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){
} }
} }
if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) UpdatePHASetting(); if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) UpdateSettings_PHA();
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) UpdatePSDSetting(); if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) UpdateSettings_PSD();
enableSignalSlot = true; enableSignalSlot = true;
} }
@ -2806,7 +2823,7 @@ void DigiSettingsPanel::SyncAllChannelsTab_PHA(){
} }
void DigiSettingsPanel::UpdatePHASetting(){ void DigiSettingsPanel::UpdateSettings_PHA(){
enableSignalSlot = false; enableSignalSlot = false;
@ -2933,7 +2950,7 @@ void DigiSettingsPanel::SyncAllChannelsTab_PSD(){
} }
} }
void DigiSettingsPanel::UpdatePSDSetting(){ void DigiSettingsPanel::UpdateSettings_PSD(){
enableSignalSlot = false; enableSignalSlot = false;
@ -3015,6 +3032,14 @@ void DigiSettingsPanel::UpdatePSDSetting(){
} }
void DigiSettingsPanel::SyncAllChannelsTab_QDC(){
}
void DigiSettingsPanel::UpdateSettings_QDC(){
}
void DigiSettingsPanel::CheckRadioAndCheckedButtons(){ void DigiSettingsPanel::CheckRadioAndCheckedButtons(){
int id1 = cbFromBoard->currentIndex(); int id1 = cbFromBoard->currentIndex();

View File

@ -42,9 +42,10 @@ private:
void CleanUpGroupBox(QGroupBox * & gBox); void CleanUpGroupBox(QGroupBox * & gBox);
void SetUpChannelMask(); void SetUpChannelMask(unsigned int digiID);
void SetUpACQReadOutTab(); void SetUpACQReadOutTab();
void SetUpGlobalTriggerMaskAndFrontPanelMask(QGridLayout * & gLayout); void SetUpGlobalTriggerMaskAndFrontPanelMask(QGridLayout * & gLayout);
void SetUpInquiryCopyTab();
void SetUpPHABoard(); void SetUpPHABoard();
void SetUpPHAChannel(); void SetUpPHAChannel();
@ -63,9 +64,11 @@ private:
void UpdateBoardAndChannelsStatus(); // ReadRegister void UpdateBoardAndChannelsStatus(); // ReadRegister
void SyncAllChannelsTab_PHA(); void SyncAllChannelsTab_PHA();
void UpdatePHASetting(); void UpdateSettings_PHA();
void SyncAllChannelsTab_PSD(); void SyncAllChannelsTab_PSD();
void UpdatePSDSetting(); void UpdateSettings_PSD();
void SyncAllChannelsTab_QDC();
void UpdateSettings_QDC();
void CheckRadioAndCheckedButtons(); void CheckRadioAndCheckedButtons();

View File

@ -30,7 +30,7 @@ class Reg{
rwType = RW::ReadWrite; rwType = RW::ReadWrite;
group = 0; group = 0;
maxBit = 0; maxBit = 0;
partialStep = 0; partialStep = 0; //for time parameter, partial step * tick2ns = full step
comboList.clear(); comboList.clear();
} }
Reg(std::string name, uint32_t address, RW type = RW::ReadWrite, bool group = false, unsigned int max = 0, int pStep = 0){ Reg(std::string name, uint32_t address, RW type = RW::ReadWrite, bool group = false, unsigned int max = 0, int pStep = 0){
@ -68,8 +68,9 @@ class Reg{
std::vector<std::pair<std::string, unsigned int>> GetComboList() const {return comboList;} std::vector<std::pair<std::string, unsigned int>> GetComboList() const {return comboList;}
uint32_t ActualAddress(int ch = -1){ uint32_t ActualAddress(int ch = -1, int subCh = 0){ //for QDC, ch is groupID
if( address == 0x8180 ) return (ch < 0 ? address : (address + 4*(ch/2))); if( address == 0x8180 ) return (ch < 0 ? address : (address + 4*(ch/2))); // DPP::TriggerValidationMask_G
if( address == 0x10D0 ) return (ch < 0 ? address + 0x7000 + (ch << 8): (address + (ch << 8) + 4*subCh)); // DPP::QDC::TriggerThreshold_G
if( address < 0x8000 ){ if( address < 0x8000 ){
if( group ) { if( group ) {
if( ch < 0 ) return address + 0x7000; if( ch < 0 ) return address + 0x7000;
@ -81,7 +82,7 @@ class Reg{
return 0; return 0;
} }
unsigned short Index (unsigned short ch); unsigned short Index (unsigned short ch, int subCh = 0);
uint32_t CalAddress(unsigned int index); /// output actual address, also write the registerAddress uint32_t CalAddress(unsigned int index); /// output actual address, also write the registerAddress
void SetName(std::string str) {this->name = str;} void SetName(std::string str) {this->name = str;}
@ -105,10 +106,12 @@ inline void Reg::Print() const{
printf(" Max Value : 0x%X = %d \n", maxBit, maxBit); printf(" Max Value : 0x%X = %d \n", maxBit, maxBit);
} }
inline unsigned short Reg::Index (unsigned short ch){ inline unsigned short Reg::Index (unsigned short ch, int subCh){ //for QDC, ch = group
unsigned short index; unsigned short index;
if( address == 0x8180){ if( address == 0x8180){ //DPP::TriggerValidationMask_G
index = ((address + 4*(ch/2)) & 0x0FFF) / 4; index = ((address + 4*(ch/2)) & 0x0FFF) / 4;
}else if( address == 0x10D0){ //DPP::QDC::TriggerThreshold_G
index = ((address + (ch << 8) + 4*subCh) & 0x0FFF) / 4;
}else if( address < 0x8000){ }else if( address < 0x8000){
index = (address + (ch << 8)) / 4; index = (address + (ch << 8)) / 4;
}else{ }else{
@ -204,14 +207,20 @@ const Reg SoftwareClear_W ("SoftwareClear_W" , 0xEF28,
namespace DPP { namespace DPP {
namespace Bit_BoardConfig{ namespace Bit_BoardConfig{
/// -------------------- shared with PHA, PSD, and QDC
const std::pair<unsigned short, unsigned short> AnalogProbe1 = {2, 12} ;
const std::pair<unsigned short, unsigned short> RecordTrace = {1, 16} ;
/// -------------------- shared with PHA and PSD
const std::pair<unsigned short, unsigned short> EnableAutoDataFlush = {1, 0} ; /// length, smallest pos const std::pair<unsigned short, unsigned short> EnableAutoDataFlush = {1, 0} ; /// length, smallest pos
const std::pair<unsigned short, unsigned short> DecimateTrace = {1, 1} ;
const std::pair<unsigned short, unsigned short> TrigPropagation = {1, 2} ; const std::pair<unsigned short, unsigned short> TrigPropagation = {1, 2} ;
const std::pair<unsigned short, unsigned short> DualTrace = {1, 11} ; const std::pair<unsigned short, unsigned short> DualTrace = {1, 11} ;
const std::pair<unsigned short, unsigned short> AnalogProbe1 = {2, 12} ;
const std::pair<unsigned short, unsigned short> AnalogProbe2 = {2, 14} ;
const std::pair<unsigned short, unsigned short> RecordTrace = {1, 16} ;
const std::pair<unsigned short, unsigned short> EnableExtra2 = {1, 17} ; const std::pair<unsigned short, unsigned short> EnableExtra2 = {1, 17} ;
/// -------------------- PHA only
const std::pair<unsigned short, unsigned short> DecimateTrace = {1, 1} ;
const std::pair<unsigned short, unsigned short> AnalogProbe2 = {2, 14} ;
const std::pair<unsigned short, unsigned short> DigiProbel1_PHA = {4, 20} ; const std::pair<unsigned short, unsigned short> DigiProbel1_PHA = {4, 20} ;
const std::pair<unsigned short, unsigned short> DigiProbel2_PHA = {3, 26} ; const std::pair<unsigned short, unsigned short> DigiProbel2_PHA = {3, 26} ;
@ -240,9 +249,7 @@ namespace DPP {
const std::vector<std::pair<std::string, unsigned int>> ListDigiProbe2_PHA = {{"Trigger", 0}}; const std::vector<std::pair<std::string, unsigned int>> ListDigiProbe2_PHA = {{"Trigger", 0}};
///-------------------------- ///------------------------ PSD only
const std::pair<unsigned short, unsigned short> AnaProbe_PSD = {3, 11} ;
const std::pair<unsigned short, unsigned short> DigiProbel1_PSD = {3, 23} ; const std::pair<unsigned short, unsigned short> DigiProbel1_PSD = {3, 23} ;
const std::pair<unsigned short, unsigned short> DigiProbel2_PSD = {3, 26} ; const std::pair<unsigned short, unsigned short> DigiProbel2_PSD = {3, 26} ;
const std::pair<unsigned short, unsigned short> DisableDigiTrace_PSD = {1, 31} ; const std::pair<unsigned short, unsigned short> DisableDigiTrace_PSD = {1, 31} ;
@ -269,6 +276,11 @@ namespace DPP {
{"Baseline Freeze", 6}, {"Baseline Freeze", 6},
{"Trigger", 7}}; {"Trigger", 7}};
/// -------------------- QDC only
const std::pair<unsigned short, unsigned short> ExtTriggerMode_QDC = {2, 20} ;
const std::vector<std::pair<std::string, unsigned int>> ListExtTriggerMode_QDC = {{"Trigger", 0},
{"Veto", 1},
{"Anti-Veto", 2}};
} }
namespace Bit_DPPAlgorithmControl_PHA { namespace Bit_DPPAlgorithmControl_PHA {
@ -676,7 +688,7 @@ namespace DPP {
const Reg ThresholdForPSDCut ("ThresholdForPSDCut" , 0x1078, RW::ReadWrite, false, 0x3FF, -1); /// R/W const Reg ThresholdForPSDCut ("ThresholdForPSDCut" , 0x1078, RW::ReadWrite, false, 0x3FF, -1); /// R/W
const Reg PurGapThreshold ("PurGapThreshold" , 0x107C, RW::ReadWrite, false, 0xFFF, -1); /// R/W const Reg PurGapThreshold ("PurGapThreshold" , 0x107C, RW::ReadWrite, false, 0xFFF, -1); /// R/W
const Reg DPPAlgorithmControl2_G ("DPPAlgorithmControl2_G" , 0x1084, RW::ReadWrite, true, {}); /// R/W const Reg DPPAlgorithmControl2_G ("DPPAlgorithmControl2_G" , 0x1084, RW::ReadWrite, true, {}); /// R/W
const Reg EarlyBaselineFreeze ("EarlyBaselineFreeze" , 0x10D8, RW::ReadWrite, true, 0x3FF, 4); /// R/W const Reg EarlyBaselineFreeze ("EarlyBaselineFreeze" , 0x10D8, RW::ReadWrite, false, 0x3FF, 4); /// R/W
namespace Bit_CFDSetting { namespace Bit_CFDSetting {
const std::pair<unsigned short, unsigned short> CFDDealy = {8, 0} ; const std::pair<unsigned short, unsigned short> CFDDealy = {8, 0} ;
@ -781,16 +793,14 @@ namespace DPP {
const Reg ChannelMask_G ("Channel Group Mask" , 0x10A8, RW::ReadWrite, true, 0xFF, 1); /// R/W const Reg ChannelMask_G ("Channel Group Mask" , 0x10A8, RW::ReadWrite, true, 0xFF, 1); /// R/W
const Reg DCOffset_LowCh_G ("DC offset for low ch." , 0x10C0, RW::ReadWrite, true, {}); /// R/W const Reg DCOffset_LowCh_G ("DC offset for low ch." , 0x10C0, RW::ReadWrite, true, {}); /// R/W
const Reg DCOffset_HighCh_G ("DC offset for high ch." , 0x10C4, RW::ReadWrite, true, {}); /// R/W const Reg DCOffset_HighCh_G ("DC offset for high ch." , 0x10C4, RW::ReadWrite, true, {}); /// R/W
const Reg TriggerThreshold_G ("Trigger Threshold" , 0x10D0, RW::ReadWrite, true, {}); /// R/W const Reg TriggerThreshold_G ("Trigger Threshold" , 0x10D0, RW::ReadWrite, true, 0xFFF, 1); /// R/W
const Reg NumberEventsPerAggregate ("Number of Events per Aggregate", 0x8020, RW::ReadWrite, false, 0x3FF, 1); /// R/W const Reg NumberEventsPerAggregate ("Number of Events per Aggregate", 0x8020, RW::ReadWrite, false, 0x3FF, 1); /// R/W
const Reg RecordLength ("Record Length" , 0x8024, RW::ReadWrite, false, 0xFFF, 1); /// R/W const Reg RecordLength ("Record Length" , 0x8024, RW::ReadWrite, false, 0xFFF, 1); /// R/W
const Reg GroupEnableMask ("Group Enable Mask" , 0x8120, RW::ReadWrite, false, 0xFF, 1); /// R/W
} }
} // end of DPP namepace Register } // end of DPP namepace Register
@ -868,15 +878,11 @@ const std::vector<Reg> RegisterQDCList = { //TODO
DPP::QDC::ChannelMask_G, DPP::QDC::ChannelMask_G,
DPP::QDC::DCOffset_LowCh_G, DPP::QDC::DCOffset_LowCh_G,
DPP::QDC::DCOffset_HighCh_G, DPP::QDC::DCOffset_HighCh_G,
DPP::QDC::TriggerThreshold_G, DPP::QDC::TriggerThreshold_G
DPP::QDC::NumberEventsPerAggregate,
DPP::QDC::RecordLength
}; };
/// Only Board Setting /// Only Board Setting
const std::vector<Reg> RegisterDPPList = { const std::vector<Reg> RegisterPHAPSDBoardList = {
DPP::BoardConfiguration , DPP::BoardConfiguration ,
DPP::AggregateOrganization , DPP::AggregateOrganization ,
@ -944,4 +950,71 @@ const std::vector<Reg> RegisterDPPList = {
}; };
const std::vector<Reg> RegisterQDCBoardList = {
DPP::BoardConfiguration ,
DPP::AggregateOrganization,
DPP::QDC::NumberEventsPerAggregate,
DPP::QDC::RecordLength ,
DPP::AcquisitionControl,
DPP::AcquisitionStatus_R,
DPP::SoftwareTrigger_W,
DPP::GlobalTriggerMask,
DPP::FrontPanelTRGOUTEnableMask,
DPP::LVDSIOData,
DPP::FrontPanelIOControl,
DPP::QDC::GroupEnableMask,
DPP::ROCFPGAFirmwareRevision_R,
DPP::VoltageLevelModeConfig,
DPP::SoftwareClockSync_W,
DPP::BoardInfo_R,
DPP::AnalogMonitorMode,
DPP::EventSize_R,
DPP::TimeBombDowncounter_R,
DPP::FanSpeedControl,
DPP::RunStartStopDelay,
DPP::BoardFailureStatus_R,
DPP::DisableExternalTrigger,
DPP::FrontPanelLVDSIONewFeatures,
DPP::BufferOccupancyGain,
DPP::ExtendedVetoDelay,
DPP::ReadoutControl,
DPP::ReadoutStatus_R,
DPP::BoardID,
DPP::MCSTBaseAddressAndControl,
DPP::RelocationAddress,
DPP::InterruptStatusID,
DPP::InterruptEventNumber,
DPP::MaxAggregatePerBlockTransfer,
DPP::Scratch ,
DPP::SoftwareReset_W ,
DPP::SoftwareClear_W ,
DPP::ConfigurationReload_W ,
DPP::ROMChecksum_R ,
DPP::ROMChecksumByte2_R ,
DPP::ROMChecksumByte1_R ,
DPP::ROMChecksumByte0_R ,
DPP::ROMConstantByte2_R ,
DPP::ROMConstantByte1_R ,
DPP::ROMConstantByte0_R ,
DPP::ROM_C_Code_R ,
DPP::ROM_R_Code_R ,
DPP::ROM_IEEE_OUI_Byte2_R ,
DPP::ROM_IEEE_OUI_Byte1_R ,
DPP::ROM_IEEE_OUI_Byte0_R ,
DPP::ROM_BoardVersion_R ,
DPP::ROM_BoardFromFactor_R ,
DPP::ROM_BoardIDByte1_R ,
DPP::ROM_BoardIDByte0_R ,
DPP::ROM_PCB_rev_Byte3_R ,
DPP::ROM_PCB_rev_Byte2_R ,
DPP::ROM_PCB_rev_Byte1_R ,
DPP::ROM_PCB_rev_Byte0_R ,
DPP::ROM_FlashType_R ,
DPP::ROM_BoardSerialNumByte1_R ,
DPP::ROM_BoardSerialNumByte0_R ,
DPP::ROM_VCXO_Type_R
};
#endif #endif

View File

@ -661,7 +661,7 @@ void Scope::SetUpPSDPanel(){
} }
connect(cbAnaProbe1, &RComboBox::currentIndexChanged, this, [=](){ connect(cbAnaProbe1, &RComboBox::currentIndexChanged, this, [=](){
if( !enableSignalSlot ) return; if( !enableSignalSlot ) return;
digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::AnaProbe_PSD, cbAnaProbe1->currentData().toInt(), cbScopeCh->currentIndex()); digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::AnalogProbe1, cbAnaProbe1->currentData().toInt(), cbScopeCh->currentIndex());
//dataTrace[0]->setName(cbAnaProbe1->currentText()); //dataTrace[0]->setName(cbAnaProbe1->currentText());
switch( cbAnaProbe1->currentIndex() ){ switch( cbAnaProbe1->currentIndex() ){
@ -875,7 +875,7 @@ void Scope::UpdatePSDPanel(){
uint32_t BdCfg = digi[ID]->GetSettingFromMemory(DPP::BoardConfiguration, ch); uint32_t BdCfg = digi[ID]->GetSettingFromMemory(DPP::BoardConfiguration, ch);
int temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnaProbe_PSD); int temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnalogProbe1);
for( int i = 0; i < cbAnaProbe1->count(); i++){ for( int i = 0; i < cbAnaProbe1->count(); i++){
if( cbAnaProbe1->itemData(i).toInt() == temp ) { if( cbAnaProbe1->itemData(i).toInt() == temp ) {
cbAnaProbe1->setCurrentIndex(i); cbAnaProbe1->setCurrentIndex(i);

View File

@ -6,7 +6,7 @@
#define MaxNDigitizer MaxNPorts * MaxNBoards #define MaxNDigitizer MaxNPorts * MaxNBoards
#define MaxNChannels 64 #define MaxNChannels 16 //for QDC, this is group.
#define MaxRecordLength 0x3fff * 8 #define MaxRecordLength 0x3fff * 8
#define MaxSaveFileSize 1024 * 1024 * 1024 * 2 #define MaxSaveFileSize 1024 * 1024 * 1024 * 2