From c851da2f3ca34421066a470e0a18441d0ab65f16 Mon Sep 17 00:00:00 2001 From: "carina@hades" Date: Mon, 17 Oct 2022 14:42:00 -0400 Subject: [PATCH] finished the save/load of setting file while offline --- ClassData.h | 2 +- ClassDigitizer.cpp | 118 ++++++++++++++++++++++++++++-------------- ClassDigitizer.h | 29 +++++++---- FSUDAQ.cpp | 33 ++++++++---- RegisterAddress.h | 8 +++ boardSetting.cpp | 21 ++++++-- channelSettingPHA.cpp | 5 +- test.cpp | 35 +++++++------ 8 files changed, 166 insertions(+), 85 deletions(-) diff --git a/ClassData.h b/ClassData.h index 50418a9..a25af18 100644 --- a/ClassData.h +++ b/ClassData.h @@ -13,7 +13,7 @@ #include "CAENDigitizerType.h" #include "macro.h" -#define MaxNData 10000 /// for timestamp 8 byte = 80kB +#define MaxNData 10000 /// 10k events per channels class Data{ diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 3a27d26..cf4a171 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -23,10 +23,11 @@ void Digitizer::Initalization(){ NChannel = 16; ADCbits = 1; DPPType = 0; - DPPTypeStr = ""; ADCFullSize = 0; ch2ns = 0; BoardInfo = {}; + + isDummy = true; VMEBaseAddress = 0; LinkType = CAEN_DGTZ_USB; /// default USB @@ -63,7 +64,7 @@ void Digitizer::PrintBoard (){ printf("Sampling rate : %.0f MHz = %.1f ns \n", 1000/ch2ns, ch2ns); printf("Number of Channels : %d = 0x%X\n", NChannel, channelMask); printf("SerialNumber :\e[1m\e[33m %d\e[0m\n", BoardInfo.SerialNumber); - printf("DPPType : %d (%s)\n", DPPType, DPPTypeStr.c_str()); + printf("DPPType : %d (%s)\n", DPPType, GetDPPString().c_str()); printf("ADC bit is \e[33m%d\e[0m, %d = 0x%X\n", ADCbits, ADCFullSize, ADCFullSize); printf("ROC FPGA Release is %s\n", BoardInfo.ROC_FirmwareRel); printf("AMC FPGA Release is %s\n", BoardInfo.AMC_FirmwareRel); @@ -110,36 +111,20 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose ADCbits = BoardInfo.ADC_NBits; ADCFullSize = (unsigned int)( pow(2, ADCbits) -1 ); - //SetBoardID(BoardInfo.SerialNumber); - } } ///====================== Check DPP firmware revision - sscanf(BoardInfo.AMC_FirmwareRel, "%d", &DPPType); data->DPPType = DPPType; - switch (DPPType){ - case V1724_DPP_PHA_CODE: DPPTypeStr = "DPP-PHA x724"; break; /// 0x80 - case V1720_DPP_CI_CODE : DPPTypeStr = "DPP-CI x720"; break; /// 0x82 - case V1720_DPP_PSD_CODE: DPPTypeStr = "DPP-PSD x720"; break; /// 0x83 - case V1751_DPP_PSD_CODE: DPPTypeStr = "DPP-PSD x751"; break; /// 0x84 - case V1751_DPP_ZLE_CODE: DPPTypeStr = "DPP-ZLE x751"; break; /// 0x85 - case V1743_DPP_CI_CODE: DPPTypeStr = "DPP-PSD x743"; break; /// 0x86 - case V1740_DPP_QDC_CODE: DPPTypeStr = "DPP-QDC x740"; break; /// 0x87 - case V1730_DPP_PSD_CODE: DPPTypeStr = "DPP-PSD x730"; break; /// 0x88 - case V1730_DPP_PHA_CODE: DPPTypeStr = "DPP-PHA x730"; break; /// 0x8B - case V1730_DPP_ZLE_CODE: DPPTypeStr = "DPP-ZLE x730"; break; /// 0x8C - case V1730_DPP_DAW_CODE: DPPTypeStr = "DPP-DAW x730"; break; /// 0x8D - } if ( verbose ){ PrintBoard(); if (DPPType < 0x80 ) { printf("This digitizer does not have DPP-PHA firmware\n"); }else { printf("\t==== This digitizer has a DPP firmware!\n"); - printf("\e[32m\t %s \e[0m", DPPTypeStr.c_str()); + printf("\e[32m\t %s \e[0m", GetDPPString().c_str()); } } @@ -190,6 +175,7 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose ErrorMsg("end of OpenDigitizer"); if( isConnected && program) { + isDummy = false; ProgramBoard(); } @@ -375,13 +361,13 @@ unsigned int Digitizer::CalByteForBuffer(){ } } - //printf(" Channel Mask : %04X \n", chMask); - //printf("Max number of Agg per Readout : %u \n", numAggBLT); - //printf(" is Extra2 enabed : %u \n", ((boardCfg >> 17) & 0x1) ); - // - //for( int pCh = 0; pCh < NChannel/2; pCh++){ - // printf("Paied Ch : %d, RecordLength (bit value): %u, Event per Agg. : %u \n", pCh, recordLength[pCh], eventAgg[pCh]); - //} + printf(" Channel Mask : %04X \n", chMask); + printf("Max number of Agg per Readout : %u \n", numAggBLT); + printf(" is Extra2 enabed : %u \n", ((boardCfg >> 17) & 0x1) ); + + for( int pCh = 0; pCh < NChannel/2; pCh++){ + printf("Paied Ch : %d, RecordLength (bit value): %u, Event per Agg. : %u \n", pCh, recordLength[pCh], eventAgg[pCh]); + } unsigned int bufferSize = 4; /// Board Agg. header /// Cal size for each dual channel aggregation @@ -415,11 +401,19 @@ void Digitizer::ReadData(){ //=========================================================== //=========================================================== void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool isSave2MemAndFile){ - if( !isConnected ) return; - //printf("0x%X, ch:%02d, 0x%X=%u\n", registerAddress, ch, value, value); + + printf("%s[0x%04X](ch-%02d): %u \n", registerAddress.GetNameChar(), registerAddress.GetAddress(),ch, value); + + if( !isConnected ) { + SetSettingToMemory(registerAddress, value, ch); + SaveSettingToFile(registerAddress, value, ch); + return; + } + + if( registerAddress.GetType() == RW::ReadONLY ) return; ret = CAEN_DGTZ_WriteRegister(handle, registerAddress.ActualAddress(ch), value); - if( ret == 0 && isSave2MemAndFile) { + if( ret == 0 && isSave2MemAndFile && registerAddress.GetType() == RW::ReadWrite) { SetSettingToMemory(registerAddress, value, ch); SaveSettingToFile(registerAddress, value, ch); } @@ -429,6 +423,7 @@ void Digitizer::WriteRegister (Reg registerAddress, uint32_t value, int ch, bool uint32_t Digitizer::ReadRegister(Reg registerAddress, unsigned short ch, bool isSave2MemAndFile, std::string str ){ if( !isConnected ) return 0; + if( registerAddress.GetType() == RW::WriteONLY ) return 0; uint32_t data[1]; ret = CAEN_DGTZ_ReadRegister(handle, registerAddress.ActualAddress(ch), data); @@ -475,14 +470,18 @@ Reg Digitizer::FindRegister(uint32_t address){ if( tempReg.GetName() == ""){ if( DPPType == V1730_DPP_PHA_CODE ){ for( int p = 0; p < (int) RegisterPHAList[p]; p++){ - if( address == RegisterPHAList[p].GetAddress() ) tempReg = RegisterPHAList[p]; - break; + if( address == RegisterPHAList[p].GetAddress() ) { + tempReg = RegisterPHAList[p]; + break; + } } } if( DPPType == V1730_DPP_PSD_CODE ){ for( int p = 0; p < (int) RegisterPSDList[p]; p++){ - if( address == RegisterPSDList[p].GetAddress() ) tempReg = RegisterPSDList[p]; - break; + if( address == RegisterPSDList[p].GetAddress() ) { + tempReg = RegisterPSDList[p]; + break; + } } } } @@ -557,7 +556,7 @@ void Digitizer::PrintSettingFromMemory(){ for( int i = 0; i < SETTINGSIZE; i++) printf("%4d | 0x%04X |0x%08X = %u \n", i, i*4, setting[i], setting[i]); } -void Digitizer::OpenSettingBinary(std::string fileName){ +int Digitizer::OpenSettingBinary(std::string fileName){ if( settingFile != NULL ) delete settingFile; settingFile = fopen(fileName.c_str(), "r+"); @@ -576,30 +575,50 @@ void Digitizer::OpenSettingBinary(std::string fileName){ printf("Created file : %s. file size : %d Byte\n", settingFileName.c_str(), inFileSize); fclose (settingFile); settingFileExist = true; + return 0; }else{ this->settingFileName = fileName; settingFileExist = true; printf("setting file already exist. do nothing. Should program the digitizer\n"); + return -1; } } -void Digitizer::LoadSettingBinary(std::string fileName){ +int Digitizer::LoadSettingBinary(std::string fileName){ settingFile = fopen(fileName.c_str(), "r+"); if( settingFile == NULL ) { - printf(" %s does not exist.\n", fileName.c_str()); + printf(" %s does not exist or cannot load.\n", fileName.c_str()); settingFileExist = false; - return; + return -1; }else{ settingFileExist = true; settingFileName = fileName; + fclose (settingFile); - /// load binary to memoery - size_t dummy = fread( setting, SETTINGSIZE * sizeof(unsigned int), 1, settingFile); + uint32_t fileDPP = ((ReadSettingFromFile(Register::DPP::AMCFirmwareRevision_R, 0) >> 8) & 0xFF); - ProgramSettingsToBoard(); + /// compare seeting DPP version; + if( isConnected && DPPType != fileDPP ){ + printf("DPPType in the file is %s(0x%X), but the dgitizer DPPType is %s(0x%X). \n", GetDPPString(fileDPP).c_str(), fileDPP, GetDPPString().c_str(), DPPType); + return -1; + }else{ + /// load binary to memoery + DPPType = fileDPP; + printf("DPPType in the file is %s(0x%X). \n", GetDPPString(fileDPP).c_str(), fileDPP); + settingFile = fopen(fileName.c_str(), "r+"); + size_t dummy = fread( setting, SETTINGSIZE * sizeof(unsigned int), 1, settingFile); + fclose (settingFile); + + uint32_t boardInfo = GetSettingFromMemory(Register::DPP::BoardInfo_R); + if( (boardInfo & 0xFF) == 0x0E ) ch2ns = 4.0; + if( (boardInfo & 0xFF) == 0x0B ) ch2ns = 2.0; + + ProgramSettingsToBoard(); /// do nothing if not connected. + return 0; + } } } @@ -678,6 +697,25 @@ void Digitizer::SaveSettingAsText(std::string fileName){ } } +std::string Digitizer::GetDPPString(int DPPType){ + std::string DPPTypeStr = ""; + if( DPPType == 0 ) DPPType = this->DPPType; + switch (DPPType){ + case V1724_DPP_PHA_CODE: DPPTypeStr = "DPP-PHA x724"; break; /// 0x80 + case V1720_DPP_CI_CODE : DPPTypeStr = "DPP-CI x720"; break; /// 0x82 + case V1720_DPP_PSD_CODE: DPPTypeStr = "DPP-PSD x720"; break; /// 0x83 + case V1751_DPP_PSD_CODE: DPPTypeStr = "DPP-PSD x751"; break; /// 0x84 + case V1751_DPP_ZLE_CODE: DPPTypeStr = "DPP-ZLE x751"; break; /// 0x85 + case V1743_DPP_CI_CODE: DPPTypeStr = "DPP-PSD x743"; break; /// 0x86 + case V1740_DPP_QDC_CODE: DPPTypeStr = "DPP-QDC x740"; break; /// 0x87 + case V1730_DPP_PSD_CODE: DPPTypeStr = "DPP-PSD x730"; break; /// 0x88 + case V1730_DPP_PHA_CODE: DPPTypeStr = "DPP-PHA x730"; break; /// 0x8B + case V1730_DPP_ZLE_CODE: DPPTypeStr = "DPP-ZLE x730"; break; /// 0x8C + case V1730_DPP_DAW_CODE: DPPTypeStr = "DPP-DAW x730"; break; /// 0x8D + } + return DPPTypeStr; +} + void Digitizer::ErrorMsg(std::string header){ switch (ret){ ///case CAEN_DGTZ_Success : /** 0 */ printf("%s | Operation completed successfully.\n", header.c_str()); break; diff --git a/ClassDigitizer.h b/ClassDigitizer.h index 2f50d1d..efd2c30 100644 --- a/ClassDigitizer.h +++ b/ClassDigitizer.h @@ -30,7 +30,6 @@ class Digitizer{ int NChannel; /// number of channel int ADCbits; /// ADC bit int DPPType; /// DPP verion - std::string DPPTypeStr; /// DPP type in string unsigned int ADCFullSize; /// pow(2, ADCbits) - 1 float ch2ns; /// channel to ns CAEN_DGTZ_BoardInfo_t BoardInfo; @@ -46,6 +45,7 @@ class Digitizer{ int ret; /// return value, refer to CAEN_DGTZ_ErrorCode bool isConnected; /// true for digitizer communication estabished. bool AcqRun; /// true when digitizer is taking data + bool isDummy; /// true for a dummy digitizer. /// ------- setting std::string settingFileName; /// @@ -55,7 +55,8 @@ class Digitizer{ unsigned int setting[SETTINGSIZE]; /// Setting, 4bytes x 2048 = 8192 bytes ///---------- protected functions - void ErrorMsg(std::string header = ""); + + void ErrorMsg(std::string header = ""); public: Digitizer(); /// no digitizer open @@ -69,7 +70,8 @@ class Digitizer{ int CloseDigitizer(); void Initalization(); void Reset(); - + bool IsDummy() {return isDummy;}; + void PrintBoard() ; virtual int ProgramBoard() ; /// program a generic board, no program channel int ProgramPHABoard() ; /// program a default PHA board @@ -86,14 +88,15 @@ class Digitizer{ ///=================Settings /// write value to digitizer, memory, and settingFile (if exist) + /// ONLY WriteRegister can have ch = -1, for writting all channels + /// for board setting, ignore ch void WriteRegister (Reg registerAddress, uint32_t value, int ch = -1, bool isSave2MemAndFile = true); /// read value from digitizer and memory, and save to memory, and settingFile(if exist), - /// ch must be >= 0, /// for board setting, ignore ch uint32_t ReadRegister (Reg registerAddress, unsigned short ch = 0, bool isSave2MemAndFile = true, std::string str = "" ); uint32_t PrintRegister(uint32_t address, std::string msg); - ///================ Get Settings + ///================ Get Board info std::string GetModelName() const {return BoardInfo.ModelName;} int GetSerialNumber() const {return BoardInfo.SerialNumber;} int GetChannelMask() const {return channelMask;} @@ -103,7 +106,7 @@ class Digitizer{ int GetHandle() const {return handle;} bool GetConnectionStatus() const {return isConnected;} int GetDPPType() const {return DPPType;} - std::string GetDPPTypeString() const {return DPPTypeStr;} + std::string GetDPPString(int DPPType = 0); /// if no input, use digitizer DPPType int GetADCBits() const {return BoardInfo.ADC_NBits;} std::string GetROCVersion() const {return BoardInfo.ROC_FirmwareRel;} std::string GetAMCVersion() const {return BoardInfo.AMC_FirmwareRel;} @@ -116,16 +119,22 @@ class Digitizer{ void ProgramSettingsToBoard (); /// simply read settings from memory - void SetSettingToMemory (Reg registerAddress, unsigned int value, unsigned short ch = -1); - unsigned int GetSettingFromMemory (Reg registerAddress, unsigned short ch = -1); + void SetSettingToMemory (Reg registerAddress, unsigned int value, unsigned short ch = 0); + unsigned int GetSettingFromMemory (Reg registerAddress, unsigned short ch = 0); void PrintSettingFromMemory (); unsigned int * GetSetting() {return setting;}; /// memory <--> file void SaveSettingAsText (std::string fileName); std::string GetSettingFileName() {return settingFileName;} - void OpenSettingBinary (std::string fileName); /// Open setting file, if file not exist, call create and save settings, if file exit set the settignFileName but not overwrite - void LoadSettingBinary (std::string fileName); /// load settign file to memory, if digitizer connected, program digitizer + /// Open setting file, if file not exist, call create and save settings, return 0 + /// if file exit, set the settignFileName but not overwrite, return -1; + int OpenSettingBinary (std::string fileName); + /// load setting file to memory + /// if connected and DPPtype match, program digitizer + /// else assumed not connected and save settings to memory; + /// if problem, return -1; load without problem, return 0; + int LoadSettingBinary (std::string fileName); void SaveSettingToFile (Reg registerAddress, unsigned int value, unsigned short ch = 0); /// also save to memory unsigned int ReadSettingFromFile (Reg registerAddress, unsigned short ch = 0); /// read from setting binary diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 1715c0f..2846570 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -19,7 +19,6 @@ #include "FSUDAQ.h" - enum MenuIdentifiers{ M_DIGITIZER_OPEN, @@ -94,7 +93,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { fMenuDigitizers = new TGPopupMenu(gClient->GetRoot()); fMenuDigitizers->AddEntry("&Open Digitizers", M_DIGITIZER_OPEN); - fMenuDigitizers->AddEntry("&Load Settings", M_LOAD_SETTINGS); + fMenuDigitizers->AddEntry("&Load Setting (Offline)", M_LOAD_SETTINGS); fMenuDigitizers->AddEntry("&Trigger Summary", M_TRIGGER_SUMMARY); fMenuDigitizers->AddSeparator(); fMenuDigitizers->AddEntry("Digitizer &Settings", M_BOARD_SETTINGS); @@ -106,6 +105,10 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { fMenuDigitizers->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); fMenuBar->AddPopup("&Digitizers", fMenuDigitizers, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); + fMenuDigitizers->DisableEntry( M_TRIGGER_SUMMARY); + fMenuDigitizers->DisableEntry( M_BOARD_SETTINGS); + fMenuDigitizers->DisableEntry( M_CH_SETTING_PHA); + fMenuDigitizers->DisableEntry( M_CH_SETTING_PSD); fMenuDigitizers->DisableEntry( M_REGISTER_SETTING); fMenuUtility = new TGPopupMenu(gClient->GetRoot()); @@ -404,14 +407,14 @@ void MainWindow::OpenDigitizers(){ printf("------------ %d \n", i); digi[i] = new Digitizer(boardID[i], portID[i], false, false); LogMsg(Form("%2d, Serial number : %3d opened (%s, %s)", i, digi[i]->GetSerialNumber(), - digi[i]->GetDPPTypeString().c_str(), + digi[i]->GetDPPString().c_str(), digi[i]->GetModelName().c_str())); digi[i]->OpenSettingBinary("./setting_" + std::to_string(digi[i]->GetSerialNumber()) + ".bin"); } fMenuDigitizers->DisableEntry( M_DIGITIZER_OPEN); - fMenuDigitizers->EnableEntry( M_LOAD_SETTINGS); + fMenuDigitizers->DisableEntry( M_LOAD_SETTINGS); fMenuDigitizers->EnableEntry( M_TRIGGER_SUMMARY); fMenuDigitizers->EnableEntry( M_REGISTER_SETTING); bOpenDigitizers->SetEnabled(false); @@ -454,19 +457,29 @@ void MainWindow::LoadSettingFromFile(){ printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir); dir = fi.fIniDir; - LogMsg((char *)"This is not implement yet. Should Load and Program all digitizers"); + if( fi.fFilename == NULL) return; + int loadStatus = -1; /// if no digitize open if( digi == NULL ) { - - - + LogMsg((char *)"No Digitizer is connected. Create a dummy digitizer."); + digi = new Digitizer *[1]; + nDigi = 1; + digi[0] = new Digitizer(); + loadStatus = digi[0]->LoadSettingBinary( fi.fFilename ); + boardIDEntry->SetNumber(0, false); }else{ - - + loadStatus = digi[0]->LoadSettingBinary( fi.fFilename ); /// still dummy digitizer } + if( boardSetting != NULL ) boardSetting->CloseWindow(); + if( channelSettingPHA != NULL ) channelSettingPHA->CloseWindow(); + if( channelSettingPSD != NULL ) channelSettingPSD->CloseWindow(); + + HandleMenu(M_BOARD_SETTINGS); + OpenChannelSetting(0); + } void MainWindow::ChangeBoard(){ diff --git a/RegisterAddress.h b/RegisterAddress.h index 8ba04a7..508febd 100644 --- a/RegisterAddress.h +++ b/RegisterAddress.h @@ -43,6 +43,7 @@ class Reg{ uint32_t GetAddress() const {return this->address; } char GetType() const {return this->type;} bool GetGroup() const {return this->group;} + void Print() const ; uint32_t ActualAddress(int ch = -1){ if( address == 0x8180 ) return (ch < 0 ? address : (address + 4*(ch/2))); @@ -63,6 +64,13 @@ class Reg{ bool group; }; +inline void Reg::Print() const{ + printf(" Name: %s\n", name.c_str()); + printf("Address: 0x%04X\n", address); + printf(" Type: %s\n", type == RW::ReadWrite ? "Read/Write" : (type == RW::ReadONLY ? "Read-Only" : "Write-Only") ); + printf(" Group: %s\n", group ? "True" : "False"); +} + inline unsigned short Reg::Index (unsigned short ch){ unsigned short index; if( address == 0x8180){ diff --git a/boardSetting.cpp b/boardSetting.cpp index 7897171..0c82622 100644 --- a/boardSetting.cpp +++ b/boardSetting.cpp @@ -75,6 +75,7 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d TGTextButton * bProgramBoardFromFile = new TGTextButton(hframe1, "Load File"); hframe1->AddFrame(bProgramBoardFromFile, new TGLayoutHints( kLHintsLeft | kLHintsCenterY, 5,5,3,3)); bProgramBoardFromFile->Connect("Clicked()", "BoardSetting", this, "ProgramBoardFromFile()"); + if( nDigi == 1 && digi[0]->IsDummy() ) bProgramBoardFromFile->SetEnabled(false); TGTextButton * bSaveFile = new TGTextButton(hframe1, "Save As"); hframe1->AddFrame(bSaveFile, new TGLayoutHints( kLHintsLeft | kLHintsCenterY, 5,5,3,3)); bSaveFile->Connect("Clicked()", "BoardSetting", this, "SaveSettingFile()"); @@ -735,9 +736,14 @@ void BoardSetting::EnableEdit(){ // When ACQ is running, disable all control } void BoardSetting::ReadStatus(){ - if( digi == NULL ) return; + if( digi == NULL) return; int boardID = boardIDEntry->GetNumber(); + if( digi[boardID]->IsDummy() ) { + txtACQBoardReady->SetText("No Digitizer is opened!"); + txtACQBoardReady->SetTextColor(red); + return; + } /// ACQ Status ///digi[boardID]->PrintRegister(Register::DPP::AcquisitionStatus, "ACQ Status"); @@ -783,7 +789,7 @@ void BoardSetting::ReadStatus(){ ///================ Board Failure Status ///digi[boardID]->PrintRegister(Register::DPP::BoardFailureStatus, "Board Fail"); - temp = digi[boardID]->GetSettingFromMemory(Register::DPP::BoardFailureStatus_R); + temp = digi[boardID]->ReadRegister(Register::DPP::BoardFailureStatus_R); if( ((temp >> 4) & 0x1) == 0 ) { enPLLStatus->SetText( "OK" , false); enPLLStatus->SetTextColor(1); }else{ @@ -1411,15 +1417,20 @@ void BoardSetting::ProgramBoardFromFile(){ txtSettingFile->SetText(fi.fFilename); + int loadStatus = -1; if( digi == NULL ) { + ///digi = new Digitizer *[1]; + ///nDigi = 1; + ///digi[0] = new Digitizer(); + ///loadStatus = digi[0]->LoadSettingBinary( fi.fFilename ); }else{ int boardID = boardIDEntry->GetNumber(); - digi[boardID]->LoadSettingBinary( fi.fFilename ); - - ChangeBoard(); + loadStatus = digi[boardID]->LoadSettingBinary( fi.fFilename ); } + if( loadStatus == 0 ) ChangeBoard(); + } void BoardSetting::SaveSettingFile(){ diff --git a/channelSettingPHA.cpp b/channelSettingPHA.cpp index 9712dc5..5137534 100644 --- a/channelSettingPHA.cpp +++ b/channelSettingPHA.cpp @@ -264,7 +264,7 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi TGLabel * lbTrapScale = new TGLabel(vfDPPCtrl11, "Trap. Scaling [bit] :"); vfDPPCtrl11->AddFrame(lbTrapScale, haha); numTrapScale = new TGNumberEntry(vfDPPCtrl12, 14, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative ); vfDPPCtrl12->AddFrame(numTrapScale); numTrapScale->Resize(width, 20); - numTrapScale->Connect("Changed()", "ChannelSettingPHA", this, "SetDPPAlgorithm1()"); + numTrapScale->Connect("Modified()", "ChannelSettingPHA", this, "SetDPPAlgorithm1()"); TGLabel * lbDecimation = new TGLabel(vfDPPCtrl11, "Decimation :"); vfDPPCtrl11->AddFrame(lbDecimation, haha); cbDecimation = new TGComboBox(vfDPPCtrl12); vfDPPCtrl12->AddFrame(cbDecimation); @@ -545,7 +545,6 @@ void ChannelSettingPHA::ChangeCh(){ cbBaselineOptimize->Select( ( (temp >> 29) & 0x1), false); cbExtra2WordOption->Select( ( (temp >> 8) & 0x7), false); - } void ChannelSettingPHA::SetAllChannels(){ @@ -557,7 +556,7 @@ void ChannelSettingPHA::SetAllChannels(){ short ch = chIDEntry->GetNumber(); ///use memory from this channel and set to all other channal - for( int p = 0; (int) RegisterPHAList.size(); p++){ + for( int p = 0; p < (int) RegisterPHAList.size(); p++){ unsigned short temp = digi[boardID]->GetSettingFromMemory(RegisterPHAList[p], ch); for( int i = 0; i < digi[boardID]->GetNChannel() ; i++){ diff --git a/test.cpp b/test.cpp index ba9eddb..3644e28 100644 --- a/test.cpp +++ b/test.cpp @@ -79,28 +79,31 @@ long get_time(){ int main(int argc, char* argv[]){ - //for( int p = 0; p < (int) RegisterDPPList.size(); p++){ - // printf("0x%04X , %s\n", (uint32_t) RegisterDPPList[p], RegisterDPPList[p].GetNameChar()); - //} + //##################### Demo for loading and change setting without open a digitizer + Digitizer dig; + dig.LoadSettingBinary("setting_323.bin"); - Digitizer * dig = new Digitizer; - dig->SetDPPType (V1730_DPP_PHA_CODE); + //dig.PrintSettingFromMemory(); + ///dig.SaveSettingAsText("haha.txt"); - //dig->OpenSettingBinary("setting_323.bin"); - dig->LoadSettingBinary("setting_323.bin"); - //dig->PrintSettingFromMemory(); - //printf("##############################################################\n"); - //dig->SaveSettingAsText("haha.txt"); + printf("ch2ns = %f \n", dig.GetCh2ns()); - //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(); + ///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(); printf("Buffer Size : %u byte = %.2f MB \n", bSize, bSize/1024./1024.); + + Reg haha = dig.FindRegister(Register::DPP::RecordLength_G); + + haha.Print(); + + + //##################### /* const int nBoard = 2;