mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-23 00:18:37 -05:00
Message queues rework: VOR localizer updates
This commit is contained in:
parent
7bbc2749eb
commit
0fad030382
@ -157,11 +157,12 @@ bool VORDemodSC::handleMessage(const Message& cmd)
|
|||||||
m_guiMessageQueue->push(msg);
|
m_guiMessageQueue->push(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagePipes& messagePipes = MainCore::instance()->getMessagePipes();
|
MessagePipes2& messagePipes = MainCore::instance()->getMessagePipes2();
|
||||||
QList<MessageQueue*> *reportMessageQueues = messagePipes.getMessageQueues(this, "report");
|
QList<ObjectPipe*> pipes;
|
||||||
|
messagePipes.getMessagePipes(this, "report", pipes);
|
||||||
|
|
||||||
if (reportMessageQueues) {
|
if (pipes.size() > 0) {
|
||||||
sendChannelReport(reportMessageQueues);
|
sendChannelReport(pipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -177,11 +178,12 @@ bool VORDemodSC::handleMessage(const Message& cmd)
|
|||||||
m_guiMessageQueue->push(msg);
|
m_guiMessageQueue->push(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
MessagePipes& messagePipes = MainCore::instance()->getMessagePipes();
|
MessagePipes2& messagePipes = MainCore::instance()->getMessagePipes2();
|
||||||
QList<MessageQueue*> *reportMessageQueues = messagePipes.getMessageQueues(this, "report");
|
QList<ObjectPipe*> pipes;
|
||||||
|
messagePipes.getMessagePipes(this, "report", pipes);
|
||||||
|
|
||||||
if (reportMessageQueues) {
|
if (pipes.size() > 0) {
|
||||||
sendChannelReport(reportMessageQueues);
|
sendChannelReport(pipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
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 (const auto& pipe : messagePipes)
|
||||||
|
|
||||||
for (; it != messageQueues->end(); ++it)
|
|
||||||
{
|
{
|
||||||
SWGSDRangel::SWGChannelReport *swgChannelReport = new SWGSDRangel::SWGChannelReport();
|
MessageQueue *messageQueue = qobject_cast<MessageQueue*>(pipe->m_element);
|
||||||
swgChannelReport->setDirection(0);
|
|
||||||
swgChannelReport->setChannelType(new QString(m_channelId));
|
if (messageQueue)
|
||||||
swgChannelReport->setVorDemodScReport(new SWGSDRangel::SWGVORDemodSCReport());
|
{
|
||||||
webapiFormatChannelReport(*swgChannelReport);
|
SWGSDRangel::SWGChannelReport *swgChannelReport = new SWGSDRangel::SWGChannelReport();
|
||||||
MainCore::MsgChannelReport *msg = MainCore::MsgChannelReport::create(this, swgChannelReport);
|
swgChannelReport->setDirection(0);
|
||||||
(*it)->push(msg);
|
swgChannelReport->setChannelType(new QString(m_channelId));
|
||||||
|
swgChannelReport->setVorDemodScReport(new SWGSDRangel::SWGVORDemodSCReport());
|
||||||
|
webapiFormatChannelReport(*swgChannelReport);
|
||||||
|
MainCore::MsgChannelReport *msg = MainCore::MsgChannelReport::create(this, swgChannelReport);
|
||||||
|
messageQueue->push(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ class QNetworkAccessManager;
|
|||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
class QThread;
|
class QThread;
|
||||||
class DeviceAPI;
|
class DeviceAPI;
|
||||||
|
class ObjectPipe;
|
||||||
|
|
||||||
class VORDemodSC : public BasebandSampleSink, public ChannelAPI {
|
class VORDemodSC : public BasebandSampleSink, public ChannelAPI {
|
||||||
public:
|
public:
|
||||||
@ -153,7 +154,7 @@ private:
|
|||||||
const VORDemodSCSettings& settings,
|
const VORDemodSCSettings& settings,
|
||||||
bool force
|
bool force
|
||||||
);
|
);
|
||||||
void sendChannelReport(QList<MessageQueue*> *messageQueues);
|
void sendChannelReport(QList<ObjectPipe*>& messagePipes);
|
||||||
void webapiFormatChannelSettings(
|
void webapiFormatChannelSettings(
|
||||||
QList<QString>& channelSettingsKeys,
|
QList<QString>& channelSettingsKeys,
|
||||||
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
|
||||||
|
@ -244,25 +244,24 @@ bool VORLocalizer::handleMessage(const Message& cmd)
|
|||||||
|
|
||||||
return true;
|
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
|
else
|
||||||
{
|
{
|
||||||
return false;
|
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
|
QByteArray VORLocalizer::serialize() const
|
||||||
{
|
{
|
||||||
return m_settings.serialize();
|
return m_settings.serialize();
|
||||||
@ -337,7 +336,7 @@ void VORLocalizer::applySettings(const VORLocalizerSettings& settings, bool forc
|
|||||||
void VORLocalizer::updateChannels()
|
void VORLocalizer::updateChannels()
|
||||||
{
|
{
|
||||||
MainCore *mainCore = MainCore::instance();
|
MainCore *mainCore = MainCore::instance();
|
||||||
MessagePipes& messagePipes = mainCore->getMessagePipes();
|
MessagePipes2& messagePipes = mainCore->getMessagePipes2();
|
||||||
std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets();
|
std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets();
|
||||||
std::vector<DeviceSet*>::const_iterator it = deviceSets.begin();
|
std::vector<DeviceSet*>::const_iterator it = deviceSets.begin();
|
||||||
m_availableChannels.clear();
|
m_availableChannels.clear();
|
||||||
@ -362,7 +361,8 @@ void VORLocalizer::updateChannels()
|
|||||||
{
|
{
|
||||||
if (!m_availableChannels.contains(channel))
|
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(
|
QObject::connect(
|
||||||
messageQueue,
|
messageQueue,
|
||||||
&MessageQueue::messageEnqueued,
|
&MessageQueue::messageEnqueued,
|
||||||
@ -370,6 +370,7 @@ void VORLocalizer::updateChannels()
|
|||||||
[=](){ this->handleChannelMessageQueue(messageQueue); },
|
[=](){ this->handleChannelMessageQueue(messageQueue); },
|
||||||
Qt::QueuedConnection
|
Qt::QueuedConnection
|
||||||
);
|
);
|
||||||
|
connect(pipe, SIGNAL(toBeDeleted(int, QObject*)), this, SLOT(handleMessagePipeToBeDeleted(int, QObject*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
VORLocalizerSettings::AvailableChannel availableChannel =
|
VORLocalizerSettings::AvailableChannel availableChannel =
|
||||||
|
@ -218,7 +218,7 @@ private:
|
|||||||
private slots:
|
private slots:
|
||||||
void networkManagerFinished(QNetworkReply *reply);
|
void networkManagerFinished(QNetworkReply *reply);
|
||||||
void handleChannelMessageQueue(MessageQueue* messageQueue);
|
void handleChannelMessageQueue(MessageQueue* messageQueue);
|
||||||
|
void handleMessagePipeToBeDeleted(int reason, QObject* object);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDE_FEATURE_VORLOCALIZER_H_
|
#endif // INCLUDE_FEATURE_VORLOCALIZER_H_
|
||||||
|
@ -164,7 +164,7 @@ void ObjectPipesRegistrations::processGC()
|
|||||||
|
|
||||||
void ObjectPipesRegistrations::removeProducer(QObject *producer)
|
void ObjectPipesRegistrations::removeProducer(QObject *producer)
|
||||||
{
|
{
|
||||||
qDebug("ObjectPipesRegistrations::removeProducer: %p", producer);
|
qDebug("ObjectPipesRegistrations::removeProducer: %p %s", producer, qPrintable(producer->objectName()));
|
||||||
QMutexLocker mlock(&m_mutex);
|
QMutexLocker mlock(&m_mutex);
|
||||||
|
|
||||||
if (m_producerPipes.contains(producer) && (m_producerPipes[producer].size() != 0))
|
if (m_producerPipes.contains(producer) && (m_producerPipes[producer].size() != 0))
|
||||||
@ -212,7 +212,7 @@ void ObjectPipesRegistrations::removeProducer(QObject *producer)
|
|||||||
|
|
||||||
void ObjectPipesRegistrations::removeConsumer(QObject *consumer)
|
void ObjectPipesRegistrations::removeConsumer(QObject *consumer)
|
||||||
{
|
{
|
||||||
qDebug("ObjectPipesRegistrations::removeConsumer: %p", consumer);
|
qDebug("ObjectPipesRegistrations::removeConsumer: %p %s", consumer, qPrintable(consumer->objectName()));
|
||||||
QMutexLocker mlock(&m_mutex);
|
QMutexLocker mlock(&m_mutex);
|
||||||
|
|
||||||
if (m_consumerPipes.contains(consumer) && (m_consumerPipes[consumer].size() != 0))
|
if (m_consumerPipes.contains(consumer) && (m_consumerPipes[consumer].size() != 0))
|
||||||
|
Loading…
Reference in New Issue
Block a user