2019-11-14 19:04:24 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2019 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 //
|
|
|
|
// (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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef PLUGINS_CHANNELTX_REMOTESOURCE_REMOTESOURCESOURCE_H_
|
|
|
|
#define PLUGINS_CHANNELTX_REMOTESOURCE_REMOTESOURCESOURCE_H_
|
|
|
|
|
|
|
|
#include <QObject>
|
2020-07-12 04:03:08 -04:00
|
|
|
#include <QThread>
|
2019-11-14 19:04:24 -05:00
|
|
|
|
|
|
|
#include "cm256cc/cm256.h"
|
|
|
|
|
|
|
|
#include "dsp/channelsamplesource.h"
|
|
|
|
#include "dsp/interpolator.h"
|
|
|
|
#include "channel/remotedatablock.h"
|
|
|
|
#include "channel/remotedataqueue.h"
|
|
|
|
#include "channel/remotedatareadqueue.h"
|
|
|
|
|
|
|
|
#include "remotesourcesettings.h"
|
|
|
|
|
2020-07-12 04:03:08 -04:00
|
|
|
class RemoteSourceWorker;
|
2019-11-14 19:04:24 -05:00
|
|
|
|
|
|
|
class RemoteSourceSource : public QObject, public ChannelSampleSource {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
RemoteSourceSource();
|
|
|
|
~RemoteSourceSource();
|
|
|
|
|
|
|
|
virtual void pull(SampleVector::iterator begin, unsigned int nbSamples);
|
|
|
|
virtual void pullOne(Sample& sample);
|
2020-11-14 05:13:32 -05:00
|
|
|
virtual void prefetch(unsigned int nbSamples) { (void) nbSamples; }
|
2019-11-14 19:04:24 -05:00
|
|
|
|
|
|
|
void start();
|
|
|
|
void stop();
|
|
|
|
bool isRunning() const { return m_running; }
|
|
|
|
RemoteDataReadQueue& getDataQueue() { return m_dataReadQueue; }
|
|
|
|
void dataBind(const QString& m_dataAddress, uint16_t dataPort);
|
|
|
|
uint32_t getNbCorrectableErrors() const { return m_nbCorrectableErrors; }
|
|
|
|
uint32_t getNbUncorrectableErrors() const { return m_nbUncorrectableErrors; }
|
|
|
|
const RemoteMetaDataFEC& getRemoteMetaDataFEC() const { return m_currentMeta; }
|
|
|
|
|
|
|
|
void applyChannelSettings(int channelSampleRate, bool force = false);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void newRemoteSampleRate(unsigned int sampleRate);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_running;
|
2020-07-12 04:03:08 -04:00
|
|
|
RemoteSourceWorker *m_sourceWorker;
|
|
|
|
QThread m_sourceWorkerThread;
|
2019-11-14 19:04:24 -05:00
|
|
|
RemoteDataQueue m_dataQueue;
|
|
|
|
RemoteDataReadQueue m_dataReadQueue;
|
|
|
|
CM256 m_cm256;
|
|
|
|
CM256 *m_cm256p;
|
|
|
|
RemoteSourceSettings m_settings;
|
|
|
|
CM256::cm256_block m_cm256DescriptorBlocks[2*RemoteNbOrginalBlocks]; //!< CM256 decoder descriptors (block addresses and block indexes)
|
|
|
|
RemoteMetaDataFEC m_currentMeta;
|
|
|
|
uint32_t m_nbCorrectableErrors; //!< count of correctable errors in number of blocks
|
|
|
|
uint32_t m_nbUncorrectableErrors; //!< count of uncorrectable errors in number of blocks
|
|
|
|
|
|
|
|
int m_channelSampleRate;
|
|
|
|
Interpolator m_interpolator;
|
|
|
|
Real m_interpolatorDistance;
|
|
|
|
Real m_interpolatorDistanceRemain;
|
|
|
|
bool m_interpolatorConsumed;
|
|
|
|
Complex m_modSample;
|
|
|
|
|
2020-07-12 04:03:08 -04:00
|
|
|
void startWorker();
|
|
|
|
void stopWorker();
|
2019-11-14 19:04:24 -05:00
|
|
|
void handleDataBlock(RemoteDataBlock *dataBlock);
|
|
|
|
void printMeta(const QString& header, RemoteMetaDataFEC *metaData);
|
|
|
|
void getSample();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void handleData();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PLUGINS_CHANNELTX_REMOTESOURCE_REMOTESOURCESOURCE_H_
|