SOLARIS_QT6_DAQ/digiSettingsPanel.cpp

646 lines
24 KiB
C++
Raw Normal View History

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>
std::vector<std::pair<std::string, int>> infoIndex = {{"Serial Num : ", 8},
{"IP : ", 20},
{"Model Name : ", 5},
{"FPGA version : ", 1},
{"DPP Type : ", 2},
{"CUP version : ", 0},
{"ADC bits : ", 15},
{"ADC rate [Msps] : ", 16},
{"Num. of Channel : ", 14},
{"Input range [Vpp] : ", 17},
{"Input Type : ", 18},
{"Input Impedance [Ohm] : ", 19}
};
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-02-23 16:08:47 -05:00
setGeometry(0, 0, 1600, 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
//@========================== 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-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
{//^====================== Group of Digitizer Info
QGroupBox * infoBox = new QGroupBox("Board Info", tab);
QGridLayout * infoLayout = new QGridLayout(infoBox);
2023-02-23 16:08:47 -05:00
tabLayout_V1->addWidget(infoBox);
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);
lab->setAlignment(Qt::AlignRight);
2023-02-23 16:08:47 -05:00
leInfo[iDigi][j] = new QLineEdit(tab);
leInfo[iDigi][j]->setReadOnly(true);
leInfo[iDigi][j]->setText(QString::fromStdString(digi[iDigi]->ReadValue(TYPE::DIG, infoIndex[j].second)));
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-25 17:16:14 -05:00
}
{//^====================== Group Board status
QGroupBox * statusBox = new QGroupBox("Board Status", tab);
2023-02-23 16:08:47 -05:00
//QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
//sizePolicy.setHorizontalStretch(0);
//sizePolicy.setVerticalStretch(0);
//statusBox->setSizePolicy(sizePolicy);
QGridLayout * statusLayout = new QGridLayout(statusBox);
statusLayout->setHorizontalSpacing(0);
2023-02-23 16:08:47 -05:00
tabLayout_V1->addWidget(statusBox);
//------- 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));
statusLayout->addWidget(LEDStatus[iDigi][i], 0, 1 + i);
}
//------- 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));
statusLayout->addWidget(ACQStatus[iDigi][i], 1, 1 + i);
}
//------- 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-23 16:08:47 -05:00
{//^====================== Board Setting Buttons
QGridLayout * bnLayout = new QGridLayout();
tabLayout_V2->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);
bnLayout->addWidget(leSettingFile[iDigi], rowId, 1, 1, 9);
//-------------------------------------
rowId ++;
QPushButton * bnReadSettngs = new QPushButton("Refresh Settings", tab);
bnLayout->addWidget(bnReadSettngs, rowId, 0, 1, 2);
connect(bnReadSettngs, &QPushButton::clicked, this, &DigiSettingsPanel::RefreshSettings);
2023-01-26 19:12:18 -05:00
QPushButton * bnResetBd = new QPushButton("Reset Board", tab);
2023-02-23 16:08:47 -05:00
bnLayout->addWidget(bnResetBd, rowId, 2, 1, 2);
connect(bnResetBd, &QPushButton::clicked, this, &DigiSettingsPanel::onReset);
2023-01-26 19:12:18 -05:00
QPushButton * bnDefaultSetting = new QPushButton("Set Default Settings", tab);
2023-02-23 16:08:47 -05:00
bnLayout->addWidget(bnDefaultSetting, rowId, 4, 1, 2);
connect(bnDefaultSetting, &QPushButton::clicked, this, &DigiSettingsPanel::onDefault);
2023-01-26 19:12:18 -05:00
QPushButton * bnSaveSettings = new QPushButton("Save Settings", tab);
2023-02-23 16:08:47 -05:00
bnLayout->addWidget(bnSaveSettings, rowId, 6, 1, 2);
connect(bnSaveSettings, &QPushButton::clicked, this, &DigiSettingsPanel::SaveSettings);
QPushButton * bnLoadSettings = new QPushButton("Load Settings", tab);
2023-02-23 16:08:47 -05:00
bnLayout->addWidget(bnLoadSettings, rowId, 8, 1, 2);
connect(bnLoadSettings, &QPushButton::clicked, this, &DigiSettingsPanel::LoadSettings);
2023-02-23 16:08:47 -05:00
}
{//^====================== Group Board settings
QGroupBox * digiBox = new QGroupBox("Board Settings", tab);
QGridLayout * boardLayout = new QGridLayout(digiBox);
tabLayout_V2->addWidget(digiBox);
int rowId = 0;
//-------------------------------------
rowId ++;
QLabel * lbClockSource = new QLabel("Clock Source :", tab);
lbClockSource->setAlignment(Qt::AlignRight);
boardLayout->addWidget(lbClockSource, rowId, 0);
2023-02-24 19:21:27 -05:00
cbbClockSource[iDigi] = new QComboBox(tab);
boardLayout->addWidget(cbbClockSource[iDigi], rowId, 1, 1, 2);
cbbClockSource[iDigi]->addItem("Internal 62.5 MHz", "Internal");
cbbClockSource[iDigi]->addItem("Front Panel Clock input", "FPClkIn");
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-02-24 19:21:27 -05:00
QStringList startSourceText = {"EncodedClkIn", "SINlevel", "SINedge", "SWcmd", "LVDS"};
for( int i = 0; i < 5; i++){
cbStartSource[iDigi][i] = new QCheckBox(startSourceText[i], tab);
boardLayout->addWidget(cbStartSource[iDigi][i], rowId, 1 + i);
}
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);
QCheckBox * cbGlbTrgSource1 = new QCheckBox("Trg-IN", tab);
boardLayout->addWidget(cbGlbTrgSource1, rowId, 1);
QCheckBox * cbGlbTrgSource2 = new QCheckBox("SwTrg", tab);
boardLayout->addWidget(cbGlbTrgSource2, rowId, 2);
QCheckBox * cbGlbTrgSource3 = new QCheckBox("LVDS", tab);
boardLayout->addWidget(cbGlbTrgSource3, rowId, 3);
QCheckBox * cbGlbTrgSource4 = new QCheckBox("GPIO", tab);
boardLayout->addWidget(cbGlbTrgSource4, rowId, 4);
QCheckBox * cbGlbTrgSource5 = new QCheckBox("TestPulse", tab);
boardLayout->addWidget(cbGlbTrgSource5, rowId, 5);
//-------------------------------------
rowId ++;
QLabel * lbTrgOutMode = new QLabel("Trg-OUT Mode :", tab);
lbTrgOutMode->setAlignment(Qt::AlignRight);
boardLayout->addWidget(lbTrgOutMode, rowId, 0);
QComboBox * comTrgOut = new QComboBox(tab);
boardLayout->addWidget(comTrgOut, rowId, 1, 1, 2);
comTrgOut->addItem("Disabled");
comTrgOut->addItem("TRG-IN");
comTrgOut->addItem("SwTrg");
comTrgOut->addItem("LVDS");
comTrgOut->addItem("Run");
comTrgOut->addItem("TestPulse");
comTrgOut->addItem("Busy");
comTrgOut->addItem("Fixed 0");
comTrgOut->addItem("Fixed 1");
comTrgOut->addItem("SyncIn signal");
comTrgOut->addItem("S-IN signal");
comTrgOut->addItem("GPIO signal");
comTrgOut->addItem("Accepted triggers");
comTrgOut->addItem("Trigger Clock signal");
//-------------------------------------
rowId ++;
QLabel * lbGPIOMode = new QLabel("GPIO Mode :", tab);
lbGPIOMode->setAlignment(Qt::AlignRight);
boardLayout->addWidget(lbGPIOMode, rowId, 0);
QComboBox * comGPIO = new QComboBox(tab);
boardLayout->addWidget(comGPIO, rowId, 1, 1, 2);
comGPIO->addItem("Disabled");
comGPIO->addItem("TRG-IN");
comGPIO->addItem("S-IN");
comGPIO->addItem("LVDS");
comGPIO->addItem("SwTrg");
comGPIO->addItem("Run");
comGPIO->addItem("TestPulse");
comGPIO->addItem("Busy");
comGPIO->addItem("Fixed 0");
comGPIO->addItem("Fixed 1");
//-------------------------------------
QLabel * lbAutoDisarmAcq = new QLabel("Auto disarm ACQ :", tab);
lbAutoDisarmAcq->setAlignment(Qt::AlignRight);
boardLayout->addWidget(lbAutoDisarmAcq, rowId, 4, 1, 2);
QComboBox * comAutoDisarmAcq = new QComboBox(tab);
boardLayout->addWidget(comAutoDisarmAcq, rowId, 6);
comAutoDisarmAcq->addItem("Enabled");
comAutoDisarmAcq->addItem("Disabled");
2023-01-25 18:27:05 -05:00
//-------------------------------------
rowId ++;
QLabel * lbBusyInSource = new QLabel("Busy In Source :", tab);
lbBusyInSource->setAlignment(Qt::AlignRight);
boardLayout->addWidget(lbBusyInSource, rowId, 0);
QComboBox * comBusyIn = new QComboBox(tab);
boardLayout->addWidget(comBusyIn, rowId, 1, 1, 2);
comBusyIn->addItem("Disabled");
comBusyIn->addItem("GPIO");
comBusyIn->addItem("LVDS");
comBusyIn->addItem("LVDS");
//-------------------------------------
QLabel * lbStatEvents = new QLabel("Stat. Event :", tab);
lbStatEvents->setAlignment(Qt::AlignRight);
boardLayout->addWidget(lbStatEvents, rowId, 4, 1, 2);
QComboBox * comAStatEvents = new QComboBox(tab);
boardLayout->addWidget(comAStatEvents, rowId, 6);
comAStatEvents->addItem("Enabled");
comAStatEvents->addItem("Disabled");
2023-01-25 18:27:05 -05:00
//-------------------------------------
rowId ++;
QLabel * lbSyncOutMode = new QLabel("Sync Out mode :", tab);
lbSyncOutMode->setAlignment(Qt::AlignRight);
boardLayout->addWidget(lbSyncOutMode, rowId, 0);
QComboBox * comSyncOut = new QComboBox(tab);
boardLayout->addWidget(comSyncOut, rowId, 1, 1, 2);
comSyncOut->addItem("Disabled");
comSyncOut->addItem("SyncIn");
comSyncOut->addItem("TestPulse");
comSyncOut->addItem("Internal 62.5 MHz Clock");
comSyncOut->addItem("Run");
2023-01-25 17:16:14 -05:00
2023-01-25 18:27:05 -05:00
//-------------------------------------
rowId ++;
QLabel * lbBoardVetoSource = new QLabel("Board Veto Source :", tab);
lbBoardVetoSource->setAlignment(Qt::AlignRight);
boardLayout->addWidget(lbBoardVetoSource, rowId, 0);
2023-01-25 17:16:14 -05:00
2023-01-25 18:27:05 -05:00
QComboBox * comBoardVetoSource = new QComboBox(tab);
boardLayout->addWidget(comBoardVetoSource, rowId, 1, 1, 2);
comBoardVetoSource->addItem("Disabled");
comBoardVetoSource->addItem("S-In");
comBoardVetoSource->addItem("LVSD");
comBoardVetoSource->addItem("GPIO");
QLabel * lbBdVetoWidth = new QLabel("Board Veto Width [ns] : ", tab);
lbBdVetoWidth->setAlignment(Qt::AlignRight);
boardLayout->addWidget(lbBdVetoWidth, rowId, 3, 1, 2);
QSpinBox * sbBdVetoWidth = new QSpinBox(tab); // may be QDoubleSpinBox
sbBdVetoWidth->setMinimum(0);
sbBdVetoWidth->setSingleStep(20);
boardLayout->addWidget(sbBdVetoWidth, rowId, 5);
QComboBox * comBdVetoPolarity = new QComboBox(tab);
boardLayout->addWidget(comBdVetoPolarity, rowId, 6);
comBdVetoPolarity->addItem("High");
comBdVetoPolarity->addItem("Low");
//-------------------------------------
rowId ++;
QLabel * lbRunDelay = new QLabel("Run Delay [ns] :", tab);
lbRunDelay->setAlignment(Qt::AlignRight);
boardLayout->addWidget(lbRunDelay, rowId, 0);
QSpinBox * sbRunDelay = new QSpinBox(tab);
sbRunDelay->setMinimum(0);
sbRunDelay->setMaximum(524280);
sbRunDelay->setSingleStep(20);
boardLayout->addWidget(sbRunDelay, rowId, 1);
//-------------------------------------
QLabel * lbClockOutDelay = new QLabel("Clock Out Delay [ps] :", tab);
lbClockOutDelay->setAlignment(Qt::AlignRight);
boardLayout->addWidget(lbClockOutDelay, rowId, 3, 1, 2);
2023-01-25 18:27:05 -05:00
QDoubleSpinBox * dsbClockOutDelay = new QDoubleSpinBox(tab);
dsbClockOutDelay->setMinimum(-1888.888);
dsbClockOutDelay->setMaximum(1888.888);
dsbClockOutDelay->setValue(0);
boardLayout->addWidget(dsbClockOutDelay, rowId, 5);
2023-01-25 18:27:05 -05:00
//-------------------------------------
rowId ++;
QLabel * lbIOLevel = new QLabel("IO Level :", tab);
lbIOLevel->setAlignment(Qt::AlignRight);
boardLayout->addWidget(lbIOLevel, rowId, 0);
QComboBox * comIOLevel = new QComboBox(tab);
boardLayout->addWidget(comIOLevel, rowId, 1, 1, 2);
comIOLevel->addItem("NIM (0 = 0V, 1 = -0.8V)");
comIOLevel->addItem("TTL (0 = 0V, 1 = 3.3V)");
//-------------------------------------- Test pulse
}
2023-01-25 17:16:14 -05:00
2023-01-30 18:40:24 -05:00
{//^====================== Group channel settings
2023-02-23 16:08:47 -05:00
QGroupBox * chBox = new QGroupBox("Channel Settings", tab);
tabLayout_V2->addWidget(chBox);
2023-01-30 18:40:24 -05:00
QGridLayout * chLayout = new QGridLayout(chBox); //chBox->setLayout(chLayout);
QSignalMapper * onOffMapper = new QSignalMapper(tab);
2023-02-23 16:08:47 -05:00
connect(onOffMapper, &QSignalMapper::mappedInt, this, &DigiSettingsPanel::onChannelonOff);
2023-01-31 18:59:12 -05:00
2023-01-30 18:40:24 -05:00
QTabWidget * chTabWidget = new QTabWidget(tab); chLayout->addWidget(chTabWidget);
{//.......... All Settings tab
QWidget * tab_All = new QWidget(tab);
chTabWidget->addTab(tab_All, "All Settings");
tab_All->setStyleSheet("background-color: #EEEEEE");
QGridLayout * allLayout = new QGridLayout(tab_All);
allLayout->setHorizontalSpacing(0);
allLayout->setVerticalSpacing(0);
2023-02-02 19:01:10 -05:00
unsigned short ch = digi[iDigi]->GetNChannels();
2023-01-30 18:40:24 -05:00
cbCh[iDigi][ch] = new QCheckBox("On/Off", tab); allLayout->addWidget(cbCh[iDigi][ch], 0, 0);
onOffMapper->setMapping(cbCh[iDigi][ch], (iDigi << 12) + ch);
connect(cbCh[iDigi][ch], SIGNAL(clicked()), onOffMapper, SLOT(map()));
2023-01-30 18:40:24 -05:00
QLabel * lbRL = new QLabel("Record Length [ns]", tab); allLayout->addWidget(lbRL, 1, 0);
lbRL->setAlignment(Qt::AlignRight);
sbRecordLength[ch] = new QSpinBox(tab); allLayout->addWidget(sbRecordLength[ch], 1, 1);
QLabel * lbPT = new QLabel("Pre Trigger [ns]", tab); allLayout->addWidget(lbPT, 1, 2);
lbPT->setAlignment(Qt::AlignRight);
sbPreTrigger[ch] = new QSpinBox(tab); allLayout->addWidget(sbPreTrigger[ch], 1, 3);
}
2023-01-25 17:16:14 -05:00
2023-01-30 18:40:24 -05:00
{//.......... Ch On/Off
QWidget * tab_onOff = new QWidget(tab); chTabWidget->addTab(tab_onOff, "On/Off");
tab_onOff->setStyleSheet("background-color: #EEEEEE");
QGridLayout * allLayout = new QGridLayout(tab_onOff);
allLayout->setHorizontalSpacing(0);
allLayout->setVerticalSpacing(0);
2023-02-02 19:01:10 -05:00
for( int ch = 0; ch < digi[iDigi]->GetNChannels(); ch++){
2023-01-30 18:40:24 -05:00
cbCh[iDigi][ch] = new QCheckBox(QString::number(ch)); allLayout->addWidget(cbCh[iDigi][ch], ch/8, ch%8);
cbCh[iDigi][ch]->setLayoutDirection(Qt::RightToLeft);
onOffMapper->setMapping(cbCh[iDigi][ch], (iDigi << 12) + ch);
connect(cbCh[iDigi][ch], SIGNAL(clicked()), onOffMapper, SLOT(map()));
}
}
}
{//^====================== Group trigger settings
QGroupBox * triggerBox = new QGroupBox("Trigger Map", tab);
QGridLayout * triggerLayout = new QGridLayout(triggerBox);
2023-01-30 18:40:24 -05:00
//triggerBox->setLayout(triggerLayout);
2023-02-23 16:08:47 -05:00
tabLayout_V1->addWidget(triggerBox);
2023-01-26 19:12:18 -05:00
triggerLayout->setHorizontalSpacing(0);
triggerLayout->setVerticalSpacing(0);
QLabel * instr = new QLabel("Reading: Column (C) represents a trigger channel for Row (R) channel.\nFor example, R3C1 = ch-3 trigger source is ch-1.\n", tab);
triggerLayout->addWidget(instr, 0, 0, 1, 64+15);
QSignalMapper * triggerMapper = new QSignalMapper(tab);
2023-02-23 16:08:47 -05:00
connect(triggerMapper, &QSignalMapper::mappedInt, this, &DigiSettingsPanel::onTriggerClick);
2023-01-26 19:12:18 -05:00
int rowID = 1;
int colID = 0;
2023-02-02 19:01:10 -05:00
for(int i = 0; i < digi[iDigi]->GetNChannels(); i++){
2023-01-26 19:12:18 -05:00
colID = 0;
2023-02-02 19:01:10 -05:00
for(int j = 0; j < digi[iDigi]->GetNChannels(); j++){
2023-01-26 19:12:18 -05:00
bn[i][j] = new QPushButton(tab);
bn[i][j]->setFixedSize(QSize(10,10));
bnClickStatus[i][j] = false;
if( i%4 != 0 && j == (i/4)*4) {
bn[i][j]->setStyleSheet("background-color: red;");
bnClickStatus[i][j] = true;
}
triggerLayout->addWidget(bn[i][j], rowID, colID);
2023-01-26 19:12:18 -05:00
2023-01-30 18:40:24 -05:00
triggerMapper->setMapping(bn[i][j], (iDigi << 12) + (i << 8) + j);
2023-01-26 19:12:18 -05:00
connect(bn[i][j], SIGNAL(clicked()), triggerMapper, SLOT(map()));
2023-01-25 17:16:14 -05:00
2023-01-26 19:12:18 -05:00
colID ++;
2023-02-02 19:01:10 -05:00
if( j%4 == 3 && j!= digi[iDigi]->GetNChannels() - 1){
2023-01-26 19:12:18 -05:00
QFrame * vSeparator = new QFrame(tab);
vSeparator->setFrameShape(QFrame::VLine);
triggerLayout->addWidget(vSeparator, rowID, colID);
colID++;
}
}
rowID++;
2023-02-02 19:01:10 -05:00
if( i%4 == 3 && i != digi[iDigi]->GetNChannels() - 1){
2023-01-26 19:12:18 -05:00
QFrame * hSeparator = new QFrame(tab);
hSeparator->setFrameShape(QFrame::HLine);
2023-02-02 19:01:10 -05:00
triggerLayout->addWidget(hSeparator, rowID, 0, 1, digi[iDigi]->GetNChannels() + 15);
2023-01-26 19:12:18 -05:00
rowID++;
}
}
}
} //=== end of tab
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
printf("%s\n", __func__);
2023-01-30 18:40:24 -05:00
for( int iDig = 0; iDig < nDigi; iDig ++){
for( int i =0 ; i < MaxNumberOfChannel; i++){
if( cbCh[iDig][i] != NULL) delete cbCh[iDig][i];
}
}
2023-02-23 16:08:47 -05:00
}
//^================================================================
void DigiSettingsPanel::onTriggerClick(int haha){
unsigned short iDig = haha >> 12;
unsigned short ch = (haha >> 8 ) & 0xF;
unsigned short ch2 = haha & 0xFF;
qDebug() << "Digi-" << iDig << ", Ch-" << ch << ", " << ch2;
if(bnClickStatus[ch][ch2]){
bn[ch][ch2]->setStyleSheet("");
bnClickStatus[ch][ch2] = false;
}else{
bn[ch][ch2]->setStyleSheet("background-color: red;");
bnClickStatus[ch][ch2] = true;
}
}
void DigiSettingsPanel::onChannelonOff(int haha){
unsigned short iDig = haha >> 12;
//qDebug()<< "nDigi-" << iDig << ", ch-" << (haha & 0xFF);
if( (haha & 0xFF) == 64){
if( cbCh[iDig][64]->isChecked() ){
for( int i = 0 ; i < digi[iDig]->GetNChannels() ; i++){
cbCh[iDig][i]->setChecked(true);
}
}else{
for( int i = 0 ; i < digi[iDig]->GetNChannels() ; i++){
cbCh[iDig][i]->setChecked(false);
}
}
}else{
unsigned int nOn = 0;
for( int i = 0; i < digi[iDig]->GetNChannels(); i++){
nOn += (cbCh[iDig][i]->isChecked() ? 1 : 0);
}
if( nOn == 64){
cbCh[iDig][64]->setChecked(true);
}else{
cbCh[iDig][64]->setChecked(false);
}
}
}
//^================================================================
void DigiSettingsPanel::onReset(){
emit sendLogMsg("Reset Digitizer-" + QString::number(digi[ID]->GetSerialNumber()));
digi[ID]->Reset();
}
void DigiSettingsPanel::onDefault(){
emit sendLogMsg("Program Digitizer-" + QString::number(digi[ID]->GetSerialNumber()) + " to default PHA.");
digi[ID]->ProgramPHA();
}
void DigiSettingsPanel::RefreshSettings(){
digi[ID]->ReadAllSettings();
ShowSettingsToPanel();
}
void DigiSettingsPanel::SaveSettings(){
}
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()) ){
emit sendLogMsg("Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber()));
}else{
emit sendLogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber()));
}
//TODO ==== show result
ShowSettingsToPanel();
}
void DigiSettingsPanel::ShowSettingsToPanel(){
2023-02-24 19:21:27 -05:00
enableSignalSlot = false;
2023-02-23 16:08:47 -05:00
for (unsigned short j = 0; j < (unsigned short) infoIndex.size(); j++){
leInfo[ID][j]->setText(QString::fromStdString(digi[ID]->GetSettingValue(TYPE::DIG, infoIndex[j].second)));
}
//--------- LED Status
2023-02-24 19:21:27 -05:00
unsigned int ledStatus = atoi(digi[ID]->GetSettingValue(TYPE::DIG, DIGIPARA::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-02-24 19:21:27 -05:00
unsigned int acqStatus = atoi(digi[ID]->GetSettingValue(TYPE::DIG, DIGIPARA::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++){
leTemp[ID][i]->setText(QString::fromStdString(digi[ID]->GetSettingValue(TYPE::DIG, DIGIPARA::DIG::TempSensADC[i])));
}
//-------- board settings
ReadCombBoxValue(cbbClockSource[ID], TYPE::DIG, DIGIPARA::DIG::ClockSource);
QString result = QString::fromStdString(digi[ID]->GetSettingValue(TYPE::DIG, DIGIPARA::DIG::StartSource));
QStringList resultList = result.remove(QChar(' ')).split("|");
qDebug() << resultList;
//for( int j = 0; j < 5; j++){
// cbStartSource[ID][j]->setChecked(false);
// for( int i = 0; resultList.count(); i++){
// if( resultList[i] == cbStartSource[ID][j]->text()) cbStartSource[ID][j]->setChecked(true);
// }
//}
2023-02-23 16:08:47 -05:00
2023-02-24 19:21:27 -05:00
enableSignalSlot = true;
2023-02-23 16:08:47 -05:00
}
2023-02-24 19:21:27 -05:00
void DigiSettingsPanel::ReadCombBoxValue(QComboBox *cb, TYPE type, Reg para){
QString result = QString::fromStdString(digi[ID]->GetSettingValue(type, para));
int index = cb->findData(result);
if( index >= 0 && index < cb->count()) {
cb->setCurrentIndex(index);
}else{
qDebug() << result;
}
}