2022-08-04 17:27:33 -04:00
|
|
|
#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
|
|
|
/**************
|
2022-08-10 18:35:13 -04:00
|
|
|
const int nBoard = 1;
|
|
|
|
DigitizerPHA *dig = new DigitizerPHA[nBoard];
|
2022-08-04 17:27:33 -04:00
|
|
|
//DigitizerPSD * psd = new DigitizerPSD();
|
2022-08-03 19:00:41 -04:00
|
|
|
|
2022-08-10 18:35:13 -04:00
|
|
|
for( int i = 0 ; i < nBoard; i++){
|
|
|
|
int board = i % 3;
|
|
|
|
int port = i/3;
|
|
|
|
dig[i].OpenDigitizer(board, port, true);
|
2022-08-18 17:34:28 -04:00
|
|
|
dig[i].CreateAndSaveSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin");
|
|
|
|
//dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin");
|
2022-08-10 18:35:13 -04:00
|
|
|
}
|
|
|
|
|
2022-08-18 17:34:28 -04:00
|
|
|
dig[0].PrintBoardConfiguration();
|
2022-08-15 18:54:55 -04:00
|
|
|
dig[0].PrintChannelSettingFromDigitizer(4);
|
2022-08-12 18:13:54 -04:00
|
|
|
|
2022-08-03 19:00:41 -04:00
|
|
|
|
2022-08-17 16:08:49 -04:00
|
|
|
Data * data = dig[0].data;
|
|
|
|
data->AllocateMemory();
|
2022-08-12 18:13:54 -04:00
|
|
|
|
2022-08-10 18:35:13 -04:00
|
|
|
dig[0].StartACQ();
|
2022-08-18 17:34:28 -04:00
|
|
|
|
|
|
|
for( int p = 0; p < 11; p++){
|
|
|
|
sleep(1);
|
|
|
|
dig[0].ReadData();
|
2022-08-23 13:43:05 -04:00
|
|
|
data->DecodeBuffer(1);
|
2022-08-18 17:34:28 -04:00
|
|
|
}
|
2022-08-05 18:15:50 -04:00
|
|
|
|
2022-08-10 18:35:13 -04:00
|
|
|
dig[0].StopACQ();
|
2022-08-03 19:00:41 -04:00
|
|
|
|
2022-08-18 17:34:28 -04:00
|
|
|
|
2022-08-17 16:08:49 -04:00
|
|
|
|
2022-08-03 19:00:41 -04:00
|
|
|
delete [] dig;
|
2022-08-04 17:27:33 -04:00
|
|
|
//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);
|
|
|
|
|
|
|
|
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
|
|
|
|
2022-08-24 17:50:21 -04:00
|
|
|
haha = fopen("output.bin", "r");
|
|
|
|
printf("pos : %d \n", (int) ftell(haha));
|
|
|
|
|
|
|
|
do{
|
|
|
|
unsigned int word[1]; /// 4 bytes
|
|
|
|
size_t dump = fread(word, 4, 1, haha);
|
|
|
|
fseek(haha, -4, SEEK_CUR);
|
|
|
|
unsigned int aggSize = (word[0] & 0x0FFFFFFF) * 4; ///byte
|
|
|
|
short header = ((word[0] >> 28 ) & 0xF);
|
|
|
|
if( header != 10 ) break;
|
|
|
|
|
|
|
|
printf("-------- %d word = %d bytes\n", aggSize/4, aggSize);
|
|
|
|
char * buffer = new char[aggSize];
|
|
|
|
dump = fread(buffer, aggSize, 1, haha);
|
|
|
|
|
|
|
|
data->DecodeBuffer(buffer, 1);
|
|
|
|
|
|
|
|
if( ftell(haha) >= inFileSize ) break;
|
|
|
|
|
|
|
|
}while(!feof(haha) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fclose(haha);
|
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;
|
|
|
|
}
|