From 4d3ced9b483e1380fe021bf6a6686959a9713324 Mon Sep 17 00:00:00 2001 From: "carina@hades" Date: Fri, 7 Oct 2022 16:15:58 -0400 Subject: [PATCH] added save and translate setting File --- ClassData.h | 46 +++++------ ClassDigitizer.cpp | 189 +++++++++++++++++++++++++++++++++++++++++---- ClassDigitizer.h | 6 +- FSUDAQ.cpp | 5 +- RegisterAddress.h | 162 -------------------------------------- boardSetting.cpp | 36 ++++++++- boardSetting.h | 1 + test.cpp | 7 +- triggerSummary.cpp | 1 - 9 files changed, 245 insertions(+), 208 deletions(-) diff --git a/ClassData.h b/ClassData.h index d54486f..aac408e 100644 --- a/ClassData.h +++ b/ClassData.h @@ -47,7 +47,7 @@ class Data{ void AllocateMemory(); - void SetSaveWaveformToMemory(bool OnOff) { this->SaveWaveformToMemory = OnOff; } + void SetSaveWaveToMemory(bool OnOff) { this->SaveWaveToMemory = OnOff; } void ClearData(); void ClearTriggerRate(); @@ -55,15 +55,15 @@ class Data{ void SaveBuffer(const char * fileName); void PrintBuffer(); //Incorrect - void DecodeBuffer(int verbose = 0); - void DecodeBuffer(char * buffer, int verbose = 0); // for outside data + void DecodeBuffer(bool fastDecode, int verbose = 0); + void DecodeBuffer(char * buffer, bool fastDecode, int verbose = 0); // for outside data void PrintStat(); protected: unsigned int nw; - bool SaveWaveformToMemory; + bool SaveWaveToMemory; ///for temperary std::vector tempWaveform1; @@ -73,8 +73,8 @@ class Data{ unsigned int ReadBuffer(unsigned int nWord, int verbose = 0); - int DecodePHADualChannelBlock(unsigned int ChannelMask, int verbose); - int DecodePSDDualChannelBlock(unsigned int ChannelMask, int verbose); + int DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose); + int DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose); unsigned short saveFileIndex; @@ -89,7 +89,7 @@ inline Data::Data(){ for ( int i = 0; i < MaxNChannels; i++) TotNumEvents[i] = 0; ClearData(); ClearTriggerRate(); - SaveWaveformToMemory = true; + SaveWaveToMemory = true; nw = 0; saveFileIndex = 0; } @@ -102,7 +102,7 @@ inline void Data::AllocateMemory(){ delete buffer; //TODO calculate Suitable buffer size - BufferSize = 1* 1024* 1024; /// 10M byte + BufferSize = 10* 1024* 1024; /// 10M byte buffer = (char *) malloc( BufferSize); printf("Allocated %d (%lu) byte for buffer \n", BufferSize, sizeof(buffer)); ///for( int i = 0 ; i < MaxNChannels ; i++ ) Events[i] = (CAEN_DGTZ_DPP_PHA_Event_t *) malloc( BufferSize); @@ -151,7 +151,7 @@ inline unsigned int Data::ReadBuffer(unsigned int nWord, int verbose){ inline void Data::SaveBuffer(const char * fileName){ char saveFileName[100]; - sprintf(saveFileName, "%s_%03u.bin", fileName , saveFileIndex); + sprintf(saveFileName, "%s_%03u.fsu", fileName , saveFileIndex); FILE * haha = fopen(saveFileName, "a+"); fseek(haha, 0L, SEEK_END); @@ -161,7 +161,7 @@ inline void Data::SaveBuffer(const char * fileName){ if( inFileSize > (unsigned int)MaxSaveFileSize ) { /// 2 GB fclose(haha); saveFileIndex ++; - sprintf(saveFileName, "%s_%03u.bin", fileName , saveFileIndex); + sprintf(saveFileName, "%s_%03u.fsu", fileName , saveFileIndex); FILE * haha = fopen(saveFileName, "a+"); } @@ -191,12 +191,12 @@ inline void Data::PrintBuffer(){ } -inline void Data::DecodeBuffer(char * buffer, int verbose){ +inline void Data::DecodeBuffer(char * buffer, bool fastDecode, int verbose){ this->buffer = buffer; - DecodeBuffer(verbose); + DecodeBuffer(fastDecode, verbose); } -inline void Data::DecodeBuffer(int verbose){ +inline void Data::DecodeBuffer(bool fastDecode, int verbose){ /// verbose : 0 = off, 1 = only energy + timestamp, 2 = show header, 3 = wave if( buffer == NULL ) { @@ -232,10 +232,10 @@ inline void Data::DecodeBuffer(int verbose){ if( verbose >= 2 ) printf("---------------------- Dual Channel Block : %d, nw : %d\n", chMask *2, nw); if( DPPType == V1730_DPP_PHA_CODE ) { - if ( DecodePHADualChannelBlock(chMask, verbose) < 0 ) break; + if ( DecodePHADualChannelBlock(chMask, fastDecode, verbose) < 0 ) break; } if( DPPType == V1730_DPP_PSD_CODE ) { - if ( DecodePHADualChannelBlock(chMask, verbose) < 0 ) break; + if ( DecodePHADualChannelBlock(chMask, fastDecode, verbose) < 0 ) break; } } }else{ @@ -255,7 +255,7 @@ inline void Data::DecodeBuffer(int verbose){ } -inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, int verbose){ +inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose){ nw = nw + 1; unsigned int word = ReadBuffer(nw, verbose); @@ -347,7 +347,7 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, int verbose //TODO Skip ///===== read waveform - if( SaveWaveformToMemory ) { + if( SaveWaveToMemory ) { tempWaveform1.clear(); tempWaveform2.clear(); tempDigiWaveform1.clear(); @@ -364,7 +364,7 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, int verbose bool dp0 = (( word >> 14 ) & 0x1 ); unsigned short wave0 = ( word & 0x3FFF); - if( SaveWaveformToMemory){ + if( SaveWaveToMemory){ if( hasDualTrace ){ tempWaveform1.push_back(wave0); tempWaveform2.push_back(wave1); @@ -385,7 +385,7 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, int verbose } } - if( SaveWaveformToMemory ) { + if( SaveWaveToMemory ) { if( hasDualTrace ){ Waveform1[channel][NumEvents[channel]] = tempWaveform1; Waveform2[channel][NumEvents[channel]] = tempWaveform2; @@ -447,7 +447,7 @@ inline int Data::DecodePHADualChannelBlock(unsigned int ChannelMask, int verbose return nw; } -inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, int verbose){ +inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose){ nw = nw + 1; unsigned int word = ReadBuffer(nw, verbose); @@ -537,7 +537,7 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, int verbose if( verbose >= 2 ) printf("ch : %d, timeStamp %u \n", channel, timeStamp0); ///===== read waveform - if( SaveWaveformToMemory ) { + if( SaveWaveToMemory ) { tempWaveform1.clear(); tempWaveform2.clear(); tempDigiWaveform1.clear(); @@ -554,7 +554,7 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, int verbose bool dp1a = (( word >> 14 ) & 0x1 ); unsigned short wavea = ( word & 0x3FFF); - if( SaveWaveformToMemory){ + if( SaveWaveToMemory){ if( hasDualTrace ){ tempWaveform1.push_back(wavea); tempWaveform2.push_back(waveb); @@ -574,7 +574,7 @@ inline int Data::DecodePSDDualChannelBlock(unsigned int ChannelMask, int verbose } } - if( SaveWaveformToMemory ) { + if( SaveWaveToMemory ) { if( hasDualTrace ){ Waveform1[channel][NumEvents[channel]] = tempWaveform1; Waveform2[channel][NumEvents[channel]] = tempWaveform2; diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index c04125c..7345aea 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -73,6 +73,8 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose this->boardID = boardID; this->portID = portID; + + if( boardID < 0 || portID < 0 ) return 0; /// for using the Digitizer Class without open digitizer /***************************************************/ /** Open the digitizer and read board information */ @@ -708,7 +710,11 @@ unsigned short Digitizer::CalSettingIndex(uint32_t registerAddress, int ch){ index = newAddress / 4; }else{ newAddress = registerAddress; - index = (newAddress & 0x0FFF) / 4; + if(registerAddress < 0xF000) { + index = (newAddress & 0x0FFF) / 4; + }else{ + index = ((newAddress & 0x0FFF) + 0x0200 ) / 4; + } } //printf("---------address : 0x%04X = %5d = index : %6.1f (%d)\n", newAddress, newAddress, (newAddress & 0x0FFF) / 4., index); return index; @@ -741,18 +747,7 @@ void Digitizer::SetSettingFromMemory(uint32_t registerAddress, int ch){ void Digitizer::FillAllSettings(){ /// for 1 digitizer, 16 channels, needs 0x10XX to 0x1FXX - /// Board setting is 0x8000 --> 0x0000 - /// Saved date YYYYMMDDHH --> 0x0004 - /// Global Trigger Mask 0x810C --> 0x010C - /// Channel mask 0x8120 --> 0x0120 - /// ROM Board version 0xF030 --> 0x0030 - /// Board Form factor 0xF034 --> 0x0034 - /// Board ID Byte 1 0xF038 --> 0x0038 - /// Board ID Byte 0 0xF03C --> 0x003C - /// Board Serial Num Byte1 0xF080 --> 0x0080 - /// Board Serial Num Byte0 0xF084 --> 0x0084 /// serial number = byte0 << 8 + byte1 - /// ROC fireware version is 0x8124 --> 0x0124 - /// Board Info is 0x8140 --> 0x0140 + /// ------------------------------------- /// for 1 channel is 0x2000 = 8192 byte should be enough for all setting for 1 board @@ -843,7 +838,33 @@ void Digitizer::FillAllSettings(){ FillSetting(Register::DPP::InterruptEventNumber ); /// 0xEF18; /// R/W FillSetting(Register::DPP::MaxAggregatePerBlockTransfer); /// 0xEF1C; /// R/W FillSetting(Register::DPP::Scratch ); /// 0xEF20; /// R/W - + + FillSetting(Register::DPP::ROMChecksum_R ); /// 0xF000; /// R + FillSetting(Register::DPP::ROMChecksumByte2_R ); /// 0xF004; /// R + FillSetting(Register::DPP::ROMChecksumByte1_R ); /// 0xF008; /// R + FillSetting(Register::DPP::ROMChecksumByte0_R ); /// 0xF00C; /// R + FillSetting(Register::DPP::ROMConstantByte2_R ); /// 0xF010; /// R + FillSetting(Register::DPP::ROMConstantByte1_R ); /// 0xF014; /// R + FillSetting(Register::DPP::ROMConstantByte0_R ); /// 0xF018; /// R + FillSetting(Register::DPP::ROM_C_Code_R ); /// 0xF01C; /// R + FillSetting(Register::DPP::ROM_R_Code_R ); /// 0xF020; /// R + FillSetting(Register::DPP::ROM_IEEE_OUI_Byte2_R ); /// 0xF024; /// R + FillSetting(Register::DPP::ROM_IEEE_OUI_Byte1_R ); /// 0xF028; /// R + FillSetting(Register::DPP::ROM_IEEE_OUI_Byte0_R ); /// 0xF02C; /// R + FillSetting(Register::DPP::ROM_BoardVersion_R ); /// 0xF030; /// R + FillSetting(Register::DPP::ROM_BoardFromFactor_R ); /// 0xF034; /// R + FillSetting(Register::DPP::ROM_BoardIDByte1_R ); /// 0xF038; /// R + FillSetting(Register::DPP::ROM_BoardIDByte0_R ); /// 0xF03C; /// R + FillSetting(Register::DPP::ROM_PCB_rev_Byte3_R ); /// 0xF040; /// R + FillSetting(Register::DPP::ROM_PCB_rev_Byte2_R ); /// 0xF044; /// R + FillSetting(Register::DPP::ROM_PCB_rev_Byte1_R ); /// 0xF048; /// R + FillSetting(Register::DPP::ROM_PCB_rev_Byte0_R ); /// 0xF04C; /// R + FillSetting(Register::DPP::ROM_FlashType_R ); /// 0xF050; /// R + FillSetting(Register::DPP::ROM_BoardSerialNumByte1_R ); /// 0xF080; /// R + FillSetting(Register::DPP::ROM_BoardSerialNumByte0_R ); /// 0xF084; /// R + FillSetting(Register::DPP::ROM_VCXO_Type_R ); /// 0xF088; /// R + + isSettingFilledinMemeory = true; } @@ -944,7 +965,7 @@ void Digitizer::LoadSettingBinary(string fileName){ SetSettingFromMemory(Register::DPP::PSD::EarlyBaselineFreeze , ch); /// 0x10D8; /// R/W } } - + SetSettingFromMemory(Register::DPP::BoardConfiguration ); /// 0x8000; /// R/W SetSettingFromMemory(Register::DPP::AggregateOrganization ); /// 0x800C; /// R/W SetSettingFromMemory(Register::DPP::AcquisitionControl ); /// 0x8100; /// R/W @@ -1006,6 +1027,144 @@ void Digitizer::SaveSettingToFile(uint32_t registerAddress, unsigned int value, fclose (settingFile); } +void Digitizer::SaveSettingAsText(string fileName){ + + FILE * txtFile = fopen(fileName.c_str(), "w+"); + + if( txtFile == NULL ) { + printf("Cannot open %s.\n", fileName.c_str()); + return; + } + uint32_t address = 0; /// this is the actual address + uint32_t registerAddress = 0; /// this is the register address from RegisterAddress.h + string name = ""; + for( int i = 0; i < SETTINGSIZE ; i++){ + + name = ""; + registerAddress = i * 4; + + if( i < 0x0200 /4 ) {address = i * 4 + 0x8000; registerAddress = registerAddress; } + if( 0x0200 / 4 <= i && i < 0x0F00 /4 ) {address = i * 4 + 0xEE00; registerAddress = registerAddress; }/// EE00 == F000 - 0200 + if( 0xF000 / 4 <= i && i < 0x1000 /4 ) {address = i * 4 + 0xE000; registerAddress = registerAddress; } + if( 0x1000 / 4 <= i ) { registerAddress = registerAddress & 0xF0FF ; } + + if( DPPType == V1730_DPP_PSD_CODE || DPPType == V1730_DPP_PHA_CODE) { + + switch( registerAddress ){ + case Register::DPP::RecordLength_G : name = "DPP::RecordLength_G "; break; + case Register::DPP::InputDynamicRange : name = "DPP::InputDynamicRange "; break; + case Register::DPP::NumberEventsPerAggregate_G : name = "DPP::NumberEventsPerAggregate_G "; break; + case Register::DPP::PreTrigger : name = "DPP::PreTrigger "; break; + case Register::DPP::TriggerThreshold : name = "DPP::TriggerThreshold "; break; + case Register::DPP::TriggerHoldOffWidth : name = "DPP::TriggerHoldOffWidth "; break; + case Register::DPP::DPPAlgorithmControl : name = "DPP::DPPAlgorithmControl "; break; + case Register::DPP::ChannelStatus_R : name = "DPP::ChannelStatus_R "; break; + case Register::DPP::AMCFirmwareRevision_R : name = "DPP::AMCFirmwareRevision_R "; break; + case Register::DPP::ChannelDCOffset : name = "DPP::ChannelDCOffset "; break; + case Register::DPP::ChannelADCTemperature_R : name = "DPP::ChannelADCTemperature_R "; break; + case Register::DPP::VetoWidth : name = "DPP::VetoWidth "; break; + + case Register::DPP::BoardConfiguration : name = "DPP::BoardConfiguration "; break; + case Register::DPP::AggregateOrganization : name = "DPP::AggregateOrganization "; break; + case Register::DPP::AcquisitionControl : name = "DPP::AcquisitionControl "; break; + case Register::DPP::AcquisitionStatus_R : name = "DPP::AcquisitionStatus_R "; break; + case Register::DPP::GlobalTriggerMask : name = "DPP::GlobalTriggerMask "; break; + case Register::DPP::FrontPanelTRGOUTEnableMask : name = "DPP::FrontPanelTRGOUTEnableMask "; break; + case Register::DPP::LVDSIOData : name = "DPP::LVDSIOData "; break; + case Register::DPP::FrontPanelIOControl : name = "DPP::FrontPanelIOControl "; break; + case Register::DPP::ChannelEnableMask : name = "DPP::ChannelEnableMask "; break; + case Register::DPP::ROCFPGAFirmwareRevision_R : name = "DPP::ROCFPGAFirmwareRevision_R "; break; + case Register::DPP::EventStored_R : name = "DPP::EventStored_R "; break; + case Register::DPP::VoltageLevelModeConfig : name = "DPP::VoltageLevelModeConfig "; break; + case Register::DPP::BoardInfo_R : name = "DPP::BoardInfo_R "; break; + case Register::DPP::AnalogMonitorMode : name = "DPP::AnalogMonitorMode "; break; + case Register::DPP::EventSize_R : name = "DPP::EventSize_R "; break; + case Register::DPP::TimeBombDowncounter_R : name = "DPP::TimeBombDowncounter_R "; break; + case Register::DPP::FanSpeedControl : name = "DPP::FanSpeedControl "; break; + case Register::DPP::RunStartStopDelay : name = "DPP::RunStartStopDelay "; break; + case Register::DPP::BoardFailureStatus_R : name = "DPP::BoardFailureStatus_R "; break; + case Register::DPP::DisableExternalTrigger : name = "DPP::DisableExternalTrigger "; break; + case Register::DPP::TriggerValidationMask_G : name = "DPP::TriggerValidationMask_G "; break; + case Register::DPP::FrontPanelLVDSIONewFeatures : name = "DPP::FrontPanelLVDSIONewFeatures "; break; + case Register::DPP::BufferOccupancyGain : name = "DPP::BufferOccupancyGain "; break; + case Register::DPP::ExtendedVetoDelay : name = "DPP::ExtendedVetoDelay "; break; + case Register::DPP::ReadoutControl : name = "DPP::ReadoutControl "; break; + case Register::DPP::ReadoutStatus_R : name = "DPP::ReadoutStatus_R "; break; + case Register::DPP::BoardID : name = "DPP::BoardID "; break; + case Register::DPP::MCSTBaseAddressAndControl : name = "DPP::MCSTBaseAddressAndControl "; break; + case Register::DPP::RelocationAddress : name = "DPP::RelocationAddress "; break; + case Register::DPP::InterruptStatusID : name = "DPP::InterruptStatusID "; break; + case Register::DPP::InterruptEventNumber : name = "DPP::InterruptEventNumber "; break; + case Register::DPP::MaxAggregatePerBlockTransfer : name = "DPP::MaxAggregatePerBlockTransfer "; break; + case Register::DPP::Scratch : name = "DPP::Scratch "; break; + case Register::DPP::ROMChecksum_R : name = "DPP::ROMChecksum_R "; break; + case Register::DPP::ROMChecksumByte2_R : name = "DPP::ROMChecksumByte2_R "; break; + case Register::DPP::ROMChecksumByte1_R : name = "DPP::ROMChecksumByte1_R "; break; + case Register::DPP::ROMChecksumByte0_R : name = "DPP::ROMChecksumByte0_R "; break; + case Register::DPP::ROMConstantByte2_R : name = "DPP::ROMConstantByte2_R "; break; + case Register::DPP::ROMConstantByte1_R : name = "DPP::ROMConstantByte1_R "; break; + case Register::DPP::ROMConstantByte0_R : name = "DPP::ROMConstantByte0_R "; break; + case Register::DPP::ROM_C_Code_R : name = "DPP::ROM_C_Code_R "; break; + case Register::DPP::ROM_R_Code_R : name = "DPP::ROM_R_Code_R "; break; + case Register::DPP::ROM_IEEE_OUI_Byte2_R : name = "DPP::ROM_IEEE_OUI_Byte2_R "; break; + case Register::DPP::ROM_IEEE_OUI_Byte1_R : name = "DPP::ROM_IEEE_OUI_Byte1_R "; break; + case Register::DPP::ROM_IEEE_OUI_Byte0_R : name = "DPP::ROM_IEEE_OUI_Byte0_R "; break; + case Register::DPP::ROM_BoardVersion_R : name = "DPP::ROM_BoardVersion_R "; break; + case Register::DPP::ROM_BoardFromFactor_R : name = "DPP::ROM_BoardFromFactor_R "; break; + case Register::DPP::ROM_BoardIDByte1_R : name = "DPP::ROM_BoardIDByte1_R "; break; + case Register::DPP::ROM_BoardIDByte0_R : name = "DPP::ROM_BoardIDByte0_R "; break; + case Register::DPP::ROM_PCB_rev_Byte3_R : name = "DPP::ROM_PCB_rev_Byte3_R "; break; + case Register::DPP::ROM_PCB_rev_Byte2_R : name = "DPP::ROM_PCB_rev_Byte2_R "; break; + case Register::DPP::ROM_PCB_rev_Byte1_R : name = "DPP::ROM_PCB_rev_Byte1_R "; break; + case Register::DPP::ROM_PCB_rev_Byte0_R : name = "DPP::ROM_PCB_rev_Byte0_R "; break; + case Register::DPP::ROM_FlashType_R : name = "DPP::ROM_FlashType_R "; break; + case Register::DPP::ROM_BoardSerialNumByte1_R : name = "DPP::ROM_BoardSerialNumByte1_R "; break; + case Register::DPP::ROM_BoardSerialNumByte0_R : name = "DPP::ROM_BoardSerialNumByte0_R "; break; + case Register::DPP::ROM_VCXO_Type_R : name = "DPP::ROM_VCXO_Type_R "; break; + } + } + + if( DPPType == V1730_DPP_PSD_CODE ) { + switch (registerAddress) { + case Register::DPP::PSD::CFDSetting : name = "DPP::PSD::CFDSetting "; break; + case Register::DPP::PSD::ChargeZeroSuppressionThreshold : name = "DPP::PSD::ChargeZeroSuppressionThreshold "; break; + case Register::DPP::PSD::ShortGateWidth : name = "DPP::PSD::ShortGateWidth "; break; + case Register::DPP::PSD::LongGateWidth : name = "DPP::PSD::LongGateWidth "; break; + case Register::DPP::PSD::GateOffset : name = "DPP::PSD::GateOffset "; break; + case Register::DPP::PSD::TriggerThreshold : name = "DPP::PSD::TriggerThreshold "; break; + case Register::DPP::PSD::FixedBaseline : name = "DPP::PSD::FixedBaseline "; break; + case Register::DPP::PSD::TriggerLatency : name = "DPP::PSD::TriggerLatency "; break; + case Register::DPP::PSD::ShapedTriggerWidth : name = "DPP::PSD::ShapedTriggerWidth "; break; + case Register::DPP::PSD::TriggerHoldOffWidth : name = "DPP::PSD::TriggerHoldOffWidth "; break; + case Register::DPP::PSD::ThresholdForPSDCut : name = "DPP::PSD::ThresholdForPSDCut "; break; + case Register::DPP::PSD::PurGapThreshold : name = "DPP::PSD::PurGapThreshold "; break; + case Register::DPP::PSD::DPPAlgorithmControl2_G : name = "DPP::PSD::DPPAlgorithmControl2_G "; break; + case Register::DPP::PSD::EarlyBaselineFreeze : name = "DPP::PSD::EarlyBaselineFreeze "; break; + } + } + + if( DPPType == V1730_DPP_PHA_CODE ) { + switch (registerAddress) { + case Register::DPP::PHA::ChannelStopAcquisition : name = "DPP::PHA::ChannelStopAcquisition "; break; + case Register::DPP::PHA::RCCR2SmoothingFactor : name = "DPP::PHA::RCCR2SmoothingFactor "; break; + case Register::DPP::PHA::InputRiseTime : name = "DPP::PHA::InputRiseTime "; break; + case Register::DPP::PHA::TrapezoidRiseTime : name = "DPP::PHA::TrapezoidRiseTime "; break; + case Register::DPP::PHA::TrapezoidFlatTop : name = "DPP::PHA::TrapezoidFlatTop "; break; + case Register::DPP::PHA::PeakingTime : name = "DPP::PHA::PeakingTime "; break; + case Register::DPP::PHA::DecayTime : name = "DPP::PHA::DecayTime "; break; + case Register::DPP::PHA::TriggerThreshold : name = "DPP::PHA::TriggerThreshold "; break; + case Register::DPP::PHA::RiseTimeValidationWindow : name = "DPP::PHA::RiseTimeValidationWindow "; break; + case Register::DPP::PHA::TriggerHoldOffWidth : name = "DPP::PHA::TriggerHoldOffWidth "; break; + case Register::DPP::PHA::PeakHoldOff : name = "DPP::PHA::PeakHoldOff "; break; + case Register::DPP::PHA::ShapedTriggerWidth : name = "DPP::PHA::ShapedTriggerWidth "; break; + case Register::DPP::PHA::DPPAlgorithmControl2_G : name = "DPP::PHA::DPPAlgorithmControl2_G "; break; + case Register::DPP::PHA::FineGain : name = "DPP::PHA::FineGain "; break; + } + } + + if( name != "" ) fprintf( txtFile, "0x%04X %35s 0x%08X %d\n", address, name.c_str(), setting[i], setting[i]); + } +} diff --git a/ClassDigitizer.h b/ClassDigitizer.h index 745df2f..57dc7bf 100644 --- a/ClassDigitizer.h +++ b/ClassDigitizer.h @@ -127,7 +127,11 @@ class Digitizer{ void CreateAndSaveSettingToFile (string fileName); void SaveSettingToFile (uint32_t registerAddress, unsigned int value, int ch = -1); unsigned int ReadSettingFromFile (uint32_t registerAddress, int ch = -1); /// read from setting binary - + void SaveSettingAsText (string fileName); + ///void TranslateSettingBin2Text (string binFileName, int DPPType, string txtFileName); + + unsigned int * GetSetting() {return setting;}; + string GetSettingFileName() {return settingFileName;} virtual int ProgramBoard(); diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index dcf7342..d37ef3d 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -151,7 +151,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { TGHorizontalFrame *hfg1 = new TGHorizontalFrame(vframe); vframe->AddFrame(hfg1 ,new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0)); TGLabel * lbDataPath = new TGLabel(hfg1, "Save Data Prefix"); hfg1->AddFrame(lbDataPath, uniLayoutHints); - dataPrefix = new TGTextEntry(hfg1, "test"); hfg1->AddFrame(dataPrefix,uniLayoutHints); + dataPrefix = new TGTextEntry(hfg1, "ExpName"); hfg1->AddFrame(dataPrefix,uniLayoutHints); dataPrefix->Resize(100, 20); TGLabel * lbRunNum = new TGLabel(hfg1, "Run"); hfg1->AddFrame(lbRunNum, uniLayoutHints); @@ -699,7 +699,7 @@ void * MainWindow::FillHistogram(void * ptr){ uint32_t ElapsedTime = 0; TString dataFileName = dataPrefix->GetText(); - dataFileName += Form("%03d_run_%03d", (int) digi[boardID]->GetSerialNumber(), (int) runIDEntry->GetNumber()); + dataFileName += Form("_run%03d_%03d", (int) runIDEntry->GetNumber(), (int) digi[boardID]->GetSerialNumber()); printf("|%s|\n", dataFileName.Data()); @@ -773,7 +773,6 @@ void * MainWindow::FillHistogram(void * ptr){ data->ClearData(); PreviousTime = CurrentTime; - } fEcanvas->GetCanvas()->Update(); diff --git a/RegisterAddress.h b/RegisterAddress.h index 29c63fb..3f0df06 100644 --- a/RegisterAddress.h +++ b/RegisterAddress.h @@ -188,166 +188,4 @@ namespace Register { } - -/** -/// This provides an alternative way for control -namespace Setting{ - - enum PHA{ - /// board configuration - AutoDataFlush_board_bool, - DecimateWaveForm_board_bool, - TriggerPropapation_board_bool, - DualTrace_board_bool, - AnalogProbe1_board_2bit, - AnalogProbe2_board_2bit, - WavefromRecording_board_bool, - EnableExtra2Word_board_bool, - EnergyRecording_board_bool, - VirtualProbe_board_4bit, - - /// DPP Algorithm Control 1 - TrapazoidRescaling_5bit, - WaveformDecimation_2bit, - WaveformDecimationGain_2bit, - PeakSampling_2bit, - PulsePolarity_bool, - TriggerMode_2bit, - BaselineSampling_3bit, - DisableSelfTrigger_bool, - RolloverFlag_bool, - PileupFlag_bool, - - /// DPP Algorithm Control 2 - LocalShapedTrigger_bool, - LocalShapedTriggerMode_2bit, - LocalTriggerValidation_bool, - LocalTriggerValidationMode_2bit, - Extra2WordOption_3bit, - VetoSource_2bit, - TriggerCounterRateStep_2bit, - BaselineCalculationWhenACQOFF_bool, - TagCorrelatedEvents_bool, - BaselineRestoreOptimization_bool, - - /// ACQ control - StartStopMode_2bit, - StartStopACQ_bool, - PLLClockSource_bool, - VetoInForTRGOUT_bool, - - /// Global Trigger Mask - GlobalTrgMask_8bit, - GlobalTrgMajorityCoincienceWindow_4bit, - GlobalTrgMajorityLevel_3bit, - GlobalTrgExternalTrigger_bool, - GlobalTrgSoftwareTrigger_bool, - - /// Front Panel TRG-OUT Mask - FrontTRGOUTMask_8bit, - FrontTRGOUTLogic_2bit, - FrontTRGOUTMajorityLevel_3bit, - FrontTRGOUTExternalTrigger_bool, - FrontTRGOUTSoftwareTrigger_bool, - - /// Front Plane I/O - FrontPanelIO_LEMO_bool, - FrontPanelIO_TRGOUT_bool, - FrontPanelIO_TRGINCtrl_bool, - FrontPanelIO_TRGINtoMezzanines_bool, - FrontPanelIO_TRGOUTmode_6bit, - - /// Trigger Validation Mask - TriggerValidationMask_8bit, - TriggerValidationOperation_2bit, - TriggerValidationMajority_3bit, - TriggerValidationExternalTrigger_bool, - TriggerValidationSoftwareTrigger_bool, - - /// Readout Control - ReadoutCtrl_VMEInterruptLevel_3bit, - ReadoutCtrl_OpticalLinkInterrupt_bool, - ReadoutCtrl_VMEBusError_bool, - ReadoutCtrl_VMEAlign64_bool, - - /// Registers for channel - RecordLength_G_ns, - PreTriggerLength_ns, - InputDynamicRange_bool, - DCOffset_precentage, - VetoWidth_ns, - EventPreAggregate_G_max1023, - AggregateOrganization_board_3bit, - MaxAggregatePerBlockTransfer_board_10bit, - - TriggerThreshold_LSD, - TriggerHoldOffWidth_ns, - TriggerSmoothingFactor_5bit, /// RC-CR2 Smoothing Factor - TriggerOutputWidth_ns, /// Shaped Trigger Width - InputRiseTime_ns, - - TrapezoidRiseTime_ns, - TrapezoidFlatTop_ns, - DecayTime_ns, - PeakingTime_ns, - PeakingHoldOff_ns, - EnergyFineGain_16bit, - RiseTimeValidationWindow_ns, - - ADCTemperature_8bit, - - /// Others - FanSpeedControl_bool, - RunStartStopDelay_8bit, - DisableExternalTrigger_bool, - ExtendedVetoDelay_16bit, - AnalogMonitorMode_3bit, - BufferOccupancyGain_4bit, - - ///==========read only - - /// AMC Firmware Revisiion - AMCFirmwareNumber_readOnly_8bit, - AMCDPPcode_readOnly_8bit, - AMCBuildDay_readOnly_8bit, - AMCBuildMonth_readOnly_4bits, - AMCBuildYear_readOnly_4bits, - - /// ACQ Status - ACQStatus_readOnly_bool, - ACQEventReady_readOnly_bool, - ACQEventFull_readOnly_bool, - ACQClockSource_readOnly_bool, - ACQPLLLock_readOnly_bool, - ACQBoardReady_readOnly_bool, - ACQ_S_IN_Statue_readOnly_bool, - ACQ_TRGIN_Status_readOnly_bool, - ACQChannelShutDownStatus_readOnly_bool, - ACQTenmperatureStatus_readOnly_4bit, - - - ///========== not impletementd - DataFlush_writeOnly_any, /// any bit write, write only - ChannelStopAcq_bool, - ChannelSoftwareTrigger_writeOnly_any, - - FineGain_16bit, /// this is complicated value - - ADCCalibration_32bit, - - ChannelsShutdown_bool, - - SoftwareTrigger_writeOnly_any, - - ChannelEnableMask_16bit, - - /// ChannelStatus - ChannelStatus_SPI_bool, - ChannelStatus_ADCCalib_bool, - ChannelStatus_ADCPowerDown_bool - - }; - -}*/ - #endif diff --git a/boardSetting.cpp b/boardSetting.cpp index b3bcf71..18aac7d 100644 --- a/boardSetting.cpp +++ b/boardSetting.cpp @@ -73,9 +73,12 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d {///=========== Setting file TGHorizontalFrame *hframe1 = new TGHorizontalFrame(vframe); vframe->AddFrame(hframe1, new TGLayoutHints(kLHintsLeft, 5, 5, 0, 0)); - TGTextButton * bProgramBoardFromFile = new TGTextButton(hframe1, "Open File"); hframe1->AddFrame(bProgramBoardFromFile, new TGLayoutHints( kLHintsLeft | kLHintsCenterY, 5,5,3,3)); + TGTextButton * bProgramBoardFromFile = new TGTextButton(hframe1, "Load File"); hframe1->AddFrame(bProgramBoardFromFile, new TGLayoutHints( kLHintsLeft | kLHintsCenterY, 5,5,3,3)); bProgramBoardFromFile->Connect("Clicked()", "BoardSetting", this, "ProgramBoardFromFile()"); + TGTextButton * bSaveFile = new TGTextButton(hframe1, "Save As"); hframe1->AddFrame(bSaveFile, new TGLayoutHints( kLHintsLeft | kLHintsCenterY, 5,5,3,3)); + bSaveFile->Connect("Clicked()", "BoardSetting", this, "SaveSettingFile()"); + TGLabel * lbSettingFile = new TGLabel(hframe1, "Setting file :"); hframe1->AddFrame(lbSettingFile, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,4,2)); txtSettingFile = new TGTextEntry(hframe1, ""); hframe1->AddFrame(txtSettingFile, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3)); txtSettingFile->SetEnabled(false); @@ -1401,6 +1404,8 @@ void BoardSetting::ProgramBoardFromFile(){ printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir); dir = fi.fIniDir; + if( fi.fFilename == NULL) return; + txtSettingFile->SetText(fi.fFilename); if( digi == NULL ) { @@ -1413,3 +1418,32 @@ void BoardSetting::ProgramBoardFromFile(){ } } + +void BoardSetting::SaveSettingFile(){ + + const char *filetypes[] = { "Setting File", "*.bin", + 0, 0}; + + static TString dir("."); + TGFileInfo fi; + fi.fFileTypes = filetypes; + fi.SetIniDir(dir); + printf("fIniDir = %s\n", fi.fIniDir); + new TGFileDialog(gClient->GetRoot(), fMain, kFDSave, &fi); + printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir); + dir = fi.fIniDir; + + if( fi.fFilename == NULL) return; + + txtSettingFile->SetText(fi.fFilename); + + if( digi == NULL ) { + + }else{ + + int boardID = boardIDEntry->GetNumber(); + digi[boardID]->CreateAndSaveSettingToFile( fi.fFilename ); + + } + +} diff --git a/boardSetting.h b/boardSetting.h index a50a834..5a28ee2 100644 --- a/boardSetting.h +++ b/boardSetting.h @@ -178,5 +178,6 @@ class BoardSetting{ void ReadData(); void ProgramDefaultBoard(); void ProgramBoardFromFile(); + void SaveSettingFile(); }; #endif diff --git a/test.cpp b/test.cpp index 68626db..bf8740a 100644 --- a/test.cpp +++ b/test.cpp @@ -88,11 +88,11 @@ int main(int argc, char* argv[]){ int board = i % 3; int port = i/3; dig[i] = new Digitizer(board, port, false, true); - //dig[i]->CreateAndSaveSettingBinary("setting_" + to_string(dig[i]->GetSerialNumber()) + ".bin"); + dig[i]->CreateAndSaveSettingToFile("setting_" + to_string(dig[i]->GetSerialNumber()) + ".bin"); //dig[i]->OpenSettingBinary("setting_" + to_string(dig[i]->GetSerialNumber()) + ".bin"); } - dig[0]->LoadSettingBinary("setting_" + to_string(dig[0]->GetSerialNumber()) + ".bin"); + //dig[0]->LoadSettingBinary("setting_" + to_string(dig[0]->GetSerialNumber()) + ".bin"); //dig[0]->Reset(); //dig[0]->ProgramPHABoard(); @@ -140,6 +140,9 @@ int main(int argc, char* argv[]){ //dig[0]->ReadSettingFromFile(Register::DPP::Scratch); //dig[0]->PrintSettingFromMemory(); + + dig[0]->SaveSettingAsText("haha.txt"); + printf("============================== other dig\n"); dig[1]->LoadSettingBinary("setting_323.bin"); diff --git a/triggerSummary.cpp b/triggerSummary.cpp index 4965ceb..34ac91e 100644 --- a/triggerSummary.cpp +++ b/triggerSummary.cpp @@ -115,7 +115,6 @@ TriggerSummary::~TriggerSummary(){ delete numUpdateTime; updateFlag = false; - //usleep(500 * 1000); ///delete thread; /// Don;t delete the thread, otherwise, thread will not run after close and reopen.