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",
"qdatetime": "cpp",
"fstream": "cpp",
"allocator": "cpp"
"allocator": "cpp",
"qsignalmapper": "cpp"
},
"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());
ret = CAEN_FELib_SetValue(handle, parameter, value.c_str());
if (ret != CAEN_FELib_Success) {
printf("|%s||%s|\n", parameter, value.c_str());
printf("WriteError|%s||%s|\n", parameter, value.c_str());
ErrorMsg(__func__);
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
# 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

View File

@ -185,76 +185,71 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
//-------------------------------------
rowId ++;
QPushButton * bnReadSettngs = new QPushButton("Refresh Settings", tab);
bnLayout->addWidget(bnReadSettngs, rowId, 0, 1, 2);
connect(bnReadSettngs, &QPushButton::clicked, this, &DigiSettingsPanel::RefreshSettings);
bnReadSettngs[iDigi] = new QPushButton("Refresh Settings", tab);
bnLayout->addWidget(bnReadSettngs[iDigi], rowId, 0, 1, 2);
connect(bnReadSettngs[iDigi], &QPushButton::clicked, this, &DigiSettingsPanel::RefreshSettings);
QPushButton * bnResetBd = new QPushButton("Reset Board", tab);
bnLayout->addWidget(bnResetBd, rowId, 2, 1, 2);
connect(bnResetBd, &QPushButton::clicked, this, [=](){
sendLogMsg("Reset Digitizer-" + QString::number(digi[ID]->GetSerialNumber()));
bnResetBd[iDigi] = new QPushButton("Reset Board", tab);
bnLayout->addWidget(bnResetBd[iDigi], rowId, 2, 1, 2);
connect(bnResetBd[iDigi], &QPushButton::clicked, this, [=](){
SendLogMsg("Reset Digitizer-" + QString::number(digi[ID]->GetSerialNumber()));
digi[ID]->Reset();
});
QPushButton * bnDefaultSetting = new QPushButton("Set Default Settings", tab);
bnLayout->addWidget(bnDefaultSetting, rowId, 4, 1, 2);
connect(bnDefaultSetting, &QPushButton::clicked, this, [=](){
sendLogMsg("Program Digitizer-" + QString::number(digi[ID]->GetSerialNumber()) + " to default PHA.");
bnDefaultSetting[iDigi] = new QPushButton("Set Default Settings", tab);
bnLayout->addWidget(bnDefaultSetting[iDigi], rowId, 4, 1, 2);
connect(bnDefaultSetting[iDigi], &QPushButton::clicked, this, [=](){
SendLogMsg("Program Digitizer-" + QString::number(digi[ID]->GetSerialNumber()) + " to default PHA.");
digi[ID]->ProgramPHA();
});
QPushButton * bnSaveSettings = new QPushButton("Save Settings", tab);
bnLayout->addWidget(bnSaveSettings, rowId, 6, 1, 2);
connect(bnSaveSettings, &QPushButton::clicked, this, &DigiSettingsPanel::SaveSettings);
bnSaveSettings[iDigi] = new QPushButton("Save Settings", tab);
bnLayout->addWidget(bnSaveSettings[iDigi], rowId, 6, 1, 2);
connect(bnSaveSettings[iDigi], &QPushButton::clicked, this, &DigiSettingsPanel::SaveSettings);
QPushButton * bnLoadSettings = new QPushButton("Load Settings", tab);
bnLayout->addWidget(bnLoadSettings, rowId, 8, 1, 2);
connect(bnLoadSettings, &QPushButton::clicked, this, &DigiSettingsPanel::LoadSettings);
bnLoadSettings[iDigi] = new QPushButton("Load Settings", tab);
bnLayout->addWidget(bnLoadSettings[iDigi], rowId, 8, 1, 2);
connect(bnLoadSettings[iDigi], &QPushButton::clicked, this, &DigiSettingsPanel::LoadSettings);
//---------------------------------------
rowId ++;
QPushButton * bnClearData = new QPushButton("Clear Data", tab);
bnLayout->addWidget(bnClearData, rowId, 0, 1, 2);
connect(bnClearData, &QPushButton::clicked, this, [=](){
digi[ID]->SendCommand(DIGIPARA::DIG::ClearData); });
bnClearData[iDigi] = new QPushButton("Clear Data", tab);
bnLayout->addWidget(bnClearData[iDigi], rowId, 0, 1, 2);
connect(bnClearData[iDigi], &QPushButton::clicked, this, [=](){ digi[ID]->SendCommand(DIGIPARA::DIG::ClearData); });
QPushButton * bnArmACQ = new QPushButton("Arm ACQ", tab);
bnLayout->addWidget(bnArmACQ, rowId, 2, 1, 2);
connect(bnArmACQ, &QPushButton::clicked, this, [=](){
digi[ID]->SendCommand(DIGIPARA::DIG::ArmACQ); });
bnArmACQ[iDigi] = new QPushButton("Arm ACQ", tab);
bnLayout->addWidget(bnArmACQ[iDigi], rowId, 2, 1, 2);
connect(bnArmACQ[iDigi], &QPushButton::clicked, this, [=](){ digi[ID]->SendCommand(DIGIPARA::DIG::ArmACQ); });
QPushButton * bnDisarmACQ = new QPushButton("Disarm ACQ", tab);
bnLayout->addWidget(bnDisarmACQ, rowId, 4, 1, 2);
connect(bnDisarmACQ, &QPushButton::clicked, this, [=](){
digi[ID]->SendCommand(DIGIPARA::DIG::DisarmACQ); });
bnDisarmACQ[iDigi] = new QPushButton("Disarm ACQ", tab);
bnLayout->addWidget(bnDisarmACQ[iDigi], rowId, 4, 1, 2);
connect(bnDisarmACQ[iDigi], &QPushButton::clicked, this, [=](){ digi[ID]->SendCommand(DIGIPARA::DIG::DisarmACQ); });
QPushButton * bnSoftwareStart= new QPushButton("Software Start ACQ", tab);
bnLayout->addWidget(bnSoftwareStart, rowId, 6, 1, 2);
connect(bnSoftwareStart, &QPushButton::clicked, this, [=](){
digi[ID]->SendCommand(DIGIPARA::DIG::SoftwareStartACQ); });
bnSoftwareStart[iDigi] = new QPushButton("Software Start ACQ", tab);
bnLayout->addWidget(bnSoftwareStart[iDigi], rowId, 6, 1, 2);
connect(bnSoftwareStart[iDigi], &QPushButton::clicked, this, [=](){ digi[ID]->SendCommand(DIGIPARA::DIG::SoftwareStartACQ); });
QPushButton * bnSoftwareStop= new QPushButton("Software Stop ACQ", tab);
bnLayout->addWidget(bnSoftwareStop, rowId, 8, 1, 2);
connect(bnSoftwareStop, &QPushButton::clicked, this, [=](){
digi[ID]->SendCommand(DIGIPARA::DIG::SoftwareStopACQ); });
bnSoftwareStop[iDigi] = new QPushButton("Software Stop ACQ", tab);
bnLayout->addWidget(bnSoftwareStop[iDigi], rowId, 8, 1, 2);
connect(bnSoftwareStop[iDigi], &QPushButton::clicked, this, [=](){ digi[ID]->SendCommand(DIGIPARA::DIG::SoftwareStopACQ); });
//---------------
if( digi[iDigi]->IsDummy() ){
bnReadSettngs->setEnabled(false);
bnResetBd->setEnabled(false);
bnDefaultSetting->setEnabled(false);
bnClearData->setEnabled(false);
bnArmACQ->setEnabled(false);
bnDisarmACQ->setEnabled(false);
bnSoftwareStart->setEnabled(false);
bnSoftwareStop->setEnabled(false);
bnReadSettngs[iDigi]->setEnabled(false);
bnResetBd[iDigi]->setEnabled(false);
bnDefaultSetting[iDigi]->setEnabled(false);
bnClearData[iDigi]->setEnabled(false);
bnArmACQ[iDigi]->setEnabled(false);
bnDisarmACQ[iDigi]->setEnabled(false);
bnSoftwareStart[iDigi]->setEnabled(false);
bnSoftwareStop[iDigi]->setEnabled(false);
}
}
{//^====================== Group Board settings
QGroupBox * digiBox = new QGroupBox("Board Settings", tab);
digiBox = new QGroupBox("Board Settings", tab);
//digiBox->setSizePolicy(sizePolicy);
QGridLayout * boardLayout = new QGridLayout(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 += " = " + cbbAutoDisarmAcq[ID]->currentData().toString();
if( digi[ID]->WriteValue(DIGIPARA::DIG::EnableAutoDisarmACQ, cbbAutoDisarmAcq[ID]->currentData().toString().toStdString())){
sendLogMsg(msg + "|OK.");
SendLogMsg(msg + "|OK.");
cbbAutoDisarmAcq[ID]->setStyleSheet("");
}else{
sendLogMsg(msg + "|Fail.");
SendLogMsg(msg + "|Fail.");
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 += " = " + cbbStatEvents[ID]->currentData().toString();
if( digi[ID]->WriteValue(DIGIPARA::DIG::EnableStatisticEvents, cbbStatEvents[ID]->currentData().toString().toStdString()) ){
sendLogMsg(msg + "|OK.");
SendLogMsg(msg + "|OK.");
cbbStatEvents[ID]->setStyleSheet("");
}else{
sendLogMsg(msg + "|Fail.");
SendLogMsg(msg + "|Fail.");
cbbStatEvents[ID]->setStyleSheet("color:red");
}
});
@ -372,10 +367,10 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
msg += " = " + QString::number(dsbBdVetoWidth[iDigi]->value());
if( digi[ID]->WriteValue(DIGIPARA::DIG::BoardVetoWidth, std::to_string(dsbBdVetoWidth[iDigi]->value()), -1) ){
dsbBdVetoWidth[ID]->setStyleSheet("");
sendLogMsg(msg + "|OK.");
SendLogMsg(msg + "|OK.");
}else{
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());
if( digi[ID]->WriteValue(DIGIPARA::DIG::VolatileClockOutDelay, std::to_string(dsbVolatileClockOutDelay[ID]->value()), -1) ){
dsbVolatileClockOutDelay[ID]->setStyleSheet("");
sendLogMsg(msg + "|OK.");
SendLogMsg(msg + "|OK.");
}else{
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());
if( digi[ID]->WriteValue(DIGIPARA::DIG::PermanentClockOutDelay, std::to_string(dsbClockOutDelay[ID]->value()), -1) ){
dsbClockOutDelay[ID]->setStyleSheet("");
sendLogMsg(msg + "|OK.");
SendLogMsg(msg + "|OK.");
}else{
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());
if( digi[ID]->WriteValue(DIGIPARA::VGA::VGAGain, std::to_string(VGA[ID][k]->value()), k)){
VGA[ID][k]->setStyleSheet("");
sendLogMsg(msg + "|OK.");
SendLogMsg(msg + "|OK.");
}else{
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;
{//*--------- Group 1
QGroupBox * box1 = new QGroupBox("Input Settings", tab);
box1 = new QGroupBox("Input Settings", tab);
allLayout->addWidget(box1);
QGridLayout * layout1 = new QGridLayout(box1);
@ -572,7 +567,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
}
{//*--------- Group 3
QGroupBox * box3 = new QGroupBox("Trap. Settings", tab);
box3 = new QGroupBox("Trap. Settings", tab);
allLayout->addWidget(box3);
QGridLayout * layout3 = new QGridLayout(box3);
@ -597,7 +592,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
}
{//*--------- Group 4
QGroupBox * box4 = new QGroupBox("Probe Settings", tab);
box4 = new QGroupBox("Probe Settings", tab);
allLayout->addWidget(box4);
QGridLayout * layout4 = new QGridLayout(box4);
@ -619,7 +614,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
}
{//*--------- Group 5
QGroupBox * box5 = new QGroupBox("Trigger Settings", tab);
box5 = new QGroupBox("Trigger Settings", tab);
allLayout->addWidget(box5);
QGridLayout * layout5 = new QGridLayout(box5);
@ -647,7 +642,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
}
{//*--------- Group 6
QGroupBox * box6 = new QGroupBox("Other Settings", tab);
box6 = new QGroupBox("Other Settings", tab);
allLayout->addWidget(box6);
QGridLayout * layout6 = new QGridLayout(box6);
@ -708,7 +703,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
{//@============== input tab
QTabWidget * inputTab = new QTabWidget(tab);
inputTab = new QTabWidget(tab);
chTabWidget->addTab(inputTab, "Input");
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());
for( int ch = 0; ch < digi[iDigi]->GetNChannels(); ch++){
//Set color of some combox
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);
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);
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
QTabWidget * trapTab = new QTabWidget(tab);
trapTab = new QTabWidget(tab);
chTabWidget->addTab(trapTab, "Trapezoid");
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
QTabWidget * probeTab = new QTabWidget(tab);
probeTab = new QTabWidget(tab);
chTabWidget->addTab(probeTab, "Probe");
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
QTabWidget * otherTab = new QTabWidget(tab);
otherTab = new QTabWidget(tab);
chTabWidget->addTab(otherTab, "Others");
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
QTabWidget * triggerTab = new QTabWidget(tab);
triggerTab = new QTabWidget(tab);
chTabWidget->addTab(triggerTab, "Trigger");
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());
}
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(spbDCOffset[iDigi][ch], &RSpinBox::returnPressed, this, [=](){ SyncSpinBox(spbDCOffset, 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
//TODO==========================
QTabWidget * triggerMapTab = new QTabWidget(tab);
triggerMapTab = new QTabWidget(tab);
chTabWidget->addTab(triggerMapTab, "Trigger Map");
QGridLayout * triggerLayout = new QGridLayout(triggerMapTab);
@ -901,6 +926,10 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer2Gen ** digi, unsigned short nDigi
enableSignalSlot = true;
show();
EnableControl();
}
DigiSettingsPanel::~DigiSettingsPanel(){
@ -934,6 +963,49 @@ void DigiSettingsPanel::RefreshSettings(){
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(){
//TODO default file Path
@ -950,16 +1022,16 @@ void DigiSettingsPanel::SaveSettings(){
switch (flag) {
case 1 : {
leSettingFile[ID]->setText(filePath);
sendLogMsg("Saved setting file <b>" + filePath + "</b>.");
SendLogMsg("Saved setting file <b>" + filePath + "</b>.");
}; break;
case 0 : {
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;
case -1 : {
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;
};
@ -979,9 +1051,9 @@ void DigiSettingsPanel::LoadSettings(){
//TODO ==== check is the file valid;
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{
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();
@ -991,6 +1063,8 @@ void DigiSettingsPanel::ShowSettingsToPanel(){
enableSignalSlot = false;
printf("%s\n", __func__);
for (unsigned short j = 0; j < (unsigned short) infoIndex.size(); j++){
leInfo[ID][j]->setText(QString::fromStdString(digi[ID]->GetSettingValue(infoIndex[j].second)));
}
@ -1171,7 +1245,6 @@ void DigiSettingsPanel::ShowSettingsToPanel(){
SyncSpinBox(spbCoinLength , -1);
SyncSpinBox(spbADCVetoWidth , -1);
}
//^###########################################################################
@ -1191,7 +1264,7 @@ void DigiSettingsPanel::SetStartSource(){
QString msg;
msg = QString::fromStdString(DIGIPARA::DIG::StartSource.GetPara()) + "|DIG:"+ QString::number(digi[ID]->GetSerialNumber());
msg += " = " + QString::fromStdString(value);
sendLogMsg(msg);
SendLogMsg(msg);
digi[ID]->WriteValue(DIGIPARA::DIG::StartSource, value);
}
@ -1214,7 +1287,7 @@ void DigiSettingsPanel::SetGlobalTriggerSource(){
QString msg;
msg = QString::fromStdString(DIGIPARA::DIG::GlobalTriggerSource.GetPara()) + "|DIG:"+ QString::number(digi[ID]->GetSerialNumber());
msg += " = " + QString::fromStdString(value);
sendLogMsg(msg);
SendLogMsg(msg);
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);
msg += " = " + cbb->currentData().toString();
if( digi[ID]->WriteValue(para, cbb->currentData().toString().toStdString(), ch_index)){
sendLogMsg(msg + "|OK.");
SendLogMsg(msg + "|OK.");
cbb->setStyleSheet("");
}else{
sendLogMsg(msg + "|Fail.");
SendLogMsg(msg + "|Fail.");
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));
msg += " = " + QString::number(spb->value());
if( digi[ID]->WriteValue(para, std::to_string(spb->value()), ch_index)){
sendLogMsg(msg + "|OK.");
SendLogMsg(msg + "|OK.");
spb->setStyleSheet("");
}else{
sendLogMsg(msg + "|Fail.");
SendLogMsg(msg + "|Fail.");
spb->setStyleSheet("color:red;");
}
});

View File

@ -16,43 +16,13 @@
#include <QPushButton>
#include <QFrame>
#include <QSignalMapper>
#include <QWheelEvent>
#include "ClassDigitizer2Gen.h"
#include "CustomWidgets.h"
#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{
Q_OBJECT
@ -62,17 +32,20 @@ public:
~DigiSettingsPanel();
private slots:
void onTriggerClick(int haha);
void RefreshSettings();
void SaveSettings();
void LoadSettings();
void RefreshSettings(); // this read digitizer and ShowSettingToPanel
public slots:
void ShowSettingsToPanel();
void EnableControl();
signals:
void sendLogMsg(const QString &msg);
void SendLogMsg(const QString &msg);
void UpdateScopeSetting();
private:
@ -80,7 +53,23 @@ private:
unsigned short nDigi;
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;
@ -90,6 +79,18 @@ private:
QPushButton * ACQStatus[MaxNumberOfDigitizer][19];
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
RComboBox * cbbClockSource[MaxNumberOfDigitizer];
QCheckBox * ckbStartSource[MaxNumberOfDigitizer][5];
@ -109,14 +110,12 @@ private:
RSpinBox * dsbClockOutDelay[MaxNumberOfDigitizer];
//-------------- Test pulse
QGroupBox * testPulseBox;
RSpinBox * dsbTestPuslePeriod[MaxNumberOfDigitizer];
RSpinBox * dsbTestPusleWidth[MaxNumberOfDigitizer];
RSpinBox * spbTestPusleLowLevel[MaxNumberOfDigitizer];
RSpinBox * spbTestPusleHighLevel[MaxNumberOfDigitizer];
//-------------- VGA
QGroupBox * VGABox;
RSpinBox * VGA[MaxNumberOfDigitizer][4];
//--------------- trigger map
@ -202,9 +201,6 @@ private:
void FillComboBoxValueFromMemory(RComboBox * &cbb, 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->setSpacing(0);
scalarLayout->setAlignment(Qt::AlignTop);
leTrigger = NULL;
leAccept = NULL;
@ -357,6 +358,8 @@ void MainWindow::StartACQ(){
chkSaveRun->setEnabled(false);
cbAutoRun->setEnabled(false);
if( digiSetting ) digiSetting->EnableControl();
//TODO ======= Auto Run
if( cbAutoRun->currentIndex() > 0 ){
int timeMinite = cbAutoRun->currentData().toInt();
@ -430,6 +433,8 @@ void MainWindow::StopACQ(){
bnOpenScope->setEnabled(true);
chkSaveRun->setEnabled(true);
if( digiSetting ) digiSetting->EnableControl();
if( chkSaveRun->isChecked() ){
//TODO ============= elog
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::UpdateScalar, this, &MainWindow::UpdateScalar);
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{
scope->show();
}
@ -604,8 +617,14 @@ void MainWindow::OpenDigitizersSettings(){
if( digiSetting == NULL){
digiSetting = new DigiSettingsPanel(digi, nDigi);
connect(digiSetting, &DigiSettingsPanel::sendLogMsg, this, &MainWindow::LogMsg);
digiSetting->show();
connect(digiSetting, &DigiSettingsPanel::SendLogMsg, this, &MainWindow::LogMsg);
if( scope ) {
connect(scope, &Scope::UpdateSettingsPanel, digiSetting, &DigiSettingsPanel::ShowSettingsToPanel);
connect(scope, &Scope::TellSettingsPanelControlOnOff, digiSetting, &DigiSettingsPanel::EnableControl);
connect(digiSetting, &DigiSettingsPanel::UpdateScopeSetting, scope, &Scope::ReadScopeSettings);
}
}else{
digiSetting->show();
}

234
scope.cpp
View File

@ -62,12 +62,12 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
//------------ Digitizer + channel selection
rowID ++;
cbScopeDigi = new QComboBox(this);
cbScopeCh = new QComboBox(this);
cbScopeDigi = new RComboBox(this);
cbScopeCh = new RComboBox(this);
layout->addWidget(cbScopeDigi, rowID, 0);
layout->addWidget(cbScopeCh, rowID, 1);
connect(cbScopeDigi, &QComboBox::currentIndexChanged, this, [=](){
connect(cbScopeDigi, &RComboBox::currentIndexChanged, this, [=](){
//if( allowChange ) StopScope();
int index = cbScopeDigi->currentIndex();
if( index == -1 ) return;
@ -77,19 +77,20 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
//if( allowChange )StartScope(index);
});
connect(cbScopeCh, &QComboBox::currentIndexChanged, this, [=](){
connect(cbScopeCh, &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex();
digiMTX.lock();
digi[iDigi]->WriteValue(DIGIPARA::CH::ChannelEnable, "false", -1);
digi[iDigi]->WriteValue(DIGIPARA::CH::ChannelEnable, "true", ch);
ReadScopeSettings(iDigi, ch);
digi[iDigi]->WriteValue(DIGIPARA::CH::ChannelEnable, "False", -1);
digi[iDigi]->WriteValue(DIGIPARA::CH::ChannelEnable, "True", ch);
ReadScopeSettings();
UpdateSettingsPanel();
digiMTX.unlock();
});
allowChange = false;
cbScopeDigi->clear(); ///this will also trigger QComboBox::currentIndexChanged
cbScopeDigi->clear(); ///this will also trigger RComboBox::currentIndexChanged
cbScopeCh->clear();
for( unsigned int i = 0 ; i < nDigi; 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);
connect(bnScopeReadSettings, &QPushButton::clicked, this, [=](){
if( !allowChange ) return;
ReadScopeSettings(cbScopeDigi->currentIndex(), cbScopeCh->currentIndex());
ReadScopeSettings();
});
//TODO----- add copy settings and paste settings
@ -121,24 +122,24 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
//------------ Probe selection
rowID ++;
//TODO --- add None
cbAnaProbe[0] = new QComboBox(this);
cbAnaProbe[0] = new RComboBox(this);
cbAnaProbe[0]->addItem("ADC Input", "ADCInput");
cbAnaProbe[0]->addItem("Time Filter", "TimeFilter");
cbAnaProbe[0]->addItem("Trapazoid", "EnergyFilter");
cbAnaProbe[0]->addItem("Trap. Baseline", "EnergyFilterBaseline");
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));
connect(cbAnaProbe[0], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);});
connect(cbAnaProbe[1], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbAnaProbe, 2);});
connect(cbAnaProbe[0], &RComboBox::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(0);
cbAnaProbe[1]->setCurrentIndex(4);
connect(cbAnaProbe[0], &QComboBox::currentIndexChanged, this, [=](){
connect(cbAnaProbe[0], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex();
@ -147,7 +148,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
digiMTX.unlock();
});
connect(cbAnaProbe[1], &QComboBox::currentIndexChanged, this, [=](){
connect(cbAnaProbe[1], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex();
int ch = cbScopeCh->currentIndex();
@ -157,7 +158,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
});
//TODO --- add None
cbDigProbe[0] = new QComboBox(this);
cbDigProbe[0] = new RComboBox(this);
cbDigProbe[0]->addItem("Trigger", "Trigger");
cbDigProbe[0]->addItem("Time Filter Armed", "TimeFilterArmed");
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("ACQ Inhibit", "AcquisitionInhibit");
cbDigProbe[1] = new QComboBox(this);
cbDigProbe[2] = new QComboBox(this);
cbDigProbe[3] = new QComboBox(this);
cbDigProbe[1] = new RComboBox(this);
cbDigProbe[2] = new RComboBox(this);
cbDigProbe[3] = new RComboBox(this);
for( int i = 0; i < cbDigProbe[0]->count() ; i++) {
cbDigProbe[1]->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));
}
connect(cbDigProbe[0], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
connect(cbDigProbe[1], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
connect(cbDigProbe[2], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
connect(cbDigProbe[3], &QComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
connect(cbDigProbe[0], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
connect(cbDigProbe[1], &RComboBox::currentIndexChanged, this, [=](){ this->ProbeChange(cbDigProbe, 4);});
connect(cbDigProbe[2], &RComboBox::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(0);
@ -192,7 +193,7 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
cbDigProbe[2]->setCurrentIndex(5);
cbDigProbe[3]->setCurrentIndex(6);
connect(cbDigProbe[0], &QComboBox::currentIndexChanged, this, [=](){
connect(cbDigProbe[0], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->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);
digiMTX.unlock();
});
connect(cbDigProbe[1], &QComboBox::currentIndexChanged, this, [=](){
connect(cbDigProbe[1], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->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);
digiMTX.unlock();
});
connect(cbDigProbe[2], &QComboBox::currentIndexChanged, this, [=](){
connect(cbDigProbe[2], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->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);
digiMTX.unlock();
});
connect(cbDigProbe[3], &QComboBox::currentIndexChanged, this, [=](){
connect(cbDigProbe[3], &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->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[3], rowID, 5);
for( int i = 0; i < 6; i++) layout->setColumnStretch(i, 1);
rowID ++;
{//------------ wave settings
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);
bLayout->setSpacing(0);
sbRL = new QSpinBox(this);
ScopeMakeSpinBox(sbRL, "Record Lenght [ns] ", bLayout, 0, 0, 32, 648000, DIGIPARA::TraceStep, DIGIPARA::CH::RecordLength);
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");
ScopeMakeSpinBox(sbRL, "Record Lenght [ns] ", bLayout, 0, 0, DIGIPARA::CH::RecordLength);
ScopeMakeSpinBox(sbThreshold, "Threshold [LSB] ", bLayout, 0, 2, DIGIPARA::CH::TriggerThreshold);
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);
//------------------ next row
sbPT = new QSpinBox(this);
ScopeMakeSpinBox(sbPT, "Pre Trigger [ns] ", bLayout, 1, 0, 32, 32000, DIGIPARA::TraceStep, DIGIPARA::CH::PreTrigger);
sbDCOffset = new QSpinBox(this);
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);
ScopeMakeSpinBox(sbPT, "Pre Trigger [ns] ", bLayout, 1, 0, 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);
ScopeMakeSpinBox(sbTimeGuard, "Trigger Guard [ns] ", bLayout, 1, 6, DIGIPARA::CH::TimeFilterRetriggerGuard);
//----------------- next row
sbTrapRiseTime = new QSpinBox(this);
ScopeMakeSpinBox(sbTrapRiseTime, "Trap. Rise Time [ns] ", bLayout, 2, 0, 32, 13000, DIGIPARA::TraceStep, DIGIPARA::CH::EnergyFilterRiseTime);
sbTrapFlatTop = new QSpinBox(this);
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);
ScopeMakeSpinBox(sbTrapRiseTime, "Trap. Rise Time [ns] ", bLayout, 2, 0, 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);
ScopeMakeSpinBox(sbEnergyFineGain, "Energy Fine Gain ", bLayout, 2, 6, DIGIPARA::CH::EnergyFilterFineGain);
//----------------- next row
sbTrapPeaking = new QSpinBox(this);
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");
ScopeMakeSpinBox(sbTrapPeaking, "Trap. Peaking [%] ", bLayout, 3, 0, DIGIPARA::CH::EnergyFilterPeakingPosition);
ScopeMakeComoBox(cbTrapPeakAvg, "Trap. Peaking ", bLayout, 3, 2, DIGIPARA::CH::EnergyFilterPeakingAvg);
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");
ScopeMakeSpinBox(sbBaselineGuard, "Baseline Guard [ns] ", bLayout, 3, 4, DIGIPARA::CH::EnergyFilterBaselineGuard);
ScopeMakeComoBox(cbBaselineAvg, "Baseline Avg ", bLayout, 3, 6, DIGIPARA::CH::EnergyFilterBaselineAvg);
//----------------
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");
ScopeMakeSpinBox(sbPileUpGuard, "Pile-up Guard [ns] ", bLayout, 4, 0, DIGIPARA::CH::EnergyFilterPileUpGuard);
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);
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);
@ -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;
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?)
//* 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, "true", ch);
@ -451,6 +406,7 @@ void Scope::StartScope(){
updateTraceThread->start();
ScopeControlOnOff(false);
emit TellSettingsPanelControlOnOff();
allowChange = true;
}
@ -478,6 +434,8 @@ void Scope::StopScope(){
}
ScopeControlOnOff(true);
emit TellSettingsPanelControlOnOff();
allowChange = true;
}
@ -497,6 +455,12 @@ void Scope::UpdateScope(){
leTriggerRate->setText(QString::fromStdString(haha));
if( atoi(haha.c_str()) == 0 ) {
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;
}
@ -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};
for( int i = 0; i < size; i++){
@ -578,12 +542,12 @@ void Scope::ScopeControlOnOff(bool 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);
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);
int index = cb->findData(QString::fromStdString(ans));
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);
lb->setAlignment(Qt::AlignRight | Qt::AlignCenter);
layout->addWidget(lb, row, col);
sb->setMinimum(min);
sb->setMaximum(max);
sb->setSingleStep(abs(step));
sb = new RSpinBox(this);
sb->setMinimum(atof(digPara.GetAnswers()[0].first.c_str()));
sb->setMaximum(atof(digPara.GetAnswers()[1].first.c_str()));
sb->setSingleStep(atof(digPara.GetAnswers()[2].first.c_str()));
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;
int iDigi = cbScopeDigi->currentIndex();
if( step > 1 ) sb->setValue(step*((sb->value() + step - 1)/step));
digiMTX.lock();
digi[iDigi]->WriteValue(digPara, std::to_string(sb->value()), cbScopeCh->currentIndex() );
digiMTX.unlock();
if( sb->decimals() == 0 && sb->singleStep() != 1) {
double step = sb->singleStep();
double value = sb->value();
sb->setValue( (std::round(value/step)*step));
}
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;");
}
});
//TODO digiSettingPanel update setting
}
void Scope::ScopeMakeComoBox(QComboBox *cb, QString str, QGridLayout *layout, int row, int col, const Reg digPara){
void Scope::ScopeMakeComoBox(RComboBox * &cb, QString str, QGridLayout *layout, int row, int col, const Reg digPara){
QLabel * lb = new QLabel(str, this);
lb->setAlignment(Qt::AlignRight | Qt::AlignCenter);
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);
connect(cb, &QComboBox::currentIndexChanged, this, [=](){
connect(cb, &RComboBox::currentIndexChanged, this, [=](){
if( !allowChange ) return;
int iDigi = cbScopeDigi->currentIndex();
digiMTX.lock();
digi[iDigi]->WriteValue(digPara, cb->currentData().toString().toStdString(), cbScopeCh->currentIndex());
digiMTX.unlock();
int ch = cbScopeCh->currentIndex();
QString msg;
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
printf("UpdateSettingsPanel \n");
emit UpdateSettingsPanel();
}else{
SendLogMsg(msg + "|Fail.");
cb->setStyleSheet("color:red;");
}
});
//TODO digiSettingPanel update setting
}

63
scope.h
View File

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