fixeed many issue when run on solaris server daq

This commit is contained in:
Ryan Tang 2023-03-10 14:42:29 -05:00
parent 6be0b9400f
commit 171561f823
6 changed files with 68 additions and 41 deletions

View File

@ -521,7 +521,7 @@ int Digitizer2Gen::ReadData(){
return CAEN_FELib_UNKNOWN;
}
evt->traceZero = false;
evt->isTraceAllZero = false;
if( ret != CAEN_FELib_Success) {
//ErrorMsg("ReadData()");

14
Event.h
View File

@ -5,7 +5,7 @@
#include <cstdlib>
#include <stdint.h>
#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(){

View File

@ -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<long>(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<long>(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());

View File

@ -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 : <font style=\"color:red;\">" + QString::number(digi[i]->GetSerialNumber()) + "</font>");
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 <b>" + settingFile + "</b> and loaded.");
LogMsg("Found setting file <b>" + settingFile + "</b> and loading. please wait.");
digi[i]->SetSettingFileName(settingFile.toStdString());
LogMsg("done settings.");
}else{
LogMsg("<font style=\"color: red;\">Unable to found setting file <b>" + settingFile + "</b>. </font>");
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("<font style=\"color : green;\"> InfluxDB URL (<b>"+ DatabaseIP + "</b>) is Valid </font>");
//==== chck database exist
LogMsg("List of database:");
std::vector<std::string> 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 + "<br>" + appendHtmlText;
if( screenID >= 0) {

View File

@ -6,9 +6,9 @@ CURLLIBS = -lcurl
OBJS= ClassDigitizer2Gen.o influxdb.o
#
ALL = test windowID
#
################################################################
all : test windowID
#
test : test.cpp ClassDigitizer2Gen.o influxdb.o

View File

@ -6,6 +6,8 @@
#include <QStandardItemModel>
#include <QLabel>
#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<QPointF> 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<QPointF> 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);
}
}