1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-19 06:41:47 -05:00

Deep redesign: Init sequence review phase #1: Fixing channel GUI init

This commit is contained in:
f4exb 2015-08-18 09:24:56 +02:00
parent 2db6c3a4c7
commit 30957e3002
7 changed files with 111 additions and 40 deletions

View File

@ -44,11 +44,15 @@ qint64 NFMDemodGUI::getCenterFrequency() const
void NFMDemodGUI::resetToDefaults() void NFMDemodGUI::resetToDefaults()
{ {
blockGUISignals(true);
ui->rfBW->setValue(4); ui->rfBW->setValue(4);
ui->afBW->setValue(3); ui->afBW->setValue(3);
ui->volume->setValue(20); ui->volume->setValue(20);
ui->squelch->setValue(-40); ui->squelch->setValue(-40);
ui->deltaFrequency->setValue(0); ui->deltaFrequency->setValue(0);
blockGUISignals(false);
applySettings(); applySettings();
} }
@ -81,6 +85,9 @@ bool NFMDemodGUI::deserialize(const QByteArray& data)
QByteArray bytetmp; QByteArray bytetmp;
quint32 u32tmp; quint32 u32tmp;
qint32 tmp; qint32 tmp;
blockGUISignals(true);
d.readS32(1, &tmp, 0); d.readS32(1, &tmp, 0);
m_channelMarker->setCenterFrequency(tmp); m_channelMarker->setCenterFrequency(tmp);
d.readS32(2, &tmp, 4); d.readS32(2, &tmp, 4);
@ -97,6 +104,9 @@ bool NFMDemodGUI::deserialize(const QByteArray& data)
m_channelMarker->setColor(u32tmp); m_channelMarker->setColor(u32tmp);
d.readS32(8, &tmp, 0); d.readS32(8, &tmp, 0);
ui->ctcss->setCurrentIndex(tmp); ui->ctcss->setCurrentIndex(tmp);
blockGUISignals(false);
applySettings(); applySettings();
return true; return true;
} }
@ -287,3 +297,14 @@ void NFMDemodGUI::setCtcssFreq(Real ctcssFreq)
} }
} }
void NFMDemodGUI::blockGUISignals(bool block)
{
m_channelMarker->blockSignals(block);
ui->deltaFrequency->blockSignals(block);
ui->deltaMinus->blockSignals(block);
ui->rfBW->blockSignals(block);
ui->afBW->blockSignals(block);
ui->volume->blockSignals(block);
ui->squelch->blockSignals(block);
}

View File

@ -59,8 +59,9 @@ private:
static const int m_rfBW[]; static const int m_rfBW[];
explicit NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent = NULL); explicit NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent = NULL);
~NFMDemodGUI(); virtual ~NFMDemodGUI();
void blockGUISignals(bool block);
void applySettings(); void applySettings();
void leaveEvent(QEvent*); void leaveEvent(QEvent*);

View File

@ -61,17 +61,17 @@ void BladerfInput::Settings::resetToDefaults()
QByteArray BladerfInput::Settings::serialize() const QByteArray BladerfInput::Settings::serialize() const
{ {
SimpleSerializer s(1); SimpleSerializer s(1);
s.writeU64(1, m_centerFrequency); s.writeS32(1, m_lnaGain);
s.writeS32(2, m_devSampleRate); s.writeS32(2, m_vga1);
s.writeS32(3, m_lnaGain); s.writeS32(3, m_vga2);
s.writeS32(4, m_vga1); s.writeU32(4, m_log2Decim);
s.writeS32(5, m_vga2); s.writeBool(5, m_xb200);
s.writeU32(6, m_log2Decim); s.writeS32(6, (int) m_xb200Path);
s.writeBool(7, m_xb200); s.writeS32(7, (int) m_xb200Filter);
s.writeS32(8, (int) m_xb200Path); s.writeS32(8, m_bandwidth);
s.writeS32(9, (int) m_xb200Filter); s.writeS32(9, (int) m_fcPos);
s.writeS32(10, m_bandwidth); s.writeU64(10, m_centerFrequency);
s.writeS32(11, (int) m_fcPos); s.writeS32(11, m_devSampleRate);
return s.final(); return s.final();
} }
@ -88,20 +88,20 @@ bool BladerfInput::Settings::deserialize(const QByteArray& data)
if (d.getVersion() == 1) if (d.getVersion() == 1)
{ {
int intval; int intval;
d.readU64(1, &m_centerFrequency, 435000*1000); d.readS32(1, &m_lnaGain, 0);
d.readS32(2, &m_devSampleRate, 3072000); d.readS32(2, &m_vga1, 20);
d.readS32(3, &m_lnaGain, 0); d.readS32(3, &m_vga2, 9);
d.readS32(4, &m_vga1, 20); d.readU32(4, &m_log2Decim, 0);
d.readS32(5, &m_vga2, 9); d.readBool(5, &m_xb200);
d.readU32(6, &m_log2Decim, 0); d.readS32(6, &intval);
d.readBool(7, &m_xb200);
d.readS32(8, &intval);
m_xb200Path = (bladerf_xb200_path) intval; m_xb200Path = (bladerf_xb200_path) intval;
d.readS32(9, &intval); d.readS32(7, &intval);
m_xb200Filter = (bladerf_xb200_filter) intval; m_xb200Filter = (bladerf_xb200_filter) intval;
d.readS32(10, &m_bandwidth, 0); d.readS32(8, &m_bandwidth, 0);
d.readS32(11, &intval, 0); d.readS32(9, &intval, 0);
m_fcPos = (fcPos_t) intval; m_fcPos = (fcPos_t) intval;
d.readU64(10, &m_centerFrequency, 435000*1000);
d.readS32(11, &m_devSampleRate, 3072000);
return true; return true;
} }
else else

