From a84c30cb1a581f14f93a97882829e4cae312a458 Mon Sep 17 00:00:00 2001 From: Blake Leverington Date: Fri, 19 Jul 2024 14:39:26 +0200 Subject: [PATCH] added new command to test setting threholds from the command line --- hit2023v2_RMS/dev_commands.h | 4 ++++ hit2023v2_RMS/device.cpp | 15 +++++++++++++++ hit2023v2_RMS/device.h | 5 ++++- hit2023v2_RMS/dialogdevices.cpp | 22 +++++++++++++++++++++- 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/hit2023v2_RMS/dev_commands.h b/hit2023v2_RMS/dev_commands.h index de63269..4154215 100644 --- a/hit2023v2_RMS/dev_commands.h +++ b/hit2023v2_RMS/dev_commands.h @@ -110,6 +110,10 @@ //D:[] D: [(Readout of 5 ADC channels as 32-bit integers)] //Slow control snapshot - read all channels of ADC +#define COMMAND_SET_CLUSTER_THRESHOLD 0x4001 + //L: ? + //D: [] + //Send 8 bit beam cluster selection threshold // ***DATA TRANSFER - SOCKET 1!!!!*** diff --git a/hit2023v2_RMS/device.cpp b/hit2023v2_RMS/device.cpp index 3ede978..8a91598 100644 --- a/hit2023v2_RMS/device.cpp +++ b/hit2023v2_RMS/device.cpp @@ -109,6 +109,7 @@ void Device::configure(DeviceConfig &cfg) ctrlSetMasterDelay(deviceConfig.master_delay); ctrlSetSlaveDelay(deviceConfig.slave_delay); ctrlSetGain(deviceConfig.gain); + ctrlSetClusterThreshold(deviceConfig.threshold); ctrlConfigBunch(deviceConfig.dma_bunch, deviceConfig.eth_bunch); ctrlConfigPeer(ipshort, DEV_BASE_DATA_PORT+ deviceConfig.device_id); } @@ -480,3 +481,17 @@ int Device::ctrlConfigBunch(int dma, int eth) else return queryCtrl(COMMAND_DAQ_DISABLE, txdata, rxdata);*/ } + +int Device::ctrlSetClusterThreshold(int threshold) +{ + QVector rxdata; + QVector txdata; + txdata.append((unsigned short)threshold); + + if (threshold) + return queryCtrl(COMMAND_SET_CLUSTER_THRESHOLD, txdata, rxdata); + else + return queryCtrl(COMMAND_SET_CLUSTER_THRESHOLD, txdata, rxdata); +} + +} diff --git a/hit2023v2_RMS/device.h b/hit2023v2_RMS/device.h index b328278..9614317 100644 --- a/hit2023v2_RMS/device.h +++ b/hit2023v2_RMS/device.h @@ -34,7 +34,9 @@ public: int gain; //0 (low) or 1 (high); TO BE DONE int dma_bunch; int eth_bunch; + int threshold; int max_sensors() + { switch(hardware_ver) { @@ -47,7 +49,7 @@ public: int nr_channels() {return 64*nr_sensors;} DeviceConfig() : own_ip{10,0,7,1}, device_ip{10,0,7,2}, device_id{0}, hardware_ver{0}, master{1}, plane{0}, position{0}, nr_sensors{0}, - period{65535}, tint{1}, master_delay{1}, slave_delay{1}, gain{0}, dma_bunch{1}, eth_bunch{1} {} + period{65535}, tint{1}, master_delay{1}, slave_delay{1}, gain{0}, dma_bunch{1}, eth_bunch{1}, threshold{10} {} }; @@ -100,6 +102,7 @@ protected: int ctrlConfigBunch(int dma, int eth); int ctrlSetMasterDelay(int tint); int ctrlSetSlaveDelay(int tint); + int ctrlSetClusterThreshold(int threshold); protected slots: void onConnected(); void onSocketError(QAbstractSocket::SocketError socketError); diff --git a/hit2023v2_RMS/dialogdevices.cpp b/hit2023v2_RMS/dialogdevices.cpp index f774e53..ef9eeab 100644 --- a/hit2023v2_RMS/dialogdevices.cpp +++ b/hit2023v2_RMS/dialogdevices.cpp @@ -28,7 +28,7 @@ void DialogDevices::showEvent(QShowEvent * event) ui->spinNrDevices->setValue(deviceSettings->value("NrDevices", int(1)).toInt()); - ui->tableDevices->setColumnCount(8); + ui->tableDevices->setColumnCount(9); QStringList h_header; h_header.append("IP Address"); h_header.append("Hardware ver."); @@ -38,6 +38,7 @@ void DialogDevices::showEvent(QShowEvent * event) h_header.append("Master"); h_header.append("Master dly"); h_header.append("Slave dly"); + h_header.append("Threshold"); ui->tableDevices->setHorizontalHeaderLabels(h_header); importSettings(); @@ -89,6 +90,8 @@ void DialogDevices::importSettings() ui->tableDevices->setItem(dev_nr, 6, newItem ); newItem = new QTableWidgetItem(deviceSettings->value("SlaveDelay","1").toString()); ui->tableDevices->setItem(dev_nr, 7, newItem ); + newItem = new QTableWidgetItem(deviceSettings->value("ClusThresh","10").toString()); + ui->tableDevices->setItem(dev_nr, 8, newItem ); } } @@ -201,6 +204,20 @@ int DialogDevices::validateAndSave() if (generated.compare(user_data) != 0) data_ok = 0; ui->tableDevices->item(dev_nr,7)->setText(generated); + + //now cluster threshold + user_data = ui->tableDevices->item(dev_nr,8)->text(); + num_value = user_data.toInt(); + if (num_value < 1) + num_value = 1; + if (num_value > 255) + num_value = 255; + generated = QString("%1").arg(num_value); + //if the strings are identical, save the value and return 1 + if (generated.compare(user_data) != 0) + data_ok = 0; + ui->tableDevices->item(dev_nr,8)->setText(generated); + } //now store the data @@ -225,6 +242,9 @@ int DialogDevices::validateAndSave() deviceSettings->setValue("Master", ui->tableDevices->item(dev_nr,5)->text()); deviceSettings->setValue("MasterDelay", ui->tableDevices->item(dev_nr,6)->text()); deviceSettings->setValue("SlaveDelay", ui->tableDevices->item(dev_nr,7)->text()); + deviceSettings->setValue("Threshold", ui->tableDevices->item(dev_nr,8)->text()); + + } return 1;