2023-04-18 13:12:05 -04:00
|
|
|
#include "Scope.h"
|
|
|
|
|
2024-01-25 16:18:47 -05:00
|
|
|
#include <QApplication>
|
2023-04-18 13:12:05 -04:00
|
|
|
#include <QValueAxis>
|
|
|
|
#include <QRandomGenerator>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
#include <QLabel>
|
2024-08-29 16:49:52 -04:00
|
|
|
#include <QScreen>
|
2023-04-18 13:12:05 -04:00
|
|
|
|
2023-10-23 12:53:51 -04:00
|
|
|
QVector<QPointF> Scope::TrapezoidFilter(QVector<QPointF> data, int baseLineEndS, int riseTimeS, int flatTopS, float decayTime_ns){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-10-23 12:53:51 -04:00
|
|
|
QVector<QPointF> trapezoid;
|
|
|
|
trapezoid.clear();
|
|
|
|
|
|
|
|
///find baseline;
|
|
|
|
double baseline = 0;
|
|
|
|
for( int i = 0; i < baseLineEndS; i++){
|
|
|
|
baseline += data[i].y();
|
|
|
|
}
|
|
|
|
baseline = baseline*1./baseLineEndS;
|
|
|
|
|
|
|
|
int length = data.size();
|
|
|
|
|
|
|
|
double pn = 0.;
|
|
|
|
double sn = 0.;
|
|
|
|
for( int i = 0; i < length ; i++){
|
|
|
|
|
|
|
|
double dlk = data[i].y() - baseline;
|
|
|
|
if( i - riseTimeS >= 0 ) dlk -= data[i - riseTimeS].y() - baseline;
|
|
|
|
if( i - flatTopS - riseTimeS >= 0 ) dlk -= data[i - flatTopS - riseTimeS].y() - baseline;
|
|
|
|
if( i - flatTopS - 2*riseTimeS >= 0) dlk += data[i - flatTopS - 2*riseTimeS].y() - baseline;
|
|
|
|
|
|
|
|
if( i == 0 ){
|
|
|
|
pn = dlk;
|
|
|
|
sn = pn + dlk*decayTime_ns;
|
|
|
|
}else{
|
|
|
|
pn = pn + dlk;
|
|
|
|
sn = sn + pn + dlk*decayTime_ns;
|
|
|
|
}
|
|
|
|
|
|
|
|
trapezoid.append(QPointF(data[i].x(), sn / decayTime_ns / riseTimeS));
|
|
|
|
|
2024-08-29 16:49:52 -04:00
|
|
|
}
|
2023-10-23 12:53:51 -04:00
|
|
|
return trapezoid;
|
|
|
|
}
|
|
|
|
|
2024-08-29 16:49:52 -04:00
|
|
|
//^========================================================
|
|
|
|
//^========================================================
|
2023-04-18 13:12:05 -04:00
|
|
|
Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow * parent) : QMainWindow(parent){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-04-18 13:12:05 -04:00
|
|
|
this->digi = digi;
|
|
|
|
this->nDigi = nDigi;
|
|
|
|
this->readDataThread = readDataThread;
|
|
|
|
|
|
|
|
setWindowTitle("Scope");
|
|
|
|
setWindowFlags( this->windowFlags() & ~Qt::WindowCloseButtonHint );
|
|
|
|
|
2024-07-26 15:21:16 -04:00
|
|
|
//====== resize window if screen too small
|
|
|
|
QScreen * screen = QGuiApplication::primaryScreen();
|
|
|
|
QRect screenGeo = screen->geometry();
|
2024-07-26 15:48:20 -04:00
|
|
|
if( screenGeo.width() < 1000 || screenGeo.height() < 800) {
|
|
|
|
setGeometry(0, 0, screenGeo.width() - 100, screenGeo.height() - 100);
|
|
|
|
}else{
|
|
|
|
setGeometry(0, 0, 1000, 800);
|
|
|
|
}
|
2024-07-26 15:21:16 -04:00
|
|
|
|
2023-04-18 13:12:05 -04:00
|
|
|
enableSignalSlot = false;
|
|
|
|
|
2023-06-23 13:50:21 -04:00
|
|
|
isACQStarted = false;
|
|
|
|
|
2023-05-26 18:06:37 -04:00
|
|
|
plot = new RChart();
|
2023-04-18 13:12:05 -04:00
|
|
|
for( int i = 0; i < MaxNumberOfTrace; i++) {
|
|
|
|
dataTrace[i] = new QLineSeries();
|
|
|
|
dataTrace[i]->setName("Trace " + QString::number(i));
|
2023-04-20 14:39:59 -04:00
|
|
|
for(int j = 0; j < 100; j ++) dataTrace[i]->append(40*j, QRandomGenerator::global()->bounded(8000) - 4000);
|
2023-04-18 13:12:05 -04:00
|
|
|
plot->addSeries(dataTrace[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
dataTrace[0]->setPen(QPen(Qt::red, 2));
|
|
|
|
dataTrace[1]->setPen(QPen(Qt::blue, 2));
|
|
|
|
dataTrace[2]->setPen(QPen(Qt::darkYellow, 1));
|
|
|
|
dataTrace[3]->setPen(QPen(Qt::darkGreen, 1));
|
2023-10-11 18:28:19 -04:00
|
|
|
dataTrace[4]->setPen(QPen(Qt::darkMagenta, 1));
|
2023-04-18 13:12:05 -04:00
|
|
|
|
|
|
|
plot->setAnimationDuration(1); // msec
|
|
|
|
plot->setAnimationOptions(QChart::NoAnimation);
|
|
|
|
plot->createDefaultAxes(); /// this must be after addSeries();
|
|
|
|
/// this must be after createDefaultAxes();
|
|
|
|
QValueAxis * yaxis = qobject_cast<QValueAxis*> (plot->axes(Qt::Vertical).first());
|
|
|
|
QValueAxis * xaxis = qobject_cast<QValueAxis*> (plot->axes(Qt::Horizontal).first());
|
2023-04-20 18:15:30 -04:00
|
|
|
yaxis->setTickCount(7);
|
2023-04-20 13:49:36 -04:00
|
|
|
yaxis->setTickInterval((0x1FFF)/4);
|
2024-01-29 17:23:11 -05:00
|
|
|
yaxis->setRange(-(0x3FFF), 0x3FFF);
|
2023-04-18 13:12:05 -04:00
|
|
|
yaxis->setLabelFormat("%.0f");
|
|
|
|
|
2023-04-20 18:15:30 -04:00
|
|
|
xaxis->setRange(0, 4000);
|
2023-04-18 13:12:05 -04:00
|
|
|
xaxis->setTickCount(11);
|
|
|
|
xaxis->setLabelFormat("%.0f");
|
|
|
|
xaxis->setTitleText("Time [ns]");
|
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
NullThePointers();
|
2023-04-24 16:37:57 -04:00
|
|
|
|
2023-04-18 13:12:05 -04:00
|
|
|
//*================================== UI
|
|
|
|
int rowID = -1;
|
|
|
|
|
|
|
|
QWidget * layoutWidget = new QWidget(this);
|
|
|
|
setCentralWidget(layoutWidget);
|
|
|
|
QGridLayout * layout = new QGridLayout(layoutWidget);
|
|
|
|
layoutWidget->setLayout(layout);
|
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
//================ Board & Ch selection
|
2023-04-18 13:12:05 -04:00
|
|
|
rowID ++;
|
|
|
|
cbScopeDigi = new RComboBox(this);
|
|
|
|
cbScopeCh = new RComboBox(this);
|
|
|
|
layout->addWidget(cbScopeDigi, rowID, 0);
|
|
|
|
layout->addWidget(cbScopeCh, rowID, 1);
|
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
for(unsigned int i = 0; i < nDigi; i++){
|
|
|
|
cbScopeDigi->addItem("Digi-" + QString::number(digi[i]->GetSerialNumber()), i);
|
|
|
|
}
|
2023-04-18 13:12:05 -04:00
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
ID = 0;
|
|
|
|
cbScopeDigi->setCurrentIndex(0);
|
2023-10-17 17:01:57 -04:00
|
|
|
for( int i = 0; i < digi[0]->GetNumInputCh(); i++) cbScopeCh->addItem("Ch-" + QString::number(i));
|
2023-06-20 11:57:39 -04:00
|
|
|
tick2ns = digi[ID]->GetTick2ns();
|
2023-08-17 12:38:15 -04:00
|
|
|
factor = digi[ID]->IsDualTrace_PHA() ? 2 : 1;
|
2023-04-19 13:41:43 -04:00
|
|
|
|
2023-04-19 14:46:10 -04:00
|
|
|
connect(cbScopeDigi, &RComboBox::currentIndexChanged, this, [=](int index){
|
2023-04-19 13:41:43 -04:00
|
|
|
if( !enableSignalSlot ) return;
|
2023-06-23 13:50:21 -04:00
|
|
|
|
|
|
|
bool saveACQStartStatus = isACQStarted;
|
|
|
|
if( isACQStarted) StopScope();
|
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
ID = index;
|
2023-06-20 11:57:39 -04:00
|
|
|
tick2ns = digi[ID]->GetTick2ns();
|
2023-08-17 12:38:15 -04:00
|
|
|
factor = digi[ID]->IsDualTrace_PHA() ? 2 : 1;
|
|
|
|
|
2023-08-22 14:38:37 -04:00
|
|
|
enableSignalSlot = false;
|
2023-04-19 13:41:43 -04:00
|
|
|
//---setup cbScopeCh
|
|
|
|
cbScopeCh->clear();
|
2023-10-17 17:01:57 -04:00
|
|
|
for( int i = 0; i < digi[ID]->GetNumInputCh(); i++) cbScopeCh->addItem("Ch-" + QString::number(i));
|
2023-04-19 14:46:10 -04:00
|
|
|
|
|
|
|
//---Setup SettingGroup
|
2023-04-19 18:08:20 -04:00
|
|
|
CleanUpSettingsGroupBox();
|
2023-10-11 18:28:19 -04:00
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) SetUpPanel_PHA();
|
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) SetUpPanel_PSD();
|
|
|
|
if( digi[ID]->GetDPPType() == V1740_DPP_QDC_CODE ) SetUpPanel_QDC();
|
2023-04-19 14:46:10 -04:00
|
|
|
|
2024-10-21 15:11:33 -04:00
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) {
|
|
|
|
QValueAxis * yaxis = qobject_cast<QValueAxis*> (plot->axes(Qt::Vertical).first());
|
|
|
|
yaxis->setRange(-(0x1FFF), 0x1FFF);
|
|
|
|
}
|
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) {
|
|
|
|
QValueAxis * yaxis = qobject_cast<QValueAxis*> (plot->axes(Qt::Vertical).first());
|
|
|
|
yaxis->setRange(0, 0x3FFF);
|
|
|
|
}
|
|
|
|
if( digi[ID]->GetDPPType() == V1740_DPP_QDC_CODE ) {
|
|
|
|
QValueAxis * yaxis = qobject_cast<QValueAxis*> (plot->axes(Qt::Vertical).first());
|
|
|
|
yaxis->setRange(0, 0xFFF);
|
|
|
|
}
|
|
|
|
|
2023-05-22 17:00:11 -04:00
|
|
|
ReadSettingsFromBoard();
|
2023-05-12 16:06:32 -04:00
|
|
|
|
2023-06-23 13:50:21 -04:00
|
|
|
if( saveACQStartStatus )StartScope();
|
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
});
|
|
|
|
|
2024-10-21 15:11:33 -04:00
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) {
|
|
|
|
QValueAxis * yaxis = qobject_cast<QValueAxis*> (plot->axes(Qt::Vertical).first());
|
|
|
|
yaxis->setRange(-(0x1FFF), 0x1FFF);
|
|
|
|
}
|
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) {
|
|
|
|
QValueAxis * yaxis = qobject_cast<QValueAxis*> (plot->axes(Qt::Vertical).first());
|
|
|
|
yaxis->setRange(0, 0x3FFF);
|
|
|
|
}
|
|
|
|
if( digi[ID]->GetDPPType() == V1740_DPP_QDC_CODE ) {
|
|
|
|
QValueAxis * yaxis = qobject_cast<QValueAxis*> (plot->axes(Qt::Vertical).first());
|
|
|
|
yaxis->setRange(0, 0xFFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-22 17:00:11 -04:00
|
|
|
connect(cbScopeCh, &RComboBox::currentIndexChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
2023-06-23 13:50:21 -04:00
|
|
|
|
|
|
|
bool saveACQStartStatus = isACQStarted;
|
|
|
|
if( isACQStarted) StopScope();
|
|
|
|
|
2023-05-22 17:00:11 -04:00
|
|
|
ReadSettingsFromBoard();
|
2023-06-23 13:50:21 -04:00
|
|
|
|
|
|
|
if( saveACQStartStatus )StartScope();
|
|
|
|
|
2023-05-22 17:00:11 -04:00
|
|
|
});
|
|
|
|
|
2023-04-21 18:10:12 -04:00
|
|
|
bnReadSettingsFromBoard = new QPushButton("Refresh Settings", this);
|
|
|
|
layout->addWidget(bnReadSettingsFromBoard, rowID, 2);
|
|
|
|
connect(bnReadSettingsFromBoard, &QPushButton::clicked, this, &Scope::ReadSettingsFromBoard);
|
|
|
|
|
2023-05-16 17:21:40 -04:00
|
|
|
QPushButton * bnClearMemory = new QPushButton("Clear Memory", this);
|
|
|
|
layout->addWidget(bnClearMemory, rowID, 3);
|
|
|
|
connect(bnClearMemory, &QPushButton::clicked, this, [=](){
|
|
|
|
digiMTX[ID].lock();
|
|
|
|
digi[ID]->GetData()->ClearData();
|
|
|
|
digiMTX[ID].unlock();
|
|
|
|
});
|
|
|
|
|
2023-08-22 14:38:37 -04:00
|
|
|
QPushButton * bnClearBuffer = new QPushButton("Clear Buffer/FIFO", this);
|
|
|
|
layout->addWidget(bnClearBuffer, rowID, 4);
|
|
|
|
connect(bnClearBuffer, &QPushButton::clicked, this, [=](){ digi[ID]->WriteRegister(DPP::SoftwareClear_W, 1);});
|
|
|
|
|
2023-10-19 15:32:44 -04:00
|
|
|
QLabel * lbRun = new QLabel("Run Status : ", this);
|
|
|
|
lbRun->setAlignment(Qt::AlignCenter | Qt::AlignRight);
|
|
|
|
layout->addWidget(lbRun, rowID, 5);
|
|
|
|
|
|
|
|
runStatus = new QPushButton("", this);
|
|
|
|
runStatus->setEnabled(false);
|
|
|
|
runStatus->setFixedSize(QSize(20,20));
|
|
|
|
layout->addWidget(runStatus, rowID, 6);
|
2023-08-22 14:38:37 -04:00
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
//================ Trace settings
|
|
|
|
rowID ++;
|
|
|
|
{
|
2023-04-19 14:46:10 -04:00
|
|
|
settingGroup = new QGroupBox("Trace Settings",this);
|
2023-10-19 15:32:44 -04:00
|
|
|
layout->addWidget(settingGroup, rowID, 0, 1, 7);
|
2023-04-19 13:41:43 -04:00
|
|
|
|
2023-04-19 14:46:10 -04:00
|
|
|
settingLayout = new QGridLayout(settingGroup);
|
|
|
|
settingLayout->setSpacing(0);
|
2023-04-19 13:41:43 -04:00
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) SetUpPanel_PHA();
|
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) SetUpPanel_PSD();
|
|
|
|
if( digi[ID]->GetDPPType() == V1740_DPP_QDC_CODE ) SetUpPanel_QDC();
|
2023-04-19 13:41:43 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
//================ Plot view
|
2023-04-18 13:12:05 -04:00
|
|
|
rowID ++;
|
2023-05-26 18:06:37 -04:00
|
|
|
plotView = new RChartView(plot, this);
|
2023-10-19 15:32:44 -04:00
|
|
|
layout->addWidget(plotView, rowID, 0, 1, 7);
|
2023-04-18 13:12:05 -04:00
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
//================ Key binding
|
|
|
|
rowID ++;
|
|
|
|
QLabel * lbhints = new QLabel("Type 'r' to restore view, '+/-' Zoom in/out, arrow key to pan.", this);
|
|
|
|
layout->addWidget(lbhints, rowID, 0, 1, 4);
|
|
|
|
|
2024-08-29 16:49:52 -04:00
|
|
|
QLabel * lbinfo = new QLabel("Trace updates every " + QString::number(ScopeUpdateMiliSec / 1000.) + " sec.", this);
|
2023-04-19 13:41:43 -04:00
|
|
|
lbinfo->setAlignment(Qt::AlignRight);
|
2023-10-19 15:32:44 -04:00
|
|
|
layout->addWidget(lbinfo, rowID, 6);
|
2023-04-19 13:41:43 -04:00
|
|
|
|
|
|
|
rowID ++;
|
|
|
|
//TODO =========== Trace step
|
2024-01-25 16:18:47 -05:00
|
|
|
QLabel * lbinfo2 = new QLabel("Maximum time range is " + QString::number(MaxDisplayTraceTimeLength) + " ns due to processing speed.", this);
|
2023-04-19 13:41:43 -04:00
|
|
|
layout->addWidget(lbinfo2, rowID, 0, 1, 5);
|
|
|
|
|
|
|
|
//================ close button
|
2023-04-18 13:12:05 -04:00
|
|
|
rowID ++;
|
|
|
|
bnScopeStart = new QPushButton("Start", this);
|
|
|
|
layout->addWidget(bnScopeStart, rowID, 0);
|
|
|
|
connect(bnScopeStart, &QPushButton::clicked, this, [=](){this->StartScope();});
|
|
|
|
|
2024-05-06 14:06:00 -04:00
|
|
|
chkSoleRun = new QCheckBox("Only this channel", this);
|
|
|
|
layout->addWidget(chkSoleRun, rowID, 1);
|
|
|
|
|
2023-04-18 13:12:05 -04:00
|
|
|
bnScopeStop = new QPushButton("Stop", this);
|
2024-05-06 14:06:00 -04:00
|
|
|
layout->addWidget(bnScopeStop, rowID, 2);
|
2023-04-18 13:12:05 -04:00
|
|
|
connect(bnScopeStop, &QPushButton::clicked, this, &Scope::StopScope);
|
|
|
|
|
|
|
|
QLabel * lbTriggerRate = new QLabel("Trigger Rate [Hz] : ", this);
|
|
|
|
lbTriggerRate->setAlignment(Qt::AlignCenter | Qt::AlignRight);
|
2024-05-06 14:06:00 -04:00
|
|
|
layout->addWidget(lbTriggerRate, rowID, 3);
|
2023-04-18 13:12:05 -04:00
|
|
|
|
|
|
|
leTriggerRate = new QLineEdit(this);
|
|
|
|
leTriggerRate->setAlignment(Qt::AlignRight);
|
|
|
|
leTriggerRate->setReadOnly(true);
|
2024-05-06 14:06:00 -04:00
|
|
|
layout->addWidget(leTriggerRate, rowID, 4);
|
2023-04-18 13:12:05 -04:00
|
|
|
|
|
|
|
QPushButton * bnClose = new QPushButton("Close", this);
|
2023-10-19 15:32:44 -04:00
|
|
|
layout->addWidget(bnClose, rowID, 6);
|
2023-04-18 13:12:05 -04:00
|
|
|
connect(bnClose, &QPushButton::clicked, this, &Scope::close);
|
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
layout->setColumnStretch(0, 1);
|
|
|
|
layout->setColumnStretch(1, 1);
|
|
|
|
layout->setColumnStretch(2, 1);
|
|
|
|
layout->setColumnStretch(3, 1);
|
|
|
|
layout->setColumnStretch(4, 1);
|
|
|
|
layout->setColumnStretch(5, 1);
|
|
|
|
|
2023-04-19 18:08:20 -04:00
|
|
|
bnScopeStart->setEnabled(true);
|
2023-06-23 13:50:21 -04:00
|
|
|
bnScopeStart->setStyleSheet("background-color: green;");
|
2023-04-19 18:08:20 -04:00
|
|
|
bnScopeStop->setEnabled(false);
|
2023-06-23 13:50:21 -04:00
|
|
|
bnScopeStop->setStyleSheet("");
|
2023-04-19 18:08:20 -04:00
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
UpdatePanelFromMomeory();
|
|
|
|
|
2024-08-29 16:49:52 -04:00
|
|
|
workerThread = new QThread(this);
|
|
|
|
scopeWorker = new ScopeWorker(this);
|
|
|
|
scopeTimer = new QTimer(this);
|
|
|
|
|
|
|
|
scopeWorker->moveToThread(workerThread);
|
|
|
|
|
|
|
|
// Setup the timer to trigger every second
|
|
|
|
connect(scopeTimer, &QTimer::timeout, scopeWorker, [=](){
|
|
|
|
scopeWorker->UpdateScope();
|
|
|
|
});
|
|
|
|
workerThread->start();
|
|
|
|
|
2023-04-20 18:15:30 -04:00
|
|
|
enableSignalSlot = true;
|
|
|
|
|
2023-04-18 13:12:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
Scope::~Scope(){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-11-17 11:44:28 -05:00
|
|
|
|
2024-08-29 16:49:52 -04:00
|
|
|
scopeTimer->stop();
|
2024-08-29 17:15:36 -04:00
|
|
|
// scalarTimer->stop();
|
2024-08-29 16:49:52 -04:00
|
|
|
|
|
|
|
if( workerThread->isRunning() ){
|
|
|
|
workerThread->quit();
|
|
|
|
workerThread->wait();
|
|
|
|
}
|
2023-11-17 11:44:28 -05:00
|
|
|
|
2023-04-18 13:12:05 -04:00
|
|
|
for( int i = 0; i < MaxNumberOfTrace; i++) delete dataTrace[i];
|
|
|
|
delete plot;
|
|
|
|
}
|
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
void Scope::NullThePointers(){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-10-11 18:28:19 -04:00
|
|
|
sbReordLength = nullptr;
|
|
|
|
sbPreTrigger = nullptr;
|
|
|
|
sbDCOffset = nullptr;
|
|
|
|
cbDynamicRange = nullptr;
|
|
|
|
cbPolarity = nullptr;
|
|
|
|
|
|
|
|
/// PHA
|
|
|
|
sbInputRiseTime = nullptr;
|
|
|
|
sbTriggerHoldOff = nullptr;
|
|
|
|
sbThreshold = nullptr;
|
|
|
|
cbSmoothingFactor = nullptr;
|
|
|
|
|
|
|
|
sbTrapRiseTime = nullptr;
|
|
|
|
sbTrapFlatTop = nullptr;
|
|
|
|
sbDecayTime = nullptr;
|
|
|
|
sbPeakingTime = nullptr;
|
|
|
|
sbPeakHoldOff = nullptr;
|
|
|
|
cbPeakAvg = nullptr;
|
|
|
|
cbBaselineAvg = nullptr;
|
|
|
|
|
|
|
|
cbAnaProbe1 = nullptr;
|
|
|
|
cbAnaProbe2 = nullptr;
|
|
|
|
cbDigiProbe1 = nullptr;
|
|
|
|
cbDigiProbe2 = nullptr;
|
|
|
|
|
|
|
|
/// PSD
|
|
|
|
sbShortGate = nullptr;
|
|
|
|
sbLongGate = nullptr;
|
|
|
|
sbGateOffset = nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
//*=======================================================
|
|
|
|
//*=======================================================
|
2023-04-18 13:12:05 -04:00
|
|
|
void Scope::StartScope(){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-04-19 18:08:20 -04:00
|
|
|
if( !digi ) return;
|
|
|
|
|
2023-04-20 18:15:30 -04:00
|
|
|
//TODO set other channel to be no trace;
|
2023-08-17 12:38:15 -04:00
|
|
|
emit UpdateOtherPanels();
|
2023-04-20 18:15:30 -04:00
|
|
|
|
2024-05-06 14:06:00 -04:00
|
|
|
if( chkSoleRun->isChecked() ){
|
2023-04-19 18:08:20 -04:00
|
|
|
|
2024-05-06 14:06:00 -04:00
|
|
|
int ID = cbScopeDigi->currentIndex();
|
|
|
|
int ch = cbScopeCh->currentIndex();
|
2024-05-17 17:45:30 -04:00
|
|
|
oldDigi = ID;
|
|
|
|
oldCh = ch;
|
2023-04-19 18:08:20 -04:00
|
|
|
|
2024-05-06 14:06:00 -04:00
|
|
|
//save present settings, channleMap, trigger condition
|
|
|
|
traceOn[ID] = digi[ID]->IsRecordTrace();
|
|
|
|
digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 1, -1);
|
2024-02-23 18:31:39 -05:00
|
|
|
|
2024-05-06 14:06:00 -04:00
|
|
|
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PHA_CODE ){
|
2024-10-21 15:11:33 -04:00
|
|
|
chMask = digi[ID]->GetSettingFromMemory(DPP::RegChannelEnableMask);
|
2024-05-06 14:06:00 -04:00
|
|
|
dppAlg = digi[ID]->GetSettingFromMemory(DPP::DPPAlgorithmControl, ch);
|
|
|
|
dppAlg2 = digi[ID]->GetSettingFromMemory(DPP::PHA::DPPAlgorithmControl2_G, ch);
|
2023-11-17 12:06:21 -05:00
|
|
|
|
2024-05-06 14:06:00 -04:00
|
|
|
digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::TriggerMode, 0, ch);
|
|
|
|
digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::DisableSelfTrigger, 0, ch);
|
|
|
|
|
|
|
|
digi[ID]->SetBits(DPP::PHA::DPPAlgorithmControl2_G, DPP::PHA::Bit_DPPAlgorithmControl2::LocalShapeTriggerMode, 0, ch);
|
|
|
|
digi[ID]->SetBits(DPP::PHA::DPPAlgorithmControl2_G, DPP::PHA::Bit_DPPAlgorithmControl2::LocalTrigValidMode, 0, ch);
|
2024-10-18 17:54:43 -04:00
|
|
|
|
|
|
|
digi[ID]->WriteRegister(DPP::RegChannelEnableMask, (1 << ch));
|
2024-05-06 14:06:00 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PSD_CODE ){
|
2024-10-21 15:11:33 -04:00
|
|
|
chMask = digi[ID]->GetSettingFromMemory(DPP::RegChannelEnableMask);
|
2024-05-06 14:06:00 -04:00
|
|
|
dppAlg = digi[ID]->GetSettingFromMemory(DPP::DPPAlgorithmControl, ch);
|
|
|
|
dppAlg2 = digi[ID]->GetSettingFromMemory(DPP::PSD::DPPAlgorithmControl2_G, ch);
|
2024-05-17 17:45:30 -04:00
|
|
|
|
|
|
|
digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::TriggerMode, 0, ch);
|
|
|
|
digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::DisableSelfTrigger, 0, ch);
|
|
|
|
|
|
|
|
digi[ID]->SetBits(DPP::PSD::DPPAlgorithmControl2_G, DPP::PSD::Bit_DPPAlgorithmControl2::LocalShapeTriggerMode, 0, ch);
|
|
|
|
digi[ID]->SetBits(DPP::PSD::DPPAlgorithmControl2_G, DPP::PSD::Bit_DPPAlgorithmControl2::LocalTrigValidMode, 0, ch);
|
2024-10-18 17:54:43 -04:00
|
|
|
|
|
|
|
digi[ID]->WriteRegister(DPP::RegChannelEnableMask, (1 << ch));
|
2024-05-06 14:06:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){
|
2024-10-21 15:11:33 -04:00
|
|
|
chMask = digi[ID]->GetSettingFromMemory(DPP::QDC::GroupEnableMask);
|
|
|
|
subChMask = digi[ID]->GetSettingFromMemory(DPP::QDC::SubChannelMask);
|
2024-05-06 14:06:00 -04:00
|
|
|
dppAlg = digi[ID]->GetSettingFromMemory(DPP::QDC::DPPAlgorithmControl, ch);
|
2024-05-17 17:45:30 -04:00
|
|
|
digi[ID]->SetBits(DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::TriggerMode, 0, ch); //set self-triiger
|
2024-10-18 17:54:43 -04:00
|
|
|
|
2024-10-21 15:11:33 -04:00
|
|
|
digi[ID]->WriteRegister(DPP::QDC::GroupEnableMask, (1 << (ch/8)));
|
|
|
|
|
|
|
|
uint32_t haha = (1 << (ch%8));
|
|
|
|
if( ch/8 == 0 ) haha |= 0x1; //must include the first subchannel
|
|
|
|
|
|
|
|
digi[ID]->WriteRegister(DPP::QDC::SubChannelMask, haha);
|
2024-05-06 14:06:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=========== start
|
|
|
|
digi[ID]->WriteRegister(DPP::SoftwareClear_W, 1);
|
|
|
|
|
|
|
|
readDataThread[ID]->SetScopeMode(true);
|
|
|
|
readDataThread[ID]->SetSaveData(false);
|
|
|
|
|
|
|
|
digi[ID]->StartACQ();
|
|
|
|
readDataThread[ID]->start();
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
for( int iDigi = (int)nDigi-1 ; iDigi >= 0; iDigi --){
|
|
|
|
|
|
|
|
traceOn[iDigi] = digi[iDigi]->IsRecordTrace(); //remember setting
|
|
|
|
SendLogMsg("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()) + " is starting ACQ." );
|
|
|
|
digi[iDigi]->WriteRegister(DPP::SoftwareClear_W, 1);
|
|
|
|
digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 1, -1);
|
|
|
|
|
|
|
|
//AggPerRead[iDigi] = digi[iDigi]->GetSettingFromMemory(DPP::MaxAggregatePerBlockTransfer);
|
|
|
|
//SendLogMsg("Set Agg/Read to 1 for scope, it was " + QString::number(AggPerRead[iDigi]) + ".");
|
|
|
|
//digi[iDigi]->WriteRegister(DPP::MaxAggregatePerBlockTransfer, 1);
|
|
|
|
|
|
|
|
readDataThread[iDigi]->SetScopeMode(true);
|
|
|
|
readDataThread[iDigi]->SetSaveData(false);
|
|
|
|
|
|
|
|
digi[iDigi]->StartACQ();
|
|
|
|
|
|
|
|
// printf("----- readDataThread running ? %d.\n", readDataThread[iDigi]->isRunning());
|
|
|
|
// if( readDataThread[iDigi]->isRunning() ){
|
|
|
|
// readDataThread[iDigi]->quit();
|
|
|
|
// readDataThread[iDigi]->wait();
|
|
|
|
// }
|
|
|
|
readDataThread[iDigi]->start();
|
|
|
|
// printf("----- readDataThread running ? %d.\n", readDataThread[iDigi]->isRunning());
|
|
|
|
}
|
2023-11-17 12:06:21 -05:00
|
|
|
|
2023-04-19 18:08:20 -04:00
|
|
|
}
|
|
|
|
|
2024-08-29 16:49:52 -04:00
|
|
|
scopeTimer->start(ScopeUpdateMiliSec);
|
2023-04-18 13:12:05 -04:00
|
|
|
|
2023-04-19 18:08:20 -04:00
|
|
|
bnScopeStart->setEnabled(false);
|
2023-06-23 13:50:21 -04:00
|
|
|
bnScopeStart->setStyleSheet("");
|
2023-04-19 18:08:20 -04:00
|
|
|
bnScopeStop->setEnabled(true);
|
2023-06-23 13:50:21 -04:00
|
|
|
bnScopeStop->setStyleSheet("background-color: red;");
|
2023-04-18 13:12:05 -04:00
|
|
|
|
2024-05-06 14:06:00 -04:00
|
|
|
chkSoleRun->setEnabled(false);
|
|
|
|
|
2023-04-21 18:10:12 -04:00
|
|
|
EnableControl(false);
|
|
|
|
|
2024-08-29 16:49:52 -04:00
|
|
|
emit TellACQOnOff(true);
|
2023-05-16 14:31:19 -04:00
|
|
|
|
2023-06-23 13:50:21 -04:00
|
|
|
isACQStarted = true;
|
|
|
|
|
2023-04-18 13:12:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Scope::StopScope(){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-04-19 18:08:20 -04:00
|
|
|
if( !digi ) return;
|
|
|
|
|
2023-05-22 17:00:11 -04:00
|
|
|
// printf("------ Scope::%s \n", __func__);
|
2024-08-29 16:49:52 -04:00
|
|
|
scopeTimer->stop();
|
2024-08-29 17:15:36 -04:00
|
|
|
// scalarTimer->stop();
|
2023-11-17 11:44:28 -05:00
|
|
|
|
2024-05-06 14:06:00 -04:00
|
|
|
if( chkSoleRun->isChecked() ){
|
|
|
|
|
2024-05-17 17:45:30 -04:00
|
|
|
//int ID = cbScopeDigi->currentIndex();
|
|
|
|
int ID = oldDigi;
|
2023-05-22 17:00:11 -04:00
|
|
|
|
2024-05-06 14:06:00 -04:00
|
|
|
if( readDataThread[ID]->isRunning() ){
|
|
|
|
readDataThread[ID]->Stop();
|
|
|
|
readDataThread[ID]->quit();
|
|
|
|
readDataThread[ID]->wait();
|
|
|
|
readDataThread[ID]->SetScopeMode(false);
|
2023-05-22 17:00:11 -04:00
|
|
|
}
|
2023-05-23 17:02:39 -04:00
|
|
|
|
2024-05-06 14:06:00 -04:00
|
|
|
digiMTX[ID].lock();
|
|
|
|
digi[ID]->StopACQ();
|
|
|
|
digiMTX[ID].unlock();
|
|
|
|
|
|
|
|
//restore setting
|
|
|
|
digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, traceOn[ID], -1);
|
2024-05-17 16:41:44 -04:00
|
|
|
|
|
|
|
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PHA_CODE ){
|
2024-05-17 17:45:30 -04:00
|
|
|
digi[ID]->WriteRegister(DPP::DPPAlgorithmControl, dppAlg, oldCh);
|
|
|
|
digi[ID]->WriteRegister(DPP::PHA::DPPAlgorithmControl2_G, dppAlg2, oldCh);
|
2024-10-21 15:11:33 -04:00
|
|
|
digi[ID]->WriteRegister(DPP::RegChannelEnableMask, chMask);
|
2024-05-17 16:41:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_PSD_CODE ){
|
2024-05-17 17:45:30 -04:00
|
|
|
digi[ID]->WriteRegister(DPP::DPPAlgorithmControl, dppAlg, oldCh);
|
|
|
|
digi[ID]->WriteRegister(DPP::PSD::DPPAlgorithmControl2_G, dppAlg2, oldCh);
|
2024-10-21 15:11:33 -04:00
|
|
|
digi[ID]->WriteRegister(DPP::RegChannelEnableMask, chMask);
|
2024-05-17 16:41:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){
|
2024-05-17 17:45:30 -04:00
|
|
|
digi[ID]->WriteRegister(DPP::QDC::DPPAlgorithmControl, dppAlg, oldCh);
|
2024-10-21 15:11:33 -04:00
|
|
|
digi[ID]->WriteRegister(DPP::QDC::GroupEnableMask, chMask);
|
|
|
|
digi[ID]->WriteRegister(DPP::QDC::SubChannelMask, subChMask);
|
2024-05-17 16:41:44 -04:00
|
|
|
}
|
2024-05-06 14:06:00 -04:00
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){
|
|
|
|
|
|
|
|
if( readDataThread[iDigi]->isRunning() ){
|
|
|
|
readDataThread[iDigi]->Stop();
|
|
|
|
readDataThread[iDigi]->quit();
|
|
|
|
readDataThread[iDigi]->wait();
|
|
|
|
readDataThread[iDigi]->SetScopeMode(false);
|
|
|
|
}
|
2024-08-29 16:49:52 -04:00
|
|
|
|
2024-05-06 14:06:00 -04:00
|
|
|
digiMTX[iDigi].lock();
|
|
|
|
digi[iDigi]->StopACQ();
|
|
|
|
//digi[iDigi]->GetData()->PrintAllData();
|
|
|
|
digiMTX[iDigi].unlock();
|
|
|
|
|
|
|
|
digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, traceOn[iDigi], -1);
|
|
|
|
//digi[iDigi]->WriteRegister(DPP::MaxAggregatePerBlockTransfer, AggPerRead[iDigi]);
|
|
|
|
|
|
|
|
}
|
2024-02-26 15:37:06 -05:00
|
|
|
|
2023-04-19 18:08:20 -04:00
|
|
|
}
|
|
|
|
|
2024-08-29 17:15:36 -04:00
|
|
|
runStatus->setStyleSheet(""); // cheated, don;t know why digi[iDigi]->GetACQStatusFromMemory(), sometimes return ACQ one.
|
2024-08-29 16:49:52 -04:00
|
|
|
|
2023-05-23 17:02:39 -04:00
|
|
|
emit UpdateOtherPanels();
|
|
|
|
|
2023-04-19 18:08:20 -04:00
|
|
|
bnScopeStart->setEnabled(true);
|
2023-06-23 13:50:21 -04:00
|
|
|
bnScopeStart->setStyleSheet("background-color: green;");
|
2023-04-19 18:08:20 -04:00
|
|
|
bnScopeStop->setEnabled(false);
|
2023-06-23 13:50:21 -04:00
|
|
|
bnScopeStop->setStyleSheet("");
|
2023-04-19 18:08:20 -04:00
|
|
|
|
2024-05-06 14:06:00 -04:00
|
|
|
chkSoleRun->setEnabled(true);
|
2023-12-12 17:59:45 -05:00
|
|
|
runStatus->setStyleSheet("");
|
|
|
|
|
2023-04-21 18:10:12 -04:00
|
|
|
EnableControl(true);
|
|
|
|
|
2024-08-29 16:49:52 -04:00
|
|
|
emit TellACQOnOff(false);
|
2023-05-16 14:31:19 -04:00
|
|
|
|
2023-06-23 13:50:21 -04:00
|
|
|
isACQStarted = false;
|
|
|
|
|
2023-05-22 17:00:11 -04:00
|
|
|
// printf("----- end of %s\n", __func__);
|
|
|
|
|
2023-04-19 18:08:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Scope::UpdateScope(){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-04-19 18:08:20 -04:00
|
|
|
if( !digi ) return;
|
|
|
|
|
|
|
|
int ch = cbScopeCh->currentIndex();
|
2023-05-24 16:04:32 -04:00
|
|
|
|
2023-10-09 17:46:32 -04:00
|
|
|
if( digi[ID]->GetInputChannelOnOff(ch) == false) return;
|
2023-05-24 16:04:32 -04:00
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
//printf("### %d %d \n", ch, digi[ID]->GetData()->DataIndex[ch]);
|
2023-10-19 15:32:44 -04:00
|
|
|
|
2024-01-25 16:18:47 -05:00
|
|
|
uint32_t acqStatus = digi[ID]->GetACQStatusFromMemory();
|
2023-10-19 15:32:44 -04:00
|
|
|
if( ( acqStatus >> 2 ) & 0x1 ){
|
|
|
|
runStatus->setStyleSheet("background-color : green;");
|
|
|
|
}else{
|
|
|
|
runStatus->setStyleSheet("");
|
|
|
|
}
|
|
|
|
|
2024-01-29 17:23:11 -05:00
|
|
|
factor = digi[ID]->IsDualTrace_PHA() ? 2 : 1;
|
|
|
|
|
2023-04-19 18:08:20 -04:00
|
|
|
Data * data = digi[ID]->GetData();
|
2024-01-26 14:53:52 -05:00
|
|
|
int index = data->GetDataIndex(ch);
|
2024-01-25 16:18:47 -05:00
|
|
|
int traceLength = data->Waveform1[ch][index].size();
|
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) traceLength = data->DigiWaveform1[ch][index].size();
|
2023-04-19 18:08:20 -04:00
|
|
|
|
2024-01-25 16:18:47 -05:00
|
|
|
if( index < 0 || data->TriggerRate[ch] == 0){
|
2023-11-17 12:14:15 -05:00
|
|
|
leTriggerRate->setStyleSheet("font-weight : bold; color : red;");
|
|
|
|
leTriggerRate->setText("No Trigger");
|
|
|
|
}else{
|
|
|
|
leTriggerRate->setStyleSheet("");
|
|
|
|
leTriggerRate->setText(QString::number(data->TriggerRate[ch]));
|
|
|
|
}
|
2023-04-19 18:08:20 -04:00
|
|
|
|
2024-01-29 17:23:11 -05:00
|
|
|
if( traceLength * tick2ns * factor > MaxDisplayTraceTimeLength) traceLength = MaxDisplayTraceTimeLength / tick2ns/ factor;
|
2023-08-24 13:27:16 -04:00
|
|
|
|
2024-01-29 17:23:11 -05:00
|
|
|
//printf("--- %s| %d, %d, %d | %ld(%d) | %d, %d | %d\n", __func__, ch, data->GetLoopIndex(ch), index, data->Waveform1[ch][index].size(), traceLength, factor, tick2ns, traceLength * tick2ns * factor );
|
2024-02-23 18:31:39 -05:00
|
|
|
if( index > 0 ){
|
2023-04-19 18:08:20 -04:00
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
QVector<QPointF> points[5];
|
2023-05-16 17:21:40 -04:00
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) {
|
2024-01-25 16:18:47 -05:00
|
|
|
if( dataTrace[4]->count() > 0 ) dataTrace[4]->clear();
|
2023-08-17 12:38:15 -04:00
|
|
|
for( int i = 0; i < traceLength ; i++ ) {
|
2023-06-20 11:57:39 -04:00
|
|
|
points[0].append(QPointF(tick2ns * i * factor, (data->Waveform1[ch][index])[i]));
|
2023-08-17 12:38:15 -04:00
|
|
|
if( i < (int) data->Waveform2[ch][index].size() ) points[1].append(QPointF(tick2ns * i * factor, (data->Waveform2[ch][index])[i]));
|
2023-06-20 11:57:39 -04:00
|
|
|
if( i < (int) data->DigiWaveform1[ch][index].size() ) points[2].append(QPointF(tick2ns * i * factor, (data->DigiWaveform1[ch][index])[i] * 1000));
|
|
|
|
if( i < (int) data->DigiWaveform2[ch][index].size() ) points[3].append(QPointF(tick2ns * i * factor, (data->DigiWaveform2[ch][index])[i] * 1000 + 500));
|
2023-05-16 17:21:40 -04:00
|
|
|
}
|
2023-10-11 18:28:19 -04:00
|
|
|
dataTrace[0]->replace(points[0]);
|
|
|
|
dataTrace[1]->replace(points[1]);
|
|
|
|
dataTrace[2]->replace(points[2]);
|
|
|
|
dataTrace[3]->replace(points[3]);
|
2023-05-16 17:21:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) {
|
2024-01-25 16:18:47 -05:00
|
|
|
if( dataTrace[4]->count() > 0 ) dataTrace[4]->clear();
|
2023-08-24 13:27:16 -04:00
|
|
|
for( int i = 0; i < traceLength ; i++ ) {
|
2023-06-20 11:57:39 -04:00
|
|
|
points[0].append(QPointF(tick2ns * i * factor, (data->Waveform1[ch][index])[i]));
|
2023-08-17 12:38:15 -04:00
|
|
|
if( i < (int) data->Waveform2[ch][index].size() ) points[1].append(QPointF(tick2ns * i * factor, (data->Waveform2[ch][index])[i]));
|
2024-01-25 16:18:47 -05:00
|
|
|
if( i < (int) data->DigiWaveform1[ch][index].size() ) points[2].append(QPointF(tick2ns * i * factor, (data->DigiWaveform1[ch][index])[i] * 1000));
|
|
|
|
if( i < (int) data->DigiWaveform2[ch][index].size() ) points[3].append(QPointF(tick2ns * i * factor, (data->DigiWaveform2[ch][index])[i] * 1000 + 500));
|
2023-05-16 17:21:40 -04:00
|
|
|
}
|
2023-10-11 18:28:19 -04:00
|
|
|
dataTrace[0]->replace(points[0]);
|
|
|
|
dataTrace[1]->replace(points[1]);
|
|
|
|
dataTrace[2]->replace(points[2]);
|
|
|
|
dataTrace[3]->replace(points[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( digi[ID]->GetDPPType() == V1740_DPP_QDC_CODE ) {
|
2024-01-25 16:18:47 -05:00
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
for( int i = 0; i < traceLength ; i++ ) {
|
2024-01-25 16:18:47 -05:00
|
|
|
points[0].append(QPointF(tick2ns * i, (data->Waveform1[ch][index])[i]));
|
|
|
|
if( i < (int) data->DigiWaveform1[ch][index].size() ) points[1].append(QPointF(tick2ns * i, (data->DigiWaveform1[ch][index])[i] * 1000));
|
|
|
|
if( i < (int) data->DigiWaveform2[ch][index].size() ) points[2].append(QPointF(tick2ns * i, (data->DigiWaveform2[ch][index])[i] * 1000 + 500));
|
|
|
|
if( i < (int) data->DigiWaveform3[ch][index].size() ) points[3].append(QPointF(tick2ns * i, (data->DigiWaveform3[ch][index])[i] * 1000 + 1000));
|
|
|
|
if( i < (int) data->DigiWaveform4[ch][index].size() ) points[4].append(QPointF(tick2ns * i, (data->DigiWaveform4[ch][index])[i] * 1000 + 1500));
|
2023-10-11 18:28:19 -04:00
|
|
|
}
|
|
|
|
dataTrace[0]->replace(points[0]);
|
|
|
|
dataTrace[1]->replace(points[1]);
|
|
|
|
dataTrace[2]->replace(points[2]);
|
|
|
|
dataTrace[3]->replace(points[3]);
|
|
|
|
dataTrace[4]->replace(points[4]);
|
2023-04-20 18:15:30 -04:00
|
|
|
}
|
2023-04-19 18:08:20 -04:00
|
|
|
}
|
2023-12-12 19:01:41 -05:00
|
|
|
//data->ClearTriggerRate();
|
2024-01-25 16:18:47 -05:00
|
|
|
//digiMTX[ID].unlock();
|
2023-04-19 18:08:20 -04:00
|
|
|
|
2023-11-17 11:44:28 -05:00
|
|
|
// if( data->TriggerRate[ch] == 0 ){
|
|
|
|
// dataTrace[0]->clear();
|
|
|
|
// dataTrace[1]->clear();
|
|
|
|
// dataTrace[2]->clear();
|
|
|
|
// dataTrace[3]->clear();
|
|
|
|
// dataTrace[4]->clear();
|
|
|
|
// }
|
2023-06-23 13:50:21 -04:00
|
|
|
|
2023-06-20 11:57:39 -04:00
|
|
|
plot->axes(Qt::Horizontal).first()->setRange(0, tick2ns * traceLength * factor);
|
2023-04-18 13:12:05 -04:00
|
|
|
|
2024-01-25 16:18:47 -05:00
|
|
|
QCoreApplication::processEvents();
|
|
|
|
|
2023-04-18 13:12:05 -04:00
|
|
|
}
|
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
//*=======================================================
|
|
|
|
//*=======================================================
|
2023-04-21 18:10:12 -04:00
|
|
|
void Scope::SetUpComboBoxSimple(RComboBox * &cb, QString str, int row, int col){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-04-19 14:46:10 -04:00
|
|
|
QLabel * lb = new QLabel(str, settingGroup);
|
2023-04-19 13:41:43 -04:00
|
|
|
lb->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
2023-04-19 14:46:10 -04:00
|
|
|
settingLayout->addWidget(lb, row, col);
|
2023-04-19 13:41:43 -04:00
|
|
|
|
2023-04-19 14:46:10 -04:00
|
|
|
cb = new RComboBox(settingGroup);
|
|
|
|
settingLayout->addWidget(cb, row, col + 1);
|
2023-04-21 18:10:12 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-05-01 16:20:16 -04:00
|
|
|
void Scope::SetUpComboBox(RComboBox * &cb, QString str, int row, int col, const Reg para){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-04-21 18:10:12 -04:00
|
|
|
SetUpComboBoxSimple(cb, str, row, col);
|
|
|
|
|
|
|
|
for( int i = 0; i < (int) para.GetComboList().size(); i++){
|
|
|
|
cb->addItem(QString::fromStdString(para.GetComboList()[i].first), para.GetComboList()[i].second);
|
|
|
|
}
|
|
|
|
|
|
|
|
connect(cb, &RComboBox::currentIndexChanged, this , [=](){
|
|
|
|
if( ! enableSignalSlot ) return;
|
|
|
|
|
|
|
|
int ch = cbScopeCh->currentIndex();
|
|
|
|
int value = cb->currentData().toInt();
|
2023-10-11 18:28:19 -04:00
|
|
|
|
2024-03-02 00:33:08 -05:00
|
|
|
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ) {
|
2023-10-11 18:28:19 -04:00
|
|
|
int grp = ch/8; // convert ch to grp
|
|
|
|
|
|
|
|
digiMTX[ID].lock();
|
|
|
|
digi[ID]->WriteRegister(para, value, grp);
|
|
|
|
digiMTX[ID].unlock();
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
digiMTX[ID].lock();
|
|
|
|
digi[ID]->WriteRegister(para, value, ch);
|
|
|
|
digiMTX[ID].unlock();
|
|
|
|
|
|
|
|
}
|
2023-04-21 18:10:12 -04:00
|
|
|
|
|
|
|
QString msg;
|
|
|
|
msg = QString::fromStdString(para.GetName()) ;
|
|
|
|
msg += "|DIG:"+ QString::number(digi[ID]->GetSerialNumber()) + ",CH:" + (ch == -1 ? "All" : QString::number(ch));
|
|
|
|
msg += " = " + cb->currentText();
|
|
|
|
if( digi[ID]->GetErrorCode() == CAEN_DGTZ_Success ){
|
|
|
|
SendLogMsg(msg + " | OK.");
|
|
|
|
cb->setStyleSheet("");
|
2023-05-23 17:02:39 -04:00
|
|
|
emit UpdateOtherPanels();
|
2023-04-21 18:10:12 -04:00
|
|
|
}else{
|
|
|
|
SendLogMsg(msg + " | Fail.");
|
|
|
|
cb->setStyleSheet("color:red;");
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
}
|
|
|
|
|
2023-05-01 16:20:16 -04:00
|
|
|
void Scope::SetUpSpinBox(RSpinBox * &sb, QString str, int row, int col, const Reg para){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-04-19 14:46:10 -04:00
|
|
|
QLabel * lb = new QLabel(str, settingGroup);
|
2023-04-19 13:41:43 -04:00
|
|
|
lb->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
2023-04-19 14:46:10 -04:00
|
|
|
settingLayout->addWidget(lb, row, col);
|
2023-04-19 13:41:43 -04:00
|
|
|
|
2023-04-19 14:46:10 -04:00
|
|
|
sb = new RSpinBox(settingGroup);
|
2023-04-19 13:41:43 -04:00
|
|
|
if( para.GetPartialStep() != 0 ){
|
|
|
|
sb->setMinimum(0);
|
2023-06-20 11:57:39 -04:00
|
|
|
sb->setMaximum(para.GetMaxBit() * para.GetPartialStep() * tick2ns);
|
|
|
|
if( para.GetPartialStep() > 0 ) sb->setSingleStep(para.GetPartialStep() * tick2ns);
|
2023-04-19 13:41:43 -04:00
|
|
|
if( para.GetPartialStep() == -1 ) sb->setSingleStep(1);
|
|
|
|
}
|
2023-04-19 14:46:10 -04:00
|
|
|
settingLayout->addWidget(sb, row, col + 1);
|
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
connect(sb, &RSpinBox::valueChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
|
|
|
sb->setStyleSheet("color:blue");
|
|
|
|
});
|
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
connect(sb, &RSpinBox::returnPressed, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
|
|
|
if( sb->decimals() == 0 && sb->singleStep() != 1) {
|
|
|
|
double step = sb->singleStep();
|
|
|
|
double value = sb->value();
|
|
|
|
sb->setValue( (std::round(value/step)*step));
|
|
|
|
}
|
|
|
|
|
2023-04-20 18:15:30 -04:00
|
|
|
int ch = cbScopeCh->currentIndex();
|
2023-04-19 13:41:43 -04:00
|
|
|
//if( chkSetAllChannel->isChecked() ) ch = -1;
|
2023-04-20 18:15:30 -04:00
|
|
|
QString msg;
|
|
|
|
msg = QString::fromStdString(para.GetName()) + "|DIG:"+ QString::number(digi[ID]->GetSerialNumber()) + ",CH:" + (ch == -1 ? "All" : QString::number(ch));
|
|
|
|
msg += " = " + QString::number(sb->value());
|
|
|
|
|
2023-06-20 11:57:39 -04:00
|
|
|
uint32_t value = sb->value() / tick2ns / abs(para.GetPartialStep());
|
2023-04-20 18:15:30 -04:00
|
|
|
|
2024-01-19 13:21:59 -05:00
|
|
|
//todo NEED TO CHECK
|
|
|
|
// if( para == DPP::RecordLength_G){
|
|
|
|
// int factor = digi[ID]->IsDualTrace_PHA() ? 2 : 1;
|
|
|
|
// value = value * factor;
|
|
|
|
// }
|
2023-04-20 18:15:30 -04:00
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
if( para == DPP::ChannelDCOffset || para == DPP::QDC::DCOffset){
|
2023-04-21 18:10:12 -04:00
|
|
|
value = uint16_t((1.0 - sb->value()/100.) * 0xFFFF);
|
|
|
|
}
|
|
|
|
|
2024-08-13 12:45:24 -04:00
|
|
|
if( para == DPP::PHA::TriggerThreshold || para == DPP::PSD::TriggerThreshold){
|
2023-04-24 15:27:05 -04:00
|
|
|
value = sb->value();
|
|
|
|
}
|
|
|
|
|
2023-04-21 18:10:12 -04:00
|
|
|
msg += " | 0x" + QString::number(value, 16);
|
|
|
|
|
2024-03-02 00:33:08 -05:00
|
|
|
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){
|
2023-10-11 18:28:19 -04:00
|
|
|
int grp = ch/8; // convert ch to grp
|
|
|
|
digiMTX[ID].lock();
|
2024-08-13 12:45:24 -04:00
|
|
|
digi[ID]->WriteRegister(para, value, grp);
|
2023-10-11 18:28:19 -04:00
|
|
|
digiMTX[ID].unlock();
|
|
|
|
}else{
|
|
|
|
digiMTX[ID].lock();
|
|
|
|
digi[ID]->WriteRegister(para, value, ch);
|
|
|
|
digiMTX[ID].unlock();
|
|
|
|
}
|
2023-06-23 13:50:21 -04:00
|
|
|
|
2023-04-20 18:15:30 -04:00
|
|
|
if( digi[ID]->GetErrorCode() == CAEN_DGTZ_Success ){
|
2023-04-21 18:10:12 -04:00
|
|
|
SendLogMsg(msg + " | OK.");
|
2023-04-20 18:15:30 -04:00
|
|
|
sb->setStyleSheet("");
|
2023-05-23 17:02:39 -04:00
|
|
|
emit UpdateOtherPanels();
|
2023-04-20 18:15:30 -04:00
|
|
|
}else{
|
2023-04-21 18:10:12 -04:00
|
|
|
SendLogMsg(msg + " | Fail.");
|
2023-04-20 18:15:30 -04:00
|
|
|
sb->setStyleSheet("color:red;");
|
|
|
|
}
|
2023-04-19 13:41:43 -04:00
|
|
|
});
|
2023-04-19 14:46:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void Scope::CleanUpSettingsGroupBox(){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-04-19 14:46:10 -04:00
|
|
|
QList<QLabel *> labelChildren1 = settingGroup->findChildren<QLabel *>();
|
|
|
|
for( int i = 0; i < labelChildren1.size(); i++) delete labelChildren1[i];
|
|
|
|
|
|
|
|
QList<RComboBox *> labelChildren2 = settingGroup->findChildren<RComboBox *>();
|
|
|
|
for( int i = 0; i < labelChildren2.size(); i++) delete labelChildren2[i];
|
|
|
|
|
|
|
|
QList<RSpinBox *> labelChildren3 = settingGroup->findChildren<RSpinBox *>();
|
|
|
|
for( int i = 0; i < labelChildren3.size(); i++) delete labelChildren3[i];
|
2023-04-19 13:41:43 -04:00
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
NullThePointers();
|
|
|
|
|
2023-04-19 13:41:43 -04:00
|
|
|
}
|
2023-04-19 14:46:10 -04:00
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
void Scope::SetUpPanel_PHA(){
|
2023-04-21 18:10:12 -04:00
|
|
|
printf("--- %s \n", __func__);
|
2023-04-19 14:46:10 -04:00
|
|
|
|
2023-04-24 15:27:05 -04:00
|
|
|
enableSignalSlot = false;
|
2023-04-20 18:15:30 -04:00
|
|
|
|
2023-04-24 15:27:05 -04:00
|
|
|
int rowID = 0;
|
2023-05-01 16:20:16 -04:00
|
|
|
SetUpSpinBox(sbReordLength, "Record Length [ns] ", rowID, 0, DPP::RecordLength_G);
|
|
|
|
SetUpSpinBox(sbPreTrigger, "Pre Trigger [ns] ", rowID, 2, DPP::PreTrigger);
|
|
|
|
SetUpSpinBox(sbDCOffset, "DC offset [%] ", rowID, 4, DPP::ChannelDCOffset);
|
2023-04-24 15:27:05 -04:00
|
|
|
sbDCOffset->setDecimals(2);
|
2023-05-01 16:20:16 -04:00
|
|
|
SetUpComboBox(cbDynamicRange, "Dynamic Range ", rowID, 6, DPP::InputDynamicRange);
|
2023-04-19 14:46:10 -04:00
|
|
|
|
2023-04-24 15:27:05 -04:00
|
|
|
rowID ++; //=============================================================
|
2023-05-01 16:20:16 -04:00
|
|
|
SetUpSpinBox(sbInputRiseTime, "Input Rise Time [ns] ", rowID, 0, DPP::PHA::InputRiseTime);
|
|
|
|
SetUpSpinBox(sbThreshold, "Threshold [LSB] ", rowID, 2, DPP::PHA::TriggerThreshold);
|
|
|
|
SetUpSpinBox(sbTriggerHoldOff,"Trigger HoldOff [ns] ", rowID, 4, DPP::PHA::TriggerHoldOffWidth);
|
|
|
|
SetUpComboBox(cbSmoothingFactor, "Smooth Factor ", rowID, 6, DPP::PHA::RCCR2SmoothingFactor);
|
2023-04-24 15:27:05 -04:00
|
|
|
|
|
|
|
rowID ++; //=============================================================
|
2023-05-01 16:20:16 -04:00
|
|
|
SetUpSpinBox(sbTrapRiseTime, "Trap. Rise Time [ns] ", rowID, 0, DPP::PHA::TrapezoidRiseTime);
|
|
|
|
SetUpSpinBox(sbTrapFlatTop, "Trap. FlatTop [ns] ", rowID, 2, DPP::PHA::TrapezoidFlatTop);
|
|
|
|
SetUpSpinBox(sbDecayTime, "Decay Time [ns] ", rowID, 4, DPP::PHA::DecayTime);
|
|
|
|
SetUpSpinBox(sbPeakingTime, "Peaking Time [ns] ", rowID, 6, DPP::PHA::PeakingTime);
|
2023-04-24 15:27:05 -04:00
|
|
|
|
|
|
|
rowID ++; //=============================================================
|
|
|
|
SetUpComboBoxSimple(cbPolarity, "Polarity ", rowID, 0);
|
2023-04-21 18:10:12 -04:00
|
|
|
cbPolarity->addItem("Positive", 0);
|
|
|
|
cbPolarity->addItem("Negative", 1);
|
2023-04-24 15:27:05 -04:00
|
|
|
connect(cbPolarity, &RComboBox::currentIndexChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
2023-05-09 12:16:08 -04:00
|
|
|
digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::Polarity, cbPolarity->currentData().toInt(), cbScopeCh->currentIndex());
|
2023-04-24 15:27:05 -04:00
|
|
|
});
|
2023-04-21 18:10:12 -04:00
|
|
|
|
2023-04-24 15:27:05 -04:00
|
|
|
SetUpComboBoxSimple(cbBaselineAvg, "Baseline Avg. ", rowID, 2);
|
2023-04-21 18:10:12 -04:00
|
|
|
cbBaselineAvg->addItem("Not evaluated", 0);
|
|
|
|
cbBaselineAvg->addItem("16 sample", 1);
|
|
|
|
cbBaselineAvg->addItem("64 sample", 2);
|
|
|
|
cbBaselineAvg->addItem("256 sample", 3);
|
|
|
|
cbBaselineAvg->addItem("1024 sample", 4);
|
|
|
|
cbBaselineAvg->addItem("4096 sample", 5);
|
|
|
|
cbBaselineAvg->addItem("16384 sample", 6);
|
2023-04-24 15:27:05 -04:00
|
|
|
connect(cbBaselineAvg, &RComboBox::currentIndexChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
2023-05-09 12:16:08 -04:00
|
|
|
digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::BaselineAvg, cbBaselineAvg->currentData().toInt(), cbScopeCh->currentIndex());
|
2023-04-24 15:27:05 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
SetUpComboBoxSimple(cbPeakAvg, "Peak Avg. ", rowID, 4);
|
|
|
|
cbPeakAvg->addItem("1 sample", 0);
|
|
|
|
cbPeakAvg->addItem("4 sample", 1);
|
|
|
|
cbPeakAvg->addItem("16 sample", 2);
|
|
|
|
cbPeakAvg->addItem("64 sample", 3);
|
|
|
|
connect(cbPeakAvg, &RComboBox::currentIndexChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
2023-05-09 12:16:08 -04:00
|
|
|
digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::PeakMean, cbPeakAvg->currentData().toInt(), cbScopeCh->currentIndex());
|
2023-04-24 15:27:05 -04:00
|
|
|
});
|
|
|
|
|
2023-05-01 16:20:16 -04:00
|
|
|
SetUpSpinBox(sbPeakHoldOff, "Peak HoldOff [ns] ", rowID, 6, DPP::PHA::PeakHoldOff);
|
2023-04-24 15:27:05 -04:00
|
|
|
|
|
|
|
|
|
|
|
rowID ++; //=============================================================
|
|
|
|
SetUpComboBoxSimple(cbAnaProbe1, "Ana. Probe 1 ", rowID, 0);
|
2023-05-15 17:18:53 -04:00
|
|
|
for( int i = 0; i < (int) DPP::Bit_BoardConfig::ListAnaProbe1_PHA.size(); i++){
|
|
|
|
cbAnaProbe1->addItem(QString::fromStdString(DPP::Bit_BoardConfig::ListAnaProbe1_PHA[i].first), DPP::Bit_BoardConfig::ListAnaProbe1_PHA[i].second);
|
|
|
|
}
|
2023-04-24 15:27:05 -04:00
|
|
|
connect(cbAnaProbe1, &RComboBox::currentIndexChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
2023-05-01 16:20:16 -04:00
|
|
|
digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::AnalogProbe1, cbAnaProbe1->currentData().toInt(), cbScopeCh->currentIndex());
|
2023-04-24 15:27:05 -04:00
|
|
|
dataTrace[0]->setName(cbAnaProbe1->currentText());
|
|
|
|
});
|
|
|
|
|
|
|
|
SetUpComboBoxSimple(cbAnaProbe2, "Ana. Probe 2 ", rowID, 2);
|
2023-05-15 17:18:53 -04:00
|
|
|
for( int i = 0; i < (int) DPP::Bit_BoardConfig::ListAnaProbe2_PHA.size(); i++){
|
|
|
|
cbAnaProbe2->addItem(QString::fromStdString(DPP::Bit_BoardConfig::ListAnaProbe2_PHA[i].first), DPP::Bit_BoardConfig::ListAnaProbe2_PHA[i].second);
|
|
|
|
}
|
2023-04-24 15:27:05 -04:00
|
|
|
connect(cbAnaProbe2, &RComboBox::currentIndexChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
2023-05-01 16:20:16 -04:00
|
|
|
digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::AnalogProbe2, cbAnaProbe2->currentData().toInt(), cbScopeCh->currentIndex());
|
2023-04-24 15:27:05 -04:00
|
|
|
dataTrace[1]->setName(cbAnaProbe2->currentText());
|
|
|
|
});
|
|
|
|
|
|
|
|
SetUpComboBoxSimple(cbDigiProbe1, "Digi. Probe 1 ", rowID, 4);
|
2023-05-15 17:18:53 -04:00
|
|
|
for( int i = 0; i < (int) DPP::Bit_BoardConfig::ListDigiProbe1_PHA.size(); i++){
|
|
|
|
cbDigiProbe1->addItem(QString::fromStdString(DPP::Bit_BoardConfig::ListDigiProbe1_PHA[i].first), DPP::Bit_BoardConfig::ListDigiProbe1_PHA[i].second);
|
|
|
|
}
|
2023-04-24 15:27:05 -04:00
|
|
|
connect(cbDigiProbe1, &RComboBox::currentIndexChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
2023-05-16 17:21:40 -04:00
|
|
|
digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1_PHA, cbDigiProbe1->currentData().toInt(), cbScopeCh->currentIndex());
|
2023-05-15 17:18:53 -04:00
|
|
|
dataTrace[2]->setName(cbDigiProbe1->currentText());
|
2023-04-24 15:27:05 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
SetUpComboBoxSimple(cbDigiProbe2, "Digi. Probe 2 ", rowID, 6);
|
2023-05-15 17:18:53 -04:00
|
|
|
for( int i = 0; i < (int) DPP::Bit_BoardConfig::ListDigiProbe2_PHA.size(); i++){
|
|
|
|
cbDigiProbe2->addItem(QString::fromStdString(DPP::Bit_BoardConfig::ListDigiProbe2_PHA[i].first), DPP::Bit_BoardConfig::ListDigiProbe2_PHA[i].second);
|
|
|
|
}
|
2023-04-24 15:27:05 -04:00
|
|
|
dataTrace[3]->setName(cbDigiProbe2->currentText());
|
|
|
|
cbDigiProbe2->setEnabled(false);
|
|
|
|
|
2023-10-12 16:27:56 -04:00
|
|
|
dataTrace[4]->setVisible(false);
|
|
|
|
|
2023-04-24 15:27:05 -04:00
|
|
|
enableSignalSlot = true;
|
2023-04-19 14:46:10 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
void Scope::SetUpPanel_PSD(){
|
2023-04-19 18:08:20 -04:00
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
enableSignalSlot = false;
|
|
|
|
printf("==== %s \n", __func__);
|
|
|
|
|
2023-04-24 15:27:05 -04:00
|
|
|
int rowID = 0;
|
2023-05-01 16:20:16 -04:00
|
|
|
SetUpSpinBox(sbReordLength, "Record Length [ns] ", rowID, 0, DPP::RecordLength_G);
|
|
|
|
SetUpSpinBox(sbPreTrigger, "Pre Trigger [ns] ", rowID, 2, DPP::PreTrigger);
|
|
|
|
SetUpSpinBox(sbDCOffset, "DC offset [%] ", rowID, 4, DPP::ChannelDCOffset);
|
2023-04-24 15:27:05 -04:00
|
|
|
sbDCOffset->setDecimals(2);
|
2023-05-01 16:20:16 -04:00
|
|
|
SetUpComboBox(cbDynamicRange, "Dynamic Range ", rowID, 6, DPP::InputDynamicRange);
|
2023-04-24 15:27:05 -04:00
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
|
2023-04-24 15:27:05 -04:00
|
|
|
rowID ++; //=============================================================
|
|
|
|
SetUpComboBoxSimple(cbPolarity, "Polarity ", rowID, 0);
|
|
|
|
cbPolarity->addItem("Positive", 0);
|
|
|
|
cbPolarity->addItem("Negative", 1);
|
|
|
|
connect(cbPolarity, &RComboBox::currentIndexChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
2023-10-11 18:28:19 -04:00
|
|
|
digi[ID]->SetBits(DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PSD::Polarity, cbPolarity->currentData().toInt(), cbScopeCh->currentIndex());
|
2023-04-24 15:27:05 -04:00
|
|
|
});
|
2023-05-12 16:06:32 -04:00
|
|
|
|
|
|
|
SetUpSpinBox(sbShortGate, "Short Gate [ns] ", rowID, 2, DPP::PSD::ShortGateWidth);
|
|
|
|
SetUpSpinBox(sbLongGate, "Long Gate [ns] ", rowID, 4, DPP::PSD::LongGateWidth);
|
|
|
|
SetUpSpinBox(sbGateOffset, "Gate Offset [ns] ", rowID, 6, DPP::PSD::GateOffset);
|
|
|
|
|
2023-05-15 17:18:53 -04:00
|
|
|
rowID ++; //=============================================================
|
2023-06-23 13:50:21 -04:00
|
|
|
SetUpSpinBox(sbThreshold, "Threshold [LSB] ", rowID, 0, DPP::PSD::TriggerThreshold);
|
|
|
|
SetUpComboBoxSimple(cbAnaProbe1, "Ana. Probe ", rowID, 2);
|
2023-05-15 17:18:53 -04:00
|
|
|
for( int i = 0; i < (int) DPP::Bit_BoardConfig::ListAnaProbe_PSD.size(); i++){
|
|
|
|
cbAnaProbe1->addItem(QString::fromStdString(DPP::Bit_BoardConfig::ListAnaProbe_PSD[i].first), DPP::Bit_BoardConfig::ListAnaProbe_PSD[i].second);
|
|
|
|
}
|
|
|
|
connect(cbAnaProbe1, &RComboBox::currentIndexChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
2023-10-05 12:26:17 -04:00
|
|
|
digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::AnalogProbe1, cbAnaProbe1->currentData().toInt(), cbScopeCh->currentIndex());
|
2023-05-16 17:21:40 -04:00
|
|
|
//dataTrace[0]->setName(cbAnaProbe1->currentText());
|
|
|
|
|
|
|
|
switch( cbAnaProbe1->currentIndex() ){
|
|
|
|
case 0 : dataTrace[0]->setName("input"); dataTrace[1]->setName("N/A"); break;
|
|
|
|
case 1 : dataTrace[0]->setName("CFD"); dataTrace[1]->setName("N/A"); break;
|
|
|
|
case 2 : dataTrace[0]->setName("baseline"); dataTrace[1]->setName("input"); break;
|
|
|
|
case 3 : dataTrace[0]->setName("baseline"); dataTrace[1]->setName("CFD"); break;
|
|
|
|
case 4 : dataTrace[0]->setName("CFD"); dataTrace[1]->setName("input"); break;
|
|
|
|
}
|
|
|
|
|
2023-05-15 17:18:53 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
SetUpComboBoxSimple(cbDigiProbe1, "Digi. Probe 1 ", rowID, 4);
|
|
|
|
for( int i = 0; i < (int) DPP::Bit_BoardConfig::ListDigiProbe1_PSD.size(); i++){
|
|
|
|
cbDigiProbe1->addItem(QString::fromStdString(DPP::Bit_BoardConfig::ListDigiProbe1_PSD[i].first), DPP::Bit_BoardConfig::ListDigiProbe1_PSD[i].second);
|
|
|
|
}
|
|
|
|
connect(cbDigiProbe1, &RComboBox::currentIndexChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
2023-05-16 17:21:40 -04:00
|
|
|
digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1_PSD, cbDigiProbe1->currentData().toInt(), cbScopeCh->currentIndex());
|
2023-05-15 17:18:53 -04:00
|
|
|
dataTrace[2]->setName(cbDigiProbe1->currentText());
|
|
|
|
});
|
|
|
|
|
|
|
|
SetUpComboBoxSimple(cbDigiProbe2, "Digi. Probe 2 ", rowID, 6);
|
|
|
|
for( int i = 0; i < (int) DPP::Bit_BoardConfig::ListDigiProbe2_PSD.size(); i++){
|
|
|
|
cbDigiProbe2->addItem(QString::fromStdString(DPP::Bit_BoardConfig::ListDigiProbe2_PSD[i].first), DPP::Bit_BoardConfig::ListDigiProbe2_PSD[i].second);
|
|
|
|
}
|
|
|
|
connect(cbDigiProbe2, &RComboBox::currentIndexChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
2023-05-16 17:21:40 -04:00
|
|
|
digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::DigiProbel1_PSD, cbDigiProbe1->currentData().toInt(), cbScopeCh->currentIndex());
|
2023-05-15 17:18:53 -04:00
|
|
|
dataTrace[3]->setName(cbDigiProbe2->currentText());
|
|
|
|
});
|
|
|
|
|
2023-10-12 16:27:56 -04:00
|
|
|
dataTrace[4]->setVisible(false);
|
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
enableSignalSlot = true;
|
2023-04-21 18:10:12 -04:00
|
|
|
}
|
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
void Scope::SetUpPanel_QDC() {
|
|
|
|
|
|
|
|
enableSignalSlot = false;
|
|
|
|
printf("==== %s \n", __func__);
|
|
|
|
|
|
|
|
int rowID = 0;
|
2023-10-19 15:32:44 -04:00
|
|
|
|
2024-03-19 18:36:49 -04:00
|
|
|
SetUpSpinBox(sbReordLength, "Record Length [ns] ", rowID, 0, DPP::QDC::RecordLength_W);
|
2023-10-11 18:28:19 -04:00
|
|
|
SetUpSpinBox(sbPreTrigger, "Pre Trigger [ns] ", rowID, 2, DPP::QDC::PreTrigger);
|
|
|
|
SetUpSpinBox(sbDCOffset, "DC offset [%] ", rowID, 4, DPP::QDC::DCOffset);
|
|
|
|
sbDCOffset->setDecimals(2);
|
|
|
|
|
|
|
|
SetUpComboBoxSimple(cbPolarity, "Polarity ", rowID, 6);
|
|
|
|
cbPolarity->addItem("Positive", 0);
|
|
|
|
cbPolarity->addItem("Negative", 1);
|
|
|
|
connect(cbPolarity, &RComboBox::currentIndexChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
2023-10-19 15:32:44 -04:00
|
|
|
digi[ID]->SetBits(DPP::QDC::DPPAlgorithmControl, DPP::QDC::Bit_DPPAlgorithmControl::Polarity, cbPolarity->currentData().toInt(), cbScopeCh->currentIndex()/8);
|
2023-10-11 18:28:19 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
rowID ++; //=============================================================
|
|
|
|
SetUpSpinBox(sbShortGate, "Gate Width [ns] ", rowID, 0, DPP::QDC::GateWidth);
|
|
|
|
SetUpSpinBox(sbGateOffset, "Gate Offset [ns] ", rowID, 2, DPP::QDC::GateOffset);
|
|
|
|
|
|
|
|
|
2023-10-13 18:02:19 -04:00
|
|
|
QLabel * lb = new QLabel("Threshold [LSB] ", settingGroup);
|
2023-10-11 18:28:19 -04:00
|
|
|
lb->setAlignment(Qt::AlignRight | Qt::AlignCenter);
|
|
|
|
settingLayout->addWidget(lb, rowID, 4);
|
|
|
|
|
|
|
|
sbThreshold = new RSpinBox(settingGroup);
|
|
|
|
settingLayout->addWidget(sbThreshold, rowID, 5);
|
|
|
|
|
|
|
|
sbThreshold->setMinimum(0);
|
|
|
|
sbThreshold->setMaximum(0xFFF);
|
|
|
|
sbThreshold->setSingleStep(1);
|
|
|
|
|
|
|
|
connect(sbThreshold, &RSpinBox::valueChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
|
|
|
sbThreshold->setStyleSheet("color : blue;");
|
|
|
|
});
|
|
|
|
|
|
|
|
connect(sbThreshold, &RSpinBox::returnPressed, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
|
|
|
|
|
|
|
uint32_t value = sbThreshold->value();
|
|
|
|
sbThreshold->setStyleSheet("");
|
|
|
|
|
|
|
|
int ch = cbScopeCh->currentIndex();
|
|
|
|
|
|
|
|
int grp = ch/8;
|
|
|
|
int subCh = ch%8;
|
|
|
|
|
|
|
|
Reg para = DPP::QDC::TriggerThreshold_sub0;
|
|
|
|
|
|
|
|
digiMTX[ID].lock();
|
|
|
|
switch(subCh){
|
|
|
|
case 0: para = DPP::QDC::TriggerThreshold_sub0; break;
|
|
|
|
case 1: para = DPP::QDC::TriggerThreshold_sub1; break;
|
|
|
|
case 2: para = DPP::QDC::TriggerThreshold_sub2; break;
|
|
|
|
case 3: para = DPP::QDC::TriggerThreshold_sub3; break;
|
|
|
|
case 4: para = DPP::QDC::TriggerThreshold_sub4; break;
|
|
|
|
case 5: para = DPP::QDC::TriggerThreshold_sub5; break;
|
|
|
|
case 6: para = DPP::QDC::TriggerThreshold_sub6; break;
|
|
|
|
case 7: para = DPP::QDC::TriggerThreshold_sub7; break;
|
|
|
|
}
|
|
|
|
digiMTX[ID].unlock();
|
|
|
|
|
|
|
|
QString msg;
|
|
|
|
msg = QString::fromStdString(para.GetName()) + "|DIG:"+ QString::number(digi[ID]->GetSerialNumber()) + ",CH:" + (ch == -1 ? "All" : QString::number(ch));
|
|
|
|
msg += " = " + QString::number(sbThreshold->value());
|
|
|
|
msg += " | 0x" + QString::number(value, 16);
|
|
|
|
|
|
|
|
digi[ID]->WriteRegister(para, value, grp);
|
|
|
|
|
|
|
|
if( digi[ID]->GetErrorCode() == CAEN_DGTZ_Success ){
|
|
|
|
SendLogMsg(msg + " | OK.");
|
|
|
|
sbThreshold->setStyleSheet("");
|
|
|
|
emit UpdateOtherPanels();
|
|
|
|
}else{
|
|
|
|
SendLogMsg(msg + " | Fail.");
|
|
|
|
sbThreshold->setStyleSheet("color:red;");
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
rowID ++; //=============================================================
|
|
|
|
SetUpComboBoxSimple(cbAnaProbe1, "Ana. Probe ", rowID, 0);
|
|
|
|
for( int i = 0; i < (int) DPP::Bit_BoardConfig::ListAnaProbe_QDC.size(); i++){
|
|
|
|
cbAnaProbe1->addItem(QString::fromStdString(DPP::Bit_BoardConfig::ListAnaProbe_QDC[i].first), DPP::Bit_BoardConfig::ListAnaProbe_QDC[i].second);
|
|
|
|
}
|
|
|
|
connect(cbAnaProbe1, &RComboBox::currentIndexChanged, this, [=](){
|
|
|
|
if( !enableSignalSlot ) return;
|
|
|
|
digi[ID]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::AnalogProbe1, cbAnaProbe1->currentData().toInt(), cbScopeCh->currentIndex());
|
2023-10-12 16:27:56 -04:00
|
|
|
dataTrace[0]->setName(cbAnaProbe1->currentText());
|
2023-10-11 18:28:19 -04:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2023-10-12 16:27:56 -04:00
|
|
|
dataTrace[1]->setVisible(true); dataTrace[1]->setName("Gate");
|
|
|
|
dataTrace[2]->setVisible(true); dataTrace[2]->setName("Trigger");
|
|
|
|
dataTrace[3]->setVisible(true); dataTrace[3]->setName("Trigger HoldOff");
|
|
|
|
dataTrace[4]->setVisible(true); dataTrace[4]->setName("OverThreshold");
|
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
enableSignalSlot = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-04-21 18:10:12 -04:00
|
|
|
void Scope::EnableControl(bool enable){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-04-21 18:10:12 -04:00
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ){
|
|
|
|
|
2023-08-22 14:38:37 -04:00
|
|
|
sbReordLength->setEnabled(enable);
|
2023-04-21 18:10:12 -04:00
|
|
|
sbPreTrigger->setEnabled(enable);
|
2023-08-22 14:38:37 -04:00
|
|
|
sbDCOffset->setEnabled(enable);
|
|
|
|
cbDynamicRange->setEnabled(enable);
|
|
|
|
|
|
|
|
sbInputRiseTime->setEnabled(enable);
|
|
|
|
//sbThreshold->setEnabled(enable);
|
|
|
|
sbTriggerHoldOff->setEnabled(enable);
|
|
|
|
cbSmoothingFactor->setEnabled(enable);
|
|
|
|
|
2023-04-21 18:10:12 -04:00
|
|
|
sbTrapRiseTime->setEnabled(enable);
|
|
|
|
sbTrapFlatTop->setEnabled(enable);
|
|
|
|
sbDecayTime->setEnabled(enable);
|
2023-08-22 14:38:37 -04:00
|
|
|
sbPeakingTime->setEnabled(enable);
|
2023-04-21 18:10:12 -04:00
|
|
|
|
2023-08-22 14:38:37 -04:00
|
|
|
cbPolarity->setEnabled(enable);
|
|
|
|
cbBaselineAvg->setEnabled(enable);
|
|
|
|
cbPeakAvg->setEnabled(enable);
|
|
|
|
sbPeakHoldOff->setEnabled(enable);
|
2023-04-21 18:10:12 -04:00
|
|
|
|
2023-10-19 15:32:44 -04:00
|
|
|
}else{
|
|
|
|
|
|
|
|
settingGroup->setEnabled(enable);
|
|
|
|
|
2023-04-21 18:10:12 -04:00
|
|
|
}
|
|
|
|
|
2023-04-19 18:08:20 -04:00
|
|
|
}
|
2023-04-20 18:15:30 -04:00
|
|
|
|
|
|
|
//*=======================================================
|
|
|
|
//*=======================================================
|
|
|
|
|
2023-05-01 16:20:16 -04:00
|
|
|
void Scope::UpdateComobox(RComboBox * &cb, const Reg para){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-04-21 18:10:12 -04:00
|
|
|
int ch = cbScopeCh->currentIndex();
|
|
|
|
|
|
|
|
enableSignalSlot = false;
|
2023-10-11 18:28:19 -04:00
|
|
|
int haha = -99;
|
|
|
|
|
2024-03-02 00:33:08 -05:00
|
|
|
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ){
|
2023-10-11 18:28:19 -04:00
|
|
|
haha = digi[ID]->GetSettingFromMemory(para, ch/8);
|
|
|
|
}else{
|
|
|
|
haha = digi[ID]->GetSettingFromMemory(para, ch);
|
|
|
|
}
|
2023-04-21 18:10:12 -04:00
|
|
|
|
|
|
|
for( int i = 0; i < cb->count(); i++){
|
|
|
|
int kaka = cb->itemData(i).toInt();
|
|
|
|
if( kaka == haha ){
|
|
|
|
cb->setCurrentIndex(i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-24 15:27:05 -04:00
|
|
|
//enableSignalSlot = true;
|
2023-04-21 18:10:12 -04:00
|
|
|
}
|
|
|
|
|
2023-05-01 16:20:16 -04:00
|
|
|
void Scope::UpdateSpinBox(RSpinBox * &sb, const Reg para){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-04-20 18:15:30 -04:00
|
|
|
int ch = cbScopeCh->currentIndex();
|
|
|
|
|
2024-03-02 00:33:08 -05:00
|
|
|
if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ) ch = ch /8;
|
2023-10-11 18:28:19 -04:00
|
|
|
|
2023-04-21 18:10:12 -04:00
|
|
|
enableSignalSlot = false;
|
2023-04-20 18:15:30 -04:00
|
|
|
unsigned int haha = digi[ID]->GetSettingFromMemory(para, ch);
|
2023-05-16 14:31:19 -04:00
|
|
|
|
2023-06-20 11:57:39 -04:00
|
|
|
if( para.GetPartialStep() > 0 ) sb->setValue(haha * para.GetPartialStep() * tick2ns);
|
2023-04-20 18:15:30 -04:00
|
|
|
if( para.GetPartialStep() == -1 ) sb->setValue(haha);
|
2023-04-24 15:27:05 -04:00
|
|
|
//enableSignalSlot = true;
|
2023-04-20 18:15:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Scope::UpdatePanelFromMomeory(){
|
|
|
|
|
2023-04-24 15:27:05 -04:00
|
|
|
enableSignalSlot = false;
|
2023-10-23 12:53:51 -04:00
|
|
|
printf("==== Scope::%s \n", __func__);
|
2023-04-20 18:15:30 -04:00
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
int ch = cbScopeCh->currentIndex();
|
2023-04-20 18:15:30 -04:00
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) UpdatePanel_PHA();
|
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) UpdatePanel_PSD();
|
|
|
|
if( digi[ID]->GetDPPType() == V1740_DPP_QDC_CODE ) UpdatePanel_QDC();
|
2023-05-12 17:06:16 -04:00
|
|
|
|
2023-10-09 17:46:32 -04:00
|
|
|
settingGroup->setEnabled(digi[ID]->GetInputChannelOnOff(ch));
|
2023-05-24 16:04:32 -04:00
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
}
|
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
void Scope::UpdatePanel_PHA(){
|
2023-05-12 17:06:16 -04:00
|
|
|
enableSignalSlot = false;
|
2024-03-22 16:47:33 -04:00
|
|
|
printf("==== %s \n", __func__);
|
2023-05-12 17:06:16 -04:00
|
|
|
|
|
|
|
int ch = cbScopeCh->currentIndex();
|
2023-04-21 18:10:12 -04:00
|
|
|
|
2023-05-01 16:20:16 -04:00
|
|
|
uint32_t DPPAlg = digi[ID]->GetSettingFromMemory(DPP::DPPAlgorithmControl, ch);
|
2023-05-09 12:16:08 -04:00
|
|
|
if( Digitizer::ExtractBits(DPPAlg, DPP::Bit_DPPAlgorithmControl_PHA::Polarity) ){
|
2023-04-24 15:27:05 -04:00
|
|
|
cbPolarity->setCurrentIndex(1);
|
|
|
|
}else{
|
|
|
|
cbPolarity->setCurrentIndex(0);
|
|
|
|
}
|
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
unsigned int haha = digi[ID]->GetSettingFromMemory(DPP::RecordLength_G, ch);
|
|
|
|
sbReordLength->setValue(haha * DPP::RecordLength_G.GetPartialStep() * tick2ns);
|
|
|
|
|
|
|
|
haha = digi[ID]->GetSettingFromMemory(DPP::ChannelDCOffset, ch);
|
|
|
|
sbDCOffset->setValue((1.0 - haha * 1.0 / 0xFFFF) * 100 );
|
|
|
|
|
|
|
|
UpdateComobox(cbDynamicRange, DPP::InputDynamicRange);
|
|
|
|
UpdateSpinBox(sbPreTrigger, DPP::PreTrigger);
|
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
UpdateSpinBox(sbInputRiseTime, DPP::PHA::InputRiseTime);
|
|
|
|
UpdateSpinBox(sbThreshold, DPP::PHA::TriggerThreshold);
|
|
|
|
UpdateSpinBox(sbTriggerHoldOff, DPP::PHA::TriggerHoldOffWidth);
|
|
|
|
|
|
|
|
UpdateSpinBox(sbTrapRiseTime, DPP::PHA::TrapezoidRiseTime);
|
|
|
|
UpdateSpinBox(sbTrapFlatTop, DPP::PHA::TrapezoidFlatTop);
|
|
|
|
UpdateSpinBox(sbDecayTime, DPP::PHA::DecayTime);
|
|
|
|
UpdateSpinBox(sbPeakingTime, DPP::PHA::PeakingTime);
|
|
|
|
|
|
|
|
UpdateComobox(cbSmoothingFactor, DPP::PHA::RCCR2SmoothingFactor);
|
|
|
|
|
|
|
|
int temp = Digitizer::ExtractBits(DPPAlg, DPP::Bit_DPPAlgorithmControl_PHA::BaselineAvg);
|
|
|
|
for(int i = 0; i < cbBaselineAvg->count(); i++){
|
|
|
|
if( cbBaselineAvg->itemData(i).toInt() == temp) {
|
|
|
|
cbBaselineAvg->setCurrentIndex(i);
|
|
|
|
break;
|
2023-04-24 15:27:05 -04:00
|
|
|
}
|
2023-05-12 17:06:16 -04:00
|
|
|
}
|
2023-04-24 15:27:05 -04:00
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
temp = Digitizer::ExtractBits(DPPAlg, DPP::Bit_DPPAlgorithmControl_PHA::PeakMean);
|
|
|
|
for(int i = 0; i < cbPeakAvg->count(); i++){
|
|
|
|
if( cbPeakAvg->itemData(i).toInt() == temp) {
|
|
|
|
cbPeakAvg->setCurrentIndex(i);
|
|
|
|
break;
|
2023-04-24 15:27:05 -04:00
|
|
|
}
|
2023-05-12 17:06:16 -04:00
|
|
|
}
|
2023-04-24 15:27:05 -04:00
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
uint32_t BdCfg = digi[ID]->GetSettingFromMemory(DPP::BoardConfiguration);
|
2023-04-24 15:27:05 -04:00
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnalogProbe1);
|
|
|
|
for(int i = 0; i < cbAnaProbe1->count(); i++){
|
|
|
|
if( cbAnaProbe1->itemData(i).toInt() == temp) {
|
|
|
|
cbAnaProbe1->setCurrentIndex(i);
|
|
|
|
dataTrace[0]->setName(cbAnaProbe1->currentText());
|
|
|
|
break;
|
2023-04-24 15:27:05 -04:00
|
|
|
}
|
2023-05-12 17:06:16 -04:00
|
|
|
}
|
|
|
|
temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnalogProbe2);
|
|
|
|
for(int i = 0; i < cbAnaProbe2->count(); i++){
|
|
|
|
if( cbAnaProbe2->itemData(i).toInt() == temp) {
|
|
|
|
cbAnaProbe2->setCurrentIndex(i);
|
|
|
|
dataTrace[1]->setName(cbAnaProbe2->currentText());
|
|
|
|
break;
|
2023-04-24 15:27:05 -04:00
|
|
|
}
|
2023-05-12 17:06:16 -04:00
|
|
|
}
|
2023-05-16 17:21:40 -04:00
|
|
|
temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel1_PHA);
|
2023-05-12 17:06:16 -04:00
|
|
|
for(int i = 0; i < cbDigiProbe1->count(); i++){
|
|
|
|
if( cbDigiProbe1->itemData(i).toInt() == temp) {
|
|
|
|
cbDigiProbe1->setCurrentIndex(i);
|
|
|
|
dataTrace[2]->setName(cbDigiProbe1->currentText());
|
|
|
|
break;
|
2023-04-24 15:27:05 -04:00
|
|
|
}
|
2023-05-12 17:06:16 -04:00
|
|
|
}
|
2023-04-24 15:27:05 -04:00
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
enableSignalSlot = true;
|
|
|
|
}
|
2023-04-24 15:27:05 -04:00
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
void Scope::UpdatePanel_PSD(){
|
2023-05-12 17:06:16 -04:00
|
|
|
enableSignalSlot = false;
|
|
|
|
|
|
|
|
printf("==== %s \n", __func__);
|
|
|
|
|
2023-05-15 17:18:53 -04:00
|
|
|
int ch = cbScopeCh->currentIndex();
|
2023-05-12 17:06:16 -04:00
|
|
|
|
2023-05-15 17:18:53 -04:00
|
|
|
uint32_t DPPAlg = digi[ID]->GetSettingFromMemory(DPP::DPPAlgorithmControl, ch);
|
|
|
|
if( Digitizer::ExtractBits(DPPAlg, DPP::Bit_DPPAlgorithmControl_PSD::Polarity) ){
|
|
|
|
cbPolarity->setCurrentIndex(1);
|
|
|
|
}else{
|
|
|
|
cbPolarity->setCurrentIndex(0);
|
|
|
|
}
|
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
unsigned int haha = digi[ID]->GetSettingFromMemory(DPP::RecordLength_G, ch);
|
|
|
|
sbReordLength->setValue(haha * DPP::RecordLength_G.GetPartialStep() * tick2ns);
|
|
|
|
|
|
|
|
haha = digi[ID]->GetSettingFromMemory(DPP::ChannelDCOffset, ch);
|
|
|
|
sbDCOffset->setValue((1.0 - haha * 1.0 / 0xFFFF) * 100 );
|
|
|
|
|
|
|
|
UpdateComobox(cbDynamicRange, DPP::InputDynamicRange);
|
|
|
|
UpdateSpinBox(sbPreTrigger, DPP::PreTrigger);
|
|
|
|
|
2023-05-15 17:18:53 -04:00
|
|
|
UpdateSpinBox(sbShortGate, DPP::PSD::ShortGateWidth);
|
|
|
|
UpdateSpinBox(sbLongGate, DPP::PSD::LongGateWidth);
|
|
|
|
UpdateSpinBox(sbGateOffset, DPP::PSD::GateOffset);
|
2024-08-13 12:45:24 -04:00
|
|
|
UpdateSpinBox(sbThreshold, DPP::PSD::TriggerThreshold);
|
2023-05-12 17:06:16 -04:00
|
|
|
|
2023-05-15 17:18:53 -04:00
|
|
|
uint32_t BdCfg = digi[ID]->GetSettingFromMemory(DPP::BoardConfiguration, ch);
|
2023-05-12 17:06:16 -04:00
|
|
|
|
2023-10-05 12:26:17 -04:00
|
|
|
int temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnalogProbe1);
|
2023-05-15 17:18:53 -04:00
|
|
|
for( int i = 0; i < cbAnaProbe1->count(); i++){
|
|
|
|
if( cbAnaProbe1->itemData(i).toInt() == temp ) {
|
|
|
|
cbAnaProbe1->setCurrentIndex(i);
|
|
|
|
dataTrace[0]->setName(cbAnaProbe1->currentText());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-05-16 17:21:40 -04:00
|
|
|
temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel1_PSD);
|
2023-05-15 17:18:53 -04:00
|
|
|
for( int i = 0; i < cbDigiProbe1->count(); i++){
|
|
|
|
if( cbDigiProbe1->itemData(i).toInt() == temp ) {
|
|
|
|
cbDigiProbe1->setCurrentIndex(i);
|
|
|
|
dataTrace[2]->setName(cbDigiProbe1->currentText());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-05-16 17:21:40 -04:00
|
|
|
temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::DigiProbel2_PSD);
|
2023-05-15 17:18:53 -04:00
|
|
|
for( int i = 0; i < cbDigiProbe2->count(); i++){
|
|
|
|
if( cbDigiProbe2->itemData(i).toInt() == temp ) {
|
|
|
|
cbDigiProbe2->setCurrentIndex(i);
|
|
|
|
dataTrace[3]->setName(cbDigiProbe2->currentText());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2023-04-20 18:15:30 -04:00
|
|
|
|
2023-04-24 15:27:05 -04:00
|
|
|
enableSignalSlot = true;
|
2023-04-20 18:15:30 -04:00
|
|
|
}
|
2023-04-21 18:10:12 -04:00
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
void Scope::UpdatePanel_QDC(){
|
|
|
|
enableSignalSlot = false;
|
|
|
|
|
|
|
|
printf("==== %s \n", __func__);
|
2023-04-21 18:10:12 -04:00
|
|
|
|
|
|
|
int ch = cbScopeCh->currentIndex();
|
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
int grp = ch/8;
|
|
|
|
|
|
|
|
uint32_t DPPAlg = digi[ID]->GetSettingFromMemory(DPP::QDC::DPPAlgorithmControl, grp);
|
|
|
|
if( Digitizer::ExtractBits(DPPAlg, DPP::QDC::Bit_DPPAlgorithmControl::Polarity) ){
|
|
|
|
cbPolarity->setCurrentIndex(1);
|
|
|
|
}else{
|
|
|
|
cbPolarity->setCurrentIndex(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t haha = digi[ID]->GetSettingFromMemory(DPP::QDC::DCOffset, grp);
|
|
|
|
sbDCOffset->setValue((1.0 - haha * 1.0 / 0xFFFF) * 100 );
|
|
|
|
|
2024-03-19 18:36:49 -04:00
|
|
|
//UpdateSpinBox(sbReordLength, DPP::QDC::RecordLength);
|
2024-05-06 14:06:00 -04:00
|
|
|
sbReordLength->setValue(digi[ID]->ReadQDCRecordLength() * 8 * 16);
|
2023-10-11 18:28:19 -04:00
|
|
|
UpdateSpinBox(sbPreTrigger, DPP::QDC::PreTrigger);
|
|
|
|
|
|
|
|
UpdateSpinBox(sbShortGate, DPP::QDC::GateWidth);
|
|
|
|
UpdateSpinBox(sbGateOffset, DPP::QDC::GateOffset);
|
|
|
|
|
2023-10-13 18:02:19 -04:00
|
|
|
int subCh = ch%8;
|
|
|
|
uint32_t threshold = 0 ;
|
|
|
|
switch( subCh ){
|
|
|
|
case 0 : threshold = digi[ID]->GetSettingFromMemory(DPP::QDC::TriggerThreshold_sub0, grp); break;
|
|
|
|
case 1 : threshold = digi[ID]->GetSettingFromMemory(DPP::QDC::TriggerThreshold_sub1, grp); break;
|
|
|
|
case 2 : threshold = digi[ID]->GetSettingFromMemory(DPP::QDC::TriggerThreshold_sub2, grp); break;
|
|
|
|
case 3 : threshold = digi[ID]->GetSettingFromMemory(DPP::QDC::TriggerThreshold_sub3, grp); break;
|
|
|
|
case 4 : threshold = digi[ID]->GetSettingFromMemory(DPP::QDC::TriggerThreshold_sub4, grp); break;
|
|
|
|
case 5 : threshold = digi[ID]->GetSettingFromMemory(DPP::QDC::TriggerThreshold_sub5, grp); break;
|
|
|
|
case 6 : threshold = digi[ID]->GetSettingFromMemory(DPP::QDC::TriggerThreshold_sub6, grp); break;
|
|
|
|
case 7 : threshold = digi[ID]->GetSettingFromMemory(DPP::QDC::TriggerThreshold_sub7, grp); break;
|
|
|
|
}
|
|
|
|
sbThreshold->setValue(threshold);
|
2023-10-11 18:28:19 -04:00
|
|
|
|
|
|
|
|
|
|
|
uint32_t BdCfg = digi[ID]->GetSettingFromMemory(DPP::BoardConfiguration, 0);
|
|
|
|
|
|
|
|
int temp = Digitizer::ExtractBits(BdCfg, DPP::Bit_BoardConfig::AnalogProbe1);
|
|
|
|
for( int i = 0; i < cbAnaProbe1->count(); i++){
|
|
|
|
if( cbAnaProbe1->itemData(i).toInt() == temp ) {
|
|
|
|
cbAnaProbe1->setCurrentIndex(i);
|
|
|
|
dataTrace[0]->setName(cbAnaProbe1->currentText());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enableSignalSlot = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Scope::ReadSettingsFromBoard(){
|
2024-03-22 16:47:33 -04:00
|
|
|
DebugPrint("%s", "Scope");
|
2023-10-11 18:28:19 -04:00
|
|
|
digi[ID]->ReadRegister(DPP::BoardConfiguration);
|
2023-04-21 18:10:12 -04:00
|
|
|
|
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ){
|
2023-10-11 18:28:19 -04:00
|
|
|
int ch = cbScopeCh->currentIndex();
|
|
|
|
|
|
|
|
digi[ID]->ReadRegister(DPP::RecordLength_G, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::PreTrigger, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::ChannelDCOffset, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::InputDynamicRange, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::BoardConfiguration, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::DPPAlgorithmControl, ch);
|
2023-04-21 18:10:12 -04:00
|
|
|
|
2023-05-01 16:20:16 -04:00
|
|
|
digi[ID]->ReadRegister(DPP::PHA::InputRiseTime, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::PHA::TriggerThreshold, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::PHA::TriggerHoldOffWidth, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::PHA::TrapezoidRiseTime, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::PHA::TrapezoidFlatTop, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::PHA::DecayTime, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::PHA::PeakingTime, ch);
|
2023-04-21 18:10:12 -04:00
|
|
|
}
|
|
|
|
|
2023-05-12 17:06:16 -04:00
|
|
|
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE){
|
2023-10-11 18:28:19 -04:00
|
|
|
int ch = cbScopeCh->currentIndex();
|
|
|
|
|
|
|
|
digi[ID]->ReadRegister(DPP::RecordLength_G, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::PreTrigger, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::ChannelDCOffset, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::InputDynamicRange, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::BoardConfiguration, ch);
|
|
|
|
digi[ID]->ReadRegister(DPP::DPPAlgorithmControl, ch);
|
2023-05-12 17:06:16 -04:00
|
|
|
|
|
|
|
digi[ID]->ReadRegister(DPP::PSD::ShortGateWidth);
|
|
|
|
digi[ID]->ReadRegister(DPP::PSD::LongGateWidth);
|
|
|
|
digi[ID]->ReadRegister(DPP::PSD::GateOffset);
|
2023-10-11 18:28:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if( digi[ID]->GetDPPType() == V1740_DPP_QDC_CODE){
|
|
|
|
int ch = cbScopeCh->currentIndex();
|
|
|
|
int grp = ch/8;
|
|
|
|
|
2024-03-19 18:36:49 -04:00
|
|
|
//digi[ID]->ReadRegister(DPP::QDC::RecordLength, grp);
|
|
|
|
|
|
|
|
digi[ID]->ReadQDCRecordLength();
|
|
|
|
|
2023-10-11 18:28:19 -04:00
|
|
|
digi[ID]->ReadRegister(DPP::QDC::PreTrigger, grp);
|
|
|
|
digi[ID]->ReadRegister(DPP::QDC::DCOffset, grp);
|
|
|
|
digi[ID]->ReadRegister(DPP::QDC::DPPAlgorithmControl, grp);
|
|
|
|
|
|
|
|
digi[ID]->ReadRegister(DPP::QDC::GateOffset, grp);
|
|
|
|
digi[ID]->ReadRegister(DPP::QDC::GateWidth, grp);
|
|
|
|
|
|
|
|
digi[ID]->ReadRegister(DPP::QDC::TriggerThreshold_sub0, grp);
|
|
|
|
digi[ID]->ReadRegister(DPP::QDC::TriggerThreshold_sub1, grp);
|
|
|
|
digi[ID]->ReadRegister(DPP::QDC::TriggerThreshold_sub2, grp);
|
|
|
|
digi[ID]->ReadRegister(DPP::QDC::TriggerThreshold_sub3, grp);
|
|
|
|
digi[ID]->ReadRegister(DPP::QDC::TriggerThreshold_sub4, grp);
|
|
|
|
digi[ID]->ReadRegister(DPP::QDC::TriggerThreshold_sub5, grp);
|
|
|
|
digi[ID]->ReadRegister(DPP::QDC::TriggerThreshold_sub6, grp);
|
|
|
|
digi[ID]->ReadRegister(DPP::QDC::TriggerThreshold_sub7, grp);
|
2023-05-12 17:06:16 -04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-04-21 18:10:12 -04:00
|
|
|
UpdatePanelFromMomeory();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|