fixeed many issue when run on solaris server daq
This commit is contained in:
parent
6be0b9400f
commit
171561f823
|
@ -521,7 +521,7 @@ int Digitizer2Gen::ReadData(){
|
||||||
return CAEN_FELib_UNKNOWN;
|
return CAEN_FELib_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
evt->traceZero = false;
|
evt->isTraceAllZero = false;
|
||||||
|
|
||||||
if( ret != CAEN_FELib_Success) {
|
if( ret != CAEN_FELib_Success) {
|
||||||
//ErrorMsg("ReadData()");
|
//ErrorMsg("ReadData()");
|
||||||
|
|
14
Event.h
14
Event.h
|
@ -5,7 +5,7 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define MaxTraceLenght 2048
|
#define MaxTraceLenght 8100
|
||||||
|
|
||||||
class Event {
|
class Event {
|
||||||
public:
|
public:
|
||||||
|
@ -36,7 +36,7 @@ class Event {
|
||||||
size_t dataSize; /// number of byte of the data, size/8 = word [64 bits]
|
size_t dataSize; /// number of byte of the data, size/8 = word [64 bits]
|
||||||
uint32_t n_events;
|
uint32_t n_events;
|
||||||
|
|
||||||
bool traceZero;
|
bool isTraceAllZero;
|
||||||
|
|
||||||
Event(){
|
Event(){
|
||||||
Init();
|
Init();
|
||||||
|
@ -74,7 +74,7 @@ class Event {
|
||||||
digital_probes_type[3] = 0xFF;
|
digital_probes_type[3] = 0xFF;
|
||||||
data = NULL;
|
data = NULL;
|
||||||
|
|
||||||
traceZero = true; // indicate trace are all zero
|
isTraceAllZero = true; // indicate trace are all zero
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearMemory(){
|
void ClearMemory(){
|
||||||
|
@ -88,7 +88,7 @@ class Event {
|
||||||
if( digital_probes[2] != NULL) delete digital_probes[2];
|
if( digital_probes[2] != NULL) delete digital_probes[2];
|
||||||
if( digital_probes[3] != NULL) delete digital_probes[3];
|
if( digital_probes[3] != NULL) delete digital_probes[3];
|
||||||
|
|
||||||
traceZero = true;
|
isTraceAllZero = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDataType(unsigned int type){
|
void SetDataType(unsigned int type){
|
||||||
|
@ -106,13 +106,13 @@ class Event {
|
||||||
digital_probes[2] = new uint8_t[MaxTraceLenght];
|
digital_probes[2] = new uint8_t[MaxTraceLenght];
|
||||||
digital_probes[3] = new uint8_t[MaxTraceLenght];
|
digital_probes[3] = new uint8_t[MaxTraceLenght];
|
||||||
|
|
||||||
traceZero = true;
|
isTraceAllZero = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearTrace(){
|
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++){
|
for( int i = 0; i < MaxTraceLenght; i++){
|
||||||
analog_probes[0][i] = 0;
|
analog_probes[0][i] = 0;
|
||||||
|
@ -123,7 +123,7 @@ class Event {
|
||||||
digital_probes[2][i] = 0;
|
digital_probes[2][i] = 0;
|
||||||
digital_probes[3][i] = 0;
|
digital_probes[3][i] = 0;
|
||||||
}
|
}
|
||||||
traceZero = true;
|
isTraceAllZero = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintEnergyTimeStamp(){
|
void PrintEnergyTimeStamp(){
|
||||||
|
|
|
@ -32,7 +32,7 @@ bool InfluxDB::TestingConnection(){
|
||||||
std::string InfluxDB::CheckDatabases(){
|
std::string InfluxDB::CheckDatabases(){
|
||||||
curl_easy_setopt(curl, CURLOPT_POST, 1);
|
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";
|
std::string postFields="q=Show databases";
|
||||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(postFields.length()));
|
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_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;
|
std::string postFields = "q=" + query;
|
||||||
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, static_cast<long>(postFields.length()));
|
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){
|
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);
|
curl_easy_setopt(curl, CURLOPT_POST, 1);
|
||||||
|
|
||||||
std::string postFields = "q=CREATE DATABASE " + databaseName;
|
std::string postFields = "q=CREATE DATABASE " + databaseName;
|
||||||
|
@ -143,7 +143,7 @@ void InfluxDB::Execute(){
|
||||||
try{
|
try{
|
||||||
respond = curl_easy_perform(curl);
|
respond = curl_easy_perform(curl);
|
||||||
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &respondCode);
|
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");
|
if( respond != CURLE_OK) printf("############# InfluxDB::Execute fail\n");
|
||||||
} catch (std::exception& e){ // in case of unexpected error
|
} catch (std::exception& e){ // in case of unexpected error
|
||||||
printf("%s\n", e.what());
|
printf("%s\n", e.what());
|
||||||
|
|
|
@ -249,6 +249,7 @@ MainWindow::~MainWindow(){
|
||||||
if( digi ){
|
if( digi ){
|
||||||
for( int i = 0; i < nDigi ; i++){
|
for( int i = 0; i < nDigi ; i++){
|
||||||
if( digi[i]->IsDummy()) continue;
|
if( digi[i]->IsDummy()) continue;
|
||||||
|
//printf("=== %d %p\n", i, readDataThread[i]);
|
||||||
if( readDataThread[i]->isRunning()) StopACQ();
|
if( readDataThread[i]->isRunning()) StopACQ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -478,14 +479,6 @@ void MainWindow::OpenDigitizers(){
|
||||||
if(digi[i]->IsConnected()){
|
if(digi[i]->IsConnected()){
|
||||||
|
|
||||||
LogMsg("Opened digitizer : <font style=\"color:red;\">" + QString::number(digi[i]->GetSerialNumber()) + "</font>");
|
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);
|
readDataThread[i] = new ReadDataThread(digi[i], this);
|
||||||
connect(readDataThread[i], &ReadDataThread::sendMsg, this, &MainWindow::LogMsg);
|
connect(readDataThread[i], &ReadDataThread::sendMsg, this, &MainWindow::LogMsg);
|
||||||
|
@ -495,19 +488,31 @@ void MainWindow::OpenDigitizers(){
|
||||||
//*------ search for settings_XXXX.dat
|
//*------ search for settings_XXXX.dat
|
||||||
QString settingFile = analysisPath + "/settings_" + QString::number(digi[i]->GetSerialNumber()) + ".dat";
|
QString settingFile = analysisPath + "/settings_" + QString::number(digi[i]->GetSerialNumber()) + ".dat";
|
||||||
if( digi[i]->LoadSettingsFromFile( settingFile.toStdString().c_str() ) ){
|
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());
|
digi[i]->SetSettingFileName(settingFile.toStdString());
|
||||||
|
LogMsg("done settings.");
|
||||||
}else{
|
}else{
|
||||||
LogMsg("<font style=\"color: red;\">Unable to found setting file <b>" + settingFile + "</b>. </font>");
|
LogMsg("<font style=\"color: red;\">Unable to found setting file <b>" + settingFile + "</b>. </font>");
|
||||||
digi[i]->SetSettingFileName("");
|
digi[i]->SetSettingFileName("");
|
||||||
LogMsg("Reset digitizer and use deault setting");
|
LogMsg("Reset digitizer.");
|
||||||
digi[i]->Reset();
|
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();
|
digi[i]->ReadAllSettings();
|
||||||
|
|
||||||
SetUpScalar();
|
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);
|
bnOpenScalar->setEnabled(true);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
@ -529,10 +534,18 @@ void MainWindow::CloseDigitizers(){
|
||||||
|
|
||||||
scalar->close();
|
scalar->close();
|
||||||
DeleteTriggerLineEdit(); // this use digi->GetNChannels();
|
DeleteTriggerLineEdit(); // this use digi->GetNChannels();
|
||||||
|
|
||||||
|
if( scope != NULL ){
|
||||||
|
scope->close();
|
||||||
|
delete scope;
|
||||||
|
scope = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
digiSetting->close();
|
if( digiSetting != NULL ){
|
||||||
delete digiSetting;
|
digiSetting->close();
|
||||||
digiSetting = NULL;
|
delete digiSetting;
|
||||||
|
digiSetting = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for( int i = 0; i < nDigi; i++){
|
for( int i = 0; i < nDigi; i++){
|
||||||
if( digi[i] == NULL) return;
|
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>");
|
LogMsg("<font style=\"color : green;\"> InfluxDB URL (<b>"+ DatabaseIP + "</b>) is Valid </font>");
|
||||||
|
|
||||||
//==== chck database exist
|
//==== chck database exist
|
||||||
|
LogMsg("List of database:");
|
||||||
std::vector<std::string> databaseList = influx->GetDatabaseList();
|
std::vector<std::string> databaseList = influx->GetDatabaseList();
|
||||||
bool foundDatabase = false;
|
bool foundDatabase = false;
|
||||||
for( int i = 0; i < (int) databaseList.size(); i++){
|
for( int i = 0; i < (int) databaseList.size(); i++){
|
||||||
if( databaseList[i] == DatabaseName.toStdString() ) foundDatabase = true;
|
if( databaseList[i] == DatabaseName.toStdString() ) foundDatabase = true;
|
||||||
|
LogMsg(QString::number(i) + "|" + QString::fromStdString(databaseList[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if( foundDatabase ){
|
if( foundDatabase ){
|
||||||
|
@ -1496,15 +1511,18 @@ void MainWindow::WriteElog(QString htmlText, QString subject, QString category,
|
||||||
if( elogID < 0 ) return;
|
if( elogID < 0 ) return;
|
||||||
if( expName == "" ) 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;
|
QStringList arg;
|
||||||
arg << "-h" << ElogIP << "-p" << "8080" << "-l" << expName << "-u" << "GeneralFSU" << "fsuphysics-888"
|
arg << "-h" << ElogIP << "-p" << "8080" << "-l" << expName << "-u" << "GeneralSOLARIS" << "solaris"
|
||||||
<< "-a" << "Author=GeneralFSU" ;
|
<< "-a" << "Author=\'General SOLARIS\'" ;
|
||||||
if( runNumber > 0 ) arg << "-a" << "Run=" + QString::number(runNumber);
|
if( runNumber > 0 ) arg << "-a" << "Run=" + QString::number(runNumber);
|
||||||
if( category != "" ) arg << "-a" << "Category=" + category;
|
if( category != "" ) arg << "-a" << "Category=" + category;
|
||||||
|
|
||||||
arg << "-a" << "Subject=" + subject
|
arg << "-a" << "Subject=" + subject
|
||||||
<< "-n " << "2" << htmlText ;
|
<< "-n " << "2" << htmlText ;
|
||||||
|
|
||||||
QProcess elogBash(this);
|
QProcess elogBash(this);
|
||||||
elogBash.start("elog", arg);
|
elogBash.start("elog", arg);
|
||||||
elogBash.waitForFinished();
|
elogBash.waitForFinished();
|
||||||
|
@ -1527,7 +1545,7 @@ void MainWindow::AppendElog(QString appendHtmlText, int screenID){
|
||||||
QProcess elogBash(this);
|
QProcess elogBash(this);
|
||||||
|
|
||||||
QStringList arg;
|
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
|
//retrevie the elog
|
||||||
elogBash.start("elog", arg);
|
elogBash.start("elog", arg);
|
||||||
|
@ -1544,7 +1562,7 @@ void MainWindow::AppendElog(QString appendHtmlText, int screenID){
|
||||||
QString originalHtml = output.mid(index + separator.length());
|
QString originalHtml = output.mid(index + separator.length());
|
||||||
|
|
||||||
arg.clear();
|
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;
|
<< "-n" << "2" << originalHtml + "<br>" + appendHtmlText;
|
||||||
|
|
||||||
if( screenID >= 0) {
|
if( screenID >= 0) {
|
||||||
|
|
2
makeTest
2
makeTest
|
@ -6,9 +6,9 @@ CURLLIBS = -lcurl
|
||||||
OBJS= ClassDigitizer2Gen.o influxdb.o
|
OBJS= ClassDigitizer2Gen.o influxdb.o
|
||||||
|
|
||||||
#
|
#
|
||||||
ALL = test windowID
|
|
||||||
#
|
#
|
||||||
################################################################
|
################################################################
|
||||||
|
all : test windowID
|
||||||
|
|
||||||
#
|
#
|
||||||
test : test.cpp ClassDigitizer2Gen.o influxdb.o
|
test : test.cpp ClassDigitizer2Gen.o influxdb.o
|
||||||
|
|
27
scope.cpp
27
scope.cpp
|
@ -6,6 +6,8 @@
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
|
#define MaxDisplayTraceDataLength 2000 //data point,
|
||||||
|
|
||||||
Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow *parent) : QMainWindow(parent){
|
Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDataThread, QMainWindow *parent) : QMainWindow(parent){
|
||||||
this->digi = digi;
|
this->digi = digi;
|
||||||
this->nDigi = nDigi;
|
this->nDigi = nDigi;
|
||||||
|
@ -333,6 +335,11 @@ Scope::Scope(Digitizer2Gen **digi, unsigned int nDigi, ReadDataThread ** readDat
|
||||||
lbinfo->setAlignment(Qt::AlignRight);
|
lbinfo->setAlignment(Qt::AlignRight);
|
||||||
layout->addWidget(lbinfo, rowID, 5);
|
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
|
//------------ close button
|
||||||
rowID ++;
|
rowID ++;
|
||||||
bnScopeStart = new QPushButton("Start", this);
|
bnScopeStart = new QPushButton("Start", this);
|
||||||
|
@ -483,9 +490,6 @@ void Scope::UpdateScope(){
|
||||||
emit UpdateScalar();
|
emit UpdateScalar();
|
||||||
|
|
||||||
if( digi ){
|
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();
|
digiMTX.lock();
|
||||||
std::string time = digi[iDigi]->ReadValue(DIGIPARA::CH::ChannelRealtime, ch); // for refreashing SelfTrgRate and SavedCount
|
std::string time = digi[iDigi]->ReadValue(DIGIPARA::CH::ChannelRealtime, ch); // for refreashing SelfTrgRate and SavedCount
|
||||||
|
@ -496,16 +500,21 @@ void Scope::UpdateScope(){
|
||||||
return;
|
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++) {
|
||||||
for( int j = 0; j < 2; j++) dataTrace[j]->append(sample2ns * i, digi[iDigi]->evt->analog_probes[j][i]);
|
QVector<QPointF> points;
|
||||||
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( 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();
|
digiMTX.unlock();
|
||||||
|
|
||||||
plot->axes(Qt::Horizontal).first()->setRange(0, sample2ns * traceLength);
|
plot->axes(Qt::Horizontal).first()->setRange(0, sample2ns * traceLength);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user