1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

Message queues rework: VOR localizer updates

This commit is contained in:
f4exb 2022-02-26 13:44:46 +01:00
parent 7bbc2749eb
commit 0fad030382
5 changed files with 45 additions and 38 deletions

View File

@ -157,11 +157,12 @@ bool VORDemodSC::handleMessage(const Message& cmd)
m_guiMessageQueue->push(msg);
}
MessagePipes& messagePipes = MainCore::instance()->getMessagePipes();
QList<MessageQueue*> *reportMessageQueues = messagePipes.getMessageQueues(this, "report");
MessagePipes2& messagePipes = MainCore::instance()->getMessagePipes2();
QList<ObjectPipe*> pipes;
messagePipes.getMessagePipes(this, "report", pipes);
if (reportMessageQueues) {
sendChannelReport(reportMessageQueues);
if (pipes.size() > 0) {
sendChannelReport(pipes);
}
return true;
@ -177,11 +178,12 @@ bool VORDemodSC::handleMessage(const Message& cmd)
m_guiMessageQueue->push(msg);
}
MessagePipes& messagePipes = MainCore::instance()->getMessagePipes();
QList<MessageQueue*> *reportMessageQueues = messagePipes.getMessageQueues(this, "report");
MessagePipes2& messagePipes = MainCore::instance()->getMessagePipes2();
QList<ObjectPipe*> pipes;
messagePipes.getMessagePipes(this, "report", pipes);
if (reportMessageQueues) {
sendChannelReport(reportMessageQueues);
if (pipes.size() > 0) {
sendChannelReport(pipes);
}
return true;
@ -550,19 +552,22 @@ void VORDemodSC::sendChannelSettings(
}
}
void VORDemodSC::sendChannelReport(QList<MessageQueue*> *messageQueues)
void VORDemodSC::sendChannelReport(QList<ObjectPipe*>& messagePipes)
{
QList<MessageQueue*>::iterator it = messageQueues->begin();
for (; it != messageQueues->end(); ++it)
for (const auto& pipe : messagePipes)
{
SWGSDRangel::SWGChannelReport *swgChannelReport = new SWGSDRangel::SWGChannelReport();
swgChannelReport->setDirection(0);
swgChannelReport->setChannelType(new QString(m_channelId));
swgChannelReport->setVorDemodScReport(new SWGSDRangel::SWGVORDemodSCReport());
webapiFormatChannelReport(*swgChannelReport);
MainCore::MsgChannelReport *msg = MainCore::MsgChannelReport::create(this, swgChannelReport);
(*it)->push(msg);
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
if (messageQueue)
{
SWGSDRangel::SWGChannelReport *swgChannelReport = new SWGSDRangel::SWGChannelReport();
swgChannelReport->setDirection(0);
swgChannelReport->setChannelType(new QString(m_channelId));
swgChannelReport->setVorDemodScReport(new SWGSDRangel::SWGVORDemodSCReport());
webapiFormatChannelReport(*swgChannelReport);
MainCore::MsgChannelReport *msg = MainCore::MsgChannelReport::create(this, swgChannelReport);
messageQueue->push(msg);
}
}
}

View File

@ -35,6 +35,7 @@ class QNetworkAccessManager;
class QNetworkReply;
class QThread;
class DeviceAPI;
class ObjectPipe;
class VORDemodSC : public BasebandSampleSink, public ChannelAPI {
public:
@ -153,7 +154,7 @@ private:
const VORDemodSCSettings& settings,
bool force
);
void sendChannelReport(QList<MessageQueue*> *messageQueues);
void sendChannelReport(QList<ObjectPipe*>& messagePipes);
void webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings,

View File

@ -244,25 +244,24 @@ bool VORLocalizer::handleMessage(const Message& cmd)
return true;
}
else if (MessagePipesCommon::MsgReportChannelDeleted::match(cmd))
{
qDebug() << "VORLocalizer::handleMessage: MsgReportChannelDeleted";
MessagePipesCommon::MsgReportChannelDeleted& report = (MessagePipesCommon::MsgReportChannelDeleted&) cmd;
const MessagePipesCommon::ChannelRegistrationKey& channelKey = report.getChannelRegistrationKey();
const PipeEndPoint *channel = channelKey.m_key;
m_availableChannels.remove(const_cast<ChannelAPI*>(reinterpret_cast<const ChannelAPI*>(channel)));
updateChannels();
MessageQueue *messageQueue = MainCore::instance()->getMessagePipes().unregisterChannelToFeature(channel, this, "report");
disconnect(messageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleChannelMessageQueue(MessageQueue*)));
return true;
}
else
{
return false;
}
}
void VORLocalizer::handleMessagePipeToBeDeleted(int reason, QObject* object)
{
if (reason == 0) // producer (channel)
{
if (m_availableChannels.contains((ChannelAPI*) object))
{
m_availableChannels.remove((ChannelAPI*) object);
updateChannels();
}
}
}
QByteArray VORLocalizer::serialize() const
{
return m_settings.serialize();
@ -337,7 +336,7 @@ void VORLocalizer::applySettings(const VORLocalizerSettings& settings, bool forc
void VORLocalizer::updateChannels()
{
MainCore *mainCore = MainCore::instance();
MessagePipes& messagePipes = mainCore->getMessagePipes();
MessagePipes2& messagePipes = mainCore->getMessagePipes2();
std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets();
std::vector<DeviceSet*>::const_iterator it = deviceSets.begin();
m_availableChannels.clear();
@ -362,7 +361,8 @@ void VORLocalizer::updateChannels()
{
if (!m_availableChannels.contains(channel))
{
MessageQueue *messageQueue = messagePipes.registerChannelToFeature(channel, this, "report");
ObjectPipe *pipe = messagePipes.registerProducerToConsumer(channel, this, "report");
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
QObject::connect(
messageQueue,
&MessageQueue::messageEnqueued,
@ -370,6 +370,7 @@ void VORLocalizer::updateChannels()
[=](){ this->handleChannelMessageQueue(messageQueue); },
Qt::QueuedConnection
);
connect(pipe, SIGNAL(toBeDeleted(int, QObject*)), this, SLOT(handleMessagePipeToBeDeleted(int, QObject*)));
}
VORLocalizerSettings::AvailableChannel availableChannel =

View File

@ -218,7 +218,7 @@ private:
private slots:
void networkManagerFinished(QNetworkReply *reply);
void handleChannelMessageQueue(MessageQueue* messageQueue);
void handleMessagePipeToBeDeleted(int reason, QObject* object);
};
#endif // INCLUDE_FEATURE_VORLOCALIZER_H_

View File

@ -164,7 +164,7 @@ void ObjectPipesRegistrations::processGC()
void ObjectPipesRegistrations::removeProducer(QObject *producer)
{
qDebug("ObjectPipesRegistrations::removeProducer: %p", producer);
qDebug("ObjectPipesRegistrations::removeProducer: %p %s", producer, qPrintable(producer->objectName()));
QMutexLocker mlock(&m_mutex);
if (m_producerPipes.contains(producer) && (m_producerPipes[producer].size() != 0))
@ -212,7 +212,7 @@ void ObjectPipesRegistrations::removeProducer(QObject *producer)
void ObjectPipesRegistrations::removeConsumer(QObject *consumer)
{
qDebug("ObjectPipesRegistrations::removeConsumer: %p", consumer);
qDebug("ObjectPipesRegistrations::removeConsumer: %p %s", consumer, qPrintable(consumer->objectName()));
QMutexLocker mlock(&m_mutex);
if (m_consumerPipes.contains(consumer) && (m_consumerPipes[consumer].size() != 0))