From 746d4011d262736f11d28fa8ef2fd8fa3af447a0 Mon Sep 17 00:00:00 2001
From: Jon Beniston <jon@beniston.com>
Date: Wed, 29 Mar 2023 19:20:05 +0100
Subject: [PATCH] Add UTC data time in radiometer. Fix centre frequency
 display. Support smaller bandwidths for SID measurement.

---
 .../channelrx/radioastronomy/radioastronomygui.cpp  | 13 ++++++++-----
 .../channelrx/radioastronomy/radioastronomygui.h    |  4 ++--
 .../channelrx/radioastronomy/radioastronomygui.ui   | 10 +++++++++-
 .../radioastronomy/radioastronomysettings.h         |  2 +-
 plugins/channelrx/radioastronomy/readme.md          |  5 +++--
 5 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/plugins/channelrx/radioastronomy/radioastronomygui.cpp b/plugins/channelrx/radioastronomy/radioastronomygui.cpp
index 5fc26a296..d108511db 100644
--- a/plugins/channelrx/radioastronomy/radioastronomygui.cpp
+++ b/plugins/channelrx/radioastronomy/radioastronomygui.cpp
@@ -286,6 +286,7 @@ void RadioAstronomyGUI::resizePowerTable()
     ui->powerTable->setItem(row, POWER_COL_AIR_TEMP, new QTableWidgetItem("20.0"));
     ui->powerTable->setItem(row, POWER_COL_SENSOR_1, new QTableWidgetItem("1.0000000"));
     ui->powerTable->setItem(row, POWER_COL_SENSOR_2, new QTableWidgetItem("1.0000000"));
+    ui->powerTable->setItem(row, POWER_COL_UTC, new QTableWidgetItem("15/04/2016 10:17:00"));
     ui->powerTable->resizeColumnsToContents();
     ui->powerTable->removeRow(row);
 }
@@ -633,6 +634,7 @@ void RadioAstronomyGUI::powerMeasurementReceived(FFTMeasurement *fft, bool skipC
     QTableWidgetItem* airTempItem = new QTableWidgetItem();
     QTableWidgetItem* sensor1Item = new QTableWidgetItem();
     QTableWidgetItem* sensor2Item = new QTableWidgetItem();
+    QTableWidgetItem* utcItem = new QTableWidgetItem();
 
     ui->powerTable->setItem(row, POWER_COL_DATE, dateItem);
     ui->powerTable->setItem(row, POWER_COL_TIME, timeItem);
@@ -661,12 +663,14 @@ void RadioAstronomyGUI::powerMeasurementReceived(FFTMeasurement *fft, bool skipC
     ui->powerTable->setItem(row, POWER_COL_AIR_TEMP, airTempItem);
     ui->powerTable->setItem(row, POWER_COL_SENSOR_1, sensor1Item);
     ui->powerTable->setItem(row, POWER_COL_SENSOR_2, sensor2Item);
+    ui->powerTable->setItem(row, POWER_COL_UTC, utcItem);
 
     ui->powerTable->setSortingEnabled(true);
 
     QDateTime dateTime = fft->m_dateTime;
     dateItem->setData(Qt::DisplayRole, dateTime.date());
     timeItem->setData(Qt::DisplayRole, dateTime.time());
+    utcItem->setData(Qt::DisplayRole, dateTime.toUTC());
 
     powerItem->setData(Qt::DisplayRole, fft->m_totalPower);
     powerDBItem->setData(Qt::DisplayRole, fft->m_totalPowerdBFS);
@@ -1155,7 +1159,7 @@ void RadioAstronomyGUI::updateBWLimits()
 {
     qint64 sr = (qint64) m_settings.m_sampleRate;
     int digits = ceil(log10(sr+1));
-    ui->rfBW->setValueRange(true, digits, 1000, sr);
+    ui->rfBW->setValueRange(true, digits, 100, sr);
 }
 
 void RadioAstronomyGUI::on_deltaFrequency_changed(qint64 value)
@@ -1965,7 +1969,6 @@ RadioAstronomyGUI::RadioAstronomyGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUI
     m_pluginAPI(pluginAPI),
     m_deviceUISet(deviceUISet),
     m_channelMarker(this),
-    m_deviceCenterFrequency(0),
     m_doApplySettings(true),
     m_basebandSampleRate(0),
     m_centerFrequency(0),
@@ -2059,10 +2062,10 @@ RadioAstronomyGUI::RadioAstronomyGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUI
     // Also, set bandwidth before sampleRate
     ui->rfBW->setColorMapper(ColorMapper(ColorMapper::GrayGold));
     ui->rfBW->setValue(m_settings.m_rfBandwidth);
-    ui->rfBW->setValueRange(true, 8, 1000, 99999999);
+    ui->rfBW->setValueRange(true, 8, 100, 99999999);
     ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGold));
     ui->sampleRate->setValue(m_settings.m_sampleRate);
