tested endRunScript, fixed autoRun

This commit is contained in:
Ryan Tang 2023-03-30 13:09:11 -04:00
parent 97b05d2b99
commit aacac712ca
5 changed files with 38 additions and 29 deletions

View File

@ -308,7 +308,7 @@ void Digitizer2Gen::SetPHADataFormat(unsigned short dataFormat){
if( evt ) delete evt; if( evt ) delete evt;
evt = new Event(); evt = new Event();
evt->SetDataType(dataFormat); evt->SetDataType(dataFormat);
dataStartIndetifier += dataFormat; dataStartIndetifier = 0xAAA0 + dataFormat;
if( dataFormat == 0 ){ if( dataFormat == 0 ){
ret = CAEN_FELib_SetReadDataFormat(ep_handle, ret = CAEN_FELib_SetReadDataFormat(ep_handle,

View File

@ -42,7 +42,7 @@ SOLARISpanel::SOLARISpanel(Digitizer2Gen **digi, unsigned short nDigi,
printf("################################# \n"); printf("################################# \n");
for( int i = 0; i < (int) mapping.size() ; i++){ for( int i = 0; i < (int) mapping.size() ; i++){
for( int j = 0; j < (int) mapping[i].size(); j++ ){ for( int j = 0; j < (int) mapping[i].size(); j++ ){
printf("%3d,", mapping[i][j]); printf("%4d,", mapping[i][j]);
QList<int> haha ; QList<int> haha ;
haha << mapping[i][j] << ((i << 8 ) + j); haha << mapping[i][j] << ((i << 8 ) + j);
if( mapping[i][j] >= 0 ) detIDListTemp << haha; if( mapping[i][j] >= 0 ) detIDListTemp << haha;

View File

@ -362,12 +362,19 @@ void MainWindow::StartACQ(){
if(result == QDialog::Accepted ){ if(result == QDialog::Accepted ){
startComment = lineEdit->text(); startComment = lineEdit->text();
if( startComment == "") startComment = "Start Comment: No commet was typed."; if( startComment == "") startComment = "No commet was typed.";
leRunComment->setText("Start Comment: " + startComment); startComment = "Start Comment: " + startComment;
}else{ }else{
LogMsg("Start Run aborted. "); LogMsg("Start Run aborted. ");
return; return;
} }
if( cbAutoRun -> currentData().toInt() != 0 ){
startComment = startComment + ". AutoRun for " + cbAutoRun->currentText();
}
leRunComment->setText(startComment);
}else{ }else{
//==========TODO auto run comment //==========TODO auto run comment
startComment = "AutoRun for " + cbAutoRun->currentText(); startComment = "AutoRun for " + cbAutoRun->currentText();
@ -461,14 +468,14 @@ void MainWindow::StopACQ(){
if(result == QDialog::Accepted ){ if(result == QDialog::Accepted ){
stopComment = lineEdit->text(); stopComment = lineEdit->text();
if( stopComment == "") stopComment = "Stop Comment: No commet was typed."; if( stopComment == "") stopComment = "No commet was typed.";
leRunComment->setText("Stop Comment: " + stopComment); stopComment = "Stop Comment: " + stopComment;
leRunComment->setText(stopComment);
}else{ }else{
LogMsg("Cancel Run aborted. "); LogMsg("Cancel Run aborted. ");
return; return;
} }
}else{ }else{
//TODO =============
stopComment = "End of AutoRun for " + cbAutoRun->currentText(); stopComment = "End of AutoRun for " + cbAutoRun->currentText();
leRunComment->setText(stopComment); leRunComment->setText(stopComment);
} }
@ -515,10 +522,7 @@ void MainWindow::StopACQ(){
+ "======================"; + "======================";
AppendElog(msg, chromeWindowID); AppendElog(msg, chromeWindowID);
QProcess::startDetached(settingFilePath + "/scripts/endRunScript.sh");
QProcess endRunScript;
endRunScript.start("/bin/bash", QStringList() << "scripts/endRunScript.sh");
//endRunScript.waitForFinished();
}else{ }else{
LogMsg("=========================== no-Save Run stopped."); LogMsg("=========================== no-Save Run stopped.");
@ -543,24 +547,26 @@ void MainWindow::AutoRun(){
} }
needManualComment = true; needManualComment = true;
isRunning = true;
///=========== infinite single run ///=========== infinite single run
if( cbAutoRun->currentData().toInt() == 0 ){ if( cbAutoRun->currentData().toInt() == 0 ){
StartACQ(); StartACQ();
disconnect(runTimer, &QTimer::timeout, nullptr, nullptr);
}else{ }else{
StartACQ(); StartACQ();
connect(runTimer, &QTimer::timeout, this, [=](){ connect(runTimer, &QTimer::timeout, this, [=](){
if( isRunning ){
StopACQ(); StopACQ();
isRunning = false;
if( cbAutoRun->currentData().toInt() > 0 ) { if( cbAutoRun->currentData().toInt() > 0 ) {
bnStartACQ->setEnabled(true); bnStartACQ->setEnabled(true);
bnStopACQ->setEnabled(false); bnStopACQ->setEnabled(false);
bnComment->setEnabled(false); bnComment->setEnabled(false);
}
}else{ }else{
LogMsg("Wait for 10 sec for next Run....");
elapsedTimer.invalidate();
elapsedTimer.start();
while(elapsedTimer.elapsed() < 10000) QCoreApplication::processEvents();
StartACQ(); StartACQ();
isRunning = true;
} }
}); });
} }
@ -818,7 +824,7 @@ bool MainWindow::CheckSOLARISpanelOK(){
while (!in.atEnd()) { while (!in.atEnd()) {
QString line = in.readLine(); QString line = in.readLine();
if( line.contains("//^")) continue; if( line.contains("//^")) continue;
if( line.contains("//*=")){ if( line.contains("//C=")){
int in1 = line.indexOf("{"); int in1 = line.indexOf("{");
int in2 = line.lastIndexOf("}"); int in2 = line.lastIndexOf("}");
if( in2 > in1){ if( in2 > in1){
@ -829,7 +835,7 @@ bool MainWindow::CheckSOLARISpanelOK(){
return false; return false;
} }
} }
if( line.contains("//*#")){ if( line.contains("//C#")){
int in1 = line.indexOf("{"); int in1 = line.indexOf("{");
int in2 = line.lastIndexOf("}"); int in2 = line.lastIndexOf("}");
if( in2 > in1){ if( in2 > in1){
@ -841,12 +847,12 @@ bool MainWindow::CheckSOLARISpanelOK(){
return false; return false;
} }
} }
if( line.contains("//* ") ) { if( line.contains("//C ") ) {
startRecord = true; startRecord = true;
singleDigiMap.clear(); singleDigiMap.clear();
continue; continue;
} }
if( startRecord && line.contains("//*----")){ if( startRecord && line.contains("//C----")){
startRecord = false; startRecord = false;
mapping.push_back(singleDigiMap); mapping.push_back(singleDigiMap);
continue; continue;
@ -1918,7 +1924,7 @@ void MainWindow::WriteElog(QString htmlText, QString subject, QString category,
QStringList arg; QStringList arg;
arg << "-h" << ElogIP << "-p" << "8080" << "-l" << expName << "-u" << "GeneralSOLARIS" << "solaris" arg << "-h" << ElogIP << "-p" << "8080" << "-l" << expName << "-u" << "GeneralSOLARIS" << "solaris"
<< "-a" << "Author=\'General SOLARIS\'" ; << "-a" << "Author=\'General SOLARIS\'" ;
if( runNumber > 0 ) arg << "-a" << "Run=" + QString::number(runNumber); if( runNumber > 0 ) arg << "-a" << "RunNo=" + QString::number(runNumber);
if( category != "" ) arg << "-a" << "Category=" + category; if( category != "" ) arg << "-a" << "Category=" + category;
arg << "-a" << "Subject=" + subject arg << "-a" << "Subject=" + subject

View File

@ -12,6 +12,7 @@
#include <QComboBox> #include <QComboBox>
#include <QLabel> #include <QLabel>
#include <QTimer> #include <QTimer>
#include <QThread>
#include <QChart> #include <QChart>
#include <QLineSeries> #include <QLineSeries>
@ -140,6 +141,7 @@ private:
bool needManualComment; bool needManualComment;
bool isRunning; bool isRunning;
QTimer * runTimer; QTimer * runTimer;
QElapsedTimer elapsedTimer;
unsigned int autoRunStartRunID; unsigned int autoRunStartRunID;
//@----- digi Setting panel //@----- digi Setting panel
@ -192,6 +194,7 @@ private:
//@------ custom comment; //@------ custom comment;
QPushButton * bnComment; QPushButton * bnComment;
void AppendComment(); void AppendComment();
}; };

2
scripts/endRunScript.sh Normal file → Executable file
View File

@ -3,6 +3,6 @@
echo "################# end Run Script" echo "################# end Run Script"
#xterm -T endRunScript -hold -geometry 100x20+0+0 -sb -sl 1000 -e "Process_Run" "lastRun" #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" xterm -T endRunScript -geometry 100x20+0+0 -sb -sl 1000 -e "source ~/Analysis/SOLARIS.sh; Process_Run lastRun 2 0"
echo "################# done" echo "################# done"