many issues fixed. setting is sync across all panels

This commit is contained in:
Ryan Tang 2023-03-10 17:28:02 -05:00
parent 171561f823
commit 013f24165c
9 changed files with 418 additions and 276 deletions

View File

@ -69,7 +69,8 @@
"variant": "cpp", "variant": "cpp",
"qdatetime": "cpp", "qdatetime": "cpp",
"fstream": "cpp", "fstream": "cpp",
"allocator": "cpp" "allocator": "cpp",
"qsignalmapper": "cpp"
}, },
"better-comments.multilineComments": true, "better-comments.multilineComments": true,

View File

@ -135,7 +135,7 @@ bool Digitizer2Gen::WriteValue(const char * parameter, std::string value){
printf(" %s|%-45s|%s|\n", __func__, parameter, value.c_str()); printf(" %s|%-45s|%s|\n", __func__, parameter, value.c_str());
ret = CAEN_FELib_SetValue(handle, parameter, value.c_str()); ret = CAEN_FELib_SetValue(handle, parameter, value.c_str());
if (ret != CAEN_FELib_Success) { if (ret != CAEN_FELib_Success) {
printf("|%s||%s|\n", parameter, value.c_str()); printf("WriteError|%s||%s|\n", parameter, value.c_str());
ErrorMsg(__func__); ErrorMsg(__func__);
return false; return false;
} }

44
CustomWidgets.h Normal file
View File

@ -0,0 +1,44 @@
#ifndef CustomWidgets_H
#define CustomWidgets_H
#include <QWidget>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QComboBox>
#include <QWheelEvent>
//^=======================================
class RComboBox : public QComboBox{
public :
RComboBox(QWidget * parent = nullptr): QComboBox(parent){
setFocusPolicy(Qt::StrongFocus);
}
protected:
void wheelEvent(QWheelEvent * event) override{ event->ignore(); }
};
//^=======================================
class RSpinBox : public QDoubleSpinBox{
Q_OBJECT
public :
RSpinBox(QWidget * parent = nullptr, int decimal = 0): QDoubleSpinBox(parent){
setFocusPolicy(Qt::StrongFocus);
setDecimals(decimal);
}
signals:
void returnPressed();
protected:
void wheelEvent(QWheelEvent * event) override{ event->ignore(); }
void keyPressEvent(QKeyEvent * event) override{
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
emit returnPressed();
} else {
QDoubleSpinBox::keyPressEvent(event);
}
}
};
#endif

View File

@ -18,5 +18,5 @@ LIBS += -lcurl -lCAEN_FELib -lX11
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Input # Input
HEADERS += ClassDigitizer2Gen.h Event.h influxdb.h mainwindow.h digiSettingsPanel.h Digiparameters.h scope.h manyThread.h HEADERS += ClassDigitizer2Gen.h Event.h influxdb.h mainwindow.h digiSettingsPanel.h Digiparameters.h scope.h manyThread.h CustomWidgets.h
SOURCES += ClassDigitizer2Gen.cpp influxdb.cpp main.cpp mainwindow.cpp digiSettingsPanel.cpp scope.cpp SOURCES += ClassDigitizer2Gen.cpp influxdb.cpp main.cpp mainwindow.cpp digiSettingsPanel.cpp scope.cpp

View File