-    ui->sampleRate->setValueRange(true, 8, 100000, 99999999);
+    ui->sampleRate->setValueRange(true, 8, 1000, 99999999);
     ui->integration->setColorMapper(ColorMapper(ColorMapper::GrayGold));
     ui->integration->setValue(m_settings.m_integration);
     ui->integration->setValueRange(true, 7, 1, 99999999);
@@ -6244,5 +6247,5 @@ void RadioAstronomyGUI::makeUIConnections()
 
 void RadioAstronomyGUI::updateAbsoluteCenterFrequency()
 {
-    setStatusFrequency(m_deviceCenterFrequency + m_settings.m_inputFrequencyOffset);
+    setStatusFrequency(m_centerFrequency + m_settings.m_inputFrequencyOffset);
 }
diff --git a/plugins/channelrx/radioastronomy/radioastronomygui.h b/plugins/channelrx/radioastronomy/radioastronomygui.h
index c94603d19..527af32b1 100644
--- a/plugins/channelrx/radioastronomy/radioastronomygui.h
+++ b/plugins/channelrx/radioastronomy/radioastronomygui.h
@@ -223,7 +223,6 @@ private:
     ChannelMarker m_channelMarker;
     RollupState m_rollupState;
     RadioAstronomySettings m_settings;
-    qint64 m_deviceCenterFrequency;
     bool m_doApplySettings;
     QList<RadioAstronomySettings::AvailableFeature> m_availableFeatures;
 
@@ -486,7 +485,8 @@ private:
         POWER_COL_SOLAR_FLUX,
         POWER_COL_AIR_TEMP,
         POWER_COL_SENSOR_1,
-        POWER_COL_SENSOR_2
+        POWER_COL_SENSOR_2,
+        POWER_COL_UTC
     };
 
     enum PowerMarkerTable {
diff --git a/plugins/channelrx/radioastronomy/radioastronomygui.ui b/plugins/channelrx/radioastronomy/radioastronomygui.ui
index cf468b062..e25ea3f5b 100644
--- a/plugins/channelrx/radioastronomy/radioastronomygui.ui
+++ b/plugins/channelrx/radioastronomy/radioastronomygui.ui
@@ -4936,7 +4936,7 @@ This should be close to the expected difference in power between hot and cold ca
         <string>Time</string>
        </property>
        <property name="toolTip">
-        <string>Time measurement finished</string>
+        <string>Local time measurement finished</string>
        </property>
       </column>
       <column>
@@ -5139,6 +5139,14 @@ This should be close to the expected difference in power between hot and cold ca
         <string>Sensor 2 data</string>
        </property>
       </column>
+      <column>
+       <property name="text">
+        <string>UTC</string>
+       </property>
+       <property name="toolTip">
+        <string>UTC date and time measurement finished</string>
+       </property>
+      </column>
      </widget>
     </item>
    </layout>
diff --git a/plugins/channelrx/radioastronomy/radioastronomysettings.h b/plugins/channelrx/radioastronomy/radioastronomysettings.h
index 1c14905d1..ce03d2c3c 100644
--- a/plugins/channelrx/radioastronomy/radioastronomysettings.h
+++ b/plugins/channelrx/radioastronomy/radioastronomysettings.h
@@ -28,7 +28,7 @@
 class Serializable;
 
 // Number of columns in the tables
-#define RADIOASTRONOMY_POWERTABLE_COLUMNS 27
+#define RADIOASTRONOMY_POWERTABLE_COLUMNS 28
 
 // Number of sensors
 #define RADIOASTRONOMY_SENSORS 2
diff --git a/plugins/channelrx/radioastronomy/readme.md b/plugins/channelrx/radioastronomy/readme.md
index ec6640854..c43e64bd6 100644
--- a/plugins/channelrx/radioastronomy/readme.md
+++ b/plugins/channelrx/radioastronomy/readme.md
@@ -764,8 +764,8 @@ The Radiometer Data table shows measurement results and settings at the time of
 
 The columns in the table include:
 
-- Date - Date at the end of the measurement.
-- Time - Time at the end of the measurement.
+- Date - Local date at the end of the measurement.
+- Time - Local time at the end of the measurement.
 - Power (FFT) - Power relative to fullscale (sum of FFT absolute magnitude).
 - Power (dBFS) - Power in dBFS.
 - Power (dBm) - Power in dBm.
@@ -791,6 +791,7 @@ The columns in the table include:
 - Air Temp (C) - Surface air temperature at observation point in Celsius from Star Tracker.
 - Sensor 1 - Data recorded for Sensor 1.
 - Sensor 2 - Data recorded for Sensor 2.
+- UTC - UTC date and time at the end of the measurement.
 
 Right clicking on the table shows a popup menu that supports: