solved the slow down problem by repaint the main window

This commit is contained in:
Ryan Tang 2024-04-18 10:06:55 -04:00
parent 3c8229fbfb
commit dfe4c4738b
7 changed files with 43 additions and 12 deletions

View File

@ -160,6 +160,7 @@
"fstream": "cpp",
"Analyzer.C": "cpp",
"process_Run.C": "cpp",
"EncoreAnalyzer.C": "cpp"
"EncoreAnalyzer.C": "cpp",
"qfiledialog": "cpp"
}
}

View File

@ -5,6 +5,7 @@
#include <QMutex>
#include <QWaitCondition>
#include <QMessageBox>
#include <QCoreApplication>
#include "macro.h"
#include "ClassDigitizer.h"
@ -81,6 +82,7 @@ public:
digi->ReadACQStatus();
digiMTX[ID].unlock();
t2 = t1;
// QCoreApplication::processEvents();
}
// if( isSaveData && !stop ) {

View File

@ -97,8 +97,17 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr
SetUpInfo("Ch. Mem. Size ", memStr.toStdString() , infoLayout[ID], 3, 2);
uint32_t boardInfo = digi[ID]->GetSettingFromMemory(DPP::BoardInfo_R);
printf("----------- boardInfo : 0x%08X \n", boardInfo);
SetUpInfo("Board Type ", ((boardInfo >> 16) & 0xFF) == 0x10 ? "16-ch VME" : "8-ch Bd.", infoLayout[ID], 3, 4);
// printf("----------- boardInfo : 0x%08X \n", boardInfo);
std::string boardInfoStr;
unsigned short boardTypeNumber = (boardInfo & 0xFF);
switch (boardTypeNumber){
case 0x04 : boardInfoStr = "64-ch VME"; break;
case 0x0E : boardInfoStr = ((boardInfo >> 16) & 0xFF) == 0x10 ? "16-ch VME" : "8-ch Bd."; break;
case 0x0B : boardInfoStr = ((boardInfo >> 16) & 0xFF) == 0x10 ? "16-ch VME" : "8-ch Bd."; break;
default : boardInfoStr = "unknown";
}
SetUpInfo("Board Type ", boardInfoStr, infoLayout[ID], 3, 4);
}

View File

