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

Tx ph.1: Corrected Tx preset setup

This commit is contained in:
f4exb 2016-10-22 10:10:17 +02:00
parent e24202ad2a
commit 118c335225
3 changed files with 34 additions and 27 deletions

View File

@ -219,20 +219,19 @@ void DeviceSinkAPI::loadSinkSettings(const Preset* preset)
{
if (preset->isSourcePreset())
{
qDebug("DeviceSinkAPI::loadSinkSettings: Preset [%s | %s] is not a sink preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
qDebug("DeviceSinkAPI::loadSinkSettings: Preset [%s | %s] is not a sink preset", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
}
else
{
qDebug("DeviceSinkAPI::loadSinkSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
qDebug("DeviceSinkAPI::loadSinkSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
if(m_sampleSinkPluginGUI != 0)
{
// TODO: is "source" limiting to source devices?
const QByteArray* sourceConfig = preset->findBestDeviceConfig(m_sampleSinkId, m_sampleSinkSerial, m_sampleSinkSequence);
if (sourceConfig != 0)
{
qDebug() << "DeviceSinkAPI::loadSinkSettings: deserializing sink " << qPrintable(m_sampleSinkId);
qDebug("DeviceSinkAPI::loadSinkSettings: deserializing sink: %s", qPrintable(m_sampleSinkId));
m_sampleSinkPluginGUI->deserialize(*sourceConfig);
}
@ -250,14 +249,16 @@ void DeviceSinkAPI::saveSinkSettings(Preset* preset)
}
else
{
qDebug("DeviceSinkAPI::saveSinkSettings: sink preset");
if(m_sampleSinkPluginGUI != NULL)
{
// TODO: is "source" limiting to source devices?
qDebug("DeviceSinkAPI::saveSourceSettings: %s saved", qPrintable(m_sampleSinkPluginGUI->getName()));
preset->addOrUpdateDeviceConfig(m_sampleSinkId, m_sampleSinkSerial, m_sampleSinkSequence, m_sampleSinkPluginGUI->serialize());
preset->setCenterFrequency(m_sampleSinkPluginGUI->getCenterFrequency());
}
else
{
qDebug("DeviceSinkAPI::saveSinkSettings: no sink");
}
}
}
@ -265,11 +266,11 @@ void DeviceSinkAPI::loadChannelSettings(const Preset *preset, PluginAPI *pluginA
{
if (preset->isSourcePreset())
{
qDebug("DeviceSinkAPI::loadChannelSettings: Loading preset [%s | %s] not a sink preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
qDebug("DeviceSinkAPI::loadChannelSettings: Loading preset [%s | %s] not a sink preset", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
}
else
{
qDebug("DeviceSinkAPI::loadChannelSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
qDebug("DeviceSinkAPI::loadChannelSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
// Available channel plugins
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations();
@ -278,6 +279,8 @@ void DeviceSinkAPI::loadChannelSettings(const Preset *preset, PluginAPI *pluginA
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
m_channelInstanceRegistrations.clear();
qDebug("DeviceSinkAPI::loadChannelSettings: %d channel(s) in preset", preset->getChannelCount());
for(int i = 0; i < preset->getChannelCount(); i++)
{
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
@ -287,11 +290,11 @@ void DeviceSinkAPI::loadChannelSettings(const Preset *preset, PluginAPI *pluginA
for(int i = 0; i < openChannels.count(); i++)
{
qDebug("DeviceSourceAPI::loadChannelSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
qDebug("DeviceSinkAPI::loadChannelSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
if(openChannels[i].m_channelName == channelConfig.m_channel)
{
qDebug("DeviceSourceAPI::loadChannelSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName));
qDebug("DeviceSinkAPI::loadChannelSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName));
reg = openChannels.takeAt(i);
m_channelInstanceRegistrations.append(reg);
break;
@ -306,7 +309,7 @@ void DeviceSinkAPI::loadChannelSettings(const Preset *preset, PluginAPI *pluginA
{
if((*channelRegistrations)[i].m_channelName == channelConfig.m_channel)
{
qDebug("DeviceSourceAPI::loadChannelSettings: creating new channel [%s]", qPrintable(channelConfig.m_channel));
qDebug("DeviceSinkAPI::loadChannelSettings: creating new channel [%s]", qPrintable(channelConfig.m_channel));
reg = ChannelInstanceRegistration(channelConfig.m_channel, (*channelRegistrations)[i].m_plugin->createTxChannel(channelConfig.m_channel, this));
break;
}
@ -315,7 +318,7 @@ void DeviceSinkAPI::loadChannelSettings(const Preset *preset, PluginAPI *pluginA
if(reg.m_gui != NULL)
{
qDebug("DeviceSourceAPI::loadChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channel));
qDebug("DeviceSinkAPI::loadChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channel));
reg.m_gui->deserialize(channelConfig.m_config);
}
}
@ -323,7 +326,7 @@ void DeviceSinkAPI::loadChannelSettings(const Preset *preset, PluginAPI *pluginA
// everything, that is still "available" is not needed anymore
for(int i = 0; i < openChannels.count(); i++)
{
qDebug("DeviceSourceAPI::loadChannelSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
qDebug("DeviceSinkAPI::loadChannelSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
openChannels[i].m_gui->destroy();
}
@ -339,12 +342,11 @@ void DeviceSinkAPI::saveChannelSettings(Preset *preset)
}
else
{
qDebug("DeviceSinkAPI::saveChannelSettings: sink preset");
qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
{
qDebug("DeviceSinkAPI::saveChannelSettings: channel [%s] saved", qPrintable(m_channelInstanceRegistrations[i].m_channelName));
preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize());
}
}

View File

@ -221,7 +221,7 @@ void DeviceSourceAPI::loadSourceSettings(const Preset* preset)
{
if (preset->isSourcePreset())
{
qDebug("DeviceAPI::loadSourceSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
qDebug("DeviceSourceAPI::loadSourceSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
if(m_sampleSourcePluginGUI != 0)
{
@ -229,7 +229,7 @@ void DeviceSourceAPI::loadSourceSettings(const Preset* preset)
if (sourceConfig != 0)
{
qDebug() << "DeviceAPI::loadSettings: deserializing source " << qPrintable(m_sampleSourceId);
qDebug("DeviceSourceAPI::loadSettings: deserializing source %s", qPrintable(m_sampleSourceId));
m_sampleSourcePluginGUI->deserialize(*sourceConfig);
}
@ -239,7 +239,7 @@ void DeviceSourceAPI::loadSourceSettings(const Preset* preset)
}
else
{
qDebug("DeviceAPI::loadSourceSettings: Loading preset [%s | %s] is not a source preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
qDebug("DeviceSourceAPI::loadSourceSettings: Loading preset [%s | %s] is not a source preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
}
}
@ -247,17 +247,20 @@ void DeviceSourceAPI::saveSourceSettings(Preset* preset)
{
if (preset->isSourcePreset())
{
qDebug("DeviceAPI::saveSourceSettings");
if(m_sampleSourcePluginGUI != NULL)
{
qDebug("DeviceSourceAPI::saveSourceSettings: %s saved", qPrintable(m_sampleSourcePluginGUI->getName()));
preset->addOrUpdateDeviceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence, m_sampleSourcePluginGUI->serialize());
preset->setCenterFrequency(m_sampleSourcePluginGUI->getCenterFrequency());
}
else
{
qDebug("DeviceSourceAPI::saveSourceSettings: no source");
}
}
else
{
qDebug("DeviceAPI::saveSourceSettings: not a source preset");
qDebug("DeviceSourceAPI::saveSourceSettings: not a source preset");
}
}
@ -265,7 +268,7 @@ void DeviceSourceAPI::loadChannelSettings(const Preset *preset, PluginAPI *plugi
{
if (preset->isSourcePreset())
{
qDebug("DeviceAPI::loadChannelSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
qDebug("DeviceSourceAPI::loadChannelSettings: Loading preset [%s | %s]", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
// Available channel plugins
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations();
@ -274,6 +277,8 @@ void DeviceSourceAPI::loadChannelSettings(const Preset *preset, PluginAPI *plugi
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
m_channelInstanceRegistrations.clear();
qDebug("DeviceSourceAPI::loadChannelSettings: %d channel(s) in preset", preset->getChannelCount());
for(int i = 0; i < preset->getChannelCount(); i++)
{
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
@ -327,7 +332,7 @@ void DeviceSourceAPI::loadChannelSettings(const Preset *preset, PluginAPI *plugi
}
else
{
qDebug("DeviceAPI::loadChannelSettings: Loading preset [%s | %s] not a source preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
qDebug("DeviceSourceAPI::loadChannelSettings: Loading preset [%s | %s] not a source preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
}
}
@ -335,18 +340,17 @@ void DeviceSourceAPI::saveChannelSettings(Preset *preset)
{
if (preset->isSourcePreset())
{
qDebug("DeviceAPI::saveChannelSettings");
qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
{
qDebug("DeviceSourceAPI::saveChannelSettings: channel [%s] saved", qPrintable(m_channelInstanceRegistrations[i].m_channelName));
preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize());
}
}
else
{
qDebug("DeviceAPI::saveChannelSettings: not a source preset");
qDebug("DeviceSourceAPI::saveChannelSettings: not a source preset");
}
}

View File

@ -439,6 +439,7 @@ void MainWindow::savePresetSettings(Preset* preset, int tabIndex)
{
preset->setSpectrumConfig(deviceUI->m_spectrumGUI->serialize());
preset->clearChannels();
preset->setSourcePreset(false);
deviceUI->m_deviceSinkAPI->saveChannelSettings(preset);
deviceUI->m_deviceSinkAPI->saveSinkSettings(preset);
}