diff --git a/Aux/test.cpp b/Aux/test.cpp index f1b360a..3b87596 100644 --- a/Aux/test.cpp +++ b/Aux/test.cpp @@ -26,7 +26,7 @@ static void raw(void); int keyboardhit(); int getch(void); -// #include +#include size_t WriteCallBack(char *contents, size_t size, size_t nmemb, void *userp){ // printf(" InfluxDB::%s \n", __func__); @@ -34,9 +34,7 @@ size_t WriteCallBack(char *contents, size_t size, size_t nmemb, void *userp){ return size * nmemb; } -//^====================================== -int main(int argc, char* argv[]){ - +void testInflux(){ InfluxDB * influx = new InfluxDB(); influx->SetURL("https://fsunuc.physics.fsu.edu/influx/"); @@ -56,11 +54,8 @@ int main(int argc, char* argv[]){ // printf("%s \n", influx->Query("testing", "SELECT * from haha ORDER by time DESC LIMIT 5").c_str()); - - delete influx; - // CURL *curl = curl_easy_init(); // CURLcode res; @@ -156,14 +151,92 @@ int main(int argc, char* argv[]){ //============================================= end of influxDB example - // Digitizer * digi = new Digitizer(0, 26006, false, true); - // digi->Reset(); +} - //digi->ProgramBoard_PHA(); - //digi->WriteRegister(DPP::SoftwareClear_W, 1); +void CheckBufferSize(int MaxAggPreRead, int EvtPreAgg){ + + + //Buffer depends on + + Digitizer * digi = new Digitizer(0, 26006, false, true); + digi->Reset(); + digi->ProgramBoard(); + + digi->WriteRegister(DPP::SoftwareClear_W, 1); + + digi->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 0, -1); + digi->WriteRegister(DPP::RecordLength_G, 10, -1); + + digi->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::EnableExtra2, 1, -1); + + digi->WriteRegister(DPP::MaxAggregatePerBlockTransfer, MaxAggPreRead); + digi->WriteRegister(DPP::NumberEventsPerAggregate_G, EvtPreAgg); + + unsigned int bufferSize = digi->CalByteForBuffer(true); + unsigned int bufferSizeCAEN = digi->CalByteForBufferCAEN(); + + printf("Manual Buffer Size : %u Byte = %u words\n", bufferSize, bufferSize/4); + printf(" CAEN Buffer Size : %u Byte = %u words\n", bufferSizeCAEN, bufferSizeCAEN/4); + + unsigned int haha = bufferSize*2 + 16 *( 1- MaxAggPreRead ); + printf("---- %u %u \n", haha, haha/4); + + + delete digi; + +} + +void GetOneAgg(){ + + Digitizer * digi = new Digitizer(0, 26006, false, true); + + if( digi->IsConnected() ){ + digi->Reset(); + digi->ProgramBoard(); + + digi->WriteRegister(DPP::SoftwareClear_W, 1); + + digi->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 0, -1); + digi->WriteRegister(DPP::RecordLength_G, 10, -1); + + digi->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::EnableExtra2, 1, -1); + + digi->WriteRegister(DPP::MaxAggregatePerBlockTransfer, 1); + digi->WriteRegister(DPP::NumberEventsPerAggregate_G, 2); + + unsigned int bufferSize = digi->CalByteForBuffer(true); + unsigned int bufferSizeCAEN = digi->CalByteForBufferCAEN(); + + printf("Manual Buffer Size : %u Byte = %u words\n", bufferSize, bufferSize/4); + printf(" CAEN Buffer Size : %u Byte = %u words\n", bufferSizeCAEN, bufferSizeCAEN/4); + + + digi->StartACQ(); + + usleep(5000*1000); // wait 1sec + + + digi->ReadData(); + digi->GetData()->DecodeBuffer(false, 4); + + digi->StopACQ(); + } + + delete digi; + +} + + +//^====================================== +int main(int argc, char* argv[]){ + + + // CheckBufferSize(5, 4); + + GetOneAgg(); + - // digi->WriteRegister(DPP::QDC::RecordLength, 31, -1); // T = N * 8 * 16 // digi->WriteRegister(DPP::QDC::PreTrigger, 60, -1); // digi->WriteRegister(DPP::QDC::TriggerThreshold_sub2, 17, -1); diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 5d0078a..c2e72fb 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -501,9 +501,9 @@ void Digitizer::StartACQ(){ //return; } }else if( DPPType == V1730_DPP_PSD_CODE) { - bufferSize = 200 * 1024 * 1024; //TODO allocate 200 MB for PSD + bufferSize = CalByteForBufferCAEN(); }else if( DPPType == V1740_DPP_QDC_CODE) { - bufferSize = 200 * 1024 * 1024; //TODO allocate 200 MB for QDC + bufferSize = CalByteForBufferCAEN(); }else{ printf("DPP type not supported. ACQ not start.\n"); return; @@ -576,7 +576,7 @@ void Digitizer::StopACQ(){ data->ZeroTotalFileSize(); } -unsigned int Digitizer::CalByteForBuffer(){ +unsigned int Digitizer::CalByteForBuffer(bool verbose){ unsigned int numAggBLT; unsigned int chMask ; unsigned int boardCfg ; @@ -605,14 +605,18 @@ unsigned int Digitizer::CalByteForBuffer(){ } } - ///printf(" agg. orgainzation (bit) : 0x%X \n", aggOrgan); - ///printf(" Channel Mask : %04X \n", chMask); - ///printf("Max number of Agg per Readout : %u \n", numAggBLT); - ///printf(" is Extra2 enabed : %u \n", ((boardCfg >> 17) & 0x1) ); - ///printf(" is Record wave : %u \n", ((boardCfg >> 16) & 0x1) ); - ///for( int pCh = 0; pCh < NumInputCh/2; pCh++){ - /// printf("Paired Ch : %d, RecordLength (bit value): %u, Event per Agg. : %u \n", pCh, recordLength[pCh], eventAgg[pCh]); - ///} + if( verbose ){ + printf("=================================== Setting related to Buffer\n"); + printf(" agg. orgainzation (bit) : 0x%X \n", aggOrgan); + printf(" Channel Mask : %04X \n", chMask); + printf("Max number of Agg per Readout : %u \n", numAggBLT); + printf(" is Extra2 enabed : %u \n", ((boardCfg >> 17) & 0x1) ); + printf(" is Record wave : %u \n", ((boardCfg >> 16) & 0x1) ); + for( int pCh = 0; pCh < NumInputCh/2; pCh++){ + printf("Paired Ch : %d, RecordLength (bit value): %u, Event per Agg. : %u \n", pCh, recordLength[pCh], eventAgg[pCh]); + } + printf("==============================================================\n"); + } unsigned int bufferSize = aggOrgan; // just for get rip of the warning in complier bufferSize = 0; @@ -627,6 +631,15 @@ unsigned int Digitizer::CalByteForBuffer(){ return bufferSize ; } +unsigned int Digitizer::CalByteForBufferCAEN(){ + + char * BufferCAEN; + uint32_t AllocatedSize, BufferSize; + ret = CAEN_DGTZ_MallocReadoutBuffer(handle, &BufferCAEN, &AllocatedSize); + return AllocatedSize; + +} + int Digitizer::ReadData(){ if( softwareDisable ) return CAEN_DGTZ_DigitizerNotReady; if( !isConnected ) return CAEN_DGTZ_DigitizerNotFound; diff --git a/ClassDigitizer.h b/ClassDigitizer.h index 7eedbe4..f8179ac 100644 --- a/ClassDigitizer.h +++ b/ClassDigitizer.h @@ -108,7 +108,8 @@ class Digitizer{ void ReadAndPrintACQStatue(); void ReadACQStatus() { acqStatus = ReadRegister(DPP::AcquisitionStatus_R); } - unsigned int CalByteForBuffer(); + unsigned int CalByteForBuffer(bool verbose = false); + unsigned int CalByteForBufferCAEN(); //^================= Settings /// write value to digitizer, memory, and settingFile (if exist) diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 7066ecb..30eb626 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -1807,7 +1807,12 @@ void MainWindow::UpdateAllPanels(int panelID){ //*************************************************************** void MainWindow::SetUpInflux(){ - if( influxIP == "" ) return; + if( influxIP == "" ) { + LogMsg("Influx missing inputs. skip."); + leInfluxIP->setEnabled(false); + leDatabaseName->setEnabled(false); + return; + } if( influx ) { delete influx;