basic settings are done. next, focus on data ACQ for multiple board

This commit is contained in:
carina@hades 2022-10-18 17:23:29 -04:00
parent bf824f76a7
commit 408740f854
9 changed files with 90 additions and 13 deletions

View File

@ -55,6 +55,7 @@ class Data{
void ClearTriggerRate(); void ClearTriggerRate();
void SaveBuffer(const char * fileName); void SaveBuffer(const char * fileName);
unsigned int GetPresentFileSize() {return presentFileSizeByte;}
void PrintBuffer(); //Incorrect void PrintBuffer(); //Incorrect
void DecodeBuffer(bool fastDecode, int verbose = 0); void DecodeBuffer(bool fastDecode, int verbose = 0);
@ -78,6 +79,7 @@ class Data{
int DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose); int DecodePHADualChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose);
int DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose); int DecodePSDDualChannelBlock(unsigned int ChannelMask, bool fastDecode, int verbose);
unsigned int presentFileSizeByte;
unsigned short saveFileIndex; unsigned short saveFileIndex;
}; };
@ -157,7 +159,9 @@ inline void Data::SaveBuffer(const char * fileName){
} }
fwrite(buffer, nByte, 1, haha); fwrite(buffer, nByte, 1, haha);
presentFileSizeByte = ftell(haha);
fclose(haha); fclose(haha);
} }

View File

