From f8ddccdac871deb4ba652463bfc56bf8f0793e9c Mon Sep 17 00:00:00 2001 From: "carina@hades" Date: Mon, 26 Sep 2022 16:47:20 -0400 Subject: [PATCH] testing with digitizers --- ClassDigitizer.cpp | 93 +++++++++++++--------- ClassDigitizer.h | 6 +- DigitizerPHA.cpp | 2 + DigitizerPSD.cpp | 4 +- FSUDAQ.cpp | 53 +++++-------- FSUDAQ.h | 2 + boardSetting.cpp | 189 ++++++++++++++++++--------------------------- boardSetting.h | 47 +++++------ test.cpp | 8 +- 9 files changed, 193 insertions(+), 211 deletions(-) diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 2771987..ad06ed5 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -1,13 +1,28 @@ #include "ClassDigitizer.h" Digitizer::Digitizer(){ + Initalization(); +} +Digitizer::Digitizer(int boardID, int portID, bool program, bool verbose){ + Initalization(); + OpenDigitizer(boardID, portID, program, verbose); +} + +Digitizer::~Digitizer(){ + delete data; + CloseDigitizer(); +} + +void Digitizer::Initalization(){ + portID = -1; boardID = -1; handle = -1; NChannel = 0; ADCbits = 1; DPPType = 0; + DPPTypeStr = ""; ADCFullSize = 0; ch2ns = 0; BoardInfo = {}; @@ -28,18 +43,7 @@ Digitizer::Digitizer(){ ret = -1; isConnected = false; AcqRun = false; - -} - -Digitizer::Digitizer(int boardID, int portID, bool verbose){ - Digitizer(); - OpenDigitizer(boardID, portID, true, verbose); -} - -Digitizer::~Digitizer(){ - CloseDigitizer(); - delete data; } void Digitizer::Reset(){ @@ -106,23 +110,22 @@ int Digitizer::OpenDigitizer(int boardID, int portID, bool program, bool verbose ///====================== Check DPP firmware revision sscanf(BoardInfo.AMC_FirmwareRel, "%d", &DPPType); + switch (DPPType){ + case V1724_DPP_PHA_CODE: DPPTypeStr = "DPP-PHA x724"; break; + case V1720_DPP_CI_CODE : DPPTypeStr = "DPP-CI x720"; break; + case V1720_DPP_PSD_CODE: DPPTypeStr = "DPP-PSD x720"; break; + case V1751_DPP_PSD_CODE: DPPTypeStr = "DPP-PSD x751"; break; + case V1751_DPP_ZLE_CODE: DPPTypeStr = "DPP-ZLE x751"; break; + case V1743_DPP_CI_CODE: DPPTypeStr = "DPP-PSD x743"; break; + case V1740_DPP_QDC_CODE: DPPTypeStr = "DPP-QDC x740"; break; + case V1730_DPP_PSD_CODE: DPPTypeStr = "DPP-PSD x730"; break; + case V1730_DPP_PHA_CODE: DPPTypeStr = "DPP-PHA x730"; break; + case V1730_DPP_ZLE_CODE: DPPTypeStr = "DPP-ZLE x730"; break; + case V1730_DPP_DAW_CODE: DPPTypeStr = "DPP-DAW x730"; break; + } if (DPPType >= 0x80 && verbose) { - printf("\t==== This digitizer has a DPP firmware!\n"); - printf("\e[32m"); - switch (DPPType){ - case V1724_DPP_PHA_CODE: printf("\tDPP-PHA for x724 boards \n"); break; - case V1720_DPP_CI_CODE : printf("\tDPP-CI for x720 boards \n"); break; - case V1720_DPP_PSD_CODE: printf("\tDPP-PSD for x720 boards \n"); break; - case V1751_DPP_PSD_CODE: printf("\tDPP-PSD for x751 boards \n"); break; - case V1751_DPP_ZLE_CODE: printf("\tDPP-ZLE for x751 boards \n"); break; - case V1743_DPP_CI_CODE: printf("\tDPP-PSD for x743 boards \n"); break; - case V1740_DPP_QDC_CODE: printf("\tDPP-QDC for x740 boards \n"); break; - case V1730_DPP_PSD_CODE: printf("\tDPP-PSD for x730 boards \n"); break; - case V1730_DPP_PHA_CODE: printf("\tDPP-PHA for x730 boards \n"); break; - case V1730_DPP_ZLE_CODE: printf("\tDPP-ZLE for x730 boards \n"); break; - case V1730_DPP_DAW_CODE: printf("\tDPP-DAW for x730 boards \n"); break; - } - printf("\e[0m"); + printf("\t==== This digitizer has a DPP firmware!\n"); + printf("\e[32m\t %s \e[0m", DPPTypeStr.c_str()); } ///======================= Check virtual probe @@ -187,8 +190,6 @@ int Digitizer::CloseDigitizer(){ ret = CAEN_DGTZ_SWStopAcquisition(handle); ret |= CAEN_DGTZ_CloseDigitizer(handle); - //data->FreeMemory(); - return ret; } @@ -356,19 +357,19 @@ void Digitizer::WriteRegister(uint32_t address, uint32_t value, int ch ){ uint32_t Digitizer::ReadRegister(uint32_t address, int ch, string str ){ if( !isConnected ) return 0; - uint32_t * Data = new uint32_t[NChannel]; + uint32_t * data = new uint32_t[NChannel]; if( address < 0x8000) { if( ch < 0 ) { - ret = CAEN_DGTZ_ReadRegister(handle, address + 0x7000, Data); + ret = CAEN_DGTZ_ReadRegister(handle, address + 0x7000, data); }else{ - ret = CAEN_DGTZ_ReadRegister(handle, address + (ch << 8), Data); + ret = CAEN_DGTZ_ReadRegister(handle, address + (ch << 8), data); } }else{ - ret = CAEN_DGTZ_ReadRegister(handle, address, Data); + ret = CAEN_DGTZ_ReadRegister(handle, address, data); } ErrorMsg("ReadRegister:" + std::to_string(address)); - if( str != "" ) printf("%s : 0x%x \n", str.c_str(), Data[0]); - return Data[0]; + if( str != "" ) printf("%s : 0x%08x \n", str.c_str(), data[0]); + return data[0]; } void Digitizer::SetChannelMask(uint32_t mask){ @@ -534,7 +535,7 @@ uint32_t Digitizer::PrintRegister(uint32_t address, std::string msg){ printf("----------------------------------------------------\e[0m\n"); uint32_t * value = new uint32_t[1]; - CAEN_DGTZ_ReadRegister(handle, (uint32_t) Register::BoardConfiguration, value); + CAEN_DGTZ_ReadRegister(handle, address, value); printf(" %*s 32 28 24 20 16 12 8 4 0\n", (int) msg.length(), ""); printf(" %*s | | | | | | | | |\n", (int) msg.length(), ""); printf(" %*s", (int) msg.length(), ""); @@ -640,7 +641,7 @@ void Digitizer::CreateAndSaveSettingBinary(string fileName){ SaveSettingEditByteByRegister(Register::DPP::AMCFirmwareRevision, ch); SaveSettingEditByteByRegister(Register::DPP::VetoWidth, ch); - if( DPPType == 0x8B ) { /// DPP-PHA + if( DPPType == V1730_DPP_PHA_CODE ) { /// DPP-PHA SaveSettingEditByteByRegister(Register::DPP::PHA::TriggerThreshold, ch); SaveSettingEditByteByRegister(Register::DPP::PHA::RCCR2SmoothingFactor, ch); SaveSettingEditByteByRegister(Register::DPP::PHA::RiseTimeValidationWindow, ch); @@ -657,6 +658,24 @@ void Digitizer::CreateAndSaveSettingBinary(string fileName){ SaveSettingEditByteByRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, ch); SaveSettingEditByteByRegister(Register::DPP::PHA::FineGain, ch); } + + if( DPPType == V1730_DPP_PSD_CODE ) { /// DPP-PSD + SaveSettingEditByteByRegister(Register::DPP::PSD::CFDSetting, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::ForcedDataFlush, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::ChargeZeroSuppressionThreshold, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::ShortGateWidth, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::LongGateWidth, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::GateOffset, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::TriggerThreshold, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::FixedBaseline, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::TriggerLatency, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::ShapedTriggerWidth, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::TriggerHoldOffWidth, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::ThresholdForPSDCut, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::PurGapThreshold, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::DPPAlgorithmControl2_G, ch); + SaveSettingEditByteByRegister(Register::DPP::PSD::EarlyBaselineFreeze, ch); + } } } diff --git a/ClassDigitizer.h b/ClassDigitizer.h index 72618a9..230db7e 100644 --- a/ClassDigitizer.h +++ b/ClassDigitizer.h @@ -23,10 +23,10 @@ class Digitizer{ public: Digitizer(); - Digitizer(int boardID, int portID = 0, bool verbose = false); + Digitizer(int boardID, int portID = 0, bool program = false, bool verbose = false); ~Digitizer(); - + void Initalization(); void Reset(); int OpenDigitizer(int boardID, int portID = 0, bool program = false, bool verbose = false);/// portID is for optical link for using PCIe card, from 0, 1, 2, 3 int CloseDigitizer(); @@ -70,6 +70,7 @@ class Digitizer{ int GetHandle() {return handle;} bool GetConnectionStatus() {return isConnected;} int GetDPPType() {return DPPType;} + std::string GetDPPTypeString() {return DPPTypeStr;} CAEN_DGTZ_ConnectionType GetLinkType() {return LinkType;} int GetADCBits() {return BoardInfo.ADC_NBits;} std::string GetROCVersion() {return BoardInfo.ROC_FirmwareRel;} @@ -126,6 +127,7 @@ class Digitizer{ int NChannel; /// number of channel int ADCbits; /// ADC bit int DPPType; /// DPP verion + std::string DPPTypeStr; /// DPP type in string unsigned int ADCFullSize; /// pow(2, ADCbits) - 1 float ch2ns; /// channel to ns CAEN_DGTZ_BoardInfo_t BoardInfo; diff --git a/DigitizerPHA.cpp b/DigitizerPHA.cpp index 5ee4d8a..508e56e 100644 --- a/DigitizerPHA.cpp +++ b/DigitizerPHA.cpp @@ -5,6 +5,8 @@ DigitizerPHA::DigitizerPHA(){ } DigitizerPHA::DigitizerPHA(int boardID, int portID, bool verbose){ + Initalization(); + DPPType = V1730_DPP_PHA_CODE; OpenDigitizer(boardID, portID, true, verbose); } diff --git a/DigitizerPSD.cpp b/DigitizerPSD.cpp index 79436d2..ad5ad3b 100644 --- a/DigitizerPSD.cpp +++ b/DigitizerPSD.cpp @@ -6,7 +6,9 @@ DigitizerPSD::DigitizerPSD(){ } DigitizerPSD::DigitizerPSD(int boardID, int portID){ - OpenDigitizer(boardID, portID); + Initalization(); + DPPType = V1730_DPP_PSD_CODE; + OpenDigitizer(boardID, portID, true, false); } DigitizerPSD::~DigitizerPSD(){ diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 752f235..fc93fdc 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -88,7 +88,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2)); ///================= Open digitizers - TGTextButton *bOpenDigitizers = new TGTextButton(hframe,"Open Digitizers"); + bOpenDigitizers = new TGTextButton(hframe,"Open Digitizers"); bOpenDigitizers->Connect("Clicked()","MainWindow",this,"OpenDigitizers()"); hframe->AddFrame(bOpenDigitizers, uniLayoutHints); @@ -140,7 +140,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { // //HandleMenu(M_BOARD_SETTINGS); //HandleMenu(M_CH_SETTING_PHA); - HandleMenu(M_CH_SETTING_PSD); + //HandleMenu(M_CH_SETTING_PSD); } MainWindow::~MainWindow() { @@ -214,16 +214,9 @@ void MainWindow::HandleMenu(Int_t id){ ///========================= Board setting case M_BOARD_SETTINGS:{ - if( boardSetting == NULL ) { - boardSetting = new BoardSetting(gClient->GetRoot(), 600, 600, digi, nDigi); - boardSetting->Connect("LogMsg(char*)", "MainWindow", this, "LogMsg(char*)"); - boardSetting->Connect("Haha(Int_t)", "MainWindow", this, "OpenChannelSetting(Int_t)"); - }else{ - if ( boardSetting->IsOpen() == false ){ - boardSetting = new BoardSetting(gClient->GetRoot(), 600, 600, digi, nDigi); - //boardSetting->Connect("BdLogMsg(TString)", "MainWindow", this, "LogMsg(TString)"); - } - } + boardSetting = new BoardSetting(gClient->GetRoot(), 600, 600, digi, nDigi); + boardSetting->Connect("LogMsg(char*)", "MainWindow", this, "LogMsg(char*)"); + boardSetting->Connect("Haha(Int_t)", "MainWindow", this, "OpenChannelSetting(Int_t)"); }break; ///========================= Program setting @@ -287,27 +280,19 @@ void MainWindow::OpenDigitizers(){ digi = new Digitizer * [nDigi]; - //pha = new DigitizerPHA * [nPHA]; - //psd = new DigitizerPHA * [nPSD]; - // - //iPHA = 0; - //iPSD = 0; - for( int i = 0; i < nDigi; i++){ printf("------------ %d \n", i); - if( DPPType[i] == V1730_DPP_PSD_CODE ) { - digi[i] = new DigitizerPSD(boardID[i], portID[i]); - printf("Open as PSD\n"); - }else if( DPPType[i] == V1730_DPP_PHA_CODE ){ - digi[i] = new DigitizerPHA(boardID[i], portID[i]); - printf("Open as PHA\n"); - }else{ - digi[i] = new Digitizer(boardID[i], portID[i]); - printf("Open as Ordinary Digitizer\n"); - } + digi[i] = new Digitizer(boardID[i], portID[i], false, false); // TODO basic board program + LogMsg(Form("%2d, Serial number : %3d opened (%s, %s)", i, digi[i]->GetSerialNumber(), + digi[i]->GetDPPTypeString().c_str(), + digi[i]->GetModelName().c_str())); + digi[i]->CreateAndSaveSettingBinary("setting_" + to_string(digi[i]->GetSerialNumber()) + ".bin"); } + fMenuDigitizers->DisableEntry( M_DIGITIZER_OPEN); + bOpenDigitizers->SetEnabled(false); + } } @@ -341,15 +326,15 @@ void MainWindow::OpenChannelSetting(Int_t boardID){ printf("#### %s \n", __func__); - //if( digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE ){ - // channelSettingPHA = new ChannelSettingPHA(gClient->GetRoot(), 600, 600, digi, nDigi, boardID); - // channelSettingPHA->Connect("LogMsg(char*)", "MainWindow", this, "LogMsg(char*)"); - //} + if( digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE ){ + channelSettingPHA = new ChannelSettingPHA(gClient->GetRoot(), 600, 600, digi, nDigi, boardID); + channelSettingPHA->Connect("LogMsg(char*)", "MainWindow", this, "LogMsg(char*)"); + } - //if( digi[boardID]->GetDPPType() == V1730_DPP_PSD_CODE ){ + if( digi[boardID]->GetDPPType() == V1730_DPP_PSD_CODE ){ channelSettingPSD = new ChannelSettingPSD(gClient->GetRoot(), 600, 600, digi, nDigi, boardID); channelSettingPSD->Connect("LogMsg(char*)", "MainWindow", this, "LogMsg(char*)"); - //} + } } void MainWindow::LogMsg(char * msg){ diff --git a/FSUDAQ.h b/FSUDAQ.h index 27056b0..6f3a758 100644 --- a/FSUDAQ.h +++ b/FSUDAQ.h @@ -44,6 +44,8 @@ private: //TGTextButton *bStartRun; //TGTextButton *bStopRun; //TGTextButton *bFitTrace; + + TGTextButton *bOpenDigitizers; unsigned short nDigi; vector DPPType; diff --git a/boardSetting.cpp b/boardSetting.cpp index 4fcae3f..c0c2fc0 100644 --- a/boardSetting.cpp +++ b/boardSetting.cpp @@ -20,31 +20,6 @@ TString boardSettingName[NUM_BOARD_INFO] = { "Model", "AMC version" }; -Pixel_t BoardSetting::red = 0; -Pixel_t BoardSetting::blue = 0; - -TGNumberEntry * BoardSetting::boardIDEntry = NULL; -Digitizer ** BoardSetting::digi = NULL; -TGTextEntry * BoardSetting::txtACQStatus = NULL; -TGTextEntry * BoardSetting::txtACQEventReady = NULL; -TGTextEntry * BoardSetting::txtACQEventFull = NULL; -TGTextEntry * BoardSetting::txtACQClockSource = NULL; -TGTextEntry * BoardSetting::txtACQPLLLock = NULL; -TGTextEntry * BoardSetting::txtACQChDown = NULL; -TGTextEntry * BoardSetting::txtACQSIN = NULL; -TGTextEntry * BoardSetting::txtACQTRIGIN = NULL; -TGTextEntry * BoardSetting::txtACQBoardReady = NULL; -TGTextEntry * BoardSetting::txtACQTemp0 = NULL; -TGTextEntry * BoardSetting::txtACQTemp1 = NULL; -TGTextEntry * BoardSetting::txtACQTemp2 = NULL; -TGTextEntry * BoardSetting::txtACQTemp3 = NULL; - -TGTextEntry * BoardSetting::txtEventReady = NULL; -TGTextEntry * BoardSetting::txtBusError = NULL; -TGTextEntry * BoardSetting::txtVMEFIFO = NULL; - -bool BoardSetting::isOpened = false; - BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nBoard){ this->nDigi = nBoard; @@ -235,6 +210,11 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d bOpenChannelSetting->SetHeight(40); bOpenChannelSetting->Connect("Clicked()", "BoardSetting", this, "OpenChannelSetting()"); + TGTextButton * bUpdateStatus = new TGTextButton(hRow0, "Update Status"); hRow0->AddFrame(bUpdateStatus, new TGLayoutHints( kLHintsExpandX | kLHintsExpandY, 5, 0, 5, 0)); + bUpdateStatus->SetHeight(40); + bUpdateStatus->Connect("Clicked()", "BoardSetting", this, "ReadStatus()"); + + TGHorizontalFrame * hRow1 = new TGHorizontalFrame(vframe); vframe->AddFrame(hRow1, new TGLayoutHints( kLHintsExpandX)); {///========= Board Configure @@ -419,9 +399,7 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d bSWClockSync = new TGTextButton(hAcqCtrl_c, "Send Software Clock Sync Signal"); hAcqCtrl_c->AddFrame(bSWClockSync, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); bSWClockSync->Connect("Clicked()", "BoardSetting", this, "SendSoftwareClockSyncSignal()"); bSWClockSync->Resize(250, 20); - - - + } {///========= Trigger Configure @@ -694,10 +672,8 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d isOpened = true; ///Setup thread - readStatusThread = new TThread("readStatus", ReadStatus, (void *) 1); - if( digi != NULL ) readStatusThread->Run(); - - isOpened = true; + ///readStatusThread = new TThread("readStatus", ReadStatus, (void *) 1); + ///if( digi != NULL ) readStatusThread->Run(); } BoardSetting::~BoardSetting(){ @@ -706,10 +682,10 @@ BoardSetting::~BoardSetting(){ printf("close BoardSetting window\n"); - for( int i = 0; i < nDigi; i++) digi[i] = 0; - + //for( int i = 0; i < nDigi; i++) digi[i] = 0; //pha = 0; //psd = 0; + //delete readStatusThread; fMain->Cleanup(); delete fMain; @@ -720,64 +696,74 @@ void BoardSetting::LogMsg(TString msg){ Emit("LogMsg(char*)", msg.Data()); } -void * BoardSetting::ReadStatus(void * ptr){ - if( digi == NULL ) return 0; +void BoardSetting::ReadStatus(){ + if( digi == NULL ) return; - int pauseTime = 1000; /// msec int boardID = boardIDEntry->GetNumber(); - if( digi[boardID]->GetDPPType() == V1730_DPP_PHA_CODE ) { + /// ACQ Status + digi[boardID]->PrintRegister(Register::DPP::AcquisitionStatus, "ACQ Status"); + uint32_t temp = digi[boardID]->ReadRegister(Register::DPP::AcquisitionStatus); - //pha = dynamic_cast (digi[boardID]); - - //while( digi[boardID]->isACQRunning() == false ){ - while( isOpened ){ - - printf("=========== %s for PHA\n", __func__); - /// ACQ Status - uint32_t temp = digi[boardID]->ReadRegister(Register::DPP::AcquisitionStatus); - - txtACQStatus ->SetText( ((temp >> 2) & 0x1) == 0 ? "ACQ is stopped" : "ACQ is Running", false); txtACQStatus->SetTextColor( ((temp >> 2) & 0x1) == 0 ? 1 : blue); - txtACQEventReady ->SetText( ((temp >> 3) & 0x1) == 0 ? "no Event" : "Has Events", false); txtACQEventReady->SetTextColor( ((temp >> 3) & 0x1) == 0 ? 1 : blue); - txtACQEventFull ->SetText( ((temp >> 4) & 0x1) == 0 ? "no channel FULL" : "a channel FULL", false); txtACQEventFull->SetTextColor( ((temp >> 4) & 0x1) == 0 ? 1 : red); - txtACQClockSource->SetText( ((temp >> 5) & 0x1) == 0 ? "Internal Clock" : "External Clock", false); txtACQClockSource->SetTextColor( ((temp >> 5) & 0x1) == 0 ? 1 : blue); - txtACQPLLLock ->SetText( ((temp >> 7) & 0x1) == 0 ? "PLL no lock" : "PLL locked", false); txtACQPLLLock->SetTextColor( ((temp >> 7) & 0x1) == 0 ? 1 : blue); - txtACQBoardReady ->SetText( ((temp >> 8) & 0x1) == 0 ? "Board NOT Ready (PLL & ADCs are NOT sync)" : "Board Ready (PLL & ADCs are sync)", false); - txtACQBoardReady->SetTextColor( ((temp >> 8) & 0x1) == 0 ? red : 1); - txtACQChDown ->SetText( ((temp >> 19) & 0x1) == 0 ? "Channels are ON" : "Channels ShutDown", false); - txtACQChDown->SetTextColor( ((temp >> 19) & 0x1) == 0 ? 1 : red); - txtACQSIN ->SetText( ((temp >> 15) & 0x1) == 0 ? "S-IN = 0" : "S-IN = 1", false); txtACQSIN->SetTextColor( ((temp >> 15) & 0x1) == 0 ? 1 : blue); - txtACQTRIGIN ->SetText( ((temp >> 16) & 0x1) == 0 ? "TRG-IN = 0" : "TRG-IN = 1", false); txtACQTRIGIN->SetTextColor( ((temp >> 16) & 0x1) == 0 ? 1 : blue); - - txtACQTemp0->SetText( ((temp >> 20) & 0x1) == 0 ? "< 70" : "> 70", false); txtACQTemp0->SetTextColor( ((temp >> 20) & 0x1) == 0 ? 1 : red); - txtACQTemp1->SetText( ((temp >> 21) & 0x1) == 0 ? "< 70" : "> 70", false); txtACQTemp1->SetTextColor( ((temp >> 21) & 0x1) == 0 ? 1 : red); - txtACQTemp2->SetText( ((temp >> 22) & 0x1) == 0 ? "< 70" : "> 70", false); txtACQTemp2->SetTextColor( ((temp >> 22) & 0x1) == 0 ? 1 : red); - txtACQTemp3->SetText( ((temp >> 23) & 0x1) == 0 ? "< 70" : "> 70", false); txtACQTemp3->SetTextColor( ((temp >> 23) & 0x1) == 0 ? 1 : red); - - /// Redaout Status - temp = digi[boardID]->ReadRegister(Register::DPP::ReadoutStatus); - if( (temp & 0x1) == 1 ){ - txtEventReady->SetText( "Event Ready" , false); txtEventReady->SetTextColor(blue); - }else{ - txtEventReady->SetText( "No Data Ready" , false); txtEventReady->SetTextColor(red); - } - - if( (( temp >> 2 ) & 0x1 ) == 0 ){ - txtBusError->SetText( "no Bus Error", false ); txtBusError->SetTextColor(blue); - }else{ - txtBusError->SetText( "Bus Error", false ); txtBusError->SetTextColor(red); - } - - if( (( temp >> 3 ) & 0x1 ) == 0 ){ - txtVMEFIFO->SetText( "VME FIFO NOT EMPTY", false ); txtVMEFIFO->SetTextColor(red); - }else{ - txtVMEFIFO->SetText( "VME FIFO EMPTY", false ); txtVMEFIFO->SetTextColor(red); - } - - usleep(pauseTime*1000); - } - + txtACQStatus ->SetText( ((temp >> 2) & 0x1) == 0 ? "ACQ is stopped" : "ACQ is Running", false); txtACQStatus->SetTextColor( ((temp >> 2) & 0x1) == 0 ? 1 : blue); + txtACQEventReady ->SetText( ((temp >> 3) & 0x1) == 0 ? "no Event" : "Has Events", false); txtACQEventReady->SetTextColor( ((temp >> 3) & 0x1) == 0 ? 1 : blue); + txtACQEventFull ->SetText( ((temp >> 4) & 0x1) == 0 ? "no channel FULL" : "a channel FULL", false); txtACQEventFull->SetTextColor( ((temp >> 4) & 0x1) == 0 ? 1 : red); + txtACQClockSource->SetText( ((temp >> 5) & 0x1) == 0 ? "Internal Clock" : "External Clock", false); txtACQClockSource->SetTextColor( ((temp >> 5) & 0x1) == 0 ? 1 : blue); + txtACQPLLLock ->SetText( ((temp >> 7) & 0x1) == 0 ? "PLL no lock" : "PLL locked", false); txtACQPLLLock->SetTextColor( ((temp >> 7) & 0x1) == 0 ? 1 : blue); + txtACQBoardReady ->SetText( ((temp >> 8) & 0x1) == 0 ? "Board NOT Ready (PLL & ADCs are NOT sync)" : "Board Ready (PLL & ADCs are sync)", false); + txtACQBoardReady->SetTextColor( ((temp >> 8) & 0x1) == 0 ? red : 1); + txtACQChDown ->SetText( ((temp >> 19) & 0x1) == 0 ? "Channels are ON" : "Channels ShutDown", false); + txtACQChDown->SetTextColor( ((temp >> 19) & 0x1) == 0 ? 1 : red); + txtACQSIN ->SetText( ((temp >> 15) & 0x1) == 0 ? "S-IN = 0" : "S-IN = 1", false); txtACQSIN->SetTextColor( ((temp >> 15) & 0x1) == 0 ? 1 : blue); + txtACQTRIGIN ->SetText( ((temp >> 16) & 0x1) == 0 ? "TRG-IN = 0" : "TRG-IN = 1", false); txtACQTRIGIN->SetTextColor( ((temp >> 16) & 0x1) == 0 ? 1 : blue); + + txtACQTemp0->SetText( ((temp >> 20) & 0x1) == 0 ? "< 70" : "> 70", false); txtACQTemp0->SetTextColor( ((temp >> 20) & 0x1) == 0 ? 1 : red); + txtACQTemp1->SetText( ((temp >> 21) & 0x1) == 0 ? "< 70" : "> 70", false); txtACQTemp1->SetTextColor( ((temp >> 21) & 0x1) == 0 ? 1 : red); + txtACQTemp2->SetText( ((temp >> 22) & 0x1) == 0 ? "< 70" : "> 70", false); txtACQTemp2->SetTextColor( ((temp >> 22) & 0x1) == 0 ? 1 : red); + txtACQTemp3->SetText( ((temp >> 23) & 0x1) == 0 ? "< 70" : "> 70", false); txtACQTemp3->SetTextColor( ((temp >> 23) & 0x1) == 0 ? 1 : red); + + /// Redaout Status + digi[boardID]->PrintRegister(Register::DPP::ReadoutStatus, "Readout Status"); + temp = digi[boardID]->ReadRegister(Register::DPP::ReadoutStatus); + if( (temp & 0x1) == 1 ){ + txtEventReady->SetText( "Event Ready" , false); txtEventReady->SetTextColor(blue); + }else{ + txtEventReady->SetText( "No Data Ready" , false); txtEventReady->SetTextColor(red); } + + if( (( temp >> 2 ) & 0x1 ) == 0 ){ + txtBusError->SetText( "no Bus Error", false ); txtBusError->SetTextColor(blue); + }else{ + txtBusError->SetText( "Bus Error", false ); txtBusError->SetTextColor(red); + } + + if( (( temp >> 3 ) & 0x1 ) == 0 ){ + txtVMEFIFO->SetText( "VME FIFO NOT EMPTY", false ); txtVMEFIFO->SetTextColor(red); + }else{ + txtVMEFIFO->SetText( "VME FIFO EMPTY", false ); txtVMEFIFO->SetTextColor(red); + } + + ///================ Board Failure Status + digi[boardID]->PrintRegister(Register::DPP::BoardFailureStatus, "Board Fail"); + temp = digi[boardID]->ReadRegister(Register::DPP::BoardFailureStatus, -1, "Board Fail"); + if( ((temp >> 4) & 0x1) == 0 ) { + enPLLStatus->SetText( "OK" , false); enPLLStatus->SetTextColor(1); + }else{ + enPLLStatus->SetText( "Lost Lock" , false); enPLLStatus->SetTextColor(red); + } + + if( ((temp >> 5) & 0x1) == 0 ) { + enTempStatus->SetText( "OK" , false); enTempStatus->SetTextColor(1); + }else{ + enTempStatus->SetText( "Failure" , false); enTempStatus->SetTextColor(red); + } + + if( ((temp >> 6) & 0x1) == 0 ) { + enADCPwrStatus->SetText( "OK", false); enADCPwrStatus->SetTextColor(1); + }else{ + enADCPwrStatus->SetText( "Failure", false); enADCPwrStatus->SetTextColor(red); + } + } void BoardSetting::ChangeBoard(){ @@ -789,7 +775,6 @@ void BoardSetting::ChangeBoard(){ } int boardID = boardIDEntry->GetNumber(); - digi[boardID]->PrintBoard(); for( int i = 0; i < NUM_BOARD_INFO; i++){ switch (i) { @@ -821,28 +806,6 @@ void BoardSetting::ChangeBoard(){ } } - ///================ Board Failure Status - unsigned int tempBits; - - tempBits = digi[boardID]->ReadRegister(Register::BoardFailureStatus); - if( (tempBits & 0x10) == 0 ) { - enPLLStatus->SetText( "OK" , false); enPLLStatus->SetTextColor(1); - }else{ - enPLLStatus->SetText( "Lost Lock" , false); enPLLStatus->SetTextColor(red); - } - - if( (tempBits & 0x20) == 0 ) { - enTempStatus->SetText( "OK (<70)" , false); enTempStatus->SetTextColor(1); - }else{ - enTempStatus->SetText( "Failure" , false); enTempStatus->SetTextColor(red); - } - - if( (tempBits & 0x40) == 0 ) { - enADCPwrStatus->SetText( "OK", false); enADCPwrStatus->SetTextColor(1); - }else{ - enADCPwrStatus->SetText( "Failure", false); enADCPwrStatus->SetTextColor(red); - } - cbAggOrg->Select( digi[boardID]->ReadRegister(Register::DPP::AggregateOrganization) , false); numAggBLT->SetNumber( digi[boardID]->ReadRegister(Register::DPP::MaxAggregatePerBlockTransfer) , false); cbFanCtrl->Select( digi[boardID]->ReadRegister(Register::DPP::FanSpeedControl) , false); @@ -852,10 +815,12 @@ void BoardSetting::ChangeBoard(){ cbAnaMonitor->Select( digi[boardID]->ReadRegister(Register::DPP::AnalogMonitorMode) & 0x7 , false); numBufferOccpGain->SetNumber( digi[boardID]->ReadRegister(Register::DPP::BufferOccupancyGain) & 0xf, false); - + + ReadStatus(); + /// ACQ Control //digi[boardID]->PrintRegister(Register::DPP::AcquisitionControl, "AcquisitionControl"); - tempBits = digi[boardID]->ReadRegister(Register::DPP::AcquisitionControl); + uint32_t tempBits = digi[boardID]->ReadRegister(Register::DPP::AcquisitionControl); cbAcqMode->Select( tempBits & 0x3 , false); bAcqArm->SetState( ((tempBits >> 2) & 0x1) ? kButtonDown : kButtonUp, false); cbPLLref->Select( ((tempBits >> 6) & 0x1), false); diff --git a/boardSetting.h b/boardSetting.h index cf1b553..2a16e97 100644 --- a/boardSetting.h +++ b/boardSetting.h @@ -22,14 +22,14 @@ class BoardSetting{ private: TGMainFrame * fMain; - static Pixel_t red, blue; + Pixel_t red, blue; - static TGNumberEntry * boardIDEntry; + TGNumberEntry * boardIDEntry; TGTextEntry * entry[NUM_BOARD_INFO]; int nDigi; - static Digitizer ** digi; + Digitizer ** digi; /// board failure status TGTextEntry * enPLLStatus; @@ -61,19 +61,19 @@ class BoardSetting{ TGNumberEntry * numRunStartStopDelay; /// ACQ Status - static TGTextEntry * txtACQStatus; - static TGTextEntry * txtACQEventReady; - static TGTextEntry * txtACQEventFull; - static TGTextEntry * txtACQClockSource; - static TGTextEntry * txtACQPLLLock; - static TGTextEntry * txtACQChDown; - static TGTextEntry * txtACQSIN; - static TGTextEntry * txtACQTRIGIN; - static TGTextEntry * txtACQBoardReady; - static TGTextEntry * txtACQTemp0; - static TGTextEntry * txtACQTemp1; - static TGTextEntry * txtACQTemp2; - static TGTextEntry * txtACQTemp3; + TGTextEntry * txtACQStatus; + TGTextEntry * txtACQEventReady; + TGTextEntry * txtACQEventFull; + TGTextEntry * txtACQClockSource; + TGTextEntry * txtACQPLLLock; + TGTextEntry * txtACQChDown; + TGTextEntry * txtACQSIN; + TGTextEntry * txtACQTRIGIN; + TGTextEntry * txtACQBoardReady; + TGTextEntry * txtACQTemp0; + TGTextEntry * txtACQTemp1; + TGTextEntry * txtACQTemp2; + TGTextEntry * txtACQTemp3; /// Trigger control TGCheckButton * cbGbTRGMskCh[8]; @@ -118,13 +118,12 @@ class BoardSetting{ TGCheckButton * bEnableExtendedBlockTransfer; /// Redaout Status - static TGTextEntry * txtEventReady; - static TGTextEntry * txtBusError; - static TGTextEntry * txtVMEFIFO; + TGTextEntry * txtEventReady; + TGTextEntry * txtBusError; + TGTextEntry * txtVMEFIFO; + + bool isOpened; - TThread * readStatusThread; - static bool isOpened; - static void * ReadStatus(void * ptr); /// thread. public: BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nBoard); @@ -134,12 +133,14 @@ class BoardSetting{ void CloseWindow() { delete this;} void ChangeBoard(); + + void ReadStatus(); + ///=== Button void ResetSettingToDefault(); void ClearBuffer(); void OpenChannelSetting(); - ///=== Board Configure void SetBoardConfiguration(); diff --git a/test.cpp b/test.cpp index 9e3302d..a95a768 100644 --- a/test.cpp +++ b/test.cpp @@ -5,18 +5,22 @@ int main(int argc, char* argv[]){ + + /**************/ - const int nBoard = 1; + + const int nBoard = 3; Digitizer **dig = new Digitizer *[nBoard]; for( int i = 0 ; i < nBoard; i++){ int board = i % 3; int port = i/3; - dig[i] = new DigitizerPHA(board, port, true); + dig[i] = new Digitizer(board, port, false, true); dig[i]->CreateAndSaveSettingBinary("setting_" + to_string(dig[i]->GetSerialNumber()) + ".bin"); //dig[i].OpenSettingBinary("setting_" + to_string(dig[i].GetSerialNumber()) + ".bin"); } + /* DigitizerPHA * pha = dynamic_cast (dig[0]); pha->ProgramBoard(); pha->PrintBoardConfiguration();