cannot get trace, need to review the Digitizer Class using test.cpp
This commit is contained in:
parent
0000be1d44
commit
4a80fcc10d
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -8,6 +8,8 @@ programSettings.txt
|
|||
|
||||
data
|
||||
|
||||
*.txt
|
||||
|
||||
*~
|
||||
*.autosave
|
||||
moc_*
|
||||
|
|
15
ClassData.h
15
ClassData.h
|
@ -34,7 +34,8 @@ class Data{
|
|||
unsigned short NumEventsDecoded[MaxNChannels]; /// reset at every decode
|
||||
unsigned short NumNonPileUpDecoded[MaxNChannels]; /// reset at every decode
|
||||
|
||||
/// store data for event building
|
||||
/// store data for event building and deduce the trigger rate.
|
||||
//TODO... make it a circular memory
|
||||
bool IsNotRollOverFakeAgg;
|
||||
unsigned short NumEvents[MaxNChannels]; /// max 65535, reset only clear Data
|
||||
unsigned long long Timestamp[MaxNChannels][MaxNData]; /// 47 bit
|
||||
|
@ -68,7 +69,7 @@ class Data{
|
|||
|
||||
void PrintStat() const;
|
||||
|
||||
void PrintData() const;
|
||||
void PrintAllData() const;
|
||||
|
||||
//^================= Saving data
|
||||
void OpenSaveFile(std::string fileNamePrefix);
|
||||
|
@ -178,6 +179,7 @@ inline void Data::ClearData(){
|
|||
|
||||
inline void Data::ClearBuffer(){
|
||||
delete buffer;
|
||||
buffer = nullptr;
|
||||
AllocatedSize = 0;
|
||||
nByte = 0;
|
||||
}
|
||||
|
@ -245,7 +247,7 @@ inline void Data::PrintBuffer() const{
|
|||
}
|
||||
}
|
||||
|
||||
inline void Data::PrintData() const{
|
||||
inline void Data::PrintAllData() const{
|
||||
printf("============================= Print Data\n");
|
||||
for( int ch = 0; ch < MaxNChannels ; ch++){
|
||||
if( NumEvents[ch] == 0 ) continue;
|
||||
|
@ -280,12 +282,8 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){
|
|||
return;
|
||||
}
|
||||
|
||||
if( nByte == 0 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if( nByte == 0 ) return;
|
||||
nw = 0;
|
||||
|
||||
ClearTriggerRate();
|
||||
|
||||
do{
|
||||
|
@ -722,7 +720,6 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDe
|
|||
NumEvents[channel] ++;
|
||||
NumEventsDecoded[channel] ++;
|
||||
TotNumEvents[channel] ++;
|
||||
|
||||
}
|
||||
|
||||
if( NumEvents[channel] >= MaxNData ) ClearData();
|
||||
|
|
|
@ -288,7 +288,7 @@ int Digitizer::ProgramPHABoard(){
|
|||
printf("======== program board PHA\n");
|
||||
|
||||
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::RecordLength_G + 0x7000, 62);
|
||||
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x0F8915); /// has Extra2
|
||||
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x0F8915); /// has Extra2, dual trace, input and trap-baseline
|
||||
///ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x0D8115); /// diable Extra2
|
||||
|
||||
//TODO change to write register
|
||||
|
@ -369,6 +369,7 @@ void Digitizer::StopACQ(){
|
|||
printf("\n\e[1m\e[33m====== Acquisition STOPPED for Board %d\e[0m\n", boardID);
|
||||
AcqRun = false;
|
||||
data->ClearTriggerRate();
|
||||
data->ClearBuffer();
|
||||
}
|
||||
|
||||
unsigned int Digitizer::CalByteForBuffer(){
|
||||
|
@ -906,6 +907,7 @@ void Digitizer::SetPreTriggerDuration(unsigned int ns, int ch)
|
|||
void Digitizer::SetDCOffset(float offsetPrecentage, int ch) { WriteRegister( Register::DPP::ChannelDCOffset, uint( 0xFFFF * (1.0-offsetPrecentage)), ch ); ErrorMsg(__func__);}
|
||||
void Digitizer::SetVetoWidth(uint32_t bit, int ch) { WriteRegister( Register::DPP::VetoWidth, bit, ch); ErrorMsg(__func__);}
|
||||
|
||||
|
||||
void Digitizer::SetTriggerPolarity(bool RiseingIsZero, int ch ){
|
||||
if( !isConnected ) return;
|
||||
if ( DPPType >= 128 ) return; /// do thing for DPP firmware
|
||||
|
@ -926,7 +928,7 @@ void Digitizer::SetDPPAlgorithmControl(uint32_t bit, int ch){
|
|||
if( ret != 0 ) ErrorMsg(__func__);
|
||||
}
|
||||
|
||||
unsigned int Digitizer::ReadBits(Reg address, unsigned int bitLength, unsigned int bitSmallestPos, int ch ){
|
||||
unsigned int Digitizer::ReadBits(Register::Reg address, unsigned int bitLength, unsigned int bitSmallestPos, int ch ){
|
||||
int tempCh = ch;
|
||||
if (ch < 0 && address < 0x8000 ) tempCh = 0; /// take ch-0
|
||||
uint32_t bit = ReadRegister(address, tempCh);
|
||||
|
@ -934,7 +936,7 @@ unsigned int Digitizer::ReadBits(Reg address, unsigned int bitLength, unsigned i
|
|||
return bit;
|
||||
}
|
||||
|
||||
void Digitizer::SetBits(Reg address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch){
|
||||
void Digitizer::SetBits(Register::Reg address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch){
|
||||
///printf("address : 0x%X, value : 0x%X, len : %d, pos : %d, ch : %d \n", address, bitValue, bitLength, bitSmallestPos, ch);
|
||||
uint32_t bit ;
|
||||
uint32_t bitmask = (uint(pow(2, bitLength)-1) << bitSmallestPos);
|
||||
|
|
|
@ -76,7 +76,7 @@ class Digitizer{
|
|||
|
||||
void PrintBoard() ;
|
||||
virtual int ProgramBoard() ; /// program a generic board, no program channel
|
||||
int ProgramPHABoard() ; /// program a default PHA board
|
||||
int ProgramPHABoard() ; /// program a default PHA board with dual trace
|
||||
|
||||
//^================ ACQ control
|
||||
void StopACQ();
|
||||
|
@ -138,6 +138,12 @@ class Digitizer{
|
|||
void SaveSettingToFile (Register::Reg registerAddress, unsigned int value, unsigned short ch = 0); /// also save to memory
|
||||
unsigned int ReadSettingFromFile (Register::Reg registerAddress, unsigned short ch = 0); /// read from setting binary
|
||||
|
||||
//============ old methods, that only manipulate digitizer register, not setting in memory
|
||||
// void SetTriggerPolarity(bool RiseingIsZero, int ch );
|
||||
// void SetDPPAlgorithmControl(uint32_t bit, int ch);
|
||||
// unsigned int ReadBits(Register::Reg address, unsigned int bitLength, unsigned int bitSmallestPos, int ch );
|
||||
// void SetBits(Register::Reg address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
}
|
||||
void Stop() { this->stop = true;}
|
||||
void SetWaitTimeinSec(float sec) {waitTime = sec * 10 ;}
|
||||
unsigned int GetWaitTimeinSec() const {return waitTime/10;}
|
||||
float GetWaitTimeinSec() const {return waitTime/10.;}
|
||||
void run(){
|
||||
unsigned int count = 0;
|
||||
stop = false;
|
||||
|
@ -92,12 +92,12 @@ public:
|
|||
usleep(100000);
|
||||
count ++;
|
||||
if( count % waitTime == 0){
|
||||
emit updataScalar();
|
||||
emit timeUp();
|
||||
}
|
||||
}while(!stop);
|
||||
}
|
||||
signals:
|
||||
void updataScalar();
|
||||
void timeUp();
|
||||
private:
|
||||
bool stop;
|
||||
unsigned int waitTime;
|
||||
|
|
14
FSUDAQ.cpp
14
FSUDAQ.cpp
|
@ -183,7 +183,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
|||
lbScalarACQStatus = nullptr;
|
||||
|
||||
scalarThread = new TimingThread();
|
||||
connect(scalarThread, &TimingThread::updataScalar, this, &MainWindow::UpdateScalar);
|
||||
connect(scalarThread, &TimingThread::timeUp, this, &MainWindow::UpdateScalar);
|
||||
|
||||
}
|
||||
|
||||
|
@ -370,10 +370,15 @@ void MainWindow::OpenDigitizers(){
|
|||
readDataThread = new ReadDataThread * [nDigi];
|
||||
for( unsigned int i = 0; i < nDigi; i++){
|
||||
digi[i] = new Digitizer(portList[i].first, portList[i].second);
|
||||
//TODO === load settings
|
||||
digi[i]->Reset();
|
||||
digi[i]->ProgramPHABoard();
|
||||
readDataThread[i] = new ReadDataThread(digi[i], i);
|
||||
connect(readDataThread[i], &ReadDataThread::sendMsg, this, &MainWindow::LogMsg);
|
||||
}
|
||||
|
||||
digi[0]->SaveAllSettingsAsText("setting.txt");
|
||||
|
||||
LogMsg(QString("Done. Opened %1 digitizer(s).").arg(nDigi));
|
||||
|
||||
WaitForDigitizersOpen(false);
|
||||
|
@ -571,6 +576,9 @@ void MainWindow::StartACQ(){
|
|||
}
|
||||
lbScalarACQStatus->setText("<font style=\"color: green;\"><b>ACQ On</b></font>");
|
||||
|
||||
bnStartACQ->setEnabled(false);
|
||||
bnStopACQ->setEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::StopACQ(){
|
||||
|
@ -597,6 +605,9 @@ void MainWindow::StopACQ(){
|
|||
}
|
||||
|
||||
lbScalarACQStatus->setText("<font style=\"color: red;\"><b>ACQ Off</b></font>");
|
||||
|
||||
bnStartACQ->setEnabled(true);
|
||||
bnStopACQ->setEnabled(false);
|
||||
}
|
||||
|
||||
void MainWindow::AutoRun(){
|
||||
|
@ -707,6 +718,7 @@ void MainWindow::OpenScope(){
|
|||
scope->show();
|
||||
}else{
|
||||
scope->show();
|
||||
scope->activateWindow();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
110
Scope.cpp
110
Scope.cpp
|
@ -50,8 +50,7 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh
|
|||
|
||||
updateTraceThread = new TimingThread();
|
||||
updateTraceThread->SetWaitTimeinSec(0.5);
|
||||
|
||||
//connect(updateTraceThread, &UpdateTraceThread::updateTrace, this, &Scope::UpdateScope);
|
||||
connect(updateTraceThread, &TimingThread::timeUp, this, &Scope::UpdateScope);
|
||||
|
||||
//*================================== UI
|
||||
int rowID = -1;
|
||||
|
@ -86,11 +85,9 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh
|
|||
for( int i = 0; i < digi[ID]->GetNChannels(); i++) cbScopeCh->addItem("Ch-" + QString::number(i));
|
||||
|
||||
//---Setup SettingGroup
|
||||
if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) {
|
||||
SetUpPHAPanel();
|
||||
}else{
|
||||
CleanUpSettingsGroupBox();
|
||||
}
|
||||
CleanUpSettingsGroupBox();
|
||||
if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ) SetUpPHAPanel();
|
||||
if( digi[ID]->GetDPPType() == V1730_DPP_PSD_CODE ) SetUpPSDPanel();
|
||||
|
||||
});
|
||||
|
||||
|
@ -130,7 +127,6 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh
|
|||
rowID ++;
|
||||
bnScopeStart = new QPushButton("Start", this);
|
||||
layout->addWidget(bnScopeStart, rowID, 0);
|
||||
bnScopeStart->setEnabled(false);
|
||||
connect(bnScopeStart, &QPushButton::clicked, this, [=](){this->StartScope();});
|
||||
|
||||
bnScopeStop = new QPushButton("Stop", this);
|
||||
|
@ -150,8 +146,6 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh
|
|||
layout->addWidget(bnClose, rowID, 5);
|
||||
connect(bnClose, &QPushButton::clicked, this, &Scope::close);
|
||||
|
||||
|
||||
|
||||
layout->setColumnStretch(0, 1);
|
||||
layout->setColumnStretch(1, 1);
|
||||
layout->setColumnStretch(2, 1);
|
||||
|
@ -161,6 +155,9 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh
|
|||
|
||||
enableSignalSlot = true;
|
||||
|
||||
bnScopeStart->setEnabled(true);
|
||||
bnScopeStop->setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -177,11 +174,91 @@ Scope::~Scope(){
|
|||
//*=======================================================
|
||||
//*=======================================================
|
||||
void Scope::StartScope(){
|
||||
if( !digi ) return;
|
||||
|
||||
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){
|
||||
|
||||
digi[iDigi]->GetData()->SetSaveWaveToMemory(true);
|
||||
|
||||
digi[iDigi]->StartACQ();
|
||||
|
||||
readDataThread[iDigi]->SetScopeMode(true);
|
||||
readDataThread[iDigi]->SetSaveData(false);
|
||||
|
||||
readDataThread[iDigi]->start();
|
||||
|
||||
}
|
||||
|
||||
updateTraceThread->start();
|
||||
|
||||
bnScopeStart->setEnabled(false);
|
||||
bnScopeStop->setEnabled(true);
|
||||
|
||||
}
|
||||
|
||||
void Scope::StopScope(){
|
||||
if( !digi ) return;
|
||||
|
||||
updateTraceThread->Stop();
|
||||
updateTraceThread->quit();
|
||||
updateTraceThread->exit();
|
||||
|
||||
|
||||
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){
|
||||
|
||||
digi[iDigi]->StopACQ();
|
||||
|
||||
readDataThread[iDigi]->quit();
|
||||
readDataThread[iDigi]->wait();
|
||||
}
|
||||
|
||||
bnScopeStart->setEnabled(true);
|
||||
bnScopeStop->setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
void Scope::UpdateScope(){
|
||||
|
||||
printf("---- %s \n", __func__);
|
||||
|
||||
if( !digi ) return;
|
||||
|
||||
int ID = cbScopeDigi->currentIndex();
|
||||
int ch = cbScopeCh->currentIndex();
|
||||
int ch2ns = digi[ID]->GetCh2ns();
|
||||
|
||||
Data * data = digi[ID]->GetData();
|
||||
|
||||
digiMTX[ID].lock();
|
||||
leTriggerRate->setText(QString::number(data->TriggerRate[ch]));
|
||||
|
||||
unsigned short index = data->NumEvents[ch];
|
||||
unsigned short traceLength = data->Waveform1[ch][index].size();
|
||||
|
||||
if( data->TriggerRate[ch] > 0 ){
|
||||
|
||||
printf("--- %d | %d \n", index, traceLength );
|
||||
|
||||
QVector<QPointF> points;
|
||||
for( int i = 0; i < (int) (data->Waveform1[ch][index]).size() ; i++ ) points.append(QPointF(ch2ns * i, (data->Waveform1[ch][index])[i]));
|
||||
dataTrace[0]->replace(points);
|
||||
|
||||
points.clear();
|
||||
for( int i = 0; i < (int) (data->Waveform2[ch][index]).size() ; i++ ) points.append(QPointF(ch2ns * i, (data->Waveform2[ch][index])[i]));
|
||||
dataTrace[1]->replace(points);
|
||||
|
||||
points.clear();
|
||||
for( int i = 0; i < (int) (data->DigiWaveform1[ch][index]).size() ; i++ ) points.append(QPointF(ch2ns * i, (data->DigiWaveform1[ch][index])[i] * 1000));
|
||||
dataTrace[2]->replace(points);
|
||||
|
||||
points.clear();
|
||||
for( int i = 0; i < (int) (data->DigiWaveform2[ch][index]).size() ; i++ ) points.append(QPointF(ch2ns * i, (data->DigiWaveform2[ch][index])[i] * 1000));
|
||||
dataTrace[3]->replace(points);
|
||||
|
||||
}
|
||||
digiMTX[ID].unlock();
|
||||
|
||||
plot->axes(Qt::Horizontal).first()->setRange(0, ch2ns * traceLength);
|
||||
|
||||
}
|
||||
|
||||
|
@ -243,8 +320,6 @@ void Scope::SetUpSpinBox(RSpinBox * &sb, QString str, int row, int col, const Re
|
|||
|
||||
void Scope::CleanUpSettingsGroupBox(){
|
||||
|
||||
printf("-- %s\n", __func__);
|
||||
|
||||
QList<QLabel *> labelChildren1 = settingGroup->findChildren<QLabel *>();
|
||||
for( int i = 0; i < labelChildren1.size(); i++) delete labelChildren1[i];
|
||||
|
||||
|
@ -255,12 +330,9 @@ void Scope::CleanUpSettingsGroupBox(){
|
|||
for( int i = 0; i < labelChildren3.size(); i++) delete labelChildren3[i];
|
||||
|
||||
}
|
||||
|
||||
void Scope::SetUpPHAPanel(){
|
||||
|
||||
CleanUpSettingsGroupBox();
|
||||
|
||||
printf("-- %s\n", __func__);
|
||||
|
||||
SetUpSpinBox(sbReordLength, "Record Length [ns]", 0, 0, Register::DPP::RecordLength_G);
|
||||
SetUpSpinBox(sbPreTrigger, "Pre Trigger [ns]", 0, 2, Register::DPP::PreTrigger);
|
||||
|
||||
|
@ -275,6 +347,10 @@ void Scope::SetUpPHAPanel(){
|
|||
SetUpSpinBox(sbDecayTime, "Decay Time [ns]", 2, 4, Register::DPP::PHA::DecayTime);
|
||||
SetUpSpinBox(sbPeakingTime, "Peaking Time [ns]", 2, 6, Register::DPP::PHA::PeakingTime);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Scope::SetUpPSDPanel(){
|
||||
|
||||
SetUpSpinBox(sbReordLength, "Record Length [ns]", 0, 0, Register::DPP::RecordLength_G);
|
||||
SetUpSpinBox(sbPreTrigger, "Pre Trigger [ns]", 0, 2, Register::DPP::PreTrigger);
|
||||
}
|
||||
|
|
13
Scope.h
13
Scope.h
|
@ -31,21 +31,22 @@ public:
|
|||
Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow * parent = nullptr);
|
||||
~Scope();
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void StartScope();
|
||||
void StopScope();
|
||||
void UpdateScope();
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
|
||||
|
||||
void SetUpComboBox(RComboBox * &cb, QString str, int row, int col, const Register::Reg para);
|
||||
void SetUpSpinBox(RSpinBox * &sb, QString str, int row, int col, const Register::Reg para);
|
||||
|
||||
void CleanUpSettingsGroupBox();
|
||||
void SetUpPHAPanel();
|
||||
|
||||
signals:
|
||||
|
||||
private:
|
||||
void SetUpPSDPanel();
|
||||
|
||||
Digitizer ** digi;
|
||||
unsigned short nDigi;
|
||||
|
|
13
test.cpp
13
test.cpp
|
@ -38,17 +38,18 @@ int main(int argc, char* argv[]){
|
|||
const float ch2ns = dig[0]->GetCh2ns();
|
||||
|
||||
Data * data = dig[0]->GetData();
|
||||
data->Allocate80MBMemory();
|
||||
|
||||
dig[0]->StartACQ();
|
||||
|
||||
sleep(3);
|
||||
|
||||
dig[0]->ReadData();
|
||||
|
||||
data->SaveBuffer("test");
|
||||
for( int i = 0; i < 5; i ++ ){
|
||||
sleep(1);
|
||||
dig[0]->ReadData();
|
||||
data->DecodeBuffer(false, true);
|
||||
}
|
||||
|
||||
dig[0]->StopACQ();
|
||||
|
||||
data->PrintAllData();
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user