1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 13:51:47 -05:00

Tx ph.1: add Tx tab (1). Core dump.

This commit is contained in:
f4exb 2016-10-21 16:57:50 +02:00
parent ffb8b4d737
commit 55f4d6d46f
6 changed files with 243 additions and 44 deletions

View File

@ -24,7 +24,8 @@ SamplingDeviceControl::SamplingDeviceControl(QWidget* parent) :
QWidget(parent),
ui(new Ui::SamplingDeviceControl),
m_pluginManager(0),
m_deviceAPI(0)
m_deviceSourceAPI(0),
m_deviceSinkAPI(0)
{
ui->setupUi(this);
}

View File

@ -31,6 +31,7 @@ namespace Ui {
class ChannelMarker;
class PluginManager;
class DeviceSourceAPI;
class DeviceSinkAPI;
class SDRANGEL_API SamplingDeviceControl : public QWidget {
Q_OBJECT
@ -40,7 +41,8 @@ public:
~SamplingDeviceControl();
void setPluginManager(PluginManager *pluginManager) { m_pluginManager = pluginManager; }
void setDeviceAPI(DeviceSourceAPI *devieAPI) { m_deviceAPI = devieAPI; }
void setDeviceAPI(DeviceSourceAPI *deviceAPI) { m_deviceSourceAPI = deviceAPI; }
void setDeviceAPI(DeviceSinkAPI *deviceAPI) { m_deviceSinkAPI = deviceAPI; }
QComboBox *getDeviceSelector();
QPushButton *getDeviceSelectionConfirm();
QComboBox *getChannelSelector();
@ -49,7 +51,8 @@ public:
private:
Ui::SamplingDeviceControl* ui;
PluginManager *m_pluginManager;
DeviceSourceAPI *m_deviceAPI;
DeviceSourceAPI *m_deviceSourceAPI;
DeviceSinkAPI *m_deviceSinkAPI;
};

View File

@ -15,7 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <device/devicesourceapi.h>
#include <QInputDialog>
#include <QMessageBox>
#include <QLabel>
@ -29,6 +28,8 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "device/devicesourceapi.h"
#include "device/devicesinkapi.h"
#include "audio/audiodeviceinfo.h"
#include "gui/indicator.h"
#include "gui/presetitem.h"
@ -208,8 +209,50 @@ void MainWindow::addSourceDevice()
int sampleSourceIndex = m_pluginManager->selectSampleSourceBySerialOrSequence("sdrangel.samplesource.filesource", "0", 0, m_deviceUIs.back()->m_deviceSourceAPI);
}
void MainWindow::addSinkDevice()
{
DSPDeviceSinkEngine *dspDeviceSinkEngine = m_dspEngine->addDeviceSinkEngine();
dspDeviceSinkEngine->start();
uint dspDeviceSinkEngineUID = dspDeviceSinkEngine->getUID();
char tabNameCStr[16];
sprintf(tabNameCStr, "T%d", dspDeviceSinkEngineUID);
m_deviceUIs.push_back(new DeviceUISet(m_masterTimer));
m_deviceUIs.back()->m_deviceSourceEngine = 0;
m_deviceUIs.back()->m_deviceSinkEngine = dspDeviceSinkEngine;
DeviceSinkAPI *deviceSinkAPI = new DeviceSinkAPI(this, m_deviceUIs.size()-1, dspDeviceSinkEngine, m_deviceUIs.back()->m_spectrum, m_deviceUIs.back()->m_channelWindow);
m_deviceUIs.back()->m_deviceSourceAPI = 0;
m_deviceUIs.back()->m_deviceSinkAPI = deviceSinkAPI;
m_deviceUIs.back()->m_samplingDeviceControl->setDeviceAPI(deviceSinkAPI);
m_deviceUIs.back()->m_samplingDeviceControl->setPluginManager(m_pluginManager);
m_pluginManager->populateTxChannelComboBox(m_deviceUIs.back()->m_samplingDeviceControl->getChannelSelector());
connect(m_deviceUIs.back()->m_samplingDeviceControl->getAddChannelButton(), SIGNAL(clicked(bool)), this, SLOT(on_channel_addClicked(bool)));
dspDeviceSinkEngine->addSink(m_deviceUIs.back()->m_spectrumVis);
ui->tabSpectra->addTab(m_deviceUIs.back()->m_spectrum, tabNameCStr);
ui->tabSpectraGUI->addTab(m_deviceUIs.back()->m_spectrumGUI, tabNameCStr);
ui->tabChannels->addTab(m_deviceUIs.back()->m_channelWindow, tabNameCStr);
bool sampleSourceSignalsBlocked = m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(true);
m_pluginManager->duplicateLocalSampleSinkDevices(dspDeviceSinkEngineUID);
m_pluginManager->fillSampleSinkSelector(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector(), dspDeviceSinkEngineUID);
connect(m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelectionConfirm(), SIGNAL(clicked(bool)), this, SLOT(on_sampleSink_confirmClicked(bool)));
m_deviceUIs.back()->m_samplingDeviceControl->getDeviceSelector()->blockSignals(sampleSourceSignalsBlocked);
ui->tabInputsSelect->addTab(m_deviceUIs.back()->m_samplingDeviceControl, tabNameCStr);
int sampleSinkIndex = m_pluginManager->selectSampleSinkBySerialOrSequence("sdrangel.samplesink.filesink", "0", 0, m_deviceUIs.back()->m_deviceSinkAPI);
}
void MainWindow::removeLastDevice()
{
if (m_deviceUIs.back()->m_deviceSourceEngine) // source tab
{
DSPDeviceSourceEngine *lastDeviceEngine = m_deviceUIs.back()->m_deviceSourceEngine;
lastDeviceEngine->stopAcquistion();
lastDeviceEngine->removeSink(m_deviceUIs.back()->m_spectrumVis);
@ -237,6 +280,37 @@ void MainWindow::removeLastDevice()
lastDeviceEngine->stop();
m_dspEngine->removeLastDeviceSourceEngine();
}
else if (m_deviceUIs.back()->m_deviceSinkEngine) // sink tab
{
DSPDeviceSinkEngine *lastDeviceEngine = m_deviceUIs.back()->m_deviceSinkEngine;
lastDeviceEngine->stopGeneration();
lastDeviceEngine->removeSink(m_deviceUIs.back()->m_spectrumVis);
ui->tabSpectraGUI->removeTab(ui->tabSpectraGUI->count() - 1);
ui->tabSpectra->removeTab(ui->tabSpectra->count() - 1);
m_deviceUIs.back()->m_deviceSinkAPI->freeAll();
ui->tabChannels->removeTab(ui->tabChannels->count() - 1);
ui->tabInputsSelect->removeTab(ui->tabInputsSelect->count() - 1);
m_deviceWidgetTabs.removeLast();
ui->tabInputsView->clear();
for (int i = 0; i < m_deviceWidgetTabs.size(); i++)
{
qDebug("MainWindow::removeLastDevice: adding back tab for %s", m_deviceWidgetTabs[i].displayName.toStdString().c_str());
ui->tabInputsView->addTab(m_deviceWidgetTabs[i].gui, m_deviceWidgetTabs[i].tabName);
ui->tabInputsView->setTabToolTip(i, m_deviceWidgetTabs[i].displayName);
}
delete m_deviceUIs.back();
lastDeviceEngine->stop();
m_dspEngine->removeLastDeviceSinkEngine();
}
m_deviceUIs.pop_back();
}
@ -315,10 +389,20 @@ void MainWindow::loadPresetSettings(const Preset* preset, int tabIndex)
if (tabIndex >= 0)
{
DeviceUISet *deviceUI = m_deviceUIs[tabIndex];
if (deviceUI->m_deviceSourceEngine) // source device
{
deviceUI->m_spectrumGUI->deserialize(preset->getSpectrumConfig());
deviceUI->m_deviceSourceAPI->loadChannelSettings(preset, &(m_pluginManager->m_pluginAPI));
deviceUI->m_deviceSourceAPI->loadSourceSettings(preset);
}
else if (deviceUI->m_deviceSinkEngine) // sink device
{
deviceUI->m_spectrumGUI->deserialize(preset->getSpectrumConfig());
deviceUI->m_deviceSinkAPI->loadChannelSettings(preset, &(m_pluginManager->m_pluginAPI));
deviceUI->m_deviceSinkAPI->loadSinkSettings(preset);
}
}
// has to be last step
restoreState(preset->getLayout());
@ -334,10 +418,20 @@ void MainWindow::savePresetSettings(Preset* preset, int tabIndex)
//int currentSourceTabIndex = ui->tabInputsView->currentIndex();
DeviceUISet *deviceUI = m_deviceUIs[tabIndex];
if (deviceUI->m_deviceSourceEngine) // source device
{
preset->setSpectrumConfig(deviceUI->m_spectrumGUI->serialize());
preset->clearChannels();
deviceUI->m_deviceSourceAPI->saveChannelSettings(preset);
deviceUI->m_deviceSourceAPI->saveSourceSettings(preset);
}
else if (deviceUI->m_deviceSinkEngine) // sink device
{
preset->setSpectrumConfig(deviceUI->m_spectrumGUI->serialize());
preset->clearChannels();
deviceUI->m_deviceSinkAPI->saveChannelSettings(preset);
deviceUI->m_deviceSinkAPI->saveSinkSettings(preset);
}
preset->setLayout(saveState());
}
@ -676,18 +770,40 @@ void MainWindow::on_sampleSource_confirmClicked(bool checked)
if (currentSourceTabIndex >= 0)
{
qDebug("MainWindow::on_sampleSource_currentIndexChanged: tab at %d", currentSourceTabIndex);
qDebug("MainWindow::on_sampleSource_confirmClicked: tab at %d", currentSourceTabIndex);
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
deviceUI->m_deviceSourceAPI->saveSourceSettings(m_settings.getWorkingPreset());
int selectedComboIndex = deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex();
void *devicePtr = deviceUI->m_samplingDeviceControl->getDeviceSelector()->itemData(selectedComboIndex).value<void *>();
m_pluginManager->selectSampleSourceByDevice(devicePtr, deviceUI->m_deviceSourceAPI);
m_settings.setSourceIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex());
deviceUI->m_deviceSourceAPI->loadSourceSettings(m_settings.getWorkingPreset());
if (currentSourceTabIndex == 0)
{
m_settings.setSourceIndex(deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex());
}
}
}
void MainWindow::on_sampleSink_confirmClicked(bool checked)
{
// Do it in the currently selected source tab
int currentSinkTabIndex = ui->tabInputsSelect->currentIndex();
if (currentSinkTabIndex >= 0)
{
qDebug("MainWindow::on_sampleSink_confirmClicked: tab at %d", currentSinkTabIndex);
DeviceUISet *deviceUI = m_deviceUIs[currentSinkTabIndex];
deviceUI->m_deviceSinkAPI->saveSinkSettings(m_settings.getWorkingPreset());
int selectedComboIndex = deviceUI->m_samplingDeviceControl->getDeviceSelector()->currentIndex();
void *devicePtr = deviceUI->m_samplingDeviceControl->getDeviceSelector()->itemData(selectedComboIndex).value<void *>();
m_pluginManager->selectSampleSinkByDevice(devicePtr, deviceUI->m_deviceSinkAPI);
deviceUI->m_deviceSinkAPI->loadSinkSettings(m_settings.getWorkingPreset());
}
}
void MainWindow::on_rxChannel_addClicked(bool checked)
void MainWindow::on_channel_addClicked(bool checked)
{
// Do it in the currently selected source tab
int currentSourceTabIndex = ui->tabInputsSelect->currentIndex();
@ -695,8 +811,16 @@ void MainWindow::on_rxChannel_addClicked(bool checked)
if (currentSourceTabIndex >= 0)
{
DeviceUISet *deviceUI = m_deviceUIs[currentSourceTabIndex];
if (deviceUI->m_deviceSourceEngine) // source device => Rx channels
{
m_pluginManager->createRxChannelInstance(deviceUI->m_samplingDeviceControl->getChannelSelector()->currentIndex(), deviceUI->m_deviceSourceAPI);
}
else if (deviceUI->m_deviceSinkEngine) // sink device => Tx channels
{
m_pluginManager->createTxChannelInstance(deviceUI->m_samplingDeviceControl->getChannelSelector()->currentIndex(), deviceUI->m_deviceSinkAPI);
}
}
}
@ -711,6 +835,11 @@ void MainWindow::on_action_addSourceDevice_triggered()
addSourceDevice();
}
void MainWindow::on_action_addSinkDevice_triggered()
{
addSinkDevice();
}
void MainWindow::on_action_removeLastDevice_triggered()
{
if (m_deviceUIs.size() > 1)

View File

@ -45,7 +45,7 @@ class PluginGUI;
class ChannelMarker;
class PluginManager;
class DeviceSourceAPI;
class DeviceSinkApi;
class DeviceSinkAPI;
class PluginInterface;
class QWidget;
@ -67,7 +67,7 @@ public:
DSPDeviceSourceEngine *m_deviceSourceEngine;
DeviceSourceAPI *m_deviceSourceAPI;
DSPDeviceSinkEngine *m_deviceSinkEngine;
DeviceSinkApi *m_deviceSinkAPI;
DeviceSinkAPI *m_deviceSinkAPI;
QByteArray m_mainWindowState;
DeviceUISet(QTimer& timer);
@ -135,6 +135,7 @@ private:
void applySettings();
void addSourceDevice();
void addSinkDevice();
void removeLastDevice();
private slots:
@ -154,10 +155,12 @@ private slots:
void on_action_DV_Serial_triggered(bool checked);
void on_action_My_Position_triggered();
void on_sampleSource_confirmClicked(bool checked);
void on_rxChannel_addClicked(bool checked);
void on_sampleSink_confirmClicked(bool checked);
void on_channel_addClicked(bool checked);
void on_action_Loaded_Plugins_triggered();
void on_action_About_triggered();
void on_action_addSourceDevice_triggered();
void on_action_addSinkDevice_triggered();
void on_action_removeLastDevice_triggered();
void on_action_Exit_triggered();
void tabInputViewIndexChanged();

View File

@ -33,7 +33,16 @@
</font>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -66,7 +75,7 @@
<x>0</x>
<y>0</y>
<width>1012</width>
<height>19</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menu_File">
@ -92,6 +101,7 @@
<string>&amp;Acquisition</string>
</property>
<addaction name="action_addSourceDevice"/>
<addaction name="action_addSinkDevice"/>
<addaction name="action_removeLastDevice"/>
</widget>
<widget class="QMenu" name="menu_View">
@ -163,7 +173,16 @@
</attribute>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout_6">
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="spacing">
@ -391,7 +410,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -422,7 +450,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -459,7 +496,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -487,7 +533,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -619,6 +674,11 @@
<string>My Position</string>
</property>
</action>
<action name="action_addSinkDevice">
<property name="text">
<string>Add sink device</string>
</property>
</action>
<zorder>presetDock</zorder>
<zorder>channelDock</zorder>
</widget>
@ -648,6 +708,8 @@
<include location="resources/res.qrc"/>
<include location="resources/res.qrc"/>
<include location="resources/res.qrc"/>
<include location="resources/res.qrc"/>
<include location="resources/res.qrc"/>
</resources>
<connections>
<connection>

View File

@ -69,6 +69,7 @@ void PluginManager::loadPlugins()
}
updateSampleSourceDevices();
updateSampleSinkDevices();
}
void PluginManager::registerRxChannel(const QString& channelName, PluginInterface* plugin)