From ece4b26d97c9416229404e821ad7368d9115bd93 Mon Sep 17 00:00:00 2001 From: "carina@hades" Date: Thu, 22 Sep 2022 17:53:29 -0400 Subject: [PATCH] stage the change in test branch --- FSUDAQ.cpp | 6 ++--- FSUDAQ.h | 2 +- boardSetting.cpp | 4 ++++ boardSetting.h | 2 +- channelSetting.cpp | 60 +++++++++++++++++++++++++--------------------- channelSetting.h | 6 ++++- 6 files changed, 47 insertions(+), 33 deletions(-) diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 647fbe4..9b05039 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -228,7 +228,7 @@ void MainWindow::HandleMenu(Int_t id){ ///========================= Channel setting case M_CH_SETTING: channelSetting = new ChannelSetting(gClient->GetRoot(), 600, 600, digi, nDigi); - channelSetting->Connect("LogMsg(TString)", "MainWindow", this, "LogMsg(TString)"); + channelSetting->Connect("ChLogMsg(TString)", "MainWindow", this, "LogMsg(TString)"); break; @@ -236,11 +236,11 @@ void MainWindow::HandleMenu(Int_t id){ case M_BOARD_SETTINGS:{ if( boardSetting == NULL ) { boardSetting = new BoardSetting(gClient->GetRoot(), 600, 600, digi, nDigi); - boardSetting->Connect("LogMsg(TString)", "MainWindow", this, "LogMsg(TString)"); + boardSetting->Connect("BdLogMsg(TString)", "MainWindow", this, "LogMsg(TString)"); }else{ if ( boardSetting->IsOpen() == false ){ boardSetting = new BoardSetting(gClient->GetRoot(), 600, 600, digi, nDigi); - boardSetting->Connect("LogMsg(TString)", "MainWindow", this, "LogMsg(TString)"); + boardSetting->Connect("BdLogMsg(TString)", "MainWindow", this, "LogMsg(TString)"); } } }break; diff --git a/FSUDAQ.h b/FSUDAQ.h index 38df5ca..9944ab9 100644 --- a/FSUDAQ.h +++ b/FSUDAQ.h @@ -89,6 +89,6 @@ public: //void ChangeMod(); //void ChangeChannel(); - void LogMsg(TString msg); + void LogMsg(TString); void GoodBye(); }; diff --git a/boardSetting.cpp b/boardSetting.cpp index fdcb159..db3f645 100644 --- a/boardSetting.cpp +++ b/boardSetting.cpp @@ -724,6 +724,10 @@ BoardSetting::~BoardSetting(){ } +void BoardSetting::BdLogMsg(TString msg){ + Emit("BdLogMsg(TString)", msg); +} + void * BoardSetting::ReadStatus(void * ptr){ if( digi == NULL ) return 0; diff --git a/boardSetting.h b/boardSetting.h index a6fb66d..b87a954 100644 --- a/boardSetting.h +++ b/boardSetting.h @@ -170,7 +170,7 @@ class BoardSetting{ ///==== Readout Control void SetReadOutControl(); - void LogMsg(TString msg); // *SIGNAL* + void BdLogMsg(TString); // *SIGNAL* }; #endif diff --git a/channelSetting.cpp b/channelSetting.cpp index 1792d50..4d01a1b 100644 --- a/channelSetting.cpp +++ b/channelSetting.cpp @@ -93,6 +93,7 @@ ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer cbInputDynamicRange = new TGComboBox(vfInput2); vfInput2->AddFrame(cbInputDynamicRange, layoutHints); cbInputDynamicRange->AddEntry("2.0 Vpp", 0); cbInputDynamicRange->AddEntry("0.5 Vpp", 1); + cbInputDynamicRange->Resize(width, 20); cbInputDynamicRange->Connect("Selected(Int_t, Int_t)", "ChannelSetting", this, "SetInputDynamicRange()"); ///---------- Record Length @@ -380,6 +381,8 @@ ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer fMain->Resize(fMain->GetDefaultSize()); fMain->MapWindow(); + ch2ns = 4; + isOpened = true; } ChannelSetting::~ChannelSetting(){ @@ -400,18 +403,22 @@ ChannelSetting::~ChannelSetting(){ } - -void ChannelSetting::LogMsg(TString msg){ - Emit("LogMsg(TString)", msg); +void ChannelSetting::ChLogMsg(TString msg){ + Emit("ChLogMsg(TString)", msg); } void ChannelSetting::ChangeBoard(){ + if ( digi == NULL ) return; + + int boardID = boardIDEntry->GetNumber(); + ch2ns = (unsigned short) digi[boardID]->GetCh2ns(); + ChangeCh(); } void ChannelSetting::ChangeCh(){ - LogMsg(Form("Change to Channel %d",chIDEntry->GetNumber()) ); + ChLogMsg("dsadasdsa"); if ( digi == NULL ) return; @@ -422,10 +429,7 @@ void ChannelSetting::ChangeCh(){ printf("All channels mode.\n"); return; } - - float ch2ns = digi[boardID]->GetCh2ns(); - //TODO SetNumber need to change bit to unit cbOnOff->Select( (digi[boardID]->GetChannelMask() >> ch) & 0x1, false); /// don't emit signal cbInputDynamicRange->Select( digi[boardID]->ReadRegister(Register::DPP::InputDynamicRange, ch), false); numRecordLength->SetNumber( digi[boardID]->ReadRegister(Register::DPP::RecordLength_G, ch) * 8 * ch2ns, false); @@ -613,25 +617,27 @@ void ChannelSetting::SetInputDynamicRange(){ digi[boardID]->WriteRegister(Register::DPP::InputDynamicRange, cbInputDynamicRange->GetSelected(), ch); } -void ChannelSetting::SetRecordLength(){ - printf("=================== SetRecordLength()\n"); - if ( digi == NULL ) return; +void ChannelSetting::ChangeAStep(TGNumberEntry * numEntry, unsigned short stepSize, uint32_t address){ + + unsigned int temp = numEntry->GetNumber(); + unsigned int res = temp % (stepSize * ch2ns); + temp = temp - res + ( ( res < (stepSize * ch2ns/2) ) ? (stepSize * ch2ns ) : 0 ); + numEntry->SetNumber(temp, false); short boardID = boardIDEntry->GetNumber(); short ch = chIDEntry->GetNumber(); - unsigned short ch2ns = digi[boardID]->GetCh2ns(); - - unsigned short temp = ((unsigned short)(numRecordLength->GetNumber())) / 8 / ch2ns; - - numRecordLength->SetNumber(temp * 8 * ch2ns, false); - - digi[boardID]->WriteRegister(Register::DPP::RecordLength_G, temp , ch); + if( digi != NULL ) digi[boardID]->WriteRegister(address, temp / stepSize / ch2ns , ch); +} + +void ChannelSetting::SetRecordLength(){ + printf("=================== SetRecordLength()\n"); + ChangeAStep(numRecordLength, 8, Register::DPP::RecordLength_G); } void ChannelSetting::SetPreTrigger(){ printf("=================== SetPreTrigger()\n"); - if ( digi == NULL ) return; + ChangeAStep(numPreTrigger, 4, Register::DPP::PreTrigger); } void ChannelSetting::SetEventAggregate(){ @@ -641,12 +647,12 @@ void ChannelSetting::SetEventAggregate(){ void ChannelSetting::SetTriggerThreshold(){ printf("=================== SetTriggerThreshold()\n"); - if ( digi == NULL ) return; + } void ChannelSetting::SetTriggerHoldOff(){ printf("=================== SetTriggerHoldOff()\n"); - if ( digi == NULL ) return; + ChangeAStep(numTriggerHoldOff, 4, Register::DPP::PHA::TriggerHoldOffWidth); } void ChannelSetting::SetDCOffset(){ @@ -661,35 +667,35 @@ void ChannelSetting::SetTriggerSmoothing(){ void ChannelSetting::SetInputRiseTime(){ printf("=================== SetInputRiseTime()\n"); - if ( digi == NULL ) return; + ChangeAStep(numInputRiseTime, 4, Register::DPP::PHA::InputRiseTime); } void ChannelSetting::SetRiseTimeValidWin(){ printf("=================== SetRiseTimeValidWin()\n"); - if ( digi == NULL ) return; + ChangeAStep(numRiseTimeValidWin, 1, Register::DPP::PHA::RiseTimeValidationWindow); } void ChannelSetting::SetTrapRiseTime(){ printf("=================== SetTrapRiseTime()\n"); - if ( digi == NULL ) return; + ChangeAStep(numTrapRiseTime, 4, Register::DPP::PHA::TrapezoidRiseTime); } void ChannelSetting::SetTrapFlatTop(){ printf("=================== SetTrapFlatTop()\n"); - if ( digi == NULL ) return; + ChangeAStep(numTrapFlatTop, 4, Register::DPP::PHA::TrapezoidFlatTop); } void ChannelSetting::SetDecay(){ printf("=================== SetDecay()\n"); - if ( digi == NULL ) return; + ChangeAStep(numDecay, 4, Register::DPP::PHA::DecayTime); } void ChannelSetting::SetPeaking(){ printf("=================== SetPeaking()\n"); - if ( digi == NULL ) return; + ChangeAStep(numPeaking, 4, Register::DPP::PHA::PeakingTime); } void ChannelSetting::SetPeakHoldOff(){ printf("=================== SetPeakHoldOff()\n"); - if ( digi == NULL ) return; + ChangeAStep(numPeakHoldOff, 4, Register::DPP::PHA::PeakHoldOff); } diff --git a/channelSetting.h b/channelSetting.h index 8422c59..ed6b13c 100644 --- a/channelSetting.h +++ b/channelSetting.h @@ -66,6 +66,10 @@ class ChannelSetting{ Digitizer ** digi; int NChannel; bool isOpened; + + unsigned short ch2ns; + + void ChangeAStep(TGNumberEntry * numEntry, unsigned short stepSize, uint32_t address); public: ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nDigi); @@ -103,7 +107,7 @@ class ChannelSetting{ void SetPeaking(); void SetPeakHoldOff(); - void LogMsg(TString); // *SIGNAL* + void ChLogMsg(TString); // *SIGNAL* }; #endif