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) { bool Digitizer::GetInputChannelOnOff(unsigned ch) {
DebugPrint("%s", "Digitizer"); // DebugPrint("%s", "Digitizer");
if( softwareDisable ) return false; if( softwareDisable ) return false;
// regChannelMask = GetSettingFromMemory(DPP::RegChannelEnableMask);
regChannelMask = GetSettingFromMemory(DPP::RegChannelEnableMask);
if( isInputChEqRegCh ) return (regChannelMask & ( 1 << ch) ); if( isInputChEqRegCh ) return (regChannelMask & ( 1 << ch) );
int grpID = ch/8; //may change for not grouped in 8; 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); uint32_t bitmask = (uint(pow(2, bitLength)-1) << bitSmallestPos);
int tempCh = ch; int tempCh = ch;
if (ch < 0 && address < 0x8000 ) tempCh = 0; /// take ch-0 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); ///printf("bit : 0x%X, bitmask : 0x%X \n", bit, bitmask);
bit = (bit & ~bitmask) | (bitValue << bitSmallestPos); bit = (bit & ~bitmask) | (bitValue << bitSmallestPos);
///printf("bit : 0x%X, ch : %d \n", bit, ch); ///printf("bit : 0x%X, ch : %d \n", bit, ch);

View File

@ -109,9 +109,10 @@ class Digitizer{
Data * GetData() const {return data;} Data * GetData() const {return data;}
uint32_t GetACQStatusFromMemory() const {return acqStatus;} uint32_t GetACQStatusFromMemory() const {return acqStatus;}
void ReadAndPrintACQStatue(); void ReadAndPrintACQStatue();
void ReadACQStatus() { void ReadACQStatus() { // Only use when ACQ is running;
// printf("%s\n", __func__); // 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); unsigned int CalByteForBuffer(bool verbose = false);

View File

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

View File

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

View File

@ -20,7 +20,7 @@ class Histogram2D : public QCustomPlot{
public: 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){ 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 i = 0; i < 3; i ++ ){
for( int j = 0; j < 3; j ++ ){ for( int j = 0; j < 3; j ++ ){
box[i][j] = nullptr; 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){ inline void Histogram2D::Rebin(int xbin, double xmin, double xmax, int ybin, double ymin, double ymax){
DebugPrint("%s", "Histogram2D"); // DebugPrint("%s", "Histogram2D");
xMin = xmin; xMin = xmin;
xMax = xmax; xMax = xmax;
yMin = ymin; yMin = ymin;

View File

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