From e3d5f52aa2314eb752fb1fb394c3a1268f4945c8 Mon Sep 17 00:00:00 2001 From: qinliqing Date: Mon, 14 Apr 2025 18:20:52 +0200 Subject: [PATCH] bug fix; cal/raw display --- hit2023v2_RAWCAL/datareceiver.h | 6 +++--- hit2023v2_RAWCAL/display.cpp | 9 +++++++++ hit2023v2_RAWCAL/display.h | 9 ++++++++- hit2023v2_RAWCAL/display.ui | 13 ++++++++++--- hit2023v2_RAWCAL/displayserver.cpp | 14 +++++++------- hit2023v2_RAWCAL/displayserver.h | 2 +- 6 files changed, 38 insertions(+), 15 deletions(-) diff --git a/hit2023v2_RAWCAL/datareceiver.h b/hit2023v2_RAWCAL/datareceiver.h index 7cd068c..f564845 100644 --- a/hit2023v2_RAWCAL/datareceiver.h +++ b/hit2023v2_RAWCAL/datareceiver.h @@ -60,8 +60,8 @@ public: struct SensorData { unsigned short raw1; // First 16-bit unsigned short unsigned short raw2; // Second 16-bit unsigned short - short cal1; // First 16-bit signed short - short cal2; // Second 16-bit signed short + signed short cal1; // First 16-bit signed short + signed short cal2; // Second 16-bit signed short }; SensorData* sensorData; // Renamed from sensor_data @@ -126,7 +126,7 @@ public: int frameRate = 0; int devNr = 0; - int sensorsPerBoard = 2; + int sensorsPerBoard = 5; DataBuffer dataBuffer; diff --git a/hit2023v2_RAWCAL/display.cpp b/hit2023v2_RAWCAL/display.cpp index a077365..3c6902b 100644 --- a/hit2023v2_RAWCAL/display.cpp +++ b/hit2023v2_RAWCAL/display.cpp @@ -39,6 +39,10 @@ BPMDisplay::BPMDisplay(QWidget *parent) : // Gray out the buttons when they are disabled ui->pushButton_savecalib->setStyleSheet(expertModeEnabled ? "" : "background-color: gray;"); + // Check if checkBox_toggleRawCal exists in UI + if (ui->checkBox_toggleRawCal) { + connect(ui->checkBox_toggleRawCal, &QCheckBox::stateChanged, this, &BPMDisplay::onDataToggleChanged); + } } @@ -465,3 +469,8 @@ void BPMDisplay::updateStatus(unsigned short value) { ui->lcdNumber_status->display((value)); } + +void BPMDisplay::onDataToggleChanged(int state) { + showCalibrated = (state == Qt::Checked); + plot(); +} diff --git a/hit2023v2_RAWCAL/display.h b/hit2023v2_RAWCAL/display.h index 923f1f4..f54ef6e 100644 --- a/hit2023v2_RAWCAL/display.h +++ b/hit2023v2_RAWCAL/display.h @@ -29,8 +29,9 @@ public: void setTitle(QString title); - QVector buffer; + QVector buffer; //unsigned short raw; signed short cal QVector rmsbuffer; + bool showCalibrated = false; public slots: @@ -47,6 +48,7 @@ public slots: void updateRms(unsigned short value); void updateMax(unsigned short value); void updateStatus(unsigned short value); + void onDataToggleChanged(int state); @@ -57,11 +59,16 @@ protected: QVector dataRMS; + private: Ui::display *ui; QRadioButton *radioButtonFixedScale; // Pointer to the Fixed Scale radio button QRadioButton *radioButtonAutoscale; // Pointer to the Autoscale radio button QButtonGroup *buttonGroup; + + QCheckBox *checkBoxToggleRawCal; //for show raw or cal data + + QMap> backgroundDataMap; // Map to store background data for each plane bool subtractBackground = false; // Flag to track if background subtraction is enabled diff --git a/hit2023v2_RAWCAL/display.ui b/hit2023v2_RAWCAL/display.ui index bb11732..b529ff2 100644 --- a/hit2023v2_RAWCAL/display.ui +++ b/hit2023v2_RAWCAL/display.ui @@ -167,10 +167,9 @@ - + - expert -mode + Show caled @@ -182,6 +181,14 @@ calibration + + + + expert +mode + + + diff --git a/hit2023v2_RAWCAL/displayserver.cpp b/hit2023v2_RAWCAL/displayserver.cpp index 95ae6a2..863a236 100644 --- a/hit2023v2_RAWCAL/displayserver.cpp +++ b/hit2023v2_RAWCAL/displayserver.cpp @@ -118,20 +118,20 @@ void DisplayServer::plot() if (nr_channels > lastFrame[dev_id].buffer_size) nr_channels = lastFrame[dev_id].buffer_size; //check if there's really some data in the buffer //WARNING!!! Device order is not yet implemented!!! (probably) - for (int i = 0; i < int(nr_channels/2); i++){ //should be 32 + for (int i = 0; i < planeConfig[plane]->nr_sensors * 64 / 2 ; i++){ //should be 32 //displays[plane]->buffer[current_base+i] = lastFrame[dev_id].sensor_data[i]; //old code // Use RAW values (index 2*i) or CAL values (index 2*i + 1) rawValue = lastFrame[dev_id].sensorData[i]; // Get int(RAW1+RAW2) - std::cerr << rawValue.raw1 << " " << rawValue.raw2 << " " <showCalibrated) //RAW1, RAW2, ... { - displays[plane]->buffer[current_base + i] = static_cast(rawValue.raw1); - displays[plane]->buffer[current_base + i + 1] = static_cast(rawValue.raw2); + displays[plane]->buffer[current_base + 2*i] = static_cast(rawValue.raw1); + displays[plane]->buffer[current_base + 2*i + 1] = static_cast(rawValue.raw2); } else //CAL1, CAL2 { - displays[plane]->buffer[current_base + i] = static_cast(rawValue.cal1); - displays[plane]->buffer[current_base + i + 1] = static_cast(rawValue.cal2); + displays[plane]->buffer[current_base + 2*i] = static_cast(rawValue.cal1); + displays[plane]->buffer[current_base + 2*i + 1] = static_cast(rawValue.cal2); } diff --git a/hit2023v2_RAWCAL/displayserver.h b/hit2023v2_RAWCAL/displayserver.h index 52c47cc..2b452fa 100644 --- a/hit2023v2_RAWCAL/displayserver.h +++ b/hit2023v2_RAWCAL/displayserver.h @@ -32,7 +32,7 @@ public: void unsetup(); // New boolean flag to control display of RAW or CAL data - bool showRawData = true; // Default is to show RAW data + bool showRawData = true; // Default is to show RAW data // use displays[plane]->showCalibrated instead signals: public slots: