2016-01-24 13:21:21 -05: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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef INCLUDE_SDRDAEMONINPUT_H
|
|
|
|
#define INCLUDE_SDRDAEMONINPUT_H
|
|
|
|
|
|
|
|
#include "dsp/samplesource.h"
|
|
|
|
#include <QString>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <ctime>
|
|
|
|
#include <iostream>
|
2016-02-14 14:01:46 -05:00
|
|
|
#include <stdint.h>
|
2016-01-24 13:21:21 -05:00
|
|
|
|
2016-02-16 20:22:05 -05:00
|
|
|
class SDRdaemonUDPHandler;
|
2016-01-24 13:21:21 -05:00
|
|
|
|
|
|
|
class SDRdaemonInput : public SampleSource {
|
|
|
|
public:
|
2016-02-01 02:24:14 -05:00
|
|
|
class MsgConfigureSDRdaemonUDPLink : public Message {
|
2016-01-24 13:21:21 -05:00
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2016-02-01 02:24:14 -05:00
|
|
|
const QString& getAddress() const { return m_address; }
|
|
|
|
quint16 getPort() const { return m_port; }
|
2016-01-24 13:21:21 -05:00
|
|
|
|
2016-02-01 02:24:14 -05:00
|
|
|
static MsgConfigureSDRdaemonUDPLink* create(const QString& address, quint16 port)
|
2016-01-24 13:21:21 -05:00
|
|
|
{
|
2016-02-01 02:24:14 -05:00
|
|
|
return new MsgConfigureSDRdaemonUDPLink(address, port);
|
2016-01-24 13:21:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2016-02-01 02:24:14 -05:00
|
|
|
QString m_address;
|
|
|
|
quint16 m_port;
|
2016-01-24 13:21:21 -05:00
|
|
|
|
2016-02-01 02:24:14 -05:00
|
|
|
MsgConfigureSDRdaemonUDPLink(const QString& address, quint16 port) :
|
2016-01-24 13:21:21 -05:00
|
|
|
Message(),
|
2016-02-01 02:24:14 -05:00
|
|
|
m_address(address),
|
|
|
|
m_port(port)
|
2016-01-24 13:21:21 -05:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2016-02-17 17:47:03 -05:00
|
|
|
class MsgConfigureSDRdaemonAutoCorr : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
public:
|
|
|
|
bool getDCBlock() const { return m_dcBlock; }
|
|
|
|
bool getIQImbalance() const { return m_iqCorrection; }
|
|
|
|
|
|
|
|
static MsgConfigureSDRdaemonAutoCorr* create(bool dcBlock, bool iqImbalance)
|
|
|
|
{
|
|
|
|
return new MsgConfigureSDRdaemonAutoCorr(dcBlock, iqImbalance);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_dcBlock;
|
|
|
|
bool m_iqCorrection;
|
|
|
|
|
|
|
|
MsgConfigureSDRdaemonAutoCorr(bool dcBlock, bool iqImbalance) :
|
|
|
|
Message(),
|
|
|
|
m_dcBlock(dcBlock),
|
|
|
|
m_iqCorrection(iqImbalance)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2016-01-24 13:21:21 -05:00
|
|
|
class MsgConfigureSDRdaemonWork : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool isWorking() const { return m_working; }
|
|
|
|
|
|
|
|
static MsgConfigureSDRdaemonWork* create(bool working)
|
|
|
|
{
|
|
|
|
return new MsgConfigureSDRdaemonWork(working);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_working;
|
|
|
|
|
|
|
|
MsgConfigureSDRdaemonWork(bool working) :
|
|
|
|
Message(),
|
|
|
|
m_working(working)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2016-03-18 09:03:34 -04:00
|
|
|
class MsgConfigureSDRdaemonAutoFollowPolicy : public Message {
|
2016-03-10 23:25:25 -05:00
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool autoFollowRate() const { return m_autoFollowRate; }
|
2016-03-18 09:03:34 -04:00
|
|
|
bool autoCorrBuffer() const { return m_autoCorrBuffer; }
|
2016-03-10 23:25:25 -05:00
|
|
|
|
2016-03-18 09:03:34 -04:00
|
|
|
static MsgConfigureSDRdaemonAutoFollowPolicy* create(bool autoFollowRate, bool autoCorrBuffer)
|
2016-03-10 23:25:25 -05:00
|
|
|
{
|
2016-03-18 09:03:34 -04:00
|
|
|
return new MsgConfigureSDRdaemonAutoFollowPolicy(autoFollowRate, autoCorrBuffer);
|
2016-03-10 23:25:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_autoFollowRate;
|
2016-03-18 09:03:34 -04:00
|
|
|
bool m_autoCorrBuffer;
|
2016-03-10 23:25:25 -05:00
|
|
|
|
2016-03-18 09:03:34 -04:00
|
|
|
MsgConfigureSDRdaemonAutoFollowPolicy(bool autoFollowRate, bool autoCorrBuffer) :
|
2016-03-10 23:25:25 -05:00
|
|
|
Message(),
|
2016-03-18 09:03:34 -04:00
|
|
|
m_autoFollowRate(autoFollowRate),
|
|
|
|
m_autoCorrBuffer(autoCorrBuffer)
|
2016-03-10 23:25:25 -05:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2016-03-18 09:03:34 -04:00
|
|
|
class MsgConfigureSDRdaemonResetIndexes : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
public:
|
|
|
|
static MsgConfigureSDRdaemonResetIndexes* create()
|
|
|
|
{
|
|
|
|
return new MsgConfigureSDRdaemonResetIndexes();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
MsgConfigureSDRdaemonResetIndexes() :
|
|
|
|
Message()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2016-01-24 13:21:21 -05: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)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgReportSDRdaemonStreamData : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2016-02-22 09:03:16 -05:00
|
|
|
int getSampleRateStream() const { return m_sampleRateStream; }
|
2016-01-24 13:21:21 -05:00
|
|
|
int getSampleRate() const { return m_sampleRate; }
|
|
|
|
quint64 getCenterFrequency() const { return m_centerFrequency; }
|
2016-02-14 14:01:46 -05:00
|
|
|
uint32_t get_tv_sec() const { return m_tv_sec; }
|
|
|
|
uint32_t get_tv_usec() const { return m_tv_usec; }
|
2016-01-24 13:21:21 -05:00
|
|
|
|
2016-02-22 09:03:16 -05:00
|
|
|
static MsgReportSDRdaemonStreamData* create(int sampleRateStream, int sampleRate, quint64 centerFrequency, uint32_t tv_sec, uint32_t tv_usec)
|
2016-01-24 13:21:21 -05:00
|
|
|
{
|
2016-02-22 09:03:16 -05:00
|
|
|
return new MsgReportSDRdaemonStreamData(sampleRateStream, sampleRate, centerFrequency, tv_sec, tv_usec);
|
2016-01-24 13:21:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2016-02-22 09:03:16 -05:00
|
|
|
int m_sampleRateStream;
|
2016-01-24 13:21:21 -05:00
|
|
|
int m_sampleRate;
|
|
|
|
quint64 m_centerFrequency;
|
2016-02-14 14:01:46 -05:00
|
|
|
uint32_t m_tv_sec;
|
|
|
|
uint32_t m_tv_usec;
|
2016-01-24 13:21:21 -05:00
|
|
|
|
2016-02-22 09:03:16 -05:00
|
|
|
MsgReportSDRdaemonStreamData(int sampleRateStream, int sampleRate, quint64 centerFrequency, uint32_t tv_sec, uint32_t tv_usec) :
|
2016-01-24 13:21:21 -05:00
|
|
|
Message(),
|
2016-02-22 09:03:16 -05:00
|
|
|
m_sampleRateStream(sampleRateStream),
|
2016-01-24 13:21:21 -05:00
|
|
|
m_sampleRate(sampleRate),
|
|
|
|
m_centerFrequency(centerFrequency),
|
2016-02-14 14:01:46 -05:00
|
|
|
m_tv_sec(tv_sec),
|
|
|
|
m_tv_usec(tv_usec)
|
2016-01-24 13:21:21 -05:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
class MsgReportSDRdaemonStreamTiming : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2016-02-16 20:22:05 -05:00
|
|
|
uint32_t get_tv_sec() const { return m_tv_sec; }
|
|
|
|
uint32_t get_tv_usec() const { return m_tv_usec; }
|
2016-02-23 08:57:40 -05:00
|
|
|
bool getSyncLock() const { return m_syncLock; }
|
2016-02-23 12:09:20 -05:00
|
|
|
uint32_t getFrameSize() const { return m_frameSize; }
|
2016-02-23 12:19:35 -05:00
|
|
|
bool getLz4Compression() const { return m_lz4; }
|
2016-02-23 13:27:47 -05:00
|
|
|
float getLz4CompressionRatio() const { return m_compressionRatio; }
|
|
|
|
uint32_t getLz4DataCRCOK() const { return m_nbLz4CRCOK; }
|
|
|
|
uint32_t getLz4SuccessfulDecodes() const { return m_nbLz4SuccessfulDecodes; }
|
2016-03-17 10:41:48 -04:00
|
|
|
int32_t getBufferGauge() const { return m_bufferGauge; }
|
2016-01-24 13:21:21 -05:00
|
|
|
|
2016-02-23 08:57:40 -05:00
|
|
|
static MsgReportSDRdaemonStreamTiming* create(uint32_t tv_sec,
|
|
|
|
uint32_t tv_usec,
|
2016-02-23 12:09:20 -05:00
|
|
|
bool syncLock,
|
2016-02-23 12:19:35 -05:00
|
|
|
uint32_t frameSize,
|
2016-02-23 12:29:08 -05:00
|
|
|
bool lz4,
|
2016-02-23 13:27:47 -05:00
|
|
|
float compressionRatio,
|
|
|
|
uint32_t nbLz4CRCOK,
|
2016-03-17 10:41:48 -04:00
|
|
|
uint32_t nbLz4SuccessfulDecodes,
|
|
|
|
int32_t bufferGauge)
|
2016-01-24 13:21:21 -05:00
|
|
|
{
|
2016-02-23 08:57:40 -05:00
|
|
|
return new MsgReportSDRdaemonStreamTiming(tv_sec,
|
|
|
|
tv_usec,
|
2016-02-23 12:09:20 -05:00
|
|
|
syncLock,
|
2016-02-23 12:19:35 -05:00
|
|
|
frameSize,
|
2016-02-23 12:29:08 -05:00
|
|
|
lz4,
|
2016-02-23 13:27:47 -05:00
|
|
|
compressionRatio,
|
|
|
|
nbLz4CRCOK,
|
2016-03-17 10:41:48 -04:00
|
|
|
nbLz4SuccessfulDecodes,
|
|
|
|
bufferGauge);
|
2016-01-24 13:21:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2016-02-16 20:22:05 -05:00
|
|
|
uint32_t m_tv_sec;
|
|
|
|
uint32_t m_tv_usec;
|
2016-02-23 08:57:40 -05:00
|
|
|
bool m_syncLock;
|
2016-02-23 12:09:20 -05:00
|
|
|
uint32_t m_frameSize;
|
2016-02-23 12:19:35 -05:00
|
|
|
bool m_lz4;
|
2016-02-23 12:29:08 -05:00
|
|
|
float m_compressionRatio;
|
2016-02-23 13:27:47 -05:00
|
|
|
uint32_t m_nbLz4CRCOK;
|
|
|
|
uint32_t m_nbLz4SuccessfulDecodes;
|
2016-03-17 10:41:48 -04:00
|
|
|
int32_t m_bufferGauge;
|
2016-01-24 13:21:21 -05:00
|
|
|
|
2016-02-23 08:57:40 -05:00
|
|
|
MsgReportSDRdaemonStreamTiming(uint32_t tv_sec,
|
|
|
|
uint32_t tv_usec,
|
2016-02-23 12:09:20 -05:00
|
|
|
bool syncLock,
|
2016-02-23 12:19:35 -05:00
|
|
|
uint32_t frameSize,
|
2016-02-23 12:29:08 -05:00
|
|
|
bool lz4,
|
2016-02-23 13:27:47 -05:00
|
|
|
float compressionRatio,
|
|
|
|
uint32_t nbLz4CRCOK,
|
2016-03-17 10:41:48 -04:00
|
|
|
uint32_t nbLz4SuccessfulDecodes,
|
|
|
|
int32_t bufferGauge) :
|
2016-01-24 13:21:21 -05:00
|
|
|
Message(),
|
2016-02-16 20:22:05 -05:00
|
|
|
m_tv_sec(tv_sec),
|
2016-02-23 08:57:40 -05:00
|
|
|
m_tv_usec(tv_usec),
|
2016-02-23 12:09:20 -05:00
|
|
|
m_syncLock(syncLock),
|
2016-02-23 12:19:35 -05:00
|
|
|
m_frameSize(frameSize),
|
2016-02-23 12:29:08 -05:00
|
|
|
m_lz4(lz4),
|
2016-02-23 13:27:47 -05:00
|
|
|
m_compressionRatio(compressionRatio),
|
|
|
|
m_nbLz4CRCOK(nbLz4CRCOK),
|
2016-03-17 10:41:48 -04:00
|
|
|
m_nbLz4SuccessfulDecodes(nbLz4SuccessfulDecodes),
|
|
|
|
m_bufferGauge(bufferGauge)
|
2016-01-24 13:21:21 -05:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
SDRdaemonInput(const QTimer& masterTimer);
|
|
|
|
virtual ~SDRdaemonInput();
|
|
|
|
|
|
|
|
virtual bool init(const Message& message);
|
|
|
|
virtual bool start(int device);
|
|
|
|
virtual void stop();
|
|
|
|
|
|
|
|
virtual const QString& getDeviceDescription() const;
|
|
|
|
virtual int getSampleRate() const;
|
|
|
|
virtual quint64 getCenterFrequency() const;
|
|
|
|
std::time_t getStartingTimeStamp() const;
|
|
|
|
|
|
|
|
virtual bool handleMessage(const Message& message);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QMutex m_mutex;
|
2016-02-01 02:24:14 -05:00
|
|
|
QString m_address;
|
|
|
|
quint16 m_port;
|
2016-02-16 20:22:05 -05:00
|
|
|
SDRdaemonUDPHandler* m_SDRdaemonUDPHandler;
|
2016-01-24 13:21:21 -05:00
|
|
|
QString m_deviceDescription;
|
|
|
|
int m_sampleRate;
|
|
|
|
quint64 m_centerFrequency;
|
|
|
|
std::time_t m_startingTimeStamp;
|
|
|
|
const QTimer& m_masterTimer;
|
2016-03-18 09:03:34 -04:00
|
|
|
bool m_autoFollowRate;
|
|
|
|
bool m_autoCorrBuffer;
|
2016-01-24 13:21:21 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDE_SDRDAEMONINPUT_H
|