slightly reduce function call

This commit is contained in:
Ryan Tang 2024-03-22 17:20:07 -04:00
parent a0f9c4d727
commit 1af2bd4ce9
6 changed files with 29 additions and 29 deletions

View File

@ -297,11 +297,9 @@ void Digitizer::SetRegChannelMask(uint32_t mask){
}
bool Digitizer::GetInputChannelOnOff(unsigned ch) {
DebugPrint("%s", "Digitizer");
// DebugPrint("%s", "Digitizer");
if( softwareDisable ) return false;
regChannelMask = GetSettingFromMemory(DPP::RegChannelEnableMask);
// regChannelMask = GetSettingFromMemory(DPP::RegChannelEnableMask);
if( isInputChEqRegCh ) return (regChannelMask & ( 1 << ch) );
int grpID = ch/8; //may change for not grouped in 8;
@ -1324,7 +1322,8 @@ void Digitizer::SetBits(Reg address, unsigned int bitValue, unsigned int bitLeng
uint32_t bitmask = (uint(pow(2, bitLength)-1) << bitSmallestPos);
int tempCh = ch;
if (ch < 0 && address < 0x8000 ) tempCh = 0; /// take ch-0
bit = ReadRegister(address, tempCh);
//bit = ReadRegister(address, tempCh);
bit = GetSettingFromMemory(address, tempCh);
///printf("bit : 0x%X, bitmask : 0x%X \n", bit, bitmask);
bit = (bit & ~bitmask) | (bitValue << bitSmallestPos);
///printf("bit : 0x%X, ch : %d \n", bit, ch);

View File

@ -109,9 +109,10 @@ class Digitizer{
Data * GetData() const {return data;}
uint32_t GetACQStatusFromMemory() const {return acqStatus;}
void ReadAndPrintACQStatue();
void ReadACQStatus() {
void ReadACQStatus() { // Only use when ACQ is running;
// printf("%s\n", __func__);
acqStatus = ReadRegister(DPP::AcquisitionStatus_R);
//acqStatus = ReadRegister(DPP::AcquisitionStatus_R);
CAEN_DGTZ_ReadRegister(handle, DPP::AcquisitionStatus_R, &acqStatus);
}
unsigned int CalByteForBuffer(bool verbose = false);

View File

@ -4,7 +4,7 @@
#include <regex>
InfluxDB::InfluxDB(){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
curl = curl_easy_init();
databaseIP = "";
respondCode = 0;
@ -17,7 +17,7 @@ InfluxDB::InfluxDB(){
}
InfluxDB::InfluxDB(std::string url, bool verbose){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
curl = curl_easy_init();
if( verbose) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
SetURL(url);
@ -31,13 +31,13 @@ InfluxDB::InfluxDB(std::string url, bool verbose){
}
InfluxDB::~InfluxDB(){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
void InfluxDB::SetURL(std::string url){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
// check the last char of url is "/"
if( url.back() != '/') {
this->databaseIP = url + "/";
@ -47,14 +47,14 @@ void InfluxDB::SetURL(std::string url){
}
void InfluxDB::SetToken(std::string token){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
this->token = token;
headers = curl_slist_append(headers, "Accept: application/csv");
if( !token.empty() ) headers = curl_slist_append(headers, ("Authorization: Token " + token).c_str());
}
bool InfluxDB::TestingConnection(bool debug){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
CheckInfluxVersion(debug);
if( respond != CURLE_OK ) return false;
connectionOK = true;
@ -62,7 +62,7 @@ bool InfluxDB::TestingConnection(bool debug){
}
std::string InfluxDB::CheckInfluxVersion(bool debug){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
curl_easy_setopt(curl, CURLOPT_URL, (databaseIP + "ping").c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, NULL);
curl_easy_setopt(curl, CURLOPT_HEADER, 1);
@ -97,7 +97,7 @@ std::string InfluxDB::CheckInfluxVersion(bool debug){
}
std::string InfluxDB::CheckDatabases(){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
if( ! connectionOK ) return "no connection. try TestConnection() again.";
if( influxVersion == 2 && token.empty() ) return "token no provided, abort.";
@ -175,7 +175,7 @@ std::string InfluxDB::CheckDatabases(){
}
void InfluxDB::PrintDataBaseList(){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
for( size_t i = 0; i < databaseList.size(); i++){
printf("%2ld| %s\n", i, databaseList[i].c_str());
}
@ -183,7 +183,7 @@ void InfluxDB::PrintDataBaseList(){
}
std::string InfluxDB::Query(std::string databaseName, std::string influxQL_query){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
if( ! connectionOK ) return "no connection. try TestConnection() again.";
if( influxVersion == 2 && token.empty() ) return "token no provided, abort.";
@ -209,7 +209,7 @@ std::string InfluxDB::Query(std::string databaseName, std::string influxQL_query
}
void InfluxDB::CreateDatabase(std::string databaseName){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
if( ! connectionOK ) return ;
if( influxVersion == 2 && token.empty() ) return;
@ -226,25 +226,25 @@ void InfluxDB::CreateDatabase(std::string databaseName){
}
void InfluxDB::AddDataPoint(std::string fullString){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
// printf(" InfluxDB::%s |%s| \n", __func__, fullString.c_str());
dataPoints += fullString + "\n";
}
void InfluxDB::ClearDataPointsBuffer(){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
// printf(" InfluxDB::%s \n", __func__);
dataPoints = "";
}
void InfluxDB::PrintDataPoints(){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
// printf(" InfluxDB::%s \n", __func__);
printf("%s\n", dataPoints.c_str());
}
void InfluxDB::WriteData(std::string databaseName){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
if( ! connectionOK ) return ;
if( influxVersion == 2 && token.empty() ) return;
@ -262,7 +262,7 @@ void InfluxDB::WriteData(std::string databaseName){
}
void InfluxDB::Execute(){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
// printf(" InfluxDB::%s \n", __func__);
try{
respond = curl_easy_perform(curl);
@ -276,7 +276,7 @@ void InfluxDB::Execute(){
}
size_t InfluxDB::WriteCallBack(char *contents, size_t size, size_t nmemb, void *userp){
DebugPrint("%s", "InfluxDB")
DebugPrint("%s", "InfluxDB");
// printf(" InfluxDB::%s \n", __func__);
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;

View File

@ -12,7 +12,7 @@ class Histogram1D : public QCustomPlot{
Q_OBJECT
public:
Histogram1D(QString title, QString xLabel, int xbin, double xmin, double xmax, QWidget * parent = nullptr) : QCustomPlot(parent){
DebugPrint("%s", "Histogram1D");
// DebugPrint("%s", "Histogram1D");
isLogY = false;
for( int i = 0; i < 3; i ++) txt[i] = nullptr;
@ -237,7 +237,7 @@ public:
void SetXTitle(QString xTitle) { xAxis->setLabel(xTitle); }
void Rebin(int xbin, double xmin, double xmax){
DebugPrint("%s", "Histogram1D");
// DebugPrint("%s", "Histogram1D");
xMin = xmin;
xMax = xmax;
xBin = xbin;

View File

@ -20,7 +20,7 @@ class Histogram2D : public QCustomPlot{
public:
Histogram2D(QString title, QString xLabel, QString yLabel, int xbin, double xmin, double xmax, int ybin, double ymin, double ymax, QWidget * parent = nullptr) : QCustomPlot(parent){
DebugPrint("%s", "Histogram2D");
// DebugPrint("%s", "Histogram2D");
for( int i = 0; i < 3; i ++ ){
for( int j = 0; j < 3; j ++ ){
box[i][j] = nullptr;
@ -297,7 +297,7 @@ inline void Histogram2D::Fill(double x, double y){
}
inline void Histogram2D::Rebin(int xbin, double xmin, double xmax, int ybin, double ymin, double ymax){
DebugPrint("%s", "Histogram2D");
// DebugPrint("%s", "Histogram2D");
xMin = xmin;
xMax = xmax;
yMin = ymin;

View File

@ -202,7 +202,7 @@ void SingleSpectra::ChangeHistView(){
}
void SingleSpectra::FillHistograms(){
DebugPrint("%s", "SingleSpectra");
// DebugPrint("%s", "SingleSpectra");
if( !fillHistograms ) return;
unsigned short maxFillTimePerDigi = maxFillTimeinMilliSec/nDigi;