LimeRFE USB support: GUI: Rx/Tx sync: work with device set indexes and set focus on Rx or Tx when switched on

This commit is contained in:
f4exb 2020-01-21 18:05:14 +01:00
parent 839ce57209
commit e3bea93676
6 changed files with 77 additions and 48 deletions

View File

@ -47,6 +47,8 @@ LimeRFEController::LimeRFESettings::LimeRFESettings()
m_txHAMChannel = HAM_144_146MHz;
m_txCellularChannel = CellularBand38;
m_txPort = TxPortJ3;
m_swrEnable = false;
m_swrSource = SWRExternal;
m_txRxDriven = false;
m_rxOn = false;
m_txOn = false;

View File

@ -22,14 +22,16 @@
#include "dsp/dspengine.h"
#include "dsp/dspdevicesourceengine.h"
#include "dsp/dspdevicesinkengine.h"
#include "mainwindow.h"
#include "device/deviceuiset.h"
#include "gui/doublevalidator.h"
#include "limerfeusbdialog.h"
#include "ui_limerfeusbdialog.h"
LimeRFEUSBDialog::LimeRFEUSBDialog(LimeRFEUSBCalib& limeRFEUSBCalib, QWidget* parent) :
LimeRFEUSBDialog::LimeRFEUSBDialog(LimeRFEUSBCalib& limeRFEUSBCalib, MainWindow* mainWindow) :
m_limeRFEUSBCalib(limeRFEUSBCalib),
QDialog(parent),
QDialog(mainWindow),
ui(new Ui::LimeRFEUSBDialog),
m_rxTxToggle(false),
m_currentPowerCorrection(0.0),
@ -37,6 +39,7 @@ LimeRFEUSBDialog::LimeRFEUSBDialog(LimeRFEUSBCalib& limeRFEUSBCalib, QWidget* pa
m_deviceSetSync(false)
{
ui->setupUi(this);
m_mainWindow = mainWindow;
ui->powerCorrValue->setValidator(new DoubleValidator(-99.9, 99.9, 1, ui->powerCorrValue));
std::vector<std::string> comPorts;
SerialUtil::getComPorts(comPorts, "ttyUSB[0-9]+"); // regex is for Linux only
@ -656,6 +659,9 @@ void LimeRFEUSBDialog::stopStartRx(bool start)
if (deviceSourceEngine->initAcquisition()) {
deviceSourceEngine->startAcquisition();
}
MainWindow::MsgDeviceSetFocus *msg = MainWindow::MsgDeviceSetFocus::create(m_rxDeviceSetIndex[rxDeviceSetSequence]);
m_mainWindow->getInputMessageQueue()->push(msg);
}
else
{
@ -678,6 +684,9 @@ void LimeRFEUSBDialog::stopStartTx(bool start)
if (deviceSinkEngine->initGeneration()) {
deviceSinkEngine->startGeneration();
}
MainWindow::MsgDeviceSetFocus *msg = MainWindow::MsgDeviceSetFocus::create(m_txDeviceSetIndex[txDeviceSetSequence]);
m_mainWindow->getInputMessageQueue()->push(msg);
}
else
{
@ -710,22 +719,37 @@ void LimeRFEUSBDialog::updateAbsPower(double powerCorrDB)
void LimeRFEUSBDialog::updateDeviceSetList()
{
DSPEngine *dspEngine = DSPEngine::instance();
std::vector<DeviceUISet*>& deviceUISets = m_mainWindow->getDeviceUISets();
std::vector<DeviceUISet*>::const_iterator it = deviceUISets.begin();
m_sourceEngines.clear();
m_rxDeviceSetIndex.clear();
m_sinkEngines.clear();
m_txDeviceSetIndex.clear();
ui->deviceSetRx->clear();
ui->deviceSetTx->clear();
unsigned int deviceIndex = 0;
unsigned int rxIndex = 0;
unsigned int txIndex = 0;
for (uint32_t i = 0; i < dspEngine->getDeviceSourceEnginesNumber(); i++)
for (; it != deviceUISets.end(); ++it, deviceIndex++)
{
DSPDeviceSourceEngine *deviceSourceEngine = dspEngine->getDeviceSourceEngineByIndex(i);
m_sourceEngines.push_back(deviceSourceEngine);
ui->deviceSetRx->addItem(QString("%1").arg(i));
}
DSPDeviceSourceEngine *deviceSourceEngine = (*it)->m_deviceSourceEngine;
DSPDeviceSinkEngine *deviceSinkEngine = (*it)->m_deviceSinkEngine;
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));
if (deviceSourceEngine)
{
m_sourceEngines.push_back(deviceSourceEngine);
m_rxDeviceSetIndex.push_back(deviceIndex);
ui->deviceSetRx->addItem(QString("%1").arg(deviceIndex));
rxIndex++;
}
else if (deviceSinkEngine)
{
m_sinkEngines.push_back(deviceSinkEngine);
m_txDeviceSetIndex.push_back(deviceIndex);
ui->deviceSetTx->addItem(QString("%1").arg(deviceIndex));
txIndex++;
}
}
}
@ -824,9 +848,11 @@ void LimeRFEUSBDialog::on_rxTxToggle_clicked()
int rc = m_controller.setTx(m_settings, m_settings.m_txOn);
ui->statusText->setText(m_controller.getError(rc).c_str());
displayMode();
}
highlightApplyButton(true);
if (m_deviceSetSync) {
syncRxTx();
}
}
}
void LimeRFEUSBDialog::on_apply_clicked()

