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-09-26 16:47:20 -04:00
|
|
|
|
|
|
|
|
2022-08-26 17:18:43 -04:00
|
|
|
/**************/
|
2022-09-26 16:47:20 -04:00
|
|
|
|
|
|
|
const int nBoard = 3;
|
2022-08-26 17:18:43 -04:00
|
|
|
Digitizer **dig = new Digitizer *[nBoard];
|
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;
|
2022-09-26 16:47:20 -04:00
|
|
|
dig[i] = new Digitizer(board, port, false, true);
|
2022-08-26 17:18:43 -04:00
|
|
|
dig[i]->CreateAndSaveSettingBinary("setting_" + to_string(dig[i]->GetSerialNumber()) + ".bin");
|
2022-08-18 17:34:28 -04:00
|
|
|
//dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin");
|
2022-08-10 18:35:13 -04:00
|
|
|
}
|
|
|
|
|
2022-09-26 16:47:20 -04:00
|
|
|
/*
|
2022-08-26 17:18:43 -04:00
|
|
|
DigitizerPHA * pha = dynamic_cast<DigitizerPHA*> (dig[0]);
|
|
|
|
pha->ProgramBoard();
|
|
|
|
pha->PrintBoardConfiguration();
|
|
|
|
pha->PrintChannelSettingFromDigitizer(0);
|
|
|
|
pha->PrintChannelSettingFromDigitizer(15);
|
2022-08-12 18:13:54 -04:00
|
|
|
|
2022-08-29 18:06:12 -04:00
|
|
|
pha->GetSetting(Setting::PHA::AnalogProbe1_board_2bit);
|
|
|
|
|
2022-08-26 17:18:43 -04:00
|
|
|
remove("test.bin");
|
2022-08-03 19:00:41 -04:00
|
|
|
|
2022-08-26 17:18:43 -04:00
|
|
|
Data * data = pha->GetData();
|
2022-08-17 16:08:49 -04:00
|
|
|
data->AllocateMemory();
|
2022-08-12 18:13:54 -04:00
|
|
|
|
2022-08-26 17:18:43 -04:00
|
|
|
pha->StartACQ();
|
2022-08-18 17:34:28 -04:00
|
|
|
|
2022-08-26 17:18:43 -04:00
|
|
|
for( int p = 0; p < 100; p++){
|
2022-08-18 17:34:28 -04:00
|
|
|
sleep(1);
|
2022-08-26 17:18:43 -04:00
|
|
|
pha->ReadData();
|
|
|
|
data->SaveBuffer("test.bin");
|
2022-08-23 13:43:05 -04:00
|
|
|
data->DecodeBuffer(1);
|
2022-09-16 17:53:57 -04:00
|
|
|
data->PrintStat();
|
2022-08-26 17:18:43 -04:00
|
|
|
data->ClearData();
|
2022-08-18 17:34:28 -04:00
|
|
|
}
|
2022-08-05 18:15:50 -04:00
|
|
|
|
2022-08-26 17:18:43 -04:00
|
|
|
pha->StopACQ();
|
2022-08-03 19:00:41 -04:00
|
|
|
|
2022-08-18 17:34:28 -04:00
|
|
|
|
2022-08-26 17:18:43 -04:00
|
|
|
delete pha;
|
|
|
|
//delete [] dig;
|
2022-08-03 19:00:41 -04:00
|
|
|
|
2022-08-26 17:18:43 -04:00
|
|
|
/*********************/
|
2022-08-23 13:43:05 -04:00
|
|
|
|
|
|
|
|
|
|
|
///********************* method for using Data Class for decoding bin file
|
2022-08-26 17:18:43 -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;
|
|
|
|
}
|