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(){
|
||||
|
||||
ch2ns = 2.0;
|
||||
boardSN = 0;
|
||||
buffer = NULL;
|
||||
for ( int i = 0; i < MaxNChannels; i++) TotNumEvents[i] = 0;
|
||||
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
|
||||
}
|
||||
data->ch2ns = ch2ns;
|
||||
|
||||
data->boardSN = BoardInfo.SerialNumber;
|
||||
ADCbits = BoardInfo.ADC_NBits;
|
||||
ADCFullSize = (unsigned int)( pow(2, ADCbits) -1 );
|
||||
//SetBoardID(BoardInfo.SerialNumber);
|
||||
|
@ -265,7 +265,8 @@ int Digitizer::ProgramPHABoard(){
|
|||
printf("======== program board PHA\n");
|
||||
|
||||
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
|
||||
ret = CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command
|
||||
|
@ -317,11 +318,15 @@ int Digitizer::ProgramPHABoard(){
|
|||
//========================================================= ACQ control
|
||||
void Digitizer::StartACQ(){
|
||||
if ( AcqRun ) return;
|
||||
|
||||
data->AllocateMemory(CalByteForBuffer());
|
||||
ret = CAEN_DGTZ_SWStartAcquisition(handle);
|
||||
|
||||
if( ret != 0 ) {
|
||||
ErrorMsg("Start ACQ");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("\e[1m\e[33m======= Acquisition Started for Board %d\e[0m\n", boardID);
|
||||
AcqRun = true;
|
||||
}
|
||||
|
@ -376,7 +381,11 @@ unsigned int Digitizer::CalByteForBuffer(){
|
|||
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(){
|
||||
|
@ -394,7 +403,24 @@ void Digitizer::ReadData(){
|
|||
ErrorMsg(__func__);
|
||||
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];
|
||||
}
|
||||
|
||||
void Digitizer::PrintACQStatue(){
|
||||
if( !isConnected ) return;
|
||||
unsigned int status = ReadRegister(Register::DPP::AcquisitionStatus_R);
|
||||
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");
|
||||
|
||||
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);
|
||||
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]);
|
||||
|
||||
return value[0];
|
||||
}
|
||||
|
||||
//========================================== setting file IO
|
||||
|
@ -867,21 +892,5 @@ int Digitizer::GetChTemperature(int ch){
|
|||
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);
|
||||
|
||||
Data * data = new Data();
|
||||
//TODO get the DPPType and boardSN from file
|
||||
data->DPPType = V1730_DPP_PHA_CODE;
|
||||
data->boardSN = 323;
|
||||
data->SetSaveWaveToMemory(true);
|
||||
|
|
|
@ -608,8 +608,6 @@ void MainWindow::PlotSingleTrace(){
|
|||
int chID = chIDEntry->GetNumber();
|
||||
|
||||
Data * data = digi[boardID]->GetData();
|
||||
data->AllocateMemory();
|
||||
|
||||
int ch2ns = (int) digi[boardID]->GetCh2ns();
|
||||
|
||||
digi[boardID]->StartACQ();
|
||||
|
@ -736,8 +734,6 @@ void * MainWindow::RunThread(void * ptr){
|
|||
printf("|%s|\n", dataFileName.Data());
|
||||
|
||||
Data * data = digi[boardID]->GetData();
|
||||
unsigned int bufferSize = digi[boardID]->CalByteForBuffer();
|
||||
data->AllocateMemory(bufferSize);
|
||||
|
||||
while(digi[boardID]->IsRunning()){
|
||||
|
||||
|
|
52
test.cpp
52
test.cpp
|
@ -81,27 +81,49 @@ unsigned long get_time(){
|
|||
|
||||
int main(int argc, char* argv[]){
|
||||
|
||||
/**##################### Demo for loading and change setting without open a digitizer
|
||||
Digitizer dig;
|
||||
dig.LoadSettingBinary("setting_323.bin");
|
||||
/**////##################### Demo for loading and change setting without open a digitizer
|
||||
Digitizer * dig = new Digitizer();
|
||||
dig->OpenDigitizer(0, 1, false, true);
|
||||
dig->LoadSettingBinary("setting_323.bin");
|
||||
|
||||
//dig.PrintSettingFromMemory();
|
||||
///dig.SaveSettingAsText("haha.txt");
|
||||
//dig->ProgramPHABoard();
|
||||
|
||||
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++){
|
||||
/// dig.SaveSettingToFile(Register::DPP::NumberEventsPerAggregate_G, 10, i);
|
||||
///}
|
||||
///dig.SaveSettingToFile(Register::DPP::MaxAggregatePerBlockTransfer, 200, 0);
|
||||
///
|
||||
unsigned int bSize = dig.CalByteForBuffer();
|
||||
unsigned int bSize = dig->CalByteForBuffer();
|
||||
printf(" Buffer Size : %8u byte = %.2f MB \n", bSize, bSize/1024./1024.);
|
||||
|
||||
printf("Buffer Size : %u byte = %.2f MB \n", bSize, bSize/1024./1024.);
|
||||
usleep(1e6);
|
||||
|
||||
Reg haha = dig.FindRegister(Register::DPP::RecordLength_G);
|
||||
haha.Print();
|
||||
|
||||
char * buffer = NULL;
|
||||
uint32_t size;
|
||||
CAEN_DGTZ_MallocReadoutBuffer(dig->GetHandle(), (char **)& buffer, &size);
|
||||
|
||||
printf("CAEN calculated Buffer Size : %8u byte = %.2f MB \n", size, size/1024./1024.);
|
||||
|
||||
printf(" diff : %8u byte \n", size > bSize ? size - bSize : bSize - size);
|
||||
|
||||
///Block
|
||||
/// 1 -> 128
|
||||
/// 2 -> 240
|
||||
/// 3 -> 352
|
||||
/// 4 -> 464
|
||||
/// 5 -> 576
|
||||
|
||||
delete buffer;
|
||||
|
||||
//delete dig;
|
||||
|
||||
/**///##################### test with 2 digitizers
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user