2018-08-31 21:29:53 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
2019-01-22 23:44:13 +00:00
|
|
|
// Copyright (C) 2018-2019 Edouard Griffiths, F4EXB //
|
2018-08-31 21:29:53 +00:00
|
|
|
// //
|
|
|
|
// 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 //
|
2019-04-11 04:39:30 +00:00
|
|
|
// (at your option) any later version. //
|
2018-08-31 21:29:53 +00:00
|
|
|
// //
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2019-01-22 23:44:13 +00:00
|
|
|
#ifndef PLUGINS_CHANNELTX_REMOTESRC_REMOTESRC_H_
|
|
|
|
#define PLUGINS_CHANNELTX_REMOTESRC_REMOTESRC_H_
|
2018-09-01 20:24:21 +00:00
|
|
|
|
2018-09-02 00:00:01 +00:00
|
|
|
#include <QObject>
|
2018-12-20 22:20:21 +00:00
|
|
|
#include <QNetworkRequest>
|
2018-09-02 00:00:01 +00:00
|
|
|
|
2018-08-31 21:29:53 +00:00
|
|
|
#include "dsp/basebandsamplesource.h"
|
2019-05-09 15:27:12 +00:00
|
|
|
#include "channel/channelapi.h"
|
2018-08-31 22:18:35 +00:00
|
|
|
#include "util/message.h"
|
2018-08-31 21:29:53 +00:00
|
|
|
|
2019-11-15 00:04:24 +00:00
|
|
|
#include "remotesourcesettings.h"
|
2019-01-22 23:44:13 +00:00
|
|
|
|
2018-12-20 22:20:21 +00:00
|
|
|
class QNetworkAccessManager;
|
|
|
|
class QNetworkReply;
|
2019-11-15 00:04:24 +00:00
|
|
|
class QThread;
|
|
|
|
|
|
|
|
class DeviceAPI;
|
|
|
|
class RemoteSourceBaseband;
|
2018-08-31 21:29:53 +00:00
|
|
|
|
2019-05-09 15:27:12 +00:00
|
|
|
class RemoteSource : public BasebandSampleSource, public ChannelAPI {
|
2018-08-31 21:29:53 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2019-01-22 23:44:13 +00:00
|
|
|
class MsgConfigureRemoteSource : public Message {
|
2018-09-01 02:37:23 +00:00
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2019-01-22 23:44:13 +00:00
|
|
|
const RemoteSourceSettings& getSettings() const { return m_settings; }
|
2018-09-01 02:37:23 +00:00
|
|
|
bool getForce() const { return m_force; }
|
|
|
|
|
2019-01-22 23:44:13 +00:00
|
|
|
static MsgConfigureRemoteSource* create(const RemoteSourceSettings& settings, bool force)
|
2018-09-01 02:37:23 +00:00
|
|
|
{
|
2019-01-22 23:44:13 +00:00
|
|
|
return new MsgConfigureRemoteSource(settings, force);
|
2018-09-01 02:37:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2019-01-22 23:44:13 +00:00
|
|
|
RemoteSourceSettings m_settings;
|
2018-09-01 02:37:23 +00:00
|
|
|
bool m_force;
|
|
|
|
|
2019-01-22 23:44:13 +00:00
|
|
|
MsgConfigureRemoteSource(const RemoteSourceSettings& settings, bool force) :
|
2018-09-01 02:37:23 +00:00
|
|
|
Message(),
|
|
|
|
m_settings(settings),
|
|
|
|
m_force(force)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2018-09-02 17:12:03 +00:00
|
|
|
class MsgQueryStreamData : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
public:
|
|
|
|
static MsgQueryStreamData* create() {
|
|
|
|
return new MsgQueryStreamData();
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
MsgQueryStreamData() : Message() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgReportStreamData : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
uint32_t get_tv_sec() const { return m_tv_sec; }
|
|
|
|
uint32_t get_tv_usec() const { return m_tv_usec; }
|
|
|
|
uint32_t get_queueSize() const { return m_queueSize; }
|
|
|
|
uint32_t get_queueLength() const { return m_queueLength; }
|
|
|
|
uint32_t get_readSamplesCount() const { return m_readSamplesCount; }
|
|
|
|
uint32_t get_nbCorrectableErrors() const { return m_nbCorrectableErrors; }
|
|
|
|
uint32_t get_nbUncorrectableErrors() const { return m_nbUncorrectableErrors; }
|
|
|
|
uint32_t get_nbOriginalBlocks() const { return m_nbOriginalBlocks; }
|
|
|
|
uint32_t get_nbFECBlocks() const { return m_nbFECBlocks; }
|
|
|
|
uint32_t get_centerFreq() const { return m_centerFreq; }
|
|
|
|
uint32_t get_sampleRate() const { return m_sampleRate; }
|
|
|
|
|
|
|
|
static MsgReportStreamData* create(
|
|
|
|
uint32_t tv_sec,
|
|
|
|
uint32_t tv_usec,
|
|
|
|
uint32_t queueSize,
|
|
|
|
uint32_t queueLength,
|
|
|
|
uint32_t readSamplesCount,
|
|
|
|
uint32_t nbCorrectableErrors,
|
|
|
|
uint32_t nbUncorrectableErrors,
|
|
|
|
uint32_t nbOriginalBlocks,
|
|
|
|
uint32_t nbFECBlocks,
|
|
|
|
uint32_t centerFreq,
|
|
|
|
uint32_t sampleRate)
|
|
|
|
{
|
|
|
|
return new MsgReportStreamData(
|
|
|
|
tv_sec,
|
|
|
|
tv_usec,
|
|
|
|
queueSize,
|
|
|
|
queueLength,
|
|
|
|
readSamplesCount,
|
|
|
|
nbCorrectableErrors,
|
|
|
|
nbUncorrectableErrors,
|
|
|
|
nbOriginalBlocks,
|
|
|
|
nbFECBlocks,
|
|
|
|
centerFreq,
|
|
|
|
sampleRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
uint32_t m_tv_sec;
|
|
|
|
uint32_t m_tv_usec;
|
|
|
|
uint32_t m_queueSize;
|
|
|
|
uint32_t m_queueLength;
|
|
|
|
uint32_t m_readSamplesCount;
|
|
|
|
uint32_t m_nbCorrectableErrors;
|
|
|
|
uint32_t m_nbUncorrectableErrors;
|
|
|
|
uint32_t m_nbOriginalBlocks;
|
|
|
|
uint32_t m_nbFECBlocks;
|
|
|
|
uint32_t m_centerFreq;
|
|
|
|
uint32_t m_sampleRate;
|
|
|
|
|
|
|
|
MsgReportStreamData(
|
|
|
|
uint32_t tv_sec,
|
|
|
|
uint32_t tv_usec,
|
|
|
|
uint32_t queueSize,
|
|
|
|
uint32_t queueLength,
|
|
|
|
uint32_t readSamplesCount,
|
|
|
|
uint32_t nbCorrectableErrors,
|
|
|
|
uint32_t nbUncorrectableErrors,
|
|
|
|
uint32_t nbOriginalBlocks,
|
|
|
|
uint32_t nbFECBlocks,
|
|
|
|
uint32_t centerFreq,
|
|
|
|
uint32_t sampleRate) :
|
|
|
|
Message(),
|
|
|
|
m_tv_sec(tv_sec),
|
|
|
|
m_tv_usec(tv_usec),
|
|
|
|
m_queueSize(queueSize),
|
|
|
|
m_queueLength(queueLength),
|
|
|
|
m_readSamplesCount(readSamplesCount),
|
|
|
|
m_nbCorrectableErrors(nbCorrectableErrors),
|
|
|
|
m_nbUncorrectableErrors(nbUncorrectableErrors),
|
|
|
|
m_nbOriginalBlocks(nbOriginalBlocks),
|
|
|
|
m_nbFECBlocks(nbFECBlocks),
|
|
|
|
m_centerFreq(centerFreq),
|
|
|
|
m_sampleRate(sampleRate)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2019-05-08 20:11:53 +00:00
|
|
|
RemoteSource(DeviceAPI *deviceAPI);
|
2020-10-04 17:07:42 +00:00
|
|
|
virtual ~RemoteSource();
|
2018-08-31 21:29:53 +00:00
|
|
|
|
|
|
|
virtual void destroy() { delete this; }
|
|
|
|
|
|
|
|
virtual void start();
|
|
|
|
virtual void stop();
|
2019-11-15 00:04:24 +00:00
|
|
|
virtual void pull(SampleVector::iterator& begin, unsigned int nbSamples);
|
2018-08-31 21:29:53 +00:00
|
|
|
virtual bool handleMessage(const Message& cmd);
|
|
|
|
|
2020-11-21 19:24:18 +00:00
|
|
|
virtual void getIdentifier(QString& id) { id = objectName(); }
|
2018-08-31 21:29:53 +00:00
|
|
|
virtual void getTitle(QString& title) { title = m_settings.m_title; }
|
|
|
|
virtual qint64 getCenterFrequency() const { return 0; }
|
|
|
|
|
2019-05-09 22:34:35 +00:00
|
|
|
virtual int getNbSinkStreams() const { return 0; }
|
|
|
|
virtual int getNbSourceStreams() const { return 1; }
|
2019-05-09 15:27:12 +00:00
|
|
|
|
|
|
|
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
|
|
|
|
{
|
|
|
|
(void) streamIndex;
|
|
|
|
(void) sinkElseSource;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-08-31 21:29:53 +00:00
|
|
|
virtual QByteArray serialize() const;
|
|
|
|
virtual bool deserialize(const QByteArray& data);
|
|
|
|
|
2018-09-01 02:37:23 +00:00
|
|
|
virtual int webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
|
|
|
virtual int webapiSettingsPutPatch(
|
|
|
|
bool force,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
|
|
|
virtual int webapiReportGet(
|
|
|
|
SWGSDRangel::SWGChannelReport& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
2019-08-01 21:21:57 +00:00
|
|
|
static void webapiFormatChannelSettings(
|
|
|
|
SWGSDRangel::SWGChannelSettings& response,
|
|
|
|
const RemoteSourceSettings& settings);
|
|
|
|
|
|
|
|
static void webapiUpdateChannelSettings(
|
|
|
|
RemoteSourceSettings& settings,
|
|
|
|
const QStringList& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings& response);
|
|
|
|
|
2019-11-17 10:09:07 +00:00
|
|
|
uint32_t getNumberOfDeviceStreams() const;
|
|
|
|
|
2020-11-21 19:24:18 +00:00
|
|
|
static const char* const m_channelIdURI;
|
|
|
|
static const char* const m_channelId;
|
2018-08-31 21:29:53 +00:00
|
|
|
|
|
|
|
private:
|
2019-05-08 20:11:53 +00:00
|
|
|
DeviceAPI* m_deviceAPI;
|
2019-11-15 00:04:24 +00:00
|
|
|
QThread *m_thread;
|
|
|
|
RemoteSourceBaseband *m_basebandSource;
|
2019-01-22 23:44:13 +00:00
|
|
|
RemoteSourceSettings m_settings;
|
2018-09-01 02:37:23 +00:00
|
|
|
|
2018-12-20 22:20:21 +00:00
|
|
|
QNetworkAccessManager *m_networkManager;
|
|
|
|
QNetworkRequest m_networkRequest;
|
|
|
|
|
2019-01-22 23:44:13 +00:00
|
|
|
void applySettings(const RemoteSourceSettings& settings, bool force = false);
|
2018-09-01 02:37:23 +00:00
|
|
|
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);
|
2019-01-22 23:44:13 +00:00
|
|
|
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const RemoteSourceSettings& settings, bool force);
|
2020-10-22 22:11:18 +00:00
|
|
|
void featuresSendSettings(QList<QString>& channelSettingsKeys, const RemoteSourceSettings& settings, bool force);
|
|
|
|
void webapiFormatChannelSettings(
|
|
|
|
QList<QString>& channelSettingsKeys,
|
|
|
|
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
|
|
|
|
const RemoteSourceSettings& settings,
|
|
|
|
bool force
|
|
|
|
);
|
2018-09-01 02:37:23 +00:00
|
|
|
|
|
|
|
private slots:
|
2018-12-20 22:20:21 +00:00
|
|
|
void networkManagerFinished(QNetworkReply *reply);
|
2018-08-31 21:29:53 +00:00
|
|
|
};
|
2018-09-01 20:24:21 +00:00
|
|
|
|
2019-01-22 23:44:13 +00:00
|
|
|
#endif // PLUGINS_CHANNELTX_REMOTESRC_REMOTESRC_H_
|