Message pipes rework: settings pipes change in AFC, SSB demod, Frequency tracker

pull/1171/head
f4exb 2022-03-02 06:58:54 +01:00
rodzic 1c5a777709
commit 283ab64c59
6 zmienionych plików z 88 dodań i 44 usunięć

Wyświetl plik

@ -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,24 +582,29 @@ 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)
{
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
MainCore::MsgChannelSettings *msg = MainCore::MsgChannelSettings::create(
this,
channelSettingsKeys,
swgChannelSettings,
force
);
(*it)->push(msg);
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
if (messageQueue)
{
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
MainCore::MsgChannelSettings *msg = MainCore::MsgChannelSettings::create(
this,
channelSettingsKeys,
swgChannelSettings,
force
);
messageQueue->push(msg);
}
}
}

Wyświetl plik

@ -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

Wyświetl plik

@ -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,24 +552,27 @@ 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 (; it != messageQueues->end(); ++it)
for (const auto& pipe : pipes)
{
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
MainCore::MsgChannelSettings *msg = MainCore::MsgChannelSettings::create(
this,
channelSettingsKeys,
swgChannelSettings,
force
);
(*it)->push(msg);
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
if (messageQueue)
{
SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings();
webapiFormatChannelSettings(channelSettingsKeys, swgChannelSettings, settings, force);
MainCore::MsgChannelSettings *msg = MainCore::MsgChannelSettings::create(
this,
channelSettingsKeys,
swgChannelSettings,
force
);
messageQueue->push(msg);
}
}
}

Wyświetl plik

@ -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

Wyświetl plik

@ -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))
ObjectPipe *pipe = MainCore::instance()->getMessagePipes2().unregisterProducerToConsumer(m_trackerChannelAPI, this, "settings");
if (pipe)
{
qDebug("AFC::removeTrackerFeatureReference: m_trackerChannelAPI: %s", qPrintable(m_trackerChannelAPI->objectName()));
ObjectPipe *pipe = MainCore::instance()->getMessagePipes2().unregisterProducerToConsumer(m_trackerChannelAPI, this, "settings");
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);
m_trackedChannelAPIs.clear();
if (messageQueue) {
disconnect(messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleChannelMessageQueue(MessageQueue*)));
}
}
m_trackedChannelAPIs.removeAll(channel);
}
}
void AFC::handleChannelMessageQueue(MessageQueue* messageQueue)

Wyświetl plik

@ -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_