View File

@ -80,7 +80,7 @@
<property name="text"> <property name="text">
<string>&lt;p&gt;Copyright (C) 2013 maintech GmbH, Otto-Hahn-Str. 15, 97204 Höchberg, Germany&lt;br&gt; <string>&lt;p&gt;Copyright (C) 2013 maintech GmbH, Otto-Hahn-Str. 15, 97204 Höchberg, Germany&lt;br&gt;
Written by Christian Daniel.&lt;/p&gt; Written by Christian Daniel.&lt;/p&gt;
&lt;p&gt;Copyright (C) 2015 Edouard Griffiths, F4EXB. Code branch at: &lt;a href=&quot;https://github.com/f4exb/rtl-sdrangelove/tree/f4exb&quot;&gt;https://github.com/f4exb/rtl-sdrangelove/tree/f4exb&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Version 2 Copyright (C) 2015 Edouard Griffiths, F4EXB. Code branch at: &lt;a href=&quot;https://github.com/f4exb/rtl-sdrangelove/tree/f4exb&quot;&gt;https://github.com/f4exb/rtl-sdrangelove/tree/f4exb&lt;/a&gt;. Complete redesign.&lt;/p&gt;
&lt;p&gt;Many thanks to the osmocom developer team - especially horizon, Hoernchen &amp;amp; tnt.&lt;/p&gt; &lt;p&gt;Many thanks to the osmocom developer team - especially horizon, Hoernchen &amp;amp; tnt.&lt;/p&gt;
&lt;p&gt;SDRangelove itself is licensed as &quot;GPL2+&quot; with the added exception, that plugins using only header files from the &quot;include&quot;-subdirectory and not from the &quot;include-gpl&quot;-subdirectory do not count as derived works.&lt;/p&gt; &lt;p&gt;SDRangelove itself is licensed as &quot;GPL2+&quot; with the added exception, that plugins using only header files from the &quot;include&quot;-subdirectory and not from the &quot;include-gpl&quot;-subdirectory do not count as derived works.&lt;/p&gt;
&lt;p&gt;The following rules apply to the SDRangelove main application and libsdrbase:&lt;br&gt; &lt;p&gt;The following rules apply to the SDRangelove main application and libsdrbase:&lt;br&gt;

View File

@ -53,6 +53,7 @@ MainWindow::MainWindow(QWidget* parent) :
m_sampleFileName(std::string("./test.sdriq")), m_sampleFileName(std::string("./test.sdriq")),
m_pluginManager(new PluginManager(this, m_dspEngine)) m_pluginManager(new PluginManager(this, m_dspEngine))
{ {
qDebug() << "MainWindow::MainWindow: start";
connect(m_dspEngine->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection); connect(m_dspEngine->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection);
m_dspEngine->start(); m_dspEngine->start();
@ -60,11 +61,15 @@ MainWindow::MainWindow(QWidget* parent) :
delete ui->mainToolBar; delete ui->mainToolBar;
createStatusBar(); createStatusBar();
qDebug() << "MainWindow::MainWindow: step #1";
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
qDebug() << "MainWindow::MainWindow: step #2";
// work around broken Qt dock widget ordering // work around broken Qt dock widget ordering
removeDockWidget(ui->inputDock); removeDockWidget(ui->inputDock);
removeDockWidget(ui->processingDock); removeDockWidget(ui->processingDock);
@ -74,18 +79,26 @@ MainWindow::MainWindow(QWidget* parent) :
addDockWidget(Qt::LeftDockWidgetArea, ui->processingDock); addDockWidget(Qt::LeftDockWidgetArea, ui->processingDock);
addDockWidget(Qt::LeftDockWidgetArea, ui->presetDock); addDockWidget(Qt::LeftDockWidgetArea, ui->presetDock);
addDockWidget(Qt::RightDockWidgetArea, ui->channelDock); addDockWidget(Qt::RightDockWidgetArea, ui->channelDock);
qDebug() << "MainWindow::MainWindow: step #3";
ui->inputDock->show(); ui->inputDock->show();
ui->processingDock->show(); ui->processingDock->show();
ui->presetDock->show(); ui->presetDock->show();
ui->channelDock->show(); ui->channelDock->show();
qDebug() << "MainWindow::MainWindow: step #4";
ui->menu_Window->addAction(ui->inputDock->toggleViewAction()); ui->menu_Window->addAction(ui->inputDock->toggleViewAction());
ui->menu_Window->addAction(ui->processingDock->toggleViewAction()); ui->menu_Window->addAction(ui->processingDock->toggleViewAction());
ui->menu_Window->addAction(ui->presetDock->toggleViewAction()); ui->menu_Window->addAction(ui->presetDock->toggleViewAction());
ui->menu_Window->addAction(ui->channelDock->toggleViewAction()); ui->menu_Window->addAction(ui->channelDock->toggleViewAction());
qDebug() << "MainWindow::MainWindow: step #5";
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection); connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
//connect(m_dspEngine->getReportQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection);
qDebug() << "MainWindow::MainWindow: step #6";
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500); m_statusTimer.start(500);
@ -94,11 +107,13 @@ MainWindow::MainWindow(QWidget* parent) :
m_pluginManager->loadPlugins(); m_pluginManager->loadPlugins();
qDebug() << "MainWindow::MainWindow: step #7";
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true); bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
m_pluginManager->fillSampleSourceSelector(ui->sampleSource); m_pluginManager->fillSampleSourceSelector(ui->sampleSource);
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked); ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
//m_dspEngine->start(); qDebug() << "MainWindow::MainWindow: step #8 (was DSP engine start)";
m_spectrumVis = new SpectrumVis(ui->glSpectrum); m_spectrumVis = new SpectrumVis(ui->glSpectrum);
m_dspEngine->addSink(m_spectrumVis); m_dspEngine->addSink(m_spectrumVis);
@ -109,19 +124,36 @@ MainWindow::MainWindow(QWidget* parent) :
ui->glSpectrum->connectTimer(m_masterTimer); ui->glSpectrum->connectTimer(m_masterTimer);
ui->glSpectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum); ui->glSpectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
qDebug() << "MainWindow::MainWindow: step #9";
loadSettings(); loadSettings();
qDebug() << "MainWindow::MainWindow: step #10";
int sampleSourceIndex = m_pluginManager->selectSampleSource(m_settings.getCurrent()->getSource()); // select SampleSource from settings int sampleSourceIndex = m_pluginManager->selectSampleSource(m_settings.getCurrent()->getSource()); // select SampleSource from settings
if(sampleSourceIndex >= 0) {
qDebug() << "MainWindow::MainWindow: step #11";
if(sampleSourceIndex >= 0)
{
bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true); bool sampleSourceSignalsBlocked = ui->sampleSource->blockSignals(true);
ui->sampleSource->setCurrentIndex(sampleSourceIndex); ui->sampleSource->setCurrentIndex(sampleSourceIndex);
ui->sampleSource->blockSignals(sampleSourceSignalsBlocked); ui->sampleSource->blockSignals(sampleSourceSignalsBlocked);
} }
qDebug() << "MainWindow::MainWindow: step #12";
loadSettings(m_settings.getCurrent()); loadSettings(m_settings.getCurrent());
qDebug() << "MainWindow::MainWindow: step #13";
applySettings(); applySettings();
qDebug() << "MainWindow::MainWindow: step #14";
updatePresets(); updatePresets();
qDebug() << "MainWindow::MainWindow: end";
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -182,6 +214,7 @@ void MainWindow::setInputGUI(QWidget* gui)
void MainWindow::loadSettings() void MainWindow::loadSettings()
{ {
qDebug() << "MainWindow::loadSettings"; qDebug() << "MainWindow::loadSettings";
m_settings.load(); m_settings.load();
for(int i = 0; i < m_settings.getPresetCount(); ++i) for(int i = 0; i < m_settings.getPresetCount(); ++i)
@ -191,7 +224,7 @@ void MainWindow::loadSettings()
Preset* current = m_settings.getCurrent(); Preset* current = m_settings.getCurrent();
loadSettings(current); //loadSettings(current);
} }
void MainWindow::loadSettings(const Preset* preset) void MainWindow::loadSettings(const Preset* preset)

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>SDRangelove</string> <string>SDRangelove V2</string>
</property> </property>
<property name="windowIcon"> <property name="windowIcon">
<iconset resource="resources/res.qrc"> <iconset resource="resources/res.qrc">

