fix bug on Influx when expName is Empty

This commit is contained in:
splitPoleDAQ 2023-11-17 12:06:21 -05:00
parent e32cde9b4b
commit 0e28cfcd12
3 changed files with 21 additions and 15 deletions

View File

@ -1089,7 +1089,7 @@ void MainWindow::StartACQ(){
{//^=== elog and database
if( influx ){
influx->AddDataPoint("RunID value=" + std::to_string(runID));
if( elogName != "" ) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=1");
if( !elogName.isEmpty() ) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=1");
influx->WriteData(dataBaseName.toStdString());
influx->ClearDataPointsBuffer();
}
@ -1169,7 +1169,7 @@ void MainWindow::StopACQ(){
{//^=== elog and database
if( influx && elogName != "" ) {
influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=0");
if( !elogName.isEmpty() ) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=0");
influx->WriteData(dataBaseName.toStdString());
influx->ClearDataPointsBuffer();
}
@ -1493,10 +1493,10 @@ void MainWindow::OpenScope(){
if( scope ) {
if( onOff ) {
lbScalarACQStatus->setText("<font style=\"color: green;\"><b>ACQ On</b></font>");
if( influx ) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=1");
if( influx && !elogName.isEmpty()) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=1");
}else{
lbScalarACQStatus->setText("<font style=\"color: red;\"><b>ACQ Off</b></font>");
if( influx ) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=0");
if( influx && !elogName.isEmpty()) influx->AddDataPoint("SavingData,ExpName=" + elogName.toStdString() + " value=0");
}
if( influx ){
influx->WriteData(dataBaseName.toStdString());

View File

@ -363,29 +363,30 @@ void Scope::StartScope(){
//TODO set other channel to be no trace;
emit UpdateOtherPanels();
for( unsigned int iDigi = 0; iDigi < nDigi; iDigi ++){
for( int iDigi = (int)nDigi-1 ; iDigi >= 0; iDigi --){
traceOn[iDigi] = digi[iDigi]->IsRecordTrace(); //remember setting
SendLogMsg("Digi-" + QString::number(digi[iDigi]->GetSerialNumber()) + " is starting ACQ." );
digi[iDigi]->WriteRegister(DPP::SoftwareClear_W, 1);
digi[iDigi]->GetData()->ClearData();
digi[iDigi]->SetBits(DPP::BoardConfiguration, DPP::Bit_BoardConfig::RecordTrace, 1, -1);
readDataThread[iDigi]->SetScopeMode(true);
readDataThread[iDigi]->SetSaveData(false);
digi[iDigi]->StartACQ();
// printf("----- readDataThread running ? %d.\n", readDataThread[iDigi]->isRunning());
if( readDataThread[iDigi]->isRunning() ){
readDataThread[iDigi]->quit();
readDataThread[iDigi]->wait();
}
readDataThread[iDigi]->SetScopeMode(true);
readDataThread[iDigi]->SetSaveData(false);
// if( readDataThread[iDigi]->isRunning() ){
// readDataThread[iDigi]->quit();
// readDataThread[iDigi]->wait();
// }
readDataThread[iDigi]->start();
// printf("----- readDataThread running ? %d.\n", readDataThread[iDigi]->isRunning());
}
printf("=========================== 1\n");
updateTraceThread->start();
updateScalarThread->start();
printf("=========================== 2\n");
bnScopeStart->setEnabled(false);
bnScopeStart->setStyleSheet("");
@ -393,7 +394,6 @@ void Scope::StartScope(){
bnScopeStop->setStyleSheet("background-color: red;");
EnableControl(false);
printf("=========================== 3\n");
TellACQOnOff(true);

View File

@ -117,18 +117,22 @@ void InfluxDB::CreateDatabase(std::string databaseName){
}
void InfluxDB::AddDataPoint(std::string fullString){
// printf(" InfluxDB::%s |%s| \n", __func__, fullString.c_str());
dataPoints += fullString + "\n";
}
void InfluxDB::ClearDataPointsBuffer(){
// printf(" InfluxDB::%s \n", __func__);
dataPoints = "";
}
void InfluxDB::PrintDataPoints(){
// printf(" InfluxDB::%s \n", __func__);
printf("%s\n", dataPoints.c_str());
}
void InfluxDB::WriteData(std::string databaseName){
// printf(" InfluxDB::%s \n", __func__);
if( dataPoints.length() == 0 ) return;
//printf("|%s|\n", (databaseIP + "write?db=" + databaseName).c_str());
curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "write?db=" + databaseName).c_str());
@ -140,6 +144,7 @@ void InfluxDB::WriteData(std::string databaseName){
void InfluxDB::Execute(){
// printf(" InfluxDB::%s \n", __func__);
try{
respond = curl_easy_perform(curl);
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &respondCode);
@ -152,6 +157,7 @@ void InfluxDB::Execute(){
}
size_t InfluxDB::WriteCallBack(char *contents, size_t size, size_t nmemb, void *userp){
// printf(" InfluxDB::%s \n", __func__);
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}