diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index a05dd09..050adb5 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -16,6 +16,8 @@ Digitizer::~Digitizer(){ } void Digitizer::Initalization(){ + + data = new Data(); portID = -1; boardID = -1; @@ -26,20 +28,13 @@ void Digitizer::Initalization(){ ADCFullSize = 0; ch2ns = 0; BoardInfo = {}; - - isDummy = true; + channelMask = 0xFFFF; VMEBaseAddress = 0; LinkType = CAEN_DGTZ_USB; /// default USB IOlev = CAEN_DGTZ_IOLevel_NIM; ///default NIM - AcqMode = CAEN_DGTZ_DPP_ACQ_MODE_List; ///default list mode - channelMask = 0xFFFF; - - data = new Data(); - isSettingFilledinMemeory = false; - settingFileName = ""; settingFileExist = false; settingFile = NULL; @@ -47,7 +42,7 @@ void Digitizer::Initalization(){ ret = -1; isConnected = false; AcqRun = false; - + isDummy = true; } void Digitizer::Reset(){ @@ -242,6 +237,8 @@ int Digitizer::ProgramBoard(){ /// Set the digitizer acquisition mode (CAEN_DGTZ_SW_CONTROLLED or CAEN_DGTZ_S_IN_CONTROLLED) ret |= CAEN_DGTZ_SetAcquisitionMode(handle, CAEN_DGTZ_SW_CONTROLLED); /// software command + + CAEN_DGTZ_DPP_AcqMode_t AcqMode = CAEN_DGTZ_DPP_ACQ_MODE_List; ret |= CAEN_DGTZ_SetDPPAcquisitionMode(handle, AcqMode, CAEN_DGTZ_DPP_SAVE_PARAM_EnergyAndTime); /** Set the digitizer's behaviour when an external trigger arrives: diff --git a/ClassDigitizer.h b/ClassDigitizer.h index efd2c30..386bf1b 100644 --- a/ClassDigitizer.h +++ b/ClassDigitizer.h @@ -39,7 +39,6 @@ class Digitizer{ uint32_t VMEBaseAddress; /// For direct USB or Optical-link connection, VMEBaseAddress must be 0 CAEN_DGTZ_ConnectionType LinkType; /// USB or Optic CAEN_DGTZ_IOLevel_t IOlev; /// TTL signal (1 = 1.5 to 5V, 0 = 0 to 0.7V ) or NIM signal (1 = -1 to -0.8V, 0 = 0V) - CAEN_DGTZ_DPP_AcqMode_t AcqMode; ///------- other parameters int ret; /// return value, refer to CAEN_DGTZ_ErrorCode diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 91c7b19..78a5f1d 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -52,8 +52,21 @@ long get_time(){ return time_ms; } -///make static members -Digitizer ** MainWindow::digi = NULL; +///============= Global variable +TH1F * hEnergy[MaxNBoards][MaxNChannels] = {NULL}; +TH1F * hChannel[MaxNBoards] = {NULL}; + +TGraph * gAnaTrace1 = NULL ; +TGraph * gAnaTrace2 = NULL ; +TGraph * gDigiTrace1 = NULL ; +TGraph * gDigiTrace2 = NULL ; + +Pixel_t red, blue, green; + +unsigned short nDigi; +Digitizer ** digi = NULL; + +///============ static members TGTextEdit * MainWindow::teLog = NULL; TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL; TGNumberEntry * MainWindow::boardIDEntry = NULL; @@ -64,18 +77,15 @@ TGNumberEntry * MainWindow::runIDEntry = NULL; BoardSetting * MainWindow::boardSetting = NULL; -TH1F * MainWindow::hEnergy[MaxNBoards][MaxNChannels] = {NULL}; -TH1F * MainWindow::hChannel[MaxNBoards] = {NULL}; - -TGraph * MainWindow::gAnaTrace1 = NULL ; -TGraph * MainWindow::gAnaTrace2 = NULL ; -TGraph * MainWindow::gDigiTrace1 = NULL ; -TGraph * MainWindow::gDigiTrace2 = NULL ; MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { nDigi = 0; + gClient->GetColorByName("red", red); + gClient->GetColorByName("blue", blue); + gClient->GetColorByName("green", green); + /// Create a main frame fMain = new TGMainFrame(p,w,h); ///fMain->SetWMPosition(500, 500); //does not work @@ -147,7 +157,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { cbMode->AddEntry("Count Hist.", Mode_CountHist); cbMode->AddEntry("Ocsilloscope.", Mode_Oscilloscope); cbMode->AddEntry("Data Run", Mode_DataRun); - cbMode->Select(1, false); + cbMode->Select(Mode_Oscilloscope, false); cbMode->Resize(80, 20); cbMode->Connect("Changed()", "MainWindow", this, "ChangePlot()"); @@ -226,17 +236,25 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { LogMsg((char*)"The LogMsg is not complete for all actions. [update later]"); LogMsg((char*)"Please \"Open Digitizers\" to start."); - HandleMenu(M_DIGITIZER_OPEN); + //HandleMenu(M_DIGITIZER_OPEN); //HandleMenu(M_BOARD_SETTINGS); //HandleMenu(M_CH_SETTING_PHA); //HandleMenu(M_CH_SETTING_PSD); //HandleMenu(M_REGISTER_SETTING); //HandleMenu(M_TRIGGER_SUMMARY); - gAnaTrace1 = new TGraph(); gAnaTrace1->GetYaxis()->SetRangeUser(0, 0x3FFF); - gAnaTrace2 = new TGraph(); gAnaTrace2->SetLineColor(2); - gDigiTrace1 = new TGraph(); gDigiTrace1->SetLineColor(4); - gDigiTrace2 = new TGraph(); gDigiTrace2->SetLineColor(6); + gAnaTrace1 = new TGraph(); + gAnaTrace1->SetName("Analog Trace 1"); + gAnaTrace1->GetXaxis()->SetTitle("[ns]"); + gAnaTrace2 = new TGraph(); + gAnaTrace2->SetName("Analog Trace 2"); + gAnaTrace2->SetLineColor(2); + gDigiTrace1 = new TGraph(); + gDigiTrace1->SetName("Digital Trace 1"); + gDigiTrace1->SetLineColor(4); + gDigiTrace2 = new TGraph(); + gDigiTrace2->SetName("Digital Trace 2"); + gDigiTrace2->SetLineColor(6); gStyle->SetOptStat("neiou"); @@ -265,8 +283,6 @@ MainWindow::~MainWindow() { delete bPlotSingleTrace; delete bFitTrace; - delete [] digi; - delete boardSetting; delete channelSettingPHA; delete channelSettingPSD; @@ -276,16 +292,6 @@ MainWindow::~MainWindow() { delete fillHistThread; - delete gAnaTrace1; - delete gAnaTrace2; - delete gDigiTrace1; - delete gDigiTrace2; - - for( int i = 0; i < MaxNBoards; i++){ - delete hChannel[i]; - for( int j = 0; j < MaxNChannels; j++) delete hEnergy[i][j]; - } - /// Clean up used widgets: frames, buttons, layout hints fMain->Cleanup(); delete fMain; @@ -314,7 +320,7 @@ void MainWindow::HandleMenu(Int_t id){ ///========================= Trigger summary case M_TRIGGER_SUMMARY: { - triggerSummary = new TriggerSummary(gClient->GetRoot(), 600, 600, digi, nDigi); + triggerSummary = new TriggerSummary(gClient->GetRoot(), 600, 600); }break; case M_LOAD_SETTINGS:{ @@ -323,27 +329,27 @@ void MainWindow::HandleMenu(Int_t id){ ///========================= Channel setting case M_CH_SETTING_PHA: - channelSettingPHA = new ChannelSettingPHA(gClient->GetRoot(), 600, 600, digi, nDigi, 0); + channelSettingPHA = new ChannelSettingPHA(gClient->GetRoot(), 600, 600, 0); channelSettingPHA->Connect("LogMsg(char*)", "MainWindow", this, "LogMsg(char*)"); channelSettingPHA->Connect("SendPlotTraceCmd()", "MainWindow", this, "PlotSingleTrace()"); break; case M_CH_SETTING_PSD: - channelSettingPSD = new ChannelSettingPSD(gClient->GetRoot(), 600, 600, digi, nDigi, 0); + channelSettingPSD = new ChannelSettingPSD(gClient->GetRoot(), 600, 600, 0); channelSettingPSD->Connect("LogMsg(char*)", "MainWindow", this, "LogMsg(char*)"); //channelSettingPSD->Connect("SendPlotTraceCmd()", "MainWindow", this, "PlotSingleTrace()"); break; ///========================= Board setting case M_BOARD_SETTINGS:{ - boardSetting = new BoardSetting(gClient->GetRoot(), 600, 600, digi, nDigi); + boardSetting = new BoardSetting(gClient->GetRoot(), 600, 600); boardSetting->Connect("LogMsg(char*)", "MainWindow", this, "LogMsg(char*)"); boardSetting->Connect("Haha(Int_t)", "MainWindow", this, "OpenChannelSetting(Int_t)"); }break; ///========================= Setting Summary case M_REGISTER_SETTING:{ - registerSetting = new RegisterSetting(gClient->GetRoot(), 600, 600, digi, nDigi, Register::DPP::RecordLength_G); + registerSetting = new RegisterSetting(gClient->GetRoot(), 600, 600, Register::DPP::RecordLength_G); ///registerSetting->Connect("SendChangeSignal()", "ChannelSettingPHA", this, "ChangeCh()"); ///registerSetting->Connect("SendChangeSignal()", "ChannelSettingPSD", this, "ChangeCh()"); }break; @@ -544,7 +550,11 @@ void MainWindow::StopRun(){ for( int i = 0; i < nDigi; i++){ digi[i]->StopACQ(); - //Save last bit of buffer + } + + fillHistThread->Join(); + + for( int i = 0; i < nDigi; i++){ ///===== clear data; digi[i]->GetData()->ClearTriggerRate(); } @@ -569,13 +579,13 @@ void MainWindow::OpenChannelSetting(Int_t boardID){ if( digi == NULL ) return; if( digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE ){ - channelSettingPHA = new ChannelSettingPHA(gClient->GetRoot(), 600, 600, digi, nDigi, boardID); + channelSettingPHA = new ChannelSettingPHA(gClient->GetRoot(), 600, 600, boardID); channelSettingPHA->Connect("LogMsg(char*)", "MainWindow", this, "LogMsg(char*)"); channelSettingPHA->Connect("SendPlotTraceCmd()", "MainWindow", this, "PlotSingleTrace()"); } if( digi[boardID]->GetDPPType() == V1730_DPP_PSD_CODE ){ - channelSettingPSD = new ChannelSettingPSD(gClient->GetRoot(), 600, 600, digi, nDigi, boardID); + channelSettingPSD = new ChannelSettingPSD(gClient->GetRoot(), 600, 600, boardID); channelSettingPSD->Connect("LogMsg(char*)", "MainWindow", this, "LogMsg(char*)"); //channelSettingPSD->Connect("SendPlotTraceCmd()", "MainWindow", this, "PlotSingleTrace()"); } @@ -775,6 +785,7 @@ void * MainWindow::RunThread(void * ptr){ uint32_t bdConfig = digi[boardID]->GetSettingFromMemory(Register::DPP::BoardConfiguration); bool isDualTrace = ( bdConfig >> 11 ) & 0x1; + bool hasTrace = (bdConfig >> 16 ) & 0x1; Data * data = digi[boardID]->GetData(); @@ -813,8 +824,8 @@ void * MainWindow::RunThread(void * ptr){ fEcanvas->GetCanvas()->cd(); ///Fill trace - if( cbMode->GetSelected() == Mode_Oscilloscope){ - + if( cbMode->GetSelected() == Mode_Oscilloscope && hasTrace){ + unsigned short nData = data->NumEvents[ch]; traceLength = (data->Waveform1[ch][nData-1]).size(); if( traceLength > 0 ){ @@ -829,9 +840,10 @@ void * MainWindow::RunThread(void * ptr){ if( isDualTrace) gAnaTrace2->RemovePoint(i); } } - gAnaTrace1->GetYaxis()->SetRangeUser(0, 0x3FFF); - gAnaTrace1->Draw("APL"); - gAnaTrace2->Draw("L"); + gAnaTrace1->Draw("AL"); + ///this causes warning + gAnaTrace1->GetYaxis()->SetRangeUser(0, 0x3FFF); + gAnaTrace2->Draw("same L"); } } @@ -844,21 +856,20 @@ void * MainWindow::RunThread(void * ptr){ for( int i = 0 ; i < digi[boardID]->GetNChannel(); i++){ for( int j = 0; j < data->NumEvents[i]; j++) hChannel[boardID]->Fill(i); } - + ///Fill Energy histogram for( int i = 0; i < data->NumEvents[ch]; i++){ - hEnergy[boardID][ch]->Fill( data->Energy[ch][i]); + hEnergy[boardID][ch]->Fill( data->Energy[ch][i] ); } - + if( cbMode->GetSelected() == Mode_EnergyHist ) hEnergy[boardID][ch]->Draw("hist"); if( cbMode->GetSelected() == Mode_CountHist ) hChannel[boardID]->Draw("hist"); - + data->ClearData(); PreviousTime = CurrentTime; } - fEcanvas->GetCanvas()->Update(); - gSystem->ProcessEvents(); + fEcanvas->GetCanvas()->Update(); } data->ClearData(); @@ -874,5 +885,16 @@ int main(int argc, char **argv) { TApplication theApp("App",&argc,argv); new MainWindow(gClient->GetRoot(),800,800); theApp.Run(); + + delete gAnaTrace1; + delete gAnaTrace2; + delete gDigiTrace1; + delete gDigiTrace2; + + for( int i = 0; i < MaxNBoards; i++){ + delete hChannel[i]; + for( int j = 0; j < MaxNChannels; j++) delete hEnergy[i][j]; + } + return 0; } diff --git a/FSUDAQ.h b/FSUDAQ.h index 3b85792..76fa9ac 100644 --- a/FSUDAQ.h +++ b/FSUDAQ.h @@ -52,11 +52,9 @@ private: TGTextButton *bPlotSingleTrace; TGTextButton *bFitTrace; - unsigned short nDigi; std::vector portID; std::vector boardID; std::vector serialNum; - static Digitizer ** digi; static BoardSetting * boardSetting; ChannelSettingPHA * channelSettingPHA; @@ -66,15 +64,7 @@ private: ProgramSetting * programSetting; TThread * fillHistThread; - - static TH1F * hEnergy [MaxNBoards][MaxNChannels]; - static TH1F * hChannel[MaxNBoards]; - - static TGraph * gAnaTrace1; /// analogy trace 1 - static TGraph * gAnaTrace2; /// analogy trace 2 - static TGraph * gDigiTrace1; /// digital trace 1 - static TGraph * gDigiTrace2; /// digital trace 1 - + public: MainWindow(const TGWindow *p, UInt_t w, UInt_t h); virtual ~MainWindow(); diff --git a/boardSetting.cpp b/boardSetting.cpp index 292e77d..31efc9e 100644 --- a/boardSetting.cpp +++ b/boardSetting.cpp @@ -9,6 +9,7 @@ #include "boardSetting.h" + TString boardSettingName[NUM_BOARD_INFO] = { "Model", "DPP Type", "Link Type", @@ -20,14 +21,13 @@ TString boardSettingName[NUM_BOARD_INFO] = { "Model", "AMC version" }; -BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nBoard){ - - this->nDigi = nBoard; - this->digi = digi; - - gClient->GetColorByName("red", red); - gClient->GetColorByName("blue", blue); - +///======== declared at FSUDAQ.cpp +extern Pixel_t red, blue, green; +extern unsigned short nDigi; +extern Digitizer ** digi; + +BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h){ + fMain = new TGMainFrame(p,w,h); fMain->SetWindowName("Board Settings & Status"); fMain->Connect("CloseWindow()", "BoardSetting", this, "CloseWindow()"); @@ -42,9 +42,9 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d boardIDEntry = new TGNumberEntry(hframe0, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); hframe0->AddFrame(boardIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4)); boardIDEntry->SetWidth(50); - boardIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, nBoard-1); + boardIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, nDigi-1); boardIDEntry->Connect("Modified()", "BoardSetting", this, "ChangeBoard()"); - if( nBoard <= 1 ) boardIDEntry->SetState(false); + if( nDigi <= 1 ) boardIDEntry->SetState(false); int boardID = boardIDEntry->GetNumber(); @@ -621,6 +621,10 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d TGTextButton * bReadData = new TGTextButton(vfButton, "Read Data"); vfButton->AddFrame(bReadData, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0)); bReadData->Connect("Clicked()", "BoardSetting", this, "ReadData()"); + + TGTextButton * bCaliADC = new TGTextButton(vfButton, "Calibrate ADC"); vfButton->AddFrame(bCaliADC, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0)); + bCaliADC->Connect("Clicked()", "ChannelSettingPHA", this, "CaliADC()"); + } TGHorizontalFrame * hRow2 = new TGHorizontalFrame(vframe); vframe->AddFrame(hRow2, new TGLayoutHints(kLHintsExpandX)); @@ -1435,7 +1439,7 @@ void BoardSetting::ReadData(){ digi[boardID]->ReadData(); //data->PrintBuffer(); - data->DecodeBuffer(2); + data->DecodeBuffer(false, 3); data->PrintStat(); @@ -1542,3 +1546,9 @@ void BoardSetting::FillBufferSizeTextBox(){ uint32_t buffer = digi[boardID]->CalByteForBuffer(); txtBufferSize->SetText(Form("%.2f", buffer/1024./1024.)); } + +void BoardSetting::CaliADC(){ + if ( digi == NULL ) return; + short boardID = boardIDEntry->GetNumber(); + if( digi != NULL ) digi[boardID]->WriteRegister(Register::DPP::ADCCalibration_W, 1); +} diff --git a/boardSetting.h b/boardSetting.h index 38d6a3c..64f82b3 100644 --- a/boardSetting.h +++ b/boardSetting.h @@ -21,17 +21,12 @@ class BoardSetting{ private: TGMainFrame * fMain; - Pixel_t red, blue; - TGNumberEntry * boardIDEntry; TGTextEntry * entry[NUM_BOARD_INFO]; TGTextEntry * txtSettingFile; - int nDigi; - Digitizer ** digi; - /// board failure status TGTextEntry * enPLLStatus; TGTextEntry * enTempStatus; @@ -131,7 +126,7 @@ class BoardSetting{ public: - BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nBoard); + BoardSetting(const TGWindow *p, UInt_t w, UInt_t h); virtual ~BoardSetting(); bool IsOpen() {return isOpened;} @@ -189,6 +184,7 @@ class BoardSetting{ void ProgramDefaultBoard(); void ProgramBoardFromFile(); void SaveSettingFile(); + void CaliADC(); void FillBufferSizeTextBox(); }; diff --git a/channelSettingPHA.cpp b/channelSettingPHA.cpp index 6d51547..c55dd63 100644 --- a/channelSettingPHA.cpp +++ b/channelSettingPHA.cpp @@ -10,14 +10,13 @@ #include "channelSettingPHA.h" -ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nDigi, int boardID){ - - this->digi = digi; - this->nDigi = nDigi; - - Pixel_t red, green; - gClient->GetColorByName("red", red); - gClient->GetColorByName("green", green); +///========= declared at FSUDAQ.cpp +extern Pixel_t red, blue, green; + +extern unsigned short nDigi; +extern Digitizer ** digi; + +ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, int boardID){ fMain = new TGMainFrame(p,w,h); fMain->SetWindowName("Channel Settings PHA"); @@ -66,6 +65,27 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi int ch = chIDEntry->GetNumber(); int width = 80; + TGHorizontalFrame *hframeStatus = new TGHorizontalFrame(vframe, w, 50 ); vframe->AddFrame(hframeStatus, new TGLayoutHints(kLHintsCenterX, 2,2,2,2)); + + {///================== Channel Status + + txtSPIBus = new TGTextEntry(hframeStatus, new TGTextBuffer(1)); hframeStatus->AddFrame(txtSPIBus, new TGLayoutHints(kLHintsLeft, 5,5,0,0)); + txtSPIBus->SetEnabled(false); + txtSPIBus->Resize(200, 20); + txtSPIBus->SetText( "SPI bus not busy" ); + + txtADCCaliStatus = new TGTextEntry(hframeStatus, new TGTextBuffer(1)); hframeStatus->AddFrame(txtADCCaliStatus, new TGLayoutHints(kLHintsLeft, 5,5,0,0)); + txtADCCaliStatus->SetEnabled(false); + txtADCCaliStatus->Resize(200, 20); + txtADCCaliStatus->SetText( "ADC Calibration None" ); + + txtADCPowerStatus = new TGTextEntry(hframeStatus, new TGTextBuffer(1)); hframeStatus->AddFrame(txtADCPowerStatus, new TGLayoutHints(kLHintsLeft, 5,5,0,0)); + txtADCPowerStatus->SetEnabled(false); + txtADCPowerStatus->Resize(300, 20); + txtADCPowerStatus->SetText( "ADC Power OK." ); + + } + TGHorizontalFrame *hframe1 = new TGHorizontalFrame(vframe, w, 50 ); vframe->AddFrame(hframe1, new TGLayoutHints(kLHintsCenterX, 2,2,2,2)); {///================== Input Setting @@ -391,7 +411,7 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi } {///================== Commands Buttons - TGGroupFrame * gfCmd = new TGGroupFrame(hframe2, "Commands", kHorizontalFrame); hframe2->AddFrame(gfCmd); + TGGroupFrame * gfCmd = new TGGroupFrame(hframe2, "Commands", kHorizontalFrame); hframe2->AddFrame(gfCmd, new TGLayoutHints(kLHintsExpandY)); TGVerticalFrame * vfCmd = new TGVerticalFrame(gfCmd); gfCmd->AddFrame(vfCmd, new TGLayoutHints(kLHintsExpandX)); TGTextButton * bReadSetting = new TGTextButton(vfCmd, "Read Settings"); vfCmd->AddFrame(bReadSetting, new TGLayoutHints(kLHintsExpandX, 5,5,3,4)); @@ -399,7 +419,7 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi TGTextButton * bReadTrace = new TGTextButton(vfCmd, "Read Trace"); vfCmd->AddFrame(bReadTrace, new TGLayoutHints(kLHintsExpandX, 5,5,3,4)); bReadTrace->Connect("Clicked()", "ChannelSettingPHA", this, "ReadTrace()"); - + } {///=================== Comment @@ -432,10 +452,55 @@ ChannelSettingPHA::~ChannelSettingPHA(){ isOpened = false; delete boardIDEntry; - + delete chIDEntry; + + delete eTemp ; + + delete txtSPIBus; + delete txtADCCaliStatus; + delete txtADCPowerStatus; + delete cbOnOff; - delete cbInputDynamicRange; delete cbPolarity; + delete cbInputDynamicRange; + delete numRecordLength; + delete numPreTrigger; + delete numEventAgg; + delete eBuffer ; + + delete numTriggerThreshold; + delete numTriggerHoldOff; + delete numDCOffset; + delete cbTriggerSmoothing; + delete numInputRiseTime; + delete numRiseTimeValidWin; + delete cbTriggerMode; + + delete numTrapRiseTime; + delete numTrapFlatTop; + delete numDecay; + delete numPeaking; + delete numPeakHoldOff; + delete cbPeakMean; + delete cbBaseLineAvg; + + delete numTrapScale; + delete cbDecimation; + delete cbDecimationGain; + delete cbRollOver; + delete cbPileUp; + delete cbLocalShapedTrigger; + + delete cbLocalTriggerValid; + delete cbVetoSource; + delete cbTriggerCounterRate; + delete cbBaselineCal; + delete cbTagCorrelatedEvent; + delete cbBaselineOptimize; + + delete cbDisableSelfTrigger; + delete cbExtra2WordOption; + /// fMain must be delete last; fMain->Cleanup(); @@ -497,14 +562,37 @@ void ChannelSettingPHA::ChangeCh(){ } LogMsg(Form("Read Channel %d Setting", (int)chIDEntry->GetNumber())); - + + uint32_t temp = 0; + if( digi[boardID]->IsDummy() ) { + txtADCCaliStatus->SetText("No Digitizer is opened!!!", false); txtADCCaliStatus->SetTextColor(red); + }else{ + temp = digi[boardID]->GetSettingFromMemory(Register::DPP::ChannelStatus_R, ch); + + if( (( temp >> 2 ) & 0x1 ) == 0 ){ + txtSPIBus->SetText("SPI bus is not busy.", false); txtSPIBus->SetTextColor(blue); + }else{ + txtSPIBus->SetText("SPI bus is BUSY.", false); txtSPIBus->SetTextColor(red); + } + if( (( temp >> 3 ) & 0x1 ) == 0 ){ + txtADCCaliStatus->SetText("ADC has not been calibrated.", false); txtADCCaliStatus->SetTextColor(red); + }else{ + txtADCCaliStatus->SetText("ADC has been calibrated.", false); txtADCCaliStatus->SetTextColor(blue); + } + if( (( temp >> 8 ) & 0x1 ) == 0 ){ + txtADCPowerStatus->SetText("ADC OK.", false); txtADCPowerStatus->SetTextColor(blue); + }else{ + txtADCPowerStatus->SetText("ADC Power down due to over-heat.", false); txtADCPowerStatus->SetTextColor(red); + } + } + cbOnOff->Select( (digi[boardID]->GetChannelMask() >> ch) & 0x1, false); /// don't emit signal cbInputDynamicRange->Select( digi[boardID]->GetSettingFromMemory(Register::DPP::InputDynamicRange, ch), false); numRecordLength->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::RecordLength_G, ch) * 8 * ch2ns, false); numPreTrigger->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::PreTrigger, ch) * 4 * ch2ns, false); numEventAgg->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::NumberEventsPerAggregate_G, ch), false); - uint32_t temp = digi[boardID]->GetSettingFromMemory(Register::DPP::ChannelDCOffset, ch); + temp = digi[boardID]->GetSettingFromMemory(Register::DPP::ChannelDCOffset, ch); numDCOffset->SetNumber( 100.0 - temp * 100.0/0xFFFF , false); eTemp->SetText(Form("%d C", digi[boardID]->GetSettingFromMemory(Register::DPP::ChannelADCTemperature_R, ch)), false); @@ -550,6 +638,9 @@ void ChannelSettingPHA::ChangeCh(){ cbTagCorrelatedEvent->Select( ( (temp >> 19) & 0x1), false); cbBaselineOptimize->Select( ( (temp >> 29) & 0x1), false); cbExtra2WordOption->Select( ( (temp >> 8) & 0x7), false); + + uint32_t buffer = digi[boardID]->CalByteForBuffer(); + eBuffer->SetText(Form("%.2f", buffer/1024./1024.)); } diff --git a/channelSettingPHA.h b/channelSettingPHA.h index c200171..dd8c636 100644 --- a/channelSettingPHA.h +++ b/channelSettingPHA.h @@ -22,6 +22,10 @@ class ChannelSettingPHA{ TGTextEntry * eTemp ; + TGTextEntry * txtSPIBus; + TGTextEntry * txtADCCaliStatus; + TGTextEntry * txtADCPowerStatus; + TGComboBox * cbOnOff; TGComboBox * cbPolarity; TGComboBox * cbInputDynamicRange; @@ -63,8 +67,6 @@ class ChannelSettingPHA{ TGComboBox * cbDisableSelfTrigger; TGComboBox * cbExtra2WordOption; - Digitizer ** digi; - int nDigi; int NChannel; // hard coded = 16 bool isOpened; @@ -75,7 +77,7 @@ class ChannelSettingPHA{ void ChangeAStep(TGNumberEntry * numEntry, unsigned short stepSize, uint32_t address); public: - ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nDigi, int boardID); + ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, int boardID); virtual ~ChannelSettingPHA(); void CloseWindow() { delete this; } diff --git a/channelSettingPSD.cpp b/channelSettingPSD.cpp index e2efb6b..4df59cb 100644 --- a/channelSettingPSD.cpp +++ b/channelSettingPSD.cpp @@ -10,14 +10,11 @@ #include "channelSettingPSD.h" -ChannelSettingPSD::ChannelSettingPSD(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nDigi, int boardID){ - - this->digi = digi; - this->nDigi = nDigi; - - Pixel_t red, green; - gClient->GetColorByName("red", red); - gClient->GetColorByName("green", green); +extern Pixel_t red, blue, green; +extern unsigned short nDigi; +extern Digitizer ** digi; + +ChannelSettingPSD::ChannelSettingPSD(const TGWindow *p, UInt_t w, UInt_t h, int boardID){ fMain = new TGMainFrame(p,w,h); fMain->SetWindowName("Channel Settings PSD"); diff --git a/channelSettingPSD.h b/channelSettingPSD.h index 23c1b88..0723e77 100644 --- a/channelSettingPSD.h +++ b/channelSettingPSD.h @@ -75,8 +75,6 @@ class ChannelSettingPSD{ TGComboBox * cbDisableSelfTrigger; TGComboBox * cbExtraWordOption; - Digitizer ** digi; - int nDigi; int NChannel; // hard coded = 16 bool isOpened; @@ -87,7 +85,7 @@ class ChannelSettingPSD{ void ChangeAStep(TGNumberEntry * numEntry, unsigned short stepSize, uint32_t address); public: - ChannelSettingPSD(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nDigi, int boardID); + ChannelSettingPSD(const TGWindow *p, UInt_t w, UInt_t h, int boardID); virtual ~ChannelSettingPSD(); void CloseWindow() { delete this; } diff --git a/registerSetting.cpp b/registerSetting.cpp index 901156d..2347641 100644 --- a/registerSetting.cpp +++ b/registerSetting.cpp @@ -9,10 +9,10 @@ #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; +extern unsigned short nDigi; +extern Digitizer ** digi; + +RegisterSetting::RegisterSetting(const TGWindow *p, UInt_t w, UInt_t h, uint32_t address){ for( int i = 0; i < MaxNChannels; i++) value[i] = 0; @@ -40,9 +40,9 @@ RegisterSetting::RegisterSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitize 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->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, nDigi-1); boardIDEntry->Connect("Modified()", "RegisterSetting", this, "ChangeBoard()"); - if( nBoard <= 1 ) boardIDEntry->SetState(false); + if( nDigi <= 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)); @@ -142,8 +142,6 @@ RegisterSetting::~RegisterSetting(){ delete txtValueUnit[i]; } - for( int i = 0; i < nDigi; i++ ) digi[i] = 0; - fMain->Cleanup(); delete fMain; diff --git a/registerSetting.h b/registerSetting.h index cb851c4..3e2c748 100644 --- a/registerSetting.h +++ b/registerSetting.h @@ -37,8 +37,6 @@ class RegisterSetting{ int textID; - int nDigi; - Digitizer ** digi; int DPPType; unsigned int ConvertHexToDec(const char * text); @@ -49,7 +47,7 @@ class RegisterSetting{ ///static bool updateFlag; public: - RegisterSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nBoard, uint32_t address); + RegisterSetting(const TGWindow *p, UInt_t w, UInt_t h, uint32_t address); virtual ~RegisterSetting(); diff --git a/triggerSummary.cpp b/triggerSummary.cpp index 309951f..ce1eb37 100644 --- a/triggerSummary.cpp +++ b/triggerSummary.cpp @@ -9,8 +9,9 @@ #include "triggerSummary.h" -Digitizer ** TriggerSummary::digi = NULL; -int TriggerSummary::nDigi = 0; +extern unsigned short nDigi; +extern Digitizer ** digi; + bool TriggerSummary::updateFlag = true; TGTextEntry * TriggerSummary::txtTrigger[MaxNBoards][MaxNChannels] = {NULL}; TGTextEntry * TriggerSummary::txtThresholdValue[MaxNBoards][MaxNChannels] = {NULL}; @@ -19,10 +20,7 @@ TGNumberEntry * TriggerSummary::numUpdateTime = NULL; unsigned short TriggerSummary::value[MaxNBoards][MaxNChannels] = {0}; -TriggerSummary::TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nBoard){ - - this->nDigi = nBoard; - this->digi = digi; +TriggerSummary::TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h){ fMain = new TGMainFrame(p,w,h); fMain->SetWindowName("Scalar Panel"); diff --git a/triggerSummary.h b/triggerSummary.h index 46cc850..350c740 100644 --- a/triggerSummary.h +++ b/triggerSummary.h @@ -18,9 +18,6 @@ class TriggerSummary{ RQ_OBJECT("TriggerSummary") private: TGMainFrame * fMain; - - static int nDigi; - static Digitizer ** digi; static TGTextEntry * txtTrigger[MaxNBoards][MaxNChannels]; static TGTextEntry * txtThresholdValue[MaxNBoards][MaxNChannels]; @@ -33,7 +30,7 @@ class TriggerSummary{ static unsigned short value[MaxNBoards][MaxNChannels]; public: - TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nBoard); + TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h); virtual ~TriggerSummary(); void CloseWindow() { delete this;}