added Module Settign Pannel, cannot change setting

This commit is contained in:
Ryan Tang 2022-03-30 18:33:44 -04:00
parent 50e6eb64d8
commit 77119d9a38
7 changed files with 234 additions and 59 deletions

View File

@ -29,7 +29,7 @@ APIBASE = /usr/opt/xia/PixieSDK/lib/
LIBS = $(APIBASE)libPixie16Api.so $(APIBASE)libPixieSDK.a $(PLXBASE)PlxApi.a
OBJS = pixieDAQ.o Pixie16Class.o settingsSummary.o scalarPanel.o
OBJS = pixieDAQ.o Pixie16Class.o settingsSummary.o scalarPanel.o moduleSetting.o
all: testing/test testing/example pixieDAQ
@ -60,6 +60,10 @@ scalarPanel.o : scalarPanel.cpp scalarPanel.h
@echo "--------- creating scalarPanel.o.o"
$(CC) $(CFLAGS) $(PIXIE_LIB_PATH) scalarPanel.cpp $(ROOT_FLAG)
moduleSetting.o : moduleSetting.cpp moduleSetting.h
@echo "--------- creating moduleSetting.o"
$(CC) $(CFLAGS) $(PIXIE_LIB_PATH) moduleSetting.cpp $(ROOT_FLAG)
#--------------------------
testing/example : testing/example.o
@echo "-------- making example"

109
moduleSetting.cpp Normal file
View File

@ -0,0 +1,109 @@
#include <TApplication.h>
#include <TGClient.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TRandom.h>
#include <TGButton.h>
#include <TRootEmbeddedCanvas.h>
#include <TGTableContainer.h>
#include <TGFileDialog.h>
#include "moduleSetting.h"
ModuleSetting::ModuleSetting(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie){
this->pixie = pixie;
fMain = new TGMainFrame(p,w,h);
fMain->SetWindowName("Pixie16 Channel Settings ");
fMain->Connect("CloseWindow()", "ModuleSetting", this, "CloseWindow()");
TGVerticalFrame * vframe = new TGVerticalFrame(fMain);
fMain->AddFrame(vframe, new TGLayoutHints(kLHintsCenterX, 2,2,2,2));
///==========Module choose
TGHorizontalFrame *hframe0 = new TGHorizontalFrame(vframe, w, 50 );
vframe->AddFrame(hframe0, new TGLayoutHints(kLHintsCenterX, 2,2,2,2));
TGLabel * lb0 = new TGLabel(hframe0, "Module ID :");
hframe0->AddFrame(lb0, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5, 5, 3, 4));
modIDEntry = new TGNumberEntry(hframe0, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
modIDEntry->SetWidth(50);
modIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetNumModule()-1);
modIDEntry->Connect("Modified()", "ModuleSetting", this, "ChangeMod()");
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",
};
TGHorizontalFrame *hframe[NUM_MOD_SETTING];
TGLabel * lb[NUM_MOD_SETTING];
for( int i = 0 ; i < NUM_MOD_SETTING; i++){
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);
entry[i]->SetText( Form("%d", temp) );
hframe[i]->AddFrame(entry[i], new TGLayoutHints(kLHintsRight, 5,5,3,4));
lb[i] = new TGLabel(hframe[i], settingName[i]);
hframe[i]->AddFrame(lb[i], new TGLayoutHints(kLHintsRight | kLHintsCenterY, 5, 5, 3, 4));
}
fMain->MapSubwindows();
fMain->Resize(fMain->GetDefaultSize());
fMain->MapWindow();
isOpened = true;
}
ModuleSetting::~ModuleSetting(){
isOpened = false;
delete modIDEntry;
for ( int i = 0; i < NUM_MOD_SETTING; i++){
delete entry[i];
}
/// fMain must be delete last;
fMain->Cleanup();
delete fMain;
}
void ModuleSetting::ChangeMod(){
}

40
moduleSetting.h Normal file
View File

@ -0,0 +1,40 @@
#ifndef MODULE_SETTING_H
#define MODULE_SETTING_H
#include <TQObject.h>
#include <TGNumberEntry.h>
#include <TGComboBox.h>
#include <TGLabel.h>
#include "Pixie16Class.h"
class TGWindow;
class TGMainFrame;
#define MAXCH 16
#define NUM_MOD_SETTING 13
class ModuleSetting{
private:
TGMainFrame * fMain;
TGNumberEntry * modIDEntry;
TGTextEntry * entry[NUM_MOD_SETTING];
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 ChangeMod();
bool isOpened;
};
#endif

