mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-15 04:41:55 -05:00
Message pipes rework: settings pipes change in AFC, SSB demod, Frequency tracker
This commit is contained in:
parent
1c5a777709
commit
283ab64c59
@ -270,10 +270,11 @@ void SSBDemod::applySettings(const SSBDemodSettings& settings, bool force)
|
||||
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
||||
}
|
||||
|
||||
QList<MessageQueue*> *messageQueues = MainCore::instance()->getMessagePipes().getMessageQueues(this, "settings");
|
||||
QList<ObjectPipe*> pipes;
|
||||
MainCore::instance()->getMessagePipes2().getMessagePipes(this, "settings", pipes);
|
||||
|
||||
if (messageQueues) {
|
||||
sendChannelSettings(messageQueues, reverseAPIKeys, settings, force);
|
||||
if (pipes.size() > 0) {
|
||||
sendChannelSettings(pipes, reverseAPIKeys, settings, force);
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
@ -581,14 +582,18 @@ void SSBDemod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, co
|
||||
}
|
||||
|
||||
void SSBDemod::sendChannelSettings(
|
||||
QList<MessageQueue*> *messageQueues,
|
||||
const QList<ObjectPipe*>& pipes,
|
||||
QList<QString>& channelSettingsKeys,
|
||||
const SSBDemodSettings& settings,
|
||||
bool force)
|
||||
{
|
||||
QList<MessageQueue*>::iterator it = messageQueues->begin();
|
||||
qDebug("SSBDemod::sendChannelSettings: %d pipes", pipes.size());
|
||||
|
||||
for (; it != messageQueues->end(); ++it)
|
||||
for (const auto& pipe : pipes)
|
||||
{
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
|
||||
if (messageQueue)
|
||||
{
|
||||
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
||||
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
|
||||
@ -598,7 +603,8 @@ void SSBDemod::sendChannelSettings(
|
||||
swgChannelSettings,
|
||||
force
|
||||
);
|
||||
(*it)->push(msg);
|
||||
messageQueue->push(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ class QNetworkAccessManager;
|
||||
class QNetworkReply;
|
||||
class QThread;
|
||||
class DeviceAPI;
|
||||
class ObjectPipe;
|
||||
|
||||
class SSBDemod : public BasebandSampleSink, public ChannelAPI {
|
||||
public:
|
||||
@ -148,7 +149,7 @@ private:
|
||||
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);
|
||||
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const SSBDemodSettings& settings, bool force);
|
||||
void sendChannelSettings(
|
||||
QList<MessageQueue*> *messageQueues,
|
||||
const QList<ObjectPipe*>& pipes,
|
||||
QList<QString>& channelSettingsKeys,
|
||||
const SSBDemodSettings& settings,
|
||||
bool force
|
||||
|
@ -274,10 +274,11 @@ void FreqTracker::applySettings(const FreqTrackerSettings& settings, bool force)
|
||||
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
||||
}
|
||||
|
||||
QList<MessageQueue*> *messageQueues = MainCore::instance()->getMessagePipes().getMessageQueues(this, "settings");
|
||||
QList<ObjectPipe*> pipes;
|
||||
MainCore::instance()->getMessagePipes2().getMessagePipes(this, "settings", pipes);
|
||||
|
||||
if (messageQueues) {
|
||||
sendChannelSettings(messageQueues, reverseAPIKeys, settings, force);
|
||||
if (pipes.size() > 0) {
|
||||
sendChannelSettings(pipes, reverseAPIKeys, settings, force);
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
@ -551,14 +552,16 @@ void FreqTracker::webapiReverseSendSettings(QList<QString>& channelSettingsKeys,
|
||||
}
|
||||
|
||||
void FreqTracker::sendChannelSettings(
|
||||
QList<MessageQueue*> *messageQueues,
|
||||
const QList<ObjectPipe*>& pipes,
|
||||
QList<QString>& channelSettingsKeys,
|
||||
const FreqTrackerSettings& settings,
|
||||
bool force)
|
||||
{
|
||||
QList<MessageQueue*>::iterator it = messageQueues->begin();
|
||||
for (const auto& pipe : pipes)
|
||||
{
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
|
||||
for (; it != messageQueues->end(); ++it)
|
||||
if (messageQueue)
|
||||
{
|
||||
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
|
||||
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
|
||||
@ -568,7 +571,8 @@ void FreqTracker::sendChannelSettings(
|
||||
swgChannelSettings,
|
||||
force
|
||||
);
|
||||
(*it)->push(msg);
|
||||
messageQueue->push(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
class QNetworkAccessManager;
|
||||
class QNetworkReply;
|
||||
class DeviceAPI;
|
||||
class ObjectPipe;
|
||||
|
||||
class FreqTracker : public BasebandSampleSink, public ChannelAPI {
|
||||
public:
|
||||
@ -145,7 +146,7 @@ private:
|
||||
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);
|
||||
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const FreqTrackerSettings& settings, bool force);
|
||||
void sendChannelSettings(
|
||||
QList<MessageQueue*> *messageQueues,
|
||||
const QList<ObjectPipe*>& pipes,
|
||||
QList<QString>& channelSettingsKeys,
|
||||
const FreqTrackerSettings& settings,
|
||||
bool force
|
||||
|
@ -630,6 +630,7 @@ void AFC::trackerDeviceChange(int deviceIndex)
|
||||
|
||||
MainCore *mainCore = MainCore::instance();
|
||||
m_trackerDeviceSet = mainCore->getDeviceSets()[deviceIndex];
|
||||
m_trackerChannelAPI = nullptr;
|
||||
|
||||
for (int i = 0; i < m_trackerDeviceSet->getNumberOfChannels(); i++)
|
||||
{
|
||||
@ -651,12 +652,22 @@ void AFC::trackerDeviceChange(int deviceIndex)
|
||||
);
|
||||
}
|
||||
|
||||
connect(pipe, SIGNAL(toBeDeleted(int, QObject*)), this, SLOT(handleTrackerMessagePipeToBeDeleted(int, QObject*)));
|
||||
m_trackerChannelAPI = channel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AFC::handleTrackerMessagePipeToBeDeleted(int reason, QObject* object)
|
||||
{
|
||||
if ((reason == 0) && ((ChannelAPI*) object == m_trackerChannelAPI)) // tracker channel has been de;eted
|
||||
{
|
||||
m_trackerChannelAPI = nullptr;
|
||||
updateDeviceSetLists();
|
||||
}
|
||||
}
|
||||
|
||||
void AFC::trackedDeviceChange(int deviceIndex)
|
||||
{
|
||||
qDebug("AFC::trackedDeviceChange: deviceIndex: %d", deviceIndex);
|
||||
@ -667,6 +678,8 @@ void AFC::trackedDeviceChange(int deviceIndex)
|
||||
|
||||
MainCore *mainCore = MainCore::instance();
|
||||
m_trackedDeviceSet = mainCore->getDeviceSets()[deviceIndex];
|
||||
m_trackerIndexInDeviceSet = -1;
|
||||
m_trackedChannelAPIs.clear();
|
||||
|
||||
for (int i = 0; i < m_trackedDeviceSet->getNumberOfChannels(); i++)
|
||||
{
|
||||
@ -688,41 +701,58 @@ void AFC::trackedDeviceChange(int deviceIndex)
|
||||
);
|
||||
m_trackerIndexInDeviceSet = i;
|
||||
}
|
||||
|
||||
m_trackedChannelAPIs.push_back(channel);
|
||||
connect(pipe, SIGNAL(toBeDeleted(int, QObject*)), this, SLOT(handleTrackedMessagePipeToBeDeleted(int, QObject*)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AFC::handleTrackedMessagePipeToBeDeleted(int reason, QObject* object)
|
||||
{
|
||||
if ((reason == 0) && m_trackedChannelAPIs.contains((ChannelAPI*) object))
|
||||
{
|
||||
m_trackedChannelAPIs.removeAll((ChannelAPI*) object);
|
||||
updateDeviceSetLists();
|
||||
}
|
||||
}
|
||||
|
||||
void AFC::removeTrackerFeatureReference()
|
||||
{
|
||||
if (m_trackerChannelAPI)
|
||||
{
|
||||
if (MainCore::instance()->existsChannel(m_trackerChannelAPI))
|
||||
{
|
||||
qDebug("AFC::removeTrackerFeatureReference: m_trackerChannelAPI: %s", qPrintable(m_trackerChannelAPI->objectName()));
|
||||
ObjectPipe *pipe = MainCore::instance()->getMessagePipes2().unregisterProducerToConsumer(m_trackerChannelAPI, this, "settings");
|
||||
|
||||
if (pipe)
|
||||
{
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
|
||||
if (messageQueue) {
|
||||
disconnect(messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleChannelMessageQueue(MessageQueue*)));
|
||||
}
|
||||
}
|
||||
|
||||
m_trackerChannelAPI = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void AFC::removeTrackedFeatureReferences()
|
||||
{
|
||||
for (QList<ChannelAPI*>::iterator it = m_trackedChannelAPIs.begin(); it != m_trackedChannelAPIs.end(); ++it)
|
||||
for (auto& channel : m_trackedChannelAPIs)
|
||||
{
|
||||
ChannelAPI *channel = *it;
|
||||
ObjectPipe *pipe = MainCore::instance()->getMessagePipes2().unregisterProducerToConsumer(channel, this, "settings");
|
||||
|
||||
if (MainCore::instance()->existsChannel(channel))
|
||||
if (pipe)
|
||||
{
|
||||
qDebug("AFC::removeTrackedFeatureReferences: channel: %s", qPrintable(channel->objectName()));
|
||||
MainCore::instance()->getMessagePipes2().unregisterProducerToConsumer(channel, this, "settings");
|
||||
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||
|
||||
if (messageQueue) {
|
||||
disconnect(messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleChannelMessageQueue(MessageQueue*)));
|
||||
}
|
||||
}
|
||||
|
||||
m_trackedChannelAPIs.clear();
|
||||
m_trackedChannelAPIs.removeAll(channel);
|
||||
}
|
||||
}
|
||||
|
||||
void AFC::handleChannelMessageQueue(MessageQueue* messageQueue)
|
||||
|
@ -226,6 +226,8 @@ private:
|
||||
private slots:
|
||||
void networkManagerFinished(QNetworkReply *reply);
|
||||
void handleChannelMessageQueue(MessageQueue* messageQueue);
|
||||
void handleTrackerMessagePipeToBeDeleted(int reason, QObject* object);
|
||||
void handleTrackedMessagePipeToBeDeleted(int reason, QObject* object);
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FEATURE_AFC_H_
|
||||
|
Loading…
Reference in New Issue
Block a user