@ -212,7 +212,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
/// setup thread /// setup thread
//saveDataThread = new TThread("hahaha", SaveData, (void *) 1); //saveDataThread = new TThread("hahaha", SaveData, (void *) 1);
fillHistThread = new TThread("kakaka", FillHistogram, (void *) 1); fillHistThread = new TThread("kakaka", RunThread, (void *) 1);
boardSetting = NULL; boardSetting = NULL;
channelSettingPHA = NULL; channelSettingPHA = NULL;
@ -571,6 +571,14 @@ void MainWindow::OpenChannelSetting(Int_t boardID){
} }
} }
//TODO, should merge into LogMsg.
void MainWindow::UpdateChannelSetting(){
if( digi == NULL ) return;
if( channelSettingPHA != NULL ) channelSettingPHA->ChangeCh();
if( channelSettingPSD != NULL ) channelSettingPSD->ChangeCh();
}
void MainWindow::LogMsg(char * msg){ void MainWindow::LogMsg(char * msg){
time_t now = time(0); time_t now = time(0);
@ -708,7 +716,7 @@ void MainWindow::FitTrace(){
} }
//TODO use the ptr to tell which board, and each digitizer has an indivual thread for savign data and filling hists. //TODO use the ptr to tell which board, and each digitizer has an indivual thread for savign data and filling hists.
void * MainWindow::FillHistogram(void * ptr){ void * MainWindow::RunThread(void * ptr){
printf("=== %s\n", __func__); printf("=== %s\n", __func__);
if( digi == NULL ) return 0; if( digi == NULL ) return 0;
@ -722,13 +730,14 @@ void * MainWindow::FillHistogram(void * ptr){
uint32_t CurrentTime = 0; uint32_t CurrentTime = 0;
uint32_t ElapsedTime = 0; uint32_t ElapsedTime = 0;
TString dataFileName = dataPrefix->GetText(); TString dataFileName = ProgramSetting::DataSavingPath + dataPrefix->GetText();
dataFileName += Form("_run%03d_%03d", (int) runIDEntry->GetNumber(), (int) digi[boardID]->GetSerialNumber()); dataFileName += Form("_run%03d_%03d", (int) runIDEntry->GetNumber(), (int) digi[boardID]->GetSerialNumber());
printf("|%s|\n", dataFileName.Data()); printf("|%s|\n", dataFileName.Data());
Data * data = digi[boardID]->GetData(); Data * data = digi[boardID]->GetData();
data->AllocateMemory(); unsigned int bufferSize = digi[boardID]->CalByteForBuffer();
data->AllocateMemory(bufferSize);
while(digi[boardID]->IsRunning()){ while(digi[boardID]->IsRunning()){
@ -746,6 +755,7 @@ void * MainWindow::FillHistogram(void * ptr){
if( cbMode->GetSelected() == Mode_DataRun ){ if( cbMode->GetSelected() == Mode_DataRun ){
// Rate graph? // Rate graph?
data->SaveBuffer(dataFileName.Data()); data->SaveBuffer(dataFileName.Data());
LogMsg((char *) Form("File Size : %.2f MB", data->GetPresentFileSize() / 1024./1024. );
}else{ }else{

View File

@ -88,7 +88,7 @@ public:
void StartRun(); void StartRun();
void StopRun(); void StopRun();
static void * FillHistogram(void * ptr); /// thread static void * RunThread(void * ptr); /// thread
void PlotSingleTrace(); void PlotSingleTrace();
void FitTrace(); void FitTrace();
@ -96,6 +96,7 @@ public:
void Oscilloscope(); void Oscilloscope();
void OpenChannelSetting(Int_t); void OpenChannelSetting(Int_t);
void UpdateChannelSetting();
void LogMsg(char * ); void LogMsg(char * );
void GoodBye(); void GoodBye();

View File

@ -360,6 +360,13 @@ BoardSetting::BoardSetting(const TGWindow *p, UInt_t w, UInt_t h, Digitizer ** d
cbFanCtrl->Resize(100, 20); cbFanCtrl->Resize(100, 20);
cbFanCtrl->Connect("Changed()", "BoardSetting", this, "SetFanSpeedControl()"); cbFanCtrl->Connect("Changed()", "BoardSetting", this, "SetFanSpeedControl()");
TGVerticalFrame * vBdCfga_haha = new TGVerticalFrame(hframeBdCfg3); hframeBdCfg3->AddFrame(vBdCfga_haha, new TGLayoutHints( kLHintsLeft, 5, 5, 10, 0) );
TGLabel * lbBufferSize = new TGLabel(vBdCfga_haha, "Buffer Size [MByte]", kHorizontalFrame); vBdCfga_haha->AddFrame(lbBufferSize, kaka);
txtBufferSize = new TGTextEntry(vBdCfga_haha, ""); vBdCfga_haha->AddFrame(txtBufferSize);
txtBufferSize->SetEnabled(false);
txtBufferSize->Resize(100, 20);
} }
{///========== ACQ control {///========== ACQ control
@ -905,6 +912,8 @@ void BoardSetting::ChangeBoard(){
cbAggOrg->Select( digi[boardID]->GetSettingFromMemory(Register::DPP::AggregateOrganization) , false); cbAggOrg->Select( digi[boardID]->GetSettingFromMemory(Register::DPP::AggregateOrganization) , false);
numAggBLT->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::MaxAggregatePerBlockTransfer) , false); numAggBLT->SetNumber( digi[boardID]->GetSettingFromMemory(Register::DPP::MaxAggregatePerBlockTransfer) , false);
FillBufferSizeTextBox();
if( digi[boardID]->GetNChannel() == 8 ){ if( digi[boardID]->GetNChannel() == 8 ){
///FAN Speed control only for desktop version ///FAN Speed control only for desktop version
cbFanCtrl->SetEnabled(true); cbFanCtrl->SetEnabled(true);
@ -1139,6 +1148,10 @@ void BoardSetting::Haha(Int_t boardID){ /// this is for sending signal to mainwi
Emit("Haha(Int_t)", boardID); Emit("Haha(Int_t)", boardID);
} }
void BoardSetting::TellChannelSettingtoUpdate(){
Emit("TellChannelSettingtoUpdate()");
}
void BoardSetting::ResetSettingToDefault(){ /// same for PHA and PSD void BoardSetting::ResetSettingToDefault(){ /// same for PHA and PSD
printf("=== %s\n", __func__); printf("=== %s\n", __func__);
@ -1218,6 +1231,7 @@ void BoardSetting::SetAggregateOrganization(){ /// same for PHA and PSD
int boardID = boardIDEntry->GetNumber(); int boardID = boardIDEntry->GetNumber();
digi[boardID]->WriteRegister(Register::DPP::AggregateOrganization, cbAggOrg->GetSelected()); digi[boardID]->WriteRegister(Register::DPP::AggregateOrganization, cbAggOrg->GetSelected());
FillBufferSizeTextBox();
} }
void BoardSetting::SetReadOutAggregate(){ /// same for PHA and PSD void BoardSetting::SetReadOutAggregate(){ /// same for PHA and PSD
@ -1226,6 +1240,8 @@ void BoardSetting::SetReadOutAggregate(){ /// same for PHA and PSD
if( digi == NULL ) return; if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber(); int boardID = boardIDEntry->GetNumber();
digi[boardID]->WriteRegister(Register::DPP::MaxAggregatePerBlockTransfer, (unsigned int) numAggBLT->GetNumber()); digi[boardID]->WriteRegister(Register::DPP::MaxAggregatePerBlockTransfer, (unsigned int) numAggBLT->GetNumber());
FillBufferSizeTextBox();
} }
@ -1487,7 +1503,7 @@ void BoardSetting::SaveSettingFile(){
const char *filetypes[] = { "Setting File", "*.bin", const char *filetypes[] = { "Setting File", "*.bin",
0, 0}; 0, 0};
static TString dir("."); static TString dir(".");
TGFileInfo fi; TGFileInfo fi;
fi.fFileTypes = filetypes; fi.fFileTypes = filetypes;
@ -1504,10 +1520,15 @@ void BoardSetting::SaveSettingFile(){
if( digi == NULL ) { if( digi == NULL ) {
}else{ }else{
int boardID = boardIDEntry->GetNumber(); int boardID = boardIDEntry->GetNumber();
digi[boardID]->OpenSettingBinary( fi.fFilename ); digi[boardID]->OpenSettingBinary( fi.fFilename );
} }
} }
void BoardSetting::FillBufferSizeTextBox(){
if( digi == NULL ) return;
int boardID = boardIDEntry->GetNumber();
uint32_t buffer = digi[boardID]->CalByteForBuffer();
txtBufferSize->SetText(Form("%.2f", buffer/1024./1024.));
}

View File

@ -52,6 +52,8 @@ class BoardSetting{
TGNumberEntry * numAggBLT; /// number of Agg pre Block transfer TGNumberEntry * numAggBLT; /// number of Agg pre Block transfer
TGComboBox * cbFanCtrl; TGComboBox * cbFanCtrl;
TGTextEntry * txtBufferSize;
/// ACQ control /// ACQ control
TGComboBox * cbAcqMode; TGComboBox * cbAcqMode;
TGCheckButton * bAcqArm; TGCheckButton * bAcqArm;
@ -177,11 +179,17 @@ class BoardSetting{
///==== Others ///==== Others
void LogMsg(TString msg); // *SIGNAL* void LogMsg(TString msg); // *SIGNAL*
void Haha(Int_t boardID); // *SIGNAL* /// Haha is for sending signal to mainwindow to open channel setting for the board
void Haha(Int_t boardID); // *SIGNAL*
/// this send signal to MainWindows, and tell channel setting to update
//TODO to merge to LogMsg
void TellChannelSettingtoUpdate(); // *SIGNAL*
void ReadData(); void ReadData();
void ProgramDefaultBoard(); void ProgramDefaultBoard();
void ProgramBoardFromFile(); void ProgramBoardFromFile();
void SaveSettingFile(); void SaveSettingFile();
void FillBufferSizeTextBox();
}; };
#endif #endif

View File

@ -23,7 +23,7 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
fMain->SetWindowName("Channel Settings PHA"); fMain->SetWindowName("Channel Settings PHA");
fMain->Connect("CloseWindow()", "ChannelSettingPHA", this, "CloseWindow()"); fMain->Connect("CloseWindow()", "ChannelSettingPHA", this, "CloseWindow()");
TGLayoutHints * layoutHintsR = new TGLayoutHints(kLHintsRight, 5,5,3,2); /// left, right, top, bottom TGLayoutHints * layoutHintsR = new TGLayoutHints(kLHintsRight, 5,5,3,3); /// left, right, top, bottom
TGLayoutHints * layoutHints = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5,5,0,0); /// left, right, top, bottom TGLayoutHints * layoutHints = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 5,5,0,0); /// left, right, top, bottom
TGVerticalFrame * vframe = new TGVerticalFrame(fMain); TGVerticalFrame * vframe = new TGVerticalFrame(fMain);
@ -118,6 +118,11 @@ ChannelSettingPHA::ChannelSettingPHA(const TGWindow *p, UInt_t w, UInt_t h, Digi
numEventAgg->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 511); numEventAgg->SetLimits(TGNumberFormat::kNELLimitMinMax, 0, 511);
numEventAgg->Connect("Modified()", "ChannelSettingPHA", this, "SetEventAggregate()"); numEventAgg->Connect("Modified()", "ChannelSettingPHA", this, "SetEventAggregate()");
TGLabel * lbBuffer = new TGLabel(vfInput1, "Buffer Size [MByte]"); vfInput1->AddFrame(lbBuffer, layoutHintsR);
eBuffer = new TGTextEntry(vfInput2,""); vfInput2->AddFrame(eBuffer, layoutHints);
eBuffer->Resize(width, 20);
eBuffer->SetEnabled(false);
///const uint32_t ChannelDCOffset = 0x1098; /// R/W ///const uint32_t ChannelDCOffset = 0x1098; /// R/W
TGLabel * lbDCOffset = new TGLabel(vfInput1, "DC offset [%]"); vfInput1->AddFrame(lbDCOffset, layoutHintsR); TGLabel * lbDCOffset = new TGLabel(vfInput1, "DC offset [%]"); vfInput1->AddFrame(lbDCOffset, layoutHintsR);
numDCOffset = new TGNumberEntry(vfInput2, 20, 0, 0, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative); vfInput2->AddFrame(numDCOffset, layoutHints); numDCOffset = new TGNumberEntry(vfInput2, 20, 0, 0, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative); vfInput2->AddFrame(numDCOffset, layoutHints);
@ -680,6 +685,10 @@ void ChannelSettingPHA::SetEventAggregate() {
short ch = chIDEntry->GetNumber(); short ch = chIDEntry->GetNumber();
unsigned int temp = numEventAgg->GetNumber(); unsigned int temp = numEventAgg->GetNumber();
if( digi != NULL ) digi[boardID]->WriteRegister(Register::DPP::NumberEventsPerAggregate_G, temp , ch); if( digi != NULL ) digi[boardID]->WriteRegister(Register::DPP::NumberEventsPerAggregate_G, temp , ch);
uint32_t buffer = digi[boardID]->CalByteForBuffer();
eBuffer->SetText(Form("%.2f", buffer/1024./1024.));
} }

View File

@ -28,7 +28,7 @@ class ChannelSettingPHA{
TGNumberEntry * numRecordLength; TGNumberEntry * numRecordLength;
TGNumberEntry * numPreTrigger; TGNumberEntry * numPreTrigger;
TGNumberEntry * numEventAgg; TGNumberEntry * numEventAgg;
TGTextEntry * eBuffer ;
TGNumberEntry * numTriggerThreshold; TGNumberEntry * numTriggerThreshold;
TGNumberEntry * numTriggerHoldOff; TGNumberEntry * numTriggerHoldOff;

View File

@ -11,6 +11,7 @@
std::string ProgramSetting::IP = "http://fsunuc.physics.fsu.edu/influx/"; std::string ProgramSetting::IP = "http://fsunuc.physics.fsu.edu/influx/";
std::string ProgramSetting::databaseName = "testing"; std::string ProgramSetting::databaseName = "testing";
std::string ProgramSetting::DataSavingPath = "/home/catrina/FSUDAQ/";
ProgramSetting::ProgramSetting(const TGWindow *p){ ProgramSetting::ProgramSetting(const TGWindow *p){
fMain = new TGMainFrame(p, 600, 400); fMain = new TGMainFrame(p, 600, 400);
@ -20,7 +21,7 @@ ProgramSetting::ProgramSetting(const TGWindow *p){
TGVerticalFrame * vframe = new TGVerticalFrame(fMain); fMain->AddFrame(vframe); TGVerticalFrame * vframe = new TGVerticalFrame(fMain); fMain->AddFrame(vframe);
{///============== Database {///============== Database
TGGroupFrame * gfDatabase = new TGGroupFrame(vframe, "Database Setting", kHorizontalFrame); vframe->AddFrame(gfDatabase, new TGLayoutHints(kLHintsExpandY, 5, 5, 5, 5)); TGGroupFrame * gfDatabase = new TGGroupFrame(vframe, "Database Setting", kHorizontalFrame); vframe->AddFrame(gfDatabase, new TGLayoutHints(kLHintsExpandY | kLHintsExpandX , 5, 5, 5, 5));
TGVerticalFrame * vfDB = new TGVerticalFrame(gfDatabase); gfDatabase->AddFrame(vfDB); TGVerticalFrame * vfDB = new TGVerticalFrame(gfDatabase); gfDatabase->AddFrame(vfDB);
@ -37,6 +38,18 @@ ProgramSetting::ProgramSetting(const TGWindow *p){
} }
{///============== Data Saving Path
TGGroupFrame * gfData = new TGGroupFrame(vframe, "Data Storage", kHorizontalFrame); vframe->AddFrame(gfData, new TGLayoutHints(kLHintsExpandY | kLHintsExpandY , 5, 5, 5, 5));
TGVerticalFrame * vfData = new TGVerticalFrame(gfData); gfData->AddFrame(vfData);
TGHorizontalFrame * hfData = new TGHorizontalFrame(vfData); vfData->AddFrame(hfData);
TGLabel * lbDataPath = new TGLabel(hfData, "Data Absolute Path :"); hfData->AddFrame(lbDataPath, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
txtDataPath = new TGTextEntry(hfData, DataSavingPath.c_str()); hfData->AddFrame(txtDataPath, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 5,5,3,3));
txtDataPath->Connect("ReturnPressed()", "ProgramSetting", this, "SetDataPath()");
txtDataPath->Resize(300, 20);
}
{///============== Read Time event building {///============== Read Time event building
@ -65,3 +78,11 @@ void ProgramSetting::SetDataBase(){
printf("Name: %s\n", databaseName.c_str()); printf("Name: %s\n", databaseName.c_str());
} }
void ProgramSetting::SetDataPath(){
DataSavingPath = txtDataPath->GetText();
printf("DataSavingPath : %s\n", DataSavingPath.c_str());
}

View File

@ -22,6 +22,7 @@ class ProgramSetting{
TGTextEntry * txtIP; TGTextEntry * txtIP;
TGTextEntry * txtDBName; TGTextEntry * txtDBName;
TGTextEntry * txtDataPath;
public: public:
ProgramSetting(const TGWindow *p); ProgramSetting(const TGWindow *p);
@ -31,8 +32,10 @@ class ProgramSetting{
static std::string IP; static std::string IP;
static std::string databaseName; static std::string databaseName;
static std::string DataSavingPath;
void SetDataBase(); void SetDataBase();
void SetDataPath();
}; };
#endif #endif