View File

@ -31,6 +31,7 @@
class DSPDeviceSourceEngine;
class DSPDeviceSinkEngine;
class MainWindow;
namespace Ui {
class LimeRFEUSBDialog;
@ -40,7 +41,7 @@ class SDRGUI_API LimeRFEUSBDialog : public QDialog {
Q_OBJECT
public:
explicit LimeRFEUSBDialog(LimeRFEUSBCalib& limeRFEUSBCalib, QWidget* parent = nullptr);
explicit LimeRFEUSBDialog(LimeRFEUSBCalib& limeRFEUSBCalib, MainWindow* mainWindow);
~LimeRFEUSBDialog();
private:
@ -61,6 +62,7 @@ private:
void highlightApplyButton(bool highlight);
Ui::LimeRFEUSBDialog* ui;
MainWindow *m_mainWindow;
LimeRFEController m_controller;
LimeRFEController::LimeRFESettings m_settings;
LimeRFEUSBCalib& m_limeRFEUSBCalib;
@ -73,7 +75,9 @@ private:
int m_rxDeviceSetSequence;
int m_txDeviceSetSequence;
std::vector<DSPDeviceSourceEngine*> m_sourceEngines;
std::vector<int> m_rxDeviceSetIndex;
std::vector<DSPDeviceSinkEngine*> m_sinkEngines;
std::vector<int> m_txDeviceSetIndex;
private slots:
void on_openDevice_clicked();

View File

@ -886,7 +886,7 @@
</rect>
</property>
<property name="toolTip">
<string>Sequence of Rx DeviceSet </string>
<string>Index of Rx DeviceSet </string>
</property>
</widget>
<widget class="QComboBox" name="deviceSetTx">
@ -899,7 +899,7 @@
</rect>
</property>
<property name="toolTip">
<string>Sequence of Tx DeviceSet </string>
<string>Index of Tx DeviceSet </string>
</property>
</widget>
<widget class="QLabel" name="deviceSetRxLabel">

View File

@ -181,21 +181,17 @@ Use this switch to activate Rx/Tx toggle. When Rx is switched on Tx is switched
When switched on this connects the Rx (D.1) and Tx (D.2) switches to a Rx and Tx device set selected by (D.5) and (D.6) respectively in order to start or stop devices accordingly.
<h3>D.5 Rx device set sequence</h3>
<h3>D.5 Rx device set index</h3>
Select the Rx device set sequence with which you want to synchronize the Rx switch (D.1). Note that this is the sequence of Rx in increasing order of Rx tabs and not the tab number itself.
Select the Rx device set index with which you want to synchronize the Rx switch (D.1).
For example if you have a configuration with R0, T1 and R2 tabs the device set corresponding to R2 will be identified with sequence number 1.
<h3>D.6 Tx device set index</h3>
<h3>D.6 Tx device set sequence</h3>
Select the Tx device set index with which you want to synchronize the Tx switch (D.2).
Select the Tx device set sequence with which you want to synchronize the Tx switch (D.2). Note that this is the sequence of Tx in increasing order of Tx tabs and not the tab number itself.
<h3>D.7 Refresh device sets indexes</h3>
Using the same example as above T1 is identified with sequence number 0.
<h3>D.7 Refresh device sets sequences</h3>
When the configuration of device sets changes you can use this button to refresh the device set sequences in (D.5) and (D.6).
When the configuration of device sets changes you can use this button to refresh the device set indexes in (D.5) and (D.6).
<h2>5. Status window</h2>

View File

@ -68,6 +68,26 @@ class SDRGUI_API MainWindow : public QMainWindow {
Q_OBJECT
public:
class MsgDeviceSetFocus : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getDeviceSetIndex() const { return m_deviceSetIndex; }
static MsgDeviceSetFocus* create(int deviceSetIndex)
{
return new MsgDeviceSetFocus(deviceSetIndex);
}
private:
int m_deviceSetIndex;
MsgDeviceSetFocus(int deviceSetIndex) :
Message(),
m_deviceSetIndex(deviceSetIndex)
{ }
};
explicit MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parser, QWidget* parent = 0);
~MainWindow();
static MainWindow *getInstance() { return m_instance; } // Main Window is de facto a singleton so this just returns its reference
@ -82,6 +102,7 @@ public:
const QTimer& getMasterTimer() const { return m_masterTimer; }
const MainSettings& getMainSettings() const { return m_settings; }
const PluginManager *getPluginManager() const { return m_pluginManager; }
std::vector<DeviceUISet*>& getDeviceUISets() { return m_deviceUIs; }
void commandKeysConnect(QObject *object, const char *slot);
void commandKeysDisconnect(QObject *object, const char *slot);
@ -279,26 +300,6 @@ private:
QString tabName;
};
class MsgDeviceSetFocus : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getDeviceSetIndex() const { return m_deviceSetIndex; }
static MsgDeviceSetFocus* create(int deviceSetIndex)
{
return new MsgDeviceSetFocus(deviceSetIndex);
}
private:
int m_deviceSetIndex;
MsgDeviceSetFocus(int deviceSetIndex) :
Message(),
m_deviceSetIndex(deviceSetIndex)
{ }
};
class MsgApplySettings : public Message {
MESSAGE_CLASS_DECLARATION