From 97b05d2b99be91ca8d18406254950f999dfca99b Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS-DAQ" Date: Wed, 29 Mar 2023 15:24:53 -0400 Subject: [PATCH] added EndRunScript. when change/creaet new exp, push to database if exist --- mainwindow.cpp | 23 +++++++++++++++++++++-- scripts/endRunScript.sh | 8 ++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 scripts/endRunScript.sh diff --git a/mainwindow.cpp b/mainwindow.cpp index 9b996cd..d9c15da 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -421,7 +421,7 @@ void MainWindow::StartACQ(){ if( influx ){ influx->ClearDataPointsBuffer(); if( chkSaveRun->isChecked() ){ - influx->AddDataPoint("RunID,start=1 value=" + std::to_string(runID) + ",expName=\"" + expName.toStdString()+ + "\",comment=\"" + startComment.replace(' ', '_').toStdString() + "\""); + influx->AddDataPoint("RunID,start=1 value=" + std::to_string(runID) + ",expName=\"" + expName.toStdString() + "\",comment=\"" + startComment.replace(' ', '_').toStdString() + "\""); } influx->AddDataPoint("StartStop value=1"); influx->WriteData(DatabaseName.toStdString()); @@ -516,6 +516,10 @@ void MainWindow::StopACQ(){ AppendElog(msg, chromeWindowID); + QProcess endRunScript; + endRunScript.start("/bin/bash", QStringList() << "scripts/endRunScript.sh"); + //endRunScript.waitForFinished(); + }else{ LogMsg("=========================== no-Save Run stopped."); } @@ -1767,6 +1771,14 @@ void MainWindow::CreateNewExperiment(const QString newExpName){ bnOpenDigitizers->setEnabled(true); bnOpenDigitizers->setStyleSheet("color:red;"); + if( influx ){ + influx->ClearDataPointsBuffer(); + startComment = "New experiment [" + expName + "] was created."; + influx->AddDataPoint("RunID,start=0 value=" + std::to_string(runID) + ",expName=\"" + expName.toStdString() + "\",comment=\"" + startComment.replace(' ', '_').toStdString() + "\""); + influx->WriteData(DatabaseName.toStdString()); + } + + } void MainWindow::ChangeExperiment(const QString newExpName){ @@ -1784,6 +1796,13 @@ void MainWindow::ChangeExperiment(const QString newExpName){ CreateRawDataFolderAndLink(); LoadExpSettings(); + if( influx ){ + influx->ClearDataPointsBuffer(); + startComment = "Switched to experiment [" + expName + "]."; + influx->AddDataPoint("RunID,start=0 value=" + std::to_string(runID) + ",expName=\"" + expName.toStdString() + "\",comment=\"" + startComment.replace(' ', '_').toStdString() + "\""); + influx->WriteData(DatabaseName.toStdString()); + } + } void MainWindow::WriteExpNameSh(){ @@ -1800,7 +1819,7 @@ void MainWindow::WriteExpNameSh(){ file2.write(("rootDataPath="+ rootDataFolder + "\n").toStdString().c_str()); file2.write(("runID="+std::to_string(runID)+"\n").c_str()); file2.write(("elogID="+std::to_string(elogID)+"\n").c_str()); - file2.write("//------------end of file."); + file2.write("#------------end of file."); file2.close(); LogMsg("Saved expName.sh to "+ analysisPath + "/working/expName.sh."); diff --git a/scripts/endRunScript.sh b/scripts/endRunScript.sh new file mode 100644 index 0000000..ffb8d7c --- /dev/null +++ b/scripts/endRunScript.sh @@ -0,0 +1,8 @@ +#!/bin/bash -l + +echo "################# end Run Script" + +#xterm -T endRunScript -hold -geometry 100x20+0+0 -sb -sl 1000 -e "Process_Run" "lastRun" +xterm -T endRunScript -geometry 100x20+0+0 -sb -sl 1000 -e "Process_Run" "lastRun" "2" + +echo "################# done" \ No newline at end of file