added EndRunScript. when change/creaet new exp, push to database if exist

This commit is contained in:
Ryan Tang 2023-03-29 15:24:53 -04:00
parent 2898e8e69a
commit 97b05d2b99
2 changed files with 29 additions and 2 deletions

View File

@ -421,7 +421,7 @@ void MainWindow::StartACQ(){
if( influx ){ if( influx ){
influx->ClearDataPointsBuffer(); influx->ClearDataPointsBuffer();
if( chkSaveRun->isChecked() ){ 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->AddDataPoint("StartStop value=1");
influx->WriteData(DatabaseName.toStdString()); influx->WriteData(DatabaseName.toStdString());
@ -516,6 +516,10 @@ void MainWindow::StopACQ(){
AppendElog(msg, chromeWindowID); AppendElog(msg, chromeWindowID);
QProcess endRunScript;
endRunScript.start("/bin/bash", QStringList() << "scripts/endRunScript.sh");
//endRunScript.waitForFinished();
}else{ }else{
LogMsg("=========================== no-Save Run stopped."); LogMsg("=========================== no-Save Run stopped.");
} }
@ -1767,6 +1771,14 @@ void MainWindow::CreateNewExperiment(const QString newExpName){
bnOpenDigitizers->setEnabled(true); bnOpenDigitizers->setEnabled(true);
bnOpenDigitizers->setStyleSheet("color:red;"); 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){ void MainWindow::ChangeExperiment(const QString newExpName){
@ -1784,6 +1796,13 @@ void MainWindow::ChangeExperiment(const QString newExpName){
CreateRawDataFolderAndLink(); CreateRawDataFolderAndLink();
LoadExpSettings(); 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(){ void MainWindow::WriteExpNameSh(){
@ -1800,7 +1819,7 @@ void MainWindow::WriteExpNameSh(){
file2.write(("rootDataPath="+ rootDataFolder + "\n").toStdString().c_str()); file2.write(("rootDataPath="+ rootDataFolder + "\n").toStdString().c_str());
file2.write(("runID="+std::to_string(runID)+"\n").c_str()); file2.write(("runID="+std::to_string(runID)+"\n").c_str());
file2.write(("elogID="+std::to_string(elogID)+"\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(); file2.close();
LogMsg("Saved expName.sh to <b>"+ analysisPath + "/working/expName.sh<b>."); LogMsg("Saved expName.sh to <b>"+ analysisPath + "/working/expName.sh<b>.");

8
scripts/endRunScript.sh Normal file
View File

@ -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"