diff --git a/.gitignore b/.gitignore
index 1f8c151..7332c9e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,5 @@ read-set
*.cxx
*.pcm
pixieDAQ
+
+data
diff --git a/Makefile b/Makefile
index 81bc0a0..105951e 100644
--- a/Makefile
+++ b/Makefile
@@ -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 moduleSetting.o channelSetting.o
+OBJS = startStopDialog.o pixieDAQ.o Pixie16Class.o settingsSummary.o scalarPanel.o moduleSetting.o channelSetting.o
all: testing/test testing/example pixieDAQ
@@ -68,6 +68,10 @@ channelSetting.o : channelSetting.cpp channelSetting.h global_macro.h
@echo "--------- creating channelSetting.o"
$(CC) $(CFLAGS) $(PIXIE_LIB_PATH) channelSetting.cpp $(ROOT_FLAG)
+startStopDialog.o : startStopDialog.cpp startStopDialog.h
+ @echo "--------- creating startStopDialog.o"
+ $(CC) $(CFLAGS) $(PIXIE_LIB_PATH) startStopDialog.cpp $(ROOT_FLAG)
+
#--------------------------
diff --git a/Pixie16Class.cpp b/Pixie16Class.cpp
index f3519f2..d6a7f4d 100644
--- a/Pixie16Class.cpp
+++ b/Pixie16Class.cpp
@@ -502,7 +502,7 @@ int Pixie16::ProcessSingleData(short ch){
if( nextWord == nFIFOWords ) {nextWord = 0; breakProcessLoopFlag = 1;}
if( nextWord > nFIFOWords ) {nextWord = nextWord - nFIFOWords; breakProcessLoopFlag = 2;}
- if( data->ch == ch ) breakProcessLoopFlag = 1;
+ if( data->ch == ch ) {nextWord = 0; breakProcessLoopFlag = 3;}
}
return breakProcessLoopFlag ;
diff --git a/elogEntry.sh b/elogEntry.sh
new file mode 100755
index 0000000..daa2063
--- /dev/null
+++ b/elogEntry.sh
@@ -0,0 +1,79 @@
+#!/bin/bash -l
+
+ExpName="testClover"
+ElogIP="elog.physics.fsu.edu"
+DataPath="/home/tandem/XIAEventBuilder/data"
+elogIDFile="/home/tandem/XIAEventBuilder/data/elogID.txt"
+
+echo "======================================= making elog Entry"
+
+elogIDFile=${DataPath}"/elogID.txt"
+if [ -f ${elogIDFile} ]; then
+ source ${elogIDFile}
+else
+ touch ${elogIDFile}
+fi
+isStart=$1
+lastRunID=$2
+Comment=$3
+elogFileName=${DataPath}"/elogText.txt"
+
+#Get file size
+RUN=${lastRunID}
+runLen=${#lastRunID}
+if [ ${runLen} -eq 1 ]; then
+ RUN="00"${RUN}
+elif [ ${runLen} -eq 2 ]; then
+ RUN="0"${RUN}
+fi;
+
+
+if [ ${isStart} == "1" ]; then
+
+ #make text file for elog text
+ echo "**************************************************************************
" > ${elogFileName}
+ echo "Run-${RUN} start at $(date)
" >> ${elogFileName}
+ echo "Start Run Comment : "${Comment}"
">> ${elogFileName}
+ echo "--------------------------------------------------------------------------
" >> ${elogFileName}
+
+ #push to elog
+ IDStr=$(elog -h ${ElogIP} -l ${ExpName} -u GeneralFox fsuphysics888 -a Author="GeneralFox" -a Category="Run" -a RunNo=${lastRunID} -a Subject="Run Log" -n 2 -m ${elogFileName})
+
+ echo ${IDStr}
+
+ IDStr=$(echo ${IDStr} | tail -1 | awk '{print $4}')
+
+ if [ ${IDStr:0:3} == "ID=" ] && [[ ${IDStr:3} =~ ${re} ]]; then
+ elogIDStr="Elog"${IDStr}
+ echo "Elog is succefully pushed at ${elogIDStr}"
+ echo ${elogIDStr} >> ${elogIDFile}
+ fi
+
+else
+
+ elogFileName2=${DataPath}"/elogText2.txt"
+
+ #download elog entry
+ echo "====== getting elog entry"
+ elog -h ${ElogIP} -l elog/${ExpName} -u GeneralFox fsuphysics888 -w ${ElogID} > ${elogFileName2}
+
+ cutLineNum=$(grep -n "==============" ${elogFileName2} | cut -d: -f1)
+ #check encoding
+ encoding=$(grep "Encoding" ${elogFileName2} | awk '{print $2}')
+ if [ $encoding = "plain" ]; then encodingID=1 ; fi
+ if [ $encoding = "HTML" ]; then encodingID=2 ; fi
+ if [ $encoding = "ELcode" ]; then encodingID=0 ; fi
+ #remove all header
+ sed -i "1,${cutLineNum}d" ${elogFileName2}
+
+ echo "Run Stop at $(date)
" >> ${elogFileName2}
+ echo "End Run Comment : "${Comment}"
" >> ${elogFileName2}
+ totalFileSize=$(du -hc ${DataPath}"/"testRun_${RUN}* | tail -1| awk {'print $1'})
+ echo "File Size : "${totalFileSize}"
">> ${elogFileName2}
+ echo "**************************************************************************
" >> ${elogFileName2}
+
+ cat ${elogFileName2}
+
+ elog -h ${ElogIP} -p 8080 -l ${ExpName} -u GeneralFox fsuphysics888 -e ${ElogID} -n ${encodingID} -m ${elogFileName2}
+
+fi
diff --git a/pixieDAQ.cpp b/pixieDAQ.cpp
index 325e082..202ea15 100644
--- a/pixieDAQ.cpp
+++ b/pixieDAQ.cpp
@@ -159,7 +159,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) {
tePath = new TGTextEntry(hframe2, new TGTextBuffer(30));
tePath->SetWidth(50);
- tePath->SetText("testRun");
+ tePath->SetText("data/testRun");
hframe2->AddFrame(tePath, uniLayoutHints);
runIDEntry = new TGNumberEntry(hframe2, 0, 0, 0, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative);
@@ -258,6 +258,7 @@ MainWindow::~MainWindow() {
delete moduleSetting;
delete channelSetting;
delete scalarPanel;
+ delete startStopDialog;
delete saveDataThread;
delete fillHistThread;
@@ -432,7 +433,7 @@ void MainWindow::Scope(){
///printf(" next word : %u\n", pixie->GetNextWord());
///printf("number of word received : %u\n", pixie->GetnFIFOWords());
- while( pixie->ProcessSingleData() < 1 ){ /// full set of dataBlack
+ while( pixie->ProcessSingleData() <= 1 ){ /// full set of dataBlack
if( pixie->GetNextWord() >= pixie->GetnFIFOWords() ) break;
if( data->slot < 2 ) break;
@@ -554,54 +555,74 @@ void MainWindow::GoodBye(){
void MainWindow::StartRun(){
- TString saveFileName = Form("%s_%03lu.evt", tePath->GetText(), runIDEntry->GetIntNumber());
+ startStopDialog = new StartStopDialog(gClient->GetRoot(), fMain, 400, 200, true);
- pixie->OpenFile(saveFileName.Data(), false);
-
- LogMsg(Form("Start Run. Save data at %s.\n", saveFileName.Data()));
-
- ///clear histogram;
- isEnergyHistFilled = false;
- for( unsigned int iMod = 0 ; iMod < pixie->GetNumModule(); iMod++){
- for( int j = 0; j < MAXCH ; j++){
- hEnergy[iMod][j]->Reset();
+ if( StartStopDialog::isOK){
+
+ TString saveFileName = Form("%s_%03lu.evt", tePath->GetText(), runIDEntry->GetIntNumber());
+
+ pixie->OpenFile(saveFileName.Data(), false);
+
+ LogMsg(Form("Start Run. Save data at %s.\n", saveFileName.Data()));
+
+ ///clear histogram;
+ isEnergyHistFilled = false;
+ for( unsigned int iMod = 0 ; iMod < pixie->GetNumModule(); iMod++){
+ for( int j = 0; j < MAXCH ; j++){
+ hEnergy[iMod][j]->Reset();
+ }
}
+
+ TString cmd = Form("/home/tandem/PixieDAQ/elogEntry.sh %d %d \"%s\"", 1, (int) runIDEntry->GetIntNumber(), StartStopDialog::Comment.Data() );
+ int temp = system(cmd.Data());
+
+ pixie->StartRun(1);
+ if( pixie->IsRunning() ) saveDataThread->Run(); /// call SaveData()
+ //if( pixie->IsRunning() ) fillHistThread->Run(); /// call SaveData()
+
+ bStartRun->SetEnabled(false);
+ bStopRun->SetEnabled(true);
+ bFitTrace->SetEnabled(false);
}
- pixie->StartRun(1);
- if( pixie->IsRunning() ) saveDataThread->Run(); /// call SaveData()
- //if( pixie->IsRunning() ) fillHistThread->Run(); /// call SaveData()
-
- bStartRun->SetEnabled(false);
- bStopRun->SetEnabled(true);
}
void MainWindow::StopRun(){
- pixie->StopRun();
- pixie->ReadData(0);
- pixie->SaveData();
+ startStopDialog = new StartStopDialog(gClient->GetRoot(), fMain, 400, 200, true);
- LogMsg("Stop Run");
- LogMsg(Form("File Size : %.2f MB", pixie->GetFileSize()/1024./1024.));
- pixie->CloseFile();
-
- pixie->PrintStatistics(0);
- bStartRun->SetEnabled(true);
- bStopRun->SetEnabled(false);
-
- runIDEntry->SetIntNumber(runIDEntry->GetIntNumber()+1);
+ if( StartStopDialog::isOK){
+
+ pixie->StopRun();
+ saveDataThread->Join();
+ usleep(200*1000);
+ pixie->ReadData(0);
+ pixie->SaveData();
+
+ LogMsg("Stop Run");
+ LogMsg(Form("File Size : %.2f MB", pixie->GetFileSize()/1024./1024.));
+ pixie->CloseFile();
+ pixie->PrintStatistics(0);
+ bStartRun->SetEnabled(true);
+ bStopRun->SetEnabled(false);
+ bFitTrace->SetEnabled(true);
+
+ TString cmd = Form("/home/tandem/PixieDAQ/elogEntry.sh %d %d \"%s\"", 0, (int)runIDEntry->GetIntNumber(), StartStopDialog::Comment.Data() );
+ int temp = system(cmd.Data());
+
+ runIDEntry->SetIntNumber(runIDEntry->GetIntNumber()+1);
+ }
}
void MainWindow::OpenScalar(){
if( scalarPanel == NULL ) {
- scalarPanel = new ScalarPanel(gClient->GetRoot(), 600, 600, pixie);
+ scalarPanel = new ScalarPanel(gClient->GetRoot(), fMain, 600, 600, pixie);
}else{
- if( !scalarPanel->isOpened ) scalarPanel = new ScalarPanel(gClient->GetRoot(), 600, 600, pixie);
+ if( !scalarPanel->isOpened ) scalarPanel = new ScalarPanel(gClient->GetRoot(), fMain, 600, 600, pixie);
}
}
@@ -666,7 +687,7 @@ void * MainWindow::SaveData(void* ptr){
if( pixie->GetnFIFOWords() > 0 ) {
pixie->SaveData();
///ScanNumDataBlockInExtFIFO() should be here after ReadData(). becasue not a whlole dataBlock is in FIFO.
- //pixie->ScanNumDataBlockInExtFIFO(); //TODO need to check the time comsumtion
+ pixie->ScanNumDataBlockInExtFIFO(); //TODO need to check the time comsumtion
pixie->SetFIFOisUsed(false);
localClock.Stop("timer");
@@ -702,7 +723,6 @@ void * MainWindow::SaveData(void* ptr){
}
}
}
-
pixie->ReadData(0);
pixie->SaveData();
diff --git a/pixieDAQ.h b/pixieDAQ.h
index c8ed858..fa166d1 100644
--- a/pixieDAQ.h
+++ b/pixieDAQ.h
@@ -18,6 +18,7 @@
#include "scalarPanel.h"
#include "moduleSetting.h"
#include "channelSetting.h"
+#include "startStopDialog.h"
class TGWindow;
class TGMainFrame;
@@ -51,6 +52,7 @@ private:
ModuleSetting * moduleSetting;
ChannelSetting * channelSetting;
ScalarPanel * scalarPanel;
+ StartStopDialog * startStopDialog;
TThread * saveDataThread;
TThread * fillHistThread;
diff --git a/scalarPanel.cpp b/scalarPanel.cpp
index b9806af..2a27814 100644
--- a/scalarPanel.cpp
+++ b/scalarPanel.cpp
@@ -20,15 +20,16 @@ TGTextEntry * ScalarPanel::teRealTime[MAXMOD] = {NULL};
int updateTime = 500; // msec
-ScalarPanel::ScalarPanel(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie){
+ScalarPanel::ScalarPanel(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, Pixie16 * pixie){
this->pixie = pixie;
nMod = pixie->GetNumModule();
- fMain = new TGMainFrame(p,w,h);
+ fMain = new TGTransientFrame(p,main,w,h);
fMain->SetWindowName("Pixie16 Scalar Panel");
fMain->Connect("CloseWindow()", "ScalarPanel", this, "CloseWindow()");
+ fMain->SetMWMHints(1,4, 0);
///Module choose
TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain, w, 50 );
@@ -120,7 +121,7 @@ void * ScalarPanel::UpdateScalar(void * ptr){
Pixie16ReadStatisticsFromModule (statistics, mod);
double realTime = Pixie16ComputeRealTime (statistics, mod);
- teRealTime[mod]->SetText(Form("%.2f", realTime));
+ teRealTime[mod]->SetText(Form("%.0f", realTime));
for( int ch = 0; ch < MAXCH ; ch ++){
@@ -128,7 +129,7 @@ void * ScalarPanel::UpdateScalar(void * ptr){
double OCR = Pixie16ComputeOutputCountRate (statistics, mod, ch);
double liveTime = Pixie16ComputeLiveTime (statistics, mod, ch);
- teRate[mod][ch]->SetText(Form("%.2f[%.2f] %.2f", ICR, OCR, liveTime));
+ teRate[mod][ch]->SetText(Form("%.2f[%.2f] %.0f", ICR, OCR, liveTime));
}
gSystem->Sleep(updateTime);
}
diff --git a/scalarPanel.h b/scalarPanel.h
index 1242b09..9cc1627 100644
--- a/scalarPanel.h
+++ b/scalarPanel.h
@@ -15,7 +15,7 @@ class TGMainFrame;
class ScalarPanel{
private:
- TGMainFrame * fMain;
+ TGTransientFrame * fMain;
static int nMod;
static Pixie16 * pixie;
@@ -28,7 +28,7 @@ private:
TThread * thread;
public:
- ScalarPanel(const TGWindow *p, UInt_t w, UInt_t h, Pixie16 * pixie);
+ ScalarPanel(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, Pixie16 * pixie);
virtual ~ScalarPanel();
static void * UpdateScalar(void * ptr);
diff --git a/settingsSummary.cpp b/settingsSummary.cpp
index b7bbac5..85a4f4f 100644
--- a/settingsSummary.cpp
+++ b/settingsSummary.cpp
@@ -20,6 +20,7 @@ SettingsSummary::SettingsSummary(const TGWindow *p, UInt_t w, UInt_t h, Pixie16
fMain = new TGMainFrame(p,w,h);
fMain->SetWindowName("Pixie16 Settings Summary");
fMain->Connect("CloseWindow()", "SettingsSummary", this, "CloseWindow()");
+ fMain->SetMWMHints(1,4, 0);
gClient->GetColorByName("red", red);
gClient->GetColorByName("black", black);
diff --git a/startStopDialog.cpp b/startStopDialog.cpp
new file mode 100644
index 0000000..3b3da40
--- /dev/null
+++ b/startStopDialog.cpp
@@ -0,0 +1,70 @@
+#include "startStopDialog.h"
+
+
+TString StartStopDialog::Comment = "";
+bool StartStopDialog::isOK = false;
+
+StartStopDialog::StartStopDialog(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, bool isStart){
+
+ this->isStart = isStart;
+ this->isOK = false;
+ Comment = "";
+
+ fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
+ fMain->DontCallClose(); /// to avoid double deletions.
+ //fMain->SetCleanup(kDeepCleanup); /// use hierarchical cleaning
+ fMain->Connect("CloseWindow()", "StartStopDialog", this, "CloseWindow()");
+
+ TGHorizontalFrame * fFrame1 = new TGHorizontalFrame(fMain); fMain->AddFrame(fFrame1, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX, 5, 5, 5, 5));
+ txtComment = new TGTextEntry(fFrame1, ""); fFrame1->AddFrame(txtComment);
+ txtComment->Resize(300, 20);
+ txtComment->Connect("ReturnPressed()", "StartStopDialog", this, "DoOK()");
+
+ TGHorizontalFrame * fFrame2 = new TGHorizontalFrame(fMain); fMain->AddFrame(fFrame2,new TGLayoutHints(kLHintsCenterX | kLHintsExpandX, 5, 5, 5, 5));
+ TGTextButton * bOK = new TGTextButton(fFrame2, "OK"); fFrame2->AddFrame(bOK, new TGLayoutHints(kLHintsCenterX));
+ bOK->Connect("Clicked()", "StartStopDialog", this, "DoOK()");
+ TGTextButton * bCancel = new TGTextButton(fFrame2, "Cancel"); fFrame2->AddFrame(bCancel, new TGLayoutHints(kLHintsCenterX));
+ bCancel->Connect("Clicked()", "StartStopDialog", this, "DoClose()");
+
+ TGHorizontalFrame * fFrame3 = new TGHorizontalFrame(fMain); fMain->AddFrame(fFrame3,new TGLayoutHints(kLHintsCenterX | kLHintsExpandX, 5, 5, 5, 5));
+
+ if( isStart ){
+ TGLabel * lbInfo = new TGLabel(fFrame3, "* Cancel or Close this dialog box will cancel START run.\n Only OK or press Enter will process."); fFrame3->AddFrame(lbInfo);
+ }else{
+ TGLabel * lbInfo = new TGLabel(fFrame3, "* Cancel or Close this dialog box will cancel STOP run.\n* Only OK or press Enter will process."); fFrame3->AddFrame(lbInfo);
+ }
+
+ fMain->MapSubwindows();
+ fMain->Resize();
+
+ fMain->CenterOnParent(); /// position relative to the parent's window
+ if( isStart) {
+ fMain->SetWindowName("Start Comment");
+ }else{
+ fMain->SetWindowName("Stop Comment");
+ }
+ fMain->MapWindow();
+
+ gClient->WaitFor(fMain); /// make everything wait for it
+
+}
+
+
+StartStopDialog::~StartStopDialog(){
+ printf("-------- %s |%s| %d\n", __func__, Comment.Data(), isOK);
+ delete txtComment;
+ fMain->DeleteWindow(); /// deletes fMain
+}
+
+void StartStopDialog::DoClose(){
+ isOK = false;
+ ///Wait for 500 msec
+ TTimer::SingleShot(500, "StartStopDialog", this, "CloseWindow()");
+}
+
+void StartStopDialog::DoOK(){
+ Comment = "";
+ Comment = txtComment->GetText();
+ isOK = true;
+ TTimer::SingleShot(500, "StartStopDialog", this, "CloseWindow()");
+}
diff --git a/startStopDialog.h b/startStopDialog.h
new file mode 100644
index 0000000..cbea170
--- /dev/null
+++ b/startStopDialog.h
@@ -0,0 +1,37 @@
+#ifndef START_STOP_DIALOG_H
+#define START_STOP_DIALOG_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+class TGWindow;
+class TGMainFrame;
+
+class StartStopDialog{
+ RQ_OBJECT("StartStopDialog")
+ private:
+
+ TGTextEntry * txtComment;
+ bool isStart;
+
+ public:
+ StartStopDialog(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, bool isStart);
+ virtual ~StartStopDialog();
+
+ TGTransientFrame * fMain;
+
+ void DoClose();
+ void DoOK();
+
+ void CloseWindow() { delete this;}
+
+ static TString Comment;
+ static bool isOK;
+
+};
+
+#endif
diff --git a/test_ryan.set b/test_ryan.set
index 76d9b58..13e7cf2 100644
--- a/test_ryan.set
+++ b/test_ryan.set
@@ -7,12 +7,12 @@
1,
1,
31,
- 5,
- 69,
+ 120,
+ 43,
8,
32,
6,
- 2,
+ 306,
0,
1,
107,
@@ -25,7 +25,7 @@
10,
2,
10,
- 10,
+ 3,
10,
10,
10,
@@ -97,12 +97,12 @@
16544,
16544,
16544,
- 16548,
- 16548,
+ 132,
+ 132,
16544,
16544,
- 16548,
- 16548,
+ 16544,
+ 132,
16544,
16544,
16544,
@@ -259,12 +259,12 @@
65535,
65535,
65535,
- 4000,
- 4000,
+ 40000,
+ 40000,
4000,
65535,
4000,
- 4000,
+ 40000,
65535,
65535,
4000,
@@ -421,12 +421,12 @@
32768,
32768,
32768,
- 21845,
- 21845,
+ 48059,
+ 48059,
21845,
32768,
21845,
- 21845,
+ 50244,
32768,
32768,
21845,
@@ -529,8 +529,8 @@
1100456650,
1100456650,
1100456650,
- 1112014848,
- 1112014848,
+ 1095552204,
+ 1095552204,
1112012226,
1100456650,
1112014848,