mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-03-31 16:48:29 -04:00
Tx ph.1: added sink or source type indicator to preset
This commit is contained in:
parent
9a60088c05
commit
717b240157
sdrbase
@ -217,108 +217,136 @@ void DeviceSinkAPI::freeAll()
|
||||
|
||||
void DeviceSinkAPI::loadSinkSettings(const Preset* preset)
|
||||
{
|
||||
qDebug("DeviceSinkAPI::loadSinkSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||
|
||||
if(m_sampleSinkPluginGUI != 0)
|
||||
if (preset->isSourcePreset())
|
||||
{
|
||||
// TODO: is "source" limiting to source devices?
|
||||
const QByteArray* sourceConfig = preset->findBestSourceConfig(m_sampleSinkId, m_sampleSinkSerial, m_sampleSinkSequence);
|
||||
qDebug("DeviceSinkAPI::loadSinkSettings: Preset [%s | %s] is not a sink preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||
}
|
||||
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);
|
||||
m_sampleSinkPluginGUI->deserialize(*sourceConfig);
|
||||
}
|
||||
// TODO: is "source" limiting to source devices?
|
||||
const QByteArray* sourceConfig = preset->findBestDeviceConfig(m_sampleSinkId, m_sampleSinkSerial, m_sampleSinkSequence);
|
||||
|
||||
qint64 centerFrequency = preset->getCenterFrequency();
|
||||
m_sampleSinkPluginGUI->setCenterFrequency(centerFrequency);
|
||||
if (sourceConfig != 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
qDebug("DeviceSinkAPI::saveSinkSettings");
|
||||
|
||||
if(m_sampleSinkPluginGUI != NULL)
|
||||
if (preset->isSourcePreset())
|
||||
{
|
||||
// TODO: is "source" limiting to source devices?
|
||||
preset->addOrUpdateSourceConfig(m_sampleSinkId, m_sampleSinkSerial, m_sampleSinkSequence, m_sampleSinkPluginGUI->serialize());
|
||||
preset->setCenterFrequency(m_sampleSinkPluginGUI->getCenterFrequency());
|
||||
qDebug("DeviceSinkAPI::saveSinkSettings: not a sink preset");
|
||||
}
|
||||
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)
|
||||
{
|
||||
qDebug("DeviceSinkAPI::loadChannelSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||
|
||||
// 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++)
|
||||
if (preset->isSourcePreset())
|
||||
{
|
||||
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
|
||||
ChannelInstanceRegistration reg;
|
||||
qDebug("DeviceSinkAPI::loadChannelSettings: Loading preset [%s | %s] not a sink preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||
}
|
||||
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));
|
||||
reg = openChannels.takeAt(i);
|
||||
m_channelInstanceRegistrations.append(reg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
qDebug("DeviceSourceAPI::loadChannelSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
|
||||
|
||||
// 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)
|
||||
if(openChannels[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));
|
||||
qDebug("DeviceSourceAPI::loadChannelSettings: 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 < 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));
|
||||
reg.m_gui->deserialize(channelConfig.m_config);
|
||||
qDebug("DeviceSourceAPI::loadChannelSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
||||
openChannels[i].m_gui->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
// 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));
|
||||
openChannels[i].m_gui->destroy();
|
||||
renameChannelInstances();
|
||||
}
|
||||
|
||||
renameChannelInstances();
|
||||
}
|
||||
|
||||
void DeviceSinkAPI::saveChannelSettings(Preset *preset)
|
||||
{
|
||||
qDebug("DeviceSinkAPI::saveChannelSettings");
|
||||
|
||||
qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
|
||||
|
||||
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
|
||||
if (preset->isSourcePreset())
|
||||
{
|
||||
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)
|
||||
{
|
||||
qDebug("DeviceAPI::loadSourceSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||
|
||||
if(m_sampleSourcePluginGUI != 0)
|
||||
if (preset->isSourcePreset())
|
||||
{
|
||||
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);
|
||||
m_sampleSourcePluginGUI->deserialize(*sourceConfig);
|
||||
}
|
||||
const QByteArray* sourceConfig = preset->findBestDeviceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence);
|
||||
|
||||
qint64 centerFrequency = preset->getCenterFrequency();
|
||||
m_sampleSourcePluginGUI->setCenterFrequency(centerFrequency);
|
||||
if (sourceConfig != 0)
|
||||
{
|
||||
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)
|
||||
{
|
||||
qDebug("DeviceAPI::saveSourceSettings");
|
||||
|
||||
if(m_sampleSourcePluginGUI != NULL)
|
||||
if (preset->isSourcePreset())
|
||||
{
|
||||
preset->addOrUpdateSourceConfig(m_sampleSourceId, m_sampleSourceSerial, m_sampleSourceSequence, m_sampleSourcePluginGUI->serialize());
|
||||
preset->setCenterFrequency(m_sampleSourcePluginGUI->getCenterFrequency());
|
||||
qDebug("DeviceAPI::saveSourceSettings");
|
||||
|
||||
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)
|
||||
{
|
||||
qDebug("DeviceAPI::loadChannelSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||
|
||||
// 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++)
|
||||
if (preset->isSourcePreset())
|
||||
{
|
||||
const Preset::ChannelConfig& channelConfig = preset->getChannelConfig(i);
|
||||
ChannelInstanceRegistration reg;
|
||||
qDebug("DeviceAPI::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));
|
||||
reg = openChannels.takeAt(i);
|
||||
m_channelInstanceRegistrations.append(reg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
qDebug("DeviceSourceAPI::loadChannelSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
|
||||
|
||||
// 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)
|
||||
if(openChannels[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));
|
||||
qDebug("DeviceSourceAPI::loadChannelSettings: 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 < 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));
|
||||
reg.m_gui->deserialize(channelConfig.m_config);
|
||||
qDebug("DeviceSourceAPI::loadChannelSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
||||
openChannels[i].m_gui->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
// everything, that is still "available" is not needed anymore
|
||||
for(int i = 0; i < openChannels.count(); i++)
|
||||
renameChannelInstances();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug("DeviceSourceAPI::loadChannelSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
||||
openChannels[i].m_gui->destroy();
|
||||
qDebug("DeviceAPI::loadChannelSettings: Loading preset [%s | %s] not a source preset\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||
}
|
||||
|
||||
renameChannelInstances();
|
||||
}
|
||||
|
||||
void DeviceSourceAPI::saveChannelSettings(Preset *preset)
|
||||
{
|
||||
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++)
|
||||
if (preset->isSourcePreset())
|
||||
{
|
||||
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()
|
||||
{
|
||||
m_sourcePreset = true;
|
||||
m_group = "default";
|
||||
m_description = "no name";
|
||||
m_centerFrequency = 0;
|
||||
@ -36,19 +37,19 @@ QByteArray Preset::serialize() const
|
||||
s.writeBlob(4, m_layout);
|
||||
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(25 + i*4, m_sourceConfigs[i].m_sourceSerial);
|
||||
s.writeS32(26 + i*4, m_sourceConfigs[i].m_sourceSequence);
|
||||
s.writeBlob(27 + i*4, m_sourceConfigs[i].m_config);
|
||||
s.writeString(24 + i*4, m_deviceConfigs[i].m_deviceId);
|
||||
s.writeString(25 + i*4, m_deviceConfigs[i].m_deviceSerial);
|
||||
s.writeS32(26 + i*4, m_deviceConfigs[i].m_deviceSequence);
|
||||
s.writeBlob(27 + i*4, m_deviceConfigs[i].m_config);
|
||||
|
||||
qDebug("Preset::serialize: source: id: %s, ser: %s, seq: %d",
|
||||
qPrintable(m_sourceConfigs[i].m_sourceId),
|
||||
qPrintable(m_sourceConfigs[i].m_sourceSerial),
|
||||
m_sourceConfigs[i].m_sourceSequence);
|
||||
qPrintable(m_deviceConfigs[i].m_deviceId),
|
||||
qPrintable(m_deviceConfigs[i].m_deviceSerial),
|
||||
m_deviceConfigs[i].m_deviceSequence);
|
||||
|
||||
if (i >= (200-23)/4) // full!
|
||||
{
|
||||
@ -100,7 +101,7 @@ bool Preset::deserialize(const QByteArray& data)
|
||||
sourcesCount = ((200-23)/4) - 1;
|
||||
}
|
||||
|
||||
m_sourceConfigs.clear();
|
||||
m_deviceConfigs.clear();
|
||||
|
||||
for (int i = 0; i < sourcesCount; i++)
|
||||
{
|
||||
@ -120,7 +121,7 @@ bool Preset::deserialize(const QByteArray& data)
|
||||
qPrintable(sourceSerial),
|
||||
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,
|
||||
int sourceSequence,
|
||||
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 (it->m_sourceSequence == sourceSequence)
|
||||
if (it->m_deviceSequence == sourceSequence)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (it->m_sourceSerial == sourceSerial)
|
||||
if (it->m_deviceSerial == sourceSerial)
|
||||
{
|
||||
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
|
||||
{
|
||||
@ -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,
|
||||
int sourceSequence) const
|
||||
{
|
||||
SourceConfigs::const_iterator it = m_sourceConfigs.begin();
|
||||
SourceConfigs::const_iterator itFirstOfKind = m_sourceConfigs.end();
|
||||
SourceConfigs::const_iterator itMatchSequence = m_sourceConfigs.end();
|
||||
DeviceeConfigs::const_iterator it = m_deviceConfigs.begin();
|
||||
DeviceeConfigs::const_iterator itFirstOfKind = m_deviceConfigs.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;
|
||||
}
|
||||
|
||||
if (sourceSerial.isNull() || sourceSerial.isEmpty())
|
||||
{
|
||||
if (it->m_sourceSequence == sourceSequence)
|
||||
if (it->m_deviceSequence == sourceSequence)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (it->m_sourceSerial == sourceSerial)
|
||||
if (it->m_deviceSerial == sourceSerial)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if(it->m_sourceSequence == sourceSequence)
|
||||
else if(it->m_deviceSequence == sourceSequence)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
else // definitely not found !
|
||||
@ -246,7 +247,7 @@ const QByteArray* Preset::findBestSourceConfig(const QString& sourceId,
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -18,28 +18,32 @@ public:
|
||||
};
|
||||
typedef QList<ChannelConfig> ChannelConfigs;
|
||||
|
||||
struct SourceConfig
|
||||
struct DeviceConfig
|
||||
{
|
||||
QString m_sourceId;
|
||||
QString m_sourceSerial;
|
||||
int m_sourceSequence;
|
||||
QString m_deviceId;
|
||||
QString m_deviceSerial;
|
||||
int m_deviceSequence;
|
||||
QByteArray m_config;
|
||||
|
||||
SourceConfig(const QString& sourceId,
|
||||
const QString& sourceSerial,
|
||||
int sourceSequence,
|
||||
DeviceConfig(const QString& deviceId,
|
||||
const QString& deviceSerial,
|
||||
int deviceSequence,
|
||||
const QByteArray& config) :
|
||||
m_sourceId(sourceId),
|
||||
m_sourceSerial(sourceSerial),
|
||||
m_sourceSequence(sourceSequence),
|
||||
m_deviceId(deviceId),
|
||||
m_deviceSerial(deviceSerial),
|
||||
m_deviceSequence(deviceSequence),
|
||||
m_config(config)
|
||||
{ }
|
||||
};
|
||||
typedef QList<SourceConfig> SourceConfigs;
|
||||
typedef QList<DeviceConfig> DeviceeConfigs;
|
||||
|
||||
Preset();
|
||||
|
||||
void resetToDefaults();
|
||||
|
||||
void setSourcePreset(bool isSourcePreset) { m_sourcePreset = isSourcePreset; }
|
||||
bool isSourcePreset() const { return m_sourcePreset; }
|
||||
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
|
||||
@ -61,19 +65,19 @@ public:
|
||||
int getChannelCount() const { return m_channelConfigs.count(); }
|
||||
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,
|
||||
const QString& sourceSerial,
|
||||
int sourceSequence,
|
||||
void addOrUpdateDeviceConfig(const QString& deviceId,
|
||||
const QString& deviceSerial,
|
||||
int deviceSequence,
|
||||
const QByteArray& config);
|
||||
|
||||
const QByteArray* findBestSourceConfig(const QString& sourceId,
|
||||
const QString& sourceSerial,
|
||||
int sourceSequence) const;
|
||||
const QByteArray* findBestDeviceConfig(const QString& deviceId,
|
||||
const QString& deviceSerial,
|
||||
int deviceSequence) const;
|
||||
|
||||
static bool presetCompare(const Preset *p1, Preset *p2)
|
||||
{
|
||||
@ -85,7 +89,9 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// group and preset description
|
||||
bool m_sourcePreset;
|
||||
|
||||
// group and preset description
|
||||
QString m_group;
|
||||
QString m_description;
|
||||
quint64 m_centerFrequency;
|
||||
@ -106,8 +112,8 @@ protected:
|
||||
// channels and configurations
|
||||
ChannelConfigs m_channelConfigs;
|
||||
|
||||
// sources and configurations
|
||||
SourceConfigs m_sourceConfigs;
|
||||
// devices and configurations
|
||||
DeviceeConfigs m_deviceConfigs;
|
||||
|
||||
// screen and dock layout
|
||||
QByteArray m_layout;
|
||||
|
Loading…
Reference in New Issue
Block a user