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
2022-10-06 15:49:08 -04:00
lbCh [ i ] = new TGLabel ( vframe0 , Form ( " %02d " , i ) ) ; vframe0 - > AddFrame ( lbCh [ i ] , new TGLayoutHints ( kLHintsRight , 5 , 5 , 4 , 2 ) ) ;
2022-10-04 16:54:01 -04:00
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 ) ;
}
}
2022-10-06 17:10:54 -04:00
/**
{ ///================= Register Info
TGGroupFrame * groupInfo = new TGGroupFrame ( fMain , " Register Info " , kHorizontalFrame ) ; fMain - > AddFrame ( groupInfo , new TGLayoutHints ( kLHintsExpandX , 10 , 10 , 10 , 10 ) ) ;
txtInfo = new TGLabel ( groupInfo ) ; groupInfo - > AddFrame ( txtInfo , new TGLayoutHints ( kLHintsLeft , 2 , 2 , 10 , 0 ) ) ;
//txtInfo->SetText("dsjakldjsla\nsdjakldjsajkdlsa\n");
} */
2022-10-04 16:54:01 -04:00
fMain - > MapSubwindows ( ) ;
fMain - > Resize ( fMain - > GetDefaultSize ( ) ) ;
fMain - > MapWindow ( ) ;
ChangeBoard ( ) ;
}
RegisterSetting : : ~ RegisterSetting ( ) {
printf ( " === %s \n " , __func__ ) ;
delete boardIDEntry ;
delete txtAddress ;
delete cbName ;
2022-10-06 17:10:54 -04:00
delete bSetALLChannel ;
2022-10-04 16:54:01 -04:00
delete lbValueUnit ;
2022-10-14 18:27:31 -04:00
//delete txtInfo;
2022-10-04 16:54:01 -04:00
for ( int i = 0 ; i < MaxNChannels ; i + + ) {
delete txtValueHex [ i ] ;
delete txtValueDec [ i ] ;
delete txtValueUnit [ i ] ;
}
2022-10-14 18:27:31 -04:00
for ( int i = 0 ; i < nDigi ; i + + ) digi [ i ] = 0 ;
2022-10-04 16:54:01 -04:00
fMain - > Cleanup ( ) ;
delete fMain ;
}
void RegisterSetting : : ChangeBoard ( ) {
2022-10-14 13:22:55 -04:00
this - > 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 ( ) ;
2022-10-14 13:22:55 -04:00
this - > DPPType = digi [ boardID ] - > GetDPPType ( ) ;
2022-10-05 14:28:55 -04:00
}
2022-10-14 13:22:55 -04:00
2022-10-04 16:54:01 -04:00
cbName - > RemoveAll ( ) ;
cbName - > AddEntry ( " Address NOT Exist " , 0 ) ;
2022-10-14 13:22:55 -04:00
/// Channels Setting
if ( DPPType = = V1730_DPP_PHA_CODE ) {
for ( int p = 0 ; p < ( int ) RegisterPHAList [ p ] ; p + + ) {
cbName - > AddEntry ( RegisterPHAList [ p ] . GetNameChar ( ) , ( int ) RegisterPHAList [ p ] . GetAddress ( ) ) ;
}
2022-10-04 16:54:01 -04:00
}
2022-10-14 13:22:55 -04:00
if ( DPPType = = V1730_DPP_PSD_CODE ) {
for ( int p = 0 ; p < ( int ) RegisterPSDList [ p ] ; p + + ) {
cbName - > AddEntry ( RegisterPSDList [ p ] . GetNameChar ( ) , ( int ) RegisterPSDList [ p ] . GetAddress ( ) ) ;
}
}
/// board setting
for ( int p = 0 ; p < ( int ) RegisterDPPList [ p ] ; p + + ) {
cbName - > AddEntry ( RegisterDPPList [ p ] . GetNameChar ( ) , ( int ) RegisterDPPList [ p ] . GetAddress ( ) ) ;
2022-10-04 16:54:01 -04:00
}
TypeRegisterAddress ( ) ;
UpdateRegister ( ) ;
}
void RegisterSetting : : UpdateRegister ( ) {
uint32_t address = cbName - > GetSelected ( ) ;
txtAddress - > SetText ( Form ( " 0x%04X " , address ) , false ) ;
2022-10-06 15:49:08 -04:00
if ( address = = 0 | | digi = = NULL ) {
for ( int ch = 0 ; ch < MaxNChannels ; ch + + ) {
txtValueHex [ ch ] - > SetText ( " " , false ) ;
txtValueDec [ ch ] - > SetText ( " " , false ) ;
txtValueUnit [ ch ] - > SetText ( " " , false ) ;
txtValueHex [ ch ] - > SetEnabled ( false ) ;
txtValueDec [ ch ] - > SetEnabled ( false ) ;
}
return ;
}
2022-10-05 14:28:55 -04:00
int boardID = boardIDEntry - > GetNumber ( ) ;
2022-10-14 13:22:55 -04:00
Reg tempReg = digi [ boardID ] - > FindRegister ( address ) ;
2022-10-04 16:54:01 -04:00
if ( address > = 0x8000 ) {
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 ) ;
2022-10-14 13:22:55 -04:00
if ( tempReg . GetType ( ) = = RW : : WriteONLY ) {
2022-10-04 16:54:01 -04:00
txtValueHex [ 0 ] - > SetText ( " Register " , false ) ;
txtValueDec [ 0 ] - > SetText ( " WRITE " , false ) ;
txtValueUnit [ 0 ] - > SetText ( " ONLY " , false ) ;
txtValueHex [ 0 ] - > SetEnabled ( true ) ;
txtValueDec [ 0 ] - > SetEnabled ( true ) ;
} else {
2022-10-14 13:22:55 -04:00
value [ 0 ] = digi [ boardID ] - > ReadRegister ( tempReg ) ;
2022-10-04 16:54:01 -04:00
txtValueHex [ 0 ] - > SetText ( Form ( " 0x%08X " , value [ 0 ] ) , false ) ;
txtValueDec [ 0 ] - > SetText ( Form ( " %u " , value [ 0 ] ) , false ) ;
2022-10-14 13:22:55 -04:00
if ( tempReg . GetType ( ) = = RW : : ReadONLY ) {
2022-10-04 16:54:01 -04:00
txtValueHex [ 0 ] - > SetEnabled ( false ) ;
txtValueDec [ 0 ] - > SetEnabled ( false ) ;
} else {
txtValueHex [ 0 ] - > SetEnabled ( true ) ;
txtValueDec [ 0 ] - > SetEnabled ( true ) ;
}
}
} else {
2022-10-06 15:49:08 -04:00
EButtonState bState = bSetALLChannel - > GetState ( ) ;
2022-10-04 16:54:01 -04:00
bSetALLChannel - > SetEnabled ( true ) ; /// this will also set the buttonUP
2022-10-06 15:49:08 -04:00
if ( bState = = kButtonDisabled ) bState = kButtonUp ;
bSetALLChannel - > SetState ( bState ) ;
2022-10-04 16:54:01 -04:00
2022-10-14 13:22:55 -04:00
if ( tempReg . GetType ( ) = = RW : : WriteONLY ) { /// 'W'
2022-10-04 16:54:01 -04:00
for ( int ch = 0 ; ch < digi [ boardID ] - > GetNChannel ( ) ; ch + + ) {
txtValueHex [ ch ] - > SetText ( " Register " , false ) ;
txtValueDec [ ch ] - > SetText ( " WRITE " , false ) ;
txtValueUnit [ ch ] - > SetText ( " ONLY " , false ) ;
2022-10-06 15:49:08 -04:00
if ( bState = = kButtonUp ) {
txtValueHex [ ch ] - > SetEnabled ( true ) ;
txtValueDec [ ch ] - > SetEnabled ( true ) ;
}
2022-10-04 16:54:01 -04:00
}
2022-10-06 15:49:08 -04:00
if ( bState = = kButtonDown ) {
txtValueHex [ 0 ] - > SetEnabled ( true ) ;
txtValueDec [ 0 ] - > SetEnabled ( true ) ;
}
2022-10-04 16:54:01 -04:00
} else {
for ( int ch = 0 ; ch < digi [ boardID ] - > GetNChannel ( ) ; ch + + ) {
2022-10-14 13:22:55 -04:00
if ( tempReg . GetType ( ) = = RW : : ReadONLY ) { /// Read only
value [ ch ] = digi [ boardID ] - > ReadRegister ( tempReg , ch ) ;
2022-10-04 16:54:01 -04:00
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 {
2022-10-14 13:22:55 -04:00
value [ ch ] = digi [ boardID ] - > ReadRegister ( tempReg , ch ) ;
2022-10-04 16:54:01 -04:00
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 ) ;
2022-10-14 13:22:55 -04:00
if ( tempReg . GetGroup ( ) = = true & ch % 2 = = 1 ) { /// Paired
2022-10-04 16:54:01 -04:00
txtValueHex [ ch ] - > SetEnabled ( false ) ;
txtValueDec [ ch ] - > SetEnabled ( false ) ;
}
}
}
}
2022-10-06 15:49:08 -04:00
2022-10-04 16:54:01 -04:00
}
}
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] " ) ;
2022-10-14 13:22:55 -04:00
if ( DPPType = = V1730_DPP_PHA_CODE ) { /// PHA
2022-10-04 16:54:01 -04:00
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] " ) ;
}
}
2022-10-14 13:22:55 -04:00
if ( DPPType = = 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
}
2022-10-14 13:22:55 -04:00
if ( DPPType = = V1730_DPP_PSD_CODE | | DPPType = = V1730_DPP_PHA_CODE ) {
2022-10-04 16:54:01 -04:00
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 ( ) ;
2022-10-14 13:22:55 -04:00
Reg tempReg = digi [ boardID ] - > FindRegister ( address ) ;
2022-10-04 16:54:01 -04:00
if ( bSetALLChannel - > GetState ( ) = = kButtonDown ) {
unsigned int newValue1 = ConvertHexToDec ( txtValueHex [ 0 ] - > GetText ( ) ) ;
unsigned int newValue2 = atoi ( txtValueDec [ 0 ] - > GetText ( ) ) ;
if ( value [ 0 ] ! = newValue1 ) {
2022-10-14 13:22:55 -04:00
digi [ boardID ] - > WriteRegister ( tempReg , newValue1 , - 1 ) ;
2022-10-04 16:54:01 -04:00
for ( int i = 1 ; i < MaxNChannels ; i + + ) value [ i ] = newValue1 ;
UpdateRegister ( ) ;
} else if ( value [ 0 ] ! = newValue2 ) {
2022-10-14 13:22:55 -04:00
digi [ boardID ] - > WriteRegister ( tempReg , newValue2 , - 1 ) ;
2022-10-04 16:54:01 -04:00
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 ) {
2022-10-14 13:22:55 -04:00
digi [ boardID ] - > WriteRegister ( tempReg , newValue1 , ch ) ;
2022-10-04 16:54:01 -04:00
value [ ch ] = newValue1 ;
UpdateRegister ( ) ;
//SendChangeSignal();
} else if ( value [ ch ] ! = newValue2 ) {
2022-10-14 13:22:55 -04:00
digi [ boardID ] - > WriteRegister ( tempReg , newValue2 , ch ) ;
2022-10-04 16:54:01 -04:00
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 ( ) ) ;
}