FSUDAQ/test.cpp

86 lines
1.9 KiB
C++
Raw Normal View History

#include "DigitizerPHA.h"
2022-08-23 13:43:05 -04:00
#include "DigitizerPSD.h"
#include "ClassData.h"
2022-08-03 19:00:41 -04:00
int main(int argc, char* argv[]){
2022-08-23 13:43:05 -04:00
/**************
const int nBoard = 1;
DigitizerPHA *dig = new DigitizerPHA[nBoard];
//DigitizerPSD * psd = new DigitizerPSD();
2022-08-03 19:00:41 -04:00
for( int i = 0 ; i < nBoard; i++){
int board = i % 3;
int port = i/3;
dig[i].OpenDigitizer(board, port, true);
dig[i].CreateAndSaveSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin");
//dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin");
}
dig[0].PrintBoardConfiguration();
dig[0].PrintChannelSettingFromDigitizer(4);
2022-08-03 19:00:41 -04:00
2022-08-17 16:08:49 -04:00
Data * data = dig[0].data;
data->AllocateMemory();
dig[0].StartACQ();
for( int p = 0; p < 11; p++){
sleep(1);
dig[0].ReadData();
2022-08-23 13:43:05 -04:00
data->DecodeBuffer(1);
}
dig[0].StopACQ();
2022-08-03 19:00:41 -04:00
2022-08-17 16:08:49 -04:00
2022-08-03 19:00:41 -04:00
delete [] dig;
//delete psd;
2022-08-03 19:00:41 -04:00
2022-08-23 13:43:05 -04:00
*********************/
///********************* method for using Data Class for decoding bin file
2022-08-23 15:49:03 -04:00
2022-08-23 13:43:05 -04:00
FILE * haha = fopen("output.bin", "r");
fseek(haha, 0L, SEEK_END);
size_t inFileSize = ftell(haha);
printf("file size : %d Byte\n", (int) inFileSize);
fclose(haha);
haha = fopen("output.bin", "r");
char * buffer = new char[(int)inFileSize];
size_t dump = fread(buffer, inFileSize, 1, haha);
fclose(haha);
Data * data = new Data();
2022-08-23 15:49:03 -04:00
data->DPPType = V1730_DPP_PHA_CODE;
2022-08-23 13:43:05 -04:00
data->buffer = buffer;
2022-08-23 15:49:03 -04:00
data->DecodeBuffer(14);
2022-08-23 13:43:05 -04:00
/*********************/
///****************************** casting digitizer type
2022-08-23 15:49:03 -04:00
///Digitizer ** dig = new Digitizer *[2] ;
/////dig[0] = new Digitizer();
///dig[0] = new DigitizerPHA();
///dig[1] = new DigitizerPSD();
///
///printf("%d \n", dig[0]->GetDPPType());
///printf("%d \n", dig[1]->GetDPPType());
///
///((DigitizerPHA *)dig[0])->PrintBoardConfiguration();
///
///((DigitizerPHA *)dig[0])->SetDPPAlgorithmControl2(0x10000);
2022-08-23 13:43:05 -04:00
2022-08-03 19:00:41 -04:00
return 0;
}