make the RunTimeStamp good within 1 sec
This commit is contained in:
parent
2caf5e7a9b
commit
b0acaeaa07
|
@ -19,10 +19,13 @@ public:
|
||||||
this->ID = digiID;
|
this->ID = digiID;
|
||||||
isSaveData = false;
|
isSaveData = false;
|
||||||
stop = false;
|
stop = false;
|
||||||
|
canSendMsg = true;
|
||||||
}
|
}
|
||||||
|
void SuppressFileSizeMsg() {canSendMsg = false;}
|
||||||
void Stop(){ this->stop = true;}
|
void Stop(){ this->stop = true;}
|
||||||
void SetSaveData(bool onOff) {this->isSaveData = onOff;}
|
void SetSaveData(bool onOff) {this->isSaveData = onOff;}
|
||||||
void run(){
|
void run(){
|
||||||
|
canSendMsg = true;
|
||||||
stop = false;
|
stop = false;
|
||||||
clock_gettime(CLOCK_REALTIME, &ta);
|
clock_gettime(CLOCK_REALTIME, &ta);
|
||||||
emit sendMsg("Digi-" + QString::number(digi->GetSerialNumber()) + " ReadDataThread started.");
|
emit sendMsg("Digi-" + QString::number(digi->GetSerialNumber()) + " ReadDataThread started.");
|
||||||
|
@ -43,7 +46,7 @@ public:
|
||||||
digi->hit->ClearTrace();
|
digi->hit->ClearTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isSaveData ){
|
if( isSaveData && canSendMsg ){
|
||||||
clock_gettime(CLOCK_REALTIME, &tb);
|
clock_gettime(CLOCK_REALTIME, &tb);
|
||||||
if( tb.tv_sec - ta.tv_sec > 2 ) {
|
if( tb.tv_sec - ta.tv_sec > 2 ) {
|
||||||
emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetTotalFilesSize()/1024./1024.) + " MB");
|
emit sendMsg("FileSize ("+ QString::number(digi->GetSerialNumber()) +"): " + QString::number(digi->GetTotalFilesSize()/1024./1024.) + " MB");
|
||||||
|
@ -66,7 +69,7 @@ private:
|
||||||
Digitizer2Gen * digi;
|
Digitizer2Gen * digi;
|
||||||
int ID;
|
int ID;
|
||||||
timespec ta, tb;
|
timespec ta, tb;
|
||||||
bool isSaveData, stop;
|
bool isSaveData, stop, canSendMsg;
|
||||||
};
|
};
|
||||||
|
|
||||||
//^#======================================================= Timing Thread, for some action need to be done periodically
|
//^#======================================================= Timing Thread, for some action need to be done periodically
|
||||||
|
|
102
mainwindow.cpp
102
mainwindow.cpp
|
@ -42,7 +42,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
||||||
|
|
||||||
runTimer = new QTimer();
|
runTimer = new QTimer();
|
||||||
needManualComment = true;
|
needManualComment = true;
|
||||||
isRunning = false;
|
isACQRunning = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
scalarOutputInflux = false;
|
scalarOutputInflux = false;
|
||||||
|
@ -219,7 +219,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
|
||||||
runTimer->stop();
|
runTimer->stop();
|
||||||
StopACQ();
|
StopACQ();
|
||||||
|
|
||||||
if( !isRunning ){
|
if( !isACQRunning ){
|
||||||
bnStartACQ->setEnabled(true);
|
bnStartACQ->setEnabled(true);
|
||||||
bnStopACQ->setEnabled(false);
|
bnStopACQ->setEnabled(false);
|
||||||
bnComment->setEnabled(false);
|
bnComment->setEnabled(false);
|
||||||
|
@ -415,16 +415,6 @@ int MainWindow::StartACQ(){
|
||||||
startComment = "AutoRun for " + cbAutoRun->currentText();
|
startComment = "AutoRun for " + cbAutoRun->currentText();
|
||||||
leRunComment->setText(startComment);
|
leRunComment->setText(startComment);
|
||||||
}
|
}
|
||||||
// ============ elog
|
|
||||||
QString elogMsg = "=============== Run-" + runIDStr + "<br />"
|
|
||||||
+ QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.z") + "<br />"
|
|
||||||
+ "comment : " + startComment + "<br />" +
|
|
||||||
+ "----------------------------------------------";
|
|
||||||
WriteElog(elogMsg, "Run-" + runIDStr, "Run", runID);
|
|
||||||
// ============ update expName.sh
|
|
||||||
WriteExpNameSh();
|
|
||||||
|
|
||||||
WriteRunTimeStampDat(true);
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
LogMsg("=========================== Start no-save Run");
|
LogMsg("=========================== Start no-save Run");
|
||||||
|
@ -461,7 +451,21 @@ int MainWindow::StartACQ(){
|
||||||
//TODO ========================== Sync start.
|
//TODO ========================== Sync start.
|
||||||
readDataThread[i]->SetSaveData(chkSaveRun->isChecked());
|
readDataThread[i]->SetSaveData(chkSaveRun->isChecked());
|
||||||
readDataThread[i]->start();
|
readDataThread[i]->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(chkSaveRun->isChecked() ){
|
||||||
|
QString startTimeStr = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss");
|
||||||
|
LogMsg("<font style=\"color : blue;\"> All Digitizers started. </font>");
|
||||||
|
// ============ elog
|
||||||
|
QString elogMsg = "=============== Run-" + runIDStr + "<br />"
|
||||||
|
+ startTimeStr + "<br />"
|
||||||
|
+ "comment : " + startComment + "<br />" +
|
||||||
|
+ "----------------------------------------------";
|
||||||
|
WriteElog(elogMsg, "Run-" + runIDStr, "Run", runID);
|
||||||
|
// ============ update expName.sh
|
||||||
|
WriteExpNameSh();
|
||||||
|
|
||||||
|
WriteRunTimeStampDat(true, startTimeStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( influx ){
|
if( influx ){
|
||||||
|
@ -477,7 +481,7 @@ int MainWindow::StartACQ(){
|
||||||
scalar->show();
|
scalar->show();
|
||||||
if( !scalarThread->isRunning() ) scalarThread->start();
|
if( !scalarThread->isRunning() ) scalarThread->start();
|
||||||
}
|
}
|
||||||
isRunning = True;
|
isACQRunning = True;
|
||||||
lbScalarACQStatus->setText("<font style=\"color: green;\"><b>ACQ On</b></font>");
|
lbScalarACQStatus->setText("<font style=\"color: green;\"><b>ACQ On</b></font>");
|
||||||
//scalarThread->start();
|
//scalarThread->start();
|
||||||
scalarOutputInflux = true;
|
scalarOutputInflux = true;
|
||||||
|
@ -488,6 +492,10 @@ int MainWindow::StartACQ(){
|
||||||
|
|
||||||
void MainWindow::StopACQ(){
|
void MainWindow::StopACQ(){
|
||||||
|
|
||||||
|
if( !isACQRunning ) return;
|
||||||
|
|
||||||
|
bnStopACQ->setEnabled(false);
|
||||||
|
|
||||||
if( chkSaveRun->isChecked() ){
|
if( chkSaveRun->isChecked() ){
|
||||||
//============ stop comment
|
//============ stop comment
|
||||||
if( needManualComment ){
|
if( needManualComment ){
|
||||||
|
@ -531,10 +539,33 @@ void MainWindow::StopACQ(){
|
||||||
for( int i = nDigi - 1; i >= 0; i--){
|
for( int i = nDigi - 1; i >= 0; i--){
|
||||||
if( digi[i]->IsDummy () ) continue;
|
if( digi[i]->IsDummy () ) continue;
|
||||||
digi[i]->StopACQ();
|
digi[i]->StopACQ();
|
||||||
|
readDataThread[i]->SuppressFileSizeMsg();
|
||||||
}
|
}
|
||||||
|
isACQRunning = false;
|
||||||
|
lbScalarACQStatus->setText("<font style=\"color: red;\"><b>ACQ Off</b></font>");
|
||||||
|
|
||||||
|
QString stopTimeStr = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss");
|
||||||
scalarOutputInflux = false;
|
scalarOutputInflux = false;
|
||||||
|
|
||||||
|
if( chkSaveRun->isChecked() ){
|
||||||
|
LogMsg("=========================== <b><font style=\"color : red;\">Run-" + runIDStr + "</font></b> stopped.");
|
||||||
|
LogMsg("<font style=\"color : blue;\">Please wait for collecting all remaining data.</font>");
|
||||||
|
WriteRunTimeStampDat(false, stopTimeStr);
|
||||||
|
|
||||||
|
// ============= elog
|
||||||
|
QString msg = stopTimeStr + "<br />";
|
||||||
|
for( int i = 0; i < nDigi; i++){
|
||||||
|
if( digi[i]->IsDummy () ) continue;
|
||||||
|
msg += "FileSize ("+ QString::number(digi[i]->GetSerialNumber()) +"): " + QString::number(digi[i]->GetTotalFilesSize()/1024./1024.) + " MB <br />";
|
||||||
|
}
|
||||||
|
msg += "comment : " + stopComment + "<br />"
|
||||||
|
+ "======================";
|
||||||
|
AppendElog(msg, chromeWindowID);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
LogMsg("=========================== no-Save Run stopped.");
|
||||||
|
}
|
||||||
|
|
||||||
if( influx ){
|
if( influx ){
|
||||||
influx->ClearDataPointsBuffer();
|
influx->ClearDataPointsBuffer();
|
||||||
if( chkSaveRun->isChecked() ){
|
if( chkSaveRun->isChecked() ){
|
||||||
|
@ -544,31 +575,6 @@ void MainWindow::StopACQ(){
|
||||||
influx->WriteData(DatabaseName.toStdString());
|
influx->WriteData(DatabaseName.toStdString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if( chkSaveRun->isChecked() ){
|
|
||||||
LogMsg("=========================== <b><font style=\"color : red;\">Run-" + runIDStr + "</font></b> stopped.");
|
|
||||||
LogMsg("Please wait for collecting all remaining data.");
|
|
||||||
WriteRunTimeStampDat(false);
|
|
||||||
|
|
||||||
// ============= elog
|
|
||||||
QString msg = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss.z") + "<br />";
|
|
||||||
for( int i = 0; i < nDigi; i++){
|
|
||||||
if( digi[i]->IsDummy () ) continue;
|
|
||||||
msg += "FileSize ("+ QString::number(digi[i]->GetSerialNumber()) +"): " + QString::number(digi[i]->GetTotalFilesSize()/1024./1024.) + " MB <br />";
|
|
||||||
}
|
|
||||||
msg += "comment : " + stopComment + "<br />"
|
|
||||||
+ "======================";
|
|
||||||
AppendElog(msg, chromeWindowID);
|
|
||||||
|
|
||||||
LogMsg("Run " + programSettingsPath + "/scripts/endRunScript.sh" );
|
|
||||||
QProcess::startDetached(programSettingsPath + "/scripts/endRunScript.sh");
|
|
||||||
|
|
||||||
}else{
|
|
||||||
LogMsg("=========================== no-Save Run stopped.");
|
|
||||||
}
|
|
||||||
|
|
||||||
isRunning = false;
|
|
||||||
lbScalarACQStatus->setText("<font style=\"color: red;\"><b>ACQ Off</b></font>");
|
|
||||||
|
|
||||||
if( !chkSaveRun->isChecked() ) LogMsg("Collecting remaining data from the digitizers... ");
|
if( !chkSaveRun->isChecked() ) LogMsg("Collecting remaining data from the digitizers... ");
|
||||||
for( int i = nDigi -1; i >=0; i--){
|
for( int i = nDigi -1; i >=0; i--){
|
||||||
if( readDataThread[i]->isRunning()){
|
if( readDataThread[i]->isRunning()){
|
||||||
|
@ -582,6 +588,13 @@ void MainWindow::StopACQ(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( chkSaveRun->isChecked() ){
|
||||||
|
LogMsg("Run " + programSettingsPath + "/scripts/endRunScript.sh" );
|
||||||
|
QProcess::startDetached(programSettingsPath + "/scripts/endRunScript.sh");
|
||||||
|
}
|
||||||
|
|
||||||
|
LogMsg("<b><font style=\"color : green;\">SOLARIS DAQ is ready for next run.</font></b>");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::AutoRun(){
|
void MainWindow::AutoRun(){
|
||||||
|
@ -1097,7 +1110,7 @@ void MainWindow::UpdateAllPanel(int panelID){
|
||||||
//^###################################################################### Open Scaler, when DAQ is running
|
//^###################################################################### Open Scaler, when DAQ is running
|
||||||
void MainWindow::OpenScaler(){
|
void MainWindow::OpenScaler(){
|
||||||
scalar->show();
|
scalar->show();
|
||||||
if( isRunning ) {
|
if( isACQRunning ) {
|
||||||
lbScalarACQStatus->setText("<font style=\"color: green;\"><b>ACQ On</b></font>");
|
lbScalarACQStatus->setText("<font style=\"color: green;\"><b>ACQ On</b></font>");
|
||||||
}else{
|
}else{
|
||||||
lbScalarACQStatus->setText("<font style=\"color: red;\"><b>ACQ Off</b></font>");
|
lbScalarACQStatus->setText("<font style=\"color: red;\"><b>ACQ Off</b></font>");
|
||||||
|
@ -2247,17 +2260,16 @@ void MainWindow::AppendElog(QString appendHtmlText, int screenID){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::WriteRunTimeStampDat(bool isStartRun){
|
void MainWindow::WriteRunTimeStampDat(bool isStartRun, QString timeStr){
|
||||||
|
|
||||||
QFile file(dataPath + "/" + expName + "/RunTimeStamp.dat");
|
QFile file(dataPath + "/" + expName + "/RunTimeStamp.dat");
|
||||||
|
|
||||||
QString dateTime = QDateTime::currentDateTime().toString("yyyy.MM.dd hh:mm:ss");
|
|
||||||
if( file.open(QIODevice::Text | QIODevice::WriteOnly | QIODevice::Append) ){
|
if( file.open(QIODevice::Text | QIODevice::WriteOnly | QIODevice::Append) ){
|
||||||
|
|
||||||
if( isStartRun ){
|
if( isStartRun ){
|
||||||
file.write(("Start Run | " + QString::number(runID) + " | " + dateTime + " | " + startComment + "\n").toStdString().c_str());
|
file.write(("Start Run | " + QString::number(runID) + " | " + timeStr + " | " + startComment + "\n").toStdString().c_str());
|
||||||
}else{
|
}else{
|
||||||
file.write((" Stop Run | " + QString::number(runID) + " | " + dateTime + " | " + stopComment + "\n").toStdString().c_str());
|
file.write((" Stop Run | " + QString::number(runID) + " | " + timeStr + " | " + stopComment + "\n").toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
@ -2271,9 +2283,9 @@ void MainWindow::WriteRunTimeStampDat(bool isStartRun){
|
||||||
QTextStream out(&fileCSV);
|
QTextStream out(&fileCSV);
|
||||||
|
|
||||||
if( isStartRun){
|
if( isStartRun){
|
||||||
out << QString::number(runID) + "," + dateTime + "," + startComment;
|
out << QString::number(runID) + "," + timeStr + "," + startComment;
|
||||||
}else{
|
}else{
|
||||||
out << "," + dateTime + "," + stopComment + "\n";
|
out << "," + timeStr + "," + stopComment + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
fileCSV.close();
|
fileCSV.close();
|
||||||
|
|
|
@ -86,7 +86,7 @@ private slots:
|
||||||
void WriteElog(QString htmlText, QString subject = "", QString category = "", int runNumber = 0);
|
void WriteElog(QString htmlText, QString subject = "", QString category = "", int runNumber = 0);
|
||||||
void AppendElog(QString appendHtmlText, int screenID = -1);
|
void AppendElog(QString appendHtmlText, int screenID = -1);
|
||||||
|
|
||||||
void WriteRunTimeStampDat(bool isStartRun);
|
void WriteRunTimeStampDat(bool isStartRun, QString timeStr);
|
||||||
|
|
||||||
signals :
|
signals :
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ private:
|
||||||
QString stopComment;
|
QString stopComment;
|
||||||
QString appendComment;
|
QString appendComment;
|
||||||
bool needManualComment;
|
bool needManualComment;
|
||||||
bool isRunning;
|
bool isACQRunning;
|
||||||
QTimer * runTimer;
|
QTimer * runTimer;
|
||||||
QElapsedTimer elapsedTimer;
|
QElapsedTimer elapsedTimer;
|
||||||
unsigned int autoRunStartRunID;
|
unsigned int autoRunStartRunID;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user