From 821c73362b42f66b2ea1cebe6905ab55429f72db Mon Sep 17 00:00:00 2001 From: "carina@hades" Date: Fri, 14 Oct 2022 12:23:16 -0400 Subject: [PATCH] small change --- ClassDigitizer.cpp | 38 +++++++++++++++++++------------------- ClassDigitizer.h | 3 +-- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 653994e..f513bbd 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -380,6 +380,8 @@ void Digitizer::ReadData(){ } +//=========================================================== +//=========================================================== //=========================================================== void Digitizer::WriteRegister(Reg registerAddress, uint32_t value, int ch, bool isSave2MemAndFile){ if( !isConnected ) return; @@ -458,10 +460,6 @@ void Digitizer::ReadAllSettingsFromBoard(){ isSettingFilledinMemeory = true; } -void Digitizer::SetSettingFromMemory(Reg registerAddress, int ch){ - WriteRegister(registerAddress, GetSettingFromMemory(registerAddress, ch), ch, false); -} - void Digitizer::ProgramSettingsToBoard(){ if( !isConnected ) return; /// board setting @@ -590,36 +588,38 @@ void Digitizer::SaveSettingAsText(string fileName){ return; } - Reg * haha = new Reg(); + Reg haha; for( unsigned int i = 0; i < SETTINGSIZE ; i++){ - haha->SetName(""); - uint32_t actualAddress = haha->CalAddress(i); + haha.SetName(""); + uint32_t actualAddress = haha.CalAddress(i); ///printf("%7d--- 0x%04X, 0x%04X\n", i, haha->GetAddress(), haha->ActualAddress()); - - /// board setting for( int p = 0; p < (int) RegisterDPPList.size(); p++){ - if( haha->GetAddress() == (uint32_t) RegisterDPPList[p] ) haha->SetName(RegisterDPPList[p].GetName() ); + if( haha.GetAddress() == (uint32_t) RegisterDPPList[p] ) haha = RegisterDPPList[p]; } - if( DPPType == V1730_DPP_PHA_CODE) { for( int p = 0; p < (int) RegisterPHAList.size(); p++){ - if( haha->GetAddress() == (uint32_t) RegisterPHAList[p] ) haha->SetName(RegisterPHAList[p].GetName() ); + if( haha.GetAddress() == (uint32_t) RegisterPHAList[p] ) haha = RegisterPHAList[p]; } } - if( DPPType == V1730_DPP_PSD_CODE) { for( int p = 0; p < (int) RegisterPSDList.size(); p++){ - if( haha->GetAddress() == (uint32_t) RegisterPSDList[p] ) haha->SetName(RegisterPSDList[p].GetName() ); + if( haha.GetAddress() == (uint32_t) RegisterPSDList[p] ) haha = RegisterPSDList[p]; } } - - if( haha->GetName() != "" ) fprintf( txtFile, "0x%04X %35s 0x%08X %d\n", actualAddress, haha->GetNameChar(), setting[i], setting[i]); - + if( haha.GetName() != "" ) { + std::string typeStr ; + if( haha.GetType() == RW::ReadWrite ) typeStr = "R/W"; + if( haha.GetType() == RW::ReadONLY ) typeStr = "R "; + if( haha.GetType() == RW::WriteONLY ) typeStr = " W"; + fprintf( txtFile, "0x%04X %30s 0x%08X %s %d\n", actualAddress, + haha.GetNameChar(), + setting[i], + typeStr.c_str(), + setting[i]); + } } - - delete haha; } void Digitizer::ErrorMsg(string header){ diff --git a/ClassDigitizer.h b/ClassDigitizer.h index c1ab2e4..ad192bc 100644 --- a/ClassDigitizer.h +++ b/ClassDigitizer.h @@ -114,7 +114,6 @@ class Digitizer{ ///================ Setting /// board <--> memory functions void ReadAllSettingsFromBoard (); - void SetSettingFromMemory (Reg registerAddress, int ch = -1); /// write to digitizer void ProgramSettingsToBoard (); /// simply read settings from memory @@ -124,12 +123,12 @@ class Digitizer{ unsigned int * GetSetting() {return setting;}; /// memory <--> file + void SaveSettingAsText (string fileName); string GetSettingFileName() {return settingFileName;} void OpenSettingBinary (string fileName); /// Open setting file, if file not exist, call CreateAndSaveSetiingFile, if file exit simple set the settignFileName void LoadSettingBinary (string fileName); /// load settign file to memory, if digitizer connected, program digitizer void SaveSettingToFile (Reg registerAddress, unsigned int value, int ch = -1); unsigned int ReadSettingFromFile (Reg registerAddress, int ch = -1); /// read from setting binary - void SaveSettingAsText (string fileName); ///=================== Relic methods ///void SetRecordLength (unsigned int ns, int ch = -1); /// when ch == -1, mean set all channels