mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-10 10:33:29 -05:00
0ab857c358
from, to allow either to be used as pipe sources. Add MsgMapItem, MsgPacket and MsgTargetAzimuthElevation messages that can be passed between channels and features via pipes.
148 lines
6.2 KiB
C++
148 lines
6.2 KiB
C++
///////////////////////////////////////////////////////////////////////////////////
|
|
// Copyright (C) 2021 Jon Beniston, M7RCE //
|
|
// //
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
// it under the terms of the GNU General Public License as published by //
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
// (at your option) any later version. //
|
|
// //
|
|
// This program is distributed in the hope that it will be useful, //
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
// GNU General Public License V3 for more details. //
|
|
// //
|
|
// You should have received a copy of the GNU General Public License //
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include <vector>
|
|
|
|
#include <QRegExp>
|
|
#include <QDebug>
|
|
|
|
#include "dsp/dspengine.h"
|
|
#include "device/deviceset.h"
|
|
#include "channel/channelapi.h"
|
|
#include "feature/featureset.h"
|
|
#include "feature/feature.h"
|
|
#include "maincore.h"
|
|
|
|
#include "pipeendpoint.h"
|
|
|
|
MESSAGE_CLASS_DEFINITION(PipeEndPoint::MsgReportPipes, Message)
|
|
|
|
QList<PipeEndPoint::AvailablePipeSource> PipeEndPoint::updateAvailablePipeSources(QString pipeName, QStringList pipeTypes, QStringList pipeURIs, Feature *destinationFeature)
|
|
{
|
|
MainCore *mainCore = MainCore::instance();
|
|
MessagePipes& messagePipes = mainCore->getMessagePipes();
|
|
std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets();
|
|
QHash<PipeEndPoint *, AvailablePipeSource> availablePipes;
|
|
|
|
int deviceIndex = 0;
|
|
for (std::vector<DeviceSet*>::const_iterator it = deviceSets.begin(); it != deviceSets.end(); ++it, deviceIndex++)
|
|
{
|
|
DSPDeviceSourceEngine *deviceSourceEngine = (*it)->m_deviceSourceEngine;
|
|
DSPDeviceSinkEngine *deviceSinkEngine = (*it)->m_deviceSinkEngine;
|
|
|
|
if (deviceSourceEngine || deviceSinkEngine)
|
|
{
|
|
for (int chi = 0; chi < (*it)->getNumberOfChannels(); chi++)
|
|
{
|
|
ChannelAPI *channel = (*it)->getChannelAt(chi);
|
|
int i = pipeURIs.indexOf(channel->getURI());
|
|
|
|
if (i >= 0)
|
|
{
|
|
if (!availablePipes.contains(channel))
|
|
{
|
|
MessageQueue *messageQueue = messagePipes.registerChannelToFeature(channel, destinationFeature, pipeName);
|
|
QObject::connect(
|
|
messageQueue,
|
|
&MessageQueue::messageEnqueued,
|
|
destinationFeature,
|
|
[=](){ destinationFeature->handlePipeMessageQueue(messageQueue); },
|
|
Qt::QueuedConnection
|
|
);
|
|
}
|
|
|
|
AvailablePipeSource availablePipe =
|
|
AvailablePipeSource{
|
|
deviceSinkEngine != nullptr ? AvailablePipeSource::TX : AvailablePipeSource::RX,
|
|
deviceIndex,
|
|
chi,
|
|
channel,
|
|
pipeTypes.at(i)
|
|
};
|
|
availablePipes[channel] = availablePipe;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
std::vector<FeatureSet*>& featureSets = mainCore->getFeatureeSets();
|
|
int featureIndex = 0;
|
|
for (std::vector<FeatureSet*>::const_iterator it = featureSets.begin(); it != featureSets.end(); ++it, featureIndex++)
|
|
{
|
|
for (int fi = 0; fi < (*it)->getNumberOfFeatures(); fi++)
|
|
{
|
|
Feature *feature = (*it)->getFeatureAt(fi);
|
|
int i = pipeURIs.indexOf(feature->getURI());
|
|
|
|
if (i >= 0)
|
|
{
|
|
if (!availablePipes.contains(feature))
|
|
{
|
|
MessageQueue *messageQueue = messagePipes.registerChannelToFeature(feature, destinationFeature, pipeName);
|
|
QObject::connect(
|
|
messageQueue,
|
|
&MessageQueue::messageEnqueued,
|
|
destinationFeature,
|
|
[=](){ destinationFeature->handlePipeMessageQueue(messageQueue); },
|
|
Qt::QueuedConnection
|
|
);
|
|
}
|
|
|
|
AvailablePipeSource availablePipe =
|
|
AvailablePipeSource{
|
|
AvailablePipeSource::Feature,
|
|
featureIndex,
|
|
fi,
|
|
feature,
|
|
pipeTypes.at(i)
|
|
};
|
|
availablePipes[feature] = availablePipe;
|
|
}
|
|
}
|
|
}
|
|
|
|
QList<AvailablePipeSource> availablePipeList;
|
|
QHash<PipeEndPoint*, AvailablePipeSource>::iterator it = availablePipes.begin();
|
|
|
|
for (; it != availablePipes.end(); ++it) {
|
|
availablePipeList.push_back(*it);
|
|
}
|
|
return availablePipeList;
|
|
}
|
|
|
|
PipeEndPoint *PipeEndPoint::getPipeEndPoint(const QString name, const QList<AvailablePipeSource> &availablePipeSources)
|
|
{
|
|
QRegExp re("([TRF])([0-9]+):([0-9]+) ([a-zA-Z0-9]+)");
|
|
if (re.exactMatch(name))
|
|
{
|
|
QString type = re.capturedTexts()[1];
|
|
int setIndex = re.capturedTexts()[2].toInt();
|
|
int index = re.capturedTexts()[3].toInt();
|
|
QString id = re.capturedTexts()[4];
|
|
|
|
QListIterator<AvailablePipeSource> itr(availablePipeSources);
|
|
while (itr.hasNext()) {
|
|
AvailablePipeSource p = itr.next();
|
|
if ((p.m_setIndex == setIndex) && (p.m_index == index) && (id == p.m_id))
|
|
return p.m_source;
|
|
}
|
|
}
|
|
else
|
|
qDebug() << "PipeEndPoint::getPipeEndPoint: " << name << " is malformed";
|
|
return nullptr;
|
|
}
|