diff --git a/.gitignore b/.gitignore index 2efa6ac..a200af8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ test FSUDAQ +FSUDAQ.sh test_indep EventBuilder diff --git a/DAQ/ClassData.h b/DAQ/ClassData.h index 05e356d..57bf037 100644 --- a/DAQ/ClassData.h +++ b/DAQ/ClassData.h @@ -94,7 +94,6 @@ class Data{ //========================================== inline Data::Data(){ - printf("----- %s \n", __func__); ch2ns = 2.0; boardSN = 0; DPPType = V1730_DPP_PHA_CODE; @@ -109,7 +108,6 @@ inline Data::Data(){ } inline Data::~Data(){ - printf("----- %s \n", __func__); if( buffer != NULL ) delete buffer; } diff --git a/DAQ/ClassDigitizer.cpp b/DAQ/ClassDigitizer.cpp index 3789e17..22b5020 100644 --- a/DAQ/ClassDigitizer.cpp +++ b/DAQ/ClassDigitizer.cpp @@ -343,6 +343,7 @@ void Digitizer::StartACQ(){ printf("\e[1m\e[33m======= Acquisition Started for Board %d\e[0m\n", boardID); AcqRun = true; + data->ClearTriggerRate(); } void Digitizer::StopACQ(){ @@ -352,6 +353,7 @@ void Digitizer::StopACQ(){ if( ret != 0 ) ErrorMsg("something wrong when try to stop ACQ and clear buffer"); printf("\n\e[1m\e[33m====== Acquisition STOPPED for Board %d\e[0m\n", boardID); AcqRun = false; + data->ClearTriggerRate(); } unsigned int Digitizer::CalByteForBuffer(){ @@ -533,6 +535,7 @@ Reg Digitizer::FindRegister(uint32_t address){ void Digitizer::ReadAllSettingsFromBoard(bool force){ if( !isConnected ) return; + if( AcqRun ) return; if( isSettingFilledinMemeory && !force) return; printf("===== %s \n", __func__); diff --git a/DAQ/FSUDAQ.cpp b/DAQ/FSUDAQ.cpp index 66a3ac7..1da888c 100644 --- a/DAQ/FSUDAQ.cpp +++ b/DAQ/FSUDAQ.cpp @@ -69,7 +69,6 @@ enum MenuIdentifiers{ M_FILE_OPEN, M_EXIT, M_LOAD_SETTINGS, - M_TRIGGER_SUMMARY, M_CH_SETTING_PHA, M_CH_SETTING_PSD, M_REGISTER_SETTING, @@ -110,7 +109,6 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { fMenuDigitizers = new TGPopupMenu(gClient->GetRoot()); fMenuDigitizers->AddEntry("&Open Digitizers", M_DIGITIZER_OPEN); fMenuDigitizers->AddEntry("&Load Setting (Offline)", M_LOAD_SETTINGS); - fMenuDigitizers->AddEntry("&Trigger Summary", M_TRIGGER_SUMMARY); fMenuDigitizers->AddSeparator(); fMenuDigitizers->AddEntry("Digitizer &Settings", M_BOARD_SETTINGS); fMenuDigitizers->AddEntry("&Channel Settings (PHA)", M_CH_SETTING_PHA); @@ -121,7 +119,6 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { fMenuDigitizers->Connect("Activated(Int_t)", "MainWindow", this, "HandleMenu(Int_t)"); fMenuBar->AddPopup("&Digitizers", fMenuDigitizers, new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)); - fMenuDigitizers->DisableEntry( M_TRIGGER_SUMMARY); fMenuDigitizers->DisableEntry( M_BOARD_SETTINGS); fMenuDigitizers->DisableEntry( M_CH_SETTING_PHA); fMenuDigitizers->DisableEntry( M_CH_SETTING_PSD); @@ -140,10 +137,10 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { 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)); + TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain); fMain->AddFrame(hframe, new TGLayoutHints(kLHintsCenterX,0,0,0,0)); {///================= Create a horizontal frame widget with buttons - TGGroupFrame * group0 = new TGGroupFrame(hframe, "Run Control", kVerticalFrame); hframe->AddFrame(group0); + TGGroupFrame * group0 = new TGGroupFrame(hframe, "Run Control", kVerticalFrame); hframe->AddFrame(group0, new TGLayoutHints(kLHintsExpandY)); TGVerticalFrame * vframe = new TGVerticalFrame(group0); group0->AddFrame(vframe); TGHorizontalFrame *hfg0 = new TGHorizontalFrame(vframe); vframe->AddFrame(hfg0 ,new TGLayoutHints(kLHintsLeft, 0, 0, 0, 0)); @@ -177,7 +174,7 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { 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->SetNumber(lastRunID + 1, false); runIDEntry->SetWidth(50); cbDataRun = new TGCheckButton(hfg1, "Data Run", 1); hfg1->AddFrame(cbDataRun, hahaLayoutHints); @@ -257,7 +254,6 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { //HandleMenu(M_CH_SETTING_PHA); //HandleMenu(M_CH_SETTING_PSD); //HandleMenu(M_REGISTER_SETTING); - //HandleMenu(M_TRIGGER_SUMMARY); //HandleMenu(M_PROGRAM_SETTINGS); gDummy = new TGraph(); @@ -279,9 +275,10 @@ MainWindow::MainWindow(const TGWindow *p,UInt_t w,UInt_t h) { gStyle->SetOptStat("neiou"); - DrawDummyGraph(); + fMain->Move(300, 200); + } void MainWindow::GoodBye(){ @@ -289,7 +286,6 @@ void MainWindow::GoodBye(){ printf("/// Closing Digitizer and Releasing digitizer memory\n"); for( int i = 0; i < nDigi; i++) delete digi[i]; - printf("/// Releasing histograms memory\n"); for( int i = 0; i < MaxNBoards; i++){ if( hChannel[i] != NULL ) delete hChannel[i]; for( int j = 0; j < MaxNChannels; j++){ @@ -297,7 +293,6 @@ void MainWindow::GoodBye(){ } } - printf("/// Releasing graphs memory\n"); delete gDummy; delete gAnaTrace1 ; delete gAnaTrace2 ; @@ -365,12 +360,6 @@ void MainWindow::HandleMenu(Int_t id){ ///========================= Exit case M_EXIT: GoodBye(); break; - - ///========================= Trigger summary - case M_TRIGGER_SUMMARY: { - triggerSummary = new TriggerSummary(gClient->GetRoot(), 600, 600); - TriggerSummary::isManualOpened = true; - }break; ///========================= Load setting file offline case M_LOAD_SETTINGS:{ @@ -460,7 +449,6 @@ void MainWindow::OpenDigitizers(){ digi = new Digitizer * [nDigi]; for( int i = 0; i < nDigi; i++){ - printf("------------ %d \n", i); digi[i] = new Digitizer(boardID[i], portID[i], false, false); LogMsg(Form("%2d, Serial number : %3d opened (%s, %s)", i, digi[i]->GetSerialNumber(), digi[i]->GetDPPString().c_str(), @@ -479,10 +467,11 @@ void MainWindow::OpenDigitizers(){ fMenuDigitizers->EnableEntry( M_BOARD_SETTINGS); fMenuDigitizers->EnableEntry( M_CH_SETTING_PHA); fMenuDigitizers->EnableEntry( M_CH_SETTING_PSD); - fMenuDigitizers->EnableEntry( M_TRIGGER_SUMMARY); fMenuDigitizers->EnableEntry( M_REGISTER_SETTING); bOpenDigitizers->SetEnabled(false); + triggerSummary = new TriggerSummary(gClient->GetRoot(), fMain ); + bStartRun->SetEnabled(true); if( nDigi > 1) boardIDEntry->SetState(true); @@ -548,7 +537,7 @@ void MainWindow::ChangeBoard(){ void MainWindow::UpdateExpName(){ dataPrefix->SetText(ProgramSetting::ExpName.c_str()); - runIDEntry->SetNumber(lastRunID); + runIDEntry->SetNumber(lastRunID + 1); } void MainWindow::MakeElogEntry(bool start){ @@ -592,7 +581,8 @@ void MainWindow::StartRun(){ if( StartStopDialog::isOK){ LogMsg(Form("Start Data Run")); - + lastRunID ++; + ProgramSetting::SaveProgramSetting(); cbMode->SetEnabled(false); MakeElogEntry(true); @@ -615,11 +605,6 @@ void MainWindow::StartRun(){ cbMode->SetEnabled(true); } } - - if( !TriggerSummary::isOpened ) { - triggerSummary = new TriggerSummary(gClient->GetRoot(), 600, 600); - TriggerSummary::isManualOpened = false; - } } void MainWindow::StopRun(){ @@ -640,8 +625,6 @@ void MainWindow::StopRun(){ bPlotSingleTrace->SetEnabled(true); bFitTrace->SetEnabled(true); cbMode->SetEnabled(true); - - if( !TriggerSummary::isManualOpened ) triggerSummary->CloseWindow(); ///if( cbMode->GetSelected() == Mode_DataRun ){ if( cbDataRun->GetState() == kButtonDown ) { @@ -652,10 +635,9 @@ void MainWindow::StopRun(){ LogMsg(Form("Stop Data Run")); int runID = runIDEntry->GetNumber(); - lastRunID = runID + 1; runIDEntry->SetNumber(runID +1); - MakeElogEntry(false); - ProgramSetting::SaveProgramSetting(); + MakeElogEntry(false); + }else{ bStartRun->SetEnabled(false); bStopRun->SetEnabled(true); @@ -1004,7 +986,16 @@ void * MainWindow::Run(void * ptr){ //############################################ int main(int argc, char **argv) { - printf(" Welcome to FSU DQ \n"); + printf("########################################################################################\n"); + printf(" oooooooooooo .oooooo..o ooooo ooo oooooooooo. .o. .oooooo. \n"); + printf(" `888\' `8 d8P' `Y8 `888' `8' `888' `Y8b .888. d8P' `Y8b \n"); + printf(" 888 Y88bo. 888 8 888 888 .8`888. 888 888 \n"); + printf(" 888oooo8 ``Y8888o. 888 8 888 888 .8' `888. 888 888 \n"); + printf(" 888 \" ``Y88b 888 8 888 888 .88ooo8888. 888 888 \n"); + printf(" 888 oo .d8P `88. .8' 888 d88' .8' `888. `88b d88b \n"); + printf(" o888o 8\"\"88888P' `YbodP' o888bood8P' o88o o8888o `Y8bood8P'Ybd' \n"); + printf("########################################################################################\n"); + printf(" Welcome to FSU DAQ \n"); ProgramSetting::LoadProgramSetting(); diff --git a/DAQ/elogEntry.sh b/DAQ/elogEntry.sh index 03cc420..dfedcb8 100755 --- a/DAQ/elogEntry.sh +++ b/DAQ/elogEntry.sh @@ -20,19 +20,33 @@ elogFileName=${DataPath}"/elogText.txt" echo ${isStart} echo ${Comment} +#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-${lastRunID} start at $(date)" >> ${elogFileName} - echo ${Comment} >> ${elogFileName} + 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 elogText.txt) + 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}') - echo ${IDStr} + echo ".............."${IDStr} if [ ${IDStr:0:3} == "ID=" ] && [[ ${IDStr:3} =~ ${re} ]]; then elogIDStr="Elog"${IDStr} @@ -42,23 +56,36 @@ if [ ${isStart} == "1" ]; then else - elogFileName2=elogText2.txt + elogFileName2=${DataPath}"/elogText2.txt" #download elog entry echo "====== getting elog entry" elog -h ${ElogIP} -l elog/${ExpName} -u GeneralFox fsuphysics888 -w ${ElogID} > ${elogFileName2} echo "=======================" - cat ${elogFileName2} + #cat ${elogFileName2} -# echo "remove header" -# 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 "remove header" + 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} + + #Comment + echo "End Run Comment : "${Comment}"
" >> ${elogFileName2} + + totalFileSize=$(du -hc ${DataPath}"/data/"${ExpName}_run${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/DAQ/triggerSummary.cpp b/DAQ/triggerSummary.cpp index 0653c1e..e8d0324 100644 --- a/DAQ/triggerSummary.cpp +++ b/DAQ/triggerSummary.cpp @@ -18,8 +18,6 @@ extern Digitizer ** digi; //extern bool ProgramSetting::EnableDatabase; -bool TriggerSummary::isOpened = false; -bool TriggerSummary::isManualOpened = false; bool TriggerSummary::updateFlag = true; TGTextEntry * TriggerSummary::txtTrigger[MaxNBoards][MaxNChannels] = {NULL}; TGTextEntry * TriggerSummary::txtThresholdValue[MaxNBoards][MaxNChannels] = {NULL}; @@ -29,12 +27,13 @@ TGNumberEntry * TriggerSummary::numUpdateTime = NULL; unsigned short TriggerSummary::value[MaxNBoards][MaxNChannels] = {0}; bool TriggerSummary::onOff[MaxNBoards][MaxNChannels] = {true}; -TriggerSummary::TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h){ +TriggerSummary::TriggerSummary(const TGWindow *p, const TGWindow *main){ - fMain = new TGMainFrame(p,w,h); + fMain = new TGTransientFrame(p,main); fMain->SetWindowName("Scalar Panel"); fMain->Connect("CloseWindow()", "TriggerSummary", this, "CloseWindow()"); - //fMain->SetMWMHints(0,0, 0); + fMain->CenterOnParent(true, TGTransientFrame::EPlacement::kTopRight); + fMain->SetMWMHints(1,4, 0); //tested many time to have no close button. TGHorizontalFrame *hframe = new TGHorizontalFrame(fMain); fMain->AddFrame(hframe); @@ -118,7 +117,6 @@ TriggerSummary::TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h){ fMain->MapWindow(); updateFlag = true; - isOpened = true; if( digi != NULL ){ printf("-------- %s thread\n", __func__); @@ -141,14 +139,14 @@ TriggerSummary::~TriggerSummary(){ } delete numUpdateTime; - isOpened = false; - isManualOpened = false; updateFlag = false; thread->Join(); ///delete thread; /// Don;t delete the thread, otherwise, thread will not run after close and reopen. + printf("%s ========== finial clena up\n", __func__); + fMain->Cleanup(); delete fMain; } @@ -208,7 +206,7 @@ void TriggerSummary::SetThreshold(){ if( isACQRunning ) { digi[bd]->StopACQ(); - usleep(100*1000); + usleep(500*1000); } if( digi[bd]->GetDPPType() == V1730_DPP_PSD_CODE ) { @@ -222,7 +220,7 @@ void TriggerSummary::SetThreshold(){ txtThresholdValue[bd][ch]->SetText(Form("%d", value[bd][ch]), false); if( isACQRunning ) { - usleep(100*1000); + usleep(500*1000); digi[bd]->StartACQ(); } } @@ -245,7 +243,7 @@ void TriggerSummary::SetChannelEnable(){ if( isACQRunning ) { digi[bd]->StopACQ(); - usleep(100*1000); + usleep(500*1000); } digi[bd]->SetChannelOnOff(ch, state); @@ -253,7 +251,7 @@ void TriggerSummary::SetChannelEnable(){ txtThreshold[bd][ch]->SetEnabled(state); if( isACQRunning ) { - usleep(100*1000); + usleep(500*1000); digi[bd]->StartACQ(); } } diff --git a/DAQ/triggerSummary.h b/DAQ/triggerSummary.h index ec21d9f..8b233f1 100644 --- a/DAQ/triggerSummary.h +++ b/DAQ/triggerSummary.h @@ -17,7 +17,7 @@ class TGMainFrame; class TriggerSummary{ RQ_OBJECT("TriggerSummary") private: - TGMainFrame * fMain; + TGTransientFrame * fMain; static TGTextEntry * txtTrigger[MaxNBoards][MaxNChannels]; static TGTextEntry * txtThresholdValue[MaxNBoards][MaxNChannels]; @@ -32,12 +32,9 @@ class TriggerSummary{ static bool onOff[MaxNBoards][MaxNChannels]; public: - TriggerSummary(const TGWindow *p, UInt_t w, UInt_t h); + TriggerSummary(const TGWindow *p, const TGWindow *main); virtual ~TriggerSummary(); - - static bool isOpened; - static bool isManualOpened; - + void CloseWindow() { delete this;} static void * UpdateTriggerRate(void *ptr); diff --git a/FSUDAQ.sh b/FSUDAQ.sh deleted file mode 100644 index 2a1e7f7..0000000 --- a/FSUDAQ.sh +++ /dev/null @@ -1,10 +0,0 @@ -ExpName=ZZZZZ -DataPath=/home/catrina/FSUDAQ/expDir -EnableDatabase=1 -DatabaseIP=https://fsunuc.physics.fsu.edu/influx/ -DatabaseName=testing -EnableElog=1 -ElogIP=elog.physics.fsu.edu -MaxPort=2 -MaxBoardPrePort=2 -lastRunID=1