@ -185,76 +185,71 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
//------------------------------------- //-------------------------------------
rowId ++; rowId ++;
QPushButton * bnReadSettngs = new QPushButton("Refresh Settings", tab); bnReadSettngs[iDigi] = new QPushButton("Refresh Settings", tab);
bnLayout->addWidget(bnReadSettngs, rowId, 0, 1, 2); bnLayout->addWidget(bnReadSettngs[iDigi], rowId, 0, 1, 2);
connect(bnReadSettngs, &QPushButton::clicked, this, &DigiSettingsPanel::RefreshSettings); connect(bnReadSettngs[iDigi], &QPushButton::clicked, this, &DigiSettingsPanel::RefreshSettings);
QPushButton * bnResetBd = new QPushButton("Reset Board", tab); bnResetBd[iDigi] = new QPushButton("Reset Board", tab);
bnLayout->addWidget(bnResetBd, rowId, 2, 1, 2); bnLayout->addWidget(bnResetBd[iDigi], rowId, 2, 1, 2);
connect(bnResetBd, &QPushButton::clicked, this, [=](){ connect(bnResetBd[iDigi], &QPushButton::clicked, this, [=](){
sendLogMsg("Reset Digitizer-" + QString::number(digi[ID]->GetSerialNumber())); SendLogMsg("Reset Digitizer-" + QString::number(digi[ID]->GetSerialNumber()));
digi[ID]->Reset(); digi[ID]->Reset();
}); });
QPushButton * bnDefaultSetting = new QPushButton("Set Default Settings", tab); bnDefaultSetting[iDigi] = new QPushButton("Set Default Settings", tab);
bnLayout->addWidget(bnDefaultSetting, rowId, 4, 1, 2); bnLayout->addWidget(bnDefaultSetting[iDigi], rowId, 4, 1, 2);
connect(bnDefaultSetting, &QPushButton::clicked, this, [=](){ connect(bnDefaultSetting[iDigi], &QPushButton::clicked, this, [=](){
sendLogMsg("Program Digitizer-" + QString::number(digi[ID]->GetSerialNumber()) + " to default PHA."); SendLogMsg("Program Digitizer-" + QString::number(digi[ID]->GetSerialNumber()) + " to default PHA.");
digi[ID]->ProgramPHA(); digi[ID]->ProgramPHA();
}); });
QPushButton * bnSaveSettings = new QPushButton("Save Settings", tab); bnSaveSettings[iDigi] = new QPushButton("Save Settings", tab);
bnLayout->addWidget(bnSaveSettings, rowId, 6, 1, 2); bnLayout->addWidget(bnSaveSettings[iDigi], rowId, 6, 1, 2);
connect(bnSaveSettings, &QPushButton::clicked, this, &DigiSettingsPanel::SaveSettings); connect(bnSaveSettings[iDigi], &QPushButton::clicked, this, &DigiSettingsPanel::SaveSettings);
QPushButton * bnLoadSettings = new QPushButton("Load Settings", tab); bnLoadSettings[iDigi] = new QPushButton("Load Settings", tab);
bnLayout->addWidget(bnLoadSettings, rowId, 8, 1, 2); bnLayout->addWidget(bnLoadSettings[iDigi], rowId, 8, 1, 2);
connect(bnLoadSettings, &QPushButton::clicked, this, &DigiSettingsPanel::LoadSettings); connect(bnLoadSettings[iDigi], &QPushButton::clicked, this, &DigiSettingsPanel::LoadSettings);
//--------------------------------------- //---------------------------------------
rowId ++; rowId ++;
QPushButton * bnClearData = new QPushButton("Clear Data", tab); bnClearData[iDigi] = new QPushButton("Clear Data", tab);
bnLayout->addWidget(bnClearData, rowId, 0, 1, 2); bnLayout->addWidget(bnClearData[iDigi], rowId, 0, 1, 2);
connect(bnClearData, &QPushButton::clicked, this, [=](){ connect(bnClearData[iDigi], &QPushButton::clicked, this, [=](){ digi[ID]->SendCommand(DIGIPARA::DIG::ClearData); });
digi[ID]->SendCommand(DIGIPARA::DIG::ClearData); });
QPushButton * bnArmACQ = new QPushButton("Arm ACQ", tab); bnArmACQ[iDigi] = new QPushButton("Arm ACQ", tab);
bnLayout->addWidget(bnArmACQ, rowId, 2, 1, 2); bnLayout->addWidget(bnArmACQ[iDigi], rowId, 2, 1, 2);
connect(bnArmACQ, &QPushButton::clicked, this, [=](){ connect(bnArmACQ[iDigi], &QPushButton::clicked, this, [=](){ digi[ID]->SendCommand(DIGIPARA::DIG::ArmACQ); });
digi[ID]->SendCommand(DIGIPARA::DIG::ArmACQ); });
QPushButton * bnDisarmACQ = new QPushButton("Disarm ACQ", tab); bnDisarmACQ[iDigi] = new QPushButton("Disarm ACQ", tab);
bnLayout->addWidget(bnDisarmACQ, rowId, 4, 1, 2); bnLayout->addWidget(bnDisarmACQ[iDigi], rowId, 4, 1, 2);
connect(bnDisarmACQ, &QPushButton::clicked, this, [=](){ connect(bnDisarmACQ[iDigi], &QPushButton::clicked, this, [=](){ digi[ID]->SendCommand(DIGIPARA::DIG::DisarmACQ); });
digi[ID]->SendCommand(DIGIPARA::DIG::DisarmACQ); });
QPushButton * bnSoftwareStart= new QPushButton("Software Start ACQ", tab); bnSoftwareStart[iDigi] = new QPushButton("Software Start ACQ", tab);
bnLayout->addWidget(bnSoftwareStart, rowId, 6, 1, 2); bnLayout->addWidget(bnSoftwareStart[iDigi], rowId, 6, 1, 2);
connect(bnSoftwareStart, &QPushButton::clicked, this, [=](){ connect(bnSoftwareStart[iDigi], &QPushButton::clicked, this, [=](){ digi[ID]->SendCommand(DIGIPARA::DIG::SoftwareStartACQ); });
digi[ID]->SendCommand(DIGIPARA::DIG::SoftwareStartACQ); });
QPushButton * bnSoftwareStop= new QPushButton("Software Stop ACQ", tab); bnSoftwareStop[iDigi] = new QPushButton("Software Stop ACQ", tab);
bnLayout->addWidget(bnSoftwareStop, rowId, 8, 1, 2); bnLayout->addWidget(bnSoftwareStop[iDigi], rowId, 8, 1, 2);
connect(bnSoftwareStop, &QPushButton::clicked, this, [=](){ connect(bnSoftwareStop[iDigi], &QPushButton::clicked, this, [=](){ digi[ID]->SendCommand(DIGIPARA::DIG::SoftwareStopACQ); });
digi[ID]->SendCommand(DIGIPARA::DIG::SoftwareStopACQ); });
//--------------- //---------------
if( digi[iDigi]->IsDummy() ){ if( digi[iDigi]->IsDummy() ){
bnReadSettngs->setEnabled(false); bnReadSettngs[iDigi]->setEnabled(false);
bnResetBd->setEnabled(false); bnResetBd[iDigi]->setEnabled(false);
bnDefaultSetting->setEnabled(false); bnDefaultSetting[iDigi]->setEnabled(false);
bnClearData->setEnabled(false); bnClearData[iDigi]->setEnabled(false);
bnArmACQ->setEnabled(false); bnArmACQ[iDigi]->setEnabled(false);
bnDisarmACQ->setEnabled(false); bnDisarmACQ[iDigi]->setEnabled(false);
bnSoftwareStart->setEnabled(false); bnSoftwareStart[iDigi]->setEnabled(false);
bnSoftwareStop->setEnabled(false); bnSoftwareStop[iDigi]->setEnabled(false);
} }
} }
{//^====================== Group Board settings {//^====================== Group Board settings
QGroupBox * digiBox = new QGroupBox("Board Settings", tab); digiBox = new QGroupBox("Board Settings", tab);
//digiBox->setSizePolicy(sizePolicy); //digiBox->setSizePolicy(sizePolicy);
QGridLayout * boardLayout = new QGridLayout(digiBox); QGridLayout * boardLayout = new QGridLayout(digiBox);
tabLayout_V1->addWidget(digiBox); tabLayout_V1->addWidget(digiBox);
@ -310,10 +305,10 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
msg = QString::fromStdString(DIGIPARA::DIG::EnableAutoDisarmACQ.GetPara()) + "|DIG:"+ QString::number(digi[ID]->GetSerialNumber()); msg = QString::fromStdString(DIGIPARA::DIG::EnableAutoDisarmACQ.GetPara()) + "|DIG:"+ QString::number(digi[ID]->GetSerialNumber());
msg += " = " + cbbAutoDisarmAcq[ID]->currentData().toString(); msg += " = " + cbbAutoDisarmAcq[ID]->currentData().toString();
if( digi[ID]->WriteValue(DIGIPARA::DIG::EnableAutoDisarmACQ, cbbAutoDisarmAcq[ID]->currentData().toString().toStdString())){ if( digi[ID]->WriteValue(DIGIPARA::DIG::EnableAutoDisarmACQ, cbbAutoDisarmAcq[ID]->currentData().toString().toStdString())){
sendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
cbbAutoDisarmAcq[ID]->setStyleSheet(""); cbbAutoDisarmAcq[ID]->setStyleSheet("");
}else{ }else{
sendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
cbbAutoDisarmAcq[ID]->setStyleSheet("color:red;"); cbbAutoDisarmAcq[ID]->setStyleSheet("color:red;");
} }
}); });
@ -335,10 +330,10 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
msg = QString::fromStdString(DIGIPARA::DIG::EnableStatisticEvents.GetPara()) + "|DIG:"+ QString::number(digi[ID]->GetSerialNumber()); msg = QString::fromStdString(DIGIPARA::DIG::EnableStatisticEvents.GetPara()) + "|DIG:"+ QString::number(digi[ID]->GetSerialNumber());
msg += " = " + cbbStatEvents[ID]->currentData().toString(); msg += " = " + cbbStatEvents[ID]->currentData().toString();
if( digi[ID]->WriteValue(DIGIPARA::DIG::EnableStatisticEvents, cbbStatEvents[ID]->currentData().toString().toStdString()) ){ if( digi[ID]->WriteValue(DIGIPARA::DIG::EnableStatisticEvents, cbbStatEvents[ID]->currentData().toString().toStdString()) ){
sendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
cbbStatEvents[ID]->setStyleSheet(""); cbbStatEvents[ID]->setStyleSheet("");
}else{ }else{
sendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
cbbStatEvents[ID]->setStyleSheet("color:red"); cbbStatEvents[ID]->setStyleSheet("color:red");
} }
}); });
@ -372,10 +367,10 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
msg += " = " + QString::number(dsbBdVetoWidth[iDigi]->value()); msg += " = " + QString::number(dsbBdVetoWidth[iDigi]->value());
if( digi[ID]->WriteValue(DIGIPARA::DIG::BoardVetoWidth, std::to_string(dsbBdVetoWidth[iDigi]->value()), -1) ){ if( digi[ID]->WriteValue(DIGIPARA::DIG::BoardVetoWidth, std::to_string(dsbBdVetoWidth[iDigi]->value()), -1) ){
dsbBdVetoWidth[ID]->setStyleSheet(""); dsbBdVetoWidth[ID]->setStyleSheet("");
sendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
}else{ }else{
dsbBdVetoWidth[ID]->setStyleSheet("color:red;"); dsbBdVetoWidth[ID]->setStyleSheet("color:red;");
sendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
} }
}); });
@ -413,10 +408,10 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
msg += " = " + QString::number(dsbVolatileClockOutDelay[iDigi]->value()); msg += " = " + QString::number(dsbVolatileClockOutDelay[iDigi]->value());
if( digi[ID]->WriteValue(DIGIPARA::DIG::VolatileClockOutDelay, std::to_string(dsbVolatileClockOutDelay[ID]->value()), -1) ){ if( digi[ID]->WriteValue(DIGIPARA::DIG::VolatileClockOutDelay, std::to_string(dsbVolatileClockOutDelay[ID]->value()), -1) ){
dsbVolatileClockOutDelay[ID]->setStyleSheet(""); dsbVolatileClockOutDelay[ID]->setStyleSheet("");
sendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
}else{ }else{
dsbVolatileClockOutDelay[ID]->setStyleSheet("color:red;"); dsbVolatileClockOutDelay[ID]->setStyleSheet("color:red;");
sendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
} }
}); });
@ -449,10 +444,10 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
msg += " = " + QString::number(dsbClockOutDelay[iDigi]->value()); msg += " = " + QString::number(dsbClockOutDelay[iDigi]->value());
if( digi[ID]->WriteValue(DIGIPARA::DIG::PermanentClockOutDelay, std::to_string(dsbClockOutDelay[ID]->value()), -1) ){ if( digi[ID]->WriteValue(DIGIPARA::DIG::PermanentClockOutDelay, std::to_string(dsbClockOutDelay[ID]->value()), -1) ){
dsbClockOutDelay[ID]->setStyleSheet(""); dsbClockOutDelay[ID]->setStyleSheet("");
sendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
}else{ }else{
dsbClockOutDelay[ID]->setStyleSheet("color:red;"); dsbClockOutDelay[ID]->setStyleSheet("color:red;");
sendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
} }
}); });
} }
@ -510,10 +505,10 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
msg += " = " + QString::number(VGA[ID][k]->value()); msg += " = " + QString::number(VGA[ID][k]->value());
if( digi[ID]->WriteValue(DIGIPARA::VGA::VGAGain, std::to_string(VGA[ID][k]->value()), k)){ if( digi[ID]->WriteValue(DIGIPARA::VGA::VGAGain, std::to_string(VGA[ID][k]->value()), k)){
VGA[ID][k]->setStyleSheet(""); VGA[ID][k]->setStyleSheet("");
sendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
}else{ }else{
VGA[ID][k]->setStyleSheet("color:red;"); VGA[ID][k]->setStyleSheet("color:red;");
sendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
} }
}); });
} }
@ -541,7 +536,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
int rowID = 0; int rowID = 0;
{//*--------- Group 1 {//*--------- Group 1
QGroupBox * box1 = new QGroupBox("Input Settings", tab); box1 = new QGroupBox("Input Settings", tab);
allLayout->addWidget(box1); allLayout->addWidget(box1);
QGridLayout * layout1 = new QGridLayout(box1); QGridLayout * layout1 = new QGridLayout(box1);
@ -572,7 +567,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
} }
{//*--------- Group 3 {//*--------- Group 3
QGroupBox * box3 = new QGroupBox("Trap. Settings", tab); box3 = new QGroupBox("Trap. Settings", tab);
allLayout->addWidget(box3); allLayout->addWidget(box3);
QGridLayout * layout3 = new QGridLayout(box3); QGridLayout * layout3 = new QGridLayout(box3);
@ -597,7 +592,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
} }
{//*--------- Group 4 {//*--------- Group 4
QGroupBox * box4 = new QGroupBox("Probe Settings", tab); box4 = new QGroupBox("Probe Settings", tab);
allLayout->addWidget(box4); allLayout->addWidget(box4);
QGridLayout * layout4 = new QGridLayout(box4); QGridLayout * layout4 = new QGridLayout(box4);
@ -619,7 +614,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
} }
{//*--------- Group 5 {//*--------- Group 5
QGroupBox * box5 = new QGroupBox("Trigger Settings", tab); box5 = new QGroupBox("Trigger Settings", tab);
allLayout->addWidget(box5); allLayout->addWidget(box5);
QGridLayout * layout5 = new QGridLayout(box5); QGridLayout * layout5 = new QGridLayout(box5);
@ -647,7 +642,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
} }
{//*--------- Group 6 {//*--------- Group 6
QGroupBox * box6 = new QGroupBox("Other Settings", tab); box6 = new QGroupBox("Other Settings", tab);
allLayout->addWidget(box6); allLayout->addWidget(box6);
QGridLayout * layout6 = new QGridLayout(box6); QGridLayout * layout6 = new QGridLayout(box6);
@ -708,7 +703,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
{//@============== input tab {//@============== input tab
QTabWidget * inputTab = new QTabWidget(tab); inputTab = new QTabWidget(tab);
chTabWidget->addTab(inputTab, "Input"); chTabWidget->addTab(inputTab, "Input");
SetupComboBoxTab(cbbOnOff, DIGIPARA::CH::ChannelEnable, "On/Off", inputTab, iDigi, digi[iDigi]->GetNChannels()); SetupComboBoxTab(cbbOnOff, DIGIPARA::CH::ChannelEnable, "On/Off", inputTab, iDigi, digi[iDigi]->GetNChannels());
@ -725,18 +720,19 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
SetupComboBoxTab(cbbWaveSave, DIGIPARA::CH::WaveSaving, "Wave Save", inputTab, iDigi, digi[iDigi]->GetNChannels()); SetupComboBoxTab(cbbWaveSave, DIGIPARA::CH::WaveSaving, "Wave Save", inputTab, iDigi, digi[iDigi]->GetNChannels());
for( int ch = 0; ch < digi[iDigi]->GetNChannels(); ch++){ for( int ch = 0; ch < digi[iDigi]->GetNChannels(); ch++){
//Set color of some combox
cbbOnOff[iDigi][ch]->setItemData(1, QBrush(Qt::green), Qt::ForegroundRole); cbbOnOff[iDigi][ch]->setItemData(1, QBrush(Qt::green), Qt::ForegroundRole);
connect(cbbOnOff[iDigi][ch], &RComboBox::currentIndexChanged, this, [=](int index){ cbbOnOff[ID][ch]->setStyleSheet(index == 1 ? "color : green;" : "");}); connect(cbbOnOff[iDigi][ch], &RComboBox::currentIndexChanged, this, [=](int index){ cbbOnOff[ID][ch]->setStyleSheet(index == 1 ? "" : "color : green;");});
cbbParity[iDigi][ch]->setItemData(1, QBrush(Qt::green), Qt::ForegroundRole); cbbParity[iDigi][ch]->setItemData(1, QBrush(Qt::green), Qt::ForegroundRole);
connect(cbbParity[iDigi][ch], &RComboBox::currentIndexChanged, this, [=](int index){ cbbParity[ID][ch]->setStyleSheet(index == 1 ? "color : green;" : "");}); connect(cbbParity[iDigi][ch], &RComboBox::currentIndexChanged, this, [=](int index){ cbbParity[ID][ch]->setStyleSheet(index == 1 ? "" : "color : green;");});
cbbLowFilter[iDigi][ch]->setItemData(1, QBrush(Qt::green), Qt::ForegroundRole); cbbLowFilter[iDigi][ch]->setItemData(1, QBrush(Qt::green), Qt::ForegroundRole);
connect(cbbLowFilter[iDigi][ch], &RComboBox::currentIndexChanged, this, [=](int index){ cbbLowFilter[ID][ch]->setStyleSheet(index == 1 ? "color : green;" : "");}); connect(cbbLowFilter[iDigi][ch], &RComboBox::currentIndexChanged, this, [=](int index){ cbbLowFilter[ID][ch]->setStyleSheet(index == 1 ? "" : "color : green;");});
} }
} }
{//@============== Trap tab {//@============== Trap tab
QTabWidget * trapTab = new QTabWidget(tab); trapTab = new QTabWidget(tab);
chTabWidget->addTab(trapTab, "Trapezoid"); chTabWidget->addTab(trapTab, "Trapezoid");
SetupSpinBoxTab(spbTrapRiseTime, DIGIPARA::CH::EnergyFilterRiseTime, "Trap. Rise Time [ns]", trapTab, iDigi, digi[iDigi]->GetNChannels()); SetupSpinBoxTab(spbTrapRiseTime, DIGIPARA::CH::EnergyFilterRiseTime, "Trap. Rise Time [ns]", trapTab, iDigi, digi[iDigi]->GetNChannels());
@ -751,7 +747,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
} }
{//@============== Probe tab {//@============== Probe tab
QTabWidget * probeTab = new QTabWidget(tab); probeTab = new QTabWidget(tab);
chTabWidget->addTab(probeTab, "Probe"); chTabWidget->addTab(probeTab, "Probe");
SetupComboBoxTab(cbbAnaProbe0, DIGIPARA::CH::WaveAnalogProbe0, "Analog Prob. 0", probeTab, iDigi, digi[iDigi]->GetNChannels(), 4); SetupComboBoxTab(cbbAnaProbe0, DIGIPARA::CH::WaveAnalogProbe0, "Analog Prob. 0", probeTab, iDigi, digi[iDigi]->GetNChannels(), 4);
@ -763,7 +759,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
} }
{//@============== Other tab {//@============== Other tab
QTabWidget * otherTab = new QTabWidget(tab); otherTab = new QTabWidget(tab);
chTabWidget->addTab(otherTab, "Others"); chTabWidget->addTab(otherTab, "Others");
SetupComboBoxTab(cbbEventSelector, DIGIPARA::CH::EventSelector, "Event Selector", otherTab, iDigi, digi[iDigi]->GetNChannels()); SetupComboBoxTab(cbbEventSelector, DIGIPARA::CH::EventSelector, "Event Selector", otherTab, iDigi, digi[iDigi]->GetNChannels());
@ -774,7 +770,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
{//@============== Trigger tab {//@============== Trigger tab
QTabWidget * triggerTab = new QTabWidget(tab); triggerTab = new QTabWidget(tab);
chTabWidget->addTab(triggerTab, "Trigger"); chTabWidget->addTab(triggerTab, "Trigger");
SetupComboBoxTab(cbbEvtTrigger, DIGIPARA::CH::EventTriggerSource, "Event Trig. Source", triggerTab, iDigi, digi[iDigi]->GetNChannels(), 2); SetupComboBoxTab(cbbEvtTrigger, DIGIPARA::CH::EventTriggerSource, "Event Trig. Source", triggerTab, iDigi, digi[iDigi]->GetNChannels(), 2);
@ -786,7 +782,36 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
SetupSpinBoxTab(spbADCVetoWidth, DIGIPARA::CH::ADCVetoWidth, "ADC Veto Length [ns]", triggerTab, iDigi, digi[iDigi]->GetNChannels()); SetupSpinBoxTab(spbADCVetoWidth, DIGIPARA::CH::ADCVetoWidth, "ADC Veto Length [ns]", triggerTab, iDigi, digi[iDigi]->GetNChannels());
} }
for( int ch = 0; ch < digi[ID]->GetNChannels() + 1; ch++) { for( int ch = 0; ch < digi[ID]->GetNChannels() + 1; ch++) {
//send UpdateScopeSetting signal
connect(spbDCOffset[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(spbRecordLength[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(spbPreTrigger[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(spbThreshold[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(spbTrapRiseTime[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(spbTrapFlatTop[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(spbTrapPoleZero[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(spbPeaking[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(spbTriggerGuard[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(spbTrapRiseTime[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(spbFineGain[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(spbBaselineGuard[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(spbPileupGuard[iDigi][ch], &RSpinBox::returnPressed, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(cbbParity[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(cbbWaveRes[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(cbbPeakingAvg[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(cbbLowFilter[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(cbbBaselineAvg[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(cbbAnaProbe0[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(cbbAnaProbe1[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(cbbDigProbe0[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(cbbDigProbe1[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(cbbDigProbe2[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting);
connect(cbbDigProbe3[iDigi][ch], &RComboBox::currentIndexChanged, this, &DigiSettingsPanel::UpdateScopeSetting);
//----- SyncBox
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);});
connect(spbThreshold[iDigi][ch], &RSpinBox::returnPressed, this, [=](){ SyncSpinBox(spbThreshold, ch);}); connect(spbThreshold[iDigi][ch], &RSpinBox::returnPressed, this, [=](){ SyncSpinBox(spbThreshold, ch);});
@ -838,7 +863,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
{//@============== Trigger Mask/Map tab {//@============== Trigger Mask/Map tab
//TODO========================== //TODO==========================
QTabWidget * triggerMapTab = new QTabWidget(tab); triggerMapTab = new QTabWidget(tab);
chTabWidget->addTab(triggerMapTab, "Trigger Map"); chTabWidget->addTab(triggerMapTab, "Trigger Map");
QGridLayout * triggerLayout = new QGridLayout(triggerMapTab); QGridLayout * triggerLayout = new QGridLayout(triggerMapTab);
@ -901,6 +926,10 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
enableSignalSlot = true; enableSignalSlot = true;
show();
EnableControl();
} }
DigiSettingsPanel::~DigiSettingsPanel(){ DigiSettingsPanel::~DigiSettingsPanel(){
@ -934,6 +963,49 @@ void DigiSettingsPanel::RefreshSettings(){
ShowSettingsToPanel(); ShowSettingsToPanel();
} }
void DigiSettingsPanel::EnableControl(){
bool enable = !digi[ID]->IsAcqOn();
digiBox->setEnabled(enable);
if( digi[ID]->GetFPGATyep() == "DPP_PHA") VGABox->setEnabled(enable);
if( ckbGlbTrgSource[ID][3]->isChecked() ) testPulseBox->setEnabled(enable);
box1->setEnabled(enable);
box3->setEnabled(enable);
box4->setEnabled(enable);
box5->setEnabled(enable);
box6->setEnabled(enable);
for( int i = 0; i < nDigi; i++){
bnReadSettngs[i]->setEnabled(enable);
bnResetBd[i]->setEnabled(enable);
bnDefaultSetting[i]->setEnabled(enable);
bnSaveSettings[i]->setEnabled(enable);
bnLoadSettings[i]->setEnabled(enable);
bnClearData[i]->setEnabled(enable);
bnArmACQ[i]->setEnabled(enable);
bnDisarmACQ[i]->setEnabled(enable);
bnSoftwareStart[i]->setEnabled(enable);
bnSoftwareStop[i]->setEnabled(enable);
}
QVector<QTabWidget*> tempArray = {inputTab, trapTab, probeTab, otherTab, triggerTab };
for( int k = 0; k < tempArray.size(); k++){
for( int i = 0; i < tempArray[k]->count(); i++) {
QWidget* currentTab = tempArray[k]->widget(i);
if( currentTab ){
QList<QWidget*> childWidgets = currentTab->findChildren<QWidget*>();
for(int j=0; j<childWidgets.count(); j++) {
childWidgets[j]->setEnabled(enable);
}
}
}
}
triggerMapTab->setEnabled(enable);
}
void DigiSettingsPanel::SaveSettings(){ void DigiSettingsPanel::SaveSettings(){
//TODO default file Path //TODO default file Path
@ -950,16 +1022,16 @@ void DigiSettingsPanel::SaveSettings(){
switch (flag) { switch (flag) {
case 1 : { case 1 : {
leSettingFile[ID]->setText(filePath); leSettingFile[ID]->setText(filePath);
sendLogMsg("Saved setting file <b>" + filePath + "</b>."); SendLogMsg("Saved setting file <b>" + filePath + "</b>.");
}; break; }; break;
case 0 : { case 0 : {
leSettingFile[ID]->setText("fail to write setting file."); leSettingFile[ID]->setText("fail to write setting file.");
sendLogMsg("<font style=\"color:red;\"> Fail to write setting file.</font>"); SendLogMsg("<font style=\"color:red;\"> Fail to write setting file.</font>");
}; break; }; break;
case -1 : { case -1 : {
leSettingFile[ID]->setText("fail to save setting file, same settings are empty."); leSettingFile[ID]->setText("fail to save setting file, same settings are empty.");
sendLogMsg("<font style=\"color:red;\"> Fail to save setting file, same settings are empty.</font>"); SendLogMsg("<font style=\"color:red;\"> Fail to save setting file, same settings are empty.</font>");
}; break; }; break;
}; };
@ -979,9 +1051,9 @@ void DigiSettingsPanel::LoadSettings(){
//TODO ==== check is the file valid; //TODO ==== check is the file valid;
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()));
}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()));
} }
ShowSettingsToPanel(); ShowSettingsToPanel();
@ -991,6 +1063,8 @@ void DigiSettingsPanel::ShowSettingsToPanel(){
enableSignalSlot = false; enableSignalSlot = false;
printf("%s\n", __func__);
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)));
} }
@ -1171,7 +1245,6 @@ void DigiSettingsPanel::ShowSettingsToPanel(){
SyncSpinBox(spbCoinLength , -1); SyncSpinBox(spbCoinLength , -1);
SyncSpinBox(spbADCVetoWidth , -1); SyncSpinBox(spbADCVetoWidth , -1);
} }
//^########################################################################### //^###########################################################################
@ -1191,7 +1264,7 @@ void DigiSettingsPanel::SetStartSource(){
QString msg; QString msg;
msg = QString::fromStdString(DIGIPARA::DIG::StartSource.GetPara()) + "|DIG:"+ QString::number(digi[ID]->GetSerialNumber()); msg = QString::fromStdString(DIGIPARA::DIG::StartSource.GetPara()) + "|DIG:"+ QString::number(digi[ID]->GetSerialNumber());
msg += " = " + QString::fromStdString(value); msg += " = " + QString::fromStdString(value);
sendLogMsg(msg); SendLogMsg(msg);
digi[ID]->WriteValue(DIGIPARA::DIG::StartSource, value); digi[ID]->WriteValue(DIGIPARA::DIG::StartSource, value);
} }
@ -1214,7 +1287,7 @@ void DigiSettingsPanel::SetGlobalTriggerSource(){
QString msg; QString msg;
msg = QString::fromStdString(DIGIPARA::DIG::GlobalTriggerSource.GetPara()) + "|DIG:"+ QString::number(digi[ID]->GetSerialNumber()); msg = QString::fromStdString(DIGIPARA::DIG::GlobalTriggerSource.GetPara()) + "|DIG:"+ QString::number(digi[ID]->GetSerialNumber());
msg += " = " + QString::fromStdString(value); msg += " = " + QString::fromStdString(value);
sendLogMsg(msg); SendLogMsg(msg);
digi[ID]->WriteValue(DIGIPARA::DIG::GlobalTriggerSource, value); digi[ID]->WriteValue(DIGIPARA::DIG::GlobalTriggerSource, value);
@ -1247,10 +1320,10 @@ void DigiSettingsPanel::SetupComboBox(RComboBox *&cbb, const Reg para, int ch_in
if( para.GetType() == TYPE::VGA ) msg += ",VGA:" + QString::number(ch_index); if( para.GetType() == TYPE::VGA ) msg += ",VGA:" + QString::number(ch_index);
msg += " = " + cbb->currentData().toString(); msg += " = " + cbb->currentData().toString();
if( digi[ID]->WriteValue(para, cbb->currentData().toString().toStdString(), ch_index)){ if( digi[ID]->WriteValue(para, cbb->currentData().toString().toStdString(), ch_index)){
sendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
cbb->setStyleSheet(""); cbb->setStyleSheet("");
}else{ }else{
sendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
cbb->setStyleSheet("color:red;"); cbb->setStyleSheet("color:red;");
} }
}); });
@ -1290,10 +1363,10 @@ void DigiSettingsPanel::SetupSpinBox(RSpinBox *&spb, const Reg para, int ch_inde
if( para.GetType() == TYPE::CH ) msg += ",CH:" + (ch_index == -1 ? "All" : QString::number(ch_index)); if( para.GetType() == TYPE::CH ) msg += ",CH:" + (ch_index == -1 ? "All" : QString::number(ch_index));
msg += " = " + QString::number(spb->value()); msg += " = " + QString::number(spb->value());
if( digi[ID]->WriteValue(para, std::to_string(spb->value()), ch_index)){ if( digi[ID]->WriteValue(para, std::to_string(spb->value()), ch_index)){
sendLogMsg(msg + "|OK."); SendLogMsg(msg + "|OK.");
spb->setStyleSheet(""); spb->setStyleSheet("");
}else{ }else{
sendLogMsg(msg + "|Fail."); SendLogMsg(msg + "|Fail.");
spb->setStyleSheet("color:red;"); spb->setStyleSheet("color:red;");
} }
}); });

View File

@ -16,43 +16,13 @@
#include <QPushButton> #include <QPushButton>
#include <QFrame> #include <QFrame>
#include <QSignalMapper> #include <QSignalMapper>
#include <QWheelEvent>
#include "ClassDigitizer2Gen.h" #include "ClassDigitizer2Gen.h"
#include "CustomWidgets.h"
#define MaxNumberOfDigitizer 20 #define MaxNumberOfDigitizer 20
class RComboBox : public QComboBox{
public :
RComboBox(QWidget * parent = nullptr): QComboBox(parent){
setFocusPolicy(Qt::StrongFocus);
}
protected:
void wheelEvent(QWheelEvent * event) override{ event->ignore(); }
};
class RSpinBox : public QDoubleSpinBox{
Q_OBJECT
public :
RSpinBox(QWidget * parent = nullptr, int decimal = 0): QDoubleSpinBox(parent){
setFocusPolicy(Qt::StrongFocus);
setDecimals(decimal);
}
signals:
void returnPressed();
protected:
void wheelEvent(QWheelEvent * event) override{ event->ignore(); }
void keyPressEvent(QKeyEvent * event) override{
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
emit returnPressed();
} else {
QDoubleSpinBox::keyPressEvent(event);
}
}
};
//^####################################################### //^#######################################################
class DigiSettingsPanel : public QWidget{ class DigiSettingsPanel : public QWidget{
Q_OBJECT Q_OBJECT
@ -62,17 +32,20 @@ public:
~DigiSettingsPanel(); ~DigiSettingsPanel();
private slots: private slots:
void onTriggerClick(int haha); void onTriggerClick(int haha);
void RefreshSettings();
void SaveSettings(); void SaveSettings();
void LoadSettings(); void LoadSettings();
void RefreshSettings(); // this read digitizer and ShowSettingToPanel
public slots:
void ShowSettingsToPanel();
void EnableControl();
signals: signals:
void sendLogMsg(const QString &msg); void SendLogMsg(const QString &msg);
void UpdateScopeSetting();
private: private:
@ -80,7 +53,23 @@ private:
unsigned short nDigi; unsigned short nDigi;
unsigned short ID; // index for digitizer; unsigned short ID; // index for digitizer;
void ShowSettingsToPanel(); //------------ Layout/GroupBox
QGroupBox * digiBox;
QGroupBox * VGABox;
QGroupBox * testPulseBox;
QGroupBox * box1;
QGroupBox * box3;
QGroupBox * box4;
QGroupBox * box5;
QGroupBox * box6;
QTabWidget * inputTab;
QTabWidget * trapTab;
QTabWidget * probeTab;
QTabWidget * otherTab;
QTabWidget * triggerTab;
QTabWidget * triggerMapTab;
bool enableSignalSlot; bool enableSignalSlot;
@ -90,6 +79,18 @@ private:
QPushButton * ACQStatus[MaxNumberOfDigitizer][19]; QPushButton * ACQStatus[MaxNumberOfDigitizer][19];
QLineEdit * leTemp[MaxNumberOfDigitizer][8]; QLineEdit * leTemp[MaxNumberOfDigitizer][8];
//------------- buttons
QPushButton * bnReadSettngs[MaxNumberOfChannel];
QPushButton * bnResetBd[MaxNumberOfChannel];
QPushButton * bnDefaultSetting[MaxNumberOfChannel];
QPushButton * bnSaveSettings[MaxNumberOfChannel];
QPushButton * bnLoadSettings[MaxNumberOfChannel];
QPushButton * bnClearData[MaxNumberOfChannel];
QPushButton * bnArmACQ[MaxNumberOfChannel];
QPushButton * bnDisarmACQ[MaxNumberOfChannel];
QPushButton * bnSoftwareStart[MaxNumberOfChannel];
QPushButton * bnSoftwareStop[MaxNumberOfChannel];
//-------------- board settings //-------------- board settings
RComboBox * cbbClockSource[MaxNumberOfDigitizer]; RComboBox * cbbClockSource[MaxNumberOfDigitizer];
QCheckBox * ckbStartSource[MaxNumberOfDigitizer][5]; QCheckBox * ckbStartSource[MaxNumberOfDigitizer][5];
@ -109,14 +110,12 @@ private:
RSpinBox * dsbClockOutDelay[MaxNumberOfDigitizer]; RSpinBox * dsbClockOutDelay[MaxNumberOfDigitizer];
//-------------- Test pulse //-------------- Test pulse
QGroupBox * testPulseBox;
RSpinBox * dsbTestPuslePeriod[MaxNumberOfDigitizer]; RSpinBox * dsbTestPuslePeriod[MaxNumberOfDigitizer];
RSpinBox * dsbTestPusleWidth[MaxNumberOfDigitizer]; RSpinBox * dsbTestPusleWidth[MaxNumberOfDigitizer];
RSpinBox * spbTestPusleLowLevel[MaxNumberOfDigitizer]; RSpinBox * spbTestPusleLowLevel[MaxNumberOfDigitizer];
RSpinBox * spbTestPusleHighLevel[MaxNumberOfDigitizer]; RSpinBox * spbTestPusleHighLevel[MaxNumberOfDigitizer];
//-------------- VGA //-------------- VGA
QGroupBox * VGABox;
RSpinBox * VGA[MaxNumberOfDigitizer][4]; RSpinBox * VGA[MaxNumberOfDigitizer][4];
//--------------- trigger map //--------------- trigger map
@ -202,9 +201,6 @@ private:
void FillComboBoxValueFromMemory(RComboBox * &cbb, const Reg para, int ch_index = -1); void FillComboBoxValueFromMemory(RComboBox * &cbb, const Reg para, int ch_index = -1);
void FillSpinBoxValueFromMemory(RSpinBox * &spb, const Reg para, int ch_index = -1 ); void FillSpinBoxValueFromMemory(RSpinBox * &spb, const Reg para, int ch_index = -1 );
}; };

View File

@ -56,6 +56,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
scalarLayout = new QGridLayout(layoutWidget); scalarLayout = new QGridLayout(layoutWidget);
scalarLayout->setSpacing(0); scalarLayout->setSpacing(0);
scalarLayout->setAlignment(Qt::AlignTop);
leTrigger = NULL; leTrigger = NULL;
leAccept = NULL; leAccept = NULL;
@ -357,6 +358,8 @@ void MainWindow::StartACQ(){
chkSaveRun->setEnabled(false); chkSaveRun->setEnabled(false);
cbAutoRun->setEnabled(false); cbAutoRun->setEnabled(false);
if( digiSetting ) digiSetting->EnableControl();
//TODO ======= Auto Run //TODO ======= Auto Run
if( cbAutoRun->currentIndex() > 0 ){ if( cbAutoRun->currentIndex() > 0 ){
int timeMinite = cbAutoRun->currentData().toInt(); int timeMinite = cbAutoRun->currentData().toInt();
@ -430,6 +433,8 @@ void MainWindow::StopACQ(){
bnOpenScope->setEnabled(true); bnOpenScope->setEnabled(true);
chkSaveRun->setEnabled(true); chkSaveRun->setEnabled(true);
if( digiSetting ) digiSetting->EnableControl();
if( chkSaveRun->isChecked() ){ if( chkSaveRun->isChecked() ){
//TODO ============= elog //TODO ============= elog
QString msg = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.z") + "<br />"; QString msg = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.z") + "<br />";
@ -590,6 +595,14 @@ 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);
if( digiSetting ) {
connect(scope, &Scope::UpdateSettingsPanel, digiSetting, &DigiSettingsPanel::ShowSettingsToPanel);
connect(scope, &Scope::TellSettingsPanelControlOnOff, digiSetting, &DigiSettingsPanel::EnableControl);
connect(digiSetting, &DigiSettingsPanel::UpdateScopeSetting, scope, &Scope::ReadScopeSettings);
digiSetting->EnableControl();
}
}else{ }else{
scope->show(); scope->show();
} }
@ -604,8 +617,14 @@ 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);
digiSetting->show();
if( scope ) {
connect(scope, &Scope::UpdateSettingsPanel, digiSetting, &DigiSettingsPanel::ShowSettingsToPanel);
connect(scope, &Scope::TellSettingsPanelControlOnOff, digiSetting, &DigiSettingsPanel::EnableControl);
connect(digiSetting, &DigiSettingsPanel::UpdateScopeSetting, scope, &Scope::ReadScopeSettings);
}
}else{ }else{
digiSetting->show(); digiSetting->show();
} }

236
scope.cpp
View File

@ -62,12 +62,12 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
//------------ Digitizer + channel selection //------------ Digitizer + channel selection
rowID ++; rowID ++;
cbScopeDigi = new QComboBox(this); cbScopeDigi = new RComboBox(this);
cbScopeCh = new QComboBox(this); cbScopeCh = new RComboBox(this);
layout->addWidget(cbScopeDigi, rowID, 0); layout->addWidget(cbScopeDigi, rowID, 0);
layout->addWidget(cbScopeCh, rowID, 1); layout->addWidget(cbScopeCh, rowID, 1);
connect(cbScopeDigi, &QComboBox::currentIndexChanged, this, [=](){ connect(cbScopeDigi, &RComboBox::currentIndexChanged, this, [=](){
//if( allowChange ) StopScope(); //if( allowChange ) StopScope();
int index = cbScopeDigi->currentIndex(); int index = cbScopeDigi->currentIndex();
if( index == -1 ) return; if( index == -1 ) return;
@ -77,19 +77,20 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
//if( allowChange )StartScope(index); //if( allowChange )StartScope(index);
}); });
connect(cbScopeCh, &QComboBox::currentIndexChanged, this, [=](){ connect(cbScopeCh, &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex(); int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
digiMTX.lock(); digiMTX.lock();
digi[iDigi]->WriteValue(DIGIPARA::CH::ChannelEnable, "false", -1); digi[iDigi]->WriteValue(DIGIPARA::CH::ChannelEnable, "False", -1);
digi[iDigi]->WriteValue(DIGIPARA::CH::ChannelEnable, "true", ch); digi[iDigi]->WriteValue(DIGIPARA::CH::ChannelEnable, "True", ch);
ReadScopeSettings(iDigi, ch); ReadScopeSettings();
UpdateSettingsPanel();
digiMTX.unlock(); digiMTX.unlock();
}); });
allowChange = false; allowChange = false;
cbScopeDigi->clear(); ///this will also trigger QComboBox::currentIndexChanged cbScopeDigi->clear(); ///this will also trigger RComboBox::currentIndexChanged
cbScopeCh->clear(); cbScopeCh->clear();
for( unsigned int i = 0 ; i < nDigi; i++) { for( unsigned int i = 0 ; i < nDigi; i++) {
cbScopeDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i); cbScopeDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
@ -110,7 +111,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
layout->addWidget(bnScopeReadSettings, rowID, 3); layout->addWidget(bnScopeReadSettings, rowID, 3);
connect(bnScopeReadSettings, &QPushButton::clicked, this, [=](){ connect(bnScopeReadSettings, &QPushButton::clicked, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
ReadScopeSettings(cbScopeDigi->currentIndex(), cbScopeCh->currentIndex()); ReadScopeSettings();
}); });
//TODO----- add copy settings and paste settings //TODO----- add copy settings and paste settings
@ -121,24 +122,24 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
//------------ Probe selection //------------ Probe selection
rowID ++; rowID ++;
//TODO --- add None //TODO --- add None
cbAnaProbe[0] = new QComboBox(this); cbAnaProbe[0] = new RComboBox(this);
cbAnaProbe[0]->addItem("ADC Input", "ADCInput"); cbAnaProbe[0]->addItem("ADC Input", "ADCInput");
cbAnaProbe[0]->addItem("Time Filter", "TimeFilter"); cbAnaProbe[0]->addItem("Time Filter", "TimeFilter");
cbAnaProbe[0]->addItem("Trapazoid", "EnergyFilter"); cbAnaProbe[0]->addItem("Trapazoid", "EnergyFilter");
cbAnaProbe[0]->addItem("Trap. Baseline", "EnergyFilterBaseline"); cbAnaProbe[0]->addItem("Trap. Baseline", "EnergyFilterBaseline");
cbAnaProbe[0]->addItem("Trap. - Baseline", "EnergyFilterMinusBaseline"); cbAnaProbe[0]->addItem("Trap. - Baseline", "EnergyFilterMinusBaseline");
cbAnaProbe[1] = new QComboBox(this); cbAnaProbe[1] = new RComboBox(this);
for( int i = 0; i < cbAnaProbe[0]->count() ; i++) cbAnaProbe[1]->addItem(cbAnaProbe[0]->itemText(i), cbAnaProbe[0]->itemData(i)); for( int i = 0; i < cbAnaProbe[0]->count() ; i++) cbAnaProbe[1]->addItem(cbAnaProbe[0]->itemText(i), cbAnaProbe[0]->itemData(i));
connect(cbAnaProbe[0], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);}); connect(cbAnaProbe[0], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);});
connect(cbAnaProbe[1], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);}); connect(cbAnaProbe[1], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);});
cbAnaProbe[0]->setCurrentIndex(1); ///trigger the AnaProbeChange cbAnaProbe[0]->setCurrentIndex(1); ///trigger the AnaProbeChange
cbAnaProbe[0]->setCurrentIndex(0); cbAnaProbe[0]->setCurrentIndex(0);
cbAnaProbe[1]->setCurrentIndex(4); cbAnaProbe[1]->setCurrentIndex(4);
connect(cbAnaProbe[0], &QComboBox::currentIndexChanged, this, [=](){ connect(cbAnaProbe[0], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex(); int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
@ -147,7 +148,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
digiMTX.unlock(); digiMTX.unlock();
}); });
connect(cbAnaProbe[1], &QComboBox::currentIndexChanged, this, [=](){ connect(cbAnaProbe[1], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex(); int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
@ -157,7 +158,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
}); });
//TODO --- add None //TODO --- add None
cbDigProbe[0] = new QComboBox(this); cbDigProbe[0] = new RComboBox(this);
cbDigProbe[0]->addItem("Trigger", "Trigger"); cbDigProbe[0]->addItem("Trigger", "Trigger");
cbDigProbe[0]->addItem("Time Filter Armed", "TimeFilterArmed"); cbDigProbe[0]->addItem("Time Filter Armed", "TimeFilterArmed");
cbDigProbe[0]->addItem("ReTrigger Guard", "ReTriggerGuard"); cbDigProbe[0]->addItem("ReTrigger Guard", "ReTriggerGuard");
@ -172,19 +173,19 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
cbDigProbe[0]->addItem("Trap. Saturate", "EnergylterSaturation"); cbDigProbe[0]->addItem("Trap. Saturate", "EnergylterSaturation");
cbDigProbe[0]->addItem("ACQ Inhibit", "AcquisitionInhibit"); cbDigProbe[0]->addItem("ACQ Inhibit", "AcquisitionInhibit");
cbDigProbe[1] = new QComboBox(this); cbDigProbe[1] = new RComboBox(this);
cbDigProbe[2] = new QComboBox(this); cbDigProbe[2] = new RComboBox(this);
cbDigProbe[3] = new QComboBox(this); cbDigProbe[3] = new RComboBox(this);
for( int i = 0; i < cbDigProbe[0]->count() ; i++) { for( int i = 0; i < cbDigProbe[0]->count() ; i++) {
cbDigProbe[1]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i)); cbDigProbe[1]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i));
cbDigProbe[2]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i)); cbDigProbe[2]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i));
cbDigProbe[3]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i)); cbDigProbe[3]->addItem(cbDigProbe[0]->itemText(i), cbDigProbe[0]->itemData(i));
} }
connect(cbDigProbe[0], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);}); connect(cbDigProbe[0], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
connect(cbDigProbe[1], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);}); connect(cbDigProbe[1], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
connect(cbDigProbe[2], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);}); connect(cbDigProbe[2], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
connect(cbDigProbe[3], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);}); connect(cbDigProbe[3], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
cbDigProbe[0]->setCurrentIndex(1); ///trigger the DigProbeChange cbDigProbe[0]->setCurrentIndex(1); ///trigger the DigProbeChange
cbDigProbe[0]->setCurrentIndex(0); cbDigProbe[0]->setCurrentIndex(0);
@ -192,7 +193,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
cbDigProbe[2]->setCurrentIndex(5); cbDigProbe[2]->setCurrentIndex(5);
cbDigProbe[3]->setCurrentIndex(6); cbDigProbe[3]->setCurrentIndex(6);
connect(cbDigProbe[0], &QComboBox::currentIndexChanged, this, [=](){ connect(cbDigProbe[0], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex(); int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
@ -200,7 +201,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
digi[iDigi]->WriteValue(DIGIPARA::CH::WaveDigitalProbe0, (cbDigProbe[0]->currentData()).toString().toStdString(), ch); digi[iDigi]->WriteValue(DIGIPARA::CH::WaveDigitalProbe0, (cbDigProbe[0]->currentData()).toString().toStdString(), ch);
digiMTX.unlock(); digiMTX.unlock();
}); });
connect(cbDigProbe[1], &QComboBox::currentIndexChanged, this, [=](){ connect(cbDigProbe[1], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex(); int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
@ -208,7 +209,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
digi[iDigi]->WriteValue(DIGIPARA::CH::WaveDigitalProbe1, (cbDigProbe[1]->currentData()).toString().toStdString(), ch); digi[iDigi]->WriteValue(DIGIPARA::CH::WaveDigitalProbe1, (cbDigProbe[1]->currentData()).toString().toStdString(), ch);
digiMTX.unlock(); digiMTX.unlock();
}); });
connect(cbDigProbe[2], &QComboBox::currentIndexChanged, this, [=](){ connect(cbDigProbe[2], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex(); int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
@ -216,7 +217,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
digi[iDigi]->WriteValue(DIGIPARA::CH::WaveDigitalProbe2, (cbDigProbe[2]->currentData()).toString().toStdString(), ch); digi[iDigi]->WriteValue(DIGIPARA::CH::WaveDigitalProbe2, (cbDigProbe[2]->currentData()).toString().toStdString(), ch);
digiMTX.unlock(); digiMTX.unlock();
}); });
connect(cbDigProbe[3], &QComboBox::currentIndexChanged, this, [=](){ connect(cbDigProbe[3], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex(); int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
@ -233,6 +234,8 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
layout->addWidget(cbDigProbe[2], rowID, 4); layout->addWidget(cbDigProbe[2], rowID, 4);
layout->addWidget(cbDigProbe[3], rowID, 5); layout->addWidget(cbDigProbe[3], rowID, 5);
for( int i = 0; i < 6; i++) layout->setColumnStretch(i, 1);
rowID ++; rowID ++;
{//------------ wave settings {//------------ wave settings
QGroupBox * box = new QGroupBox("Channel Settings (need ACQ stop)", this); QGroupBox * box = new QGroupBox("Channel Settings (need ACQ stop)", this);
@ -241,81 +244,29 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
QGridLayout * bLayout = new QGridLayout(box); QGridLayout * bLayout = new QGridLayout(box);
bLayout->setSpacing(0); bLayout->setSpacing(0);
sbRL = new QSpinBox(this); ScopeMakeSpinBox(sbRL, "Record Lenght [ns] ", bLayout, 0, 0, DIGIPARA::CH::RecordLength);
ScopeMakeSpinBox(sbRL, "Record Lenght [ns] ", bLayout, 0, 0, 32, 648000, DIGIPARA::TraceStep, DIGIPARA::CH::RecordLength); ScopeMakeSpinBox(sbThreshold, "Threshold [LSB] ", bLayout, 0, 2, DIGIPARA::CH::TriggerThreshold);
sbThreshold = new QSpinBox(this);
ScopeMakeSpinBox(sbThreshold, "Threshold [LSB] ", bLayout, 0, 2, 0, 8191, -20, DIGIPARA::CH::TriggerThreshold);
cbPolarity = new QComboBox(this);
cbPolarity->addItem("Pos. +", "Positive");
cbPolarity->addItem("Neg. -", "Negative");
ScopeMakeComoBox(cbPolarity, "Polarity ", bLayout, 0, 4, DIGIPARA::CH::Polarity); ScopeMakeComoBox(cbPolarity, "Polarity ", bLayout, 0, 4, DIGIPARA::CH::Polarity);
cbWaveRes = new QComboBox(this);
cbWaveRes->addItem(" 8 ns", "RES8");
cbWaveRes->addItem("16 ns", "RES16");
cbWaveRes->addItem("32 ns", "RES32");
cbWaveRes->addItem("64 ns", "RES64");
ScopeMakeComoBox(cbWaveRes, "Wave Re. ", bLayout, 0, 6, DIGIPARA::CH::WaveResolution); ScopeMakeComoBox(cbWaveRes, "Wave Re. ", bLayout, 0, 6, DIGIPARA::CH::WaveResolution);
//------------------ next row //------------------ next row
sbPT = new QSpinBox(this); ScopeMakeSpinBox(sbPT, "Pre Trigger [ns] ", bLayout, 1, 0, DIGIPARA::CH::PreTrigger);
ScopeMakeSpinBox(sbPT, "Pre Trigger [ns] ", bLayout, 1, 0, 32, 32000, DIGIPARA::TraceStep, DIGIPARA::CH::PreTrigger); ScopeMakeSpinBox(sbDCOffset, "DC offset [%] ", bLayout, 1, 2, DIGIPARA::CH::DC_Offset);
ScopeMakeSpinBox(sbTimeRiseTime, "Trigger Rise Time [ns] ", bLayout, 1, 4, DIGIPARA::CH::TimeFilterRiseTime);
sbDCOffset = new QSpinBox(this); ScopeMakeSpinBox(sbTimeGuard, "Trigger Guard [ns] ", bLayout, 1, 6, DIGIPARA::CH::TimeFilterRetriggerGuard);
ScopeMakeSpinBox(sbDCOffset, "DC offset [%] ", bLayout, 1, 2, 0, 100, -10, DIGIPARA::CH::DC_Offset);
sbTimeRiseTime = new QSpinBox(this);
ScopeMakeSpinBox(sbTimeRiseTime, "Trigger Rise Time [ns] ", bLayout, 1, 4, 32, 2000, DIGIPARA::TraceStep, DIGIPARA::CH::TimeFilterRiseTime);
sbTimeGuard = new QSpinBox(this);
ScopeMakeSpinBox(sbTimeGuard, "Trigger Guard [ns] ", bLayout, 1, 6, 0, 8000, DIGIPARA::TraceStep, DIGIPARA::CH::TimeFilterRetriggerGuard);
//----------------- next row //----------------- next row
sbTrapRiseTime = new QSpinBox(this); ScopeMakeSpinBox(sbTrapRiseTime, "Trap. Rise Time [ns] ", bLayout, 2, 0, DIGIPARA::CH::EnergyFilterRiseTime);
ScopeMakeSpinBox(sbTrapRiseTime, "Trap. Rise Time [ns] ", bLayout, 2, 0, 32, 13000, DIGIPARA::TraceStep, DIGIPARA::CH::EnergyFilterRiseTime); ScopeMakeSpinBox(sbTrapFlatTop, "Trap. Flat Top [ns] ", bLayout, 2, 2, DIGIPARA::CH::EnergyFilterFlatTop);
ScopeMakeSpinBox(sbTrapPoleZero, "Trap. Pole Zero [ns] ", bLayout, 2, 4, DIGIPARA::CH::EnergyFilterPoleZero);
sbTrapFlatTop = new QSpinBox(this); ScopeMakeSpinBox(sbEnergyFineGain, "Energy Fine Gain ", bLayout, 2, 6, DIGIPARA::CH::EnergyFilterFineGain);
ScopeMakeSpinBox(sbTrapFlatTop, "Trap. Flat Top [ns] ", bLayout, 2, 2, 32, 3000, DIGIPARA::TraceStep, DIGIPARA::CH::EnergyFilterFlatTop);
sbTrapPoleZero = new QSpinBox(this);
ScopeMakeSpinBox(sbTrapPoleZero, "Trap. Pole Zero [ns] ", bLayout, 2, 4, 32, 524000, DIGIPARA::TraceStep, DIGIPARA::CH::EnergyFilterPoleZero);
sbEnergyFineGain = new QSpinBox(this);
ScopeMakeSpinBox(sbEnergyFineGain, "Energy Fine Gain ", bLayout, 2, 6, 1, 10, -1, DIGIPARA::CH::EnergyFilterFineGain);
//----------------- next row //----------------- next row
sbTrapPeaking = new QSpinBox(this); ScopeMakeSpinBox(sbTrapPeaking, "Trap. Peaking [%] ", bLayout, 3, 0, DIGIPARA::CH::EnergyFilterPeakingPosition);
ScopeMakeSpinBox(sbTrapPeaking, "Trap. Peaking [%] ", bLayout, 3, 0, 1, 100, -10, DIGIPARA::CH::EnergyFilterPeakingPosition);
cbTrapPeakAvg = new QComboBox(this);
cbTrapPeakAvg->addItem(" 1 sample", "OneShot");
cbTrapPeakAvg->addItem(" 4 sample", "LowAVG");
cbTrapPeakAvg->addItem("16 sample", "MediumAVG");
cbTrapPeakAvg->addItem("64 sample", "HighAVG");
ScopeMakeComoBox(cbTrapPeakAvg, "Trap. Peaking ", bLayout, 3, 2, DIGIPARA::CH::EnergyFilterPeakingAvg); ScopeMakeComoBox(cbTrapPeakAvg, "Trap. Peaking ", bLayout, 3, 2, DIGIPARA::CH::EnergyFilterPeakingAvg);
ScopeMakeSpinBox(sbBaselineGuard, "Baseline Guard [ns] ", bLayout, 3, 4, DIGIPARA::CH::EnergyFilterBaselineGuard);
sbBaselineGuard = new QSpinBox(this);
ScopeMakeSpinBox(sbBaselineGuard, "Baseline Guard [ns] ", bLayout, 3, 4, 0, 8000, DIGIPARA::TraceStep, DIGIPARA::CH::EnergyFilterBaselineGuard);
cbBaselineAvg = new QComboBox(this);
cbBaselineAvg->addItem(" 0 samp.", "Fixed");
cbBaselineAvg->addItem(" 16 samp.", "VeryLow");
cbBaselineAvg->addItem(" 64 samp.", "Low");
cbBaselineAvg->addItem(" 256 samp.", "MediumLow");
cbBaselineAvg->addItem(" 1024 samp.", "Medium");
cbBaselineAvg->addItem(" 4096 samp.", "MediumHigh");
cbBaselineAvg->addItem("16384 samp.", "High");
ScopeMakeComoBox(cbBaselineAvg, "Baseline Avg ", bLayout, 3, 6, DIGIPARA::CH::EnergyFilterBaselineAvg); ScopeMakeComoBox(cbBaselineAvg, "Baseline Avg ", bLayout, 3, 6, DIGIPARA::CH::EnergyFilterBaselineAvg);
//---------------- ScopeMakeSpinBox(sbPileUpGuard, "Pile-up Guard [ns] ", bLayout, 4, 0, DIGIPARA::CH::EnergyFilterPileUpGuard);
sbPileUpGuard = new QSpinBox(this);
ScopeMakeSpinBox(sbPileUpGuard, "Pile-up Guard [ns] ", bLayout, 4, 0, 0, 64000, DIGIPARA::TraceStep, DIGIPARA::CH::EnergyFilterPileUpGuard);
cbLowFreqFilter = new QComboBox(this);
cbLowFreqFilter->addItem("Disabled", "Off");
cbLowFreqFilter->addItem("Enabled", "On");
ScopeMakeComoBox(cbLowFreqFilter, "Low Freq. Filter ", bLayout, 4, 2, DIGIPARA::CH::EnergyFilterLowFreqFilter); ScopeMakeComoBox(cbLowFreqFilter, "Low Freq. Filter ", bLayout, 4, 2, DIGIPARA::CH::EnergyFilterLowFreqFilter);
} }
@ -336,7 +287,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
layout->addWidget(lbinfo, rowID, 5); layout->addWidget(lbinfo, rowID, 5);
rowID ++; rowID ++;
QLabel * lbinfo2 = new QLabel("Maximum time range is " + QString::number(MaxDisplayTraceDataLength * 8) + " ns due to processing speed.", this); QLabel * lbinfo2 = new QLabel("Maximum time range is " + QString::number(MaxDisplayTraceDataLength * DIGIPARA::TraceStep) + " ns due to processing speed.", this);
layout->addWidget(lbinfo2, rowID, 0, 1, 5); layout->addWidget(lbinfo2, rowID, 0, 1, 5);
@ -384,7 +335,11 @@ Scope::~Scope(){
} }
void Scope::ReadScopeSettings(int iDigi, int ch){ void Scope::ReadScopeSettings(){
int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex();
if( !digi[iDigi] && digi[iDigi]->IsDummy() ) return; if( !digi[iDigi] && digi[iDigi]->IsDummy() ) return;
printf("%s\n", __func__); printf("%s\n", __func__);
@ -437,7 +392,7 @@ void Scope::StartScope(){
//*---- set digitizer to take full trace; since in scope mode, no data saving, speed would be fast (How fast?) //*---- set digitizer to take full trace; since in scope mode, no data saving, speed would be fast (How fast?)
//* when the input rate is faster than trigger rate, Digitizer will stop data taking. //* when the input rate is faster than trigger rate, Digitizer will stop data taking.
ReadScopeSettings(iDigi, ch); ReadScopeSettings();
digi[iDigi]->WriteValue(DIGIPARA::CH::ChannelEnable, "false", -1); digi[iDigi]->WriteValue(DIGIPARA::CH::ChannelEnable, "false", -1);
digi[iDigi]->WriteValue(DIGIPARA::CH::ChannelEnable, "true", ch); digi[iDigi]->WriteValue(DIGIPARA::CH::ChannelEnable, "true", ch);
@ -451,6 +406,7 @@ void Scope::StartScope(){
updateTraceThread->start(); updateTraceThread->start();
ScopeControlOnOff(false); ScopeControlOnOff(false);
emit TellSettingsPanelControlOnOff();
allowChange = true; allowChange = true;
} }
@ -478,6 +434,8 @@ void Scope::StopScope(){
} }
ScopeControlOnOff(true); ScopeControlOnOff(true);
emit TellSettingsPanelControlOnOff();
allowChange = true; allowChange = true;
} }
@ -497,6 +455,12 @@ void Scope::UpdateScope(){
leTriggerRate->setText(QString::fromStdString(haha)); leTriggerRate->setText(QString::fromStdString(haha));
if( atoi(haha.c_str()) == 0 ) { if( atoi(haha.c_str()) == 0 ) {
digiMTX.unlock(); digiMTX.unlock();
for( int j = 0; j < 4; j++){
QVector<QPointF> points;
for( unsigned int i = 0 ; i < dataTrace[j]->count(); i++) points.append(QPointF(sample2ns * i , j > 1 ? 0 : (j+1)*1000));
dataTrace[j]->replace(points);
}
return; return;
} }
@ -519,7 +483,7 @@ void Scope::UpdateScope(){
} }
void Scope::ProbeChange(QComboBox * cb[], const int size ){ void Scope::ProbeChange(RComboBox * cb[], const int size ){
QStandardItemModel * model[size] = {NULL}; QStandardItemModel * model[size] = {NULL};
for( int i = 0; i < size; i++){ for( int i = 0; i < size; i++){
@ -578,12 +542,12 @@ void Scope::ScopeControlOnOff(bool on){
cbLowFreqFilter->setEnabled(on); cbLowFreqFilter->setEnabled(on);
} }
void Scope::ScopeReadSpinBoxValue(int iDigi, int ch, QSpinBox *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]->ReadValue(digPara, ch);
sb->setValue(atoi(ans.c_str())); sb->setValue(atoi(ans.c_str()));
} }
void Scope::ScopeReadComboBoxValue(int iDigi, int ch, QComboBox *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]->ReadValue(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()) {
@ -593,38 +557,80 @@ void Scope::ScopeReadComboBoxValue(int iDigi, int ch, QComboBox *cb, const Reg d
} }
} }
void Scope::ScopeMakeSpinBox(QSpinBox *sb, QString str, QGridLayout *layout, int row, int col, int min, int max, int step, const Reg digPara){ void Scope::ScopeMakeSpinBox(RSpinBox * &sb, QString str, QGridLayout *layout, int row, int col, const Reg digPara){
QLabel * lb = new QLabel(str, this); QLabel * lb = new QLabel(str, this);
lb->setAlignment(Qt::AlignRight | Qt::AlignCenter); lb->setAlignment(Qt::AlignRight | Qt::AlignCenter);
layout->addWidget(lb, row, col); layout->addWidget(lb, row, col);
sb->setMinimum(min); sb = new RSpinBox(this);
sb->setMaximum(max); sb->setMinimum(atof(digPara.GetAnswers()[0].first.c_str()));
sb->setSingleStep(abs(step)); sb->setMaximum(atof(digPara.GetAnswers()[1].first.c_str()));
sb->setSingleStep(atof(digPara.GetAnswers()[2].first.c_str()));
layout->addWidget(sb, row, col+1); layout->addWidget(sb, row, col+1);
connect(sb, &QSpinBox::valueChanged, this, [=](){ connect(sb, &RSpinBox::valueChanged, this, [=](){
if( !allowChange ) return;
sb->setStyleSheet("color:blue");
});
connect(sb, &RSpinBox::returnPressed, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex(); int iDigi = cbScopeDigi->currentIndex();
if( step > 1 ) sb->setValue(step*((sb->value() + step - 1)/step)); if( sb->decimals() == 0 && sb->singleStep() != 1) {
digiMTX.lock(); double step = sb->singleStep();
digi[iDigi]->WriteValue(digPara, std::to_string(sb->value()), cbScopeCh->currentIndex() ); double value = sb->value();
digiMTX.unlock(); sb->setValue( (std::round(value/step)*step));
});
//TODO digiSettingPanel update setting
} }
void Scope::ScopeMakeComoBox(QComboBox *cb, QString str, QGridLayout *layout, int row, int col, const Reg digPara){ int ch = cbScopeCh->currentIndex();
QString msg;
msg = QString::fromStdString(digPara.GetPara()) + "|DIG:"+ QString::number(digi[iDigi]->GetSerialNumber()) + ",CH:" + QString::number(ch);
msg += " = " + QString::number(sb->value());
if( digi[iDigi]->WriteValue(digPara, std::to_string(sb->value()), ch)){
SendLogMsg(msg + "|OK.");
sb->setStyleSheet("");
//TODO digiSettingPanel update setting
printf("UpdateSettingsPanel \n");
emit UpdateSettingsPanel();
}else{
SendLogMsg(msg + "|Fail.");
sb->setStyleSheet("color:red;");
}
});
}
void Scope::ScopeMakeComoBox(RComboBox * &cb, QString str, QGridLayout *layout, int row, int col, const Reg digPara){
QLabel * lb = new QLabel(str, this); QLabel * lb = new QLabel(str, this);
lb->setAlignment(Qt::AlignRight | Qt::AlignCenter); lb->setAlignment(Qt::AlignRight | Qt::AlignCenter);
layout->addWidget(lb, row, col); layout->addWidget(lb, row, col);
cb = new RComboBox(this);
for( int i = 0 ; i < (int) digPara.GetAnswers().size(); i++){
cb->addItem(QString::fromStdString((digPara.GetAnswers())[i].second), QString::fromStdString((digPara.GetAnswers())[i].first));
}
layout->addWidget(cb, row, col+1); layout->addWidget(cb, row, col+1);
connect(cb, &QComboBox::currentIndexChanged, this, [=](){
connect(cb, &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return; if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex(); int iDigi = cbScopeDigi->currentIndex();
digiMTX.lock(); int ch = cbScopeCh->currentIndex();
digi[iDigi]->WriteValue(digPara, cb->currentData().toString().toStdString(), cbScopeCh->currentIndex()); QString msg;
digiMTX.unlock(); msg = QString::fromStdString(digPara.GetPara()) + "|DIG:"+ QString::number(digi[iDigi]->GetSerialNumber()) + ",CH:" + QString::number(ch);
}); msg += " = " + cb->currentData().toString();
if( digi[iDigi]->WriteValue(digPara, cb->currentData().toString().toStdString(), ch)){
SendLogMsg(msg + "|OK.");
cb->setStyleSheet("");
//TODO digiSettingPanel update setting //TODO digiSettingPanel update setting
printf("UpdateSettingsPanel \n");
emit UpdateSettingsPanel();
}else{
SendLogMsg(msg + "|Fail.");
cb->setStyleSheet("color:red;");
}
});
} }

