2022-10-04 16:54:01 -04:00
# include <TApplication.h>
# include <TGClient.h>
# include <TCanvas.h>
# include <TF1.h>
# include <TRandom.h>
# include <TRootEmbeddedCanvas.h>
# include <TGTableContainer.h>
# include <TGFileDialog.h>
# include "registerSetting.h"
RegisterSetting : : RegisterSetting ( const TGWindow * p , UInt_t w , UInt_t h , Digitizer * * digi , int nBoard , uint32_t address ) {
this - > nDigi = nBoard ;
this - > digi = digi ;
for ( int i = 0 ; i < MaxNChannels ; i + + ) value [ i ] = 0 ;
fMain = new TGMainFrame ( p , w , h ) ;
fMain - > SetWindowName ( " Register Setting " ) ;
fMain - > Connect ( " CloseWindow() " , " RegisterSetting " , this , " CloseWindow() " ) ;
TGLayoutHints * layoutHints = new TGLayoutHints ( kLHintsCenterX | kLHintsCenterY , 5 , 5 , 3 , 3 ) ; /// left, right, top, bottom
TGLayoutHints * haha = new TGLayoutHints ( kLHintsRight , 5 , 5 , 3 , 3 ) ; /// left, right, top, bottom
TGLayoutHints * kaka = new TGLayoutHints ( kLHintsLeft , 0 , 0 , 0 , 0 ) ; /// left, right, top, bottom
TGVerticalFrame * vframe = new TGVerticalFrame ( fMain ) ; fMain - > AddFrame ( vframe , layoutHints ) ;
int boardID ;
{ ///==================== Board ID & Register Name
TGHorizontalFrame * hframe1 = new TGHorizontalFrame ( vframe , w , 50 ) ; vframe - > AddFrame ( hframe1 , layoutHints ) ;
TGVerticalFrame * vframeA0 = new TGVerticalFrame ( hframe1 ) ; hframe1 - > AddFrame ( vframeA0 , layoutHints ) ;
TGVerticalFrame * vframeA1 = new TGVerticalFrame ( hframe1 ) ; hframe1 - > AddFrame ( vframeA1 , layoutHints ) ;
TGLabel * lb0 = new TGLabel ( vframeA0 , " Board ID : " ) ; vframeA0 - > AddFrame ( lb0 , haha ) ;
TGHorizontalFrame * hframe11 = new TGHorizontalFrame ( vframeA1 , w , 50 ) ; vframeA1 - > AddFrame ( hframe11 ) ;
boardIDEntry = new TGNumberEntry ( hframe11 , 0 , 0 , 0 , TGNumberFormat : : kNESInteger , TGNumberFormat : : kNEANonNegative ) ; hframe11 - > AddFrame ( boardIDEntry , kaka ) ;
boardIDEntry - > SetWidth ( 50 ) ;
boardIDEntry - > SetLimits ( TGNumberFormat : : kNELLimitMinMax , 0 , nBoard - 1 ) ;
boardIDEntry - > Connect ( " Modified() " , " RegisterSetting " , this , " ChangeBoard() " ) ;
if ( nBoard < = 1 ) boardIDEntry - > SetState ( false ) ;
boardID = boardIDEntry - > GetNumber ( ) ;
TGLabel * lb1 = new TGLabel ( hframe11 , Form ( " Serial Number : %03d " , digi = = NULL ? - 1 : digi [ boardID ] - > GetSerialNumber ( ) ) ) ; hframe11 - > AddFrame ( lb1 , new TGLayoutHints ( kLHintsCenterY , 5 , 5 , 3 , 3 ) ) ;
TGLabel * lbAdd = new TGLabel ( vframeA0 , " Address : " ) ; vframeA0 - > AddFrame ( lbAdd , haha ) ;
txtAddress = new TGTextEntry ( vframeA1 , Form ( " 0x%04x " , address ) ) ; vframeA1 - > AddFrame ( txtAddress , kaka ) ;
txtAddress - > Connect ( " ReturnPressed() " , " RegisterSetting " , this , " TypeRegisterAddress() " ) ;
txtAddress - > Resize ( 250 , 20 ) ;
TGLabel * lbName = new TGLabel ( vframeA0 , " Name : " ) ; vframeA0 - > AddFrame ( lbName , haha ) ;
cbName = new TGComboBox ( vframeA1 , " " ) ; vframeA1 - > AddFrame ( cbName , kaka ) ;
cbName - > Connect ( " Changed() " , " RegisterSetting " , this , " UpdateRegister() " ) ;
cbName - > Resize ( 250 , 20 ) ;
cbName - > EnableTextInput ( false ) ;
}
{ ///==================== Controls
TGHorizontalFrame * hframeAll = new TGHorizontalFrame ( vframe , w , 50 ) ; vframe - > AddFrame ( hframeAll , layoutHints ) ;
bSetALLChannel = new TGCheckButton ( hframeAll , " Set ALL Channels " , 1 ) ; hframeAll - > AddFrame ( bSetALLChannel , haha ) ;
bSetALLChannel - > Connect ( " Clicked() " , " RegisterSetting " , this , " SetAllChannels() " ) ;
TGTextButton * bReadSetting = new TGTextButton ( hframeAll , " Read Settings " ) ; hframeAll - > AddFrame ( bReadSetting , kaka ) ;
bReadSetting - > Connect ( " Clicked() " , " RegisterSetting " , this , " UpdateRegister() " ) ;
}
{ ///==================== values
TGHorizontalFrame * hframe = new TGHorizontalFrame ( vframe , w , 50 ) ; vframe - > AddFrame ( hframe , layoutHints ) ;
TGVerticalFrame * vframe0 = new TGVerticalFrame ( hframe ) ; hframe - > AddFrame ( vframe0 , layoutHints ) ;
TGVerticalFrame * vframe1 = new TGVerticalFrame ( hframe ) ; hframe - > AddFrame ( vframe1 , layoutHints ) ;
TGVerticalFrame * vframe2 = new TGVerticalFrame ( hframe ) ; hframe - > AddFrame ( vframe2 , layoutHints ) ;
TGVerticalFrame * vframe3 = new TGVerticalFrame ( hframe ) ; hframe - > AddFrame ( vframe3 , layoutHints ) ;
TGLabel * lbCh0 = new TGLabel ( vframe0 , " ch " ) ; vframe0 - > AddFrame ( lbCh0 , layoutHints ) ;
TGLabel * lbValueHex = new TGLabel ( vframe1 , " Bit Value [Hex] " ) ; vframe1 - > AddFrame ( lbValueHex , kaka ) ;
TGLabel * lbValueDec = new TGLabel ( vframe2 , " Bit Value [Dec] " ) ; vframe2 - > AddFrame ( lbValueDec , kaka ) ;
lbValueUnit = new TGLabel ( vframe3 , " Value [unit] " ) ; vframe3 - > AddFrame ( lbValueUnit , kaka ) ;
TGLabel * lbCh [ MaxNChannels ] ;
2022-10-05 14:28:55 -04:00
for ( int i = 0 ; i < ( digi = = NULL ? MaxNChannels : digi [ boardID ] - > GetNChannel ( ) ) ; i + + ) {
2022-10-04 16:54:01 -04:00
lbCh [ i ] = new TGLabel ( vframe0 , Form ( " %02d " , i ) ) ; vframe0 - > AddFrame ( lbCh [ i ] , new TGLayoutHints ( kLHintsRight , 5 , 5 , 3 , 2 ) ) ;
txtValueHex [ i ] = new TGTextEntry ( vframe1 , " " ) ; vframe1 - > AddFrame ( txtValueHex [ i ] , kaka ) ;
txtValueHex [ i ] - > Resize ( 100 , 20 ) ;
txtValueHex [ i ] - > SetAlignment ( kTextRight ) ;
txtValueHex [ i ] - > SetName ( Form ( " h%02d " , i ) ) ;
txtValueHex [ i ] - > Connect ( " ReturnPressed() " , " RegisterSetting " , this , " ChangeValue() " ) ;
txtValueDec [ i ] = new TGTextEntry ( vframe2 , " " ) ; vframe2 - > AddFrame ( txtValueDec [ i ] , kaka ) ;
txtValueDec [ i ] - > Resize ( 80 , 20 ) ;
txtValueDec [ i ] - > SetAlignment ( kTextRight ) ;
txtValueDec [ i ] - > SetName ( Form ( " d%02d " , i ) ) ;
txtValueDec [ i ] - > Connect ( " ReturnPressed() " , " RegisterSetting " , this , " ChangeValue() " ) ;
txtValueUnit [ i ] = new TGTextEntry ( vframe3 , " " ) ; vframe3 - > AddFrame ( txtValueUnit [ i ] , kaka ) ;
txtValueUnit [ i ] - > Resize ( 80 , 20 ) ;
txtValueUnit [ i ] - > SetAlignment ( kTextRight ) ;
txtValueUnit [ i ] - > SetName ( Form ( " u%02d " , i ) ) ;
txtValueUnit [ i ] - > Connect ( " ReturnPressed() " , " RegisterSetting " , this , " ChangeValue() " ) ;
txtValueUnit [ i ] - > SetEnabled ( false ) ;
}
}
fMain - > MapSubwindows ( ) ;
fMain - > Resize ( fMain - > GetDefaultSize ( ) ) ;
fMain - > MapWindow ( ) ;
ChangeBoard ( ) ;
}
RegisterSetting : : ~ RegisterSetting ( ) {
printf ( " === %s \n " , __func__ ) ;
delete boardIDEntry ;
delete txtAddress ;
delete cbName ;
delete lbValueUnit ;
for ( int i = 0 ; i < MaxNChannels ; i + + ) {
delete txtValueHex [ i ] ;
delete txtValueDec [ i ] ;
delete txtValueUnit [ i ] ;
}
fMain - > Cleanup ( ) ;
delete fMain ;
}
void RegisterSetting : : ChangeBoard ( ) {
2022-10-05 14:28:55 -04:00
int DPPType = V1730_DPP_PHA_CODE ;
2022-10-04 16:54:01 -04:00
2022-10-05 14:28:55 -04:00
if ( digi ! = NULL ) {
int boardID = boardIDEntry - > GetNumber ( ) ;
DPPType = digi [ boardID ] - > GetDPPType ( ) ;
}
2022-10-04 16:54:01 -04:00
cbName - > RemoveAll ( ) ;
cbName - > AddEntry ( " Address NOT Exist " , 0 ) ;
2022-10-05 14:28:55 -04:00
if ( DPPType = = V1730_DPP_PHA_CODE ) { /// PHA
2022-10-04 16:54:01 -04:00
cbName - > AddEntry ( " DPP::PHA::DataFlush_W " , Register : : DPP : : PHA : : DataFlush_W ) ;
cbName - > AddEntry ( " DPP::PHA::ChannelStopAcquisition " , Register : : DPP : : PHA : : ChannelStopAcquisition ) ;
cbName - > AddEntry ( " DPP::PHA::RCCR2SmoothingFactor " , Register : : DPP : : PHA : : RCCR2SmoothingFactor ) ;
cbName - > AddEntry ( " DPP::PHA::InputRiseTime " , Register : : DPP : : PHA : : InputRiseTime ) ;
cbName - > AddEntry ( " DPP::PHA::TrapezoidRiseTime " , Register : : DPP : : PHA : : TrapezoidRiseTime ) ;
cbName - > AddEntry ( " DPP::PHA::TrapezoidFlatTop " , Register : : DPP : : PHA : : TrapezoidFlatTop ) ;
cbName - > AddEntry ( " DPP::PHA::PeakingTime " , Register : : DPP : : PHA : : PeakingTime ) ;
cbName - > AddEntry ( " DPP::PHA::DecayTime " , Register : : DPP : : PHA : : DecayTime ) ;
cbName - > AddEntry ( " DPP::PHA::TriggerThreshold " , Register : : DPP : : PHA : : TriggerThreshold ) ;
cbName - > AddEntry ( " DPP::PHA::RiseTimeValidationWindow " , Register : : DPP : : PHA : : RiseTimeValidationWindow ) ;
cbName - > AddEntry ( " DPP::PHA::TriggerHoldOffWidth " , Register : : DPP : : PHA : : TriggerHoldOffWidth ) ;
cbName - > AddEntry ( " DPP::PHA::PeakHoldOff " , Register : : DPP : : PHA : : PeakHoldOff ) ;
cbName - > AddEntry ( " DPP::PHA::ShapedTriggerWidth " , Register : : DPP : : PHA : : ShapedTriggerWidth ) ;
cbName - > AddEntry ( " DPP::PHA::DPPAlgorithmControl2_G " , Register : : DPP : : PHA : : DPPAlgorithmControl2_G ) ;
cbName - > AddEntry ( " DPP::PHA::FineGain " , Register : : DPP : : PHA : : FineGain ) ;
}
2022-10-05 14:28:55 -04:00
if ( DPPType = = V1730_DPP_PSD_CODE ) { /// PSD
2022-10-04 16:54:01 -04:00
cbName - > AddEntry ( " DPP::PSD::CFDSetting " , Register : : DPP : : PSD : : CFDSetting ) ;
cbName - > AddEntry ( " DPP::PSD::ForcedDataFlush_W " , Register : : DPP : : PSD : : ForcedDataFlush_W ) ;
cbName - > AddEntry ( " DPP::PSD::ChargeZeroSuppressionThreshold " , Register : : DPP : : PSD : : ChargeZeroSuppressionThreshold ) ;
cbName - > AddEntry ( " DPP::PSD::ShortGateWidth " , Register : : DPP : : PSD : : ShortGateWidth ) ;
cbName - > AddEntry ( " DPP::PSD::LongGateWidth " , Register : : DPP : : PSD : : LongGateWidth ) ;
cbName - > AddEntry ( " DPP::PSD::GateOffset " , Register : : DPP : : PSD : : GateOffset ) ;
cbName - > AddEntry ( " DPP::PSD::TriggerThreshold " , Register : : DPP : : PSD : : TriggerThreshold ) ;
cbName - > AddEntry ( " DPP::PSD::FixedBaseline " , Register : : DPP : : PSD : : FixedBaseline ) ;
cbName - > AddEntry ( " DPP::PSD::TriggerLatency " , Register : : DPP : : PSD : : TriggerLatency ) ;
cbName - > AddEntry ( " DPP::PSD::ShapedTriggerWidth " , Register : : DPP : : PSD : : ShapedTriggerWidth ) ;
cbName - > AddEntry ( " DPP::PSD::TriggerHoldOffWidth " , Register : : DPP : : PSD : : TriggerHoldOffWidth ) ;
cbName - > AddEntry ( " DPP::PSD::ThresholdForPSDCut " , Register : : DPP : : PSD : : ThresholdForPSDCut ) ;
cbName - > AddEntry ( " DPP::PSD::PurGapThreshold " , Register : : DPP : : PSD : : PurGapThreshold ) ;
cbName - > AddEntry ( " DPP::PSD::DPPAlgorithmControl2_G " , Register : : DPP : : PSD : : DPPAlgorithmControl2_G ) ;
cbName - > AddEntry ( " DPP::PSD::EarlyBaselineFreeze " , Register : : DPP : : PSD : : EarlyBaselineFreeze ) ;
}
2022-10-05 14:28:55 -04:00
if ( DPPType = = V1730_DPP_PSD_CODE | | DPPType = = V1730_DPP_PHA_CODE ) {
2022-10-04 16:54:01 -04:00
cbName - > AddEntry ( " DPP::RecordLength_G " , Register : : DPP : : RecordLength_G ) ;
cbName - > AddEntry ( " DPP::InputDynamicRange " , Register : : DPP : : InputDynamicRange ) ;
cbName - > AddEntry ( " DPP::NumberEventsPerAggregate_G " , Register : : DPP : : NumberEventsPerAggregate_G ) ;
cbName - > AddEntry ( " DPP::PreTrigger " , Register : : DPP : : PreTrigger ) ;
cbName - > AddEntry ( " DPP::TriggerThreshold " , Register : : DPP : : TriggerThreshold ) ;
cbName - > AddEntry ( " DPP::TriggerHoldOffWidth " , Register : : DPP : : TriggerHoldOffWidth ) ;
cbName - > AddEntry ( " DPP::DPPAlgorithmControl " , Register : : DPP : : DPPAlgorithmControl ) ;
cbName - > AddEntry ( " DPP::ChannelStatus_R " , Register : : DPP : : ChannelStatus_R ) ;
cbName - > AddEntry ( " DPP::AMCFirmwareRevision_R " , Register : : DPP : : AMCFirmwareRevision_R ) ;
cbName - > AddEntry ( " DPP::ChannelDCOffset " , Register : : DPP : : ChannelDCOffset ) ;
cbName - > AddEntry ( " DPP::ChannelADCTemperature_R " , Register : : DPP : : ChannelADCTemperature_R ) ;
cbName - > AddEntry ( " DPP::IndividualSoftwareTrigger_W " , Register : : DPP : : IndividualSoftwareTrigger_W ) ;
cbName - > AddEntry ( " DPP::VetoWidth " , Register : : DPP : : VetoWidth ) ;
cbName - > AddEntry ( " DPP::BoardConfiguration " , Register : : DPP : : BoardConfiguration ) ;
cbName - > AddEntry ( " DPP::AggregateOrganization " , Register : : DPP : : AggregateOrganization ) ;
cbName - > AddEntry ( " DPP::ADCCalibration_W " , Register : : DPP : : ADCCalibration_W ) ;
cbName - > AddEntry ( " DPP::ChannelShutdown_W " , Register : : DPP : : ChannelShutdown_W ) ;
cbName - > AddEntry ( " DPP::AcquisitionControl " , Register : : DPP : : AcquisitionControl ) ;
cbName - > AddEntry ( " DPP::AcquisitionStatus_R " , Register : : DPP : : AcquisitionStatus_R ) ;
cbName - > AddEntry ( " DPP::SoftwareTrigger_W " , Register : : DPP : : SoftwareTrigger_W ) ;
cbName - > AddEntry ( " DPP::GlobalTriggerMask " , Register : : DPP : : GlobalTriggerMask ) ;
cbName - > AddEntry ( " DPP::FrontPanelTRGOUTEnableMask " , Register : : DPP : : FrontPanelTRGOUTEnableMask ) ;
cbName - > AddEntry ( " DPP::LVDSIOData " , Register : : DPP : : LVDSIOData ) ;
cbName - > AddEntry ( " DPP::FrontPanelIOControl " , Register : : DPP : : FrontPanelIOControl ) ;
cbName - > AddEntry ( " DPP::ChannelEnableMask " , Register : : DPP : : ChannelEnableMask ) ;
cbName - > AddEntry ( " DPP::ROCFPGAFirmwareRevision_R " , Register : : DPP : : ROCFPGAFirmwareRevision_R ) ;
cbName - > AddEntry ( " DPP::EventStored_R " , Register : : DPP : : EventStored_R ) ;
cbName - > AddEntry ( " DPP::VoltageLevelModeConfig " , Register : : DPP : : VoltageLevelModeConfig ) ;
cbName - > AddEntry ( " DPP::SoftwareClockSync_W " , Register : : DPP : : SoftwareClockSync_W ) ;
cbName - > AddEntry ( " DPP::BoardInfo_R " , Register : : DPP : : BoardInfo_R ) ;
cbName - > AddEntry ( " DPP::AnalogMonitorMode " , Register : : DPP : : AnalogMonitorMode ) ;
cbName - > AddEntry ( " DPP::EventSize_R " , Register : : DPP : : EventSize_R ) ;
cbName - > AddEntry ( " DPP::TimeBombDowncounter_R " , Register : : DPP : : TimeBombDowncounter_R ) ;
cbName - > AddEntry ( " DPP::FanSpeedControl " , Register : : DPP : : FanSpeedControl ) ;
cbName - > AddEntry ( " DPP::RunStartStopDelay " , Register : : DPP : : RunStartStopDelay ) ;
cbName - > AddEntry ( " DPP::BoardFailureStatus_R " , Register : : DPP : : BoardFailureStatus_R ) ;
cbName - > AddEntry ( " DPP::DisableExternalTrigger " , Register : : DPP : : DisableExternalTrigger ) ;
cbName - > AddEntry ( " DPP::TriggerValidationMask_G " , Register : : DPP : : TriggerValidationMask_G ) ;
cbName - > AddEntry ( " DPP::FrontPanelLVDSIONewFeatures " , Register : : DPP : : FrontPanelLVDSIONewFeatures ) ;
cbName - > AddEntry ( " DPP::BufferOccupancyGain " , Register : : DPP : : BufferOccupancyGain ) ;
cbName - > AddEntry ( " DPP::ExtendedVetoDelay " , Register : : DPP : : ExtendedVetoDelay ) ;
cbName - > AddEntry ( " DPP::ReadoutControl " , Register : : DPP : : ReadoutControl ) ;
cbName - > AddEntry ( " DPP::ReadoutStatus_R " , Register : : DPP : : ReadoutStatus_R ) ;
cbName - > AddEntry ( " DPP::BoardID " , Register : : DPP : : BoardID ) ;
cbName - > AddEntry ( " DPP::MCSTBaseAddressAndControl " , Register : : DPP : : MCSTBaseAddressAndControl ) ;
cbName - > AddEntry ( " DPP::RelocationAddress " , Register : : DPP : : RelocationAddress ) ;
cbName - > AddEntry ( " DPP::InterruptStatusID " , Register : : DPP : : InterruptStatusID ) ;
cbName - > AddEntry ( " DPP::InterruptEventNumber " , Register : : DPP : : InterruptEventNumber ) ;
cbName - > AddEntry ( " DPP::MaxAggregatePerBlockTransfer " , Register : : DPP : : MaxAggregatePerBlockTransfer ) ;
cbName - > AddEntry ( " DPP::Scratch " , Register : : DPP : : Scratch ) ;
cbName - > AddEntry ( " DPP::SoftwareReset_W " , Register : : DPP : : SoftwareReset_W ) ;
cbName - > AddEntry ( " DPP::SoftwareClear_W " , Register : : DPP : : SoftwareClear_W ) ;
cbName - > AddEntry ( " DPP::ConfigurationReload_W " , Register : : DPP : : ConfigurationReload_W ) ;
cbName - > AddEntry ( " DPP::ROMChecksum_R " , Register : : DPP : : ROMChecksum_R ) ;
cbName - > AddEntry ( " DPP::ROMChecksumByte2_R " , Register : : DPP : : ROMChecksumByte2_R ) ;
cbName - > AddEntry ( " DPP::ROMChecksumByte1_R " , Register : : DPP : : ROMChecksumByte1_R ) ;
cbName - > AddEntry ( " DPP::ROMChecksumByte0_R " , Register : : DPP : : ROMChecksumByte0_R ) ;
cbName - > AddEntry ( " DPP::ROMConstantByte2_R " , Register : : DPP : : ROMConstantByte2_R ) ;
cbName - > AddEntry ( " DPP::ROMConstantByte1_R " , Register : : DPP : : ROMConstantByte1_R ) ;
cbName - > AddEntry ( " DPP::ROMConstantByte0_R " , Register : : DPP : : ROMConstantByte0_R ) ;
cbName - > AddEntry ( " DPP::ROM_C_Code_R " , Register : : DPP : : ROM_C_Code_R ) ;
cbName - > AddEntry ( " DPP::ROM_R_Code_R " , Register : : DPP : : ROM_R_Code_R ) ;
cbName - > AddEntry ( " DPP::ROM_IEEE_OUI_Byte2_R " , Register : : DPP : : ROM_IEEE_OUI_Byte2_R ) ;
cbName - > AddEntry ( " DPP::ROM_IEEE_OUI_Byte1_R " , Register : : DPP : : ROM_IEEE_OUI_Byte1_R ) ;
cbName - > AddEntry ( " DPP::ROM_IEEE_OUI_Byte0_R " , Register : : DPP : : ROM_IEEE_OUI_Byte0_R ) ;
cbName - > AddEntry ( " DPP::ROM_BoardVersion_R " , Register : : DPP : : ROM_BoardVersion_R ) ;
cbName - > AddEntry ( " DPP::ROM_BoardFromFactor_R " , Register : : DPP : : ROM_BoardFromFactor_R ) ;
cbName - > AddEntry ( " DPP::ROM_BoardIDByte1_R " , Register : : DPP : : ROM_BoardIDByte1_R ) ;
cbName - > AddEntry ( " DPP::ROM_BoardIDByte0_R " , Register : : DPP : : ROM_BoardIDByte0_R ) ;
cbName - > AddEntry ( " DPP::ROM_PCB_rev_Byte3_R " , Register : : DPP : : ROM_PCB_rev_Byte3_R ) ;
cbName - > AddEntry ( " DPP::ROM_PCB_rev_Byte2_R " , Register : : DPP : : ROM_PCB_rev_Byte2_R ) ;
cbName - > AddEntry ( " DPP::ROM_PCB_rev_Byte1_R " , Register : : DPP : : ROM_PCB_rev_Byte1_R ) ;
cbName - > AddEntry ( " DPP::ROM_PCB_rev_Byte0_R " , Register : : DPP : : ROM_PCB_rev_Byte0_R ) ;
cbName - > AddEntry ( " DPP::ROM_FlashType_R " , Register : : DPP : : ROM_FlashType_R ) ;
cbName - > AddEntry ( " DPP::ROM_BoardSerialNumByte1_R " , Register : : DPP : : ROM_BoardSerialNumByte1_R ) ;
cbName - > AddEntry ( " DPP::ROM_BoardSerialNumByte0_R " , Register : : DPP : : ROM_BoardSerialNumByte0_R ) ;
cbName - > AddEntry ( " DPP::ROM_VCXO_Type_R " , Register : : DPP : : ROM_VCXO_Type_R ) ;
}
TypeRegisterAddress ( ) ;
UpdateRegister ( ) ;
}
std : : string RegisterSetting : : GetRegisterName ( uint32_t address ) {
uint32_t oldID = cbName - > GetSelected ( ) ;
cbName - > Select ( address , false ) ;
if ( cbName - > GetSelected ( ) = = - 1 ) {
cbName - > Select ( 0 , false ) ;
}
std : : string haha = cbName - > GetSelectedEntry ( ) - > GetTitle ( ) ;
cbName - > Select ( oldID , false ) ;
return haha ;
}
void RegisterSetting : : UpdateRegister ( ) {
uint32_t address = cbName - > GetSelected ( ) ;
txtAddress - > SetText ( Form ( " 0x%04X " , address ) , false ) ;
2022-10-05 14:28:55 -04:00
if ( digi = = NULL ) return ;
int boardID = boardIDEntry - > GetNumber ( ) ;
2022-10-04 16:54:01 -04:00
///check is the register readable
std : : string haha = cbName - > GetSelectedEntry ( ) - > GetTitle ( ) ;
int type = haha . back ( ) ;
if ( address > = 0x8000 ) {
bSetALLChannel - > SetState ( kButtonDown ) ;
bSetALLChannel - > SetEnabled ( false ) ;
for ( int ch = 0 ; ch < digi [ boardID ] - > GetNChannel ( ) ; ch + + ) {
txtValueHex [ ch ] - > SetText ( " " , false ) ;
txtValueDec [ ch ] - > SetText ( " " , false ) ;
txtValueUnit [ ch ] - > SetText ( " " , false ) ;
txtValueHex [ ch ] - > SetEnabled ( false ) ;
txtValueDec [ ch ] - > SetEnabled ( false ) ;
}
txtValueHex [ 0 ] - > SetEnabled ( true ) ;
txtValueDec [ 0 ] - > SetEnabled ( true ) ;
if ( type = = 87 ) { /// 'W'
txtValueHex [ 0 ] - > SetText ( " Register " , false ) ;
txtValueDec [ 0 ] - > SetText ( " WRITE " , false ) ;
txtValueUnit [ 0 ] - > SetText ( " ONLY " , false ) ;
txtValueHex [ 0 ] - > SetEnabled ( true ) ;
txtValueDec [ 0 ] - > SetEnabled ( true ) ;
} else {
value [ 0 ] = digi [ boardID ] - > ReadRegister ( address ) ;
txtValueHex [ 0 ] - > SetText ( Form ( " 0x%08X " , value [ 0 ] ) , false ) ;
txtValueDec [ 0 ] - > SetText ( Form ( " %u " , value [ 0 ] ) , false ) ;
if ( type = = 82 ) { /// Read only
txtValueHex [ 0 ] - > SetEnabled ( false ) ;
txtValueDec [ 0 ] - > SetEnabled ( false ) ;
} else {
txtValueHex [ 0 ] - > SetEnabled ( true ) ;
txtValueDec [ 0 ] - > SetEnabled ( true ) ;
}
}
} else {
bSetALLChannel - > SetEnabled ( true ) ; /// this will also set the buttonUP
if ( type = = 87 ) { /// 'W'
for ( int ch = 0 ; ch < digi [ boardID ] - > GetNChannel ( ) ; ch + + ) {
txtValueHex [ ch ] - > SetText ( " Register " , false ) ;
txtValueDec [ ch ] - > SetText ( " WRITE " , false ) ;
txtValueUnit [ ch ] - > SetText ( " ONLY " , false ) ;
txtValueHex [ ch ] - > SetEnabled ( true ) ;
txtValueDec [ ch ] - > SetEnabled ( true ) ;
}
} else {
for ( int ch = 0 ; ch < digi [ boardID ] - > GetNChannel ( ) ; ch + + ) {
if ( type = = 82 ) { /// Read only
value [ ch ] = digi [ boardID ] - > ReadRegister ( address , ch ) ;
txtValueHex [ ch ] - > SetText ( Form ( " 0x%08X " , value [ ch ] ) , false ) ;
txtValueDec [ ch ] - > SetText ( Form ( " %u " , value [ ch ] ) , false ) ;
txtValueHex [ ch ] - > SetEnabled ( false ) ;
txtValueDec [ ch ] - > SetEnabled ( false ) ;
} else {
value [ ch ] = digi [ boardID ] - > ReadRegister ( address , ch ) ;
txtValueHex [ ch ] - > SetText ( Form ( " 0x%08X " , value [ ch ] ) , false ) ;
txtValueDec [ ch ] - > SetText ( Form ( " %u " , value [ ch ] ) , false ) ;
if ( bSetALLChannel - > GetState ( ) = = kButtonUp ) {
txtValueHex [ ch ] - > SetEnabled ( true ) ;
txtValueDec [ ch ] - > SetEnabled ( true ) ;
}
SetTxtValueUnit ( address , ch ) ;
if ( type = = 71 & ch % 2 = = 1 ) { /// Paired
txtValueHex [ ch ] - > SetEnabled ( false ) ;
txtValueDec [ ch ] - > SetEnabled ( false ) ;
}
}
}
}
}
}
void RegisterSetting : : SetTxtValueUnit ( uint32_t address , int ch ) {
if ( digi = = NULL ) return ;
int boardID = boardIDEntry - > GetNumber ( ) ;
int ch2ns = ( int ) digi [ boardID ] - > GetCh2ns ( ) ;
txtValueUnit [ ch ] - > SetText ( " " ) ;
lbValueUnit - > SetText ( " Value [unit] " ) ;
if ( digi [ boardID ] - > GetDPPType ( ) = = V1730_DPP_PHA_CODE ) { /// PHA
if ( address = = Register : : DPP : : PHA : : RCCR2SmoothingFactor ) {
lbValueUnit - > SetText ( " Samples " ) ;
if ( value [ ch ] = = 0 ) {
txtValueUnit [ ch ] - > SetText ( " Disabled " ) ;
} else if ( value [ ch ] = = 0x3F ) {
txtValueUnit [ ch ] - > SetText ( " 128 " ) ;
} else {
txtValueUnit [ ch ] - > SetText ( Form ( " %d " , 2 * value [ ch ] ) ) ;
}
}
if ( address = = Register : : DPP : : PHA : : InputRiseTime | |
address = = Register : : DPP : : PHA : : TrapezoidRiseTime | |
address = = Register : : DPP : : PHA : : TrapezoidFlatTop | |
address = = Register : : DPP : : PHA : : PeakingTime | |
address = = Register : : DPP : : PHA : : DecayTime | |
address = = Register : : DPP : : PHA : : TriggerHoldOffWidth | |
address = = Register : : DPP : : PHA : : PeakHoldOff | |
address = = Register : : DPP : : PHA : : ShapedTriggerWidth
) {
txtValueUnit [ ch ] - > SetText ( Form ( " %d " , 4 * ch2ns * value [ ch ] ) ) ;
lbValueUnit - > SetText ( " Value [ns] " ) ;
}
if ( address = = Register : : DPP : : PHA : : TriggerThreshold ) {
lbValueUnit - > SetText ( " Value [LSB] " ) ;
txtValueUnit [ ch ] - > SetText ( Form ( " %d " , value [ ch ] ) ) ;
}
if ( address = = Register : : DPP : : PHA : : RiseTimeValidationWindow ) {
if ( value [ ch ] = = 0 ) {
txtValueUnit [ ch ] - > SetText ( " Disabled " ) ;
} else {
txtValueUnit [ ch ] - > SetText ( Form ( " %d " , ch2ns * value [ ch ] ) ) ;
}
lbValueUnit - > SetText ( " Value [ns] " ) ;
}
}
if ( digi [ boardID ] - > GetDPPType ( ) = = V1730_DPP_PSD_CODE ) { /// PSD
2022-10-05 14:28:55 -04:00
if ( address = = Register : : DPP : : PSD : : ChargeZeroSuppressionThreshold | |
address = = Register : : DPP : : PSD : : TriggerThreshold | |
address = = Register : : DPP : : PSD : : FixedBaseline
) {
txtValueUnit [ ch ] - > SetText ( Form ( " %d " , value [ ch ] ) ) ;
lbValueUnit - > SetText ( " Value [LSB] " ) ;
}
if ( address = = Register : : DPP : : PSD : : ShortGateWidth | |
address = = Register : : DPP : : PSD : : LongGateWidth | |
address = = Register : : DPP : : PSD : : GateOffset
) {
txtValueUnit [ ch ] - > SetText ( Form ( " %d " , ch2ns * value [ ch ] ) ) ;
lbValueUnit - > SetText ( " Value [ns] " ) ;
}
if ( address = = Register : : DPP : : PSD : : TriggerLatency | |
address = = Register : : DPP : : PSD : : ShapedTriggerWidth | |
address = = Register : : DPP : : PSD : : TriggerHoldOffWidth | |
address = = Register : : DPP : : PSD : : EarlyBaselineFreeze
) {
txtValueUnit [ ch ] - > SetText ( Form ( " %d " , 4 * ch2ns * value [ ch ] ) ) ;
lbValueUnit - > SetText ( " Value [ns] " ) ;
}
if ( address = = Register : : DPP : : PSD : : PurGapThreshold ) {
//TODO
}
2022-10-04 16:54:01 -04:00
}
if ( digi [ boardID ] - > GetDPPType ( ) = = V1730_DPP_PSD_CODE | | digi [ boardID ] - > GetDPPType ( ) = = V1730_DPP_PHA_CODE ) {
if ( address = = Register : : DPP : : RecordLength_G ) {
txtValueUnit [ ch ] - > SetText ( Form ( " %d " , 8 * ch2ns * value [ ch ] ) ) ;
lbValueUnit - > SetText ( " Value [ns] " ) ;
}
if ( address = = Register : : DPP : : InputDynamicRange ) {
if ( ( value [ ch ] & 0x1 ) = = 0 ) {
txtValueUnit [ ch ] - > SetText ( " 2.0 Vpp " ) ;
} else if ( ( value [ ch ] & 0x1 ) = = 1 ) {
txtValueUnit [ ch ] - > SetText ( " 0.5 Vpp " ) ;
}
}
if ( address = = Register : : DPP : : PreTrigger ) {
txtValueUnit [ ch ] - > SetText ( Form ( " %d " , 4 * ch2ns * value [ ch ] ) ) ;
lbValueUnit - > SetText ( " Value [ns] " ) ;
}
if ( address = = Register : : DPP : : TriggerHoldOffWidth ) {
txtValueUnit [ ch ] - > SetText ( Form ( " %d " , 4 * ch2ns * value [ ch ] ) ) ;
lbValueUnit - > SetText ( " Value [ns] " ) ;
}
if ( address = = Register : : DPP : : ChannelDCOffset ) {
txtValueUnit [ ch ] - > SetText ( Form ( " %.2f " , 100. - value [ ch ] * 100. / 0xFFFF ) ) ;
lbValueUnit - > SetText ( " Value [%] " ) ;
}
}
}
unsigned int RegisterSetting : : ConvertHexToDec ( const char * text ) {
/// Convert 0xXXXX to int
unsigned int address = 0 ;
std : : stringstream ss ;
ss < < std : : hex < < text ;
ss > > address ;
return address ;
}
void RegisterSetting : : TypeRegisterAddress ( ) {
unsigned int address = ConvertHexToDec ( txtAddress - > GetText ( ) ) ;
txtAddress - > SetText ( Form ( " 0x%04X " , address ) ) ;
cbName - > Select ( address , false ) ;
if ( cbName - > GetSelected ( ) = = - 1 ) {
cbName - > Select ( 0 , false ) ;
} else {
UpdateRegister ( ) ;
}
}
void RegisterSetting : : ChangeValue ( ) {
printf ( " =============%s \n " , __func__ ) ;
if ( digi = = NULL ) return ;
int boardID = boardIDEntry - > GetNumber ( ) ;
uint32_t address = cbName - > GetSelected ( ) ;
if ( bSetALLChannel - > GetState ( ) = = kButtonDown ) {
unsigned int newValue1 = ConvertHexToDec ( txtValueHex [ 0 ] - > GetText ( ) ) ;
unsigned int newValue2 = atoi ( txtValueDec [ 0 ] - > GetText ( ) ) ;
if ( value [ 0 ] ! = newValue1 ) {
digi [ boardID ] - > WriteRegister ( address , newValue1 , - 1 ) ;
for ( int i = 1 ; i < MaxNChannels ; i + + ) value [ i ] = newValue1 ;
UpdateRegister ( ) ;
} else if ( value [ 0 ] ! = newValue2 ) {
digi [ boardID ] - > WriteRegister ( address , newValue2 , - 1 ) ;
for ( int i = 1 ; i < MaxNChannels ; i + + ) value [ i ] = newValue2 ;
UpdateRegister ( ) ;
}
} else {
for ( int ch = 0 ; ch < digi [ boardID ] - > GetNChannel ( ) ; ch + + ) {
unsigned int newValue1 = ConvertHexToDec ( txtValueHex [ ch ] - > GetText ( ) ) ;
unsigned int newValue2 = atoi ( txtValueDec [ ch ] - > GetText ( ) ) ;
if ( value [ ch ] ! = newValue1 ) {
digi [ boardID ] - > WriteRegister ( address , newValue1 , ch ) ;
value [ ch ] = newValue1 ;
UpdateRegister ( ) ;
//SendChangeSignal();
} else if ( value [ ch ] ! = newValue2 ) {
digi [ boardID ] - > WriteRegister ( address , newValue2 , ch ) ;
value [ ch ] = newValue2 ;
UpdateRegister ( ) ;
//SendChangeSignal();
}
}
}
}
void RegisterSetting : : SetAllChannels ( ) {
if ( digi = = NULL ) return ;
int boardID = boardIDEntry - > GetNumber ( ) ;
if ( bSetALLChannel - > GetState ( ) = = kButtonDown ) {
for ( int ch = 1 ; ch < digi [ boardID ] - > GetNChannel ( ) ; ch + + ) {
txtValueHex [ ch ] - > SetEnabled ( false ) ;
txtValueDec [ ch ] - > SetEnabled ( false ) ;
}
} else {
UpdateRegister ( ) ;
}
}
void RegisterSetting : : SendChangeSignal ( ) {
Emit ( " SendChangeSignal() " ) ;
}
2022-10-05 14:28:55 -04:00
void RegisterSetting : : LogMsg ( TString msg ) {
Emit ( " LogMsg(char*) " , msg . Data ( ) ) ;
}