diff --git a/ClassData.h b/ClassData.h index f573409..9865b28 100644 --- a/ClassData.h +++ b/ClassData.h @@ -11,11 +11,16 @@ #include #include -#include "CAENDigitizerType.h" +//#include "CAENDigitizerType.h" #include "macro.h" #define MaxNData 10000 /// store 10k events per channels +enum DPPType{ + DPP_PHA_CODE = 0x8B, + DPP_PSD_CODE = 0x88 +}; + class Data{ public: @@ -115,7 +120,7 @@ class Data{ inline Data::Data(){ tick2ns = 2.0; boardSN = 0; - DPPType = V1730_DPP_PHA_CODE; + DPPType = DPPType::DPP_PHA_CODE; DPPTypeStr = ""; IsNotRollOverFakeAgg = false; buffer = NULL; @@ -309,8 +314,8 @@ inline void Data::PrintAllData(bool tableMode, unsigned int maxRowDisplay) const if( DataIndex[ch] < 0 ) continue; printf("------------ ch : %d, DataIndex : %d, loop : %d\n", ch, DataIndex[ch], LoopIndex[ch]); for( int ev = 0; ev <= (LoopIndex[ch] > 0 ? MaxNData : DataIndex[ch]) ; ev++){ - if( DPPType == V1730_DPP_PHA_CODE ) printf("%4d, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]); - if( DPPType == V1730_DPP_PSD_CODE ) printf("%4d, %5u, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Energy2[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]); + if( DPPType == DPPType::DPP_PHA_CODE ) printf("%4d, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]); + if( DPPType == DPPType::DPP_PSD_CODE ) printf("%4d, %5u, %5u, %15llu, %5u \n", ev, Energy[ch][ev], Energy2[ch][ev], Timestamp[ch][ev], fineTime[ch][ev]); if( maxRowDisplay > 0 && (unsigned int) ev > maxRowDisplay ) break; } } @@ -362,8 +367,8 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){ if( BoardID > 0 ) { switch(BoardID){ - case 0x8 : DPPType = V1730_DPP_PSD_CODE; break; - case 0xB : DPPType = V1730_DPP_PHA_CODE; break; + case 0x8 : DPPType = DPPType::DPP_PSD_CODE; break; + case 0xB : DPPType = DPPType::DPP_PHA_CODE; break; } } @@ -384,10 +389,10 @@ inline void Data::DecodeBuffer(bool fastDecode, int verbose){ if( ((ChannelMask >> chMask) & 0x1 ) == 0 ) continue; if( verbose >= 2 ) printf("==================== Dual Channel Block, ch Mask : %d, nw : %d\n", chMask *2, nw); - if( DPPType == V1730_DPP_PHA_CODE ) { + if( DPPType == DPPType::DPP_PHA_CODE ) { if ( DecodePHADualChannelBlock(chMask, fastDecode, verbose) < 0 ) break; } - if( DPPType == V1730_DPP_PSD_CODE ) { + if( DPPType == DPPType::DPP_PSD_CODE ) { if ( DecodePSDDualChannelBlock(chMask, fastDecode, verbose) < 0 ) break; } } diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index be87aa4..9341f26 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -542,11 +542,11 @@ void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool return; } - if( registerAddress.GetType() == RW::ReadONLY ) return; + if( registerAddress.GetRWType() == RW::ReadONLY ) return; ret = CAEN_DGTZ_WriteRegister(handle, registerAddress.ActualAddress(ch), value); - if( ret == 0 && isSave2MemAndFile && registerAddress.GetType() == RW::ReadWrite) { + if( ret == 0 && isSave2MemAndFile && registerAddress.GetRWType() == RW::ReadWrite) { if( ch < 0 ) { for(int i = 0; i < NChannel; i++){ SetSettingToMemory(registerAddress, value, i); @@ -567,7 +567,7 @@ void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool uint32_t Digitizer::ReadRegister(Reg registerAddress, unsigned short ch, bool isSave2MemAndFile, std::string str ){ if( !isConnected ) return 0; - if( registerAddress.GetType() == RW::WriteONLY ) return 0; + if( registerAddress.GetRWType() == RW::WriteONLY ) return 0; ret = CAEN_DGTZ_ReadRegister(handle, registerAddress.ActualAddress(ch), &returnData); @@ -640,7 +640,7 @@ void Digitizer::ReadAllSettingsFromBoard(bool force){ /// board setting for( int p = 0; p < (int) RegisterDPPList.size(); p++){ - if( RegisterDPPList[p].GetType() == RW::WriteONLY) continue; + if( RegisterDPPList[p].GetRWType() == RW::WriteONLY) continue; ReadRegister(RegisterDPPList[p]); } @@ -650,13 +650,13 @@ void Digitizer::ReadAllSettingsFromBoard(bool force){ for( int ch = 0; ch < NChannel; ch ++){ if( DPPType == V1730_DPP_PHA_CODE ){ for( int p = 0; p < (int) RegisterPHAList.size(); p++){ - if( RegisterPHAList[p].GetType() == RW::WriteONLY) continue; + if( RegisterPHAList[p].GetRWType() == RW::WriteONLY) continue; ReadRegister(RegisterPHAList[p], ch); } } if( DPPType == V1730_DPP_PSD_CODE ){ for( int p = 0; p < (int) RegisterPSDList.size(); p++){ - if( RegisterPSDList[p].GetType() == RW::WriteONLY) continue; + if( RegisterPSDList[p].GetRWType() == RW::WriteONLY) continue; ReadRegister(RegisterPSDList[p], ch); } } @@ -674,7 +674,7 @@ void Digitizer::ProgramSettingsToBoard(){ /// board setting for( int p = 0; p < (int) RegisterDPPList.size(); p++){ - if( RegisterDPPList[p].GetType() == RW::ReadWrite) { + if( RegisterDPPList[p].GetRWType() == RW::ReadWrite) { haha = RegisterDPPList[p]; WriteRegister(haha, GetSettingFromMemory(haha), -1, false); usleep(1 * 1000); @@ -684,7 +684,7 @@ void Digitizer::ProgramSettingsToBoard(){ for( int ch = 0; ch < NChannel; ch ++){ if( DPPType == V1730_DPP_PHA_CODE ){ for( int p = 0; p < (int) RegisterPHAList.size(); p++){ - if( RegisterPHAList[p].GetType() == RW::ReadWrite ){ + if( RegisterPHAList[p].GetRWType() == RW::ReadWrite ){ haha = RegisterPHAList[p]; WriteRegister(haha, GetSettingFromMemory(haha, ch), ch, false); usleep(1 * 1000); @@ -693,7 +693,7 @@ void Digitizer::ProgramSettingsToBoard(){ } if( DPPType == V1730_DPP_PSD_CODE ){ for( int p = 0; p < (int) RegisterPSDList.size(); p++){ - if( RegisterPSDList[p].GetType() == RW::ReadWrite){ + if( RegisterPSDList[p].GetRWType() == RW::ReadWrite){ haha = RegisterPSDList[p]; WriteRegister(haha, GetSettingFromMemory(haha, ch), ch, false); usleep(1 * 1000); @@ -865,9 +865,9 @@ void Digitizer::SaveAllSettingsAsText(std::string fileName){ } if( haha.GetName() != "" ) { std::string typeStr ; - if( haha.GetType() == RW::ReadWrite ) typeStr = "R/W"; - if( haha.GetType() == RW::ReadONLY ) typeStr = "R "; - if( haha.GetType() == RW::WriteONLY ) typeStr = " W"; + if( haha.GetRWType() == RW::ReadWrite ) typeStr = "R/W"; + if( haha.GetRWType() == RW::ReadONLY ) typeStr = "R "; + if( haha.GetRWType() == RW::WriteONLY ) typeStr = " W"; fprintf( txtFile, "0x%04X %30s 0x%08X %s %u\n", actualAddress, haha.GetNameChar(), setting[i], diff --git a/CustomThreads.h b/CustomThreads.h index e6a072b..d180b72 100644 --- a/CustomThreads.h +++ b/CustomThreads.h @@ -48,6 +48,7 @@ public: // digi->StartACQ(); // usleep(1000); // wait for some data; + printf("ReadDataThread for digi-%d running.\n", digi->GetSerialNumber()); do{ if( stop) break; @@ -84,6 +85,7 @@ public: clock_gettime(CLOCK_REALTIME, &tb); if( tb.tv_sec - ta.tv_sec > 2 ) { digiMTX[ID].lock(); + emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetData()->GetTotalFileSize()/1024./1024., 'f', 4) + " MB [" + QString::number(tb.tv_sec-t0.tv_sec) + " sec]"); //digi->GetData()->PrintStat(); digiMTX[ID].unlock(); @@ -92,7 +94,7 @@ public: } }while(!stop); - printf("ReadDataThread stopped.\n"); + printf("ReadDataThread for digi-%d stopped.\n", digi->GetSerialNumber()); } signals: void sendMsg(const QString &msg); diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index e28c402..f3c5f3d 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -379,7 +379,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr connect(cbBdReg, &RComboBox::currentIndexChanged, this, [=](int index){ if( !enableSignalSlot ) return; - if( RegisterDPPList[index].GetType() == RW::WriteONLY ) { + if( RegisterDPPList[index].GetRWType() == RW::WriteONLY ) { leBdRegRW->setText("Write ONLY" ); leBdRegValue->setText(""); leBdRegSet->setEnabled(true); @@ -389,13 +389,13 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr uint32_t value = digi[ cbDigi->currentIndex() ] ->ReadRegister(RegisterDPPList[index]); leBdRegValue->setText( "0x" + QString::number(value, 16).toUpper()); - if( RegisterDPPList[index].GetType() == RW::ReadONLY ) { + if( RegisterDPPList[index].GetRWType() == RW::ReadONLY ) { leBdRegRW->setText("Read ONLY" ); leBdRegSet->setEnabled(false); return; } - if( RegisterDPPList[index].GetType() == RW::ReadWrite ) { + if( RegisterDPPList[index].GetRWType() == RW::ReadWrite ) { leBdRegRW->setText("Read/Write" ); leBdRegSet->setEnabled(true); } @@ -414,7 +414,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr connect(cbChReg, &RComboBox::currentIndexChanged, this, [=](int index){ if( !enableSignalSlot ) return; - if( chRegList[index].GetType() == RW::WriteONLY ) { + if( chRegList[index].GetRWType() == RW::WriteONLY ) { leChRegRW->setText("Write ONLY" ); leChRegValue->setText(""); leChRegSet->setEnabled(true); @@ -424,13 +424,13 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr uint32_t value = digi[ cbDigi->currentIndex() ] ->ReadRegister(chRegList[index], cbCh->currentIndex()); leChRegValue->setText( "0x" + QString::number(value, 16).toUpper()); - if( chRegList[index].GetType() == RW::ReadONLY ) { + if( chRegList[index].GetRWType() == RW::ReadONLY ) { leChRegRW->setText("Read ONLY" ); leChRegSet->setEnabled(false); return; } - if( chRegList[index].GetType() == RW::ReadWrite ) { + if( chRegList[index].GetRWType() == RW::ReadWrite ) { leChRegRW->setText("Read/Write" ); leChRegSet->setEnabled(true); } @@ -554,6 +554,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr //Copy Board Setting for( int i = 0; i < (int) RegisterDPPList.size(); i++){ + if( RegisterDPPList[i].GetRWType() != RW::WriteONLY ) continue; uint32_t value = digi[fromIndex]->GetSettingFromMemory(RegisterDPPList[i]); digi[toIndex]->WriteRegister(RegisterDPPList[i], value); } @@ -565,7 +566,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr for( int i = 0; i < MaxNChannels; i++){ //Copy setting for( int k = 0; k < (int) regList.size(); k ++){ - if( regList[k].GetType() != RW::ReadWrite ) continue; + if( regList[k].GetRWType() != RW::ReadWrite ) continue; uint32_t value = digi[fromIndex]->GetSettingFromMemory(regList[k], i); digi[toIndex]->WriteRegister(regList[k], value, i); @@ -600,7 +601,7 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr if( ! chkCh[i]->isChecked() ) return; //Copy setting for( int k = 0; k < (int) regList.size(); k ++){ - if( regList[k].GetType() != RW::ReadWrite ) continue; + if( regList[k].GetRWType() != RW::ReadWrite ) continue; uint32_t value = digi[fromIndex]->GetSettingFromMemory(regList[k], fromCh); digi[toIndex]->WriteRegister(regList[k], value, i); diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 67abfc0..0274de4 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -1030,8 +1030,6 @@ void MainWindow::StopACQ(){ } for( unsigned int i = 0; i < nDigi; i++){ - LogMsg("Digi-" + QString::number(digi[i]->GetSerialNumber()) + " is stoping ACQ." ); - if( readDataThread[i]->isRunning() ) { readDataThread[i]->Stop(); readDataThread[i]->quit(); @@ -1041,6 +1039,7 @@ void MainWindow::StopACQ(){ digi[i]->StopACQ(); digiMTX[i].unlock(); if( chkSaveData->isChecked() ) digi[i]->GetData()->CloseSaveFile(); + LogMsg("Digi-" + QString::number(digi[i]->GetSerialNumber()) + " ACQ is stopped." ); } if( scalarThread->isRunning()){ diff --git a/RegisterAddress.h b/RegisterAddress.h index 7823e21..ced4861 100644 --- a/RegisterAddress.h +++ b/RegisterAddress.h @@ -27,7 +27,7 @@ class Reg{ Reg(){ name = ""; address = 0; - type = RW::ReadWrite; + rwType = RW::ReadWrite; group = 0; maxBit = 0; partialStep = 0; @@ -36,7 +36,7 @@ class Reg{ Reg(std::string name, uint32_t address, RW type = RW::ReadWrite, bool group = false, unsigned int max = 0, int pStep = 0){ this->name = name; this->address = address; - this->type = type; + this->rwType = type; this->group = group; this->maxBit = max; this->partialStep = pStep; @@ -46,7 +46,7 @@ class Reg{ Reg(std::string name, uint32_t address, RW type = RW::ReadWrite, bool group = false, std::vector> list = {}){ this->name = name; this->address = address; - this->type = type; + this->rwType = type; this->group = group; this->maxBit = 0; this->partialStep = 0; @@ -60,7 +60,7 @@ class Reg{ std::string GetName() const {return name;} const char * GetNameChar() const {return name.c_str();} uint32_t GetAddress() const {return address; } - RW GetType() const {return type;} + RW GetRWType() const {return rwType;} bool IsCoupled() const {return group;} unsigned int GetMaxBit() const {return maxBit;} int GetPartialStep() const {return partialStep;} /// step = partialStep * tick2ns, -1 : step = 1 @@ -90,7 +90,7 @@ class Reg{ std::string name; uint32_t address; /// This is the table of register, the actual address should call ActualAddress(); - RW type; /// read/write = 0; read = 1; write = 2 + RW rwType; /// read/write = 0; read = 1; write = 2 bool group; unsigned int maxBit ; int partialStep; @@ -100,7 +100,7 @@ class Reg{ inline void Reg::Print() const{ printf(" Name: %s\n", name.c_str()); printf(" Re.Address: 0x%04X\n", address); - printf(" Type: %s\n", type == RW::ReadWrite ? "Read/Write" : (type == RW::ReadONLY ? "Read-Only" : "Write-Only") ); + printf(" Type: %s\n", rwType == RW::ReadWrite ? "Read/Write" : (rwType == RW::ReadONLY ? "Read-Only" : "Write-Only") ); printf(" Group: %s\n", group ? "True" : "False"); printf(" Max Value : 0x%X = %d \n", maxBit, maxBit); }