View File

@ -25,10 +25,9 @@ enum MenuIdentifiers{
M_FILE_OPEN,
M_EXIT,
M_MAIN_CH_SETTINGS,
M_CH_SETTINGS_SUMMARY,
M_CH_SETTING,
M_DIGITIZER_SETTINGS,
M_DIGITIZER_INFOS
M_MODULE_SETTINGS
};
@ -64,101 +63,104 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
fMenuBar->AddPopup("&File", fMenuFile, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
fMenuSettings = new TGPopupMenu(gClient->GetRoot());
fMenuSettings->AddEntry("&Main Ch Settings", M_MAIN_CH_SETTINGS);
fMenuSettings->AddEntry("&Settings Summary", M_CH_SETTINGS_SUMMARY);
fMenuSettings->AddEntry("&Channel Setting", M_CH_SETTING);
fMenuSettings->AddSeparator();
fMenuSettings->AddEntry("Digitizer &Settings", M_DIGITIZER_SETTINGS);
fMenuSettings->AddEntry("Digitizer &Info", M_DIGITIZER_INFOS);
fMenuSettings->AddEntry("Digitizer &Settings", M_MODULE_SETTINGS);
fMenuSettings->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)");
fMenuBar->AddPopup("&Settings", fMenuSettings, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
TGLayoutHints * uniLayoutHints = new TGLayoutHints(kLHintsNormal, 2,2,10,0); ///left, right, top, bottom
/// Create a horizontal frame widget with buttons
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain,200,40);
fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
///================= signal Channel group
TGGroupFrame * group1 = new TGGroupFrame(hframe, "Single Channel", kHorizontalFrame);
hframe->AddFrame(group1, new TGLayoutHints(kLHintsCenterX, 5,5,3,3) );
hframe->AddFrame(group1 );
TGHorizontalFrame *hframe1 = new TGHorizontalFrame(group1,200,30);
group1->AddFrame(hframe1);
group1->AddFrame(hframe1 );
TGLabel * lb1 = new TGLabel(hframe1, "Module ID :");
hframe1->AddFrame(lb1, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2, 2, 5, 0));
hframe1->AddFrame(lb1, uniLayoutHints);
modIDEntry = new TGNumberEntry(hframe1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
modIDEntry->SetWidth(50);
modIDEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetNumModule()-1);
hframe1->AddFrame(modIDEntry, new TGLayoutHints(kLHintsCenterX , 2, 2, 5, 0));
hframe1->AddFrame(modIDEntry, uniLayoutHints);
TGLabel * lb2 = new TGLabel(hframe1, "Ch :");
hframe1->AddFrame(lb2, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2, 2, 5, 0));
hframe1->AddFrame(lb2, uniLayoutHints);
chEntry = new TGNumberEntry(hframe1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
chEntry->SetWidth(50);
chEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, pixie->GetDigitizerNumChannel(0));
hframe1->AddFrame(chEntry, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2, 2, 5, 0));
hframe1->AddFrame(chEntry, uniLayoutHints);
TGTextButton *bGetADCTrace = new TGTextButton(hframe1,"Get &ADC Trace");
bGetADCTrace->Connect("Clicked()","MainWindow",this,"GetADCTrace()");
hframe1->AddFrame(bGetADCTrace, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,5,0));
hframe1->AddFrame(bGetADCTrace, uniLayoutHints);
TGTextButton *bGetBaseLine = new TGTextButton(hframe1,"Get &BaseLine");
bGetBaseLine->Connect("Clicked()","MainWindow",this,"GetBaseLine()");
hframe1->AddFrame(bGetBaseLine, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,5,0));
hframe1->AddFrame(bGetBaseLine, uniLayoutHints);
TGTextButton *bScope = new TGTextButton(hframe1,"&Scope");
bScope->Connect("Clicked()","MainWindow",this,"Scope()");
hframe1->AddFrame(bScope, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,5,0));
hframe1->AddFrame(bScope, uniLayoutHints);
///================= Start Run group
TGGroupFrame * group2 = new TGGroupFrame(hframe, "Start run", kHorizontalFrame);
hframe->AddFrame(group2, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,5,0) );
//hframe->AddFrame(group2, new TGLayoutHints(kLHintsCenterX, 5,5,3,3) );
hframe->AddFrame(group2);
TGHorizontalFrame *hframe2 = new TGHorizontalFrame(group2,200,30);
group2->AddFrame(hframe2);
tePath = new TGTextEntry(hframe2, new TGTextBuffer(10));
tePath->SetText("haha.evt");
hframe2->AddFrame(tePath, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,5,0));
hframe2->AddFrame(tePath, uniLayoutHints);
TGTextButton *bStartRun = new TGTextButton(hframe2,"Start &Run");
bStartRun = new TGTextButton(hframe2,"Start &Run");
bStartRun->Connect("Clicked()","MainWindow",this,"StartRun()");
hframe2->AddFrame(bStartRun, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,5,0));
hframe2->AddFrame(bStartRun, uniLayoutHints);
TGTextButton *bStopRun = new TGTextButton(hframe2,"Stop Run");
bStopRun = new TGTextButton(hframe2,"Stop Run");
bStopRun->Connect("Clicked()","MainWindow",this,"StopRun()");
hframe2->AddFrame(bStopRun, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,5,0));
hframe2->AddFrame(bStopRun, uniLayoutHints);
TGTextButton *bScalar = new TGTextButton(hframe2,"Scalar");
bScalar->Connect("Clicked()","MainWindow",this,"OpenScalar()");
hframe2->AddFrame(bScalar, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,5,0));
hframe2->AddFrame(bScalar, uniLayoutHints);
///================= Read evt group
TGGroupFrame * group3 = new TGGroupFrame(hframe, "Read Evt", kHorizontalFrame);
hframe->AddFrame(group3, new TGLayoutHints(kLHintsCenterX, 2,2,5,0) );
TGHorizontalFrame *hframe3 = new TGHorizontalFrame(group3,200,30);
group3->AddFrame(hframe3);
TGTextButton *bOpenEVT = new TGTextButton(hframe3,"OpenEvt");
//bOpenEVT->Connect("Clicked()","MainWindow",this,"StartRun()");
hframe3->AddFrame(bOpenEVT, new TGLayoutHints(kLHintsCenterX, 2,2,5,0));
//TGGroupFrame * group3 = new TGGroupFrame(hframe, "Read Evt", kHorizontalFrame);
////hframe->AddFrame(group3, new TGLayoutHints(kLHintsCenterX, 5,5,3,3) );
//hframe->AddFrame(group3);
//
//TGHorizontalFrame *hframe3 = new TGHorizontalFrame(group3,200,30);
//group3->AddFrame(hframe3);
//
//TGTextButton *bOpenEVT = new TGTextButton(hframe3,"OpenEvt");
////bOpenEVT->Connect("Clicked()","MainWindow",this,"StartRun()");
//hframe3->AddFrame(bOpenEVT, uniLayoutHints);
///================= Create canvas widget
fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain,800,400);
fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,1));
fEcanvas = new TRootEmbeddedCanvas("Ecanvas",fMain,900,400);
fMain->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10,10,10,10));
///================= Log massage
TGGroupFrame * groupLog = new TGGroupFrame(fMain, "Log Message", kHorizontalFrame);
fMain->AddFrame(groupLog, new TGLayoutHints(kLHintsCenterX, 5,5,3,3) );
fMain->AddFrame(groupLog, new TGLayoutHints(kLHintsCenterX, 5,5,0,5) );
teLog = new TGTextEdit(groupLog, w, 60);
groupLog->AddFrame(teLog, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0,0,5,0));
groupLog->AddFrame(teLog, new TGLayoutHints(kLHintsNormal, 0,0,10,0));
/// Set a name to the main frame
@ -176,10 +178,13 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
/// setup thread
thread = new TThread("hahaha", SaveData, (void *) 1);
mainSettings = NULL;
settingsSummary = NULL;
moduleSetting = NULL;
scalarPanel = NULL;
///HandleMenu(M_MAIN_CH_SETTINGS);
bStopRun->SetEnabled(false);
///HandleMenu(M_CH_SETTINGS_SUMMARY);
}
@ -196,22 +201,37 @@ MainWindow::~MainWindow() {
void MainWindow::HandleMenu(Int_t id){
switch(id){
///========================= File Open
case M_FILE_OPEN:{
}break;
///========================= Exit
case M_EXIT: GoodBye(); break;
case M_MAIN_CH_SETTINGS: {
if( mainSettings == NULL ) {
mainSettings = new SettingsSummary(gClient->GetRoot(), 600, 600, pixie);
///========================= Channel setting summary
case M_CH_SETTINGS_SUMMARY: {
if( settingsSummary == NULL ) {
settingsSummary = new SettingsSummary(gClient->GetRoot(), 600, 600, pixie);
}else{
if( !mainSettings->isOpened ) {
mainSettings = new SettingsSummary(gClient->GetRoot(), 600, 600, pixie);
if( !settingsSummary->isOpened ) {
settingsSummary = new SettingsSummary(gClient->GetRoot(), 600, 600, pixie);
}
}
}break;
///========================= Module setting
case M_MODULE_SETTINGS:{
if( moduleSetting == NULL ) {
moduleSetting = new ModuleSetting(gClient->GetRoot(), 600, 600, pixie);
}else{
if( !moduleSetting->isOpened ) {
moduleSetting = new ModuleSetting(gClient->GetRoot(), 600, 600, pixie);
}
}
}break;
}
}
@ -279,9 +299,10 @@ void MainWindow::Scope(){
DataBlock * data = pixie->GetData();
LogMsg("Take data for 200 msec.");
pixie->StartRun(1);
usleep(100*1000);
usleep(200*1000);
pixie->ReadData(0);
pixie->StopRun();
@ -343,15 +364,10 @@ void MainWindow::StartRun(){
pixie->StartRun(1);
//Emit("StartRun()");
///start a loop that show scalar, plot
//TBenchmark clock;
//clock.Reset();
//clock.Start("timer");
if( pixie->IsRunning() ) thread->Run();
if( pixie->IsRunning() ) thread->Run(); /// call SaveData()
bStartRun->SetEnabled(false);
bStopRun->SetEnabled(true);
}
@ -366,6 +382,8 @@ void * MainWindow::SaveData(void* ptr){
pixie->ReadData(0);
pixie->SaveData();
//TODO Get file size, Fill HISTORGRAM;
}
pixie->ReadData(0);
@ -386,6 +404,8 @@ void MainWindow::StopRun(){
LogMsg("Stop Run");
pixie->PrintStatistics(0);
bStartRun->SetEnabled(true);
bStopRun->SetEnabled(false);
}

View File

@ -11,6 +11,7 @@
#include "Pixie16Class.h"
#include "settingsSummary.h"
#include "scalarPanel.h"
#include "moduleSetting.h"
class TGWindow;
class TGMainFrame;
@ -30,10 +31,13 @@ private:
TGTextEntry * tePath;
TGTextEdit * teLog;
TGTextButton *bStartRun;
TGTextButton *bStopRun;
static Pixie16 * pixie;
SettingsSummary * mainSettings;
SettingsSummary * settingsSummary;
ModuleSetting * moduleSetting;
ScalarPanel * scalarPanel;
TThread * thread;
@ -49,7 +53,7 @@ public:
void GetBaseLine();
void Scope();
void StartRun(); // *SIGNAL*
void StartRun();
static void * SaveData(void* ptr ); /// thread
void StopRun();

View File

@ -11,13 +11,12 @@
#include "scalarPanel.h"
///declaration of static variables
Pixie16 * ScalarPanel::pixie = NULL;
bool ScalarPanel::updateFlag = true;
int ScalarPanel::nMod = 0;
TGTextEntry * ScalarPanel::teRate[][MAXCH] = {NULL};
ScalarPanel::ScalarPanel(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie){
this->pixie = pixie;
@ -55,6 +54,7 @@ ScalarPanel::ScalarPanel(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie)
for( int ch = 0 ; ch < MAXCH ; ch ++){
teRate[mod][ch] = new TGTextEntry(hScalarMod[mod], new TGTextBuffer(10));
teRate[mod][ch]->SetEnabled(false);
teRate[mod][ch]->SetAlignment(kTextRight);
hScalarMod[mod]->AddFrame(teRate[mod][ch], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2,2,2,2));
}

View File

@ -2,7 +2,6 @@
#define SETTINGS_SUMMARY_H
#include <TQObject.h>
///#include <RQ_OBJECT.h>
#include <TGNumberEntry.h>
#include <TGComboBox.h>
@ -16,7 +15,6 @@ class TGMainFrame;
#define MAXCH 16
class SettingsSummary{
/// RQ_OBJECT("SettingsSummary")
private:
TGMainFrame * fMain;