matched the buffer calculation with CEAN, but it is like 2 times bigger.
This commit is contained in:
parent
c1c77b7086
commit
12f17fe912
|
@ -95,6 +95,7 @@ class Data{
|
||||||
inline Data::Data(){
|
inline Data::Data(){
|
||||||
|
|
||||||
ch2ns = 2.0;
|
ch2ns = 2.0;
|
||||||
|
boardSN = 0;
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
for ( int i = 0; i < MaxNChannels; i++) TotNumEvents[i] = 0;
|
for ( int i = 0; i < MaxNChannels; i++) TotNumEvents[i] = 0;
|
||||||
ClearData();
|
ClearData();
|
||||||
|
|
|
@ -108,7 +108,7 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose
|
||||||
case CAEN_DGTZ_V1725: ch2ns = 4.0; break; ///ns -> 250 MSamples/s
|
case CAEN_DGTZ_V1725: ch2ns = 4.0; break; ///ns -> 250 MSamples/s
|
||||||
}
|
}
|
||||||
data->ch2ns = ch2ns;
|
data->ch2ns = ch2ns;
|
||||||
|
data->boardSN = BoardInfo.SerialNumber;
|
||||||
ADCbits = BoardInfo.ADC_NBits;
|
ADCbits = BoardInfo.ADC_NBits;
|
||||||
ADCFullSize = (unsigned int)( pow(2, ADCbits) -1 );
|
ADCFullSize = (unsigned int)( pow(2, ADCbits) -1 );
|
||||||
//SetBoardID(BoardInfo.SerialNumber);
|
//SetBoardID(BoardInfo.SerialNumber);
|
||||||
|
@ -265,7 +265,8 @@ int Digitizer::ProgramPHABoard(){
|
||||||
printf("======== program board PHA\n");
|
printf("======== program board PHA\n");
|
||||||
|
|
||||||
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::RecordLength_G + 0x7000, 250);
|
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::RecordLength_G + 0x7000, 250);
|
||||||
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x0F8115);
|
ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x0F8115); /// has Extra2
|
||||||
|
///ret = CAEN_DGTZ_WriteRegister(handle, Register::DPP::BoardConfiguration, 0x0D8115); /// diable Extra2
|
||||||
|
|
||||||
//TODO change to write register
|
//TODO change to write register
|
||||||
ret = CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command
|
ret = CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command
|
||||||
|
@ -317,11 +318,15 @@ int Digitizer::ProgramPHABoard(){
|
||||||
//========================================================= ACQ control
|
//========================================================= ACQ control
|
||||||
void Digitizer::StartACQ(){
|
void Digitizer::StartACQ(){
|
||||||
if ( AcqRun ) return;
|
if ( AcqRun ) return;
|
||||||
|
|
||||||
|
data->AllocateMemory(CalByteForBuffer());
|
||||||
ret = CAEN_DGTZ_SWStartAcquisition(handle);
|
ret = CAEN_DGTZ_SWStartAcquisition(handle);
|
||||||
|
|
||||||
if( ret != 0 ) {
|
if( ret != 0 ) {
|
||||||
ErrorMsg("Start ACQ");
|
ErrorMsg("Start ACQ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("\e[1m\e[33m======= Acquisition Started for Board %d\e[0m\n", boardID);
|
printf("\e[1m\e[33m======= Acquisition Started for Board %d\e[0m\n", boardID);
|
||||||
AcqRun = true;
|
AcqRun = true;
|
||||||
}
|
}
|
||||||
|
@ -376,7 +381,11 @@ unsigned int Digitizer::CalByteForBuffer(){
|
||||||
bufferSize += ( 2 + ((boardCfg >> 17) & 0x1) + recordLength[pCh]*4 ) * eventAgg[pCh] ;
|
bufferSize += ( 2 + ((boardCfg >> 17) & 0x1) + recordLength[pCh]*4 ) * eventAgg[pCh] ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bufferSize * 4 * numAggBLT; /// 1 word = 4 byte;
|
///return bufferSize * numAggBLT * 4; /// 1 word = 4 byte;
|
||||||
|
|
||||||
|
///to Match CAEN calculation
|
||||||
|
return ( ( bufferSize * 2 + 28 ) * numAggBLT + 4 ) * 4; /// 1 word = 4 byte;
|
||||||
|
/// this is effectively, means, the board Agg. header size is 36 words, and dual channel is count for MaxNChannel.
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::ReadData(){
|
void Digitizer::ReadData(){
|
||||||
|
@ -394,7 +403,24 @@ void Digitizer::ReadData(){
|
||||||
ErrorMsg(__func__);
|
ErrorMsg(__func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Digitizer::PrintACQStatue(){
|
||||||
|
if( !isConnected ) return;
|
||||||
|
unsigned int status = ReadRegister(Register::DPP::AcquisitionStatus_R);
|
||||||
|
|
||||||
|
printf("=================== Print ACQ status \n");
|
||||||
|
printf(" 32 28 24 20 16 12 8 4 0\n");
|
||||||
|
printf(" | | | | | | | | |\n");
|
||||||
|
std::cout <<" 0b" << std::bitset<32>(status) << std::endl;
|
||||||
|
printf(" Acq state (0x%1X): %s \n", (status >> 2) & 0x1, ((status >> 2) & 0x1) == 0? "stopped" : "running");
|
||||||
|
printf(" Event Ready (0x%1X): %s \n", (status >> 3) & 0x1, ((status >> 3) & 0x1) == 0? "no event in buffer" : "event in buffer");
|
||||||
|
printf(" Event Full (0x%1X): %s \n", (status >> 4) & 0x1, ((status >> 4) & 0x1) == 0? "not full" : "full");
|
||||||
|
printf(" Clock source (0x%1X): %s \n", (status >> 5) & 0x1, ((status >> 5) & 0x1) == 0? "internal" : "external");
|
||||||
|
printf(" Board ready (0x%1X): %s \n", (status >> 8) & 0x1, ((status >> 8) & 0x1) == 0? "not ready" : "ready");
|
||||||
|
printf(" Ch shutDown (0x%1X): %s \n", (status >> 19) & 0x1, ((status >> 19) & 0x1) == 0? "Channels are on" : "channels are shutdown");
|
||||||
|
printf(" TRG-IN 0x%1X \n", (status >> 16) & 0x1);
|
||||||
|
printf(" Ch temp state 0x%04X \n", (status >> 20) & 0xF);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================
|
//===========================================================
|
||||||
|
@ -438,22 +464,21 @@ uint32_t Digitizer::ReadRegister(Reg registerAddress, unsigned short ch, bool is
|
||||||
return data[0];
|
return data[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Digitizer::PrintACQStatue(){
|
uint32_t Digitizer::PrintRegister(uint32_t address, std::string msg){
|
||||||
if( !isConnected ) return;
|
if( !isConnected ) return 0 ;
|
||||||
unsigned int status = ReadRegister(Register::DPP::AcquisitionStatus_R);
|
printf("\e[33m----------------------------------------------------\n");
|
||||||
|
printf("------------ %s = 0x%X \n", msg.c_str(), address);
|
||||||
|
printf("----------------------------------------------------\e[0m\n");
|
||||||
|
|
||||||
|
uint32_t * value = new uint32_t[1];
|
||||||
|
CAEN_DGTZ_ReadRegister(handle, address, value);
|
||||||
|
printf(" %*s 32 28 24 20 16 12 8 4 0\n", (int) msg.length(), "");
|
||||||
|
printf(" %*s | | | | | | | | |\n", (int) msg.length(), "");
|
||||||
|
printf(" %*s", (int) msg.length(), "");
|
||||||
|
std::cout << " : 0b" << std::bitset<32>(value[0]) << std::endl;
|
||||||
|
printf(" %*s : 0x%X\n", (int) msg.length(), msg.c_str(), value[0]);
|
||||||
|
|
||||||
printf("=================== Print ACQ status \n");
|
return value[0];
|
||||||
printf(" 32 28 24 20 16 12 8 4 0\n");
|
|
||||||
printf(" | | | | | | | | |\n");
|
|
||||||
std::cout <<" 0b" << std::bitset<32>(status) << std::endl;
|
|
||||||
printf(" Acq state (0x%1X): %s \n", (status >> 2) & 0x1, ((status >> 2) & 0x1) == 0? "stopped" : "running");
|
|
||||||
printf(" Event Ready (0x%1X): %s \n", (status >> 3) & 0x1, ((status >> 3) & 0x1) == 0? "no event in buffer" : "event in buffer");
|
|
||||||
printf(" Event Full (0x%1X): %s \n", (status >> 4) & 0x1, ((status >> 4) & 0x1) == 0? "not full" : "full");
|
|
||||||
printf(" Clock source (0x%1X): %s \n", (status >> 5) & 0x1, ((status >> 5) & 0x1) == 0? "internal" : "external");
|
|
||||||
printf(" Board ready (0x%1X): %s \n", (status >> 8) & 0x1, ((status >> 8) & 0x1) == 0? "not ready" : "ready");
|
|
||||||
printf(" Ch shutDown (0x%1X): %s \n", (status >> 19) & 0x1, ((status >> 19) & 0x1) == 0? "Channels are on" : "channels are shutdown");
|
|
||||||
printf(" TRG-IN 0x%1X \n", (status >> 16) & 0x1);
|
|
||||||
printf(" Ch temp state 0x%04X \n", (status >> 20) & 0xF);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//========================================== setting file IO
|
//========================================== setting file IO
|
||||||
|
@ -867,21 +892,5 @@ int Digitizer::GetChTemperature(int ch){
|
||||||
return temp[0];
|
return temp[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Digitizer::PrintRegister(uint32_t address, std::string msg){
|
|
||||||
if( !isConnected ) return 0 ;
|
|
||||||
printf("\e[33m----------------------------------------------------\n");
|
|
||||||
printf("------------ %s = 0x%X \n", msg.c_str(), address);
|
|
||||||
printf("----------------------------------------------------\e[0m\n");
|
|
||||||
|
|
||||||
uint32_t * value = new uint32_t[1];
|
|
||||||
CAEN_DGTZ_ReadRegister(handle, address, value);
|
|
||||||
printf(" %*s 32 28 24 20 16 12 8 4 0\n", (int) msg.length(), "");
|
|
||||||
printf(" %*s | | | | | | | | |\n", (int) msg.length(), "");
|
|
||||||
printf(" %*s", (int) msg.length(), "");
|
|
||||||
cout << " : 0b" << bitset<32>(value[0]) << endl;
|
|
||||||
printf(" %*s : 0x%X\n", (int) msg.length(), msg.c_str(), value[0]);
|
|
||||||
|
|
||||||
return value[0];
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -189,6 +189,7 @@ int main(int argc, char **argv) {
|
||||||
fclose(haha);
|
fclose(haha);
|
||||||
|
|
||||||
Data * data = new Data();
|
Data * data = new Data();
|
||||||
|
//TODO get the DPPType and boardSN from file
|
||||||
data->DPPType = V1730_DPP_PHA_CODE;
|
data->DPPType = V1730_DPP_PHA_CODE;
|
||||||
data->boardSN = 323;
|
data->boardSN = 323;
|
||||||
data->SetSaveWaveToMemory(true);
|
data->SetSaveWaveToMemory(true);
|
||||||
|
|
|
@ -608,8 +608,6 @@ void MainWindow::PlotSingleTrace(){
|
||||||
int chID = chIDEntry->GetNumber();
|
int chID = chIDEntry->GetNumber();
|
||||||
|
|
||||||
Data * data = digi[boardID]->GetData();
|
Data * data = digi[boardID]->GetData();
|
||||||
data->AllocateMemory();
|
|
||||||
|
|
||||||
int ch2ns = (int) digi[boardID]->GetCh2ns();
|
int ch2ns = (int) digi[boardID]->GetCh2ns();
|
||||||
|
|
||||||
digi[boardID]->StartACQ();
|
digi[boardID]->StartACQ();
|
||||||
|
@ -736,8 +734,6 @@ void * MainWindow::RunThread(void * ptr){
|
||||||
printf("|%s|\n", dataFileName.Data());
|
printf("|%s|\n", dataFileName.Data());
|
||||||
|
|
||||||
Data * data = digi[boardID]->GetData();
|
Data * data = digi[boardID]->GetData();
|
||||||
unsigned int bufferSize = digi[boardID]->CalByteForBuffer();
|
|
||||||
data->AllocateMemory(bufferSize);
|
|
||||||
|
|
||||||
while(digi[boardID]->IsRunning()){
|
while(digi[boardID]->IsRunning()){
|
||||||
|
|
||||||
|
|
52
test.cpp
52
test.cpp
|
@ -81,27 +81,49 @@ unsigned long get_time(){
|
||||||
|
|
||||||
int main(int argc, char* argv[]){
|
int main(int argc, char* argv[]){
|
||||||
|
|
||||||
/**##################### Demo for loading and change setting without open a digitizer
|
/**////##################### Demo for loading and change setting without open a digitizer
|
||||||
Digitizer dig;
|
Digitizer * dig = new Digitizer();
|
||||||
dig.LoadSettingBinary("setting_323.bin");
|
dig->OpenDigitizer(0, 1, false, true);
|
||||||
|
dig->LoadSettingBinary("setting_323.bin");
|
||||||
|
|
||||||
//dig.PrintSettingFromMemory();
|
//dig->ProgramPHABoard();
|
||||||
///dig.SaveSettingAsText("haha.txt");
|
|
||||||
|
|
||||||
printf("ch2ns = %f \n", dig.GetCh2ns());
|
//dig->PrintSettingFromMemory();
|
||||||
|
///dig->SaveSettingAsText("haha.txt");
|
||||||
|
|
||||||
|
for( int i = 0; i < dig->GetNChannel(); i++){
|
||||||
|
dig->WriteRegister(Register::DPP::NumberEventsPerAggregate_G, 2, i);
|
||||||
|
dig->WriteRegister(Register::DPP::RecordLength_G, 200, i);
|
||||||
|
}
|
||||||
|
dig->WriteRegister(Register::DPP::MaxAggregatePerBlockTransfer, 5, 0);
|
||||||
|
dig->WriteRegister(Register::DPP::BoardConfiguration, 0x0F8115); /// has Extra2
|
||||||
|
//dig->WriteRegister(Register::DPP::BoardConfiguration, 0x0D8115); /// no Extra2
|
||||||
|
|
||||||
|
|
||||||
///for( int i = 0; i < dig->GetNChannel(); i++){
|
unsigned int bSize = dig->CalByteForBuffer();
|
||||||
/// dig.SaveSettingToFile(Register::DPP::NumberEventsPerAggregate_G, 10, i);
|
printf(" Buffer Size : %8u byte = %.2f MB \n", bSize, bSize/1024./1024.);
|
||||||
///}
|
|
||||||
///dig.SaveSettingToFile(Register::DPP::MaxAggregatePerBlockTransfer, 200, 0);
|
usleep(1e6);
|
||||||
///
|
|
||||||
unsigned int bSize = dig.CalByteForBuffer();
|
|
||||||
|
char * buffer = NULL;
|
||||||
|
uint32_t size;
|
||||||
|
CAEN_DGTZ_MallocReadoutBuffer(dig->GetHandle(), (char **)& buffer, &size);
|
||||||
|
|
||||||
printf("Buffer Size : %u byte = %.2f MB \n", bSize, bSize/1024./1024.);
|
printf("CAEN calculated Buffer Size : %8u byte = %.2f MB \n", size, size/1024./1024.);
|
||||||
|
|
||||||
Reg haha = dig.FindRegister(Register::DPP::RecordLength_G);
|
printf(" diff : %8u byte \n", size > bSize ? size - bSize : bSize - size);
|
||||||
haha.Print();
|
|
||||||
|
///Block
|
||||||
|
/// 1 -> 128
|
||||||
|
/// 2 -> 240
|
||||||
|
/// 3 -> 352
|
||||||
|
/// 4 -> 464
|
||||||
|
/// 5 -> 576
|
||||||
|
|
||||||
|
delete buffer;
|
||||||
|
|
||||||
|
//delete dig;
|
||||||
|
|
||||||
/**///##################### test with 2 digitizers
|
/**///##################### test with 2 digitizers
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user