mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-09-06 07:07:48 -04:00
Tx ph.1: added sink or source type indicator to preset
This commit is contained in:
parent
9a60088c05
commit
717b240157
@ -217,108 +217,136 @@ void DeviceSinkAPI::freeAll()
|
|||||||
|
|
||||||
void DeviceSinkAPI::loadSinkSettings(const Preset* preset)
|
void DeviceSinkAPI::loadSinkSettings(const Preset* preset)
|
||||||
{
|
{
|
||||||
qDebug("DeviceSinkAPI::loadSinkSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
if (preset->isSourcePreset())
|
||||||
|
|
||||||
if(m_sampleSinkPluginGUI != 0)
|
|
||||||
{
|
{
|
||||||
// TODO: is "source" limiting to source devices?
|
qDebug("DeviceSinkAPI::loadSinkSettings: Preset [%s | %s] is not a sink preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
const QByteArray* sourceConfig = preset->findBestSourceConfig(m_sampleSinkId, m_sampleSinkSerial, m_sampleSinkSequence);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("DeviceSinkAPI::loadSinkSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
|
|
||||||
if (sourceConfig != 0)
|
if(m_sampleSinkPluginGUI != 0)
|
||||||
{
|
{
|
||||||
qDebug() << "DeviceSinkAPI::loadSinkSettings: deserializing sink " << qPrintable(m_sampleSinkId);
|
// TODO: is "source" limiting to source devices?
|
||||||
m_sampleSinkPluginGUI->deserialize(*sourceConfig);
|
const QByteArray* sourceConfig = preset->findBestDeviceConfig(m_sampleSinkId, m_sampleSinkSerial, m_sampleSinkSequence);
|
||||||
}
|
|
||||||
|
|
||||||
qint64 centerFrequency = preset->getCenterFrequency();
|
if (sourceConfig != 0)
|
||||||
m_sampleSinkPluginGUI->setCenterFrequency(centerFrequency);
|
{
|
||||||
|
qDebug() << "DeviceSinkAPI::loadSinkSettings: deserializing sink " << qPrintable(m_sampleSinkId);
|
||||||
|
m_sampleSinkPluginGUI->deserialize(*sourceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 centerFrequency = preset->getCenterFrequency();
|
||||||
|
m_sampleSinkPluginGUI->setCenterFrequency(centerFrequency);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceSinkAPI::saveSinkSettings(Preset* preset)
|
void DeviceSinkAPI::saveSinkSettings(Preset* preset)
|
||||||
{
|
{
|
||||||
qDebug("DeviceSinkAPI::saveSinkSettings");
|
if (preset->isSourcePreset())
|
||||||
|
|
||||||
if(m_sampleSinkPluginGUI != NULL)
|
|
||||||
{
|
{
|
||||||
// TODO: is "source" limiting to source devices?
|
qDebug("DeviceSinkAPI::saveSinkSettings: not a sink preset");
|
||||||
preset->addOrUpdateSourceConfig(m_sampleSinkId, m_sampleSinkSerial, m_sampleSinkSequence, m_sampleSinkPluginGUI->serialize());
|
}
|
||||||
preset->setCenterFrequency(m_sampleSinkPluginGUI->getCenterFrequency());
|
else
|
||||||
|
{
|
||||||
|
qDebug("DeviceSinkAPI::saveSinkSettings: sink preset");
|
||||||
|
|
||||||
|
if(m_sampleSinkPluginGUI != NULL)
|
||||||
|
{
|
||||||
|
// TODO: is "source" limiting to source devices?
|
||||||
|
preset->addOrUpdateDeviceConfig(m_sampleSinkId, m_sampleSinkSerial, m_sampleSinkSequence, m_sampleSinkPluginGUI->serialize());
|
||||||
|
preset->setCenterFrequency(m_sampleSinkPluginGUI->getCenterFrequency());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceSinkAPI::loadChannelSettings(const Preset *preset, PluginAPI *pluginAPI)
|
void DeviceSinkAPI::loadChannelSettings(const Preset *preset, PluginAPI *pluginAPI)
|
||||||
{
|
{
|
||||||
qDebug("DeviceSinkAPI::loadChannelSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
if (preset->isSourcePreset())
|
||||||
|
|
||||||
// Available channel plugins
|
|
||||||
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations();
|
|
||||||
|
|
||||||
// copy currently open channels and clear list
|
|
||||||
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
|
|
||||||
m_channelInstanceRegistrations.clear();
|
|
||||||
|
|
||||||
for(int i = 0; i < preset->getChannelCount(); i++)
|
|
||||||
{
|
{
|
||||||
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
|
qDebug("DeviceSinkAPI::loadChannelSettings: Loading preset [%s | %s] not a sink preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
ChannelInstanceRegistration reg;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("DeviceSinkAPI::loadChannelSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
|
|
||||||
// if we have one instance available already, use it
|
// Available channel plugins
|
||||||
|
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations();
|
||||||
|
|
||||||
for(int i = 0; i < openChannels.count(); i++)
|
// copy currently open channels and clear list
|
||||||
|
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
|
||||||
|
m_channelInstanceRegistrations.clear();
|
||||||
|
|
||||||
|
for(int i = 0; i < preset->getChannelCount(); i++)
|
||||||
{
|
{
|
||||||
qDebug("DeviceSourceAPI::loadChannelSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
|
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
|
||||||
|
ChannelInstanceRegistration reg;
|
||||||
|
|
||||||
if(openChannels[i].m_channelName == channelConfig.m_channel)
|
// if we have one instance available already, use it
|
||||||
|
|
||||||
|
for(int i = 0; i < openChannels.count(); i++)
|
||||||
{
|
{
|
||||||
qDebug("DeviceSourceAPI::loadChannelSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName));
|
qDebug("DeviceSourceAPI::loadChannelSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
|
||||||
reg = openChannels.takeAt(i);
|
|
||||||
m_channelInstanceRegistrations.append(reg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we haven't one already, create one
|
if(openChannels[i].m_channelName == channelConfig.m_channel)
|
||||||
|
|
||||||
if(reg.m_gui == NULL)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < channelRegistrations->count(); i++)
|
|
||||||
{
|
|
||||||
if((*channelRegistrations)[i].m_channelName == channelConfig.m_channel)
|
|
||||||
{
|
{
|
||||||
qDebug("DeviceSourceAPI::loadChannelSettings: creating new channel [%s]", qPrintable(channelConfig.m_channel));
|
qDebug("DeviceSourceAPI::loadChannelSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName));
|
||||||
reg = ChannelInstanceRegistration(channelConfig.m_channel, (*channelRegistrations)[i].m_plugin->createTxChannel(channelConfig.m_channel, this));
|
reg = openChannels.takeAt(i);
|
||||||
|
m_channelInstanceRegistrations.append(reg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we haven't one already, create one
|
||||||
|
|
||||||
|
if(reg.m_gui == NULL)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < channelRegistrations->count(); i++)
|
||||||
|
{
|
||||||
|
if((*channelRegistrations)[i].m_channelName == channelConfig.m_channel)
|
||||||
|
{
|
||||||
|
qDebug("DeviceSourceAPI::loadChannelSettings: creating new channel [%s]", qPrintable(channelConfig.m_channel));
|
||||||
|
reg = ChannelInstanceRegistration(channelConfig.m_channel, (*channelRegistrations)[i].m_plugin->createTxChannel(channelConfig.m_channel, this));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(reg.m_gui != NULL)
|
||||||
|
{
|
||||||
|
qDebug("DeviceSourceAPI::loadChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channel));
|
||||||
|
reg.m_gui->deserialize(channelConfig.m_config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(reg.m_gui != NULL)
|
// everything, that is still "available" is not needed anymore
|
||||||
|
for(int i = 0; i < openChannels.count(); i++)
|
||||||
{
|
{
|
||||||
qDebug("DeviceSourceAPI::loadChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channel));
|
qDebug("DeviceSourceAPI::loadChannelSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
||||||
reg.m_gui->deserialize(channelConfig.m_config);
|
openChannels[i].m_gui->destroy();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// everything, that is still "available" is not needed anymore
|
renameChannelInstances();
|
||||||
for(int i = 0; i < openChannels.count(); i++)
|
|
||||||
{
|
|
||||||
qDebug("DeviceSourceAPI::loadChannelSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
|
||||||
openChannels[i].m_gui->destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renameChannelInstances();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceSinkAPI::saveChannelSettings(Preset *preset)
|
void DeviceSinkAPI::saveChannelSettings(Preset *preset)
|
||||||
{
|
{
|
||||||
qDebug("DeviceSinkAPI::saveChannelSettings");
|
if (preset->isSourcePreset())
|
||||||
|
|
||||||
qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
|
|
||||||
|
|
||||||
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
|
|
||||||
{
|
{
|
||||||
preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize());
|
qDebug("DeviceSinkAPI::saveChannelSettings: not a sink 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++)
|
||||||
|
{
|
||||||
|
preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,106 +219,134 @@ void DeviceSourceAPI::freeAll()
|
|||||||
|
|
||||||
void DeviceSourceAPI::loadSourceSettings(const Preset* preset)
|
void DeviceSourceAPI::loadSourceSettings(const Preset* preset)
|
||||||
{
|
{
|
||||||
qDebug("DeviceAPI::loadSourceSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
if (preset->isSourcePreset())
|
||||||
|
|
||||||
if(m_sampleSourcePluginGUI != 0)
|
|
||||||
{
|
{
|
||||||
const QByteArray* sourceConfig = preset->findBestSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence);
|
qDebug("DeviceAPI::loadSourceSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
|
|
||||||
if (sourceConfig != 0)
|
if(m_sampleSourcePluginGUI != 0)
|
||||||
{
|
{
|
||||||
qDebug() << "DeviceAPI::loadSettings: deserializing source " << qPrintable(m_sampleSourceId);
|
const QByteArray* sourceConfig = preset->findBestDeviceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence);
|
||||||
m_sampleSourcePluginGUI->deserialize(*sourceConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
qint64 centerFrequency = preset->getCenterFrequency();
|
if (sourceConfig != 0)
|
||||||
m_sampleSourcePluginGUI->setCenterFrequency(centerFrequency);
|
{
|
||||||
|
qDebug() << "DeviceAPI::loadSettings: deserializing source " << qPrintable(m_sampleSourceId);
|
||||||
|
m_sampleSourcePluginGUI->deserialize(*sourceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 centerFrequency = preset->getCenterFrequency();
|
||||||
|
m_sampleSourcePluginGUI->setCenterFrequency(centerFrequency);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("DeviceAPI::loadSourceSettings: Loading preset [%s | %s] is not a source preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceSourceAPI::saveSourceSettings(Preset* preset)
|
void DeviceSourceAPI::saveSourceSettings(Preset* preset)
|
||||||
{
|
{
|
||||||
qDebug("DeviceAPI::saveSourceSettings");
|
if (preset->isSourcePreset())
|
||||||
|
|
||||||
if(m_sampleSourcePluginGUI != NULL)
|
|
||||||
{
|
{
|
||||||
preset->addOrUpdateSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence, m_sampleSourcePluginGUI->serialize());
|
qDebug("DeviceAPI::saveSourceSettings");
|
||||||
preset->setCenterFrequency(m_sampleSourcePluginGUI->getCenterFrequency());
|
|
||||||
|
if(m_sampleSourcePluginGUI != NULL)
|
||||||
|
{
|
||||||
|
preset->addOrUpdateDeviceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence, m_sampleSourcePluginGUI->serialize());
|
||||||
|
preset->setCenterFrequency(m_sampleSourcePluginGUI->getCenterFrequency());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("DeviceAPI::saveSourceSettings: not a source preset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceSourceAPI::loadChannelSettings(const Preset *preset, PluginAPI *pluginAPI)
|
void DeviceSourceAPI::loadChannelSettings(const Preset *preset, PluginAPI *pluginAPI)
|
||||||
{
|
{
|
||||||
qDebug("DeviceAPI::loadChannelSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
if (preset->isSourcePreset())
|
||||||
|
|
||||||
// Available channel plugins
|
|
||||||
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations();
|
|
||||||
|
|
||||||
// copy currently open channels and clear list
|
|
||||||
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
|
|
||||||
m_channelInstanceRegistrations.clear();
|
|
||||||
|
|
||||||
for(int i = 0; i < preset->getChannelCount(); i++)
|
|
||||||
{
|
{
|
||||||
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
|
qDebug("DeviceAPI::loadChannelSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
ChannelInstanceRegistration reg;
|
|
||||||
|
|
||||||
// if we have one instance available already, use it
|
// Available channel plugins
|
||||||
|
PluginAPI::ChannelRegistrations *channelRegistrations = pluginAPI->getRxChannelRegistrations();
|
||||||
|
|
||||||
for(int i = 0; i < openChannels.count(); i++)
|
// copy currently open channels and clear list
|
||||||
|
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
|
||||||
|
m_channelInstanceRegistrations.clear();
|
||||||
|
|
||||||
|
for(int i = 0; i < preset->getChannelCount(); i++)
|
||||||
{
|
{
|
||||||
qDebug("DeviceSourceAPI::loadChannelSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
|
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
|
||||||
|
ChannelInstanceRegistration reg;
|
||||||
|
|
||||||
if(openChannels[i].m_channelName == channelConfig.m_channel)
|
// if we have one instance available already, use it
|
||||||
|
|
||||||
|
for(int i = 0; i < openChannels.count(); i++)
|
||||||
{
|
{
|
||||||
qDebug("DeviceSourceAPI::loadChannelSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName));
|
qDebug("DeviceSourceAPI::loadChannelSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
|
||||||
reg = openChannels.takeAt(i);
|
|
||||||
m_channelInstanceRegistrations.append(reg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// if we haven't one already, create one
|
if(openChannels[i].m_channelName == channelConfig.m_channel)
|
||||||
|
|
||||||
if(reg.m_gui == NULL)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < channelRegistrations->count(); i++)
|
|
||||||
{
|
|
||||||
if((*channelRegistrations)[i].m_channelName == channelConfig.m_channel)
|
|
||||||
{
|
{
|
||||||
qDebug("DeviceSourceAPI::loadChannelSettings: creating new channel [%s]", qPrintable(channelConfig.m_channel));
|
qDebug("DeviceSourceAPI::loadChannelSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName));
|
||||||
reg = ChannelInstanceRegistration(channelConfig.m_channel, (*channelRegistrations)[i].m_plugin->createRxChannel(channelConfig.m_channel, this));
|
reg = openChannels.takeAt(i);
|
||||||
|
m_channelInstanceRegistrations.append(reg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we haven't one already, create one
|
||||||
|
|
||||||
|
if(reg.m_gui == NULL)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < channelRegistrations->count(); i++)
|
||||||
|
{
|
||||||
|
if((*channelRegistrations)[i].m_channelName == channelConfig.m_channel)
|
||||||
|
{
|
||||||
|
qDebug("DeviceSourceAPI::loadChannelSettings: creating new channel [%s]", qPrintable(channelConfig.m_channel));
|
||||||
|
reg = ChannelInstanceRegistration(channelConfig.m_channel, (*channelRegistrations)[i].m_plugin->createRxChannel(channelConfig.m_channel, this));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(reg.m_gui != NULL)
|
||||||
|
{
|
||||||
|
qDebug("DeviceSourceAPI::loadChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channel));
|
||||||
|
reg.m_gui->deserialize(channelConfig.m_config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(reg.m_gui != NULL)
|
// everything, that is still "available" is not needed anymore
|
||||||
|
for(int i = 0; i < openChannels.count(); i++)
|
||||||
{
|
{
|
||||||
qDebug("DeviceSourceAPI::loadChannelSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channel));
|
qDebug("DeviceSourceAPI::loadChannelSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
||||||
reg.m_gui->deserialize(channelConfig.m_config);
|
openChannels[i].m_gui->destroy();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// everything, that is still "available" is not needed anymore
|
renameChannelInstances();
|
||||||
for(int i = 0; i < openChannels.count(); i++)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
qDebug("DeviceSourceAPI::loadChannelSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
qDebug("DeviceAPI::loadChannelSettings: Loading preset [%s | %s] not a source preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||||
openChannels[i].m_gui->destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
renameChannelInstances();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceSourceAPI::saveChannelSettings(Preset *preset)
|
void DeviceSourceAPI::saveChannelSettings(Preset *preset)
|
||||||
{
|
{
|
||||||
qDebug("DeviceAPI::saveChannelSettings");
|
if (preset->isSourcePreset())
|
||||||
|
|
||||||
qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
|
|
||||||
|
|
||||||
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
|
|
||||||
{
|
{
|
||||||
preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize());
|
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++)
|
||||||
|
{
|
||||||
|
preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug("DeviceAPI::saveChannelSettings: not a source preset");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ Preset::Preset()
|
|||||||
|
|
||||||
void Preset::resetToDefaults()
|
void Preset::resetToDefaults()
|
||||||
{
|
{
|
||||||
|
m_sourcePreset = true;
|
||||||
m_group = "default";
|
m_group = "default";
|
||||||
m_description = "no name";
|
m_description = "no name";
|
||||||
m_centerFrequency = 0;
|
m_centerFrequency = 0;
|
||||||
@ -36,19 +37,19 @@ QByteArray Preset::serialize() const
|
|||||||
s.writeBlob(4, m_layout);
|
s.writeBlob(4, m_layout);
|
||||||
s.writeBlob(5, m_spectrumConfig);
|
s.writeBlob(5, m_spectrumConfig);
|
||||||
|
|
||||||
s.writeS32(20, m_sourceConfigs.size());
|
s.writeS32(20, m_deviceConfigs.size());
|
||||||
|
|
||||||
for (int i = 0; i < m_sourceConfigs.size(); i++)
|
for (int i = 0; i < m_deviceConfigs.size(); i++)
|
||||||
{
|
{
|
||||||
s.writeString(24 + i*4, m_sourceConfigs[i].m_sourceId);
|
s.writeString(24 + i*4, m_deviceConfigs[i].m_deviceId);
|
||||||
s.writeString(25 + i*4, m_sourceConfigs[i].m_sourceSerial);
|
s.writeString(25 + i*4, m_deviceConfigs[i].m_deviceSerial);
|
||||||
s.writeS32(26 + i*4, m_sourceConfigs[i].m_sourceSequence);
|
s.writeS32(26 + i*4, m_deviceConfigs[i].m_deviceSequence);
|
||||||
s.writeBlob(27 + i*4, m_sourceConfigs[i].m_config);
|
s.writeBlob(27 + i*4, m_deviceConfigs[i].m_config);
|
||||||
|
|
||||||
qDebug("Preset::serialize: source: id: %s, ser: %s, seq: %d",
|
qDebug("Preset::serialize: source: id: %s, ser: %s, seq: %d",
|
||||||
qPrintable(m_sourceConfigs[i].m_sourceId),
|
qPrintable(m_deviceConfigs[i].m_deviceId),
|
||||||
qPrintable(m_sourceConfigs[i].m_sourceSerial),
|
qPrintable(m_deviceConfigs[i].m_deviceSerial),
|
||||||
m_sourceConfigs[i].m_sourceSequence);
|
m_deviceConfigs[i].m_deviceSequence);
|
||||||
|
|
||||||
if (i >= (200-23)/4) // full!
|
if (i >= (200-23)/4) // full!
|
||||||
{
|
{
|
||||||
@ -100,7 +101,7 @@ bool Preset::deserialize(const QByteArray& data)
|
|||||||
sourcesCount = ((200-23)/4) - 1;
|
sourcesCount = ((200-23)/4) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sourceConfigs.clear();
|
m_deviceConfigs.clear();
|
||||||
|
|
||||||
for (int i = 0; i < sourcesCount; i++)
|
for (int i = 0; i < sourcesCount; i++)
|
||||||
{
|
{
|
||||||
@ -120,7 +121,7 @@ bool Preset::deserialize(const QByteArray& data)
|
|||||||
qPrintable(sourceSerial),
|
qPrintable(sourceSerial),
|
||||||
sourceSequence);
|
sourceSequence);
|
||||||
|
|
||||||
m_sourceConfigs.append(SourceConfig(sourceId, sourceSerial, sourceSequence, sourceConfig));
|
m_deviceConfigs.append(DeviceConfig(sourceId, sourceSerial, sourceSequence, sourceConfig));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,27 +151,27 @@ bool Preset::deserialize(const QByteArray& data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Preset::addOrUpdateSourceConfig(const QString& sourceId,
|
void Preset::addOrUpdateDeviceConfig(const QString& sourceId,
|
||||||
const QString& sourceSerial,
|
const QString& sourceSerial,
|
||||||
int sourceSequence,
|
int sourceSequence,
|
||||||
const QByteArray& config)
|
const QByteArray& config)
|
||||||
{
|
{
|
||||||
SourceConfigs::iterator it = m_sourceConfigs.begin();
|
DeviceeConfigs::iterator it = m_deviceConfigs.begin();
|
||||||
|
|
||||||
for (; it != m_sourceConfigs.end(); ++it)
|
for (; it != m_deviceConfigs.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it->m_sourceId == sourceId)
|
if (it->m_deviceId == sourceId)
|
||||||
{
|
{
|
||||||
if (sourceSerial.isNull() || sourceSerial.isEmpty())
|
if (sourceSerial.isNull() || sourceSerial.isEmpty())
|
||||||
{
|
{
|
||||||
if (it->m_sourceSequence == sourceSequence)
|
if (it->m_deviceSequence == sourceSequence)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (it->m_sourceSerial == sourceSerial)
|
if (it->m_deviceSerial == sourceSerial)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -178,9 +179,9 @@ void Preset::addOrUpdateSourceConfig(const QString& sourceId,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it == m_sourceConfigs.end())
|
if (it == m_deviceConfigs.end())
|
||||||
{
|
{
|
||||||
m_sourceConfigs.append(SourceConfig(sourceId, sourceSerial, sourceSequence, config));
|
m_deviceConfigs.append(DeviceConfig(sourceId, sourceSerial, sourceSequence, config));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -188,37 +189,37 @@ void Preset::addOrUpdateSourceConfig(const QString& sourceId,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QByteArray* Preset::findBestSourceConfig(const QString& sourceId,
|
const QByteArray* Preset::findBestDeviceConfig(const QString& sourceId,
|
||||||
const QString& sourceSerial,
|
const QString& sourceSerial,
|
||||||
int sourceSequence) const
|
int sourceSequence) const
|
||||||
{
|
{
|
||||||
SourceConfigs::const_iterator it = m_sourceConfigs.begin();
|
DeviceeConfigs::const_iterator it = m_deviceConfigs.begin();
|
||||||
SourceConfigs::const_iterator itFirstOfKind = m_sourceConfigs.end();
|
DeviceeConfigs::const_iterator itFirstOfKind = m_deviceConfigs.end();
|
||||||
SourceConfigs::const_iterator itMatchSequence = m_sourceConfigs.end();
|
DeviceeConfigs::const_iterator itMatchSequence = m_deviceConfigs.end();
|
||||||
|
|
||||||
for (; it != m_sourceConfigs.end(); ++it)
|
for (; it != m_deviceConfigs.end(); ++it)
|
||||||
{
|
{
|
||||||
if (it->m_sourceId == sourceId)
|
if (it->m_deviceId == sourceId)
|
||||||
{
|
{
|
||||||
if (itFirstOfKind == m_sourceConfigs.end())
|
if (itFirstOfKind == m_deviceConfigs.end())
|
||||||
{
|
{
|
||||||
itFirstOfKind = it;
|
itFirstOfKind = it;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceSerial.isNull() || sourceSerial.isEmpty())
|
if (sourceSerial.isNull() || sourceSerial.isEmpty())
|
||||||
{
|
{
|
||||||
if (it->m_sourceSequence == sourceSequence)
|
if (it->m_deviceSequence == sourceSequence)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (it->m_sourceSerial == sourceSerial)
|
if (it->m_deviceSerial == sourceSerial)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(it->m_sourceSequence == sourceSequence)
|
else if(it->m_deviceSequence == sourceSequence)
|
||||||
{
|
{
|
||||||
itMatchSequence = it;
|
itMatchSequence = it;
|
||||||
}
|
}
|
||||||
@ -226,16 +227,16 @@ const QByteArray* Preset::findBestSourceConfig(const QString& sourceId,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it == m_sourceConfigs.end()) // no exact match
|
if (it == m_deviceConfigs.end()) // no exact match
|
||||||
{
|
{
|
||||||
if (itMatchSequence != m_sourceConfigs.end()) // match sequence ?
|
if (itMatchSequence != m_deviceConfigs.end()) // match sequence ?
|
||||||
{
|
{
|
||||||
qDebug("Preset::findBestSourceConfig: sequence matched: id: %s seq: %d", qPrintable(itMatchSequence->m_sourceId), itMatchSequence->m_sourceSequence);
|
qDebug("Preset::findBestSourceConfig: sequence matched: id: %s seq: %d", qPrintable(itMatchSequence->m_deviceId), itMatchSequence->m_deviceSequence);
|
||||||
return &(itMatchSequence->m_config);
|
return &(itMatchSequence->m_config);
|
||||||
}
|
}
|
||||||
else if (itFirstOfKind != m_sourceConfigs.end()) // match source type ?
|
else if (itFirstOfKind != m_deviceConfigs.end()) // match source type ?
|
||||||
{
|
{
|
||||||
qDebug("Preset::findBestSourceConfig: first of kind matched: id: %s", qPrintable(itFirstOfKind->m_sourceId));
|
qDebug("Preset::findBestSourceConfig: first of kind matched: id: %s", qPrintable(itFirstOfKind->m_deviceId));
|
||||||
return &(itFirstOfKind->m_config);
|
return &(itFirstOfKind->m_config);
|
||||||
}
|
}
|
||||||
else // definitely not found !
|
else // definitely not found !
|
||||||
@ -246,7 +247,7 @@ const QByteArray* Preset::findBestSourceConfig(const QString& sourceId,
|
|||||||
}
|
}
|
||||||
else // exact match
|
else // exact match
|
||||||
{
|
{
|
||||||
qDebug("Preset::findBestSourceConfig: serial matched (exact): id: %s ser: %s", qPrintable(it->m_sourceId), qPrintable(it->m_sourceSerial));
|
qDebug("Preset::findBestSourceConfig: serial matched (exact): id: %s ser: %s", qPrintable(it->m_deviceId), qPrintable(it->m_deviceSerial));
|
||||||
return &(it->m_config);
|
return &(it->m_config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,28 +18,32 @@ public:
|
|||||||
};
|
};
|
||||||
typedef QList<ChannelConfig> ChannelConfigs;
|
typedef QList<ChannelConfig> ChannelConfigs;
|
||||||
|
|
||||||
struct SourceConfig
|
struct DeviceConfig
|
||||||
{
|
{
|
||||||
QString m_sourceId;
|
QString m_deviceId;
|
||||||
QString m_sourceSerial;
|
QString m_deviceSerial;
|
||||||
int m_sourceSequence;
|
int m_deviceSequence;
|
||||||
QByteArray m_config;
|
QByteArray m_config;
|
||||||
|
|
||||||
SourceConfig(const QString& sourceId,
|
DeviceConfig(const QString& deviceId,
|
||||||
const QString& sourceSerial,
|
const QString& deviceSerial,
|
||||||
int sourceSequence,
|
int deviceSequence,
|
||||||
const QByteArray& config) :
|
const QByteArray& config) :
|
||||||
m_sourceId(sourceId),
|
m_deviceId(deviceId),
|
||||||
m_sourceSerial(sourceSerial),
|
m_deviceSerial(deviceSerial),
|
||||||
m_sourceSequence(sourceSequence),
|
m_deviceSequence(deviceSequence),
|
||||||
m_config(config)
|
m_config(config)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
typedef QList<SourceConfig> SourceConfigs;
|
typedef QList<DeviceConfig> DeviceeConfigs;
|
||||||
|
|
||||||
Preset();
|
Preset();
|
||||||
|
|
||||||
void resetToDefaults();
|
void resetToDefaults();
|
||||||
|
|
||||||
|
void setSourcePreset(bool isSourcePreset) { m_sourcePreset = isSourcePreset; }
|
||||||
|
bool isSourcePreset() const { return m_sourcePreset; }
|
||||||
|
|
||||||
QByteArray serialize() const;
|
QByteArray serialize() const;
|
||||||
bool deserialize(const QByteArray& data);
|
bool deserialize(const QByteArray& data);
|
||||||
|
|
||||||
@ -61,19 +65,19 @@ public:
|
|||||||
int getChannelCount() const { return m_channelConfigs.count(); }
|
int getChannelCount() const { return m_channelConfigs.count(); }
|
||||||
const ChannelConfig& getChannelConfig(int index) const { return m_channelConfigs.at(index); }
|
const ChannelConfig& getChannelConfig(int index) const { return m_channelConfigs.at(index); }
|
||||||
|
|
||||||
void setSourceConfig(const QString& sourceId, const QString& sourceSerial, int sourceSequence, const QByteArray& config)
|
void setDeviceConfig(const QString& deviceId, const QString& deviceSerial, int deviceSequence, const QByteArray& config)
|
||||||
{
|
{
|
||||||
addOrUpdateSourceConfig(sourceId, sourceSerial, sourceSequence, config);
|
addOrUpdateDeviceConfig(deviceId, deviceSerial, deviceSequence, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addOrUpdateSourceConfig(const QString& sourceId,
|
void addOrUpdateDeviceConfig(const QString& deviceId,
|
||||||
const QString& sourceSerial,
|
const QString& deviceSerial,
|
||||||
int sourceSequence,
|
int deviceSequence,
|
||||||
const QByteArray& config);
|
const QByteArray& config);
|
||||||
|
|
||||||
const QByteArray* findBestSourceConfig(const QString& sourceId,
|
const QByteArray* findBestDeviceConfig(const QString& deviceId,
|
||||||
const QString& sourceSerial,
|
const QString& deviceSerial,
|
||||||
int sourceSequence) const;
|
int deviceSequence) const;
|
||||||
|
|
||||||
static bool presetCompare(const Preset *p1, Preset *p2)
|
static bool presetCompare(const Preset *p1, Preset *p2)
|
||||||
{
|
{
|
||||||
@ -85,7 +89,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// group and preset description
|
bool m_sourcePreset;
|
||||||
|
|
||||||
|
// group and preset description
|
||||||
QString m_group;
|
QString m_group;
|
||||||
QString m_description;
|
QString m_description;
|
||||||
quint64 m_centerFrequency;
|
quint64 m_centerFrequency;
|
||||||
@ -106,8 +112,8 @@ protected:
|
|||||||
// channels and configurations
|
// channels and configurations
|
||||||
ChannelConfigs m_channelConfigs;
|
ChannelConfigs m_channelConfigs;
|
||||||
|
|
||||||
// sources and configurations
|
// devices and configurations
|
||||||
SourceConfigs m_sourceConfigs;
|
DeviceeConfigs m_deviceConfigs;
|
||||||
|
|
||||||
// screen and dock layout
|
// screen and dock layout
|
||||||
QByteArray m_layout;
|
QByteArray m_layout;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user