diff --git a/ClassData.h b/ClassData.h index aac408e..a455c57 100644 --- a/ClassData.h +++ b/ClassData.h @@ -104,7 +104,7 @@ inline void Data::AllocateMemory(){ //TODO calculate Suitable buffer size BufferSize = 10* 1024* 1024; /// 10M byte buffer = (char *) malloc( BufferSize); - printf("Allocated %d (%lu) byte for buffer \n", BufferSize, sizeof(buffer)); + printf("Allocated %d byte for buffer \n", BufferSize); ///for( int i = 0 ; i < MaxNChannels ; i++ ) Events[i] = (CAEN_DGTZ_DPP_PHA_Event_t *) malloc( BufferSize); ///printf("Allocated %d byte for Events for each channel \n", BufferSize); @@ -191,6 +191,7 @@ inline void Data::PrintBuffer(){ } +//####################################################### Decode inline void Data::DecodeBuffer(char * buffer, bool fastDecode, int verbose){ this->buffer = buffer; DecodeBuffer(fastDecode, verbose); diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 7345aea..58142c7 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -679,7 +679,7 @@ int Digitizer::ProgramPHABoard(){ ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::PreTrigger + 0x7000 , 124 ); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::InputDynamicRange + 0x7000 , 0x0 ); - ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 100); + ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::NumberEventsPerAggregate_G + 0x7000, 511); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::AggregateOrganization, 0); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::MaxAggregatePerBlockTransfer, 40); ret |= CAEN_DGTZ_WriteRegister(handle, Register::DPP::DPPAlgorithmControl + 0x7000, 0xe30200f); diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index d37ef3d..74f9346 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -62,8 +62,10 @@ TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL; TGNumberEntry * MainWindow::boardIDEntry = NULL; TGNumberEntry * MainWindow::chIDEntry = NULL; TGComboBox* MainWindow::cbMode = NULL; -TGTextEntry * MainWindow::dataPrefix; -TGNumberEntry * MainWindow::runIDEntry; +TGTextEntry * MainWindow::dataPrefix = NULL; +TGNumberEntry * MainWindow::runIDEntry = NULL; + +BoardSetting * MainWindow::boardSetting = NULL; TH1F * MainWindow::hEnergy[MaxNBoards][MaxNChannels] = {NULL}; TH1F * MainWindow::hChannel[MaxNBoards] = {NULL}; @@ -416,7 +418,7 @@ void MainWindow::OpenDigitizers(){ bStartRun->SetEnabled(true); - if( nDigi <= 1) boardIDEntry->SetState(true); + if( nDigi > 1) boardIDEntry->SetState(true); chIDEntry->SetState(true); boardIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, nDigi-1); @@ -499,22 +501,29 @@ void MainWindow::StartRun(){ if( cbMode->GetSelected() == Mode_DataRun ) cbMode->SetEnabled(false); - digi[0]->StartACQ(); - if( digi[0]->IsRunning() ) fillHistThread->Run(); - + bool threadFlag = false; + for( int i = 0 ; i < nDigi; i++) { + digi[i]->StartACQ(); + if( digi[i]->IsRunning() ) threadFlag = true; + } + + if( threadFlag ) fillHistThread->Run(); + + if( boardSetting != NULL ) boardSetting->ReadStatus(); + } void MainWindow::StopRun(){ LogMsg(Form("%s",__func__)); if( digi == NULL) return; - digi[0]->StopACQ(); - - //Save last bit of buffer; - - ///===== clear data; - digi[0]->GetData()->ClearTriggerRate(); + for( int i = 0; i < nDigi; i++){ + digi[i]->StopACQ(); + //Save last bit of buffer + ///===== clear data; + digi[i]->GetData()->ClearTriggerRate(); + } bStartRun->SetEnabled(true); bStopRun->SetEnabled(false); @@ -682,14 +691,13 @@ void MainWindow::FitTrace(){ } +//TODO use the ptr to tell which board, and each digitizer has an indivual thread for savign data and filling hists. void * MainWindow::FillHistogram(void * ptr){ printf("=== %s\n", __func__); if( digi == NULL ) return 0; - //int boardID = boardIDEntry->GetNumber(); - //int ch = chIDEntry->GetNumber(); - int boardID = 0; + int boardID = boardIDEntry->GetNumber(); int ch = 0; int ch2ns = 4; int traceLength = 0; @@ -710,6 +718,7 @@ void * MainWindow::FillHistogram(void * ptr){ usleep(100*1000); /// wait 100 msec digi[boardID]->ReadData(); + if( boardSetting != NULL ) boardSetting->ReadStatus(); ch2ns = (int) digi[boardID]->GetCh2ns(); ch = chIDEntry->GetNumber(); diff --git a/FSUDAQ.h b/FSUDAQ.h index 91e9ecb..5c4ff93 100644 --- a/FSUDAQ.h +++ b/FSUDAQ.h @@ -57,7 +57,7 @@ private: vector serialNum; static Digitizer ** digi; - BoardSetting * boardSetting; + static BoardSetting * boardSetting; ChannelSettingPHA * channelSettingPHA; ChannelSettingPSD * channelSettingPSD; RegisterSetting * registerSetting; diff --git a/RegisterAddress.h b/RegisterAddress.h index 3f0df06..a8589a8 100644 --- a/RegisterAddress.h +++ b/RegisterAddress.h @@ -184,8 +184,7 @@ namespace Register { const uint32_t DPPAlgorithmControl2_G = 0x1084; /// R/W const uint32_t EarlyBaselineFreeze = 0x10D8; /// R/W } - } - + } } - + #endif diff --git a/boardSetting.cpp b/boardSetting.cpp index 18aac7d..05552d7 100644 --- a/boardSetting.cpp +++ b/boardSetting.cpp @@ -731,6 +731,14 @@ void BoardSetting::LogMsg(TString msg){ Emit("LogMsg(char*)", msg.Data()); } +void BoardSetting::DisableEdit(){ // When ACQ is running, disable all control + +} + +void BoardSetting::EnableEdit(){ // When ACQ is running, disable all control + +} + void BoardSetting::ReadStatus(){ if( digi == NULL ) return; @@ -738,7 +746,7 @@ void BoardSetting::ReadStatus(){ /// ACQ Status ///digi[boardID]->PrintRegister(Register::DPP::AcquisitionStatus, "ACQ Status"); - uint32_t temp = digi[boardID]->GetSettingFromMemory(Register::DPP::AcquisitionStatus_R); + uint32_t temp = digi[boardID]->ReadRegister(Register::DPP::AcquisitionStatus_R); txtACQStatus ->SetText( ((temp >> 2) & 0x1) == 0 ? "ACQ is stopped" : "ACQ is Running", false); txtACQStatus->SetTextColor( ((temp >> 2) & 0x1) == 0 ? 1 : blue); txtACQEventReady ->SetText( ((temp >> 3) & 0x1) == 0 ? "no Event" : "Has Events", false); txtACQEventReady->SetTextColor( ((temp >> 3) & 0x1) == 0 ? 1 : blue); @@ -759,7 +767,7 @@ void BoardSetting::ReadStatus(){ /// Redaout Status ///digi[boardID]->PrintRegister(Register::DPP::ReadoutStatus, "Readout Status"); - temp = digi[boardID]->GetSettingFromMemory(Register::DPP::ReadoutStatus_R); + temp = digi[boardID]->ReadRegister(Register::DPP::ReadoutStatus_R); if( (temp & 0x1) == 1 ){ txtEventReady->SetText( "Event Ready" , false); txtEventReady->SetTextColor(blue); }else{ diff --git a/boardSetting.h b/boardSetting.h index 5a28ee2..33dcb0e 100644 --- a/boardSetting.h +++ b/boardSetting.h @@ -134,6 +134,8 @@ class BoardSetting{ void CloseWindow() { delete this;} void ChangeBoard(); + void DisableEdit(); + void EnableEdit(); void ReadStatus();