View File

@ -82,41 +82,57 @@ void PluginManager::loadSettings(const Preset* preset)
{ {
qDebug() << "PluginManager::loadSettings"; qDebug() << "PluginManager::loadSettings";
fprintf(stderr, "-------- [%s | %s] --------\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription())); fprintf(stderr, "Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
// copy currently open channels and clear list // copy currently open channels and clear list
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations; ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
m_channelInstanceRegistrations.clear(); m_channelInstanceRegistrations.clear();
for(int i = 0; i < preset->getChannelCount(); i++) { for(int i = 0; i < preset->getChannelCount(); i++)
{
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i); const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
ChannelInstanceRegistration reg; ChannelInstanceRegistration reg;
// if we have one instance available already, use it // if we have one instance available already, use it
for(int i = 0; i < openChannels.count(); i++) {
qDebug("compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel)); for(int i = 0; i < openChannels.count(); i++)
if(openChannels[i].m_channelName == channelConfig.m_channel) { {
qDebug(" - compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
if(openChannels[i].m_channelName == channelConfig.m_channel)
{
qDebug("channel [%s] found", qPrintable(openChannels[i].m_channelName)); qDebug("channel [%s] found", qPrintable(openChannels[i].m_channelName));
reg = openChannels.takeAt(i); reg = openChannels.takeAt(i);
m_channelInstanceRegistrations.append(reg); m_channelInstanceRegistrations.append(reg);
break; break;
} }
} }
// if we haven't one already, create one // if we haven't one already, create one
if(reg.m_gui == NULL) {
for(int i = 0; i < m_channelRegistrations.count(); i++) { if(reg.m_gui == NULL)
if(m_channelRegistrations[i].m_channelName == channelConfig.m_channel) { {
qDebug("creating new channel [%s]", qPrintable(channelConfig.m_channel)); for(int i = 0; i < m_channelRegistrations.count(); i++)
{
if(m_channelRegistrations[i].m_channelName == channelConfig.m_channel)
{
qDebug(" - creating new channel [%s]", qPrintable(channelConfig.m_channel));
reg = ChannelInstanceRegistration(channelConfig.m_channel, m_channelRegistrations[i].m_plugin->createChannel(channelConfig.m_channel)); reg = ChannelInstanceRegistration(channelConfig.m_channel, m_channelRegistrations[i].m_plugin->createChannel(channelConfig.m_channel));
break; break;
} }
} }
} }
if(reg.m_gui != NULL) if(reg.m_gui != NULL)
{
qDebug(" - deserializing channel [%s]", qPrintable(channelConfig.m_channel));
reg.m_gui->deserialize(channelConfig.m_config); reg.m_gui->deserialize(channelConfig.m_config);
} }
}
// everything, that is still "available" is not needed anymore // everything, that is still "available" is not needed anymore
for(int i = 0; i < openChannels.count(); i++) { for(int i = 0; i < openChannels.count(); i++)
{
qDebug("destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName)); qDebug("destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
openChannels[i].m_gui->destroy(); openChannels[i].m_gui->destroy();
} }
@ -131,7 +147,7 @@ void PluginManager::loadSettings(const Preset* preset)
*/ */
if(m_sampleSourceName == preset->getSource()) if(m_sampleSourceName == preset->getSource())
{ {
qDebug() << "m_sampleSourcePluginGUI->deserialize (" << m_sampleSourceName .toStdString().c_str() << ")"; qDebug() << " - deserializing source " << qPrintable(m_sampleSourceName);
m_sampleSourcePluginGUI->deserialize(preset->getSourceConfig()); m_sampleSourcePluginGUI->deserialize(preset->getSourceConfig());
} }
} }