2016-06-19 03:56:49 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016 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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2017-06-09 07:42:33 -04:00
|
|
|
#ifndef INCLUDE_SDRDAEMONSOURCEINPUT_H
|
|
|
|
#define INCLUDE_SDRDAEMONSOURCEINPUT_H
|
2016-06-19 03:56:49 -04:00
|
|
|
|
|
|
|
#include <QString>
|
2017-12-27 21:21:48 -05:00
|
|
|
#include <QByteArray>
|
2016-06-19 03:56:49 -04:00
|
|
|
#include <QTimer>
|
|
|
|
#include <ctime>
|
|
|
|
#include <iostream>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
#include <dsp/devicesamplesource.h>
|
2017-06-09 07:58:27 -04:00
|
|
|
#include "sdrdaemonsourcesettings.h"
|
2017-06-07 20:06:36 -04:00
|
|
|
|
2016-10-10 19:17:55 -04:00
|
|
|
class DeviceSourceAPI;
|
2017-06-09 08:14:32 -04:00
|
|
|
class SDRdaemonSourceUDPHandler;
|
2017-09-04 18:31:45 -04:00
|
|
|
class FileRecord;
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
class SDRdaemonSourceInput : public DeviceSampleSource {
|
2016-06-19 03:56:49 -04:00
|
|
|
public:
|
2017-06-09 08:14:32 -04:00
|
|
|
class MsgConfigureSDRdaemonSource : public Message {
|
2017-06-07 20:06:36 -04:00
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2017-06-09 08:14:32 -04:00
|
|
|
const SDRdaemonSourceSettings& getSettings() const { return m_settings; }
|
2017-06-07 20:06:36 -04:00
|
|
|
bool getForce() const { return m_force; }
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
static MsgConfigureSDRdaemonSource* create(const SDRdaemonSourceSettings& settings, bool force = false)
|
2017-06-07 20:06:36 -04:00
|
|
|
{
|
2017-06-09 08:14:32 -04:00
|
|
|
return new MsgConfigureSDRdaemonSource(settings, force);
|
2017-06-07 20:06:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-06-09 08:14:32 -04:00
|
|
|
SDRdaemonSourceSettings m_settings;
|
2017-06-07 20:06:36 -04:00
|
|
|
bool m_force;
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
MsgConfigureSDRdaemonSource(const SDRdaemonSourceSettings& settings, bool force) :
|
2017-06-07 20:06:36 -04:00
|
|
|
Message(),
|
|
|
|
m_settings(settings),
|
|
|
|
m_force(force)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2016-06-19 03:56:49 -04:00
|
|
|
class MsgConfigureSDRdaemonStreamTiming : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
static MsgConfigureSDRdaemonStreamTiming* create()
|
|
|
|
{
|
|
|
|
return new MsgConfigureSDRdaemonStreamTiming();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
MsgConfigureSDRdaemonStreamTiming() :
|
|
|
|
Message()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgReportSDRdaemonAcquisition : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool getAcquisition() const { return m_acquisition; }
|
|
|
|
|
|
|
|
static MsgReportSDRdaemonAcquisition* create(bool acquisition)
|
|
|
|
{
|
|
|
|
return new MsgReportSDRdaemonAcquisition(acquisition);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_acquisition;
|
|
|
|
|
|
|
|
MsgReportSDRdaemonAcquisition(bool acquisition) :
|
|
|
|
Message(),
|
|
|
|
m_acquisition(acquisition)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
class MsgReportSDRdaemonSourceStreamData : public Message {
|
2016-06-19 03:56:49 -04:00
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
int getSampleRate() const { return m_sampleRate; }
|
|
|
|
quint64 getCenterFrequency() const { return m_centerFrequency; }
|
|
|
|
uint32_t get_tv_sec() const { return m_tv_sec; }
|
|
|
|
uint32_t get_tv_usec() const { return m_tv_usec; }
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
static MsgReportSDRdaemonSourceStreamData* create(int sampleRate, quint64 centerFrequency, uint32_t tv_sec, uint32_t tv_usec)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-09 08:14:32 -04:00
|
|
|
return new MsgReportSDRdaemonSourceStreamData(sampleRate, centerFrequency, tv_sec, tv_usec);
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int m_sampleRate;
|
|
|
|
quint64 m_centerFrequency;
|
|
|
|
uint32_t m_tv_sec;
|
|
|
|
uint32_t m_tv_usec;
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
MsgReportSDRdaemonSourceStreamData(int sampleRate, quint64 centerFrequency, uint32_t tv_sec, uint32_t tv_usec) :
|
2016-06-19 03:56:49 -04:00
|
|
|
Message(),
|
|
|
|
m_sampleRate(sampleRate),
|
|
|
|
m_centerFrequency(centerFrequency),
|
|
|
|
m_tv_sec(tv_sec),
|
|
|
|
m_tv_usec(tv_usec)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
class MsgReportSDRdaemonSourceStreamTiming : public Message {
|
2016-06-19 03:56:49 -04:00
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
uint32_t get_tv_sec() const { return m_tv_sec; }
|
|
|
|
uint32_t get_tv_usec() const { return m_tv_usec; }
|
2016-07-24 05:09:11 -04:00
|
|
|
int getFramesDecodingStatus() const { return m_framesDecodingStatus; }
|
2016-07-27 22:49:33 -04:00
|
|
|
bool allBlocksReceived() const { return m_allBlocksReceived; }
|
2016-06-19 03:56:49 -04:00
|
|
|
float getBufferLengthInSecs() const { return m_bufferLenSec; }
|
|
|
|
int32_t getBufferGauge() const { return m_bufferGauge; }
|
2016-07-17 18:39:35 -04:00
|
|
|
int getMinNbBlocks() const { return m_minNbBlocks; }
|
2016-07-27 12:49:17 -04:00
|
|
|
int getMinNbOriginalBlocks() const { return m_minNbOriginalBlocks; }
|
|
|
|
int getMaxNbRecovery() const { return m_maxNbRecovery; }
|
2016-06-19 18:45:24 -04:00
|
|
|
float getAvgNbBlocks() const { return m_avgNbBlocks; }
|
2016-07-27 12:49:17 -04:00
|
|
|
float getAvgNbOriginalBlocks() const { return m_avgNbOriginalBlocks; }
|
2016-06-19 18:45:24 -04:00
|
|
|
float getAvgNbRecovery() const { return m_avgNbRecovery; }
|
2016-07-24 05:09:11 -04:00
|
|
|
int getNbOriginalBlocksPerFrame() const { return m_nbOriginalBlocksPerFrame; }
|
|
|
|
int getNbFECBlocksPerFrame() const { return m_nbFECBlocksPerFrame; }
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
static MsgReportSDRdaemonSourceStreamTiming* create(uint32_t tv_sec,
|
2016-06-19 03:56:49 -04:00
|
|
|
uint32_t tv_usec,
|
|
|
|
float bufferLenSec,
|
2016-06-19 18:45:24 -04:00
|
|
|
int32_t bufferGauge,
|
2016-07-24 05:09:11 -04:00
|
|
|
int framesDecodingStatus,
|
2016-07-27 22:49:33 -04:00
|
|
|
bool allBlocksReceived,
|
2016-07-27 12:49:17 -04:00
|
|
|
int minNbBlocks,
|
|
|
|
int minNbOriginalBlocks,
|
|
|
|
int maxNbRecovery,
|
2016-06-19 18:45:24 -04:00
|
|
|
float avgNbBlocks,
|
2016-07-27 12:49:17 -04:00
|
|
|
float avgNbOriginalBlocks,
|
2016-07-24 05:09:11 -04:00
|
|
|
float avgNbRecovery,
|
|
|
|
int nbOriginalBlocksPerFrame,
|
|
|
|
int nbFECBlocksPerFrame)
|
2016-06-19 03:56:49 -04:00
|
|
|
{
|
2017-06-09 08:14:32 -04:00
|
|
|
return new MsgReportSDRdaemonSourceStreamTiming(tv_sec,
|
2016-06-19 03:56:49 -04:00
|
|
|
tv_usec,
|
|
|
|
bufferLenSec,
|
2016-06-19 18:45:24 -04:00
|
|
|
bufferGauge,
|
2016-07-24 05:09:11 -04:00
|
|
|
framesDecodingStatus,
|
2016-07-27 22:49:33 -04:00
|
|
|
allBlocksReceived,
|
2016-07-27 12:49:17 -04:00
|
|
|
minNbBlocks,
|
|
|
|
minNbOriginalBlocks,
|
|
|
|
maxNbRecovery,
|
2016-06-19 18:45:24 -04:00
|
|
|
avgNbBlocks,
|
2016-07-27 12:49:17 -04:00
|
|
|
avgNbOriginalBlocks,
|
2016-07-24 05:09:11 -04:00
|
|
|
avgNbRecovery,
|
|
|
|
nbOriginalBlocksPerFrame,
|
|
|
|
nbFECBlocksPerFrame);
|
2016-06-19 03:56:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
uint32_t m_tv_sec;
|
|
|
|
uint32_t m_tv_usec;
|
2016-07-24 05:09:11 -04:00
|
|
|
int m_framesDecodingStatus;
|
2016-07-27 22:49:33 -04:00
|
|
|
bool m_allBlocksReceived;
|
2016-06-19 18:45:24 -04:00
|
|
|
float m_bufferLenSec;
|
|
|
|
int32_t m_bufferGauge;
|
2016-07-17 18:39:35 -04:00
|
|
|
int m_minNbBlocks;
|
2016-07-27 12:49:17 -04:00
|
|
|
int m_minNbOriginalBlocks;
|
2016-07-17 18:39:35 -04:00
|
|
|
int m_maxNbRecovery;
|
2016-06-19 18:45:24 -04:00
|
|
|
float m_avgNbBlocks;
|
2016-07-27 12:49:17 -04:00
|
|
|
float m_avgNbOriginalBlocks;
|
2016-06-19 18:45:24 -04:00
|
|
|
float m_avgNbRecovery;
|
2016-07-24 05:09:11 -04:00
|
|
|
int m_nbOriginalBlocksPerFrame;
|
|
|
|
int m_nbFECBlocksPerFrame;
|
2016-06-19 18:45:24 -04:00
|
|
|
|
2017-06-09 08:14:32 -04:00
|
|
|
MsgReportSDRdaemonSourceStreamTiming(uint32_t tv_sec,
|
2016-06-19 03:56:49 -04:00
|
|
|
uint32_t tv_usec,
|
|
|
|
float bufferLenSec,
|
2016-06-19 18:45:24 -04:00
|
|
|
int32_t bufferGauge,
|
2016-07-24 05:09:11 -04:00
|
|
|
int framesDecodingStatus,
|
2016-07-27 22:49:33 -04:00
|
|
|
bool allBlocksReceived,
|
2016-07-27 12:49:17 -04:00
|
|
|
int minNbBlocks,
|
|
|
|
int minNbOriginalBlocks,
|
|
|
|
int maxNbRecovery,
|
2016-06-19 18:45:24 -04:00
|
|
|
float avgNbBlocks,
|
2016-07-27 12:49:17 -04:00
|
|
|
float avgNbOriginalBlocks,
|
2016-07-24 05:09:11 -04:00
|
|
|
float avgNbRecovery,
|
|
|
|
int nbOriginalBlocksPerFrame,
|
|
|
|
int nbFECBlocksPerFrame) :
|
2016-06-19 03:56:49 -04:00
|
|
|
Message(),
|
|
|
|
m_tv_sec(tv_sec),
|
|
|
|
m_tv_usec(tv_usec),
|
2016-07-24 05:09:11 -04:00
|
|
|
m_framesDecodingStatus(framesDecodingStatus),
|
2016-07-27 22:49:33 -04:00
|
|
|
m_allBlocksReceived(allBlocksReceived),
|
2016-06-19 03:56:49 -04:00
|
|
|
m_bufferLenSec(bufferLenSec),
|
2016-06-19 18:45:24 -04:00
|
|
|
m_bufferGauge(bufferGauge),
|
2016-07-27 12:49:17 -04:00
|
|
|
m_minNbBlocks(minNbBlocks),
|
|
|
|
m_minNbOriginalBlocks(minNbOriginalBlocks),
|
|
|
|
m_maxNbRecovery(maxNbRecovery),
|
2016-06-19 18:45:24 -04:00
|
|
|
m_avgNbBlocks(avgNbBlocks),
|
2016-07-27 12:49:17 -04:00
|
|
|
m_avgNbOriginalBlocks(avgNbOriginalBlocks),
|
2016-07-24 05:09:11 -04:00
|
|
|
m_avgNbRecovery(avgNbRecovery),
|
|
|
|
m_nbOriginalBlocksPerFrame(nbOriginalBlocksPerFrame),
|
|
|
|
m_nbFECBlocksPerFrame(nbFECBlocksPerFrame)
|
2016-06-19 03:56:49 -04:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-09-04 18:31:45 -04:00
|
|
|
class MsgFileRecord : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool getStartStop() const { return m_startStop; }
|
|
|
|
|
|
|
|
static MsgFileRecord* create(bool startStop) {
|
|
|
|
return new MsgFileRecord(startStop);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_startStop;
|
|
|
|
|
|
|
|
MsgFileRecord(bool startStop) :
|
|
|
|
Message(),
|
|
|
|
m_startStop(startStop)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-12-13 18:19: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)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-09-14 07:34:32 -04:00
|
|
|
SDRdaemonSourceInput(DeviceSourceAPI *deviceAPI);
|
2017-06-09 08:14:32 -04:00
|
|
|
virtual ~SDRdaemonSourceInput();
|
2017-09-14 20:32:30 -04:00
|
|
|
virtual void destroy();
|
2016-06-19 03:56:49 -04:00
|
|
|
|
2017-12-25 03:10:19 -05:00
|
|
|
virtual void init();
|
2017-04-13 21:40:45 -04:00
|
|
|
virtual bool start();
|
2016-06-19 03:56:49 -04:00
|
|
|
virtual void stop();
|
|
|
|
|
2017-12-27 21:21:48 -05:00
|
|
|
virtual QByteArray serialize() const;
|
|
|
|
virtual bool deserialize(const QByteArray& data);
|
|
|
|
|
2017-12-24 13:58:26 -05:00
|
|
|
virtual void setMessageQueueToGUI(MessageQueue *queue);
|
2016-06-19 03:56:49 -04:00
|
|
|
virtual const QString& getDeviceDescription() const;
|
|
|
|
virtual int getSampleRate() const;
|
|
|
|
virtual quint64 getCenterFrequency() const;
|
2017-12-27 21:21:48 -05:00
|
|
|
virtual void setCenterFrequency(qint64 centerFrequency);
|
2016-06-19 03:56:49 -04:00
|
|
|
std::time_t getStartingTimeStamp() const;
|
2017-12-25 20:18:30 -05:00
|
|
|
bool isStreaming() const;
|
2016-06-19 03:56:49 -04:00
|
|
|
|
|
|
|
virtual bool handleMessage(const Message& message);
|
|
|
|
|
2017-12-09 06:41:42 -05:00
|
|
|
virtual int webapiRunGet(
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
|
|
|
virtual int webapiRun(
|
|
|
|
bool run,
|
|
|
|
SWGSDRangel::SWGDeviceState& response,
|
|
|
|
QString& errorMessage);
|
|
|
|
|
2016-06-19 03:56:49 -04:00
|
|
|
private:
|
2016-10-10 19:17:55 -04:00
|
|
|
DeviceSourceAPI *m_deviceAPI;
|
2016-06-19 03:56:49 -04:00
|
|
|
QMutex m_mutex;
|
2017-11-19 12:17:28 -05:00
|
|
|
SDRdaemonSourceSettings m_settings;
|
2017-06-09 08:14:32 -04:00
|
|
|
SDRdaemonSourceUDPHandler* m_SDRdaemonUDPHandler;
|
2017-12-25 20:18:30 -05:00
|
|
|
QString m_remoteAddress;
|
|
|
|
int m_sender;
|
2016-06-19 03:56:49 -04:00
|
|
|
QString m_deviceDescription;
|
|
|
|
std::time_t m_startingTimeStamp;
|
|
|
|
bool m_autoFollowRate;
|
|
|
|
bool m_autoCorrBuffer;
|
2017-09-04 18:31:45 -04:00
|
|
|
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
2017-12-25 20:18:30 -05:00
|
|
|
|
|
|
|
void applySettings(const SDRdaemonSourceSettings& settings, bool force = false);
|
2016-06-19 03:56:49 -04:00
|
|
|
};
|
|
|
|
|
2017-06-09 07:42:33 -04:00
|
|
|
#endif // INCLUDE_SDRDAEMONSOURCEINPUT_H
|