bug fix for PHA single board

This commit is contained in:
splitPoleDAQ 2023-05-16 14:31:19 -04:00
parent 61b0f05bb7
commit e01d9fe4e6
7 changed files with 62 additions and 23 deletions

View File

@ -365,7 +365,7 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){
int indexStart = EventIndex[ch] - NumEventsDecoded[ch] + 1; int indexStart = EventIndex[ch] - NumEventsDecoded[ch] + 1;
if( indexStart < 0 ) indexStart += MaxNData; if( indexStart < 0 ) indexStart += MaxNData;
printf("%d %d| %d %d \n", EventIndex[ch], NumEventsDecoded[ch], indexStart, EventIndex[ch] ); //printf("%d %d| %d %d \n", EventIndex[ch], NumEventsDecoded[ch], indexStart, EventIndex[ch] );
unsigned long long dTime = Timestamp[ch][EventIndex[ch]] - Timestamp[ch][indexStart]; unsigned long long dTime = Timestamp[ch][EventIndex[ch]] - Timestamp[ch][indexStart];
double sec = dTime * ch2ns / 1e9; double sec = dTime * ch2ns / 1e9;

View File

@ -323,7 +323,7 @@ int Digitizer::ProgramPHABoard(){
address = DPP::PHA::TriggerHoldOffWidth; ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 0x3E ); address = DPP::PHA::TriggerHoldOffWidth; ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 0x3E );
address = DPP::PHA::RiseTimeValidationWindow;ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 0x0 ); address = DPP::PHA::RiseTimeValidationWindow;ret |= CAEN_DGTZ_WriteRegister(handle, address + 0x7000 , 0x0 );
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::ChannelDCOffset) + 0x7000 , 0xEEEE ); ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::ChannelDCOffset) + 0x7000 , 0x0CCC );
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::PreTrigger) + 0x7000 , 32 ); ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::PreTrigger) + 0x7000 , 32 );
ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::InputDynamicRange) + 0x7000 , 0x0 ); ret |= CAEN_DGTZ_WriteRegister(handle, (uint32_t)(DPP::InputDynamicRange) + 0x7000 , 0x0 );

View File

@ -40,11 +40,10 @@ public:
break; break;
} }
} }
printf("ReadDataThread stopped.\n");
} }
signals: signals:
void sendMsg(const QString &msg); void sendMsg(const QString &msg);
//void endOfLastData();
//void checkFileSize();
private: private:
Digitizer * digi; Digitizer * digi;
int ID; int ID;

View File

