2018-10-29 13:27:58 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// 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 //
|
|
|
|
// //
|
|
|
|
// 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUT_H_
|
|
|
|
#define PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUT_H_
|
|
|
|
|
2018-12-26 17:00:31 -05:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2018-10-29 13:27:58 -04:00
|
|
|
#include <QString>
|
2018-11-04 05:45:59 -05:00
|
|
|
#include <QByteArray>
|
2018-12-26 17:00:31 -05:00
|
|
|
#include <QNetworkRequest>
|
2018-10-29 13:27:58 -04:00
|
|
|
|
|
|
|
#include "dsp/devicesamplesink.h"
|
2018-10-30 05:02:32 -04:00
|
|
|
#include "soapysdr/devicesoapysdrshared.h"
|
2018-10-29 13:27:58 -04:00
|
|
|
|
2018-10-30 15:31:16 -04:00
|
|
|
#include "soapysdroutputsettings.h"
|
|
|
|
|
2018-12-26 17:00:31 -05:00
|
|
|
class QNetworkAccessManager;
|
|
|
|
class QNetworkReply;
|
2018-10-29 13:27:58 -04:00
|
|
|
class DeviceSinkAPI;
|
2018-11-04 05:45:59 -05:00
|
|
|
class SoapySDROutputThread;
|
|
|
|
|
|
|
|
namespace SoapySDR
|
|
|
|
{
|
|
|
|
class Device;
|
2018-11-14 03:19:36 -05:00
|
|
|
class ArgInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace SWGSDRangel
|
|
|
|
{
|
|
|
|
class SWGArgValue;
|
|
|
|
class SWGArgInfo;
|
2018-11-04 05:45:59 -05:00
|
|
|
}
|
2018-10-29 13:27:58 -04:00
|
|
|
|
|
|
|
class SoapySDROutput : public DeviceSampleSink {
|
2018-12-26 17:00:31 -05:00
|
|
|
Q_OBJECT
|
2018-10-29 13:27:58 -04:00
|
|
|
public:
|
2018-11-04 05:45:59 -05:00
|
|
|
class MsgConfigureSoapySDROutput : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const SoapySDROutputSettings& getSettings() const { return m_settings; }
|
|
|
|
bool getForce() const { return m_force; }
|
|
|
|
|
|
|
|
static MsgConfigureSoapySDROutput* create(const SoapySDROutputSettings& settings, bool force)
|
|
|
|
{
|
|
|
|
return new MsgConfigureSoapySDROutput(settings, force);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SoapySDROutputSettings m_settings;
|
|
|
|
bool m_force;
|
|
|
|
|
|
|
|
MsgConfigureSoapySDROutput(const SoapySDROutputSettings& settings, bool force) :
|
|
|
|
Message(),
|
|
|
|
m_settings(settings),
|
|
|
|
m_force(force)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2018-11-07 17:54:32 -05:00
|
|
|
class MsgReportGainChange : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const SoapySDROutputSettings& getSettings() const { return m_settings; }
|
|
|
|
bool getGlobalGain() const { return m_globalGain; }
|
|
|
|
bool getIndividualGains() const { return m_individualGains; }
|
|
|
|
|
|
|
|
static MsgReportGainChange* create(const SoapySDROutputSettings& settings, bool globalGain, bool individualGains)
|
|
|
|
{
|
|
|
|
return new MsgReportGainChange(settings, globalGain, individualGains);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SoapySDROutputSettings m_settings;
|
|
|
|
bool m_globalGain;
|
|
|
|
bool m_individualGains;
|
|
|
|
|
|
|
|
MsgReportGainChange(const SoapySDROutputSettings& settings, bool globalGain, bool individualGains) :
|
|
|
|
Message(),
|
|
|
|
m_settings(settings),
|
|
|
|
m_globalGain(globalGain),
|
|
|
|
m_individualGains(individualGains)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2018-11-04 05:45:59 -05:00
|
|
|
class MsgStartStop : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool getStartStop() const { return m_startStop; }
|
|
|
|
|
|
|
|
static MsgStartStop* create(bool startStop) {
|
|
|
|
return new MsgStartStop(startStop);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_startStop;
|
|
|
|
|
|
|
|
MsgStartStop(bool startStop) :
|
|
|
|
Message(),
|
|
|
|
m_startStop(startStop)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2018-10-29 13:27:58 -04:00
|
|
|
SoapySDROutput(DeviceSinkAPI *deviceAPI);
|
|
|
|
virtual ~SoapySDROutput();
|
|
|
|
virtual void destroy();
|
|
|
|
|
|
|
|
virtual void init();
|
|
|
|
virtual bool start();
|
|
|
|
virtual void stop();
|
2018-11-04 05:45:59 -05:00
|
|
|
SoapySDROutputThread *getThread() { return m_thread; }
|
|
|
|
void setThread(SoapySDROutputThread *thread) { m_thread = thread; }
|
2018-10-29 13:27:58 -04:00
|
|
|
|
|
|
|
virtual QByteArray serialize() const;
|
|
|
|
virtual bool deserialize(const QByteArray& data);
|
|
|
|
|
|
|
|
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
|
|
|
|
virtual const QString& getDeviceDescription() const;
|
|
|
|
virtual int getSampleRate() const;
|
|
|
|
virtual quint64 getCenterFrequency() const;
|
|
|
|
virtual void setCenterFrequency(qint64 centerFrequency);
|
|
|
|
|
|
|
|
virtual bool handleMessage(const Message& message);
|
|
|
|
|
2018-11-04 05:45:59 -05:00
|
|
|
void getFrequencyRange(uint64_t& min, uint64_t& max);
|
2018-11-07 07:08:35 -05:00
|
|
|
void getGlobalGainRange(int& min, int& max);
|
2018-11-07 19:52:48 -05:00
|
|
|
bool isAGCSupported();
|
2018-11-04 05:45:59 -05:00
|
|
|
const SoapySDR::RangeList& getRateRanges();
|
2018-11-04 17:54:16 -05:00
|
|
|
const std::vector<std::string>& getAntennas();
|
2018-11-04 20:40:02 -05:00
|
|
|
const SoapySDR::RangeList& getBandwidthRanges();
|
2018-11-05 11:27:32 -05:00
|
|
|
const std::vector<DeviceSoapySDRParams::FrequencySetting>& getTunableElements();
|
2018-11-07 07:08:35 -05:00
|
|
|
const std::vector<DeviceSoapySDRParams::GainSetting>& getIndividualGainsRanges();
|
2018-11-11 03:31:27 -05:00
|
|
|
const SoapySDR::ArgInfoList& getStreamArgInfoList();
|
2018-11-11 19:10:51 -05:00
|
|
|
const SoapySDR::ArgInfoList& getDeviceArgInfoList();
|
2018-11-07 17:54:32 -05:00
|
|
|
void initGainSettings(SoapySDROutputSettings& settings);
|
2018-11-15 16:25:33 -05:00
|
|
|
void initTunableElementsSettings(SoapySDROutputSettings& settings);
|
2018-11-11 03:31:27 -05:00
|
|
|
void initStreamArgSettings(SoapySDROutputSettings& settings);
|
2018-11-11 19:10:51 -05:00
|
|
|
void initDeviceArgSettings(SoapySDROutputSettings& settings);
|
2018-11-08 15:42:49 -05:00
|
|
|
bool hasDCAutoCorrection();
|
|
|
|
bool hasDCCorrectionValue();
|
|
|
|
bool hasIQAutoCorrection() { return false; } // not in SoapySDR interface
|
|
|
|
bool hasIQCorrectionValue();
|
2018-11-04 05:45:59 -05:00
|
|
|
|
2018-11-14 17:34:03 -05:00
|
|
|
virtual int webapiSettingsGet(
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
|
|
|
virtual int webapiSettingsPutPatch(
|
|
|
|
bool force,
|
|
|
|
const QStringList& deviceSettingsKeys,
|
|
|
|
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
|
|
|
QString& errorMessage);
|
|
|
|
|
|
|
|
virtual int webapiReportGet(
|
|
|
|
SWGSDRangel::SWGDeviceReport& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
|
|
|
virtual int webapiRunGet(
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
|
|
|
virtual int webapiRun(
|
|
|
|
bool run,
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
2018-10-29 13:27:58 -04:00
|
|
|
private:
|
2018-10-30 05:02:32 -04:00
|
|
|
DeviceSinkAPI *m_deviceAPI;
|
2018-11-04 05:45:59 -05:00
|
|
|
QMutex m_mutex;
|
2018-10-30 15:31:16 -04:00
|
|
|
SoapySDROutputSettings m_settings;
|
2018-10-29 13:27:58 -04:00
|
|
|
QString m_deviceDescription;
|
2018-10-30 05:02:32 -04:00
|
|
|
bool m_running;
|
2018-11-04 05:45:59 -05:00
|
|
|
SoapySDROutputThread *m_thread;
|
|
|
|
DeviceSoapySDRShared m_deviceShared;
|
2018-12-26 17:00:31 -05:00
|
|
|
QNetworkAccessManager *m_networkManager;
|
|
|
|
QNetworkRequest m_networkRequest;
|
2018-10-30 05:02:32 -04:00
|
|
|
|
|
|
|
bool openDevice();
|
|
|
|
void closeDevice();
|
2018-11-04 05:45:59 -05:00
|
|
|
SoapySDROutputThread *findThread();
|
|
|
|
void moveThreadToBuddy();
|
|
|
|
bool applySettings(const SoapySDROutputSettings& settings, bool force = false);
|
|
|
|
bool setDeviceCenterFrequency(SoapySDR::Device *dev, int requestedChannel, quint64 freq_hz, int loPpmTenths);
|
2018-11-07 17:54:32 -05:00
|
|
|
void updateGains(SoapySDR::Device *dev, int requestedChannel, SoapySDROutputSettings& settings);
|
2018-11-15 16:25:33 -05:00
|
|
|
void updateTunableElements(SoapySDR::Device *dev, int requestedChannel, SoapySDROutputSettings& settings);
|
2018-11-14 03:19:36 -05:00
|
|
|
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const SoapySDROutputSettings& settings);
|
|
|
|
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
|
2018-11-15 10:54:23 -05:00
|
|
|
QVariant webapiVariantFromArgValue(SWGSDRangel::SWGArgValue *argValue);
|
2018-11-14 03:19:36 -05:00
|
|
|
void webapiFormatArgValue(const QVariant& v, SWGSDRangel::SWGArgValue *argValue);
|
|
|
|
void webapiFormatArgInfo(const SoapySDR::ArgInfo& arg, SWGSDRangel::SWGArgInfo *argInfo);
|
2018-12-26 17:00:31 -05:00
|
|
|
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const SoapySDROutputSettings& settings, bool force);
|
|
|
|
void webapiReverseSendStartStop(bool start);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void networkManagerFinished(QNetworkReply *reply);
|
2018-10-29 13:27:58 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUT_H_ */
|