@ -41,6 +41,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent){
runRecord = nullptr;
model = nullptr;
influx = nullptr;
scalarCount = 0;
QWidget * mainLayoutWidget = new QWidget(this);
setCentralWidget(mainLayoutWidget);
@ -896,7 +897,8 @@ void MainWindow::SetupScalar(){
lbFileSize[iDigi]->setAlignment(Qt::AlignLeft | Qt::AlignCenter);
hBoxLayout->addWidget(lbFileSize[iDigi]);
QLabel * lbDigi = new QLabel("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()), scalar);
// QLabel * lbDigi = new QLabel("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()), scalar);
QLabel * lbDigi = new QLabel(QString::number(digi[iDigi]->GetSerialNumber()), scalar);
lbDigi->setAlignment(Qt::AlignRight | Qt::AlignCenter);
hBoxLayout->addWidget(lbDigi);
@ -986,6 +988,7 @@ void MainWindow::UpdateScalar(){
// digi[0]->GetData()->PrintAllData();
lbLastUpdateTime->setText("Last update: " + QDateTime::currentDateTime().toString("MM.dd hh:mm:ss"));
scalarCount ++;
uint64_t totalFileSize = 0;
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi++){
@ -994,9 +997,9 @@ void MainWindow::UpdateScalar(){
uint32_t acqStatus = digi[iDigi]->GetACQStatusFromMemory();
//printf("Digi-%d : acq on/off ? : %d \n", digi[iDigi]->GetSerialNumber(), (acqStatus >> 2) & 0x1 );
if( ( acqStatus >> 2 ) & 0x1 ){
runStatus[iDigi]->setStyleSheet("background-color : green;");
if( runStatus[iDigi]->styleSheet() == "") runStatus[iDigi]->setStyleSheet("background-color : green;");
}else{
runStatus[iDigi]->setStyleSheet("");
if( runStatus[iDigi]->styleSheet() != "") runStatus[iDigi]->setStyleSheet("");
}
if(digiSettings && digiSettings->isVisible() && digiSettings->GetTabID() == iDigi) digiSettings->UpdateACQStatus(acqStatus);
@ -1023,16 +1026,20 @@ void MainWindow::UpdateScalar(){
leAccept[iDigi][i]->setText(b);
if( influx && a != "inf" ){
influx->AddDataPoint("Rate,Bd="+std::to_string(digi[iDigi]->GetSerialNumber()) + ",Ch=" + QString::number(i).rightJustified(2, '0').toStdString() + " value=" + a.toStdString());
influx->AddDataPoint("TrigRate,Bd="+std::to_string(digi[iDigi]->GetSerialNumber()) + ",Ch=" + QString::number(i).rightJustified(2, '0').toStdString() + " value=" + a.toStdString());
}
}
}
digiMTX[iDigi].unlock();
}
if( influx ){
repaint();
scalar->repaint();
if( influx && scalarCount >= 3){
if( chkSaveData->isChecked() ) {
influx->AddDataPoint("RunID value=" + std::to_string(runID));
influx->AddDataPoint("FileSize value=" + std::to_string(totalFileSize));
@ -1040,6 +1047,7 @@ void MainWindow::UpdateScalar(){
//nflux->PrintDataPoints();
influx->WriteData(dataBaseName.toStdString());
influx->ClearDataPointsBuffer();
scalarCount = 0;
}
}
@ -1228,6 +1236,9 @@ void MainWindow::StopACQ(){
chkSaveData->setEnabled(true);
bnDigiSettings->setEnabled(true);
repaint();
printf("================ end of %s \n", __func__);
}
void MainWindow::AutoRun(){
@ -1638,7 +1649,8 @@ void MainWindow::WriteRunTimestamp(bool isStartRun){
//***************************************************************
//***************************************************************
void MainWindow::OpenScope(){
DebugPrint("%s", "FSUDAQ");
QCoreApplication::processEvents();
if( scope == nullptr ) {
scope = new Scope(digi, nDigi, readDataThread);
connect(scope, &Scope::SendLogMsg, this, &MainWindow::LogMsg);
@ -1711,7 +1723,6 @@ void MainWindow::OpenDigiSettings(){
digiSettings->show();
digiSettings->activateWindow();
}
}
//***************************************************************
@ -1731,6 +1742,7 @@ void MainWindow::OpenCanvas(){
//***************************************************************
void MainWindow::OpenAnalyzer(){
DebugPrint("%s", "FSUDAQ");
int id = cbAnalyzer->currentData().toInt();
if( id < 0 ) return;
@ -1890,6 +1902,8 @@ void MainWindow::SetUpInflux(){
void MainWindow::CheckElog(){
DebugPrint("%s", "FSUDAQ");
LogMsg("---- Checking elog... please wait....");
printf("---- Checking elog... please wait....\n");
if( elogIP != "" && elogName != "" && elogUser != "" && elogPWD != "" ){
WriteElog("Testing communication.", "Testing communication.", "Other", 0);
AppendElog("test append elog.");
@ -1902,11 +1916,13 @@ void MainWindow::CheckElog(){
if( elogID >= 0 ) {
LogMsg("Elog testing OK.");
printf("Elog testing OK.\n");
return;
}
//QMessageBox::information(nullptr, "Information", "Elog write Fail.\nPlease set the elog User and PWD in the programSettings.txt.\nline 6 = user.\nline 7 = pwd.");
LogMsg("Elog testing Fail");
printf("Elog testing Fail\n");
if( elogIP == "" ) LogMsg("no elog IP");
if( elogName == "" ) LogMsg("no elog Name");
if( elogUser == "" ) LogMsg("no elog User name. Please set it in the programSettings.txt, line 6.");

View File

@ -135,6 +135,7 @@ private:
QLineEdit * leDatabaseName;
QPushButton * bnLock;
QString influxToken;
short scalarCount;
//@----- Elog
QString elogIP;

View File

@ -204,8 +204,6 @@ void SingleSpectra::FillHistograms(){
// DebugPrint("%s", "SingleSpectra");
if( !fillHistograms ) return;
printf("=====================%s\n", __func__);
timespec t0, t1;
QVector<int> randomDigiList = generateNonRepeatedCombination(nDigi);

View File

@ -9,6 +9,8 @@
#include <QObject>
#include <QDebug>
#include <sys/resource.h>
// class CustomApplication : public QApplication{
// public:
// CustomApplication(int &argc, char **argv) : QApplication(argc, argv) {}
@ -25,6 +27,8 @@ int main(int argc, char *argv[]){
// CustomApplication a(argc, argv);
QApplication a(argc, argv);
setpriority(PRIO_PROCESS, 0, -20);
bool isLock = false;
int pid = 0;
QFile lockFile(DAQLockFile);