diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 3243d8c..4b21c0c 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -1,20 +1,24 @@ #include "ClassDigitizer.h" Digitizer::Digitizer(){ + DebugPrint("%s", "Digitizer"); Initalization(); } Digitizer::Digitizer(int boardID, int portID, bool program, bool verbose){ + DebugPrint("%s", "Digitizer"); Initalization(); OpenDigitizer(boardID, portID, program, verbose); } Digitizer::~Digitizer(){ + DebugPrint("%s", "Digitizer"); CloseDigitizer(); delete data; } void Digitizer::Initalization(){ + DebugPrint("%s", "Digitizer"); data = nullptr; @@ -52,6 +56,7 @@ void Digitizer::Initalization(){ } void Digitizer::Reset(){ + DebugPrint("%s", "Digitizer"); // ret = CAEN_DGTZ_Reset(handle); // if( ret != 0 ) ErrorMsg(__func__); @@ -65,6 +70,7 @@ void Digitizer::Reset(){ } void Digitizer::PrintBoard (){ + DebugPrint("%s", "Digitizer"); printf("Connected to Model %s with handle %d using %s\n", BoardInfo.ModelName, handle, LinkType == CAEN_DGTZ_USB ? "USB" : "Optical Link"); printf(" Family Name : %s \n", familyName.c_str()); printf(" Sampling rate : %.1f MHz = %.1f ns \n", 1000./tick2ns, tick2ns); @@ -79,7 +85,7 @@ void Digitizer::PrintBoard (){ } int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose){ - + DebugPrint("%s", "Digitizer"); this->boardID = boardID; this->portID = portID; @@ -267,7 +273,7 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose } int Digitizer::CloseDigitizer(){ - + DebugPrint("%s", "Digitizer"); if( !isConnected ) return 0; isConnected = false; ret = CAEN_DGTZ_SWStopAcquisition(handle); @@ -280,6 +286,7 @@ int Digitizer::CloseDigitizer(){ void Digitizer::SetRegChannelMask(uint32_t mask){ + DebugPrint("%s", "Digitizer"); if( softwareDisable ) return; if( !isConnected ) return; regChannelMask = mask; @@ -289,7 +296,8 @@ void Digitizer::SetRegChannelMask(uint32_t mask){ ErrorMsg(__func__); } -bool Digitizer::GetInputChannelOnOff(unsigned ch) { +bool Digitizer::GetInputChannelOnOff(unsigned ch) { + DebugPrint("%s", "Digitizer"); if( softwareDisable ) return false; regChannelMask = GetSettingFromMemory(DPP::RegChannelEnableMask); @@ -301,6 +309,7 @@ bool Digitizer::GetInputChannelOnOff(unsigned ch) { } void Digitizer::SetRegChannelOnOff(unsigned short ch, bool onOff){ + DebugPrint("%s", "Digitizer"); if( softwareDisable ) return; if( !isConnected ) return; regChannelMask = ((regChannelMask & ~( 1 << ch) ) | ( onOff << ch)) ; @@ -308,12 +317,14 @@ void Digitizer::SetRegChannelOnOff(unsigned short ch, bool onOff){ } void Digitizer::ProgramBoard(){ + DebugPrint("%s", "Digitizer"); if( DPPType == DPPTypeCode::DPP_PHA_CODE ) ProgramBoard_PHA(); if( DPPType == DPPTypeCode::DPP_PSD_CODE ) ProgramBoard_PSD(); if( DPPType == DPPTypeCode::DPP_QDC_CODE ) ProgramBoard_QDC(); } int Digitizer::ProgramBoard_PHA(){ + DebugPrint("%s", "Digitizer"); if( softwareDisable ) return 0; printf("===== Digitizer::%s\n", __func__); @@ -513,6 +524,7 @@ int Digitizer::ProgramBoard_QDC(){ //========================================================= ACQ control void Digitizer::StartACQ(){ + DebugPrint("%s", "Digitizer"); if( softwareDisable ) return; if ( AcqRun ) return; @@ -580,6 +592,7 @@ void Digitizer::StartACQ(){ } void Digitizer::StopACQ(){ + DebugPrint("%s", "Digitizer"); if( !AcqRun ) return; int ret = CAEN_DGTZ_SWStopAcquisition(handle); ret |= CAEN_DGTZ_ClearData(handle); @@ -595,6 +608,7 @@ void Digitizer::StopACQ(){ } unsigned int Digitizer::CalByteForBuffer(bool verbose){ + DebugPrint("%s", "Digitizer"); unsigned int numAggBLT; unsigned int chMask ; unsigned int boardCfg ; @@ -650,7 +664,7 @@ unsigned int Digitizer::CalByteForBuffer(bool verbose){ } unsigned int Digitizer::CalByteForBufferCAEN(){ - + DebugPrint("%s", "Digitizer"); char * BufferCAEN; uint32_t AllocatedSize; ret = CAEN_DGTZ_MallocReadoutBuffer(handle, &BufferCAEN, &AllocatedSize); @@ -661,6 +675,7 @@ unsigned int Digitizer::CalByteForBufferCAEN(){ } int Digitizer::ReadData(){ + // DebugPrint("%s", "Digitizer"); if( softwareDisable ) return CAEN_DGTZ_DigitizerNotReady; if( !isConnected ) return CAEN_DGTZ_DigitizerNotFound; if( !AcqRun) return CAEN_DGTZ_WrongAcqMode; @@ -687,6 +702,7 @@ int Digitizer::ReadData(){ } void Digitizer::ReadAndPrintACQStatue(){ + DebugPrint("%s", "Digitizer"); if( !isConnected ) return; unsigned int status = ReadRegister(DPP::AcquisitionStatus_R); @@ -721,7 +737,7 @@ void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool ret = CAEN_DGTZ_WriteRegister(handle, registerAddress.ActualAddress(ch), value); - if( ret == 0 && isSave2MemAndFile && registerAddress.GetRWType() == RW::ReadWrite) { + if( ret == 0 && isSave2MemAndFile && !AcqRun && registerAddress.GetRWType() == RW::ReadWrite ) { if( ch < 0 ) { if( registerAddress.GetAddress() < 0x8000 ){ for(int i = 0; i < NumInputCh; i++){ @@ -742,7 +758,7 @@ void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool } } - if( ret == 0 && isSave2MemAndFile && registerAddress == DPP::QDC::RecordLength_W){ + if( ret == 0 && isSave2MemAndFile && !AcqRun && registerAddress == DPP::QDC::RecordLength_W){ SetSettingToMemory(registerAddress, value, 0); SaveSettingToFile(registerAddress, value, 0); } @@ -753,6 +769,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 ){ + DebugPrint("%s", "Digitizer"); if( softwareDisable ) return 0; if( !isConnected ) return 0; if( registerAddress.GetRWType() == RW::WriteONLY ) return 0; @@ -760,7 +777,7 @@ uint32_t Digitizer::ReadRegister(Reg registerAddress, unsigned short ch, bool is ret = CAEN_DGTZ_ReadRegister(handle, registerAddress.ActualAddress(ch), &returnData); - if( ret == 0 && isSave2MemAndFile) { + if( ret == 0 && isSave2MemAndFile && !AcqRun) { //if( isSave2MemAndFile) { SetSettingToMemory(registerAddress, returnData, ch); SaveSettingToFile(registerAddress, returnData, ch); @@ -900,6 +917,7 @@ void Digitizer::ReadAllSettingsFromBoard(bool force){ } void Digitizer::ProgramSettingsToBoard(){ + DebugPrint("%s", "Digitizer"); if( softwareDisable ) return; if( !isConnected || isDummy ) return; @@ -989,23 +1007,26 @@ void Digitizer::ProgramSettingsToBoard(){ } void Digitizer::SetSettingToMemory(Reg registerAddress, unsigned int value, unsigned short ch ){ + DebugPrint("%s", "Digitizer"); unsigned short index = registerAddress.Index(ch); if( index > SETTINGSIZE ) return; setting[index] = value; } unsigned int Digitizer::GetSettingFromMemory(Reg registerAddress, unsigned short ch ){ + DebugPrint("%s", "Digitizer"); unsigned short index = registerAddress.Index(ch); if( index > SETTINGSIZE ) return 0xFFFF; return setting[index] ; } void Digitizer::PrintSettingFromMemory(){ + DebugPrint("%s", "Digitizer"); for( int i = 0; i < SETTINGSIZE; i++) printf("%4d | 0x%04X |0x%08X = %u \n", i, i*4, setting[i], setting[i]); } void Digitizer::SetSettingBinaryPath(std::string fileName){ - + DebugPrint("%s", "Digitizer"); settingFile = fopen(fileName.c_str(), "r+"); if( settingFile == NULL ){ printf("cannot open file %s. Create one.\n", fileName.c_str()); @@ -1026,7 +1047,7 @@ void Digitizer::SetSettingBinaryPath(std::string fileName){ } int Digitizer::LoadSettingBinaryToMemory(std::string fileName){ - + DebugPrint("%s", "Digitizer"); settingFile = fopen(fileName.c_str(), "r"); if( settingFile == NULL ) { @@ -1070,6 +1091,7 @@ int Digitizer::LoadSettingBinaryToMemory(std::string fileName){ } unsigned int Digitizer::ReadSettingFromFile(Reg registerAddress, unsigned short ch){ + DebugPrint("%s", "Digitizer"); if ( !isSettingFileExist ) return -1; unsigned short index = registerAddress.Index(ch); @@ -1090,7 +1112,7 @@ unsigned int Digitizer::ReadSettingFromFile(Reg registerAddress, unsigned short } void Digitizer::SaveSettingToFile(Reg registerAddress, unsigned int value, unsigned short ch){ - + DebugPrint("%s", "Digitizer"); if ( !isSettingFileExist ) return ; if ( !isSettingFileUpdate ) return; @@ -1109,7 +1131,7 @@ void Digitizer::SaveSettingToFile(Reg registerAddress, unsigned int value, unsig } void Digitizer::SaveAllSettingsAsBin(std::string fileName){ - + DebugPrint("%s", "Digitizer"); SaveAllSettingsAsTextForRun(fileName); if( !isSettingFilledinMemeory ) return; @@ -1120,6 +1142,7 @@ void Digitizer::SaveAllSettingsAsBin(std::string fileName){ } void Digitizer::SaveAllSettingsAsTextForRun (std::string fileName){ + DebugPrint("%s", "Digitizer"); if( !isSettingFilledinMemeory ) return; FILE * binFile = fopen(fileName.c_str(), "w+"); @@ -1137,6 +1160,7 @@ void Digitizer::SaveAllSettingsAsTextForRun (std::string fileName){ } void Digitizer::SaveAllSettingsAsText(std::string fileName){ + DebugPrint("%s", "Digitizer"); if( !isSettingFilledinMemeory && isConnected) return; FILE * txtFile = fopen(fileName.c_str(), "w+"); @@ -1276,12 +1300,14 @@ void Digitizer::ErrorMsg(std::string header){ //============================== DPP-Alpgorthm Control void Digitizer::SetDPPAlgorithmControl(uint32_t bit, int ch){ + DebugPrint("%s", "Digitizer"); if( softwareDisable ) return; WriteRegister( DPP::DPPAlgorithmControl, bit, ch); if( ret != 0 ) ErrorMsg(__func__); } unsigned int Digitizer::ReadBits(Reg address, unsigned int bitLength, unsigned int bitSmallestPos, int ch ){ + DebugPrint("%s", "Digitizer"); if( softwareDisable ) return 0; int tempCh = ch; if (ch < 0 && address < 0x8000 ) tempCh = 0; /// take ch-0 @@ -1291,6 +1317,7 @@ unsigned int Digitizer::ReadBits(Reg address, unsigned int bitLength, unsigned i } void Digitizer::SetBits(Reg address, unsigned int bitValue, unsigned int bitLength, unsigned int bitSmallestPos, int ch){ + DebugPrint("%s", "Digitizer"); if( softwareDisable ) return; ///printf("address : 0x%X, value : 0x%X, len : %d, pos : %d, ch : %d \n", address, bitValue, bitLength, bitSmallestPos, ch); uint32_t bit ; @@ -1306,7 +1333,7 @@ void Digitizer::SetBits(Reg address, unsigned int bitValue, unsigned int bitLeng } void Digitizer::SetOptimialAggOrg(){ - + DebugPrint("%s", "Digitizer"); if( DPPType != DPPTypeCode::DPP_QDC_CODE ) { printf("%s | this method only support QDC board.\n", __func__); return; diff --git a/ClassInfluxDB.cpp b/ClassInfluxDB.cpp index 9f3b1b8..db65e3b 100644 --- a/ClassInfluxDB.cpp +++ b/ClassInfluxDB.cpp @@ -1,9 +1,10 @@ #include "ClassInfluxDB.h" +#include "macro.h" #include InfluxDB::InfluxDB(){ - + DebugPrint("%s", "InfluxDB") curl = curl_easy_init(); databaseIP = ""; respondCode = 0; @@ -16,7 +17,7 @@ InfluxDB::InfluxDB(){ } InfluxDB::InfluxDB(std::string url, bool verbose){ - + DebugPrint("%s", "InfluxDB") curl = curl_easy_init(); if( verbose) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); SetURL(url); @@ -30,11 +31,13 @@ InfluxDB::InfluxDB(std::string url, bool verbose){ } InfluxDB::~InfluxDB(){ + DebugPrint("%s", "InfluxDB") curl_slist_free_all(headers); curl_easy_cleanup(curl); } void InfluxDB::SetURL(std::string url){ + DebugPrint("%s", "InfluxDB") // check the last char of url is "/" if( url.back() != '/') { this->databaseIP = url + "/"; @@ -44,12 +47,14 @@ void InfluxDB::SetURL(std::string url){ } void InfluxDB::SetToken(std::string token){ + DebugPrint("%s", "InfluxDB") this->token = token; headers = curl_slist_append(headers, "Accept: application/csv"); if( !token.empty() ) headers = curl_slist_append(headers, ("Authorization: Token " + token).c_str()); } bool InfluxDB::TestingConnection(bool debug){ + DebugPrint("%s", "InfluxDB") CheckInfluxVersion(debug); if( respond != CURLE_OK ) return false; connectionOK = true; @@ -57,7 +62,7 @@ bool InfluxDB::TestingConnection(bool debug){ } std::string InfluxDB::CheckInfluxVersion(bool debug){ - + DebugPrint("%s", "InfluxDB") curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "ping").c_str()); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, NULL); curl_easy_setopt(curl, CURLOPT_HEADER, 1); @@ -92,6 +97,7 @@ std::string InfluxDB::CheckInfluxVersion(bool debug){ } std::string InfluxDB::CheckDatabases(){ + DebugPrint("%s", "InfluxDB") if( ! connectionOK ) return "no connection. try TestConnection() again."; if( influxVersion == 2 && token.empty() ) return "token no provided, abort."; @@ -169,7 +175,7 @@ std::string InfluxDB::CheckDatabases(){ } void InfluxDB::PrintDataBaseList(){ - + DebugPrint("%s", "InfluxDB") for( size_t i = 0; i < databaseList.size(); i++){ printf("%2ld| %s\n", i, databaseList[i].c_str()); } @@ -177,6 +183,7 @@ void InfluxDB::PrintDataBaseList(){ } std::string InfluxDB::Query(std::string databaseName, std::string influxQL_query){ + DebugPrint("%s", "InfluxDB") if( ! connectionOK ) return "no connection. try TestConnection() again."; if( influxVersion == 2 && token.empty() ) return "token no provided, abort."; @@ -202,6 +209,7 @@ std::string InfluxDB::Query(std::string databaseName, std::string influxQL_query } void InfluxDB::CreateDatabase(std::string databaseName){ + DebugPrint("%s", "InfluxDB") if( ! connectionOK ) return ; if( influxVersion == 2 && token.empty() ) return; @@ -218,21 +226,25 @@ void InfluxDB::CreateDatabase(std::string databaseName){ } void InfluxDB::AddDataPoint(std::string fullString){ + DebugPrint("%s", "InfluxDB") // printf(" InfluxDB::%s |%s| \n", __func__, fullString.c_str()); dataPoints += fullString + "\n"; } void InfluxDB::ClearDataPointsBuffer(){ + DebugPrint("%s", "InfluxDB") // printf(" InfluxDB::%s \n", __func__); dataPoints = ""; } void InfluxDB::PrintDataPoints(){ + DebugPrint("%s", "InfluxDB") // printf(" InfluxDB::%s \n", __func__); printf("%s\n", dataPoints.c_str()); } -void InfluxDB::WriteData(std::string databaseName){ +void InfluxDB::WriteData(std::string databaseName){ + DebugPrint("%s", "InfluxDB") if( ! connectionOK ) return ; if( influxVersion == 2 && token.empty() ) return; @@ -250,6 +262,7 @@ void InfluxDB::WriteData(std::string databaseName){ } void InfluxDB::Execute(){ + DebugPrint("%s", "InfluxDB") // printf(" InfluxDB::%s \n", __func__); try{ respond = curl_easy_perform(curl); @@ -263,6 +276,7 @@ void InfluxDB::Execute(){ } size_t InfluxDB::WriteCallBack(char *contents, size_t size, size_t nmemb, void *userp){ + DebugPrint("%s", "InfluxDB") // printf(" InfluxDB::%s \n", __func__); ((std::string*)userp)->append((char*)contents, size * nmemb); return size * nmemb; diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index 15c9e32..1ba93e9 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -29,7 +29,7 @@ std::vector, unsigned short>> ReadoutToolT {{"FIFO not empty", "FIFO is empty"}, 3}}; DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QString rawDataPath, QMainWindow *parent): QMainWindow(parent){ - + DebugPrint("%s", "DigiSettingsPanel");; this->digi = digi; this->nDigi = nDigi; @@ -356,6 +356,7 @@ DigiSettingsPanel::~DigiSettingsPanel(){ //*================================================================ //*================================================================ void DigiSettingsPanel::SetUpInfo(QString label, std::string value, QGridLayout *gLayout, int row, int col){ + DebugPrint("%s", "DigiSettingsPanel");; QLabel * lab = new QLabel(label, this); lab->setAlignment(Qt::AlignRight | Qt::AlignCenter); QLineEdit * leInfo = new QLineEdit(this); @@ -367,7 +368,7 @@ void DigiSettingsPanel::SetUpInfo(QString label, std::string value, QGridLayout } void DigiSettingsPanel::SetUpCheckBox(QCheckBox * &chkBox, QString label, QGridLayout *gLayout, int row, int col, Reg para, std::pair bit, int ch, int colSpan){ - + DebugPrint("%s", "DigiSettingsPanel");; chkBox = new QCheckBox(label, this); gLayout->addWidget(chkBox, row, col, 1, colSpan); @@ -384,7 +385,7 @@ void DigiSettingsPanel::SetUpCheckBox(QCheckBox * &chkBox, QString label, QGridL } void DigiSettingsPanel::SetUpComboBoxBit(RComboBox * &cb, QString label, QGridLayout *gLayout, int row, int col, std::vector> items, Reg para, std::pair bit, int colspan, int ch){ - + DebugPrint("%s", "DigiSettingsPanel");; QLabel * lab = new QLabel(label, this); lab->setAlignment(Qt::AlignRight | Qt::AlignCenter); gLayout->addWidget(lab, row, col); @@ -424,7 +425,7 @@ void DigiSettingsPanel::SetUpComboBoxBit(RComboBox * &cb, QString label, QGridLa } void DigiSettingsPanel::SetUpComboBox(RComboBox * &cb, QString label, QGridLayout *gLayout, int row, int col, Reg para, int ch){ - + DebugPrint("%s", "DigiSettingsPanel");; QLabel * lab = new QLabel(label, this); lab->setAlignment(Qt::AlignRight | Qt::AlignCenter); gLayout->addWidget(lab, row, col); @@ -453,6 +454,7 @@ void DigiSettingsPanel::SetUpComboBox(RComboBox * &cb, QString label, QGridLayou } void DigiSettingsPanel::SetUpSpinBox(RSpinBox * &sb, QString label, QGridLayout *gLayout, int row, int col, Reg para, int ch, bool isBoard){ + DebugPrint("%s", "DigiSettingsPanel");; QLabel * lab = new QLabel(label, this); lab->setAlignment(Qt::AlignRight | Qt::AlignCenter); gLayout->addWidget(lab, row, col); @@ -534,7 +536,6 @@ void DigiSettingsPanel::SetUpSpinBox(RSpinBox * &sb, QString label, QGridLayout //&########################################################### void DigiSettingsPanel::CleanUpGroupBox(QGroupBox * & gBox){ - printf("============== %s \n", __func__); QList labelChildren1 = gBox->findChildren(); @@ -555,7 +556,7 @@ void DigiSettingsPanel::CleanUpGroupBox(QGroupBox * & gBox){ } void DigiSettingsPanel::SetUpGlobalTriggerMaskAndFrontPanelMask(QGridLayout * & gLayout){ - + DebugPrint("%s", "DigiSettingsPanel");; SetUpComboBoxBit(cbLEMOMode[ID], "LEMO Mode ", gLayout, 0, 0, DPP::Bit_FrontPanelIOControl::ListLEMOLevel, DPP::FrontPanelIOControl, DPP::Bit_FrontPanelIOControl::LEMOLevel, 1, 0); ///============================ Trig out mode @@ -933,7 +934,7 @@ void DigiSettingsPanel::SetUpGlobalTriggerMaskAndFrontPanelMask(QGridLayout * & } void DigiSettingsPanel::SetUpInquiryCopyTab(){ - + DebugPrint("%s", "DigiSettingsPanel");; //*##################################### Inquiry / Copy Tab QWidget * inquiryTab = new QWidget(this); tabWidget->addTab(inquiryTab, "Inquiry / Copy"); @@ -1315,7 +1316,7 @@ void DigiSettingsPanel::SetUpInquiryCopyTab(){ //&########################################################### void DigiSettingsPanel::SetUpChannelMask(unsigned int digiID){ - + DebugPrint("%s", "DigiSettingsPanel");; QString lbStr = "Channel Mask :"; if( digi[digiID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ) lbStr = "Group Mask :"; @@ -1378,6 +1379,7 @@ void DigiSettingsPanel::SetUpChannelMask(unsigned int digiID){ } void DigiSettingsPanel::SetUpACQReadOutTab(){ + DebugPrint("%s", "DigiSettingsPanel");; SetUpSpinBox(sbAggNum[ID], "Max Agg. Num. / read ", bdACQLayout[ID], 0, 0, DPP::MaxAggregatePerBlockTransfer, -1, true); SetUpComboBox(cbAggOrg[ID], "Aggregate Organization ", bdACQLayout[ID], 1, 0, DPP::AggregateOrganization, 0); @@ -2485,7 +2487,7 @@ void DigiSettingsPanel::SetUpBoard_QDC(){ } void DigiSettingsPanel::SetUpChannel_QDC(){ - + DebugPrint("%s", "DigiSettingsPanel");; QWidget * chAllSetting = new QWidget(this); //chAllSetting->setStyleSheet("background-color: #ECECEC;"); chTab->addTab(chAllSetting, "Group Settings"); @@ -3108,7 +3110,7 @@ void DigiSettingsPanel::SetUpChannel_QDC(){ //&########################################################### void DigiSettingsPanel::UpdateACQStatus(uint32_t status){ - + DebugPrint("%s", "DigiSettingsPanel");; leACQStatus[ID]->setText( "0x" + QString::number(status, 16).toUpper()); for( int i = 0; i < 9; i++){ @@ -3126,7 +3128,7 @@ void DigiSettingsPanel::UpdateACQStatus(uint32_t status){ } void DigiSettingsPanel::UpdateReadOutStatus(uint32_t status){ - + DebugPrint("%s", "DigiSettingsPanel");; leReadOutStatus[ID]->setText( "0x" + QString::number(status, 16).toUpper()); for( int i = 0; i < 3; i++){ @@ -3435,7 +3437,7 @@ void DigiSettingsPanel::UpdatePanelFromMemory(){ //&########################################################### void DigiSettingsPanel::UpdateSpinBox(RSpinBox * &sb, Reg para, int ch){ - + DebugPrint("%s", "DigiSettingsPanel"); int tick2ns = digi[ID]->GetTick2ns(); int pStep = para.GetPartialStep(); @@ -3464,7 +3466,7 @@ void DigiSettingsPanel::UpdateSpinBox(RSpinBox * &sb, Reg para, int ch){ } void DigiSettingsPanel::UpdateComboBox(RComboBox * & cb, Reg para, int ch){ - + DebugPrint("%s", "DigiSettingsPanel"); uint32_t value = digi[ID]->GetSettingFromMemory(para, ch); for( int i = 0; i < cb->count(); i ++){ @@ -3476,7 +3478,7 @@ void DigiSettingsPanel::UpdateComboBox(RComboBox * & cb, Reg para, int ch){ } void DigiSettingsPanel::UpdateComboBoxBit(RComboBox * & cb, uint32_t fullBit, std::pair bit){ - + DebugPrint("%s", "DigiSettingsPanel"); int temp = Digitizer::ExtractBits(fullBit, bit); for( int i = 0; i < cb->count(); i++){ if( cb->itemData(i).toInt() == temp) { @@ -3488,6 +3490,7 @@ void DigiSettingsPanel::UpdateComboBoxBit(RComboBox * & cb, uint32_t fullBit, st } void DigiSettingsPanel::SyncSpinBox(RSpinBox *(&spb)[][MaxRegChannel+1]){ + DebugPrint("%s", "DigiSettingsPanel"); if( !enableSignalSlot ) return; const int nCh = digi[ID]->GetNumRegChannels(); @@ -3551,6 +3554,7 @@ void DigiSettingsPanel::SyncComboBox(RComboBox *(&cb)[][MaxRegChannel+1]){ } void DigiSettingsPanel::SyncCheckBox(QCheckBox *(&chk)[][MaxRegChannel+1]){ + DebugPrint("%s", "DigiSettingsPanel"); if( !enableSignalSlot ) return; const int nCh = digi[ID]->GetNumRegChannels(); @@ -3580,7 +3584,7 @@ void DigiSettingsPanel::SyncCheckBox(QCheckBox *(&chk)[][MaxRegChannel+1]){ } void DigiSettingsPanel::SyncAllChannelsTab_PHA(){ - + DebugPrint("%s", "DigiSettingsPanel"); SyncSpinBox(sbRecordLength); SyncSpinBox(sbPreTrigger); SyncSpinBox(sbInputRiseTime); @@ -3626,7 +3630,7 @@ void DigiSettingsPanel::SyncAllChannelsTab_PHA(){ void DigiSettingsPanel::UpdateSettings_PHA(){ - + DebugPrint("%s", "DigiSettingsPanel"); enableSignalSlot = false; //printf("------ %s \n", __func__); @@ -3693,7 +3697,7 @@ void DigiSettingsPanel::UpdateSettings_PHA(){ void DigiSettingsPanel::SyncAllChannelsTab_PSD(){ - + DebugPrint("%s", "DigiSettingsPanel"); SyncSpinBox(sbRecordLength); SyncSpinBox(sbPreTrigger); SyncSpinBox(sbThreshold); @@ -3753,7 +3757,7 @@ void DigiSettingsPanel::SyncAllChannelsTab_PSD(){ } void DigiSettingsPanel::UpdateSettings_PSD(){ - + DebugPrint("%s", "DigiSettingsPanel"); enableSignalSlot = false; // printf("------ %s \n", __func__); @@ -3835,7 +3839,7 @@ void DigiSettingsPanel::UpdateSettings_PSD(){ } void DigiSettingsPanel::SyncAllChannelsTab_QDC(){ - + DebugPrint("%s", "DigiSettingsPanel"); if( !enableSignalSlot ) return; // SyncSpinBox(sbRecordLength); @@ -3929,6 +3933,7 @@ void DigiSettingsPanel::SyncAllChannelsTab_QDC(){ } void DigiSettingsPanel::UpdateSettings_QDC(){ + DebugPrint("%s", "DigiSettingsPanel"); enableSignalSlot = false; uint32_t haha = digi[ID]->ReadQDCRecordLength(); @@ -4014,7 +4019,7 @@ void DigiSettingsPanel::UpdateSettings_QDC(){ } void DigiSettingsPanel::CheckRadioAndCheckedButtons(){ - + DebugPrint("%s", "DigiSettingsPanel"); int id1 = cbFromBoard->currentIndex(); int id2 = cbToBoard->currentIndex(); @@ -4069,7 +4074,7 @@ void DigiSettingsPanel::ReadSettingsFromBoard(){ } void DigiSettingsPanel::SaveSetting(int opt){ - + DebugPrint("%s", "DigiSettingsPanel"); QDir dir(rawDataPath); if( !dir.exists() ) dir.mkpath("."); @@ -4102,6 +4107,7 @@ void DigiSettingsPanel::SaveSetting(int opt){ } void DigiSettingsPanel::LoadSetting(){ + DebugPrint("%s", "DigiSettingsPanel"); QFileDialog fileDialog(this); fileDialog.setDirectory(rawDataPath); fileDialog.setFileMode(QFileDialog::ExistingFile); diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index d58aacd..359d379 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -23,7 +23,7 @@ std::vector onlineAnalyzerList = {"Coincident","Splie-Pole", "Encore", "RAISOR"}; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ - + DebugPrint("%s", "FSUDAQ"); setWindowTitle("FSU DAQ"); setGeometry(500, 100, 1100, 600); @@ -293,7 +293,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){ } MainWindow::~MainWindow(){ - + DebugPrint("%s", "FSUDAQ"); if( scalar ) { scalarThread->Stop(); scalarThread->quit(); @@ -332,7 +332,7 @@ MainWindow::~MainWindow(){ //*************************************************************** //*************************************************************** void MainWindow::OpenDataPath(){ - + DebugPrint("%s", "FSUDAQ"); QFileDialog fileDialog(this); fileDialog.setFileMode(QFileDialog::Directory); int result = fileDialog.exec(); @@ -356,7 +356,7 @@ void MainWindow::OpenDataPath(){ } void MainWindow::OpenRecord(){ - + DebugPrint("%s", "FSUDAQ"); QString filePath = leDataPath->text() + "/RunTimeStamp.dat"; if( runRecord == nullptr ){ @@ -388,7 +388,7 @@ void MainWindow::OpenRecord(){ } void MainWindow::UpdateRecord(){ - + DebugPrint("%s", "FSUDAQ"); if( !runRecord ) return; QString filePath = leDataPath->text() + "/RunTimeStamp.dat"; @@ -419,7 +419,7 @@ void MainWindow::UpdateRecord(){ } void MainWindow::LoadProgramSettings(){ - + DebugPrint("%s", "FSUDAQ"); LogMsg("Loading " + programSettingsFilePath + " for Program Settings."); QFile file(programSettingsFilePath); @@ -482,7 +482,7 @@ void MainWindow::LoadProgramSettings(){ } void MainWindow::SaveProgramSettings(){ - + DebugPrint("%s", "FSUDAQ"); rawDataPath = leDataPath->text(); QFile file(programSettingsFilePath); @@ -505,7 +505,7 @@ void MainWindow::SaveProgramSettings(){ } void MainWindow::LoadLastRunFile(){ - + DebugPrint("%s", "FSUDAQ"); QFile file(rawDataPath + "/lastRun.sh"); if( !file.open(QIODevice::Text | QIODevice::ReadOnly) ) { @@ -546,7 +546,7 @@ void MainWindow::LoadLastRunFile(){ } void MainWindow::SaveLastRunFile(){ - + DebugPrint("%s", "FSUDAQ"); QFile file(rawDataPath + "/lastRun.sh"); prefix = lePrefix->text(); @@ -566,7 +566,7 @@ void MainWindow::SaveLastRunFile(){ //*************************************************************** //*************************************************************** void MainWindow::OpenDigitizers(){ - + DebugPrint("%s", "FSUDAQ"); if( cbOpenDigitizers->currentIndex() == 0 ) return; // placeholder for USB @@ -710,7 +710,6 @@ void MainWindow::OpenDigitizers(){ } void MainWindow::CloseDigitizers(){ - LogMsg("MainWindow::Closing Digitizer(s)...."); if( scope ) { @@ -785,7 +784,7 @@ void MainWindow::CloseDigitizers(){ } void MainWindow::WaitForDigitizersOpen(bool onOff){ - + DebugPrint("%s", "FSUDAQ"); // bnOpenDigitizers->setEnabled(onOff); cbOpenDigitizers->setEnabled(onOff); @@ -810,7 +809,7 @@ void MainWindow::WaitForDigitizersOpen(bool onOff){ //*************************************************************** //*************************************************************** void MainWindow::SetupScalar(){ - + DebugPrint("%s", "FSUDAQ"); // printf("%s\n", __func__); scalar = new QMainWindow(this); @@ -941,7 +940,7 @@ void MainWindow::SetupScalar(){ } void MainWindow::CleanUpScalar(){ - + DebugPrint("%s", "FSUDAQ"); if( scalar == nullptr) return; scalar->close(); @@ -970,10 +969,12 @@ void MainWindow::CleanUpScalar(){ } void MainWindow::OpenScalar(){ + DebugPrint("%s", "FSUDAQ"); scalar->show(); } void MainWindow::UpdateScalar(){ + DebugPrint("%s", "FSUDAQ"); if( digi == nullptr ) return; if( scalar == nullptr ) return; //if( !scalar->isVisible() ) return; @@ -1041,6 +1042,7 @@ void MainWindow::UpdateScalar(){ //*************************************************************** //*************************************************************** void MainWindow::StartACQ(){ + DebugPrint("%s", "FSUDAQ"); if( digi == nullptr ) return; bool commentResult = true; @@ -1126,6 +1128,7 @@ void MainWindow::StartACQ(){ } void MainWindow::StopACQ(){ + DebugPrint("%s", "FSUDAQ"); if( digi == nullptr ) return; bool commentResult = true; @@ -1217,8 +1220,8 @@ void MainWindow::StopACQ(){ } -void MainWindow::AutoRun(){ //TODO - +void MainWindow::AutoRun(){ + DebugPrint("%s", "FSUDAQ"); runTimer->disconnect(runTimerConnection); if( chkSaveData->isChecked() == false){ StartACQ(); @@ -1290,7 +1293,7 @@ void MainWindow::AutoRun(){ //TODO } void MainWindow::SetSyncMode(){ - + DebugPrint("%s", "FSUDAQ"); QDialog dialog; dialog.setWindowTitle("Board Synchronization"); @@ -1386,6 +1389,7 @@ void MainWindow::SetSyncMode(){ } void MainWindow::SetAndLockInfluxElog(){ + DebugPrint("%s", "FSUDAQ"); if( leInfluxIP->isReadOnly() ){ bnLock->setText("Lock and Set"); @@ -1505,7 +1509,7 @@ void MainWindow::SetAndLockInfluxElog(){ } bool MainWindow::CommentDialog(bool isStartRun){ - + DebugPrint("%s", "FSUDAQ"); if( isStartRun ) runID ++; QString runIDStr = QString::number(runID).rightJustified(3, '0'); @@ -1586,7 +1590,7 @@ bool MainWindow::CommentDialog(bool isStartRun){ } void MainWindow::WriteRunTimestamp(bool isStartRun){ - + DebugPrint("%s", "FSUDAQ"); QFile file(rawDataPath + "/RunTimeStamp.dat"); QString dateTime = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss"); @@ -1686,7 +1690,7 @@ void MainWindow::OpenScope(){ //*************************************************************** //*************************************************************** void MainWindow::OpenDigiSettings(){ - + DebugPrint("%s", "FSUDAQ"); if( digiSettings == nullptr ) { digiSettings = new DigiSettingsPanel(digi, nDigi, rawDataPath); //connect(scope, &Scope::SendLogMsg, this, &MainWindow::LogMsg); @@ -1703,7 +1707,7 @@ void MainWindow::OpenDigiSettings(){ //*************************************************************** //*************************************************************** void MainWindow::OpenCanvas(){ - + DebugPrint("%s", "FSUDAQ"); if( canvas == nullptr ) { canvas = new SingleSpectra(digi, nDigi, rawDataPath); canvas->show(); @@ -1716,6 +1720,7 @@ void MainWindow::OpenCanvas(){ //*************************************************************** //*************************************************************** void MainWindow::OpenAnalyzer(){ + DebugPrint("%s", "FSUDAQ"); int id = cbAnalyzer->currentData().toInt(); if( id < 0 ) return; @@ -1749,7 +1754,7 @@ void MainWindow::OpenAnalyzer(){ //*************************************************************** //*************************************************************** void MainWindow::UpdateAllPanels(int panelID){ - + DebugPrint("%s", "FSUDAQ"); //panelID is the source panel that call // scope = 1; // digiSetting = 2; @@ -1810,7 +1815,7 @@ void MainWindow::UpdateAllPanels(int panelID){ //*************************************************************** //*************************************************************** void MainWindow::SetUpInflux(){ - + DebugPrint("%s", "FSUDAQ"); if( influxIP == "" ) { LogMsg("Influx missing inputs. skip."); leInfluxIP->setEnabled(false); @@ -1874,7 +1879,7 @@ void MainWindow::SetUpInflux(){ } void MainWindow::CheckElog(){ - + DebugPrint("%s", "FSUDAQ"); if( elogIP != "" && elogName != "" && elogUser != "" && elogPWD != "" ){ WriteElog("Testing communication.", "Testing communication.", "Other", 0); AppendElog("test append elog."); @@ -1903,7 +1908,7 @@ void MainWindow::CheckElog(){ } void MainWindow::WriteElog(QString htmlText, QString subject, QString category, int runNumber){ - + DebugPrint("%s", "FSUDAQ"); //if( elogID < 0 ) return; if( elogName == "" ) return; if( elogUser == "" ) return; @@ -1932,6 +1937,7 @@ void MainWindow::WriteElog(QString htmlText, QString subject, QString category, } void MainWindow::AppendElog(QString appendHtmlText){ + DebugPrint("%s", "FSUDAQ"); if( elogID < 1 ) return; if( elogName == "" ) return; @@ -1968,6 +1974,7 @@ void MainWindow::AppendElog(QString appendHtmlText){ //*************************************************************** //*************************************************************** void MainWindow::LogMsg(QString msg){ + DebugPrint("%s", "FSUDAQ"); QString outputStr = QStringLiteral("[%1] %2").arg(QDateTime::currentDateTime().toString("MM.dd hh:mm:ss"), msg); if( logMsgHTMLMode ){ logInfo->appendHtml(outputStr); diff --git a/Histogram1D.h b/Histogram1D.h index 8b239de..08fd6e6 100644 --- a/Histogram1D.h +++ b/Histogram1D.h @@ -2,6 +2,7 @@ #define HISTOGRAM_1D_H #include "qcustomplot.h" +#include "macro.h" #define MaxNHist 10 @@ -11,7 +12,7 @@ class Histogram1D : public QCustomPlot{ Q_OBJECT public: Histogram1D(QString title, QString xLabel, int xbin, double xmin, double xmax, QWidget * parent = nullptr) : QCustomPlot(parent){ - + DebugPrint("%s", "Histogram1D"); isLogY = false; for( int i = 0; i < 3; i ++) txt[i] = nullptr; @@ -194,6 +195,7 @@ public: double GetXMax() const {return xMax;} void SetColor(QColor color, unsigned short ID = 0) { + DebugPrint("%s", "Histogram1D"); graph(ID)->setPen(QPen(color)); QColor haha = color; haha.setAlpha(20); @@ -208,6 +210,7 @@ public: } void UpdatePlot(){ + DebugPrint("%s", "Histogram1D"); for( int ID = 0 ; ID < nData; ID ++) graph(ID)->setData(xList, yList[ID]); xAxis->setRangeLower(xMin); xAxis->setRangeUpper(xMax); @@ -217,6 +220,7 @@ public: } void Clear(){ + DebugPrint("%s", "Histogram1D"); for( int ID = 0 ; ID < nData; ID ++) { for( int i = 0; i <= yList[ID].count(); i++) yList[ID][i] = 0; } @@ -233,6 +237,7 @@ public: void SetXTitle(QString xTitle) { xAxis->setLabel(xTitle); } void Rebin(int xbin, double xmin, double xmax){ + DebugPrint("%s", "Histogram1D"); xMin = xmin; xMax = xmax; xBin = xbin; @@ -263,6 +268,7 @@ public: } void Fill(double value, unsigned int ID = 0){ + // DebugPrint("%s", "Histogram1D"); if( ID == 0 ){ totalEntry ++; txt[1]->setText("Total Entry : "+ QString::number(totalEntry)); diff --git a/Histogram2D.h b/Histogram2D.h index d134f54..4e43f9e 100644 --- a/Histogram2D.h +++ b/Histogram2D.h @@ -2,6 +2,7 @@ #define HISTOGRAM_2D_H #include "qcustomplot.h" +#include "macro.h" const QList> colorCycle = { {QColor(Qt::red), "Red"}, {QColor(Qt::blue), "Blue"}, @@ -19,7 +20,7 @@ class Histogram2D : public QCustomPlot{ public: Histogram2D(QString title, QString xLabel, QString yLabel, int xbin, double xmin, double xmax, int ybin, double ymin, double ymax, QWidget * parent = nullptr) : QCustomPlot(parent){ - + DebugPrint("%s", "Histogram2D"); for( int i = 0; i < 3; i ++ ){ for( int j = 0; j < 3; j ++ ){ box[i][j] = nullptr; @@ -269,6 +270,7 @@ private: //^############################################### inline void Histogram2D::Fill(double x, double y){ + // DebugPrint("%s", "Histogram2D"); if( isBusy ) return; int xIndex, yIndex; colorMap->data()->coordToCell(x, y, &xIndex, &yIndex); @@ -277,8 +279,8 @@ inline void Histogram2D::Fill(double x, double y){ int xk = 1, yk = 1; if( xIndex < 0 ) xk = 0; if( xIndex >= xBin ) xk = 2; - if( yIndex < 0 ) yk = 0; - if( yIndex >= yBin ) yk = 2; + if( yIndex < 0 ) yk = 2; + if( yIndex >= yBin ) yk = 0; entry[xk][yk] ++; txt[xk][yk]->setText(QString::number(entry[xk][yk])); @@ -295,6 +297,7 @@ inline void Histogram2D::Fill(double x, double y){ } inline void Histogram2D::Rebin(int xbin, double xmin, double xmax, int ybin, double ymin, double ymax){ + DebugPrint("%s", "Histogram2D"); xMin = xmin; xMax = xmax; yMin = ymin; @@ -322,6 +325,7 @@ inline void Histogram2D::Rebin(int xbin, double xmin, double xmax, int ybin, do } inline void Histogram2D::Clear(){ + DebugPrint("%s", "Histogram2D"); for( int i = 0; i < 3; i ++){ for( int j = 0; j < 3; j ++){ entry[i][j] = 0; @@ -337,6 +341,7 @@ inline void Histogram2D::Clear(){ inline void Histogram2D::ClearAllCuts(){ + DebugPrint("%s", "Histogram2D"); numCut = 0; tempCutID = -1; lastPlottableID = -1; @@ -356,6 +361,7 @@ inline void Histogram2D::ClearAllCuts(){ } inline void Histogram2D::PrintCutEntry() const{ + DebugPrint("%s", "Histogram2D"); if( numCut == 0 ) return; printf("=============== There are %d cuts.\n", numCut); for( int i = 0; i < cutList.count(); i++){ @@ -365,7 +371,7 @@ inline void Histogram2D::PrintCutEntry() const{ } inline void Histogram2D::DrawCut(){ - + DebugPrint("%s", "Histogram2D"); //The histogram is the 1st plottable. // the lastPlottableID should be numCut+ 1 if( lastPlottableID != numCut ){ @@ -393,6 +399,7 @@ inline void Histogram2D::DrawCut(){ } inline void Histogram2D::rightMouseClickMenu(QMouseEvent * event){ + DebugPrint("%s", "Histogram2D"); usingMenu = true; setSelectionRectMode(QCP::SelectionRectMode::srmNone); @@ -544,6 +551,7 @@ inline void Histogram2D::rightMouseClickMenu(QMouseEvent * event){ } inline void Histogram2D::rightMouseClickRebin(){ + DebugPrint("%s", "Histogram2D"); QDialog dialog(this); dialog.setWindowTitle("Rebin histogram"); diff --git a/MultiBuilder.cpp b/MultiBuilder.cpp index 6c9e1ab..c7c8228 100644 --- a/MultiBuilder.cpp +++ b/MultiBuilder.cpp @@ -3,6 +3,7 @@ #include MultiBuilder::MultiBuilder(Data ** multiData, std::vector type, std::vector sn) : nData(type.size()){ + DebugPrint("%s", "MultiBuilder"); data = multiData; typeList = type; snList = sn; @@ -25,6 +26,7 @@ MultiBuilder::MultiBuilder(Data ** multiData, std::vector type, std::vector } MultiBuilder::MultiBuilder(Data * singleData, int type, int sn): nData(1){ + DebugPrint("%s", "MultiBuilder"); data = new Data *[1]; data[0] = singleData; typeList.push_back(type); @@ -40,9 +42,11 @@ MultiBuilder::MultiBuilder(Data * singleData, int type, int sn): nData(1){ } MultiBuilder::~MultiBuilder(){ + DebugPrint("%s", "MultiBuilder"); } void MultiBuilder::ClearEvents(){ + DebugPrint("%s", "MultiBuilder"); eventIndex = -1; eventBuilt = 0; totalEventBuilt = 0; @@ -66,7 +70,7 @@ void MultiBuilder::ClearEvents(){ } void MultiBuilder::PrintStat(){ - + DebugPrint("%s", "MultiBuilder"); printf("Total number of evet built : %ld\n", totalEventBuilt); for( int i = 0; i < nData ; i++){ for( int ch = 0; ch < data[i]->GetNChannel() ; ch++){ @@ -77,7 +81,7 @@ void MultiBuilder::PrintStat(){ } void MultiBuilder::PrintAllEvent(){ - + DebugPrint("%s", "MultiBuilder"); printf("Total number of evet built : %ld\n", totalEventBuilt); for( int i = 0; i < totalEventBuilt; i++){ printf("%5d ------- size: %ld\n", i, events[i].size()); @@ -89,7 +93,7 @@ void MultiBuilder::PrintAllEvent(){ } void MultiBuilder::FindEarlistTimeAndCh(bool verbose){ - + DebugPrint("%s", "MultiBuilder"); earlistTime = -1; earlistDigi = -1; earlistCh = -1; @@ -130,7 +134,7 @@ void MultiBuilder::FindEarlistTimeAndCh(bool verbose){ } void MultiBuilder::FindLatestTimeAndCh(bool verbose){ - + DebugPrint("%s", "MultiBuilder"); latestTime = 0; latestDigi = -1; latestCh = -1; @@ -165,6 +169,7 @@ void MultiBuilder::FindLatestTimeAndCh(bool verbose){ } void MultiBuilder::FindEarlistTimeAmongLastData(bool verbose){ + DebugPrint("%s", "MultiBuilder"); latestTime = -1; latestCh = -1; latestDigi = -1; @@ -184,6 +189,7 @@ void MultiBuilder::FindEarlistTimeAmongLastData(bool verbose){ } void MultiBuilder::FindLatestTimeOfData(bool verbose){ + DebugPrint("%s", "MultiBuilder"); latestTime = 0; latestCh = -1; latestDigi = -1; @@ -204,7 +210,7 @@ void MultiBuilder::FindLatestTimeOfData(bool verbose){ } void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){ - + DebugPrint("%s", "MultiBuilder"); FindEarlistTimeAmongLastData(verbose); // give lastest Time, Ch, and Digi FindEarlistTimeAndCh(verbose); //Give the earliest time, ch, digi @@ -334,7 +340,7 @@ void MultiBuilder::BuildEvents(bool isFinal, bool skipTrace, bool verbose){ } void MultiBuilder::BuildEventsBackWard(int maxNumEvent, bool verbose){ - + DebugPrint("%s", "MultiBuilder"); //skip trace, and only build for maxNumEvent events max // remember the end of DataIndex, prevent over build diff --git a/Scope.cpp b/Scope.cpp index 14dcdb4..cf05922 100644 --- a/Scope.cpp +++ b/Scope.cpp @@ -8,7 +8,7 @@ #include QVector Scope::TrapezoidFilter(QVector data, int baseLineEndS, int riseTimeS, int flatTopS, float decayTime_ns){ - + DebugPrint("%s", "Scope"); QVector trapezoid; trapezoid.clear(); @@ -47,7 +47,7 @@ QVector Scope::TrapezoidFilter(QVector data, int baseLineEndS, Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow * parent) : QMainWindow(parent){ - + DebugPrint("%s", "Scope"); this->digi = digi; this->nDigi = nDigi; this->readDataThread = readDataThread; @@ -307,7 +307,7 @@ Scope::Scope(Digitizer ** digi, unsigned int nDigi, ReadDataThread ** readDataTh Scope::~Scope(){ - + DebugPrint("%s", "Scope"); updateTraceThread->Stop(); updateTraceThread->quit(); updateTraceThread->wait(); @@ -323,7 +323,7 @@ Scope::~Scope(){ } void Scope::NullThePointers(){ - + DebugPrint("%s", "Scope"); sbReordLength = nullptr; sbPreTrigger = nullptr; sbDCOffset = nullptr; @@ -359,6 +359,7 @@ void Scope::NullThePointers(){ //*======================================================= //*======================================================= void Scope::StartScope(){ + DebugPrint("%s", "Scope"); if( !digi ) return; //TODO set other channel to be no trace; @@ -406,6 +407,7 @@ void Scope::StartScope(){ } void Scope::StopScope(){ + DebugPrint("%s", "Scope"); if( !digi ) return; // printf("------ Scope::%s \n", __func__); @@ -455,7 +457,7 @@ void Scope::StopScope(){ } void Scope::UpdateScope(){ - + DebugPrint("%s", "Scope"); if( !digi ) return; int ch = cbScopeCh->currentIndex(); @@ -556,6 +558,7 @@ void Scope::UpdateScope(){ //*======================================================= //*======================================================= void Scope::SetUpComboBoxSimple(RComboBox * &cb, QString str, int row, int col){ + DebugPrint("%s", "Scope"); QLabel * lb = new QLabel(str, settingGroup); lb->setAlignment(Qt::AlignRight | Qt::AlignCenter); settingLayout->addWidget(lb, row, col); @@ -566,7 +569,7 @@ void Scope::SetUpComboBoxSimple(RComboBox * &cb, QString str, int row, int col){ } void Scope::SetUpComboBox(RComboBox * &cb, QString str, int row, int col, const Reg para){ - + DebugPrint("%s", "Scope"); SetUpComboBoxSimple(cb, str, row, col); for( int i = 0; i < (int) para.GetComboList().size(); i++){ @@ -612,7 +615,7 @@ void Scope::SetUpComboBox(RComboBox * &cb, QString str, int row, int col, const } void Scope::SetUpSpinBox(RSpinBox * &sb, QString str, int row, int col, const Reg para){ - + DebugPrint("%s", "Scope"); QLabel * lb = new QLabel(str, settingGroup); lb->setAlignment(Qt::AlignRight | Qt::AlignCenter); settingLayout->addWidget(lb, row, col); @@ -687,7 +690,7 @@ void Scope::SetUpSpinBox(RSpinBox * &sb, QString str, int row, int col, const Re } void Scope::CleanUpSettingsGroupBox(){ - + DebugPrint("%s", "Scope"); QList labelChildren1 = settingGroup->findChildren(); for( int i = 0; i < labelChildren1.size(); i++) delete labelChildren1[i]; @@ -983,7 +986,7 @@ void Scope::SetUpPanel_QDC() { } void Scope::EnableControl(bool enable){ - + DebugPrint("%s", "Scope"); if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ){ sbReordLength->setEnabled(enable); @@ -1018,6 +1021,7 @@ void Scope::EnableControl(bool enable){ //*======================================================= void Scope::UpdateComobox(RComboBox * &cb, const Reg para){ + DebugPrint("%s", "Scope"); int ch = cbScopeCh->currentIndex(); enableSignalSlot = false; @@ -1041,6 +1045,7 @@ void Scope::UpdateComobox(RComboBox * &cb, const Reg para){ } void Scope::UpdateSpinBox(RSpinBox * &sb, const Reg para){ + DebugPrint("%s", "Scope"); int ch = cbScopeCh->currentIndex(); if( digi[ID]->GetDPPType() == DPPTypeCode::DPP_QDC_CODE ) ch = ch /8; @@ -1071,6 +1076,7 @@ void Scope::UpdatePanelFromMomeory(){ void Scope::UpdatePanel_PHA(){ enableSignalSlot = false; + printf("==== %s \n", __func__); int ch = cbScopeCh->currentIndex(); @@ -1260,7 +1266,7 @@ void Scope::UpdatePanel_QDC(){ } void Scope::ReadSettingsFromBoard(){ - + DebugPrint("%s", "Scope"); digi[ID]->ReadRegister(DPP::BoardConfiguration); if( digi[ID]->GetDPPType() == V1730_DPP_PHA_CODE ){ diff --git a/SingleSpectra.cpp b/SingleSpectra.cpp index 111edab..053e4ed 100644 --- a/SingleSpectra.cpp +++ b/SingleSpectra.cpp @@ -8,7 +8,7 @@ #include SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawDataPath, QMainWindow * parent) : QMainWindow(parent){ - + DebugPrint("%s", "SingleSpectra"); this->digi = digi; this->nDigi = nDigi; this->rawDataPath = rawDataPath; @@ -69,8 +69,8 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD for( unsigned int i = 0; i < nDigi; i++){ for( int j = 0; j < digi[i]->GetNumInputCh(); j++){ if( hist[i][j] ) hist[i][j]->Clear(); - lastFilledIndex[i][j] = -1; - loopFilledIndex[i][j] = 0; + // lastFilledIndex[i][j] = -1; + // loopFilledIndex[i][j] = 0; } if( hist2D[i] ) hist2D[i]->Clear(); } @@ -132,7 +132,7 @@ SingleSpectra::SingleSpectra(Digitizer ** digi, unsigned int nDigi, QString rawD } SingleSpectra::~SingleSpectra(){ - + DebugPrint("%s", "SingleSpectra"); SaveSetting(); for( unsigned int i = 0; i < nDigi; i++ ){ @@ -144,6 +144,7 @@ SingleSpectra::~SingleSpectra(){ } void SingleSpectra::ClearInternalDataCount(){ + DebugPrint("%s", "SingleSpectra"); for( unsigned int i = 0; i < nDigi; i++){ for( int ch = 0; ch < MaxRegChannel ; ch++) { lastFilledIndex[i][ch] = -1; @@ -153,7 +154,7 @@ void SingleSpectra::ClearInternalDataCount(){ } void SingleSpectra::ChangeHistView(){ - + DebugPrint("%s", "SingleSpectra"); if( !isSignalSlotActive ) return; int bd = cbDigi->currentIndex(); @@ -201,6 +202,7 @@ void SingleSpectra::ChangeHistView(){ } void SingleSpectra::FillHistograms(){ + DebugPrint("%s", "SingleSpectra"); if( !fillHistograms ) return; unsigned short maxFillTimePerDigi = maxFillTimeinMilliSec/nDigi; @@ -249,7 +251,7 @@ void SingleSpectra::FillHistograms(){ } void SingleSpectra::SaveSetting(){ - + DebugPrint("%s", "SingleSpectra"); QFile file(rawDataPath + "/singleSpectraSetting.txt"); file.open(QIODevice::Text | QIODevice::WriteOnly); @@ -279,7 +281,7 @@ void SingleSpectra::SaveSetting(){ } void SingleSpectra::LoadSetting(){ - + DebugPrint("%s", "SingleSpectra"); QFile file(rawDataPath + "/singleSpectraSetting.txt"); if( file.open(QIODevice::Text | QIODevice::ReadOnly) ){ diff --git a/macro.h b/macro.h index 57c1480..fcb3b33 100644 --- a/macro.h +++ b/macro.h @@ -43,4 +43,14 @@ typedef unsigned int uInt; typedef unsigned long uLong; typedef unsigned long long ullong; +#define DebugMode 0 //process check, when 1, print out all function call + +// if DebugMode is 1, define DebugPrint() to be printf(), else, DebugPrint() define nothing +#if DebugMode +#define DebugPrint(fmt, ...) printf(fmt "::%s\n",##__VA_ARGS__, __func__); +#else +#define DebugPrint(fmt, ...) +#endif + + #endif