#include "DigitizerPHA.h" #include "DigitizerPSD.h" #include "ClassData.h" int main(int argc, char* argv[]){ /**************/ const int nBoard = 1; Digitizer **dig = new Digitizer *[nBoard]; for( int i = 0 ; i < nBoard; i++){ int board = i % 3; int port = i/3; dig[i] = new DigitizerPHA(board, port, true); dig[i]->CreateAndSaveSettingBinary("setting_" + to_string(dig[i]->GetSerialNumber()) + ".bin"); //dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin"); } DigitizerPHA * pha = dynamic_cast (dig[0]); pha->ProgramBoard(); pha->PrintBoardConfiguration(); pha->PrintChannelSettingFromDigitizer(0); pha->PrintChannelSettingFromDigitizer(15); pha->GetSetting(Setting::PHA::AnalogProbe1_board_2bit); remove("test.bin"); Data * data = pha->GetData(); data->AllocateMemory(); pha->StartACQ(); for( int p = 0; p < 100; p++){ sleep(1); pha->ReadData(); data->SaveBuffer("test.bin"); data->DecodeBuffer(1); data->ClearData(); } pha->StopACQ(); delete pha; //delete [] dig; /*********************/ ///********************* method for using Data Class for decoding bin file /** 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(); data->DPPType = V1730_DPP_PHA_CODE; 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); /*********************/ ///****************************** casting digitizer type ///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); return 0; }