2017-01-02 21:07:43 -05:00
|
|
|
// Copyright (c) Charles J. Cliffe
|
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
|
2014-11-16 16:51:45 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <queue>
|
|
|
|
#include <vector>
|
2017-02-18 04:48:56 -05:00
|
|
|
#include <atomic>
|
2017-08-13 12:49:47 -04:00
|
|
|
#include <memory>
|
2014-11-16 16:51:45 -05:00
|
|
|
|
2014-11-22 22:17:33 -05:00
|
|
|
#include "CubicSDRDefs.h"
|
2014-12-11 19:07:21 -05:00
|
|
|
#include "DemodDefs.h"
|
2014-12-16 18:27:02 -05:00
|
|
|
#include "DemodulatorWorkerThread.h"
|
2014-11-22 22:17:33 -05:00
|
|
|
|
2015-11-22 19:56:25 -05:00
|
|
|
class DemodulatorInstance;
|
|
|
|
|
2015-07-29 20:57:02 -04:00
|
|
|
class DemodulatorPreThread : public IOThread {
|
2014-11-16 16:51:45 -05:00
|
|
|
public:
|
2014-11-17 22:58:56 -05:00
|
|
|
|
2017-08-27 05:11:30 -04:00
|
|
|
DemodulatorPreThread(DemodulatorInstance* parent);
|
2017-05-24 06:24:36 -04:00
|
|
|
virtual ~DemodulatorPreThread();
|
2014-12-01 18:59:07 -05:00
|
|
|
|
2016-06-28 15:04:52 -04:00
|
|
|
virtual void run();
|
2015-11-17 20:47:00 -05:00
|
|
|
|
|
|
|
void setDemodType(std::string demodType);
|
|
|
|
std::string getDemodType();
|
2015-01-08 21:12:49 -05:00
|
|
|
|
2015-11-22 23:25:45 -05:00
|
|
|
void setFrequency(long long sampleRate);
|
|
|
|
long long getFrequency();
|
|
|
|
|
|
|
|
void setSampleRate(long long sampleRate);
|
|
|
|
long long getSampleRate();
|
|
|
|
|
|
|
|
void setBandwidth(int bandwidth);
|
|
|
|
int getBandwidth();
|
|
|
|
|
|
|
|
void setAudioSampleRate(int rate);
|
|
|
|
int getAudioSampleRate();
|
|
|
|
|
2015-11-26 01:54:54 -05:00
|
|
|
bool isInitialized();
|
|
|
|
|
2016-06-28 15:04:52 -04:00
|
|
|
virtual void terminate();
|
2014-11-26 21:05:19 -05:00
|
|
|
|
2015-11-18 23:40:30 -05:00
|
|
|
Modem *getModem();
|
|
|
|
ModemKit *getModemKit();
|
|
|
|
|
2015-11-26 01:54:54 -05:00
|
|
|
std::string readModemSetting(std::string setting);
|
|
|
|
void writeModemSetting(std::string setting, std::string value);
|
|
|
|
ModemSettings readModemSettings();
|
|
|
|
void writeModemSettings(ModemSettings settings);
|
|
|
|
|
2014-11-16 16:51:45 -05:00
|
|
|
protected:
|
2017-08-27 05:11:30 -04:00
|
|
|
|
|
|
|
DemodulatorInstance* parent;
|
|
|
|
|
2015-01-03 17:07:39 -05:00
|
|
|
msresamp_crcf iqResampler;
|
|
|
|
double iqResampleRatio;
|
2015-01-04 13:20:31 -05:00
|
|
|
std::vector<liquid_float_complex> resampledData;
|
2014-11-16 16:51:45 -05:00
|
|
|
|
2015-11-17 19:32:47 -05:00
|
|
|
Modem *cModem;
|
|
|
|
ModemKit *cModemKit;
|
2015-11-22 23:25:45 -05:00
|
|
|
|
2017-02-18 04:48:56 -05:00
|
|
|
std::atomic_llong currentSampleRate, newSampleRate;
|
|
|
|
std::atomic_llong currentFrequency, newFrequency;
|
|
|
|
std::atomic_int currentBandwidth, newBandwidth;
|
|
|
|
std::atomic_int currentAudioSampleRate, newAudioSampleRate;
|
2015-03-15 21:02:26 -04:00
|
|
|
|
2015-11-22 23:25:45 -05:00
|
|
|
std::atomic_bool sampleRateChanged, frequencyChanged, bandwidthChanged, audioSampleRateChanged;
|
2015-11-26 01:54:54 -05:00
|
|
|
|
|
|
|
ModemSettings modemSettingsBuffered;
|
|
|
|
std::atomic_bool modemSettingsChanged;
|
2015-11-22 23:25:45 -05:00
|
|
|
|
2015-01-03 17:07:39 -05:00
|
|
|
nco_crcf freqShifter;
|
|
|
|
int shiftFrequency;
|
2014-11-27 22:13:21 -05:00
|
|
|
|
2015-07-19 23:19:10 -04:00
|
|
|
std::atomic_bool initialized;
|
2015-11-17 20:47:00 -05:00
|
|
|
std::atomic_bool demodTypeChanged;
|
|
|
|
std::string demodType;
|
2015-11-17 21:49:02 -05:00
|
|
|
std::string newDemodType;
|
2014-11-30 23:33:55 -05:00
|
|
|
|
2014-12-16 21:30:03 -05:00
|
|
|
DemodulatorWorkerThread *workerThread;
|
|
|
|
std::thread *t_Worker;
|
2014-11-30 23:33:55 -05:00
|
|
|
|
2017-08-13 12:49:47 -04:00
|
|
|
DemodulatorThreadWorkerCommandQueuePtr workerQueue;
|
|
|
|
DemodulatorThreadWorkerResultQueuePtr workerResults;
|
2015-07-30 00:28:53 -04:00
|
|
|
|
2017-08-13 12:49:47 -04:00
|
|
|
DemodulatorThreadInputQueuePtr iqInputQueue;
|
|
|
|
DemodulatorThreadPostInputQueuePtr iqOutputQueue;
|
2014-11-16 16:51:45 -05:00
|
|
|
};
|