63
scope.h
View File

@ -18,6 +18,7 @@
#include "ClassDigitizer2Gen.h" #include "ClassDigitizer2Gen.h"
#include "manyThread.h" #include "manyThread.h"
#include "CustomWidgets.h"
class Trace : public QChart{ class Trace : public QChart{
public: public:
@ -97,7 +98,7 @@ private:
bool m_isTouching; bool m_isTouching;
}; };
//^=======================================
class Scope : public QMainWindow{ class Scope : public QMainWindow{
Q_OBJECT Q_OBJECT
@ -105,19 +106,19 @@ public:
Scope(Digitizer2Gen ** digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow * parent = nullptr); Scope(Digitizer2Gen ** digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow * parent = nullptr);
~Scope(); ~Scope();
public slots:
void ReadScopeSettings(); // read from digitizer and show;
private slots: private slots:
void ReadScopeSettings(int iDigi, int ch);
void StartScope(); void StartScope();
void StopScope(); void StopScope();
void UpdateScope(); void UpdateScope();
void ScopeControlOnOff(bool on); void ScopeControlOnOff(bool on);
void ScopeReadSpinBoxValue(int iDigi, int ch, QSpinBox *sb, const Reg digPara); void ScopeReadSpinBoxValue(int iDigi, int ch, RSpinBox *sb, const Reg digPara);
void ScopeReadComboBoxValue(int iDigi, int ch, QComboBox *cb, const Reg digPara); void ScopeReadComboBoxValue(int iDigi, int ch, RComboBox *cb, const Reg digPara);
void ScopeMakeSpinBox(QSpinBox * sb, QString str, QGridLayout* layout, int row, int col, int min, int max, int step, const Reg digPara); void ScopeMakeSpinBox(RSpinBox * &sb, QString str, QGridLayout* layout, int row, int col, const Reg digPara);
void ScopeMakeComoBox(QComboBox * cb, QString str, QGridLayout* layout, int row, int col, const Reg digPara); void ScopeMakeComoBox(RComboBox * &cb, QString str, QGridLayout* layout, int row, int col, const Reg digPara);
void ProbeChange(QComboBox * cb[], const int size); void ProbeChange(RComboBox * cb[], const int size);
void closeEvent(QCloseEvent * event){ void closeEvent(QCloseEvent * event){
StopScope(); StopScope();
@ -130,6 +131,8 @@ signals:
void CloseWindow(); void CloseWindow();
void SendLogMsg(const QString &msg); void SendLogMsg(const QString &msg);
void UpdateScalar(); void UpdateScalar();
void UpdateSettingsPanel();
void TellSettingsPanelControlOnOff();
private: private:
@ -141,8 +144,8 @@ private:
QChart * plot; QChart * plot;
QLineSeries * dataTrace[6]; QLineSeries * dataTrace[6];
QComboBox * cbScopeDigi; RComboBox * cbScopeDigi;
QComboBox * cbScopeCh; RComboBox * cbScopeCh;
QPushButton * bnScopeReset; QPushButton * bnScopeReset;
QPushButton * bnScopeReadSettings; QPushButton * bnScopeReadSettings;
@ -150,29 +153,29 @@ private:
QPushButton * bnScopeStart; QPushButton * bnScopeStart;
QPushButton * bnScopeStop; QPushButton * bnScopeStop;
QComboBox * cbAnaProbe[2]; RComboBox * cbAnaProbe[2];
QComboBox * cbDigProbe[4]; RComboBox * cbDigProbe[4];
QSpinBox * sbRL; // record length RSpinBox * sbRL; // record length
QSpinBox * sbPT; // pre trigger RSpinBox * sbPT; // pre trigger
QSpinBox * sbDCOffset; RSpinBox * sbDCOffset;
QSpinBox * sbThreshold; RSpinBox * sbThreshold;
QSpinBox * sbTimeRiseTime; RSpinBox * sbTimeRiseTime;
QSpinBox * sbTimeGuard; RSpinBox * sbTimeGuard;
QSpinBox * sbTrapRiseTime; RSpinBox * sbTrapRiseTime;
QSpinBox * sbTrapFlatTop; RSpinBox * sbTrapFlatTop;
QSpinBox * sbTrapPoleZero; RSpinBox * sbTrapPoleZero;
QSpinBox * sbEnergyFineGain; RSpinBox * sbEnergyFineGain;
QSpinBox * sbTrapPeaking; RSpinBox * sbTrapPeaking;
QComboBox * cbPolarity; RComboBox * cbPolarity;
QComboBox * cbWaveRes; RComboBox * cbWaveRes;
QComboBox * cbTrapPeakAvg; RComboBox * cbTrapPeakAvg;
QLineEdit * leTriggerRate; QLineEdit * leTriggerRate;
QSpinBox * sbBaselineGuard; RSpinBox * sbBaselineGuard;
QSpinBox * sbPileUpGuard; RSpinBox * sbPileUpGuard;
QComboBox * cbBaselineAvg; RComboBox * cbBaselineAvg;
QComboBox * cbLowFreqFilter; RComboBox * cbLowFreqFilter;
bool allowChange; bool allowChange;