diff --git a/ClassData.h b/ClassData.h index ee4c688..d54486f 100644 --- a/ClassData.h +++ b/ClassData.h @@ -102,9 +102,9 @@ inline void Data::AllocateMemory(){ delete buffer; //TODO calculate Suitable buffer size - BufferSize = 1000000; /// 1M byte + BufferSize = 1* 1024* 1024; /// 10M byte buffer = (char *) malloc( BufferSize); - printf("Allocated %d byte for buffer \n", BufferSize); + printf("Allocated %d (%lu) byte for buffer \n", BufferSize, sizeof(buffer)); ///for( int i = 0 ; i < MaxNChannels ; i++ ) Events[i] = (CAEN_DGTZ_DPP_PHA_Event_t *) malloc( BufferSize); ///printf("Allocated %d byte for Events for each channel \n", BufferSize); diff --git a/ClassDigitizer.cpp b/ClassDigitizer.cpp index 222692b..3f27e0f 100644 --- a/ClassDigitizer.cpp +++ b/ClassDigitizer.cpp @@ -363,24 +363,35 @@ void Digitizer::WriteRegister(uint32_t registerAddress, uint32_t value, int ch ) if( ch < 0 ){ for( int i = 0; i < NChannel/2; i++){ ret = CAEN_DGTZ_WriteRegister(handle, registerAddress + 4*i, value); - SaveSettingToFile(registerAddress, value, i); + ReadRegister(registerAddress, i); } }else{ ret = CAEN_DGTZ_WriteRegister(handle, registerAddress + 4*(ch/2), value); - SaveSettingToFile(registerAddress, value, ch); + ReadRegister(registerAddress, ch); } }else if( registerAddress < 0x8000){ if( ch < 0 ) { ret = CAEN_DGTZ_WriteRegister(handle, registerAddress + 0x7000, value); - for( int i = 0; i < NChannel; i++) SaveSettingToFile(value, registerAddress, i); + for( int i = 0; i < NChannel; i++) ReadRegister(registerAddress, i); }else{ ret = CAEN_DGTZ_WriteRegister(handle, registerAddress + (ch<<8), value); - SaveSettingToFile(registerAddress, value, ch); + ReadRegister(registerAddress, ch); } }else{ ret = CAEN_DGTZ_WriteRegister(handle, registerAddress, value); - SaveSettingToFile(registerAddress, value); + ReadRegister(registerAddress); } + + /// for grouped address + if( registerAddress == Register::DPP::RecordLength_G || + registerAddress == Register::DPP::NumberEventsPerAggregate_G || + registerAddress == Register::DPP::PHA::DPPAlgorithmControl2_G || + registerAddress == Register::DPP::PSD::DPPAlgorithmControl2_G || + registerAddress == Register::DPP::TriggerValidationMask_G + ){ + ReadRegister(registerAddress, ch + (ch%2 == 1 ? -1 : +1)); + } + ErrorMsg("WriteRegister:" + std::to_string(registerAddress)); } @@ -400,7 +411,7 @@ uint32_t Digitizer::ReadRegister(uint32_t registerAddress, int ch, string str ){ uint32_t data[1]; ret = CAEN_DGTZ_ReadRegister(handle, actualAddress, data); - SaveSettingToFile(registerAddress, data[0], ch); + if( ret == 0 ) SaveSettingToFile(registerAddress, data[0], ch); ErrorMsg("ReadRegister:" + std::to_string(registerAddress)); if( str != "" ) printf("%s : 0x%04X(0x%04X) is 0x%08X \n", str.c_str(), actualAddress, registerAddress, data[0]); return data[0]; @@ -649,6 +660,9 @@ int Digitizer::ProgramPHABoard(){ printf("End of program board and channels\n"); + isSettingFilledinMemeory = false; + FillAllSettings(); + return ret; } diff --git a/FSUDAQ.cpp b/FSUDAQ.cpp index 2e1345b..32d18a6 100644 --- a/FSUDAQ.cpp +++ b/FSUDAQ.cpp @@ -222,8 +222,8 @@ 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_REGISTER_SETTING); - HandleMenu(M_TRIGGER_SUMMARY); + HandleMenu(M_REGISTER_SETTING); + //HandleMenu(M_TRIGGER_SUMMARY); gAnaTrace1 = new TGraph(); gAnaTrace2 = new TGraph(); @@ -403,6 +403,7 @@ void MainWindow::OpenDigitizers(){ fMenuDigitizers->DisableEntry( M_DIGITIZER_OPEN); fMenuDigitizers->EnableEntry( M_LOAD_SETTINGS); fMenuDigitizers->EnableEntry( M_TRIGGER_SUMMARY); + fMenuDigitizers->EnableEntry( M_REGISTER_SETTING); bOpenDigitizers->SetEnabled(false); bStartRun->SetEnabled(true); @@ -433,8 +434,9 @@ void MainWindow::ChangeBoard(){ void MainWindow::GoodBye(){ - printf("----- bye bye ---- \n"); + for( int i = 0; i < nDigi; i++) digi[i]->CloseDigitizer(); + printf("----- bye bye ---- \n"); gApplication->Terminate(0); } @@ -444,6 +446,7 @@ void MainWindow::StartRun(){ if( digi == NULL) return; for( int bd = 0; bd < nDigi; bd++){ + hChannel[bd]->Reset(); for( int ch = 0; ch < MaxNChannels; ch++){ hEnergy[bd][ch]->Reset(); } diff --git a/boardSetting.cpp b/boardSetting.cpp index a0b289b..122be11 100644 --- a/boardSetting.cpp +++ b/boardSetting.cpp @@ -695,11 +695,14 @@ 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; + delete boardIDEntry; + for(int i = 0; i < NUM_BOARD_INFO; i++) delete entry[i]; + fMain->Cleanup(); delete fMain; @@ -716,7 +719,7 @@ void BoardSetting::ReadStatus(){ /// ACQ Status ///digi[boardID]->PrintRegister(Register::DPP::AcquisitionStatus, "ACQ Status"); - uint32_t temp = digi[boardID]->ReadRegister(Register::DPP::AcquisitionStatus_R); + uint32_t temp = digi[boardID]->GetSettingFromMemory(Register::DPP::AcquisitionStatus_R); 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); @@ -737,7 +740,7 @@ void BoardSetting::ReadStatus(){ /// Redaout Status ///digi[boardID]->PrintRegister(Register::DPP::ReadoutStatus, "Readout Status"); - temp = digi[boardID]->ReadRegister(Register::DPP::ReadoutStatus_R); + temp = digi[boardID]->GetSettingFromMemory(Register::DPP::ReadoutStatus_R); if( (temp & 0x1) == 1 ){ txtEventReady->SetText( "Event Ready" , false); txtEventReady->SetTextColor(blue); }else{ @@ -758,7 +761,7 @@ void BoardSetting::ReadStatus(){ ///================ Board Failure Status ///digi[boardID]->PrintRegister(Register::DPP::BoardFailureStatus, "Board Fail"); - temp = digi[boardID]->ReadRegister(Register::DPP::BoardFailureStatus_R); + temp = digi[boardID]->GetSettingFromMemory(Register::DPP::BoardFailureStatus_R); if( ((temp >> 4) & 0x1) == 0 ) { enPLLStatus->SetText( "OK" , false); enPLLStatus->SetTextColor(1); }else{ @@ -819,36 +822,36 @@ void BoardSetting::ChangeBoard(){ } } - cbAggOrg->Select( digi[boardID]->ReadRegister(Register::DPP::AggregateOrganization) , false); - numAggBLT->SetNumber( digi[boardID]->ReadRegister(Register::DPP::MaxAggregatePerBlockTransfer) , false); + cbAggOrg->Select( digi[boardID]->GetSettingFromMemory(Register::DPP::AggregateOrganization) , false); + numAggBLT->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::MaxAggregatePerBlockTransfer) , false); if( digi[boardID]->GetNChannel() == 8 ){ ///FAN Speed control only for desktop version cbFanCtrl->SetEnabled(true); - cbFanCtrl->Select( digi[boardID]->ReadRegister(Register::DPP::FanSpeedControl) , false); + cbFanCtrl->Select( digi[boardID]->GetSettingFromMemory(Register::DPP::FanSpeedControl) , false); }else{ cbFanCtrl->SetEnabled(false); cbFanCtrl->Select( 0 , false); } - numRunStartStopDelay->SetNumber( digi[boardID]->ReadRegister(Register::DPP::RunStartStopDelay), false); - bEnableExtTRG->SetState( (digi[boardID]->ReadRegister(Register::DPP::DisableExternalTrigger) & 0x1) ? kButtonDown : kButtonUp, false); - ///numExtendVetoDelay->SetNumber( digi[boardID]->ReadRegister(Register::DPP::ExtendedVetoDelay) , false); + numRunStartStopDelay->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::RunStartStopDelay), false); + bEnableExtTRG->SetState( (digi[boardID]->GetSettingFromMemory(Register::DPP::DisableExternalTrigger) & 0x1) ? kButtonDown : kButtonUp, false); + ///numExtendVetoDelay->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::ExtendedVetoDelay) , false); - cbAnaMonitor->Select( digi[boardID]->ReadRegister(Register::DPP::AnalogMonitorMode) & 0x7 , false); - numBufferOccpGain->SetNumber( digi[boardID]->ReadRegister(Register::DPP::BufferOccupancyGain) & 0xf, false); + cbAnaMonitor->Select( digi[boardID]->GetSettingFromMemory(Register::DPP::AnalogMonitorMode) & 0x7 , false); + numBufferOccpGain->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::BufferOccupancyGain) & 0xf, false); ReadStatus(); /// ACQ Control //digi[boardID]->PrintRegister(Register::DPP::AcquisitionControl, "AcquisitionControl"); - uint32_t tempBits = digi[boardID]->ReadRegister(Register::DPP::AcquisitionControl); + uint32_t tempBits = digi[boardID]->GetSettingFromMemory(Register::DPP::AcquisitionControl); cbAcqMode->Select( tempBits & 0x3 , false); bAcqArm->SetState( ((tempBits >> 2) & 0x1) ? kButtonDown : kButtonUp, false); cbPLLref->Select( ((tempBits >> 6) & 0x1), false); /// Global Trigger Mask - tempBits = digi[boardID]->ReadRegister(Register::DPP::GlobalTriggerMask); + tempBits = digi[boardID]->GetSettingFromMemory(Register::DPP::GlobalTriggerMask); for( int i = 0; i < 8; i++){ cbGbTRGMskCh[i]->SetState( ((tempBits >> i ) & 0x1) == 0 ? kButtonUp : kButtonDown , false); } @@ -858,7 +861,7 @@ void BoardSetting::ChangeBoard(){ bGLBSoftwareTrigger->SetState( (( tempBits >> 31) & 0x1 ) == 0 ? kButtonUp : kButtonDown, false); /// Trigger Validation Mask - tempBits = digi[boardID]->ReadRegister(Register::DPP::TriggerValidationMask_G); + tempBits = digi[boardID]->GetSettingFromMemory(Register::DPP::TriggerValidationMask_G); for( int i = 0; i < 8; i++){ cbTRGValMskCh[i]->SetState( ((tempBits >> i ) & 0x1) == 0 ? kButtonUp : kButtonDown , false); } @@ -868,7 +871,7 @@ void BoardSetting::ChangeBoard(){ bTRGSoftwareTrigger->SetState( (( tempBits >> 31) & 0x1 ) == 0 ? kButtonUp : kButtonDown, false); /// Front Panel TRG-OUT Enable Mask , PHA = PSD only for bit[19:0] - tempBits = digi[boardID]->ReadRegister(Register::DPP::FrontPanelTRGOUTEnableMask); + tempBits = digi[boardID]->GetSettingFromMemory(Register::DPP::FrontPanelTRGOUTEnableMask); for( int i = 0; i < 8; i++){ cbTRGOUTMskCh[i]->SetState( ((tempBits >> i ) & 0x1) == 0 ? kButtonUp : kButtonDown, false ); } @@ -878,7 +881,7 @@ void BoardSetting::ChangeBoard(){ bTRGOUTSoftwareTrigger->SetState( (( tempBits >> 30) & 0x1 ) == 0 ? kButtonUp : kButtonDown, false); /// Front Panel I/O Control, PHA = PSD only for bit[19:0] - tempBits = digi[boardID]->ReadRegister(Register::DPP::FrontPanelIOControl); + tempBits = digi[boardID]->GetSettingFromMemory(Register::DPP::FrontPanelIOControl); cbLEMOIO->Select( tempBits & 0x1 , false); if( ((tempBits >> 1) & 0x1 ) == 0 ) { cbTRGOUTmode->Select( 2 , false); @@ -889,7 +892,7 @@ void BoardSetting::ChangeBoard(){ cbTRGINMezzanines->Select( (tempBits >> 11) & 0x1 , false); /// Readout Control - tempBits = digi[boardID]->ReadRegister(Register::DPP::ReadoutControl); + tempBits = digi[boardID]->GetSettingFromMemory(Register::DPP::ReadoutControl); cbVMEInterrupLevel->Select( tempBits & 0x3 , false); bOpticalLinkInterrupt->SetState( (( tempBits >> 3 ) & 0x1 ) == 0 ? kButtonUp : kButtonDown, false) ; bEventAligned->SetState( (( tempBits >> 4 ) & 0x1 ) == 0 ? kButtonUp : kButtonDown, false) ; @@ -939,7 +942,7 @@ void BoardSetting::ChangeBoard(){ /// Board Configuration //digi[boardID]->PrintRegister(Register::DPP::BoardConfiguration, "BoardConfiguration"); - tempBits = digi[boardID]->ReadRegister(Register::DPP::BoardConfiguration); + tempBits = digi[boardID]->GetSettingFromMemory(Register::DPP::BoardConfiguration); bAutoDataFlush->SetState( (tempBits & 0x1) ? kButtonDown : kButtonUp, false); bDecimateWF->SetState( ((tempBits >> 1) & 0x1) ? kButtonDown : kButtonUp, false ); @@ -997,7 +1000,7 @@ void BoardSetting::ChangeBoard(){ cbDP2->AddEntry("Baseline freeze", 6); cbDP2->AddEntry("Trigger", 7); - tempBits = digi[boardID]->ReadRegister(Register::DPP::BoardConfiguration); + tempBits = digi[boardID]->GetSettingFromMemory(Register::DPP::BoardConfiguration); bAutoDataFlush->SetState( (tempBits & 0x1) ? kButtonDown : kButtonUp, false); bTrigPropa->SetState( ((tempBits >> 2) & 0x1) ? kButtonDown : kButtonUp, false ); @@ -1323,7 +1326,7 @@ void BoardSetting::ReadData(){ if( digi == NULL ) return; int boardID = boardIDEntry->GetNumber(); - uint32_t temp = digi[boardID]->ReadRegister(Register::DPP::ReadoutStatus_R); + uint32_t temp = digi[boardID]->GetSettingFromMemory(Register::DPP::ReadoutStatus_R); if( (temp & 0x1) == 0 ) { printf("No data. \n"); return; diff --git a/channelSettingPHA.cpp b/channelSettingPHA.cpp index 5d88172..3def0f4 100644 --- a/channelSettingPHA.cpp +++ b/channelSettingPHA.cpp @@ -115,6 +115,7 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi TGLabel * lbEventAgg = new TGLabel(vfInput1, "Events / Aggregate"); vfInput1->AddFrame(lbEventAgg, layoutHintsR); numEventAgg = new TGNumberEntry(vfInput2, 512, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); vfInput2->AddFrame(numEventAgg, layoutHints); numEventAgg->Resize(width, 20); + numEventAgg->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 511); numEventAgg->Connect("Modified()", "ChannelSettingPHA", this, "SetEventAggregate()"); ///const uint32_t ChannelDCOffset = 0x1098; /// R/W @@ -491,29 +492,29 @@ void ChannelSettingPHA::ChangeCh(){ LogMsg(Form("Read Channel %d Setting", (int)chIDEntry->GetNumber())); 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); - numPreTrigger->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PreTrigger, ch) * 4 * ch2ns, false); - numEventAgg->SetNumber( digi[boardID]->ReadRegister(Register::DPP::NumberEventsPerAggregate_G, ch), false); + 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]->ReadRegister(Register::DPP::ChannelDCOffset, ch); + uint32_t temp = digi[boardID]->GetSettingFromMemory(Register::DPP::ChannelDCOffset, ch); numDCOffset->SetNumber( 1.0 - temp * 1.0/0xFFFF , false); - eTemp->SetText(Form("%d C", digi[boardID]->ReadRegister(Register::DPP::ChannelADCTemperature_R, ch)), false); + eTemp->SetText(Form("%d C", digi[boardID]->GetSettingFromMemory(Register::DPP::ChannelADCTemperature_R, ch)), false); - numTriggerThreshold->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::TriggerThreshold, ch), false); - numTriggerHoldOff ->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::TriggerHoldOffWidth, ch) * 4 * ch2ns, false); - cbTriggerSmoothing ->Select( digi[boardID]->ReadRegister(Register::DPP::PHA::RCCR2SmoothingFactor, ch), false); - numInputRiseTime ->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::InputRiseTime, ch) * 4 * ch2ns, false); - numRiseTimeValidWin->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::RiseTimeValidationWindow, ch) * ch2ns, false); + numTriggerThreshold->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::PHA::TriggerThreshold, ch), false); + numTriggerHoldOff ->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::PHA::TriggerHoldOffWidth, ch) * 4 * ch2ns, false); + cbTriggerSmoothing ->Select( digi[boardID]->GetSettingFromMemory(Register::DPP::PHA::RCCR2SmoothingFactor, ch), false); + numInputRiseTime ->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::PHA::InputRiseTime, ch) * 4 * ch2ns, false); + numRiseTimeValidWin->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::PHA::RiseTimeValidationWindow, ch) * ch2ns, false); - numTrapRiseTime->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::TrapezoidRiseTime, ch) * 4 * ch2ns, false); - numTrapFlatTop->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::TrapezoidFlatTop, ch) * 4 * ch2ns, false); - numDecay->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::DecayTime, ch) * 4 * ch2ns, false); - numPeaking->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::PeakingTime, ch) * 4 * ch2ns, false); - numPeakHoldOff->SetNumber( digi[boardID]->ReadRegister(Register::DPP::PHA::PeakHoldOff, ch) * 4 * ch2ns, false); + numTrapRiseTime->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::PHA::TrapezoidRiseTime, ch) * 4 * ch2ns, false); + numTrapFlatTop->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::PHA::TrapezoidFlatTop, ch) * 4 * ch2ns, false); + numDecay->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::PHA::DecayTime, ch) * 4 * ch2ns, false); + numPeaking->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::PHA::PeakingTime, ch) * 4 * ch2ns, false); + numPeakHoldOff->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::PHA::PeakHoldOff, ch) * 4 * ch2ns, false); - temp = digi[boardID]->ReadRegister(Register::DPP::DPPAlgorithmControl, ch); + temp = digi[boardID]->GetSettingFromMemory(Register::DPP::DPPAlgorithmControl, ch); numTrapScale->SetNumber( temp & 0x3F, false ); cbDecimation->Select( ( (temp >> 8) & 0x3), false); cbDecimationGain->Select( ( (temp >> 10) & 0x3), false); @@ -525,7 +526,7 @@ void ChannelSettingPHA::ChangeCh(){ cbRollOver->Select( ( (temp >> 26) & 0x1), false); cbPileUp->Select( ( (temp >> 27) & 0x1), false); - temp = digi[boardID]->ReadRegister(Register::DPP::PHA::DPPAlgorithmControl2_G, ch); + temp = digi[boardID]->GetSettingFromMemory(Register::DPP::PHA::DPPAlgorithmControl2_G, ch); if( (((temp >> 2)) & 0x1 ) == 1 ){ cbLocalShapedTrigger->Select( (temp & 0x3), false); }else{ @@ -687,8 +688,6 @@ void ChannelSettingPHA::ChangeAStep(TGNumberEntry * numEntry, unsigned short ste void ChannelSettingPHA::SetRecordLength() {printf("=== %s\n", __func__); ChangeAStep(numRecordLength, 8, Register::DPP::RecordLength_G); } void ChannelSettingPHA::SetPreTrigger() {printf("=== %s\n", __func__); ChangeAStep(numPreTrigger, 4, Register::DPP::PreTrigger);} -void ChannelSettingPHA::SetEventAggregate() {printf("=== %s\n", __func__); ChangeAStep(numEventAgg, 1, Register::DPP::NumberEventsPerAggregate_G);} -void ChannelSettingPHA::SetTriggerThreshold(){printf("=== %s\n", __func__); ChangeAStep(numTriggerThreshold, 1, Register::DPP::PHA::TriggerThreshold); } void ChannelSettingPHA::SetTriggerHoldOff() {printf("=== %s\n", __func__); ChangeAStep(numTriggerHoldOff, 4, Register::DPP::PHA::TriggerHoldOffWidth);} void ChannelSettingPHA::SetInputRiseTime() {printf("=== %s\n", __func__); ChangeAStep(numInputRiseTime, 4, Register::DPP::PHA::InputRiseTime);} void ChannelSettingPHA::SetRiseTimeValidWin(){printf("=== %s\n", __func__); ChangeAStep(numRiseTimeValidWin, 1, Register::DPP::PHA::RiseTimeValidationWindow);} @@ -698,6 +697,26 @@ void ChannelSettingPHA::SetDecay() {printf("=== %s\n", __func__); Chan void ChannelSettingPHA::SetPeaking() {printf("=== %s\n", __func__); ChangeAStep(numPeaking, 4, Register::DPP::PHA::PeakingTime);} void ChannelSettingPHA::SetPeakHoldOff() {printf("=== %s\n", __func__); ChangeAStep(numPeakHoldOff, 4, Register::DPP::PHA::PeakHoldOff);} +void ChannelSettingPHA::SetEventAggregate() { + printf("=== %s\n", __func__); + if ( digi == NULL ) return; + short boardID = boardIDEntry->GetNumber(); + short ch = chIDEntry->GetNumber(); + unsigned int temp = numEventAgg->GetNumber(); + if( digi != NULL ) digi[boardID]->WriteRegister(Register::DPP::NumberEventsPerAggregate_G, temp , ch); +} + + +void ChannelSettingPHA::SetTriggerThreshold(){ + printf("=== %s\n", __func__); + if ( digi == NULL ) return; + short boardID = boardIDEntry->GetNumber(); + short ch = chIDEntry->GetNumber(); + unsigned int temp = numTriggerThreshold->GetNumber(); + if( digi != NULL ) digi[boardID]->WriteRegister(Register::DPP::PHA::TriggerThreshold, temp , ch); +} + + void ChannelSettingPHA::SetDCOffset(){ printf("=== %s\n", __func__); if ( digi == NULL ) return; diff --git a/registerSetting.cpp b/registerSetting.cpp index d1556fc..7c2599a 100644 --- a/registerSetting.cpp +++ b/registerSetting.cpp @@ -86,7 +86,7 @@ RegisterSetting::RegisterSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitize for( int i = 0; i < ( digi == NULL ? MaxNChannels : digi[boardID]->GetNChannel() ); i++){ - lbCh[i] = new TGLabel(vframe0, Form("%02d", i)); vframe0->AddFrame(lbCh[i], new TGLayoutHints(kLHintsRight, 5,5,3,2)); + lbCh[i] = new TGLabel(vframe0, Form("%02d", i)); vframe0->AddFrame(lbCh[i], new TGLayoutHints(kLHintsRight, 5,5,4,2)); txtValueHex[i] = new TGTextEntry(vframe1, ""); vframe1->AddFrame(txtValueHex[i], kaka); txtValueHex[i]->Resize(100,20); @@ -295,7 +295,18 @@ void RegisterSetting::UpdateRegister(){ uint32_t address = cbName->GetSelected(); txtAddress->SetText(Form("0x%04X", address), false); - if( digi == NULL ) return; + 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; + } + int boardID = boardIDEntry->GetNumber(); ///check is the register readable @@ -303,7 +314,6 @@ void RegisterSetting::UpdateRegister(){ 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); @@ -336,20 +346,32 @@ void RegisterSetting::UpdateRegister(){ txtValueHex[0]->SetEnabled(true); txtValueDec[0]->SetEnabled(true); } - } }else{ + EButtonState bState = bSetALLChannel->GetState(); + //printf("========= %d \n", bState); bSetALLChannel->SetEnabled(true); /// this will also set the buttonUP + if( bState == kButtonDisabled) bState = kButtonUp; + bSetALLChannel->SetState(bState); 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); + + if( bState == kButtonUp ){ + txtValueHex[ch]->SetEnabled(true); + txtValueDec[ch]->SetEnabled(true); + } } + + if( bState == kButtonDown ){ + txtValueHex[0]->SetEnabled(true); + txtValueDec[0]->SetEnabled(true); + } + }else{ for( int ch = 0; ch < digi[boardID]->GetNChannel(); ch++){ if (type == 82 ){ /// Read only @@ -377,6 +399,7 @@ void RegisterSetting::UpdateRegister(){ } } } + } } diff --git a/registerSetting.h b/registerSetting.h index a527818..d95dddb 100644 --- a/registerSetting.h +++ b/registerSetting.h @@ -44,6 +44,9 @@ class RegisterSetting{ unsigned int ConvertHexToDec(const char * text); void SetTxtValueUnit(uint32_t address, int ch); + + ///TThread * thread; + ///static bool updateFlag; public: RegisterSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nBoard, uint32_t address); diff --git a/test.cpp b/test.cpp index 20901b9..283976f 100644 --- a/test.cpp +++ b/test.cpp @@ -81,7 +81,7 @@ long get_time(){ int main(int argc, char* argv[]){ - const int nBoard = 2; + const int nBoard = 1; Digitizer **dig = new Digitizer *[nBoard]; for( int i = 0 ; i < nBoard; i++){ @@ -106,6 +106,7 @@ int main(int argc, char* argv[]){ //dig[0]->WriteRegister(Register::DPP::TriggerValidationMask_G, 0x600, 3); //dig[0]->WriteRegister(Register::DPP::Scratch, 0x12345678); + dig[0]->ReadRegister(Register::DPP::PHA::TriggerThreshold, 0, "A0"); //dig[0]->ReadRegister(Register::DPP::RecordLength_G, 0, "A0"); //dig[0]->ReadRegister(Register::DPP::RecordLength_G, 3, "A0"); //dig[0]->ReadRegister(Register::DPP::DPPAlgorithmControl, 0, "A1"); @@ -114,16 +115,17 @@ int main(int argc, char* argv[]){ //dig[0]->ReadRegister(Register::DPP::TriggerValidationMask_G, 3, "A3"); //dig[0]->ReadRegister(Register::DPP::Scratch); - printf(" ======== %u \n", dig[0]->GetSettingFromMemory(Register::DPP::RecordLength_G, 0)); - printf(" ======== %u \n", dig[0]->GetSettingFromMemory(Register::DPP::RecordLength_G, 3)); + printf(" ======== %u \n", dig[0]->GetSettingFromMemory(Register::DPP::PHA::TriggerThreshold, 0)); + //printf(" ======== %u \n", dig[0]->GetSettingFromMemory(Register::DPP::RecordLength_G, 0)); + //printf(" ======== %u \n", dig[0]->GetSettingFromMemory(Register::DPP::RecordLength_G, 3)); //printf(" ======== %u \n", dig[0]->GetSettingFromMemory(Register::DPP::DPPAlgorithmControl, 0)); //printf(" ======== %u \n", dig[0]->GetSettingFromMemory(Register::DPP::TriggerValidationMask_G, 1)); //printf(" ======== %u \n", dig[0]->GetSettingFromMemory(Register::DPP::TriggerValidationMask_G, 2)); //printf(" ======== %u \n", dig[0]->GetSettingFromMemory(Register::DPP::TriggerValidationMask_G, 3)); //printf(" ======== %u \n", dig[0]->GetSettingFromMemory(Register::DPP::Scratch)); - printf("////// %u \n", dig[0]->ReadSettingFromFile(Register::DPP::RecordLength_G, 0)); - printf("////// %u \n", dig[0]->ReadSettingFromFile(Register::DPP::RecordLength_G, 3)); + //printf("////// %u \n", dig[0]->ReadSettingFromFile(Register::DPP::RecordLength_G, 0)); + //printf("////// %u \n", dig[0]->ReadSettingFromFile(Register::DPP::RecordLength_G, 3)); //dig[0]->ReadSettingFromFile(Register::DPP::DPPAlgorithmControl, 0); //dig[0]->ReadSettingFromFile(Register::DPP::TriggerValidationMask_G, 1); //dig[0]->ReadSettingFromFile(Register::DPP::TriggerValidationMask_G, 2); @@ -133,13 +135,15 @@ int main(int argc, char* argv[]){ //dig[0]->PrintSettingFromMemory(); - dig[1]->LoadSettingBinary("setting_323.bin"); + //dig[1]->LoadSettingBinary("setting_323.bin"); + // + //printf(" ======== %u \n", dig[1]->GetSettingFromMemory(Register::DPP::RecordLength_G, 0)); + //printf(" ======== %u \n", dig[1]->GetSettingFromMemory(Register::DPP::RecordLength_G, 3)); + // + //printf("////// %u \n", dig[1]->ReadSettingFromFile(Register::DPP::RecordLength_G, 0)); + //printf("////// %u \n", dig[1]->ReadSettingFromFile(Register::DPP::RecordLength_G, 3)); - printf(" ======== %u \n", dig[1]->GetSettingFromMemory(Register::DPP::RecordLength_G, 0)); - printf(" ======== %u \n", dig[1]->GetSettingFromMemory(Register::DPP::RecordLength_G, 3)); - printf("////// %u \n", dig[1]->ReadSettingFromFile(Register::DPP::RecordLength_G, 0)); - printf("////// %u \n", dig[1]->ReadSettingFromFile(Register::DPP::RecordLength_G, 3)); /** ///============================ Get Data TApplication * app = new TApplication("app", &argc, argv); diff --git a/triggerSummary.cpp b/triggerSummary.cpp index 14ff386..4965ceb 100644 --- a/triggerSummary.cpp +++ b/triggerSummary.cpp @@ -13,8 +13,11 @@ Digitizer ** TriggerSummary::digi = NULL; int TriggerSummary::nDigi = 0; bool TriggerSummary::updateFlag = true; TGTextEntry * TriggerSummary::txtTrigger[MaxNBoards][MaxNChannels] = {NULL}; +TGTextEntry * TriggerSummary::txtThresholdValue[MaxNBoards][MaxNChannels] = {NULL}; TGTextEntry * TriggerSummary::txtThreshold[MaxNBoards][MaxNChannels] = {NULL}; 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){ @@ -39,31 +42,39 @@ TriggerSummary::TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h, Digitizer TGVerticalFrame * vframe0 = new TGVerticalFrame(gBD[bd]); gBD[bd]->AddFrame(vframe0, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0)); TGVerticalFrame * vframe1 = new TGVerticalFrame(gBD[bd]); gBD[bd]->AddFrame(vframe1, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0)); TGVerticalFrame * vframe2 = new TGVerticalFrame(gBD[bd]); gBD[bd]->AddFrame(vframe2, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0)); + TGVerticalFrame * vframe3 = new TGVerticalFrame(gBD[bd]); gBD[bd]->AddFrame(vframe3, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0)); TGLabel * lbCh0 = new TGLabel(vframe0, "ch"); vframe0->AddFrame(lbCh0, new TGLayoutHints(kLHintsCenterY, 0,5,3,2)); TGLabel * lbTrigger = new TGLabel(vframe1, "Trig.[Hz]"); vframe1->AddFrame(lbTrigger, new TGLayoutHints(kLHintsCenterY, 5,5,3,2)); TGLabel * lbThreshold = new TGLabel(vframe2, "Thres."); vframe2->AddFrame(lbThreshold, new TGLayoutHints(kLHintsCenterY, 5,5,3,2)); + TGLabel * lbdummy = new TGLabel(vframe3, ""); vframe3->AddFrame(lbdummy, new TGLayoutHints(kLHintsCenterY, 5,5,3,2)); for( int ch = 0; ch < (digi == NULL ? MaxNChannels: digi[bd]->GetNChannel()); ch++){ - lbCh[bd][ch] = new TGLabel(vframe0, Form("%02d", ch)); vframe0->AddFrame(lbCh[bd][ch], new TGLayoutHints(kLHintsCenterY, 0,5,3,2)); + lbCh[bd][ch] = new TGLabel(vframe0, Form("%02d", ch)); vframe0->AddFrame(lbCh[bd][ch], new TGLayoutHints(kLHintsCenterY, 0,5,4,2)); txtTrigger[bd][ch] = new TGTextEntry(vframe1, ""); vframe1->AddFrame(txtTrigger[bd][ch], kaka); txtTrigger[bd][ch]->Resize(50,20); txtTrigger[bd][ch]->SetEnabled(false); txtTrigger[bd][ch]->SetAlignment(kTextRight); - txtThreshold[bd][ch] = new TGTextEntry(vframe2, ""); vframe2->AddFrame(txtThreshold[bd][ch], kaka); + txtThresholdValue[bd][ch] = new TGTextEntry(vframe2, ""); vframe2->AddFrame(txtThresholdValue[bd][ch], kaka); + txtThresholdValue[bd][ch]->Resize(50,20); + txtThresholdValue[bd][ch]->SetEnabled(false); + txtThresholdValue[bd][ch]->SetAlignment(kTextRight); + + value[bd][ch] = 0; + if( digi != NULL ){ + if( digi[bd]->GetDPPType() == V1730_DPP_PSD_CODE ) value[bd][ch] = digi[bd]->GetSettingFromMemory(Register::DPP::PSD::TriggerThreshold, ch); + if( digi[bd]->GetDPPType() == V1730_DPP_PHA_CODE ) value[bd][ch] = digi[bd]->GetSettingFromMemory(Register::DPP::PHA::TriggerThreshold, ch); + } + txtThresholdValue[bd][ch]->SetText(Form("%d", value[bd][ch]), false); + + txtThreshold[bd][ch] = new TGTextEntry(vframe3, ""); vframe3->AddFrame(txtThreshold[bd][ch], kaka); txtThreshold[bd][ch]->Resize(50,20); txtThreshold[bd][ch]->SetAlignment(kTextRight); txtThreshold[bd][ch]->Connect("ReturnPressed()", "TriggerSummary", this, "SetThreshold()"); - - value[bd][ch] = 0; - - if( digi != NULL ){ - if( digi[bd]->GetDPPType() == V1730_DPP_PSD_CODE ) value[bd][ch] = digi[bd]->ReadRegister(Register::DPP::PSD::TriggerThreshold, ch); - if( digi[bd]->GetDPPType() == V1730_DPP_PHA_CODE ) value[bd][ch] = digi[bd]->ReadRegister(Register::DPP::PHA::TriggerThreshold, ch); - } txtThreshold[bd][ch]->SetText(Form("%d", value[bd][ch]), false); + } } @@ -96,6 +107,7 @@ TriggerSummary::~TriggerSummary(){ for(int i = 0; i < nDigi; i++){ for(int j = 0; j < MaxNChannels; j++){ delete txtTrigger[i][j]; + delete txtThresholdValue[i][j]; delete txtThreshold[i][j]; } } @@ -103,7 +115,7 @@ TriggerSummary::~TriggerSummary(){ delete numUpdateTime; updateFlag = false; - usleep(1000 * 1000); + //usleep(500 * 1000); ///delete thread; /// Don;t delete the thread, otherwise, thread will not run after close and reopen. @@ -114,15 +126,19 @@ TriggerSummary::~TriggerSummary(){ void * TriggerSummary::UpdateTriggerRate(void * ptr){ while( updateFlag){ - + ///printf("==================== %s\n", __func__); for( int bd = 0; bd < nDigi; bd++){ for( int ch = 0; ch < digi[bd]->GetNChannel(); ch++){ txtTrigger[bd][ch]->SetText(Form("%.2f", digi[bd]->GetData()->TriggerRate[ch])); + value[bd][ch] = digi[bd]->GetSettingFromMemory(Register::DPP::PHA::TriggerThreshold, ch); + txtThresholdValue[bd][ch]->SetText(Form("%d", value[bd][ch]), false); } } usleep(numUpdateTime->GetNumber() * 1000); } + + return 0; } void TriggerSummary::SetThreshold(){ @@ -139,17 +155,17 @@ void TriggerSummary::SetThreshold(){ digi[bd]->WriteRegister(Register::DPP::PSD::TriggerThreshold, haha, ch); - value[bd][ch] = digi[bd]->ReadRegister(Register::DPP::PSD::TriggerThreshold, ch); + value[bd][ch] = digi[bd]->GetSettingFromMemory(Register::DPP::PSD::TriggerThreshold, ch); } if( digi[bd]->GetDPPType() == V1730_DPP_PHA_CODE ) { digi[bd]->WriteRegister(Register::DPP::PHA::TriggerThreshold, haha, ch); - value[bd][ch] = digi[bd]->ReadRegister(Register::DPP::PHA::TriggerThreshold, ch); + value[bd][ch] = digi[bd]->GetSettingFromMemory(Register::DPP::PHA::TriggerThreshold, ch); } - txtThreshold[bd][ch]->SetText(Form("%d", value[bd][ch]), false); + txtThresholdValue[bd][ch]->SetText(Form("%d", value[bd][ch]), false); } } } diff --git a/triggerSummary.h b/triggerSummary.h index abc35da..46cc850 100644 --- a/triggerSummary.h +++ b/triggerSummary.h @@ -23,13 +23,14 @@ class TriggerSummary{ static Digitizer ** digi; static TGTextEntry * txtTrigger[MaxNBoards][MaxNChannels]; + static TGTextEntry * txtThresholdValue[MaxNBoards][MaxNChannels]; static TGTextEntry * txtThreshold[MaxNBoards][MaxNChannels]; TThread * thread; static bool updateFlag; static TGNumberEntry * numUpdateTime; - unsigned short value[MaxNBoards][MaxNChannels]; + static unsigned short value[MaxNBoards][MaxNChannels]; public: TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** digi, int nBoard);