From 171561f8230a5334343258ba7b96a8fbb6cd1a49 Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS-DAQ" Date: Fri, 10 Mar 2023 14:42:29 -0500 Subject: [PATCH] fixeed many issue when run on solaris server daq --- ClassDigitizer2Gen.cpp | 2 +- Event.h | 14 +++++------ influxdb.cpp | 8 +++--- mainwindow.cpp | 56 ++++++++++++++++++++++++++++-------------- makeTest | 2 +- scope.cpp | 27 +++++++++++++------- 6 files changed, 68 insertions(+), 41 deletions(-) diff --git a/ClassDigitizer2Gen.cpp b/ClassDigitizer2Gen.cpp index 233015e..952d91c 100644 --- a/ClassDigitizer2Gen.cpp +++ b/ClassDigitizer2Gen.cpp @@ -521,7 +521,7 @@ int Digitizer2Gen::ReadData(){ return CAEN_FELib_UNKNOWN; } - evt->traceZero = false; + evt->isTraceAllZero = false; if( ret != CAEN_FELib_Success) { //ErrorMsg("ReadData()"); diff --git a/Event.h b/Event.h index 2dacffa..137b98d 100644 --- a/Event.h +++ b/Event.h @@ -5,7 +5,7 @@ #include #include -#define MaxTraceLenght 2048 +#define MaxTraceLenght 8100 class Event { public: @@ -36,7 +36,7 @@ class Event { size_t dataSize; /// number of byte of the data, size/8 = word [64 bits] uint32_t n_events; - bool traceZero; + bool isTraceAllZero; Event(){ Init(); @@ -74,7 +74,7 @@ class Event { digital_probes_type[3] = 0xFF; data = NULL; - traceZero = true; // indicate trace are all zero + isTraceAllZero = true; // indicate trace are all zero } void ClearMemory(){ @@ -88,7 +88,7 @@ class Event { if( digital_probes[2] != NULL) delete digital_probes[2]; if( digital_probes[3] != NULL) delete digital_probes[3]; - traceZero = true; + isTraceAllZero = true; } void SetDataType(unsigned int type){ @@ -106,13 +106,13 @@ class Event { digital_probes[2] = new uint8_t[MaxTraceLenght]; digital_probes[3] = new uint8_t[MaxTraceLenght]; - traceZero = true; + isTraceAllZero = true; } } void ClearTrace(){ - if( traceZero ) return; // no need to clear again + if( isTraceAllZero ) return; // no need to clear again for( int i = 0; i < MaxTraceLenght; i++){ analog_probes[0][i] = 0; @@ -123,7 +123,7 @@ class Event { digital_probes[2][i] = 0; digital_probes[3][i] = 0; } - traceZero = true; + isTraceAllZero = true; } void PrintEnergyTimeStamp(){ diff --git a/influxdb.cpp b/influxdb.cpp index d9070bf..afb8747 100644 --- a/influxdb.cpp +++ b/influxdb.cpp @@ -32,7 +32,7 @@ bool InfluxDB::TestingConnection(){ std::string InfluxDB::CheckDatabases(){ curl_easy_setopt(curl, CURLOPT_POST, 1); - curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "/query").c_str()); + curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "query").c_str()); std::string postFields="q=Show databases"; curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast(postFields.length())); @@ -88,7 +88,7 @@ std::string InfluxDB::Query(std::string databaseName, std::string query){ curl_easy_setopt(curl, CURLOPT_POST, 1); - curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "/query?db=" + databaseName).c_str()); + curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "query?db=" + databaseName).c_str()); std::string postFields = "q=" + query; curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast(postFields.length())); @@ -106,7 +106,7 @@ std::string InfluxDB::Query(std::string databaseName, std::string query){ } void InfluxDB::CreateDatabase(std::string databaseName){ - curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "/query").c_str()); + curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "query").c_str()); curl_easy_setopt(curl, CURLOPT_POST, 1); std::string postFields = "q=CREATE DATABASE " + databaseName; @@ -143,7 +143,7 @@ void InfluxDB::Execute(){ try{ respond = curl_easy_perform(curl); curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &respondCode); - //printf("==== respond code %ld (OK = %d)\n", respond, CURLE_OK); + //printf("==== respond %d (OK = %d)\n", respond, CURLE_OK); if( respond != CURLE_OK) printf("############# InfluxDB::Execute fail\n"); } catch (std::exception& e){ // in case of unexpected error printf("%s\n", e.what()); diff --git a/mainwindow.cpp b/mainwindow.cpp index cbd6eb0..7bf4e0e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -249,6 +249,7 @@ MainWindow::~MainWindow(){ if( digi ){ for( int i = 0; i < nDigi ; i++){ if( digi[i]->IsDummy()) continue; + //printf("=== %d %p\n", i, readDataThread[i]); if( readDataThread[i]->isRunning()) StopACQ(); } } @@ -478,14 +479,6 @@ void MainWindow::OpenDigitizers(){ if(digi[i]->IsConnected()){ LogMsg("Opened digitizer : " + QString::number(digi[i]->GetSerialNumber()) + ""); - bnStartACQ->setEnabled(true); - bnStopACQ->setEnabled(false); - bnOpenScope->setEnabled(true); - chkSaveRun->setEnabled(true); - bnOpenDigitizers->setEnabled(false); - bnOpenDigitizers->setStyleSheet(""); - //cbAutoRun->setEnabled(true); - cbAutoRun->setEnabled(false); readDataThread[i] = new ReadDataThread(digi[i], this); connect(readDataThread[i], &ReadDataThread::sendMsg, this, &MainWindow::LogMsg); @@ -495,19 +488,31 @@ void MainWindow::OpenDigitizers(){ //*------ search for settings_XXXX.dat QString settingFile = analysisPath + "/settings_" + QString::number(digi[i]->GetSerialNumber()) + ".dat"; if( digi[i]->LoadSettingsFromFile( settingFile.toStdString().c_str() ) ){ - LogMsg("Found setting file " + settingFile + " and loaded."); + LogMsg("Found setting file " + settingFile + " and loading. please wait."); digi[i]->SetSettingFileName(settingFile.toStdString()); + LogMsg("done settings."); }else{ LogMsg("Unable to found setting file " + settingFile + ". "); digi[i]->SetSettingFileName(""); - LogMsg("Reset digitizer and use deault setting"); + LogMsg("Reset digitizer."); digi[i]->Reset(); - digi[i]->ProgramPHA(false); + + digi[i]->WriteValue(DIGIPARA::CH::RecordLength, "4000"); + digi[i]->WriteValue(DIGIPARA::CH::PreTrigger, "1000"); + //digi[i]->ProgramPHA(false); } digi[i]->ReadAllSettings(); SetUpScalar(); + bnStartACQ->setEnabled(true); + bnStopACQ->setEnabled(false); + bnOpenScope->setEnabled(true); + chkSaveRun->setEnabled(true); + bnOpenDigitizers->setEnabled(false); + bnOpenDigitizers->setStyleSheet(""); + //cbAutoRun->setEnabled(true); + cbAutoRun->setEnabled(false); bnOpenScalar->setEnabled(true); }else{ @@ -529,10 +534,18 @@ void MainWindow::CloseDigitizers(){ scalar->close(); DeleteTriggerLineEdit(); // this use digi->GetNChannels(); + + if( scope != NULL ){ + scope->close(); + delete scope; + scope = NULL; + } - digiSetting->close(); - delete digiSetting; - digiSetting = NULL; + if( digiSetting != NULL ){ + digiSetting->close(); + delete digiSetting; + digiSetting = NULL; + } for( int i = 0; i < nDigi; i++){ if( digi[i] == NULL) return; @@ -968,10 +981,12 @@ void MainWindow::SetupInflux(){ LogMsg(" InfluxDB URL ("+ DatabaseIP + ") is Valid "); //==== chck database exist + LogMsg("List of database:"); std::vector databaseList = influx->GetDatabaseList(); bool foundDatabase = false; for( int i = 0; i < (int) databaseList.size(); i++){ if( databaseList[i] == DatabaseName.toStdString() ) foundDatabase = true; + LogMsg(QString::number(i) + "|" + QString::fromStdString(databaseList[i])); } if( foundDatabase ){ @@ -1496,15 +1511,18 @@ void MainWindow::WriteElog(QString htmlText, QString subject, QString category, if( elogID < 0 ) return; if( expName == "" ) return; + //TODO ===== Rethink the elog process, becasue the grafana screenshot most probably obtained from screenshot, unless there is an API for that + //TODO ===== user name and pwd load from a file. + QStringList arg; - arg << "-h" << ElogIP << "-p" << "8080" << "-l" << expName << "-u" << "GeneralFSU" << "fsuphysics-888" - << "-a" << "Author=GeneralFSU" ; + arg << "-h" << ElogIP << "-p" << "8080" << "-l" << expName << "-u" << "GeneralSOLARIS" << "solaris" + << "-a" << "Author=\'General SOLARIS\'" ; if( runNumber > 0 ) arg << "-a" << "Run=" + QString::number(runNumber); if( category != "" ) arg << "-a" << "Category=" + category; arg << "-a" << "Subject=" + subject << "-n " << "2" << htmlText ; - + QProcess elogBash(this); elogBash.start("elog", arg); elogBash.waitForFinished(); @@ -1527,7 +1545,7 @@ void MainWindow::AppendElog(QString appendHtmlText, int screenID){ QProcess elogBash(this); QStringList arg; - arg << "-h" << ElogIP << "-p" << "8080" << "-l" << expName << "-u" << "GeneralFSU" << "fsuphysics-888" << "-w" << QString::number(elogID); + arg << "-h" << ElogIP << "-p" << "8080" << "-l" << expName << "-u" << "GeneralSOLARIS" << "solaris" << "-w" << QString::number(elogID); //retrevie the elog elogBash.start("elog", arg); @@ -1544,7 +1562,7 @@ void MainWindow::AppendElog(QString appendHtmlText, int screenID){ QString originalHtml = output.mid(index + separator.length()); arg.clear(); - arg << "-h" << ElogIP << "-p" << "8080" << "-l" << expName << "-u" << "GeneralFSU" << "fsuphysics-888" << "-e" << QString::number(elogID) + arg << "-h" << ElogIP << "-p" << "8080" << "-l" << expName << "-u" << "GeneralSOLARIS" << "solaris" << "-e" << QString::number(elogID) << "-n" << "2" << originalHtml + "
" + appendHtmlText; if( screenID >= 0) { diff --git a/makeTest b/makeTest index 9aad11b..88ed8d0 100755 --- a/makeTest +++ b/makeTest @@ -6,9 +6,9 @@ CURLLIBS = -lcurl OBJS= ClassDigitizer2Gen.o influxdb.o # -ALL = test windowID # ################################################################ +all : test windowID # test : test.cpp ClassDigitizer2Gen.o influxdb.o diff --git a/scope.cpp b/scope.cpp index 8fa5bc6..5dbb25b 100644 --- a/scope.cpp +++ b/scope.cpp @@ -6,6 +6,8 @@ #include #include +#define MaxDisplayTraceDataLength 2000 //data point, + Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow *parent) : QMainWindow(parent){ this->digi = digi; this->nDigi = nDigi; @@ -333,6 +335,11 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat lbinfo->setAlignment(Qt::AlignRight); layout->addWidget(lbinfo, rowID, 5); + rowID ++; + QLabel * lbinfo2 = new QLabel("Maximum time range is " + QString::number(MaxDisplayTraceDataLength * 8) + " ns due to processing speed.", this); + layout->addWidget(lbinfo2, rowID, 0, 1, 5); + + //------------ close button rowID ++; bnScopeStart = new QPushButton("Start", this); @@ -483,9 +490,6 @@ void Scope::UpdateScope(){ emit UpdateScalar(); if( digi ){ - //---- remove all points - unsigned int dataLength = dataTrace[0]->count(); - for( int j = 0; j < 6; j++ ) dataTrace[j]->removePoints(0, dataLength); digiMTX.lock(); std::string time = digi[iDigi]->ReadValue(DIGIPARA::CH::ChannelRealtime, ch); // for refreashing SelfTrgRate and SavedCount @@ -496,16 +500,21 @@ void Scope::UpdateScope(){ return; } - unsigned int traceLength = digi[iDigi]->evt->traceLenght; + unsigned int traceLength = qMin((int) digi[iDigi]->evt->traceLenght, MaxDisplayTraceDataLength); - for( unsigned int i = 0 ; i < traceLength; i++){ - for( int j = 0; j < 2; j++) dataTrace[j]->append(sample2ns * i, digi[iDigi]->evt->analog_probes[j][i]); - for( int j = 2; j < 6; j++) dataTrace[j]->append(sample2ns * i, (j-1)*1000 + 4000 * digi[iDigi]->evt->digital_probes[j-2][i]); + for( int j = 0; j < 2; j++) { + QVector points; + for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , digi[iDigi]->evt->analog_probes[j][i])); + dataTrace[j]->replace(points); + } + for( int j = 0; j < 4; j++) { + QVector points; + for( unsigned int i = 0 ; i < traceLength; i++) points.append(QPointF(sample2ns * i , (j+1)*1000 + 4000*digi[iDigi]->evt->digital_probes[j][i])); + dataTrace[j+2]->replace(points); } - digiMTX.unlock(); - plot->axes(Qt::Horizontal).first()->setRange(0, sample2ns * traceLength); + } }