@ -724,6 +724,11 @@ void DigiSettingsPanel::SetUpSpinBox(RSpinBox * &sb, QString label, QGridLayout
sb->setSingleStep(para.GetPartialStep() * digi[ID]->GetCh2ns()); sb->setSingleStep(para.GetPartialStep() * digi[ID]->GetCh2ns());
} }
if( para == DPP::DPPAlgorithmControl ) {
sb->setSingleStep(1);
sb->setMaximum(0x3F);
}
connect(sb, &RSpinBox::valueChanged, this, [=](){ connect(sb, &RSpinBox::valueChanged, this, [=](){
if( !enableSignalSlot ) return; if( !enableSignalSlot ) return;
sb->setStyleSheet("color : blue;"); sb->setStyleSheet("color : blue;");
@ -756,6 +761,12 @@ void DigiSettingsPanel::SetUpSpinBox(RSpinBox * &sb, QString label, QGridLayout
return; return;
} }
if( para == DPP::DPPAlgorithmControl ){
digi[ID]->SetBits(para, {5,0}, sb->value(), chID);
UpdatePanelFromMemory();
return;
}
uint32_t bit = para.GetPartialStep() == -1 ? sb->value() : sb->value() / para.GetPartialStep() / digi[ID]->GetCh2ns(); uint32_t bit = para.GetPartialStep() == -1 ? sb->value() : sb->value() / para.GetPartialStep() / digi[ID]->GetCh2ns();
digi[ID]->WriteRegister(para, bit, chID); digi[ID]->WriteRegister(para, bit, chID);
@ -1366,7 +1377,7 @@ void DigiSettingsPanel::SetUpPHAChannel(){
SetUpSpinBox(sbTrapRiseTime[ID][MaxNChannels], "Rise Time [ns] : ", trapLayout, 0, 0, DPP::PHA::TrapezoidRiseTime); SetUpSpinBox(sbTrapRiseTime[ID][MaxNChannels], "Rise Time [ns] : ", trapLayout, 0, 0, DPP::PHA::TrapezoidRiseTime);
SetUpSpinBox(sbTrapFlatTop[ID][MaxNChannels], "Flat Top [ns] : ", trapLayout, 0, 2, DPP::PHA::TrapezoidFlatTop); SetUpSpinBox(sbTrapFlatTop[ID][MaxNChannels], "Flat Top [ns] : ", trapLayout, 0, 2, DPP::PHA::TrapezoidFlatTop);
SetUpSpinBox(sbDecay[ID][MaxNChannels], "Decay [ns] : ", trapLayout, 1, 0, DPP::PHA::DecayTime); SetUpSpinBox(sbDecay[ID][MaxNChannels], "Decay [ns] : ", trapLayout, 1, 0, DPP::PHA::DecayTime);
SetUpSpinBox(sbTrapScaling[ID][MaxNChannels], "Rescaling : ", trapLayout, 1, 2, DPP::PHA::DPPAlgorithmControl2_G); SetUpSpinBox(sbTrapScaling[ID][MaxNChannels], "Rescaling : ", trapLayout, 1, 2, DPP::DPPAlgorithmControl);
SetUpSpinBox(sbPeaking[ID][MaxNChannels], "Peaking [ns] : ", trapLayout, 2, 0, DPP::PHA::PeakingTime); SetUpSpinBox(sbPeaking[ID][MaxNChannels], "Peaking [ns] : ", trapLayout, 2, 0, DPP::PHA::PeakingTime);
SetUpSpinBox(sbPeakingHoldOff[ID][MaxNChannels], "Peak Hold-off [ns] : ", trapLayout, 2, 2, DPP::PHA::PeakHoldOff); SetUpSpinBox(sbPeakingHoldOff[ID][MaxNChannels], "Peak Hold-off [ns] : ", trapLayout, 2, 2, DPP::PHA::PeakHoldOff);
SetUpComboBoxBit(cbPeakAvg[ID][MaxNChannels], "Peak Avg. : ", trapLayout, 3, 0, DPP::Bit_DPPAlgorithmControl_PHA::ListPeakMean, DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::PeakMean); SetUpComboBoxBit(cbPeakAvg[ID][MaxNChannels], "Peak Avg. : ", trapLayout, 3, 0, DPP::Bit_DPPAlgorithmControl_PHA::ListPeakMean, DPP::DPPAlgorithmControl, DPP::Bit_DPPAlgorithmControl_PHA::PeakMean);
@ -2554,6 +2565,11 @@ void DigiSettingsPanel::UpdateSpinBox(RSpinBox * &sb, Reg para, int ch){
return; return;
} }
if( para == DPP::DPPAlgorithmControl ){
sb->setValue( value & 0x3F );
return;
}
sb->setValue( pStep > 0 ? value * pStep * ch2ns : value); sb->setValue( pStep > 0 ? value * pStep * ch2ns : value);
//printf("%d, %s | %d %d %u, %f\n", para.GetNameChar(), ch, ch2ns, pStep, value, sb->value()); //printf("%d, %s | %d %d %u, %f\n", para.GetNameChar(), ch, ch2ns, pStep, value, sb->value());

View File

@ -24,6 +24,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
digi = nullptr; digi = nullptr;
nDigi = 0; nDigi = 0;
scalar = nullptr;
scope = nullptr; scope = nullptr;
digiSettings = nullptr; digiSettings = nullptr;
@ -183,7 +184,6 @@ MainWindow::~MainWindow(){
delete scalarThread; delete scalarThread;
} }
} }
//*************************************************************** //***************************************************************
@ -448,7 +448,6 @@ void MainWindow::WaitForDigitizersOpen(bool onOff){
bnStopACQ->setEnabled(!onOff); bnStopACQ->setEnabled(!onOff);
chkSaveData->setEnabled(!onOff); chkSaveData->setEnabled(!onOff);
} }
//*************************************************************** //***************************************************************
@ -609,9 +608,11 @@ void MainWindow::StartACQ(){
if( commentResult == false) return; if( commentResult == false) return;
for( unsigned int i = 0; i < nDigi ; i++){ for( unsigned int i = 0; i < nDigi ; i++){
if( chkSaveData->isChecked() ) {
digi[i]->GetData()->OpenSaveFile((rawDataPath + "/" + prefix).toStdString()); digi[i]->GetData()->OpenSaveFile((rawDataPath + "/" + prefix).toStdString());
digi[i]->StartACQ();
readDataThread[i]->SetSaveData(chkSaveData->isChecked()); readDataThread[i]->SetSaveData(chkSaveData->isChecked());
}
digi[i]->StartACQ();
readDataThread[i]->start(); readDataThread[i]->start();
} }
if( chkSaveData->isChecked() ) SaveLastRunFile(); if( chkSaveData->isChecked() ) SaveLastRunFile();
@ -626,6 +627,7 @@ void MainWindow::StartACQ(){
bnStartACQ->setEnabled(false); bnStartACQ->setEnabled(false);
bnStopACQ->setEnabled(true); bnStopACQ->setEnabled(true);
bnOpenScope->setEnabled(false);
} }
@ -656,6 +658,7 @@ void MainWindow::StopACQ(){
bnStartACQ->setEnabled(true); bnStartACQ->setEnabled(true);
bnStopACQ->setEnabled(false); bnStopACQ->setEnabled(false);
bnOpenScope->setEnabled(true);
} }
void MainWindow::AutoRun(){ void MainWindow::AutoRun(){
@ -764,12 +767,19 @@ void MainWindow::OpenScope(){
if( scope == nullptr ) { if( scope == nullptr ) {
scope = new Scope(digi, nDigi, readDataThread); scope = new Scope(digi, nDigi, readDataThread);
connect(scope, &Scope::SendLogMsg, this, &MainWindow::LogMsg); connect(scope, &Scope::SendLogMsg, this, &MainWindow::LogMsg);
connect(scope, &Scope::CloseWindow, this, [=](){
bnStartACQ->setEnabled(true);
bnStopACQ->setEnabled(false);
});
scope->show(); scope->show();
}else{ }else{
scope->show(); scope->show();
scope->activateWindow(); scope->activateWindow();
} }
bnStartACQ->setEnabled(false);
bnStopACQ->setEnabled(false);
} }
//*************************************************************** //***************************************************************

View File

@ -236,6 +236,8 @@ void Scope::StartScope(){
EnableControl(false); EnableControl(false);
TellACQOnOff(true);
} }
void Scope::StopScope(){ void Scope::StopScope(){
@ -247,8 +249,9 @@ void Scope::StopScope(){
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){ for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){
digiMTX[iDigi].lock();
digi[iDigi]->StopACQ(); digi[iDigi]->StopACQ();
digiMTX[iDigi].unlock();
readDataThread[iDigi]->quit(); readDataThread[iDigi]->quit();
readDataThread[iDigi]->wait(); readDataThread[iDigi]->wait();
@ -259,6 +262,8 @@ void Scope::StopScope(){
EnableControl(true); EnableControl(true);
TellACQOnOff(false);
} }
void Scope::UpdateScope(){ void Scope::UpdateScope(){
@ -269,6 +274,7 @@ void Scope::UpdateScope(){
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
int ch2ns = digi[ID]->GetCh2ns(); int ch2ns = digi[ID]->GetCh2ns();
int factor = digi[ID]->IsDualTrace() ? 2 : 1;
Data * data = digi[ID]->GetData(); Data * data = digi[ID]->GetData();
@ -285,10 +291,10 @@ void Scope::UpdateScope(){
QVector<QPointF> points[4]; QVector<QPointF> points[4];
for( int i = 0; i < (int) (data->Waveform1[ch][index]).size() ; i++ ) { for( int i = 0; i < (int) (data->Waveform1[ch][index]).size() ; i++ ) {
points[0].append(QPointF(ch2ns * i, (data->Waveform1[ch][index])[i])); points[0].append(QPointF(ch2ns * i * factor, (data->Waveform1[ch][index])[i]));
if( i < (int) data->Waveform2[ch][index].size() ) points[1].append(QPointF(ch2ns * i, (data->Waveform2[ch][index])[i])); if( i < (int) data->Waveform2[ch][index].size() ) points[1].append(QPointF(ch2ns * i * factor, (data->Waveform2[ch][index])[i]));
if( i < (int) data->DigiWaveform1[ch][index].size() ) points[2].append(QPointF(ch2ns * i, (data->DigiWaveform1[ch][index])[i] * 1000)); if( i < (int) data->DigiWaveform1[ch][index].size() ) points[2].append(QPointF(ch2ns * i * factor, (data->DigiWaveform1[ch][index])[i] * 1000));
if( i < (int) data->DigiWaveform2[ch][index].size() ) points[3].append(QPointF(ch2ns * i, (data->DigiWaveform2[ch][index])[i] * 1000 + 500)); if( i < (int) data->DigiWaveform2[ch][index].size() ) points[3].append(QPointF(ch2ns * i * factor, (data->DigiWaveform2[ch][index])[i] * 1000 + 500));
} }
dataTrace[0]->replace(points[0]); dataTrace[0]->replace(points[0]);
dataTrace[1]->replace(points[1]); dataTrace[1]->replace(points[1]);
@ -297,8 +303,7 @@ void Scope::UpdateScope(){
} }
digiMTX[ID].unlock(); digiMTX[ID].unlock();
plot->axes(Qt::Horizontal).first()->setRange(0, ch2ns * traceLength); plot->axes(Qt::Horizontal).first()->setRange(0, ch2ns * traceLength * factor);
//plotView->SetHRange(0, ch2ns * traceLength);
} }
@ -384,7 +389,7 @@ void Scope::SetUpSpinBox(RSpinBox * &sb, QString str, int row, int col, const Re
uint32_t value = sb->value() / ch2ns / abs(para.GetPartialStep()); uint32_t value = sb->value() / ch2ns / abs(para.GetPartialStep());
if( para == DPP::RecordLength_G || para == DPP::PreTrigger){ if( para == DPP::RecordLength_G){
int factor = digi[ID]->IsDualTrace() ? 2 : 1; int factor = digi[ID]->IsDualTrace() ? 2 : 1;
value = value * factor; value = value * factor;
} }
@ -628,6 +633,7 @@ void Scope::UpdateSpinBox(RSpinBox * &sb, const Reg para){
enableSignalSlot = false; enableSignalSlot = false;
unsigned int haha = digi[ID]->GetSettingFromMemory(para, ch); unsigned int haha = digi[ID]->GetSettingFromMemory(para, ch);
if( para.GetPartialStep() > 0 ) sb->setValue(haha * para.GetPartialStep() * ch2ns); if( para.GetPartialStep() > 0 ) sb->setValue(haha * para.GetPartialStep() * ch2ns);
if( para.GetPartialStep() == -1 ) sb->setValue(haha); if( para.GetPartialStep() == -1 ) sb->setValue(haha);
//enableSignalSlot = true; //enableSignalSlot = true;
@ -642,13 +648,13 @@ void Scope::UpdatePanelFromMomeory(){
int ch = cbScopeCh->currentIndex(); int ch = cbScopeCh->currentIndex();
unsigned int haha = digi[ID]->GetSettingFromMemory(DPP::RecordLength_G, ch); unsigned int haha = digi[ID]->GetSettingFromMemory(DPP::RecordLength_G, ch);
if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ){
int factor = digi[ID]->IsDualTrace() ? 2 : 1; // if dual trace,
sbReordLength->setValue(haha * DPP::RecordLength_G.GetPartialStep() * ch2ns / factor);
}else{
sbReordLength->setValue(haha * DPP::RecordLength_G.GetPartialStep() * ch2ns); sbReordLength->setValue(haha * DPP::RecordLength_G.GetPartialStep() * ch2ns);
}
// if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ){
// int factor = digi[ID]->IsDualTrace() ? 2 : 1; // if dual trace,
// sbReordLength->setValue(haha * DPP::RecordLength_G.GetPartialStep() * ch2ns / factor);
// }else{
// }
haha = digi[ID]->GetSettingFromMemory(DPP::ChannelDCOffset, ch); haha = digi[ID]->GetSettingFromMemory(DPP::ChannelDCOffset, ch);
sbDCOffset->setValue((1.0 - haha * 1.0 / 0xFFFF) * 100 ); sbDCOffset->setValue((1.0 - haha * 1.0 / 0xFFFF) * 100 );

View File

@ -31,6 +31,12 @@ public:
Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow * parent = nullptr); Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow * parent = nullptr);
~Scope(); ~Scope();
void closeEvent(QCloseEvent * event){
StopScope();
emit CloseWindow();
event->accept();
}
private slots: private slots:
void StartScope(); void StartScope();
void StopScope(); void StopScope();
@ -39,7 +45,9 @@ private slots:
signals: signals:
void CloseWindow();
void SendLogMsg(const QString &msg); void SendLogMsg(const QString &msg);
void TellACQOnOff(const bool onOff);
private: private: