some fixes

This commit is contained in:
carina@hades 2022-10-31 16:39:19 -04:00
parent 68c55663ba
commit 6d51d1c768
8 changed files with 109 additions and 48 deletions

View File

@ -67,6 +67,7 @@ TGNumberEntry * MainWindow::chIDEntry = NULL;
TGComboBox* MainWindow::cbMode = NULL;
TGTextEntry * MainWindow::dataPrefix = NULL;
TGNumberEntry * MainWindow::runIDEntry = NULL;
TGCheckButton * MainWindow::cbDataRun = NULL;
BoardSetting * MainWindow::boardSetting = NULL;
@ -90,7 +91,6 @@ enum ModeIdentifiers{
Mode_EnergyHist,
Mode_CountHist,
Mode_Oscilloscope,
Mode_DataRun
};
@ -146,18 +146,20 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
fMenuBar->AddPopup("&Utility", fMenuUtility, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0));
}
TGLayoutHints * uniLayoutHints = new TGLayoutHints(kLHintsNormal, 2,2,10,0); ///left, right, top, bottom
TGLayoutHints * hahaLayoutHints = new TGLayoutHints(kLHintsNormal, 2,2,15,0); ///left, right, top, bottom
TGLayoutHints * haha = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 2, 10, 0); ///left, right, top, bottom
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain); fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,2,2,2,2));
{///================= Create a horizontal frame widget with buttons
TGGroupFrame * group0 = new TGGroupFrame(hframe, "Run Control", kHorizontalFrame); hframe->AddFrame(group0 );
TGGroupFrame * group0 = new TGGroupFrame(hframe, "Run Control", kVerticalFrame); hframe->AddFrame(group0);
TGVerticalFrame * vframe = new TGVerticalFrame(group0); group0->AddFrame(vframe);
TGHorizontalFrame *hfg0 = new TGHorizontalFrame(vframe); vframe->AddFrame(hfg0 ,new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
TGLayoutHints * uniLayoutHints = new TGLayoutHints(kLHintsNormal, 2,2,10,0); ///left, right, top, bottom
bOpenDigitizers = new TGTextButton(hfg0,"Open Digitizers"); hfg0->AddFrame(bOpenDigitizers, uniLayoutHints);
bOpenDigitizers->Connect("Clicked()","MainWindow",this,"OpenDigitizers()");
@ -169,34 +171,35 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
bStopRun->Connect("Clicked()", "MainWindow", this, "StopRun()");
bStopRun->SetEnabled(false);
TGLabel * lbMode = new TGLabel(hfg0, "Mode"); hfg0->AddFrame(lbMode, uniLayoutHints);
TGLabel * lbMode = new TGLabel(hfg0, "Mode"); hfg0->AddFrame(lbMode, hahaLayoutHints);
cbMode = new TGComboBox(hfg0); hfg0->AddFrame(cbMode, uniLayoutHints);
cbMode->AddEntry("Energy Hist.", Mode_EnergyHist);
cbMode->AddEntry("Count Hist.", Mode_CountHist);
cbMode->AddEntry("Ocsilloscope.", Mode_Oscilloscope);
cbMode->AddEntry("Data Run", Mode_DataRun);
cbMode->Select(Mode_Oscilloscope, false);
cbMode->Resize(80, 20);
cbMode->Connect("Changed()", "MainWindow", this, "ChangePlot()");
TGHorizontalFrame *hfg1 = new TGHorizontalFrame(vframe); vframe->AddFrame(hfg1 ,new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
TGLabel * lbDataPath = new TGLabel(hfg1, "Save Data Prefix"); hfg1->AddFrame(lbDataPath, uniLayoutHints);
TGLabel * lbDataPath = new TGLabel(hfg1, "Save Data Prefix"); hfg1->AddFrame(lbDataPath, hahaLayoutHints);
dataPrefix = new TGTextEntry(hfg1, ProgramSetting::ExpName.c_str()); hfg1->AddFrame(dataPrefix,uniLayoutHints);
dataPrefix->SetEnabled(false);
dataPrefix->Resize(100, 20);
TGLabel * lbRunNum = new TGLabel(hfg1, "Run"); hfg1->AddFrame(lbRunNum, uniLayoutHints);
TGLabel * lbRunNum = new TGLabel(hfg1, "Run"); hfg1->AddFrame(lbRunNum, hahaLayoutHints);
runIDEntry = new TGNumberEntry(hfg1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); hfg1->AddFrame(runIDEntry, uniLayoutHints);
runIDEntry->SetNumber(lastRunID, false);
runIDEntry->SetWidth(50);
cbDataRun = new TGCheckButton(hfg1, "Data Run", 1); hfg1->AddFrame(cbDataRun, hahaLayoutHints);
cbDataRun->SetState(kButtonUp);
}
{///================= single Channel group
TGGroupFrame * group1 = new TGGroupFrame(hframe, "Single Channel", kHorizontalFrame); hframe->AddFrame(group1, new TGLayoutHints(kLHintsExpandY));
TGHorizontalFrame *hfg1 = new TGHorizontalFrame(group1,200,30); group1->AddFrame(hfg1 ,new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0));
TGLayoutHints * haha = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 2, 10, 0); ///left, right, top, bottom
TGLabel * lb0 = new TGLabel(hfg1, "Board"); hfg1->AddFrame(lb0, haha);
boardIDEntry = new TGNumberEntry(hfg1, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); hfg1->AddFrame(boardIDEntry, haha);
@ -243,8 +246,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
fMain->MapWindow();
/// setup thread
//saveDataThread = new TThread("hahaha", SaveData, (void *) 1);
fillHistThread = new TThread("kakaka", RunThread, (void *) 1);
runThread = new TThread("kakaka", Run, (void *) 1);
boardSetting = NULL;
channelSettingPHA = NULL;
@ -254,9 +256,10 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
programSetting = NULL;
LogMsg((char*)"The LogMsg is not complete for all actions. [update later]");
LogMsg((char*)"Please \"Program Setting\" to set data folder");
LogMsg((char*)"Please \"Open Digitizers\" to start.");
HandleMenu(M_DIGITIZER_OPEN);
//HandleMenu(M_DIGITIZER_OPEN);
//HandleMenu(M_BOARD_SETTINGS);
//HandleMenu(M_CH_SETTING_PHA);
//HandleMenu(M_CH_SETTING_PSD);
@ -335,6 +338,7 @@ MainWindow::~MainWindow() {
delete dataPrefix;
delete runIDEntry;
delete cbDataRun;
delete bPlotSingleTrace;
delete bFitTrace;
@ -345,7 +349,7 @@ MainWindow::~MainWindow() {
delete registerSetting;
delete triggerSummary;
delete programSetting;
delete fillHistThread;
delete runThread;
fMain->Cleanup();
delete fMain;
@ -469,7 +473,7 @@ void MainWindow::OpenDigitizers(){
digi[i]->GetDPPString().c_str(),
digi[i]->GetModelName().c_str()));
digi[i]->OpenSettingBinary("./setting_" + std::to_string(digi[i]->GetSerialNumber()) + ".bin");
digi[i]->OpenSettingBinary(ProgramSetting::DataSavingPath + "/settings/setting_" + std::to_string(digi[i]->GetSerialNumber()) + ".bin");
}
fMenuDigitizers->DisableEntry( M_DIGITIZER_OPEN);
@ -566,7 +570,7 @@ void MainWindow::StartRun(){
bPlotSingleTrace->SetEnabled(false);
bFitTrace->SetEnabled(false);
if( cbMode->GetSelected() == Mode_DataRun ) {
if( cbDataRun->GetState() == kButtonDown ) {
cbMode->SetEnabled(false);
HandleMenu(M_TRIGGER_SUMMARY);
}
@ -577,7 +581,7 @@ void MainWindow::StartRun(){
if( digi[i]->IsRunning() ) threadFlag = true;
}
if( threadFlag ) fillHistThread->Run();
if( threadFlag ) runThread->Run();
if( boardSetting != NULL ) boardSetting->ReadStatus();
@ -589,7 +593,7 @@ void MainWindow::StopRun(){
for( int i = 0; i < nDigi; i++) digi[i]->StopACQ();
fillHistThread->Join();
runThread->Join();
///===== clear data;
for( int i = 0; i < nDigi; i++) digi[i]->GetData()->ClearTriggerRate();
@ -604,7 +608,8 @@ void MainWindow::StopRun(){
if( triggerSummary != NULL ) triggerSummary->CloseWindow();
if( cbMode->GetSelected() == Mode_DataRun ){
///if( cbMode->GetSelected() == Mode_DataRun ){
if( cbDataRun->GetState() == kButtonDown ) {
int runID = runIDEntry->GetNumber();
lastRunID = runID;
runIDEntry->SetNumber(runID +1);
@ -658,15 +663,20 @@ void MainWindow::LogMsg(char * msg){
}
void MainWindow::DrawDummyGraph(){
int boardID = boardIDEntry->GetNumber();
int chID = chIDEntry->GetNumber();
int ch2ns = (int) digi[boardID]->GetCh2ns();
int ch2ns = 4.0;
uint32_t rl = 125;
fEcanvas->GetCanvas()->cd();
uint32_t rl = digi[boardID]->GetSettingFromMemory(Register::DPP::RecordLength_G, chID);
if( digi != NULL ) {
ch2ns = (int) digi[boardID]->GetCh2ns();
rl = digi[boardID]->GetSettingFromMemory(Register::DPP::RecordLength_G, chID);
}
gDummy->SetPoint(1, 8.*rl*ch2ns, 0);
gDummy->SetLineColor(15);
gDummy->Draw("AL");
@ -718,13 +728,6 @@ void MainWindow::PlotSingleTrace(){
gAnaTrace1->SetPoint(i, i*ch2ns*(1+isDualTrace), (data->Waveform1[chID][0])[i]);
}
if( traceLength <= gAnaTrace1->GetN() ){
for( int i = gAnaTrace1->GetN() -1 ; i >= traceLength ; i--){
gAnaTrace1->RemovePoint(i);
if( isDualTrace) gAnaTrace2->RemovePoint(i);
gDigiTrace1->RemovePoint(i);
}
}
double xmin, xmax, ymin, ymax;
gAnaTrace1->ComputeRange(xmin, ymin, xmax, ymax);
@ -734,7 +737,6 @@ void MainWindow::PlotSingleTrace(){
short haha = (data->Waveform2[chID][0])[i];
if( haha > 0x1FFF ) haha -= 0x3FFF;
gAnaTrace2->SetPoint(i, i*ch2ns*(1+isDualTrace), haha);
//gAnaTrace2->SetPoint(i, i*ch2ns*(1+isDualTrace), (data->Waveform2[chID][0])[i] );
}
}
}
@ -815,7 +817,7 @@ void MainWindow::ChangePlot(){
}
//TODO use the ptr to tell which board, and each digitizer has an indivual thread for savign data and filling hists.
void * MainWindow::RunThread(void * ptr){
void * MainWindow::Run(void * ptr){
printf("=== %s\n", __func__);
if( digi == NULL ) return 0;
@ -829,11 +831,17 @@ void * MainWindow::RunThread(void * ptr){
uint32_t CurrentTime = 0;
uint32_t ElapsedTime = 0;
TString dataFileName = ProgramSetting::DataSavingPath + "/" + dataPrefix->GetText();
TString dataFileName = ProgramSetting::DataSavingPath + "/data/" + dataPrefix->GetText();
dataFileName += Form("_run%03d", (int) runIDEntry->GetNumber());
printf("|%s|\n", dataFileName.Data());
if( cbDataRun->GetState() == kButtonDown) {
TString msg = Form("Save data to : %s_***.bin\n", dataFileName.Data());
teLog->AddLine(msg.Data());
teLog->ShowBottom();
}
uint32_t bdConfig = digi[boardID]->GetSettingFromMemory(Register::DPP::BoardConfiguration);
bool isDualTrace = ( bdConfig >> 11 ) & 0x1;
bool hasTrace = (bdConfig >> 16 ) & 0x1;
@ -854,7 +862,7 @@ void * MainWindow::RunThread(void * ptr){
if( data->nByte > 0 ){
//data->PrintStat();
if( cbMode->GetSelected() == Mode_DataRun ){
if( cbDataRun->GetState() == kButtonDown ) {
// Rate graph?
data->SaveBuffer(dataFileName.Data());
data->DecodeBuffer(true, 0);
@ -872,7 +880,7 @@ void * MainWindow::RunThread(void * ptr){
}
}
if( cbMode->GetSelected() != Mode_DataRun){
if( cbDataRun->GetState() == kButtonUp ) {
fEcanvas->GetCanvas()->cd();
@ -891,15 +899,9 @@ void * MainWindow::RunThread(void * ptr){
}
}
if( traceLength <= gAnaTrace1->GetN() ){
for( int i = gAnaTrace1->GetN() -1 ; i >= traceLength ; i--){
gAnaTrace1->RemovePoint(i);
if( isDualTrace) gAnaTrace2->RemovePoint(i);
}
}
/// since the gDummy fixed the draw range, it does not really matter to remove extra points
gAnaTrace1->Draw("same L");
///this causes warning
///gAnaTrace1->GetYaxis();//->SetRangeUser(0, 0x3FFF);
gAnaTrace2->Draw("same L");
}
}

View File

@ -48,6 +48,7 @@ private:
static TGComboBox* cbMode;
static TGTextEntry * dataPrefix;
static TGNumberEntry * runIDEntry;
static TGCheckButton * cbDataRun;
TGTextButton *bPlotSingleTrace;
TGTextButton *bFitTrace;
@ -63,7 +64,7 @@ private:
TriggerSummary * triggerSummary;
ProgramSetting * programSetting;
TThread * fillHistThread;
TThread * runThread;
public:
MainWindow(const TGWindow *p, UInt_t w, UInt_t h);
@ -80,7 +81,7 @@ public:
void StartRun();
void StopRun();
static void * RunThread(void * ptr); /// thread
static void * Run(void * ptr); /// thread
void PlotSingleTrace();
void FitTrace();

1
DAQ/FSUDAQ.sh Symbolic link
View File

@ -0,0 +1 @@
../FSUDAQ.sh

View File

@ -1,5 +1,6 @@
#include <TApplication.h>
#include <TGClient.h>
#include <TSystem.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TRandom.h>
@ -9,19 +10,28 @@
#include <fstream>
#include <iostream>
#include <sys/stat.h>
#include <experimental/filesystem>
#include "programSetting.h"
namespace fs = std::experimental::filesystem;
std::string ProgramSetting::databaseIP = "http://fsunuc.physics.fsu.edu/influx/";
std::string ProgramSetting::databaseName = "testing";
std::string ProgramSetting::DataSavingPath = "/home/catrina/FSUDAQ";
std::string ProgramSetting::ExpName = "Test";
std::string ProgramSetting::ElogIP = "128.186.111.127";
bool ProgramSetting::EnableElog = false;
bool ProgramSetting::EnableDatabase = false;
const std::string ProgramSetting::settingFileName = "FSUDAQ.sh";
///this is declared at FSUDAQ.cpp
extern unsigned short lastRunID;
extern unsigned short nDigi;
extern Digitizer ** digi;
ProgramSetting::ProgramSetting(const TGWindow *p){
@ -71,8 +81,9 @@ ProgramSetting::ProgramSetting(const TGWindow *p){
TGVerticalFrame * vfLabel = new TGVerticalFrame(hfDB1, 200); hfDB1->AddFrame(vfLabel);
TGVerticalFrame * vfTxt = new TGVerticalFrame(hfDB1); hfDB1->AddFrame(vfTxt);
TGVerticalFrame * vfOnOff = new TGVerticalFrame(hfDB1); hfDB1->AddFrame(vfOnOff);
TGLabel * lbIP = new TGLabel(vfLabel, "IP :"); vfLabel->AddFrame(lbIP, haha);
TGLabel * lbIP = new TGLabel(vfLabel, "DB IP :"); vfLabel->AddFrame(lbIP, haha);
TGLabel * lbDBName = new TGLabel(vfLabel, "DB Name :"); vfLabel->AddFrame(lbDBName, haha);
TGLabel * lbElogIP = new TGLabel(vfLabel, "Elog IP :"); vfLabel->AddFrame(lbElogIP, haha);
@ -87,6 +98,17 @@ ProgramSetting::ProgramSetting(const TGWindow *p){
txtElogIP = new TGTextEntry(vfTxt, ElogIP.c_str()); vfTxt->AddFrame(txtElogIP, kaka);
txtElogIP->Resize(300, 20);
txtElogIP->Connect("ReturnPressed()", "ProgramSetting", this, "SetSetting()");
TGLabel * lbdummy0 = new TGLabel(vfOnOff, ""); vfOnOff->AddFrame(lbdummy0, haha);
cbDatabase = new TGCheckButton(vfOnOff, "Enable Database", 1); vfOnOff->AddFrame(cbDatabase, kaka);
cbDatabase->SetState(kButtonUp);
cbDatabase->Connect("Clicked()", "ProgramSetting", this, "SetDataBaseElogOnOff()");
cbElog = new TGCheckButton(vfOnOff, "Enable Elog", 1); vfOnOff->AddFrame(cbElog, kaka);
cbElog->SetState(kButtonUp);
cbElog->Connect("Clicked()", "ProgramSetting", this, "SetDataBaseElogOnOff()");
}
{///============== Read Time event building
@ -108,6 +130,9 @@ ProgramSetting::~ProgramSetting(){
delete txtDataPath;
delete txtExpName;
delete txtElogIP;
delete cbDatabase;
delete cbElog;
fMain->Cleanup();
delete fMain;
@ -127,6 +152,14 @@ void ProgramSetting::SetSetting(){
SaveProgramSetting();
gSystem->mkdir(( ProgramSetting::DataSavingPath + "/data").c_str());
gSystem->mkdir(( ProgramSetting::DataSavingPath + "/settings").c_str());
///save digitizer settings to the settings folder
for( int i = 0; i < nDigi; i ++){
digi[i]->OpenSettingBinary(ProgramSetting::DataSavingPath + "/settings/setting_" + std::to_string(digi[i]->GetSerialNumber()) + ".bin");
}
Emit("SetSetting()");
}
@ -144,7 +177,7 @@ void ProgramSetting::SetFolder(){
if( fi.fFilename == NULL) return;
txtDataPath->SetText(fi.fFilename);
txtDataPath->SetText(fi.fFilename, false);
SetSetting();
@ -213,8 +246,18 @@ void ProgramSetting::SaveProgramSetting(){
fputs( ("lastRunID = " + std::to_string(lastRunID) + "\n").c_str(), fileOut);
fclose(fileOut);
gSystem->CopyFile(ProgramSetting::settingFileName.c_str(), (ProgramSetting::DataSavingPath + "/FSUDAQ.sh").c_str(), true); /// overwrite
}else{
printf("%s | Cannot open file : %s.\n", __func__, ProgramSetting::settingFileName.c_str());
}
}
void ProgramSetting::SetDataBaseElogOnOff(){
EnableDatabase = ( cbDatabase->GetState() == kButtonDown ? true : false );
EnableElog = ( cbElog->GetState() == kButtonDown ? true : false );
}

View File

@ -26,6 +26,9 @@ class ProgramSetting{
TGTextEntry * txtExpName;
TGTextEntry * txtElogIP;
TGCheckButton * cbDatabase;
TGCheckButton * cbElog;
public:
ProgramSetting(const TGWindow *p);
virtual ~ProgramSetting();
@ -38,6 +41,9 @@ class ProgramSetting{
static std::string ExpName;
static std::string ElogIP;
static bool EnableElog;
static bool EnableDatabase;
const static std::string settingFileName; // fixed as FSUDAQ.sh
void SetSetting(); // *SIGNAL*
@ -47,6 +53,8 @@ class ProgramSetting{
static void SaveProgramSetting();
void SetFolder();
void SetDataBaseElogOnOff();
};

View File

@ -3,4 +3,4 @@ DataPath = /home/catrina/FSUDAQ/expDir
DatabaseIP = http://fsunuc.physics.fsu.edu/influx/
DatabaseName = testing
ElogIP = 128.186.111.127
lastRunID = 10
lastRunID = 0

6
haha/FSUDAQ.sh Normal file
View File

@ -0,0 +1,6 @@
ExpName = ZZZZZ
DataPath = /home/catrina/FSUDAQ/haha
DatabaseIP = http://fsunuc.physics.fsu.edu/influx/
DatabaseName = testing
ElogIP = 128.186.111.127
lastRunID = 1