1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-22 09:31:10 -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()
{
blockGUISignals(true);
ui->rfBW->setValue(4);
ui->afBW->setValue(3);
ui->volume->setValue(20);
ui->squelch->setValue(-40);
ui->deltaFrequency->setValue(0);
blockGUISignals(false);
applySettings();
}
@ -81,6 +85,9 @@ bool NFMDemodGUI::deserialize(const QByteArray& data)
QByteArray bytetmp;
quint32 u32tmp;
qint32 tmp;
blockGUISignals(true);
d.readS32(1, &tmp, 0);
m_channelMarker->setCenterFrequency(tmp);
d.readS32(2, &tmp, 4);
@ -97,6 +104,9 @@ bool NFMDemodGUI::deserialize(const QByteArray& data)
m_channelMarker->setColor(u32tmp);
d.readS32(8, &tmp, 0);
ui->ctcss->setCurrentIndex(tmp);
blockGUISignals(false);
applySettings();
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[];
explicit NFMDemodGUI(PluginAPI* pluginAPI, QWidget* parent = NULL);
~NFMDemodGUI();
virtual ~NFMDemodGUI();
void blockGUISignals(bool block);
void applySettings();
void leaveEvent(QEvent*);

View File

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

View File

@ -80,7 +80,7 @@
<property name="text">
<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;
&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;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;

View File

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

View File

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

View File

@ -82,41 +82,57 @@ void PluginManager::loadSettings(const Preset* preset)
{
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
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
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);
ChannelInstanceRegistration reg;
// 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));
if(openChannels[i].m_channelName == channelConfig.m_channel) {
for(int i = 0; i < openChannels.count(); i++)
{
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));
reg = openChannels.takeAt(i);
m_channelInstanceRegistrations.append(reg);
break;
}
}
// if we haven't one already, create one
if(reg.m_gui == NULL) {
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));
if(reg.m_gui == NULL)
{
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));
break;
}
}
}
if(reg.m_gui != NULL)
{
qDebug(" - deserializing channel [%s]", qPrintable(channelConfig.m_channel));
reg.m_gui->deserialize(channelConfig.m_config);
}
}
// 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));
openChannels[i].m_gui->destroy();
}
@ -131,7 +147,7 @@ void PluginManager::loadSettings(const Preset* preset)
*/
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());
}
}