added start top run comment

This commit is contained in:
Ryan Tang 2023-02-14 18:44:10 -05:00
parent 68e86fa379
commit 78330049ed
4 changed files with 77 additions and 15 deletions

View File

@ -170,7 +170,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
QLabel * lbRunComment = new QLabel("Run Comment : ", this); QLabel * lbRunComment = new QLabel("Run Comment : ", this);
lbRunComment->setAlignment(Qt::AlignRight | Qt::AlignCenter); lbRunComment->setAlignment(Qt::AlignRight | Qt::AlignCenter);
QLineEdit * leRunComment = new QLineEdit(this); leRunComment = new QLineEdit(this);
leRunComment->setReadOnly(true); leRunComment->setReadOnly(true);
leRunComment->setStyleSheet("background-color: #F3F3F3;"); leRunComment->setStyleSheet("background-color: #F3F3F3;");
@ -255,8 +255,37 @@ void MainWindow::StartACQ(){
if( chkSaveRun->isChecked() ){ if( chkSaveRun->isChecked() ){
runIDStr = QString::number(runID).rightJustified(3, '0'); runIDStr = QString::number(runID).rightJustified(3, '0');
LogMsg("=========================== Start <b><font style=\"color : red;\">Run-" + runIDStr + "</font></b>"); LogMsg("=========================== Start <b><font style=\"color : red;\">Run-" + runIDStr + "</font></b>");
//TODO ============ start comment
//============ start comment
QDialog * dOpen = new QDialog(this);
dOpen->setWindowTitle("Start Run Comment");
dOpen->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
dOpen->setMinimumWidth(600);
connect(dOpen, &QDialog::finished, dOpen, &QDialog::deleteLater);
QGridLayout * vlayout = new QGridLayout(dOpen);
QLabel *label = new QLabel("Enter Run comment for <font style=\"color : red;\">Run-" + runIDStr + "</font> : ", dOpen);
QLineEdit *lineEdit = new QLineEdit(dOpen);
QPushButton *button1 = new QPushButton("OK", dOpen);
QPushButton *button2 = new QPushButton("Cancel", dOpen);
vlayout->addWidget(label, 0, 0, 1, 2);
vlayout->addWidget(lineEdit, 1, 0, 1, 2);
vlayout->addWidget(button1, 2, 0);
vlayout->addWidget(button2, 2, 1);
connect(button1, &QPushButton::clicked, dOpen, &QDialog::accept);
connect(button2, &QPushButton::clicked, dOpen, &QDialog::reject);
int result = dOpen->exec();
if(result == QDialog::Accepted ){
startComment = lineEdit->text();
if( startComment == "") startComment = "No commet was typed.";
leRunComment->setText(startComment);
}else{
LogMsg("Start Run aborted. ");
return;
}
//TODO ============ elog //TODO ============ elog
//TODO ============ update expName.sh //TODO ============ update expName.sh
@ -296,6 +325,39 @@ void MainWindow::StartACQ(){
void MainWindow::StopACQ(){ void MainWindow::StopACQ(){
if( chkSaveRun->isChecked() ){
//============ stop comment
QDialog * dOpen = new QDialog(this);
dOpen->setWindowTitle("Stop Run Comment");
dOpen->setWindowFlags(Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
dOpen->setMinimumWidth(600);
connect(dOpen, &QDialog::finished, dOpen, &QDialog::deleteLater);
QGridLayout * vlayout = new QGridLayout(dOpen);
QLabel *label = new QLabel("Enter Run comment for ending <font style=\"color : red;\">Run-" + runIDStr + "</font> : ", dOpen);
QLineEdit *lineEdit = new QLineEdit(dOpen);
QPushButton *button1 = new QPushButton("OK", dOpen);
QPushButton *button2 = new QPushButton("Cancel", dOpen);
vlayout->addWidget(label, 0, 0, 1, 2);
vlayout->addWidget(lineEdit, 1, 0, 1, 2);
vlayout->addWidget(button1, 2, 0);
vlayout->addWidget(button2, 2, 1);
connect(button1, &QPushButton::clicked, dOpen, &QDialog::accept);
connect(button2, &QPushButton::clicked, dOpen, &QDialog::reject);
int result = dOpen->exec();
if(result == QDialog::Accepted ){
stopComment = lineEdit->text();
if( stopComment == "") stopComment = "No commet was typed.";
leRunComment->setText(stopComment);
}else{
LogMsg("Cancel Run aborted. ");
return;
}
}
for( int i = 0; i < nDigi; i++){ for( int i = 0; i < nDigi; i++){
if( digi[i]->IsDummy () ) continue; if( digi[i]->IsDummy () ) continue;
digi[i]->StopACQ(); digi[i]->StopACQ();
@ -323,12 +385,7 @@ void MainWindow::StopACQ(){
chkSaveRun->setEnabled(true); chkSaveRun->setEnabled(true);
if( chkSaveRun->isChecked() ){ if( chkSaveRun->isChecked() ){
//TODO ============ stop comment
//TODO ============= elog //TODO ============= elog
runID ++; runID ++;
leRunID->setText(QString::number(runID)); leRunID->setText(QString::number(runID));
} }
@ -542,7 +599,6 @@ void MainWindow::UpdateScalar(){
lbLastUpdateTime->setText("Last update: " + QDateTime::currentDateTime().toString("MM.dd hh:mm:ss")); lbLastUpdateTime->setText("Last update: " + QDateTime::currentDateTime().toString("MM.dd hh:mm:ss"));
printf("++++++++++++++++++ influx %p\n", influx);
if( influx ) influx->ClearDataPointsBuffer(); if( influx ) influx->ClearDataPointsBuffer();
std::string haha[MaxNumberOfChannel] = {""}; std::string haha[MaxNumberOfChannel] = {""};
double acceptRate[MaxNumberOfChannel] = {0}; double acceptRate[MaxNumberOfChannel] = {0};
@ -560,8 +616,6 @@ void MainWindow::UpdateScalar(){
//} //}
//=========== another method, directly readValue //=========== another method, directly readValue
digiMTX.lock(); digiMTX.lock();
for( int ch = 0; ch < digi[iDigi]->GetNChannels(); ch ++){ for( int ch = 0; ch < digi[iDigi]->GetNChannels(); ch ++){
std::string time = digi[iDigi]->ReadChValue(std::to_string(ch), DIGIPARA::CH::ChannelRealtime); // for refreashing SelfTrgRate and SavedCount std::string time = digi[iDigi]->ReadChValue(std::to_string(ch), DIGIPARA::CH::ChannelRealtime); // for refreashing SelfTrgRate and SavedCount
@ -569,9 +623,7 @@ void MainWindow::UpdateScalar(){
leTrigger[iDigi][ch]->setText(QString::fromStdString(haha[ch])); leTrigger[iDigi][ch]->setText(QString::fromStdString(haha[ch]));
std::string kaka = digi[iDigi]->ReadChValue(std::to_string(ch), DIGIPARA::CH::ChannelSavedCount); std::string kaka = digi[iDigi]->ReadChValue(std::to_string(ch), DIGIPARA::CH::ChannelSavedCount);
acceptRate[ch] = atoi(kaka.c_str())*1e9*1.0 / atol(time.c_str()); acceptRate[ch] = atoi(kaka.c_str())*1e9*1.0 / atol(time.c_str());
//if( kaka != "0" ) { //if( kaka != "0" ) printf("%s, %s | %.2f\n", time.c_str(), kaka.c_str(), acceptRate);
// printf("%s, %s | %.2f\n", time.c_str(), kaka.c_str(), acceptRate);
//}
leAccept[iDigi][ch]->setText(QString::number(acceptRate[ch],'f', 1)); leAccept[iDigi][ch]->setText(QString::number(acceptRate[ch],'f', 1));
} }
digiMTX.unlock(); digiMTX.unlock();
@ -580,6 +632,7 @@ void MainWindow::UpdateScalar(){
if( influx ){ if( influx ){
for( int ch = 0; ch < digi[iDigi]->GetNChannels(); ch++ ){ for( int ch = 0; ch < digi[iDigi]->GetNChannels(); ch++ ){
influx->AddDataPoint("Rate,Bd=" + std::to_string(digi[iDigi]->GetSerialNumber()) + ",Ch=" + std::to_string(ch) + " value=" + haha[ch]); influx->AddDataPoint("Rate,Bd=" + std::to_string(digi[iDigi]->GetSerialNumber()) + ",Ch=" + std::to_string(ch) + " value=" + haha[ch]);
influx->AddDataPoint("AccpRate,Bd=" + std::to_string(digi[iDigi]->GetSerialNumber()) + ",Ch=" + std::to_string(ch) + " value=" + std::to_string(acceptRate[ch]));
} }
} }
} }

View File

@ -103,9 +103,12 @@ private:
QComboBox * cbAutoRun; QComboBox * cbAutoRun;
QLineEdit * leRunID; QLineEdit * leRunID;
QLineEdit * leRawDataPath; QLineEdit * leRawDataPath;
QLineEdit * leRunComment;
ReadDataThread ** readDataThread; ReadDataThread ** readDataThread;
void StartACQ(); void StartACQ();
void StopACQ(); void StopACQ();
QString startComment;
QString stopComment;
DigiSettings * digiSetting; DigiSettings * digiSetting;

View File

@ -31,7 +31,7 @@ public:
digi->ErrorMsg("No more data"); digi->ErrorMsg("No more data");
break; break;
}else{ }else{
digi->ErrorMsg("ReadDataLoop()"); //digi->ErrorMsg("ReadDataLoop()");
digi->evt->ClearTrace(); digi->evt->ClearTrace();
} }

View File

@ -32,7 +32,8 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
dataTrace[4]->setPen(QPen(Qt::darkGreen, 1)); dataTrace[4]->setPen(QPen(Qt::darkGreen, 1));
dataTrace[5]->setPen(QPen(Qt::darkBlue, 1)); dataTrace[5]->setPen(QPen(Qt::darkBlue, 1));
plot->setAnimationOptions(QChart::SeriesAnimations); plot->setAnimationDuration(1); // msec
plot->setAnimationOptions(QChart::NoAnimation);
plot->createDefaultAxes(); /// this must be after addSeries(); plot->createDefaultAxes(); /// this must be after addSeries();
/// this must be after createDefaultAxes(); /// this must be after createDefaultAxes();
QValueAxis * yaxis = qobject_cast<QValueAxis*> (plot->axes(Qt::Vertical).first()); QValueAxis * yaxis = qobject_cast<QValueAxis*> (plot->axes(Qt::Vertical).first());
@ -323,6 +324,11 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
plotView->setRenderHints(QPainter::Antialiasing); plotView->setRenderHints(QPainter::Antialiasing);
layout->addWidget(plotView, rowID, 0, 1, 6); layout->addWidget(plotView, rowID, 0, 1, 6);
//------------- Ketbinding
rowID ++;
QLabel * lbhints = new QLabel("Type 'r' to restore view.", this);
layout->addWidget(lbhints, rowID, 0, 1, 4);
//------------ close button //------------ close button
rowID ++; rowID ++;
bnScopeStart = new QPushButton("Start", this); bnScopeStart = new QPushButton("Start", this);