1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-07-24 11:04:10 -04:00

Combine results from worker. Automatically add / remove channels.

This commit is contained in:
srcejon
2024-04-04 15:19:35 +01:00
parent f9b43294a8
commit 5e15edcbcf
11 changed files with 236 additions and 91 deletions
+62 -2
View File
@@ -21,6 +21,10 @@
#include "util/simpleserializer.h"
#include "settings/serializable.h"
#include "channel/channelwebapiutils.h"
#include "device/deviceset.h"
#include "device/deviceapi.h"
#include "maincore.h"
#include "sidsettings.h"
@@ -432,7 +436,7 @@ void SIDSettings::applySettings(const QStringList& settingsKeys, const SIDSettin
if (settingsKeys.contains("chartSplitterSizes")) {
m_chartSplitterSizes = settings.m_chartSplitterSizes;
}
if (settingsKeys.contains("title")) {
if (settingsKeys.contains("title")) {
m_title = settings.m_title;
}
if (settingsKeys.contains("rgbColor")) {
@@ -453,7 +457,7 @@ void SIDSettings::applySettings(const QStringList& settingsKeys, const SIDSettin
if (settingsKeys.contains("reverseAPIFeatureIndex")) {
m_reverseAPIFeatureIndex = settings.m_reverseAPIFeatureIndex;
}
if (settingsKeys.contains("workspaceIndex")) {
if (settingsKeys.contains("workspaceIndex")) {
m_workspaceIndex = settings.m_workspaceIndex;
}
}
@@ -596,6 +600,62 @@ SIDSettings::ChannelSettings *SIDSettings::getChannelSettings(const QString& id)
return nullptr;
}
bool SIDSettings::createChannelSettings()
{
bool settingsChanged = false;
QStringList ids;
QStringList titles;
getChannels(ids, titles);
// Create settings for channels we don't currently have settings for
for (int i = 0; i < ids.size(); i++)
{
SIDSettings::ChannelSettings *channelSettings = getChannelSettings(ids[i]);
if (!channelSettings)
{
SIDSettings::ChannelSettings newSettings;
newSettings.m_id = ids[i];
newSettings.m_enabled = true;
newSettings.m_label = titles[i];
newSettings.m_color = SIDSettings::m_defaultColors[i % SIDSettings::m_defaultColors.size()];
m_channelSettings.append(newSettings);
settingsChanged = true;
}
}
return settingsChanged;
}
// Get channels that have channelPowerDB value in their report
void SIDSettings::getChannels(QStringList& ids, QStringList& titles)
{
MainCore *mainCore = MainCore::instance();
std::vector<DeviceSet*> deviceSets = mainCore->getDeviceSets();
for (unsigned int deviceSetIndex = 0; deviceSetIndex < deviceSets.size(); deviceSetIndex++)
{
DeviceSet *deviceSet = deviceSets[deviceSetIndex];
for (int channelIndex = 0; channelIndex < deviceSet->getNumberOfChannels(); channelIndex++)
{
QString title;
ChannelWebAPIUtils::getChannelSetting(deviceSetIndex, channelIndex, "title", title);
double power;
if (ChannelWebAPIUtils::getChannelReportValue(deviceSetIndex, channelIndex, "channelPowerDB", power))
{
ChannelAPI *channel = mainCore->getChannel(deviceSetIndex, channelIndex);
QString id = mainCore->getChannelId(channel);
ids.append(id);
titles.append(title);
}
}
}
}
QByteArray SIDSettings::ChannelSettings::serialize() const
{
SimpleSerializer s(1);