simplify the update other panels machanism

This commit is contained in:
Ryan Tang 2023-03-24 17:23:59 -04:00
parent 7b237fabcb
commit b914e05097
10 changed files with 250 additions and 128 deletions

View File

@ -85,7 +85,7 @@
}, },
{ {
"tag": "?", "tag": "?",
"color": "#0076FF", "color": "#DBFF33",
"strikethrough": false, "strikethrough": false,
"backgroundColor": "transparent", "backgroundColor": "transparent",
"bold": false, "bold": false,

View File

@ -28,6 +28,16 @@ class RSpinBox : public QDoubleSpinBox{
setFocusPolicy(Qt::StrongFocus); setFocusPolicy(Qt::StrongFocus);
setDecimals(decimal); setDecimals(decimal);
} }
void SetToolTip(double min = -1){
if( min == -1 ){
setToolTip("(" + QString::number(minimum()) + " - " + QString::number(maximum()) + ", " + QString::number(singleStep()) + ")");
}else{
setToolTip("(" + QString::number(min) + " - " + QString::number(maximum()) + ", " + QString::number(singleStep()) + ")");
}
setToolTipDuration(-1);
}
signals: signals:
void returnPressed(); void returnPressed();
protected: protected:

View File

@ -20,8 +20,6 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
setWindowTitle("SOLARIS Settings"); setWindowTitle("SOLARIS Settings");
setGeometry(0, 0, 1350, 800); setGeometry(0, 0, 1350, 800);
printf("%s\n", __func__);
this->digi = digi; this->digi = digi;
this->nDigi = nDigi; this->nDigi = nDigi;
this->mapping = mapping; this->mapping = mapping;
@ -105,13 +103,48 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
connect(bnLoadSetting, &QPushButton::clicked, this, &SOLARISpanel::LoadSettings); connect(bnLoadSetting, &QPushButton::clicked, this, &SOLARISpanel::LoadSettings);
mainLayout->addWidget(bnLoadSetting, rowIndex, 2); mainLayout->addWidget(bnLoadSetting, rowIndex, 2);
QLabel * lbCoinTime = new QLabel("Coin. Time [ns]", this); QLabel * lbCoinTime = new QLabel("Coin. Time (all ch.) [ns]", this);
lbCoinTime->setAlignment(Qt::AlignRight | Qt::AlignCenter); lbCoinTime->setAlignment(Qt::AlignRight | Qt::AlignCenter);
mainLayout->addWidget(lbCoinTime, rowIndex, 3); mainLayout->addWidget(lbCoinTime, rowIndex, 3);
RSpinBox * sbCoinTime = new RSpinBox(this); sbCoinTime = new RSpinBox(this);
sbCoinTime->setMinimum(-1);
sbCoinTime->setMaximum(atof(PHA::CH::CoincidenceLength.GetAnswers()[1].first.c_str()));
sbCoinTime->setSingleStep(atof(PHA::CH::CoincidenceLength.GetAnswers()[2].first.c_str()));
sbCoinTime->setDecimals(0);
sbCoinTime->SetToolTip(atof(PHA::CH::CoincidenceLength.GetAnswers()[1].first.c_str()));
mainLayout->addWidget(sbCoinTime, rowIndex, 4); mainLayout->addWidget(sbCoinTime, rowIndex, 4);
connect(sbCoinTime, &RSpinBox::valueChanged, this, [=](){
if( !enableSignalSlot ) return;
sbCoinTime->setStyleSheet("color:blue;");
});
connect(sbCoinTime, &RSpinBox::returnPressed, this, [=](){
if( !enableSignalSlot ) return;
//printf("%s %d %d \n", para.GetPara().c_str(), index, spb->value());
if( sbCoinTime->decimals() == 0 && sbCoinTime->singleStep() != 1) {
double step = sbCoinTime->singleStep();
double value = sbCoinTime->value();
sbCoinTime->setValue( (std::round(value/step) * step) );
}
for(int i = 0; i < (int) mapping.size(); i ++){
if( i >= nDigi || digi[i]->IsDummy() || !digi[i]->IsConnected() ) return;
QString msg;
msg = QString::fromStdString(PHA::CH::CoincidenceLength.GetPara()) + "|DIG:"+ QString::number(digi[i]->GetSerialNumber());
msg += ",CH:All = " + QString::number(sbCoinTime->value());
if( digi[i]->WriteValue(PHA::CH::CoincidenceLength, std::to_string(sbCoinTime->value()))){
SendLogMsg(msg + "|OK.");
sbCoinTime->setStyleSheet("");
}else{
SendLogMsg(msg + "|Fail.");
sbCoinTime->setStyleSheet("color:red;");
}
}
UpdatePanelFromMemory();
});
///================================= ///=================================
rowIndex ++; rowIndex ++;
QLabel * info = new QLabel("Only simple trigger is avalible. For complex trigger scheme, please use the setting panel.", this); QLabel * info = new QLabel("Only simple trigger is avalible. For complex trigger scheme, please use the setting panel.", this);
@ -230,6 +263,7 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout *
sbSetting[SettingID][digiID][chID]->setMinimum(atoi(SettingItems[SettingID].GetAnswers()[0].first.c_str())); sbSetting[SettingID][digiID][chID]->setMinimum(atoi(SettingItems[SettingID].GetAnswers()[0].first.c_str()));
sbSetting[SettingID][digiID][chID]->setMaximum(atoi(SettingItems[SettingID].GetAnswers()[1].first.c_str())); sbSetting[SettingID][digiID][chID]->setMaximum(atoi(SettingItems[SettingID].GetAnswers()[1].first.c_str()));
sbSetting[SettingID][digiID][chID]->setSingleStep(atoi(SettingItems[SettingID].GetAnswers()[2].first.c_str())); sbSetting[SettingID][digiID][chID]->setSingleStep(atoi(SettingItems[SettingID].GetAnswers()[2].first.c_str()));
sbSetting[SettingID][digiID][chID]->SetToolTip();
layout0->addWidget(sbSetting[SettingID][digiID][chID], 2*i+1, 2); layout0->addWidget(sbSetting[SettingID][digiID][chID], 2*i+1, 2);
@ -268,7 +302,8 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout *
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
spb->setStyleSheet("color:red;"); spb->setStyleSheet("color:red;");
} }
emit UpdateOtherPanels(); UpdatePanelFromMemory();
UpdateOtherPanels();
}); });
///===================== for the OnOff CheckBox ///===================== for the OnOff CheckBox
@ -285,7 +320,8 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout *
} }
enableSignalSlot = true; enableSignalSlot = true;
emit UpdateOtherPanels(); UpdatePanelFromMemory();
UpdateOtherPanels();
}); });
@ -367,10 +403,11 @@ void SOLARISpanel::CreateDetGroup(int SettingID, QList<int> detID, QGridLayout *
} }
} }
UpdateOtherPanels();
}); });
UpdatePanelFromMemory();
UpdateOtherPanels();
} }
layout->addWidget(groupbox, row, col); layout->addWidget(groupbox, row, col);
} }
@ -382,14 +419,18 @@ void SOLARISpanel::RefreshSettings(){
digi[i]->ReadAllSettings(); digi[i]->ReadAllSettings();
} }
} }
UpdatePanel(); UpdatePanelFromMemory();
} }
void SOLARISpanel::UpdatePanel(){ void SOLARISpanel::UpdatePanelFromMemory(){
if( !isVisible() ) return;
enableSignalSlot = false; enableSignalSlot = false;
printf("%s\n", __func__); printf("SOLARISpanel::%s\n", __func__);
//@===================== LineEdit and SpinBox
for( int SettingID = 0; SettingID < (int) SettingItems.size() ; SettingID ++){ for( int SettingID = 0; SettingID < (int) SettingItems.size() ; SettingID ++){
for( int DigiID = 0; DigiID < (int) mapping.size(); DigiID ++){ for( int DigiID = 0; DigiID < (int) mapping.size(); DigiID ++){
if( DigiID >= nDigi ) continue;; if( DigiID >= nDigi ) continue;;
@ -410,14 +451,17 @@ void SOLARISpanel::UpdatePanel(){
haha = digi[DigiID]->GetSettingValue(PHA::CH::ChannelEnable, chID); haha = digi[DigiID]->GetSettingValue(PHA::CH::ChannelEnable, chID);
chkOnOff[SettingID][DigiID][chID]->setChecked( haha == "True" ? true : false); chkOnOff[SettingID][DigiID][chID]->setChecked( haha == "True" ? true : false);
leDisplay[SettingID][DigiID][chID]->setEnabled(haha == "True" ? true : false);
sbSetting[SettingID][DigiID][chID]->setEnabled(haha == "True" ? true : false);
///printf("====== %d %d %d |%s|\n", SettingID, DigiID, chID, haha.c_str()); ///printf("====== %d %d %d |%s|\n", SettingID, DigiID, chID, haha.c_str());
} }
} }
} }
//@===================== Trigger
for( int k = 0; k < detIDList.size() ; k++){ for( int k = 0; k < detIDList.size() ; k++){
if( detIDList[k][0] >= detMaxID[0] || 0 > detIDList[k][0]) continue; if( detIDList[k][0] >= detMaxID[0] || 0 > detIDList[k][0]) continue; //! only for array
//if( detIDList[k].size() <= 2) continue; //if( detIDList[k].size() <= 2) continue;
std::vector<unsigned long> triggerMap; std::vector<unsigned long> triggerMap;
@ -502,7 +546,35 @@ void SOLARISpanel::UpdatePanel(){
if( !isAcceptableSetting ) cbTrigger[detTypeID][detIDList[k][0]]->setCurrentText("Others"); if( !isAcceptableSetting ) cbTrigger[detTypeID][detIDList[k][0]]->setCurrentText("Others");
} }
//@===================== Coin. time
std::vector<int> coinTime;
for( int i = 0; i < detIDList.size(); i++){
for( int j = 1; j < detIDList[i].size(); j++){
int digiID = detIDList[i][j] >> 8;
int chID = (detIDList[i][j] & 0xFF);
if( digiID >= nDigi ) continue;
if( digi[digiID]->IsDummy() || !digi[digiID]->IsConnected() ) continue;
coinTime.push_back( atoi(digi[digiID]->GetSettingValue(PHA::CH::CoincidenceLength, chID).c_str()));
}
}
bool isSameCoinTime = true;
for( int i = 1; i < (int) coinTime.size(); i++){
if( coinTime[i] != coinTime[0]) {
isSameCoinTime = false;
break;
}
}
if( isSameCoinTime ){
sbCoinTime->setValue(coinTime[0]);
}else{
sbCoinTime->setValue(-1);
}
enableSignalSlot = true; enableSignalSlot = true;
} }
void SOLARISpanel::UpdateThreshold(){ void SOLARISpanel::UpdateThreshold(){

View File

@ -22,9 +22,9 @@
#include "CustomWidgets.h" #include "CustomWidgets.h"
#include "macro.h" #include "macro.h"
#define MaxSettingItem 3
#define MaxDetType 10 #define MaxDetType 10
#define MaxDetID 60 #define MaxDetID 60
#define MaxSettingItem 3
class SOLARISpanel : public QWidget{ class SOLARISpanel : public QWidget{
Q_OBJECT Q_OBJECT
@ -45,8 +45,8 @@ private slots:
void LoadSettings(); void LoadSettings();
public slots: public slots:
void UpdatePanel();
void UpdateThreshold(); void UpdateThreshold();
void UpdatePanelFromMemory();
signals: signals:
@ -66,6 +66,8 @@ private:
int FindDetTypID(QList<int> detIDListElement); int FindDetTypID(QList<int> detIDListElement);
RSpinBox * sbCoinTime;
QCheckBox * chkAll; // checkBox for all setting on that tab; QCheckBox * chkAll; // checkBox for all setting on that tab;
QCheckBox * chkAlle; QCheckBox * chkAlle;
QCheckBox * chkAllxf; QCheckBox * chkAllxf;

View File

@ -348,6 +348,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
dsbBdVetoWidth[iDigi]->setMinimum(0); dsbBdVetoWidth[iDigi]->setMinimum(0);
dsbBdVetoWidth[iDigi]->setMaximum(34359738360); dsbBdVetoWidth[iDigi]->setMaximum(34359738360);
dsbBdVetoWidth[iDigi]->setSingleStep(20); dsbBdVetoWidth[iDigi]->setSingleStep(20);
dsbBdVetoWidth[iDigi]->SetToolTip();
boardLayout->addWidget(dsbBdVetoWidth[iDigi], rowId, 5); boardLayout->addWidget(dsbBdVetoWidth[iDigi], rowId, 5);
connect(dsbBdVetoWidth[iDigi], &RSpinBox::valueChanged, this, [=](){ connect(dsbBdVetoWidth[iDigi], &RSpinBox::valueChanged, this, [=](){
if( !enableSignalSlot ) return; if( !enableSignalSlot ) return;
@ -386,6 +387,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
dsbVolatileClockOutDelay[iDigi]->setMaximum(18888.888); dsbVolatileClockOutDelay[iDigi]->setMaximum(18888.888);
dsbVolatileClockOutDelay[iDigi]->setSingleStep(74.074); dsbVolatileClockOutDelay[iDigi]->setSingleStep(74.074);
dsbVolatileClockOutDelay[iDigi]->setValue(0); dsbVolatileClockOutDelay[iDigi]->setValue(0);
dsbVolatileClockOutDelay[iDigi]->SetToolTip();
boardLayout->addWidget(dsbVolatileClockOutDelay[iDigi], rowId, 5); boardLayout->addWidget(dsbVolatileClockOutDelay[iDigi], rowId, 5);
connect(dsbVolatileClockOutDelay[iDigi], &RSpinBox::valueChanged, this, [=](){ connect(dsbVolatileClockOutDelay[iDigi], &RSpinBox::valueChanged, this, [=](){
if( !enableSignalSlot ) return; if( !enableSignalSlot ) return;
@ -422,6 +424,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
dsbClockOutDelay[iDigi]->setMaximum(18888.888); dsbClockOutDelay[iDigi]->setMaximum(18888.888);
dsbClockOutDelay[iDigi]->setValue(0); dsbClockOutDelay[iDigi]->setValue(0);
dsbClockOutDelay[iDigi]->setSingleStep(74.074); dsbClockOutDelay[iDigi]->setSingleStep(74.074);
dsbClockOutDelay[iDigi]->SetToolTip();
boardLayout->addWidget(dsbClockOutDelay[iDigi], rowId, 5); boardLayout->addWidget(dsbClockOutDelay[iDigi], rowId, 5);
connect(dsbClockOutDelay[iDigi], &RSpinBox::valueChanged, this, [=](){ connect(dsbClockOutDelay[iDigi], &RSpinBox::valueChanged, this, [=](){
if( !enableSignalSlot ) return; if( !enableSignalSlot ) return;
@ -482,6 +485,8 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
VGA[iDigi][k]->setMinimum(0); VGA[iDigi][k]->setMinimum(0);
VGA[iDigi][k]->setMaximum(40); VGA[iDigi][k]->setMaximum(40);
VGA[iDigi][k]->setSingleStep(0.5); VGA[iDigi][k]->setSingleStep(0.5);
VGA[iDigi][k]->SetToolTip();
vgaLayout->addWidget(VGA[iDigi][k], 0, 2*k+1); vgaLayout->addWidget(VGA[iDigi][k], 0, 2*k+1);
connect(VGA[iDigi][k], &RSpinBox::valueChanged, this, [=](){ connect(VGA[iDigi][k], &RSpinBox::valueChanged, this, [=](){
if( !enableSignalSlot ) return; if( !enableSignalSlot ) return;
@ -543,7 +548,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
connect(cbChPick[iDigi], &RComboBox::currentIndexChanged, this, [=](){ connect(cbChPick[iDigi], &RComboBox::currentIndexChanged, this, [=](){
int index = cbChPick[ID]->currentData().toInt(); int index = cbChPick[ID]->currentData().toInt();
if(index == -1) { if(index == -1) {
ShowSettingsToPanel(); UpdatePanelFromMemory();
return; return;
}else{ }else{
enableSignalSlot = false; enableSignalSlot = false;
@ -593,7 +598,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
FillSpinBoxValueFromMemory(spbADCVetoWidth[ID][ch], PHA::CH::ADCVetoWidth, index); FillSpinBoxValueFromMemory(spbADCVetoWidth[ID][ch], PHA::CH::ADCVetoWidth, index);
unsigned long mask = Utility::TenBase(digi[ID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, cbChPick[ID]->currentData().toInt())); unsigned long mask = Utility::TenBase(digi[ID]->GetSettingValue(PHA::CH::ChannelsTriggerMask, cbChPick[ID]->currentData().toInt()));
leTriggerMask[ID][ch]->setText("0x" + QString::number(mask, 16)); leTriggerMask[ID][ch]->setText("0x" + QString::number(mask, 16).toUpper());
enableSignalSlot = true; enableSignalSlot = true;
} }
@ -620,16 +625,16 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
SetupComboBox(cbbLowFilter[iDigi][ch], PHA::CH::EnergyFilterLowFreqFilter, -1, true, "Low Freq. Filter", layout1, rowID, 2); SetupComboBox(cbbLowFilter[iDigi][ch], PHA::CH::EnergyFilterLowFreqFilter, -1, true, "Low Freq. Filter", layout1, rowID, 2);
rowID ++; rowID ++;
SetupSpinBox(spbDCOffset[iDigi][ch], PHA::CH::DC_Offset, -1, false, "DC Offset [%]", layout1, rowID, 0); SetupSpinBox(spbDCOffset[iDigi][ch], PHA::CH::DC_Offset, -1, true, "DC Offset [%]", layout1, rowID, 0);
SetupSpinBox(spbThreshold[iDigi][ch], PHA::CH::TriggerThreshold, -1, false, "Threshold [LSB]", layout1, rowID, 2); SetupSpinBox(spbThreshold[iDigi][ch], PHA::CH::TriggerThreshold, -1, true, "Threshold [LSB]", layout1, rowID, 2);
rowID ++; rowID ++;
SetupSpinBox(spbInputRiseTime[iDigi][ch], PHA::CH::TimeFilterRiseTime, -1, false, "Input Rise Time [ns]", layout1, rowID, 0); SetupSpinBox(spbInputRiseTime[iDigi][ch], PHA::CH::TimeFilterRiseTime, -1, true, "Input Rise Time [ns]", layout1, rowID, 0);
SetupSpinBox(spbTriggerGuard[iDigi][ch], PHA::CH::TimeFilterRetriggerGuard, -1, false, "Trigger Guard [ns]", layout1, rowID, 2); SetupSpinBox(spbTriggerGuard[iDigi][ch], PHA::CH::TimeFilterRetriggerGuard, -1, true, "Trigger Guard [ns]", layout1, rowID, 2);
rowID ++; rowID ++;
SetupSpinBox(spbRecordLength[iDigi][ch], PHA::CH::RecordLength, -1, false, "Record Length [ns]", layout1, rowID, 0); SetupSpinBox(spbRecordLength[iDigi][ch], PHA::CH::RecordLength, -1, true, "Record Length [ns]", layout1, rowID, 0);
SetupSpinBox(spbPreTrigger[iDigi][ch], PHA::CH::PreTrigger, -1, false, "Pre Trigger [ns]", layout1, rowID, 2); SetupSpinBox(spbPreTrigger[iDigi][ch], PHA::CH::PreTrigger, -1, true, "Pre Trigger [ns]", layout1, rowID, 2);
} }
@ -640,21 +645,21 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
//------------------------------ //------------------------------
rowID = 0; rowID = 0;
SetupSpinBox(spbTrapRiseTime[iDigi][ch], PHA::CH::EnergyFilterRiseTime, -1, false, "Trap. Rise Time [ns]", layout3, rowID, 0); SetupSpinBox(spbTrapRiseTime[iDigi][ch], PHA::CH::EnergyFilterRiseTime, -1, true, "Trap. Rise Time [ns]", layout3, rowID, 0);
SetupSpinBox(spbTrapFlatTop[iDigi][ch], PHA::CH::EnergyFilterFlatTop, -1, false, "Trap. Flat Top [ns]", layout3, rowID, 2); SetupSpinBox(spbTrapFlatTop[iDigi][ch], PHA::CH::EnergyFilterFlatTop, -1, true, "Trap. Flat Top [ns]", layout3, rowID, 2);
SetupSpinBox(spbTrapPoleZero[iDigi][ch], PHA::CH::EnergyFilterPoleZero, -1, false, "Trap. Pole Zero [ns]", layout3, rowID, 4); SetupSpinBox(spbTrapPoleZero[iDigi][ch], PHA::CH::EnergyFilterPoleZero, -1, true, "Trap. Pole Zero [ns]", layout3, rowID, 4);
//------------------------------ //------------------------------
rowID ++; rowID ++;
SetupSpinBox(spbPeaking[iDigi][ch], PHA::CH::EnergyFilterPeakingPosition, -1, false, "Peaking [%]", layout3, rowID, 0); SetupSpinBox(spbPeaking[iDigi][ch], PHA::CH::EnergyFilterPeakingPosition, -1, true, "Peaking [%]", layout3, rowID, 0);
SetupSpinBox(spbBaselineGuard[iDigi][ch], PHA::CH::EnergyFilterBaselineGuard, -1, false, "Baseline Guard [ns]", layout3, rowID, 2); SetupSpinBox(spbBaselineGuard[iDigi][ch], PHA::CH::EnergyFilterBaselineGuard, -1, true, "Baseline Guard [ns]", layout3, rowID, 2);
SetupSpinBox(spbPileupGuard[iDigi][ch], PHA::CH::EnergyFilterPileUpGuard, -1, false, "Pile-up Guard [ns]", layout3, rowID, 4); SetupSpinBox(spbPileupGuard[iDigi][ch], PHA::CH::EnergyFilterPileUpGuard, -1, true, "Pile-up Guard [ns]", layout3, rowID, 4);
//------------------------------ //------------------------------
rowID ++; rowID ++;
SetupComboBox(cbbPeakingAvg[iDigi][ch], PHA::CH::EnergyFilterPeakingAvg, -1, true, "Peak Avg", layout3, rowID, 0); 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); 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); SetupSpinBox(spbFineGain[iDigi][ch], PHA::CH::EnergyFilterFineGain, -1, true, "Fine Gain", layout3, rowID, 4);
} }
@ -694,10 +699,11 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
rowID ++; rowID ++;
SetupComboBox(cbbChVetoSrc[iDigi][ch], PHA::CH::ChannelVetoSource, -1, true, "Veto Source", layout5, rowID, 0); SetupComboBox(cbbChVetoSrc[iDigi][ch], PHA::CH::ChannelVetoSource, -1, true, "Veto Source", layout5, rowID, 0);
QLabel * lbTrgMsk = new QLabel("Trigger Mask :"); QLabel * lbTrgMsk = new QLabel("Trigger Mask");
lbTrgMsk->setAlignment(Qt::AlignRight | Qt::AlignCenter); lbTrgMsk->setAlignment(Qt::AlignRight | Qt::AlignCenter);
layout5->addWidget(lbTrgMsk, rowID, 2); layout5->addWidget(lbTrgMsk, rowID, 2);
leTriggerMask[iDigi][ch] = new QLineEdit(this); leTriggerMask[iDigi][ch] = new QLineEdit(this);
leTriggerMask[iDigi][ch]->setToolTip("Both Hex or Dec is OK.");
layout5->addWidget(leTriggerMask[iDigi][ch], rowID, 3); layout5->addWidget(leTriggerMask[iDigi][ch], rowID, 3);
connect(leTriggerMask[iDigi][ch], &QLineEdit::textChanged, this, [=](){ connect(leTriggerMask[iDigi][ch], &QLineEdit::textChanged, this, [=](){
@ -709,7 +715,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
if( !enableSignalSlot ) return; if( !enableSignalSlot ) return;
int index = cbChPick[ID]->currentData().toInt(); int index = cbChPick[ID]->currentData().toInt();
QString SixteenBaseValue = "0x" + QString::number(Utility::TenBase(leTriggerMask[ID][ch]->text().toStdString()), 16); QString SixteenBaseValue = "0x" + QString::number(Utility::TenBase(leTriggerMask[ID][ch]->text().toStdString()), 16).toUpper();
leTriggerMask[ID][ch]->setText(SixteenBaseValue); leTriggerMask[ID][ch]->setText(SixteenBaseValue);
QString msg; QString msg;
@ -720,7 +726,8 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
if( digi[ID]->WriteValue(PHA::CH::ChannelsTriggerMask, SixteenBaseValue.toStdString(), index)){ if( digi[ID]->WriteValue(PHA::CH::ChannelsTriggerMask, SixteenBaseValue.toStdString(), index)){
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
leTriggerMask[ID][ch]->setStyleSheet(""); leTriggerMask[ID][ch]->setStyleSheet("");
ShowSettingsToPanel(); UpdatePanelFromMemory();
UpdateOtherPanels();
}else{ }else{
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
leTriggerMask[ID][ch]->setStyleSheet("color:red;"); leTriggerMask[ID][ch]->setStyleSheet("color:red;");
@ -734,8 +741,8 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
//------------------------------ //------------------------------
rowID ++; rowID ++;
SetupSpinBox(spbCoinLength[iDigi][ch], PHA::CH::CoincidenceLength, -1, false, "Coin. Length [ns]", layout5, rowID, 0); SetupSpinBox(spbCoinLength[iDigi][ch], PHA::CH::CoincidenceLength, -1, true, "Coin. Length [ns]", layout5, rowID, 0);
SetupSpinBox(spbADCVetoWidth[iDigi][ch], PHA::CH::ADCVetoWidth, -1, false, "ADC Veto Length [ns]", layout5, rowID, 2); SetupSpinBox(spbADCVetoWidth[iDigi][ch], PHA::CH::ADCVetoWidth, -1, true, "ADC Veto Length [ns]", layout5, rowID, 2);
for( int i = 0; i < layout5->columnCount(); i++) layout5->setColumnStretch(i, 1); for( int i = 0; i < layout5->columnCount(); i++) layout5->setColumnStretch(i, 1);
@ -753,8 +760,8 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
//------------------------------ //------------------------------
rowID ++; rowID ++;
SetupSpinBox(spbEnergySkimLow[iDigi][ch], PHA::CH::EnergySkimLowDiscriminator, -1, false, "Energy Skim Low", layout6, rowID, 0); SetupSpinBox(spbEnergySkimLow[iDigi][ch], PHA::CH::EnergySkimLowDiscriminator, -1, true, "Energy Skim Low", layout6, rowID, 0);
SetupSpinBox(spbEnergySkimHigh[iDigi][ch], PHA::CH::EnergySkimHighDiscriminator, -1, false, "Energy Skim High", layout6, rowID, 2); SetupSpinBox(spbEnergySkimHigh[iDigi][ch], PHA::CH::EnergySkimHighDiscriminator, -1, true, "Energy Skim High", layout6, rowID, 2);
} }
} }
@ -880,6 +887,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
for( int ch = 0; ch < digi[ID]->GetNChannels() + 1; ch++) { for( int ch = 0; ch < digi[ID]->GetNChannels() + 1; ch++) {
//send UpdateOtherPanels signal //send UpdateOtherPanels signal
/*
connect(spbDCOffset[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); connect(spbDCOffset[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels);
connect(spbRecordLength[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); connect(spbRecordLength[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels);
connect(spbPreTrigger[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels); connect(spbPreTrigger[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateOtherPanels);
@ -905,7 +913,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
connect(cbbDigProbe1[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); connect(cbbDigProbe1[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels);
connect(cbbDigProbe2[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); connect(cbbDigProbe2[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels);
connect(cbbDigProbe3[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels); connect(cbbDigProbe3[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateOtherPanels);
*/
//----- SyncBox //----- SyncBox
connect(cbbOnOff[iDigi][ch], &RComboBox::currentIndexChanged, this, [=](){ SyncComboBox(cbbOnOff, ch);}); connect(cbbOnOff[iDigi][ch], &RComboBox::currentIndexChanged, this, [=](){ SyncComboBox(cbbOnOff, ch);});
connect(spbDCOffset[iDigi][ch], &RSpinBox::returnPressed, this, [=](){ SyncSpinBox(spbDCOffset, ch);}); connect(spbDCOffset[iDigi][ch], &RSpinBox::returnPressed, this, [=](){ SyncSpinBox(spbDCOffset, ch);});
@ -1150,7 +1158,8 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
leBdSettingsRead->setText( QString::fromStdString(digi[ID]->GetSettingValue(para))); leBdSettingsRead->setText( QString::fromStdString(digi[ID]->GetSettingValue(para)));
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
cbBdAns->setStyleSheet(""); cbBdAns->setStyleSheet("");
ShowSettingsToPanel(); UpdatePanelFromMemory();
UpdateOtherPanels();
}else{ }else{
leBdSettingsRead->setText("fail write value"); leBdSettingsRead->setText("fail write value");
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
@ -1179,7 +1188,8 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
leBdSettingsRead->setText( QString::fromStdString(digi[ID]->GetSettingValue(para))); leBdSettingsRead->setText( QString::fromStdString(digi[ID]->GetSettingValue(para)));
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
sbBdSettingsWrite->setStyleSheet(""); sbBdSettingsWrite->setStyleSheet("");
ShowSettingsToPanel(); UpdatePanelFromMemory();
UpdateOtherPanels();
}else{ }else{
leBdSettingsRead->setText("fail write value"); leBdSettingsRead->setText("fail write value");
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
@ -1204,7 +1214,8 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
leBdSettingsRead->setText( QString::fromStdString(digi[ID]->GetSettingValue(para))); leBdSettingsRead->setText( QString::fromStdString(digi[ID]->GetSettingValue(para)));
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
sbBdSettingsWrite->setStyleSheet(""); sbBdSettingsWrite->setStyleSheet("");
ShowSettingsToPanel(); UpdatePanelFromMemory();
UpdateOtherPanels();
}else{ }else{
leBdSettingsRead->setText("fail write value"); leBdSettingsRead->setText("fail write value");
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
@ -1266,7 +1277,8 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
leChSettingsRead->setText( QString::fromStdString(digi[ID]->GetSettingValue(para))); leChSettingsRead->setText( QString::fromStdString(digi[ID]->GetSettingValue(para)));
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
cbChSettingsWrite->setStyleSheet(""); cbChSettingsWrite->setStyleSheet("");
ShowSettingsToPanel(); UpdatePanelFromMemory();
UpdateOtherPanels();
}else{ }else{
leChSettingsRead->setText("fail write value"); leChSettingsRead->setText("fail write value");
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
@ -1297,7 +1309,8 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
leChSettingsRead->setText( QString::fromStdString(digi[ID]->GetSettingValue(para))); leChSettingsRead->setText( QString::fromStdString(digi[ID]->GetSettingValue(para)));
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
sbChSettingsWrite->setStyleSheet(""); sbChSettingsWrite->setStyleSheet("");
ShowSettingsToPanel(); UpdatePanelFromMemory();
UpdateOtherPanels();
}else{ }else{
leChSettingsRead->setText("fail write value"); leChSettingsRead->setText("fail write value");
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
@ -1322,7 +1335,8 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
leChSettingsRead->setText( QString::fromStdString(digi[ID]->GetSettingValue(para))); leChSettingsRead->setText( QString::fromStdString(digi[ID]->GetSettingValue(para)));
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
sbChSettingsWrite->setStyleSheet(""); sbChSettingsWrite->setStyleSheet("");
ShowSettingsToPanel(); UpdatePanelFromMemory();
UpdateOtherPanels();
}else{ }else{
leChSettingsRead->setText("fail write value"); leChSettingsRead->setText("fail write value");
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
@ -1454,7 +1468,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
connect(tabWidget, &QTabWidget::currentChanged, this, [=](int index){ connect(tabWidget, &QTabWidget::currentChanged, this, [=](int index){
if( index < nDigi) { if( index < nDigi) {
ID = index; ID = index;
ShowSettingsToPanel(); UpdatePanelFromMemory();
}else{ }else{
ID = 0; ID = 0;
} }
@ -1513,9 +1527,11 @@ void DigiSettingsPanel::onTriggerClick(int haha){
}else{ }else{
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
digi[iDig]->ReadValue(PHA::CH::ChannelsTriggerMask, ch); digi[iDig]->ReadValue(PHA::CH::ChannelsTriggerMask, ch);
ShowSettingsToPanel();
} }
UpdatePanelFromMemory();
UpdateOtherPanels();
} }
void DigiSettingsPanel::ReadTriggerMap(){ void DigiSettingsPanel::ReadTriggerMap(){
@ -1550,12 +1566,12 @@ void DigiSettingsPanel::ReadTriggerMap(){
void DigiSettingsPanel::RefreshSettings(){ void DigiSettingsPanel::RefreshSettings(){
digi[ID]->ReadAllSettings(); digi[ID]->ReadAllSettings();
ShowSettingsToPanel(); UpdatePanelFromMemory();
} }
void DigiSettingsPanel::EnableControl(){ void DigiSettingsPanel::EnableControl(){
ShowSettingsToPanel(); UpdatePanelFromMemory();
bool enable = !digi[ID]->IsAcqOn(); bool enable = !digi[ID]->IsAcqOn();
@ -1651,7 +1667,8 @@ void DigiSettingsPanel::LoadSettings(){
if( digi[ID]->LoadSettingsFromFile(fileName.toStdString().c_str()) ){ if( digi[ID]->LoadSettingsFromFile(fileName.toStdString().c_str()) ){
SendLogMsg("Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber())); SendLogMsg("Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber()));
ShowSettingsToPanel(); UpdatePanelFromMemory();
UpdateOtherPanels();
}else{ }else{
SendLogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber())); SendLogMsg("Fail to Loaded settings file " + fileName + " for Digi-" + QString::number(digi[ID]->GetSerialNumber()));
} }
@ -1664,11 +1681,13 @@ void DigiSettingsPanel::SetDefaultPHASettigns(){
RefreshSettings(); RefreshSettings();
} }
void DigiSettingsPanel::ShowSettingsToPanel(){ void DigiSettingsPanel::UpdatePanelFromMemory(){
if( !isVisible() ) return;
enableSignalSlot = false; enableSignalSlot = false;
printf("%s Digi-%d\n", __func__, digi[ID]->GetSerialNumber()); printf("DigiSettingsPanel::%s Digi-%d\n", __func__, digi[ID]->GetSerialNumber());
for (unsigned short j = 0; j < (unsigned short) infoIndex.size(); j++){ for (unsigned short j = 0; j < (unsigned short) infoIndex.size(); j++){
leInfo[ID][j]->setText(QString::fromStdString(digi[ID]->GetSettingValue(infoIndex[j].second))); leInfo[ID][j]->setText(QString::fromStdString(digi[ID]->GetSettingValue(infoIndex[j].second)));
@ -1821,7 +1840,7 @@ void DigiSettingsPanel::ShowSettingsToPanel(){
} }
} }
if( isSame ) leTriggerMask[ID][MaxNumberOfChannel]->setText("0x" + QString::number(mask, 16)); if( isSame ) leTriggerMask[ID][MaxNumberOfChannel]->setText("0x" + QString::number(mask, 16).toUpper());
} }
enableSignalSlot = true; enableSignalSlot = true;
@ -1949,7 +1968,8 @@ void DigiSettingsPanel::SetupComboBox(RComboBox *&cbb, const Reg para, int ch_in
if( digi[ID]->WriteValue(para, cbb->currentData().toString().toStdString(), index)){ if( digi[ID]->WriteValue(para, cbb->currentData().toString().toStdString(), index)){
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
cbb->setStyleSheet(""); cbb->setStyleSheet("");
ShowSettingsToPanel(); UpdatePanelFromMemory();
UpdateOtherPanels();
}else{ }else{
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
cbb->setStyleSheet("color:red;"); cbb->setStyleSheet("color:red;");
@ -1968,11 +1988,13 @@ void DigiSettingsPanel::SetupSpinBox(RSpinBox *&spb, const Reg para, int ch_inde
spb->setMinimum(atof( para.GetAnswers()[0].first.c_str())); spb->setMinimum(atof( para.GetAnswers()[0].first.c_str()));
} }
spb->setMaximum(atof( para.GetAnswers()[1].first.c_str())); spb->setMaximum(atof( para.GetAnswers()[1].first.c_str()));
if( para.GetAnswers().size() >= 3 ) { if( para.GetAnswers().size() >= 3 ) {
spb->setSingleStep(atof(para.GetAnswers()[2].first.c_str())); spb->setSingleStep(atof(para.GetAnswers()[2].first.c_str()));
}else{ }else{
printf("--- missed. %s\n", para.GetPara().c_str()); printf("--- missed. %s\n", para.GetPara().c_str());
} }
spb->SetToolTip( atof( para.GetAnswers()[0].first.c_str()));
layout->addWidget(spb, row, col + 1, srow, scol); layout->addWidget(spb, row, col + 1, srow, scol);
connect(spb, &RSpinBox::valueChanged, this, [=](){ connect(spb, &RSpinBox::valueChanged, this, [=](){
@ -1995,7 +2017,8 @@ void DigiSettingsPanel::SetupSpinBox(RSpinBox *&spb, const Reg para, int ch_inde
if( digi[ID]->WriteValue(para, std::to_string(spb->value()), index)){ if( digi[ID]->WriteValue(para, std::to_string(spb->value()), index)){
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
spb->setStyleSheet(""); spb->setStyleSheet("");
ShowSettingsToPanel(); UpdatePanelFromMemory();
UpdateOtherPanels();
}else{ }else{
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
spb->setStyleSheet("color:red;"); spb->setStyleSheet("color:red;");
@ -2053,7 +2076,6 @@ void DigiSettingsPanel::SyncSpinBox(RSpinBox *(&spb)[][MaxNumberOfChannel+1], in
} }
//printf("%d =? %d \n", count, nCh); //printf("%d =? %d \n", count, nCh);
enableSignalSlot = false; enableSignalSlot = false;
if( count != nCh ){ if( count != nCh ){
spb[ID][nCh]->setValue(-1); spb[ID][nCh]->setValue(-1);

View File

@ -40,13 +40,13 @@ private slots:
void RefreshSettings(); // this read digitizer and ShowSettingToPanel void RefreshSettings(); // this read digitizer and ShowSettingToPanel
public slots: public slots:
void ShowSettingsToPanel();
void EnableControl(); void EnableControl();
void UpdatePanelFromMemory();
signals: signals:
void SendLogMsg(const QString &msg);
void UpdateOtherPanels(); void UpdateOtherPanels();
void SendLogMsg(const QString &msg);
private: private:

View File

@ -70,10 +70,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
scope = nullptr; scope = nullptr;
digiSetting = nullptr; digiSetting = nullptr;
ConnectScopeAndSetting = false;
ConnectScopeAndSolaris = false;
ConnectSettingAndSolaris = false;
QWidget * mainLayoutWidget = new QWidget(this); QWidget * mainLayoutWidget = new QWidget(this);
setCentralWidget(mainLayoutWidget); setCentralWidget(mainLayoutWidget);
QVBoxLayout * layoutMain = new QVBoxLayout(mainLayoutWidget); QVBoxLayout * layoutMain = new QVBoxLayout(mainLayoutWidget);
@ -713,6 +709,7 @@ void MainWindow::OpenScope(){
connect(scope, &Scope::CloseWindow, this, [=](){ bnStartACQ->setEnabled(true); }); connect(scope, &Scope::CloseWindow, this, [=](){ bnStartACQ->setEnabled(true); });
connect(scope, &Scope::UpdateScalar, this, &MainWindow::UpdateScalar); connect(scope, &Scope::UpdateScalar, this, &MainWindow::UpdateScalar);
connect(scope, &Scope::SendLogMsg, this, &MainWindow::LogMsg); connect(scope, &Scope::SendLogMsg, this, &MainWindow::LogMsg);
connect(scope, &Scope::UpdateOtherPanels, this, [=](){ UpdateAllPanel(0);});
connect(scope, &Scope::TellACQOnOff, this, [=](const bool onOff){ connect(scope, &Scope::TellACQOnOff, this, [=](const bool onOff){
if( influx ){ if( influx ){
influx->ClearDataPointsBuffer(); influx->ClearDataPointsBuffer();
@ -726,19 +723,9 @@ void MainWindow::OpenScope(){
influx->AddDataPoint("StartStop value=1"); influx->AddDataPoint("StartStop value=1");
influx->WriteData(DatabaseName.toStdString()); influx->WriteData(DatabaseName.toStdString());
} }
if( digiSetting) {
if( digiSetting && ConnectScopeAndSetting ) {
connect(scope, &Scope::UpdateOtherPanels, digiSetting, &DigiSettingsPanel::ShowSettingsToPanel);
connect(scope, &Scope::TellSettingsPanelControlOnOff, digiSetting, &DigiSettingsPanel::EnableControl); connect(scope, &Scope::TellSettingsPanelControlOnOff, digiSetting, &DigiSettingsPanel::EnableControl);
connect(digiSetting, &DigiSettingsPanel::UpdateOtherPanels, scope, &Scope::ReadScopeSettings); digiSetting->EnableControl();
ConnectScopeAndSetting = true;
}
if( digiSetting) digiSetting->EnableControl();
if( solarisSetting && !ConnectScopeAndSolaris ){
connect(scope, &Scope::UpdateOtherPanels, solarisSetting, &SOLARISpanel::UpdatePanel);
connect(solarisSetting, &SOLARISpanel::UpdateOtherPanels, scope, &Scope::ReadScopeSettings);
ConnectScopeAndSolaris = true;
} }
}else{ }else{
@ -757,42 +744,18 @@ void MainWindow::OpenDigitizersSettings(){
if( digiSetting == NULL){ if( digiSetting == NULL){
digiSetting = new DigiSettingsPanel(digi, nDigi); digiSetting = new DigiSettingsPanel(digi, nDigi);
connect(digiSetting, &DigiSettingsPanel::SendLogMsg, this, &MainWindow::LogMsg); connect(digiSetting, &DigiSettingsPanel::SendLogMsg, this, &MainWindow::LogMsg);
connect(digiSetting, &DigiSettingsPanel::UpdateOtherPanels, this, [=](){ UpdateAllPanel(1);});
if( scope && !ConnectScopeAndSetting) {
connect(scope, &Scope::UpdateOtherPanels, digiSetting, &DigiSettingsPanel::ShowSettingsToPanel);
connect(scope, &Scope::TellSettingsPanelControlOnOff, digiSetting, &DigiSettingsPanel::EnableControl);
connect(digiSetting, &DigiSettingsPanel::UpdateOtherPanels, scope, &Scope::ReadScopeSettings);
ConnectScopeAndSetting = true;
}
if( solarisSetting && !ConnectSettingAndSolaris){
connect(digiSetting, &DigiSettingsPanel::UpdateOtherPanels, solarisSetting, &SOLARISpanel::UpdatePanel);
connect(solarisSetting, &SOLARISpanel::UpdateOtherPanels, digiSetting, &DigiSettingsPanel::ShowSettingsToPanel);
ConnectSettingAndSolaris = true;
}
}else{ }else{
digiSetting->show(); digiSetting->show();
} }
digiSetting->UpdatePanelFromMemory();
} }
//^###################################################################### Open SOLARIS setting panel //^###################################################################### Open SOLARIS setting panel
void MainWindow::OpenSOLARISpanel(){ void MainWindow::OpenSOLARISpanel(){
solarisSetting->show(); solarisSetting->show();
solarisSetting->UpdatePanel(); solarisSetting->UpdatePanelFromMemory();
if( digiSetting && !ConnectSettingAndSolaris){
connect(digiSetting, &DigiSettingsPanel::UpdateOtherPanels, solarisSetting, &SOLARISpanel::UpdatePanel);
connect(solarisSetting, &SOLARISpanel::UpdateOtherPanels, digiSetting, &DigiSettingsPanel::ShowSettingsToPanel);
ConnectSettingAndSolaris = true;
}
if( scope && !ConnectScopeAndSolaris){
connect(scope, &Scope::UpdateOtherPanels, solarisSetting, &SOLARISpanel::UpdatePanel);
connect(solarisSetting, &SOLARISpanel::UpdateOtherPanels, scope, &Scope::ReadScopeSettings);
ConnectScopeAndSolaris = true;
}
} }
bool MainWindow::CheckSOLARISpanelOK(){ bool MainWindow::CheckSOLARISpanelOK(){
@ -864,11 +827,6 @@ bool MainWindow::CheckSOLARISpanelOK(){
} }
file.close(); file.close();
//if( (int) mapping.size() > nDigi){
// LogMsg("Num. of Digitizer in the Mapping is more than Opened DIgitizer.");
// return false;
//}
LogMsg("Mapping.h | Num. Digi : " + QString::number(mapping.size())); LogMsg("Mapping.h | Num. Digi : " + QString::number(mapping.size()));
for( int i = 0 ; i < (int) mapping.size(); i ++){ for( int i = 0 ; i < (int) mapping.size(); i ++){
if( i < nDigi ){ if( i < nDigi ){
@ -889,12 +847,34 @@ bool MainWindow::CheckSOLARISpanelOK(){
//@============= Create SOLAIRS panel //@============= Create SOLAIRS panel
solarisSetting = new SOLARISpanel(digi, nDigi, mapping, detType, detMaxID); solarisSetting = new SOLARISpanel(digi, nDigi, mapping, detType, detMaxID);
connect(solarisSetting, &SOLARISpanel::SendLogMsg, this, &MainWindow::LogMsg); connect(solarisSetting, &SOLARISpanel::SendLogMsg, this, &MainWindow::LogMsg);
connect(solarisSetting, &SOLARISpanel::UpdateOtherPanels, this, [=](){ UpdateAllPanel(2);});
if( solarisSetting == nullptr) return false; if( solarisSetting == nullptr) return false;
return true; return true;
} }
void MainWindow::UpdateAllPanel(int panelID){
printf("%s %d\n", __func__, panelID);
switch (panelID) {
case 0 :{
if( digiSetting && digiSetting->isVisible() ) digiSetting->UpdatePanelFromMemory();
if( solarisSetting && solarisSetting->isVisible() ) solarisSetting->UpdatePanelFromMemory();
};break;
case 1 :{
if( scope && scope->isVisible() ) scope->ReadScopeSettings();
if( solarisSetting && solarisSetting->isVisible() ) solarisSetting->UpdatePanelFromMemory();
};break;
case 2 :{
if( scope && scope->isVisible() ) scope->ReadScopeSettings();
if( digiSetting && digiSetting->isVisible() ) digiSetting->UpdatePanelFromMemory();
}
}
}
//^###################################################################### Open Scaler, when DAQ is running //^###################################################################### Open Scaler, when DAQ is running
void MainWindow::OpenScaler(){ void MainWindow::OpenScaler(){
scalar->show(); scalar->show();

View File

@ -39,7 +39,6 @@ public:
MainWindow(QWidget *parent = nullptr); MainWindow(QWidget *parent = nullptr);
~MainWindow(); ~MainWindow();
private slots: private slots:
void OpenDigitizers(); void OpenDigitizers();
@ -183,9 +182,7 @@ private:
unsigned long oldTimeStamp[MaxNumberOfDigitizer][MaxNumberOfChannel]; unsigned long oldTimeStamp[MaxNumberOfDigitizer][MaxNumberOfChannel];
//@------ connection between pannels //@------ connection between pannels
bool ConnectScopeAndSetting; void UpdateAllPanel(int panelID);
bool ConnectScopeAndSolaris;
bool ConnectSettingAndSolaris;
}; };

View File

@ -85,7 +85,6 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "False", -1); digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "False", -1);
digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "True", ch); digi[iDigi]->WriteValue(PHA::CH::ChannelEnable, "True", ch);
ReadScopeSettings(); ReadScopeSettings();
UpdateOtherPanels();
digiMTX[iDigi].unlock(); digiMTX[iDigi].unlock();
}); });
@ -113,6 +112,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
connect(bnScopeReadSettings, &QPushButton::clicked, this, [=](){ connect(bnScopeReadSettings, &QPushButton::clicked, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
ReadScopeSettings(); ReadScopeSettings();
UpdateOtherPanels();
}); });
//TODO----- add copy settings and paste settings //TODO----- add copy settings and paste settings
@ -327,13 +327,55 @@ Scope::~Scope(){
void Scope::ReadScopeSettings(){ void Scope::ReadScopeSettings(){
int iDigi = cbScopeDigi->currentIndex(); if( !isVisible() ) return;
int ch = cbScopeCh->currentIndex();
if( !digi[iDigi] && digi[iDigi]->IsDummy() ) return; int iDigi = cbScopeDigi->currentIndex();
if( !digi[iDigi] || digi[iDigi]->IsDummy() || !digi[iDigi]->IsConnected()) return;
int ch = cbScopeCh->currentIndex();
digi[iDigi]->ReadValue(PHA::CH::WaveAnalogProbe0, ch);
digi[iDigi]->ReadValue(PHA::CH::WaveAnalogProbe1, ch);
digi[iDigi]->ReadValue(PHA::CH::WaveDigitalProbe0, ch);
digi[iDigi]->ReadValue(PHA::CH::WaveDigitalProbe1, ch);
digi[iDigi]->ReadValue(PHA::CH::WaveDigitalProbe2, ch);
digi[iDigi]->ReadValue(PHA::CH::WaveDigitalProbe3, ch);
digi[iDigi]->ReadValue(PHA::CH::Polarity, ch);
digi[iDigi]->ReadValue(PHA::CH::WaveResolution, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterPeakingAvg, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterBaselineAvg, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterLowFreqFilter, ch);
digi[iDigi]->ReadValue(PHA::CH::RecordLength, ch);
digi[iDigi]->ReadValue(PHA::CH::PreTrigger, ch);
digi[iDigi]->ReadValue(PHA::CH::DC_Offset, ch);
digi[iDigi]->ReadValue(PHA::CH::TriggerThreshold, ch);
digi[iDigi]->ReadValue(PHA::CH::TimeFilterRiseTime, ch);
digi[iDigi]->ReadValue(PHA::CH::TimeFilterRetriggerGuard, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterRiseTime, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterFlatTop, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterPoleZero, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterFineGain, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterPeakingPosition, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterBaselineGuard, ch);
digi[iDigi]->ReadValue(PHA::CH::EnergyFilterPileUpGuard, ch);
UpdateSettingsFromMemeory();
}
void Scope::UpdateSettingsFromMemeory(){
if( !isVisible() ) return;
printf("Scope::%s\n", __func__);
int iDigi = cbScopeDigi->currentIndex();
if( !digi[iDigi] || digi[iDigi]->IsDummy() || !digi[iDigi]->IsConnected()) return;
allowChange = false; allowChange = false;
int ch = cbScopeCh->currentIndex();
for( int i = 0 ; i < 2; i++){ for( int i = 0 ; i < 2; i++){
ScopeReadComboBoxValue(iDigi, ch, cbAnaProbe[i], PHA::CH::AnalogProbe[i]); ScopeReadComboBoxValue(iDigi, ch, cbAnaProbe[i], PHA::CH::AnalogProbe[i]);
} }
@ -375,6 +417,7 @@ void Scope::ReadScopeSettings(){
sbBaselineGuard->setStyleSheet(""); sbBaselineGuard->setStyleSheet("");
sbPileUpGuard->setStyleSheet(""); sbPileUpGuard->setStyleSheet("");
allowChange = true; allowChange = true;
} }
@ -550,12 +593,12 @@ void Scope::ScopeControlOnOff(bool on){
} }
void Scope::ScopeReadSpinBoxValue(int iDigi, int ch, RSpinBox *sb, const Reg digPara){ void Scope::ScopeReadSpinBoxValue(int iDigi, int ch, RSpinBox *sb, const Reg digPara){
std::string ans = digi[iDigi]->ReadValue(digPara, ch); std::string ans = digi[iDigi]->GetSettingValue(digPara, ch);
sb->setValue(atoi(ans.c_str())); sb->setValue(atoi(ans.c_str()));
} }
void Scope::ScopeReadComboBoxValue(int iDigi, int ch, RComboBox *cb, const Reg digPara){ void Scope::ScopeReadComboBoxValue(int iDigi, int ch, RComboBox *cb, const Reg digPara){
std::string ans = digi[iDigi]->ReadValue(digPara, ch); std::string ans = digi[iDigi]->GetSettingValue(digPara, ch);
int index = cb->findData(QString::fromStdString(ans)); int index = cb->findData(QString::fromStdString(ans));
if( index >= 0 && index < cb->count()) { if( index >= 0 && index < cb->count()) {
cb->setCurrentIndex(index); cb->setCurrentIndex(index);
@ -595,16 +638,12 @@ void Scope::ScopeMakeSpinBox(RSpinBox * &sb, QString str, QGridLayout *layout, i
if( digi[iDigi]->WriteValue(digPara, std::to_string(sb->value()), ch)){ if( digi[iDigi]->WriteValue(digPara, std::to_string(sb->value()), ch)){
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
sb->setStyleSheet(""); sb->setStyleSheet("");
UpdateSettingsFromMemeory();
//TODO digiSettingPanel update setting UpdateOtherPanels();
printf("UpdateOtherPanels \n");
emit UpdateOtherPanels();
}else{ }else{
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
sb->setStyleSheet("color:red;"); sb->setStyleSheet("color:red;");
} }
}); });
@ -632,9 +671,8 @@ void Scope::ScopeMakeComoBox(RComboBox * &cb, QString str, QGridLayout *layout,
if( digi[iDigi]->WriteValue(digPara, cb->currentData().toString().toStdString(), ch)){ if( digi[iDigi]->WriteValue(digPara, cb->currentData().toString().toStdString(), ch)){
SendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
cb->setStyleSheet(""); cb->setStyleSheet("");
//TODO digiSettingPanel update setting UpdateSettingsFromMemeory();
printf("UpdateOtherPanels \n"); UpdateOtherPanels();
emit UpdateOtherPanels();
}else{ }else{
SendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
cb->setStyleSheet("color:red;"); cb->setStyleSheet("color:red;");

View File

@ -109,6 +109,7 @@ public:
public slots: public slots:
void ReadScopeSettings(); // read from digitizer and show; void ReadScopeSettings(); // read from digitizer and show;
void UpdateSettingsFromMemeory();
private slots: private slots:
void StartScope(); void StartScope();
@ -130,8 +131,8 @@ private slots:
signals: signals:
void CloseWindow(); void CloseWindow();
void SendLogMsg(const QString &msg);
void UpdateScalar(); void UpdateScalar();
void SendLogMsg(const QString &msg);
void UpdateOtherPanels(); void UpdateOtherPanels();
void TellSettingsPanelControlOnOff(); void TellSettingsPanelControlOnOff();
void TellACQOnOff(const bool onOff); void TellACQOnOff(const bool onOff);