From 114a24d076d95f260a7a781fd87359303473e4e3 Mon Sep 17 00:00:00 2001 From: "Ryan@Debain10" Date: Fri, 1 Apr 2022 15:14:11 -0400 Subject: [PATCH] can change Sych_wait InSych, and Slow Filter Range in Module setting --- Pixie16Class.cpp | 2 +- Pixie16Class.h | 3 +- channelSetting.cpp | 67 +++++++++--------- channelSetting.h | 2 +- moduleSetting.cpp | 169 +++++++++++++++++++++++++++++++++++++-------- moduleSetting.h | 13 +++- pixieDAQ.cpp | 16 ++++- settingsSummary.h | 2 +- test_ryan.set | 4 +- 9 files changed, 209 insertions(+), 69 deletions(-) diff --git a/Pixie16Class.cpp b/Pixie16Class.cpp index 7f18c14..453f7bd 100644 --- a/Pixie16Class.cpp +++ b/Pixie16Class.cpp @@ -406,7 +406,7 @@ void Pixie16::ReadData(unsigned short modID){ if( CheckError("Pixie16CheckExternalFIFOStatus") < 0 ) return; ///if(nFIFOWords *1.0 / EXTERNAL_FIFO_LENGTH > 0.2) { if(nFIFOWords > 0) { - //printf("\033[1;31m####### READ DATA \033[m: number of word in module-%d FIFO : %d \n", modID, nFIFOWords); + ///printf("\033[1;31m####### READ DATA \033[m: number of word in module-%d FIFO : %d (%.2f kB)\n", modID, nFIFOWords, nFIFOWords*4./1024.); if( ExtFIFO_Data != NULL ) delete ExtFIFO_Data; ExtFIFO_Data = new unsigned int [nFIFOWords]; retval = Pixie16ReadDataFromExternalFIFO(ExtFIFO_Data, nFIFOWords, modID); diff --git a/Pixie16Class.h b/Pixie16Class.h index 33277e9..f73e598 100644 --- a/Pixie16Class.h +++ b/Pixie16Class.h @@ -116,7 +116,6 @@ public: void CaptureADCTrace(unsigned short modID, unsigned short ch); int GetADCTraceLength() {return 8192;} unsigned short * GetADCTrace() {return ADCTrace;} - ///========================= Setting unsigned int GetNumModule() {return NumModules;} @@ -124,6 +123,7 @@ public: unsigned short GetDigitizerRev(unsigned short modID) { return ModRev[modID];} unsigned short GetDigitizerADCBits(unsigned short modID) { return ModADCBits[modID];} unsigned short GetDigitizerNumChannel(unsigned short modID) { return numChannels[modID];} + unsigned short GetDigitizerSamplingRate(unsigned short modID) { return ModADCMSPS[modID];} std::string GetSettingFile(unsigned modID) {return DSPParFile[modID];} unsigned int GetDigitizerSetting(std::string parName, unsigned short modID, bool verbose = false); @@ -133,6 +133,7 @@ public: void SetDigitizerSetting(std::string parName, unsigned int val, unsigned short modID, bool verbose = false); void SetDigitizerSynchWait(unsigned int val, unsigned short modID) { SetDigitizerSetting("SYNCH_WAIT", val, modID, 1);} void SetDigitizerInSynch(unsigned int val, unsigned short modID) { SetDigitizerSetting("IN_SYNCH", val, modID, 1);} + void SetDigitizerSlowFilterRange(unsigned int val, unsigned short modID) { SetDigitizerSetting("SLOW_FILTER_RANGE", val, modID, 1);} void SetDigitizerPresetRunTime(double val_in_sec, unsigned short modID) { SetDigitizerSetting("HOST_RT_PRESET", Decimal2IEEEFloating(val_in_sec), modID, 1);} double GetChannelSetting(std::string parName, unsigned short modID, unsigned short ch, bool verbose = false); diff --git a/channelSetting.cpp b/channelSetting.cpp index 3963f28..01b5a1f 100644 --- a/channelSetting.cpp +++ b/channelSetting.cpp @@ -11,6 +11,33 @@ #include "channelSetting.h" +TString settingName[NUM_CHANNEL_SETTING] = { "TRIGGER_RISETIME", + "TRIGGER_FLATTOP", + "TRIGGER_THRESHOLD", + "ENERGY_RISETIME", + "ENERGY_FLATTOP", + "TAU", + "TRACE_LENGTH", + "TRACE_DELAY", + "VOFFSET", + "XDT", + "BASELINE_PERCENT", + "BASELINE_AVERAGE", + "BLCUT", + "EMIN", + "QDCLen0", + "QDCLen1", + "QDCLen2", + "QDCLen3", + "QDCLen4", + "QDCLen5", + "QDCLen6", + "QDCLen7", + "MultiplicityMaskL", + "MultiplicityMaskH", + "CHANNEL_CSRA"}; + + ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie){ this->pixie = pixie; @@ -41,41 +68,13 @@ ChannelSetting::ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * chIDEntry = new TGNumberEntry(hframe0, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); chIDEntry->SetWidth(50); - chIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, MAXCH); + chIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, MAXCH-1); chIDEntry->Connect("Modified()", "ChannelSetting", this, "ChangeCh()"); hframe0->AddFrame(chIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4)); int modID = modIDEntry->GetNumber(); int ch = chIDEntry->GetNumber(); - TString settingName[NUM_CHANNEL_SETTING] = { - "TRIGGER_RISETIME", - "TRIGGER_FLATTOP", - "TRIGGER_THRESHOLD", - "ENERGY_RISETIME", - "ENERGY_FLATTOP", - "TAU", - "TRACE_LENGTH", - "TRACE_DELAY", - "VOFFSET", - "XDT", - "BASELINE_PERCENT", - "BASELINE_AVERAGE", - "BLCUT", - "EMIN", - "QDCLen0", - "QDCLen1", - "QDCLen2", - "QDCLen3", - "QDCLen4", - "QDCLen5", - "QDCLen6", - "QDCLen7", - "MultiplicityMaskL", - "MultiplicityMaskH", - "CHANNEL_CSRA", - }; - TGHorizontalFrame *hframe[NUM_CHANNEL_SETTING]; TGLabel * lb[NUM_CHANNEL_SETTING]; @@ -125,13 +124,17 @@ ChannelSetting::~ChannelSetting(){ void ChannelSetting::ChangeMod(){ - - - + ChangeCh(); } void ChannelSetting::ChangeCh(){ + int modID = modIDEntry->GetNumber(); + int ch = chIDEntry->GetNumber(); + for( int i = 0 ; i < NUM_CHANNEL_SETTING; i++){ + double temp = pixie->GetChannelSetting(settingName[i].Data(), modID, ch, false); + entry[i]->SetText( Form("%f", temp) ); + } } diff --git a/channelSetting.h b/channelSetting.h index b3cc2f6..527ff5e 100644 --- a/channelSetting.h +++ b/channelSetting.h @@ -28,7 +28,7 @@ public: ChannelSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie); virtual ~ChannelSetting(); - void CloseWindow() { printf("close window\n"); delete this; } + void CloseWindow() { printf("close ChannelSetting window\n"); delete this; } void ChangeMod(); void ChangeCh(); diff --git a/moduleSetting.cpp b/moduleSetting.cpp index c648697..4f03ecb 100644 --- a/moduleSetting.cpp +++ b/moduleSetting.cpp @@ -10,6 +10,20 @@ #include "moduleSetting.h" +TString modSettingName[NUM_MOD_SETTING] = { "CrateID", + "SlotID", + "SYNCH_WAIT", + "IN_SYNCH", + "SLOW_FILTER_RANGE", + "FAST_FILTER_RANGE", + "FastTrigBackplaneEna", + "TrigConfig0", + "TrigConfig1", + "TrigConfig2", + "TrigConfig3", + "HOST_RT_PRESET", + "MODULE_CSRB"}; + ModuleSetting::ModuleSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie){ @@ -37,22 +51,9 @@ ModuleSetting::ModuleSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pi hframe0->AddFrame(modIDEntry, new TGLayoutHints(kLHintsCenterX , 5, 5, 3, 4)); int modID = modIDEntry->GetNumber(); - - TString settingName[NUM_MOD_SETTING] = { - "CrateID", - "SlotID", - "SYNCH_WAIT", - "IN_SYNCH", - "SLOW_FILTER_RANGE", - "FAST_FILTER_RANGE", - "FastTrigBackplaneEna", - "TrigConfig0", - "TrigConfig1", - "TrigConfig2", - "TrigConfig3", - "HOST_RT_PRESET", - "MODULE_CSRB", - }; + + int comboBoxWidth = 135; + int comboBoxHeigth = 30; TGHorizontalFrame *hframe[NUM_MOD_SETTING]; TGLabel * lb[NUM_MOD_SETTING]; @@ -61,16 +62,75 @@ ModuleSetting::ModuleSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pi hframe[i] = new TGHorizontalFrame(vframe, 50, 50 ); vframe->AddFrame(hframe[i], new TGLayoutHints(kLHintsRight, 2,2,2,2)); - int temp = pixie->GetDigitizerSetting(settingName[i].Data(), modID, false); - entry[i] = new TGTextEntry(hframe[i], new TGTextBuffer(1)); - //if( i < 2 || i == NUM_MOD_SETTING -1 ) entry[i]->SetEnabled(false); - entry[i]->SetEnabled(false); + int temp = pixie->GetDigitizerSetting(modSettingName[i].Data(), modID, false); - entry[i]->SetText( Form("%d", temp) ); + if( i < 2 || i > 4){ + entry[i] = new TGTextEntry(hframe[i], new TGTextBuffer(1)); + entry[i]->SetEnabled(false); + entry[i]->SetText( Form("%d", temp) ); + + if( i == 5 ) entry[i]->SetText( Form("%d (only 0 supported)", temp) ); + + hframe[i]->AddFrame(entry[i], new TGLayoutHints(kLHintsRight, 5,5,3,4)); + } + + if( i == 2 ){ + cbSyncWait = new TGComboBox(hframe[i]); + cbSyncWait->SetWidth(comboBoxWidth); + cbSyncWait->SetHeight(comboBoxHeigth); + + cbSyncWait->AddEntry("Sync", 1); + cbSyncWait->AddEntry("not Sync", 0); + cbSyncWait->Select(temp); + cbSyncWait->Connect("Selected(Int_t, Int_t)", "ModuleSetting", this, "ChangeSyncWait()"); + + hframe[i]->AddFrame(cbSyncWait, new TGLayoutHints(kLHintsRight, 5,5,3,4)); + } - hframe[i]->AddFrame(entry[i], new TGLayoutHints(kLHintsRight, 5,5,3,4)); + if( i == 3 ){ + cbInSych = new TGComboBox(hframe[i]); + cbInSych->SetWidth(comboBoxWidth); + cbInSych->SetHeight(comboBoxHeigth); + + cbInSych->AddEntry("Clock clear", 0); + cbInSych->AddEntry("Common Clock", 1); + cbInSych->Select(temp); + cbInSych->Connect("Selected(Int_t, Int_t)", "ModuleSetting", this, "ChangeInSync()"); + + hframe[i]->AddFrame(cbInSych, new TGLayoutHints(kLHintsRight, 5,5,3,4)); + } + + if( i == 4 ){ + + cbSlowFilterRange = new TGComboBox(hframe[i]); + cbSlowFilterRange->SetWidth(comboBoxWidth); + cbSlowFilterRange->SetHeight(comboBoxHeigth); + + unsigned short sampleRate = pixie->GetDigitizerSamplingRate(modID); + if( sampleRate == 100 || sampleRate == 500 ){ + cbSlowFilterRange->AddEntry("off", 0); + cbSlowFilterRange->AddEntry("0.02 us", 1); + cbSlowFilterRange->AddEntry("0.04 us", 2); + cbSlowFilterRange->AddEntry("0.08 us", 3); + cbSlowFilterRange->AddEntry("0.16 us", 4); + cbSlowFilterRange->AddEntry("0.32 us", 5); + cbSlowFilterRange->AddEntry("0.64 us", 6); + }else{ + cbSlowFilterRange->AddEntry("off", 0); + cbSlowFilterRange->AddEntry("0.016 us", 1); + cbSlowFilterRange->AddEntry("0.032 us", 2); + cbSlowFilterRange->AddEntry("0.064 us", 3); + cbSlowFilterRange->AddEntry("0.128 us", 4); + cbSlowFilterRange->AddEntry("0.256 us", 5); + cbSlowFilterRange->AddEntry("0.512 us", 6); + } + cbSlowFilterRange->Select(temp); + cbSlowFilterRange->Connect("Selected(Int_t, Int_t)", "ModuleSetting", this, "ChangeSlowFilterRange()"); + + hframe[i]->AddFrame(cbSlowFilterRange, new TGLayoutHints(kLHintsRight, 5,5,3,4)); + } - lb[i] = new TGLabel(hframe[i], settingName[i]); + lb[i] = new TGLabel(hframe[i], modSettingName[i]); hframe[i]->AddFrame(lb[i], new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4)); } @@ -91,10 +151,13 @@ ModuleSetting::~ModuleSetting(){ delete modIDEntry; for ( int i = 0; i < NUM_MOD_SETTING; i++){ - delete entry[i]; + if( i < 2 || i > 5 ) delete entry[i]; } - + delete cbSyncWait; + delete cbInSych; + delete cbSlowFilterRange; + /// fMain must be delete last; fMain->Cleanup(); delete fMain; @@ -103,7 +166,59 @@ ModuleSetting::~ModuleSetting(){ void ModuleSetting::ChangeMod(){ + int modID = modIDEntry->GetNumber(); - - + for( int i = 0 ; i < NUM_MOD_SETTING; i++){ + int temp = pixie->GetDigitizerSetting(modSettingName[i].Data(), modID, false); + + if( i < 2 || i > 4){ + entry[i]->SetText( Form("%d", temp) ); + } + + if( i == 2 ) cbSyncWait->Select(temp); + if( i == 3 ) cbInSych->Select(temp); + + if( i == 4 ) { + + cbSlowFilterRange->RemoveAll(); + unsigned short sampleRate = pixie->GetDigitizerSamplingRate(modID); + if( sampleRate == 100 || sampleRate == 500 ){ + cbSlowFilterRange->AddEntry("off", 0); + cbSlowFilterRange->AddEntry("0.02 us", 1); + cbSlowFilterRange->AddEntry("0.04 us", 2); + cbSlowFilterRange->AddEntry("0.08 us", 3); + cbSlowFilterRange->AddEntry("0.16 us", 4); + cbSlowFilterRange->AddEntry("0.32 us", 5); + cbSlowFilterRange->AddEntry("0.64 us", 6); + }else{ + cbSlowFilterRange->AddEntry("off", 0); + cbSlowFilterRange->AddEntry("0.016 us", 1); + cbSlowFilterRange->AddEntry("0.032 us", 2); + cbSlowFilterRange->AddEntry("0.064 us", 3); + cbSlowFilterRange->AddEntry("0.128 us", 4); + cbSlowFilterRange->AddEntry("0.256 us", 5); + cbSlowFilterRange->AddEntry("0.512 us", 6); + } + cbSlowFilterRange->Select(temp); + + } + } } + +void ModuleSetting::ChangeSyncWait(){ + pixie->SetDigitizerSynchWait(cbSyncWait->GetSelected(), modIDEntry->GetNumber()); + + ///printf("%s \n", pixie->GetSettingFile(modIDEntry->GetNumber()).c_str()); + pixie->SaveSettings(pixie->GetSettingFile(modIDEntry->GetNumber())); +} + +void ModuleSetting::ChangeInSync(){ + pixie->SetDigitizerInSynch(cbInSych->GetSelected(), modIDEntry->GetNumber()); + pixie->SaveSettings(pixie->GetSettingFile(modIDEntry->GetNumber())); +} + +void ModuleSetting::ChangeSlowFilterRange(){ + pixie->SetDigitizerSlowFilterRange(cbInSych->GetSelected(), modIDEntry->GetNumber()); + pixie->SaveSettings(pixie->GetSettingFile(modIDEntry->GetNumber())); +} + diff --git a/moduleSetting.h b/moduleSetting.h index 4a4ba7a..0b7840e 100644 --- a/moduleSetting.h +++ b/moduleSetting.h @@ -22,15 +22,26 @@ private: TGTextEntry * entry[NUM_MOD_SETTING]; + TGComboBox * cbSyncWait; + TGComboBox * cbInSych; + + TGComboBox * cbSlowFilterRange; + TGComboBox * cbFastFilterRange; + + Pixie16 * pixie; public: ModuleSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie); virtual ~ModuleSetting(); - void CloseWindow() { printf("close window\n"); delete this; } + void CloseWindow() { printf("close ModuleSetting window\n"); delete this; } void ChangeMod(); + + void ChangeSyncWait(); + void ChangeInSync(); + void ChangeSlowFilterRange(); bool isOpened; diff --git a/pixieDAQ.cpp b/pixieDAQ.cpp index 11c8d9e..1e634eb 100644 --- a/pixieDAQ.cpp +++ b/pixieDAQ.cpp @@ -174,9 +174,12 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { /// Initialize the layout algorithm fMain->Resize(fMain->GetDefaultSize()); - + fMain->SetWMPosition(200, 200); //does not work?? + /// Map main frame fMain->MapWindow(); + + /// setup thread thread = new TThread("hahaha", SaveData, (void *) 1); @@ -448,16 +451,22 @@ void * MainWindow::SaveData(void* ptr){ TBenchmark localClock; localClock.Reset(); localClock.Start("timer"); + + int pauseTime = 500 ; ///msec while( pixie->IsRunning() ){ - usleep(500*1000); /// 500 msec + if( pauseTime > 10 ) usleep(pauseTime*1000); if( !pixie->IsRunning() ) break; pixie->ReadData(0); pixie->SaveData(); + double MByteRead = pixie->GetnFIFOWords()*4./1024./1024.; + + if( MByteRead > 70 && pauseTime > 10) pauseTime = pauseTime - 20; + //TODO Fill HISTORGRAM; time_t now = time(0); tm * ltm = localtime(&now); @@ -478,7 +487,8 @@ void * MainWindow::SaveData(void* ptr){ oldFileSize = newFileSize; oldTime = newTime; - teLog->AddLine(Form("[%4d-%02d-%02d %02d:%02d:%02d] File Size : %.2f MB [%.2f MB/s]", year, month, day, hour, minute, secound, newFileSize, rate)); + teLog->AddLine(Form("[%4d-%02d-%02d %02d:%02d:%02d] File Size : %.2f MB [%.2f MB/s], %.2f MB readed", + year, month, day, hour, minute, secound, newFileSize, rate, MByteRead)); teLog->LineDown(); diff --git a/settingsSummary.h b/settingsSummary.h index 061ebf1..8ac950a 100644 --- a/settingsSummary.h +++ b/settingsSummary.h @@ -54,7 +54,7 @@ public: virtual ~SettingsSummary(); - void CloseWindow() { printf("close window\n"); delete this; } + void CloseWindow() { printf("close SettingsSummary window\n"); delete this; } void ChangeOnOff(unsigned short ch); void ChangeGain(unsigned short ch); diff --git a/test_ryan.set b/test_ryan.set index d0a0043..8123c41 100644 --- a/test_ryan.set +++ b/test_ryan.set @@ -1016,7 +1016,7 @@ "ChanNum": 0, "CoincPattern": 0, "CoincWait": 0, - "ControlTask": 5, + "ControlTask": 23, "CrateID": 0, "FIFOLength": 8188, "FastFilterRange": 0, @@ -1040,7 +1040,7 @@ 0 ], "HostRunTimePreset": 1092616192, - "InSynch": 1, + "InSynch": 0, "MaxEvents": 0, "ModCSRA": 0, "ModCSRB": 1,