add time in Log massge, add file size and rate when taking data, placeholder for histogram filling
This commit is contained in:
parent
fc8b93c696
commit
f761936958
|
@ -807,6 +807,16 @@ void Pixie16::SaveData(){
|
||||||
if( outFile.is_open() ) outFile.write(reinterpret_cast<char*>(ExtFIFO_Data), nFIFOWords * sizeof(uint32_t));
|
if( outFile.is_open() ) outFile.write(reinterpret_cast<char*>(ExtFIFO_Data), nFIFOWords * sizeof(uint32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long int Pixie16::GetFileSize(){
|
||||||
|
|
||||||
|
if( outFile.is_open() ){
|
||||||
|
return outFile.tellg();
|
||||||
|
}else{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Pixie16::CloseFile(){
|
void Pixie16::CloseFile(){
|
||||||
outFile.close();
|
outFile.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ private:
|
||||||
DataBlock * data;
|
DataBlock * data;
|
||||||
unsigned int nextWord;
|
unsigned int nextWord;
|
||||||
|
|
||||||
std::ofstream outFile;
|
std::fstream outFile;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -218,6 +218,7 @@ public:
|
||||||
|
|
||||||
void OpenFile(std::string fileName, bool append);
|
void OpenFile(std::string fileName, bool append);
|
||||||
void SaveData();
|
void SaveData();
|
||||||
|
long int GetFileSize();
|
||||||
void CloseFile();
|
void CloseFile();
|
||||||
|
|
||||||
|
|
||||||
|
|
155
pixieDAQ.cpp
155
pixieDAQ.cpp
|
@ -13,8 +13,8 @@
|
||||||
#include <TAxis.h>
|
#include <TAxis.h>
|
||||||
#include <TBenchmark.h>
|
#include <TBenchmark.h>
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <ctime>
|
||||||
|
|
||||||
#include "Pixie16Class.h"
|
#include "Pixie16Class.h"
|
||||||
|
|
||||||
|
@ -33,12 +33,15 @@ enum MenuIdentifiers{
|
||||||
|
|
||||||
///make static members
|
///make static members
|
||||||
Pixie16 * MainWindow::pixie = NULL;
|
Pixie16 * MainWindow::pixie = NULL;
|
||||||
|
TGTextEdit * MainWindow::teLog = NULL;
|
||||||
|
TRootEmbeddedCanvas * MainWindow::fEcanvas = NULL;
|
||||||
|
TH1F * MainWindow::h1[13][16]={NULL};
|
||||||
|
|
||||||
MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
|
MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
|
||||||
|
|
||||||
printf("Removing Pixie16Msg.log \n");
|
printf("Removing Pixie16Msg.log \n");
|
||||||
remove( "Pixie16Msg.log");
|
remove( "Pixie16Msg.log");
|
||||||
|
|
||||||
pixie = new Pixie16();
|
pixie = new Pixie16();
|
||||||
if ( pixie->GetStatus() < 0 ) {
|
if ( pixie->GetStatus() < 0 ) {
|
||||||
printf("Exiting program... \n");
|
printf("Exiting program... \n");
|
||||||
|
@ -159,7 +162,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
|
||||||
TGGroupFrame * groupLog = new TGGroupFrame(fMain, "Log Message", kHorizontalFrame);
|
TGGroupFrame * groupLog = new TGGroupFrame(fMain, "Log Message", kHorizontalFrame);
|
||||||
fMain->AddFrame(groupLog, new TGLayoutHints(kLHintsCenterX, 5,5,0,5) );
|
fMain->AddFrame(groupLog, new TGLayoutHints(kLHintsCenterX, 5,5,0,5) );
|
||||||
|
|
||||||
teLog = new TGTextEdit(groupLog, w, 60);
|
teLog = new TGTextEdit(groupLog, w, 100);
|
||||||
groupLog->AddFrame(teLog, new TGLayoutHints(kLHintsNormal, 0,0,10,0));
|
groupLog->AddFrame(teLog, new TGLayoutHints(kLHintsNormal, 0,0,10,0));
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,6 +180,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
|
||||||
|
|
||||||
/// setup thread
|
/// setup thread
|
||||||
thread = new TThread("hahaha", SaveData, (void *) 1);
|
thread = new TThread("hahaha", SaveData, (void *) 1);
|
||||||
|
fillHistThread = new TThread("kakaka", FillHistogram, (void *) 1);
|
||||||
|
|
||||||
settingsSummary = NULL;
|
settingsSummary = NULL;
|
||||||
moduleSetting = NULL;
|
moduleSetting = NULL;
|
||||||
|
@ -185,6 +189,8 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
|
||||||
|
|
||||||
bStopRun->SetEnabled(false);
|
bStopRun->SetEnabled(false);
|
||||||
|
|
||||||
|
LogMsg("Boot OK and ready to run.");
|
||||||
|
|
||||||
///HandleMenu(M_CH_SETTINGS_SUMMARY);
|
///HandleMenu(M_CH_SETTINGS_SUMMARY);
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,12 +256,13 @@ void MainWindow::HandleMenu(Int_t id){
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::GetADCTrace() {
|
void MainWindow::GetADCTrace() {
|
||||||
printf("--------- get ADCTrace \n");
|
|
||||||
|
|
||||||
int modID = modIDEntry->GetNumber();
|
int modID = modIDEntry->GetNumber();
|
||||||
int ch = chEntry->GetNumber();
|
int ch = chEntry->GetNumber();
|
||||||
pixie->CaptureADCTrace(modID, ch);
|
|
||||||
|
LogMsg(Form("Get ADCTrace for mod:%d, ch-%02d", modID, ch));
|
||||||
|
|
||||||
|
pixie->CaptureADCTrace(modID, ch);
|
||||||
unsigned short * haha = pixie->GetADCTrace();
|
unsigned short * haha = pixie->GetADCTrace();
|
||||||
double dt = pixie->GetChannelSetting("XDT", modID, ch);
|
double dt = pixie->GetChannelSetting("XDT", modID, ch);
|
||||||
|
|
||||||
|
@ -277,6 +284,9 @@ void MainWindow::GetBaseLine(){
|
||||||
|
|
||||||
int modID = modIDEntry->GetNumber();
|
int modID = modIDEntry->GetNumber();
|
||||||
int ch = chEntry->GetNumber();
|
int ch = chEntry->GetNumber();
|
||||||
|
|
||||||
|
LogMsg(Form("Get Baseline for mod:%d, ch-%02d", modID, ch));
|
||||||
|
|
||||||
pixie->CaptureBaseLine(modID, ch);
|
pixie->CaptureBaseLine(modID, ch);
|
||||||
|
|
||||||
double * baseline = pixie->GetBasline();
|
double * baseline = pixie->GetBasline();
|
||||||
|
@ -302,16 +312,17 @@ void MainWindow::Scope(){
|
||||||
int ch = chEntry->GetNumber();
|
int ch = chEntry->GetNumber();
|
||||||
|
|
||||||
if( pixie->GetChannelOnOff(modID, ch) == false ){
|
if( pixie->GetChannelOnOff(modID, ch) == false ){
|
||||||
LogMsg(Form("ch-%d is disabled\n", ch));
|
LogMsg(Form("mod:%d, ch-%d is disabled\n", modID, ch));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LogMsg(Form("Get trace for mod:%d, ch-%02d", modID, ch));
|
||||||
|
|
||||||
double dt = pixie->GetCh2ns(modID);
|
double dt = pixie->GetCh2ns(modID);
|
||||||
|
|
||||||
DataBlock * data = pixie->GetData();
|
DataBlock * data = pixie->GetData();
|
||||||
|
|
||||||
LogMsg("Take data for 200 msec.");
|
LogMsg("[Scope] Take data for 200 msec.");
|
||||||
pixie->StartRun(1);
|
pixie->StartRun(1);
|
||||||
|
|
||||||
usleep(200*1000);
|
usleep(200*1000);
|
||||||
|
@ -320,8 +331,8 @@ void MainWindow::Scope(){
|
||||||
|
|
||||||
TGraph * gTrace = new TGraph();
|
TGraph * gTrace = new TGraph();
|
||||||
|
|
||||||
printf(" next word : %u\n", pixie->GetNextWord());
|
///printf(" next word : %u\n", pixie->GetNextWord());
|
||||||
printf("number of word received : %u\n", pixie->GetnFIFOWords());
|
///printf("number of word received : %u\n", pixie->GetnFIFOWords());
|
||||||
|
|
||||||
//TODO add statistics, like trigger rate
|
//TODO add statistics, like trigger rate
|
||||||
|
|
||||||
|
@ -331,7 +342,7 @@ void MainWindow::Scope(){
|
||||||
if( data->slot < 2 ) break;
|
if( data->slot < 2 ) break;
|
||||||
if( data->eventID >= pixie->GetnFIFOWords() ) break;
|
if( data->eventID >= pixie->GetnFIFOWords() ) break;
|
||||||
|
|
||||||
printf("mod:%d, ch:%d, event:%llu, %u, %u\n", data->slot-2, data->ch, data->eventID, pixie->GetNextWord(), pixie->GetnFIFOWords() );
|
///printf("mod:%d, ch:%d, event:%llu, %u, %u\n", data->slot-2, data->ch, data->eventID, pixie->GetNextWord(), pixie->GetnFIFOWords() );
|
||||||
|
|
||||||
if( data->ch == ch && data->slot == modID + 2 ){
|
if( data->ch == ch && data->slot == modID + 2 ){
|
||||||
|
|
||||||
|
@ -339,7 +350,7 @@ void MainWindow::Scope(){
|
||||||
gTrace->SetPoint(i, i*dt, (data->trace)[i]);
|
gTrace->SetPoint(i, i*dt, (data->trace)[i]);
|
||||||
}
|
}
|
||||||
gTrace->GetXaxis()->SetTitle("time [us]");
|
gTrace->GetXaxis()->SetTitle("time [us]");
|
||||||
gTrace->SetTitle(Form("mod:%d, ch:%d, event:%llu\n", modID, ch, data->eventID));
|
gTrace->SetTitle(Form("mod-%d, ch-%02d\n", modID, ch));
|
||||||
gTrace->Draw("APL");
|
gTrace->Draw("APL");
|
||||||
|
|
||||||
TCanvas *fCanvas = fEcanvas->GetCanvas();
|
TCanvas *fCanvas = fEcanvas->GetCanvas();
|
||||||
|
@ -351,8 +362,7 @@ void MainWindow::Scope(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///printf("=============== finished \n");
|
||||||
printf("=============== finished \n");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +385,6 @@ void MainWindow::StartRun(){
|
||||||
LogMsg(Form("Start Run. Save data at %s.\n", tePath->GetText()));
|
LogMsg(Form("Start Run. Save data at %s.\n", tePath->GetText()));
|
||||||
|
|
||||||
pixie->StartRun(1);
|
pixie->StartRun(1);
|
||||||
|
|
||||||
if( pixie->IsRunning() ) thread->Run(); /// call SaveData()
|
if( pixie->IsRunning() ) thread->Run(); /// call SaveData()
|
||||||
|
|
||||||
bStartRun->SetEnabled(false);
|
bStartRun->SetEnabled(false);
|
||||||
|
@ -383,41 +392,22 @@ void MainWindow::StartRun(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void * MainWindow::SaveData(void* ptr){
|
|
||||||
|
|
||||||
printf("Save Data()\n");
|
|
||||||
|
|
||||||
while( pixie->IsRunning() ){
|
|
||||||
|
|
||||||
usleep(500*1000); /// 500 msec
|
|
||||||
|
|
||||||
pixie->ReadData(0);
|
|
||||||
pixie->SaveData();
|
|
||||||
|
|
||||||
//TODO Get file size, Fill HISTORGRAM;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
pixie->ReadData(0);
|
|
||||||
pixie->SaveData();
|
|
||||||
|
|
||||||
printf("finished Save Data.\n");
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::StopRun(){
|
void MainWindow::StopRun(){
|
||||||
|
|
||||||
pixie->StopRun();
|
pixie->StopRun();
|
||||||
|
pixie->ReadData(0);
|
||||||
pixie->CloseFile();
|
pixie->SaveData();
|
||||||
|
|
||||||
LogMsg("Stop Run");
|
LogMsg("Stop Run");
|
||||||
|
|
||||||
|
LogMsg(Form("File Size : %.2f MB", pixie->GetFileSize()/1024./1024.));
|
||||||
|
|
||||||
|
pixie->CloseFile();
|
||||||
|
|
||||||
pixie->PrintStatistics(0);
|
pixie->PrintStatistics(0);
|
||||||
bStartRun->SetEnabled(true);
|
bStartRun->SetEnabled(true);
|
||||||
bStopRun->SetEnabled(false);
|
bStopRun->SetEnabled(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -430,13 +420,90 @@ void MainWindow::OpenScalar(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::LogMsg(TString msg){
|
void MainWindow::LogMsg(TString msg){
|
||||||
teLog->AddLine(msg);
|
|
||||||
|
time_t now = time(0);
|
||||||
|
tm * ltm = localtime(&now);
|
||||||
|
int year = 1900 + ltm->tm_year;
|
||||||
|
int month = 1 + ltm->tm_mon;
|
||||||
|
int day = ltm->tm_mday;
|
||||||
|
int hour = ltm->tm_hour;
|
||||||
|
int minute = ltm->tm_min;
|
||||||
|
int secound = ltm->tm_sec;
|
||||||
|
|
||||||
|
teLog->AddLine(Form("[%4d-%02d-%02d %02d:%02d:%02d] ", year, month, day, hour, minute, secound) + msg);
|
||||||
teLog->LineDown();
|
teLog->LineDown();
|
||||||
teLog->End();
|
teLog->ShowBottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
//############################################ Threads
|
||||||
|
|
||||||
|
void * MainWindow::SaveData(void* ptr){
|
||||||
|
|
||||||
|
printf("Save Data()\n");
|
||||||
|
|
||||||
|
double oldFileSize = 0, newFileSize = 0;
|
||||||
|
double oldTime = 0, newTime = 0;
|
||||||
|
TBenchmark localClock;
|
||||||
|
localClock.Reset();
|
||||||
|
localClock.Start("timer");
|
||||||
|
|
||||||
|
while( pixie->IsRunning() ){
|
||||||
|
|
||||||
|
usleep(500*1000); /// 500 msec
|
||||||
|
|
||||||
|
if( !pixie->IsRunning() ) break;
|
||||||
|
|
||||||
|
pixie->ReadData(0);
|
||||||
|
pixie->SaveData();
|
||||||
|
|
||||||
|
//TODO Fill HISTORGRAM;
|
||||||
|
time_t now = time(0);
|
||||||
|
tm * ltm = localtime(&now);
|
||||||
|
int year = 1900 + ltm->tm_year;
|
||||||
|
int month = 1 + ltm->tm_mon;
|
||||||
|
int day = ltm->tm_mday;
|
||||||
|
int hour = ltm->tm_hour;
|
||||||
|
int minute = ltm->tm_min;
|
||||||
|
int secound = ltm->tm_sec;
|
||||||
|
|
||||||
|
newFileSize = pixie->GetFileSize()/1024./1024.;
|
||||||
|
|
||||||
|
localClock.Stop("timer");
|
||||||
|
newTime = localClock.GetRealTime("timer"); /// sec
|
||||||
|
localClock.Start("timer");
|
||||||
|
|
||||||
|
double rate = (newFileSize - oldFileSize)/ (newTime-oldTime);
|
||||||
|
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->LineDown();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
pixie->ReadData(0);
|
||||||
|
pixie->SaveData();
|
||||||
|
|
||||||
|
printf("finished Save Data.\n");
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void * MainWindow::FillHistogram(void *ptr){
|
||||||
|
|
||||||
|
//using evtReader or process from ExtFIFOword, but in case in complete data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//############################################
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
printf(" Welcome to pixie16 DQ \n");
|
printf(" Welcome to pixie16 DQ \n");
|
||||||
|
|
||||||
|
|
10
pixieDAQ.h
10
pixieDAQ.h
|
@ -7,6 +7,7 @@
|
||||||
#include <TGMenu.h>
|
#include <TGMenu.h>
|
||||||
#include <TGTextEdit.h>
|
#include <TGTextEdit.h>
|
||||||
#include <TThread.h>
|
#include <TThread.h>
|
||||||
|
#include <TH1F.h>
|
||||||
|
|
||||||
#include "Pixie16Class.h"
|
#include "Pixie16Class.h"
|
||||||
#include "settingsSummary.h"
|
#include "settingsSummary.h"
|
||||||
|
@ -23,14 +24,14 @@ class MainWindow{
|
||||||
RQ_OBJECT("MainWindow")
|
RQ_OBJECT("MainWindow")
|
||||||
private:
|
private:
|
||||||
TGMainFrame *fMain;
|
TGMainFrame *fMain;
|
||||||
TRootEmbeddedCanvas *fEcanvas;
|
static TRootEmbeddedCanvas *fEcanvas;
|
||||||
|
|
||||||
TGMenuBar *fMenuBar;
|
TGMenuBar *fMenuBar;
|
||||||
TGPopupMenu *fMenuFile, *fMenuSettings;
|
TGPopupMenu *fMenuFile, *fMenuSettings;
|
||||||
|
|
||||||
TGNumberEntry * modIDEntry, *chEntry;
|
TGNumberEntry * modIDEntry, *chEntry;
|
||||||
TGTextEntry * tePath;
|
TGTextEntry * tePath;
|
||||||
TGTextEdit * teLog;
|
static TGTextEdit * teLog;
|
||||||
|
|
||||||
TGTextButton *bStartRun;
|
TGTextButton *bStartRun;
|
||||||
TGTextButton *bStopRun;
|
TGTextButton *bStopRun;
|
||||||
|
@ -44,6 +45,10 @@ private:
|
||||||
|
|
||||||
TThread * thread;
|
TThread * thread;
|
||||||
|
|
||||||
|
TThread * fillHistThread;
|
||||||
|
|
||||||
|
static TH1F * h1[13][16];
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(const TGWindow *p, UInt_t w, UInt_t h);
|
MainWindow(const TGWindow *p, UInt_t w, UInt_t h);
|
||||||
|
@ -61,6 +66,7 @@ public:
|
||||||
|
|
||||||
void OpenScalar();
|
void OpenScalar();
|
||||||
|
|
||||||
|
static void * FillHistogram(void * ptr); /// thread
|
||||||
|
|
||||||
void LogMsg(TString msg);
|
void LogMsg(TString msg);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user