mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-03-23 04:44:53 -04:00
LimeRFE USB: implemented device set control
This commit is contained in:
parent
cf6f8374de
commit
9d27407a66
@ -20,6 +20,8 @@
|
||||
#include "util/serialutil.h"
|
||||
#include "util/db.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "dsp/dspdevicesourceengine.h"
|
||||
#include "dsp/dspdevicesinkengine.h"
|
||||
#include "gui/doublevalidator.h"
|
||||
|
||||
#include "limerfeusbdialog.h"
|
||||
@ -29,7 +31,10 @@ LimeRFEUSBDialog::LimeRFEUSBDialog(LimeRFEUSBCalib& limeRFEUSBCalib, QWidget* pa
|
||||
m_limeRFEUSBCalib(limeRFEUSBCalib),
|
||||
QDialog(parent),
|
||||
ui(new Ui::LimeRFEUSBDialog),
|
||||
m_rxTxToggle(false)
|
||||
m_rxTxToggle(false),
|
||||
m_currentPowerCorrection(0.0),
|
||||
m_avgPower(false),
|
||||
m_deviceSetSync(false)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->powerCorrValue->setValidator(new DoubleValidator(-99.9, 99.9, 1, ui->powerCorrValue));
|
||||
@ -40,8 +45,9 @@ LimeRFEUSBDialog::LimeRFEUSBDialog(LimeRFEUSBCalib& limeRFEUSBCalib, QWidget* pa
|
||||
ui->device->addItem(QString(it->c_str()));
|
||||
}
|
||||
|
||||
updateDeviceSetList();
|
||||
displaySettings(); // default values
|
||||
m_timer.setInterval(1000);
|
||||
m_timer.setInterval(500);
|
||||
}
|
||||
|
||||
LimeRFEUSBDialog::~LimeRFEUSBDialog()
|
||||
@ -574,6 +580,11 @@ void LimeRFEUSBDialog::on_powerAutoRefresh_toggled(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::on_powerAbsAvg_clicked()
|
||||
{
|
||||
m_avgPower = ui->powerAbsAvg->isChecked();
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::on_powerCorrValue_textEdited(const QString &text)
|
||||
{
|
||||
bool ok;
|
||||
@ -587,6 +598,77 @@ void LimeRFEUSBDialog::on_powerCorrValue_textEdited(const QString &text)
|
||||
}
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::on_deviceSetRefresh_clicked()
|
||||
{
|
||||
updateDeviceSetList();
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::on_deviceSetSync_clicked()
|
||||
{
|
||||
m_deviceSetSync = ui->deviceSetSync->isChecked();
|
||||
|
||||
if (m_deviceSetSync) {
|
||||
syncRxTx();
|
||||
}
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::syncRxTx()
|
||||
{
|
||||
if (!m_settings.m_txOn) {
|
||||
stopStartTx(m_settings.m_txOn);
|
||||
}
|
||||
|
||||
stopStartRx(m_settings.m_rxOn);
|
||||
|
||||
if (m_settings.m_txOn) {
|
||||
stopStartTx(m_settings.m_txOn);
|
||||
}
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::stopStartRx(bool start)
|
||||
{
|
||||
int rxDeviceSetSequence = ui->deviceSetRx->currentIndex();
|
||||
|
||||
if ((rxDeviceSetSequence < 0) || (rxDeviceSetSequence >= m_sourceEngines.size())) {
|
||||
return;
|
||||
}
|
||||
|
||||
DSPDeviceSourceEngine *deviceSourceEngine = m_sourceEngines[rxDeviceSetSequence];
|
||||
|
||||
if (start)
|
||||
{
|
||||
if (deviceSourceEngine->initAcquisition()) {
|
||||
deviceSourceEngine->startAcquisition();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
deviceSourceEngine->stopAcquistion();
|
||||
}
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::stopStartTx(bool start)
|
||||
{
|
||||
int txDeviceSetSequence = ui->deviceSetTx->currentIndex();
|
||||
|
||||
if ((txDeviceSetSequence < 0) || (txDeviceSetSequence >= m_sinkEngines.size())) {
|
||||
return;
|
||||
}
|
||||
|
||||
DSPDeviceSinkEngine *deviceSinkEngine = m_sinkEngines[txDeviceSetSequence];
|
||||
|
||||
if (start)
|
||||
{
|
||||
if (deviceSinkEngine->initGeneration()) {
|
||||
deviceSinkEngine->startGeneration();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
deviceSinkEngine->stopGeneration();
|
||||
}
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::updateAbsPower(double powerCorrDB)
|
||||
{
|
||||
bool ok;
|
||||
@ -595,10 +677,39 @@ void LimeRFEUSBDialog::updateAbsPower(double powerCorrDB)
|
||||
if (ok)
|
||||
{
|
||||
double powerCorrected = power + powerCorrDB;
|
||||
ui->powerAbsDbText->setText(QString::number(powerCorrected, 'f', 1));
|
||||
double powerMilliwatts = CalcDb::powerFromdB(powerCorrected);
|
||||
powerMilliwatts = powerMilliwatts > 8000.0 ? 8000.0 : powerMilliwatts;
|
||||
ui->powerAbsWText->setText(QString::number(powerMilliwatts/1000.0, 'f', 3));
|
||||
double powerDisplayed = powerCorrected;
|
||||
|
||||
if (m_avgPower)
|
||||
{
|
||||
m_powerMovingAverage(powerCorrected);
|
||||
powerDisplayed = m_powerMovingAverage.asDouble();
|
||||
}
|
||||
|
||||
ui->powerAbsDbText->setText(tr("%1 dBm").arg(QString::number(powerDisplayed, 'f', 1)));
|
||||
double powerWatts = CalcDb::powerFromdB(powerDisplayed - 30.0);
|
||||
powerWatts = powerWatts > 8.0 ? 8.0 : powerWatts;
|
||||
ui->powerAbsWText->setText(tr("%1 W").arg(QString::number(powerWatts, 'f', 3)));
|
||||
}
|
||||
}
|
||||
|
||||
void LimeRFEUSBDialog::updateDeviceSetList()
|
||||
{
|
||||
DSPEngine *dspEngine = DSPEngine::instance();
|
||||
m_sourceEngines.clear();
|
||||
m_sinkEngines.clear();
|
||||
|
||||
for (uint32_t i = 0; i < dspEngine->getDeviceSourceEnginesNumber(); i++)
|
||||
{
|
||||
DSPDeviceSourceEngine *deviceSourceEngine = dspEngine->getDeviceSourceEngineByIndex(i);
|
||||
m_sourceEngines.push_back(deviceSourceEngine);
|
||||
ui->deviceSetRx->addItem(QString("%1").arg(i));
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < dspEngine->getDeviceSinkEnginesNumber(); i++)
|
||||
{
|
||||
DSPDeviceSinkEngine *deviceSinkEngine = dspEngine->getDeviceSinkEngineByIndex(i);
|
||||
m_sinkEngines.push_back(deviceSinkEngine);
|
||||
ui->deviceSetTx->addItem(QString("%1").arg(i));
|
||||
}
|
||||
}
|
||||
|
||||
@ -633,6 +744,10 @@ void LimeRFEUSBDialog::on_modeRx_toggled(bool checked)
|
||||
ui->statusText->setText(m_controller.getError(rc).c_str());
|
||||
}
|
||||
|
||||
if (m_deviceSetSync) {
|
||||
syncRxTx();
|
||||
}
|
||||
|
||||
displayMode();
|
||||
}
|
||||
|
||||
@ -667,6 +782,10 @@ void LimeRFEUSBDialog::on_modeTx_toggled(bool checked)
|
||||
ui->statusText->setText(m_controller.getError(rc).c_str());
|
||||
}
|
||||
|
||||
if (m_deviceSetSync) {
|
||||
syncRxTx();
|
||||
}
|
||||
|
||||
displayMode();
|
||||
}
|
||||
|
||||
|
@ -19,13 +19,19 @@
|
||||
#ifndef SDRGUI_LIMERFEGUI_LIMERFEUSBDIALOG_H_
|
||||
#define SDRGUI_LIMERFEGUI_LIMERFEUSBDIALOG_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTimer>
|
||||
|
||||
#include "util/movingaverage.h"
|
||||
#include "limerfe/limerfecontroller.h"
|
||||
#include "limerfe/limerfeusbcalib.h"
|
||||
#include "export.h"
|
||||
|
||||
class DSPDeviceSourceEngine;
|
||||
class DSPDeviceSinkEngine;
|
||||
|
||||
namespace Ui {
|
||||
class LimeRFEUSBDialog;
|
||||
}
|
||||
@ -48,6 +54,10 @@ private:
|
||||
double getPowerCorrection();
|
||||
void setPowerCorrection(double dbValue);
|
||||
void updateAbsPower(double powerCorrDB);
|
||||
void updateDeviceSetList();
|
||||
void stopStartRx(bool start);
|
||||
void stopStartTx(bool start);
|
||||
void syncRxTx();
|
||||
|
||||
Ui::LimeRFEUSBDialog* ui;
|
||||
LimeRFEController m_controller;
|
||||
@ -56,6 +66,13 @@ private:
|
||||
bool m_rxTxToggle;
|
||||
QTimer m_timer;
|
||||
double m_currentPowerCorrection;
|
||||
bool m_avgPower;
|
||||
MovingAverageUtil<double, double, 10> m_powerMovingAverage;
|
||||
bool m_deviceSetSync;
|
||||
int m_rxDeviceSetSequence;
|
||||
int m_txDeviceSetSequence;
|
||||
std::vector<DSPDeviceSourceEngine*> m_sourceEngines;
|
||||
std::vector<DSPDeviceSinkEngine*> m_sinkEngines;
|
||||
|
||||
private slots:
|
||||
void on_openDevice_clicked();
|
||||
@ -72,10 +89,13 @@ private slots:
|
||||
void on_powerSource_currentIndexChanged(int index);
|
||||
void on_powerRefresh_clicked();
|
||||
void on_powerAutoRefresh_toggled(bool checked);
|
||||
void on_powerAbsAvg_clicked();
|
||||
void on_powerCorrValue_textEdited(const QString &text);
|
||||
void on_modeRx_toggled(bool checked);
|
||||
void on_modeTx_toggled(bool checked);
|
||||
void on_rxTxToggle_clicked();
|
||||
void on_deviceSetRefresh_clicked();
|
||||
void on_deviceSetSync_clicked();
|
||||
void on_apply_clicked();
|
||||
void tick();
|
||||
};
|
||||
|
@ -441,8 +441,8 @@
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>350</y>
|
||||
<width>51</width>
|
||||
<height>27</height>
|
||||
<width>50</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
@ -460,8 +460,8 @@
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>350</y>
|
||||
<width>51</width>
|
||||
<height>27</height>
|
||||
<width>50</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
@ -537,8 +537,8 @@
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>350</y>
|
||||
<width>71</width>
|
||||
<height>27</height>
|
||||
<width>70</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
@ -805,15 +805,15 @@
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>290</y>
|
||||
<width>45</width>
|
||||
<width>75</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Corrected forward power in dB</string>
|
||||
<string>Corrected forward power in dBm</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>-00.0</string>
|
||||
<string>-00.0 dBm</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
@ -822,9 +822,9 @@
|
||||
<widget class="QLabel" name="powerAbsWText">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<x>250</x>
|
||||
<y>290</y>
|
||||
<width>45</width>
|
||||
<width>65</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -832,23 +832,7 @@
|
||||
<string>Corrected forward power in Watts</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0.000</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="powerAbsUnits">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>290</y>
|
||||
<width>15</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>W</string>
|
||||
<string>0.000 W</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
@ -876,6 +860,110 @@
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="powerAbsAvg">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>320</x>
|
||||
<y>290</y>
|
||||
<width>50</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Corrected power averaging</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Avg</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="deviceSetRx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>230</x>
|
||||
<y>350</y>
|
||||
<width>50</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Sequence of Rx DeviceSet </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="deviceSetTx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>310</x>
|
||||
<y>350</y>
|
||||
<width>50</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Sequence of Tx DeviceSet </string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="deviceSetRxLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>350</y>
|
||||
<width>25</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rx</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="deviceSetTxLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>290</x>
|
||||
<y>350</y>
|
||||
<width>25</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Tx</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="deviceSetSync">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>210</x>
|
||||
<y>320</y>
|
||||
<width>100</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>DeviceSet synchronization</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Rx/Tx Sync</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="deviceSetRefresh">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>370</x>
|
||||
<y>350</y>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Refresh DeviceSet indexes</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources/res.qrc">
|
||||
<normaloff>:/recycle.png</normaloff>:/recycle.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
Reference in New Issue
Block a user