Skip to content

Commit

Permalink
remove QIODevice with just QObject
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy committed Jan 7, 2025
1 parent 23bed12 commit b3fdaaa
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 80 deletions.
32 changes: 1 addition & 31 deletions decode/mskdemodulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <QTimerEvent>

MskDemodulator::MskDemodulator(QObject *parent) : QIODevice(parent) {
MskDemodulator::MskDemodulator(QObject *parent) : QObject(parent) {

afc = false;

Expand Down Expand Up @@ -80,26 +80,6 @@ MskDemodulator::MskDemodulator(QObject *parent) : QIODevice(parent) {
correctionfactor = 1.0;
}

/// Connects a sink devide to the modem for the demodulated data
void MskDemodulator::ConnectSinkDevice(QIODevice *_datasinkdevice) {
if (!_datasinkdevice)
return;
pdatasinkdevice = _datasinkdevice;
if (pdatasinkdevice.isNull())
return;
QIODevice *io = pdatasinkdevice.data();
io->open(QIODevice::WriteOnly); //!!!overrides the settings
}

/// Disconnects the sink devide from the modem
void MskDemodulator::DisconnectSinkDevice() {
if (pdatasinkdevice.isNull())
return;
QIODevice *io = pdatasinkdevice.data();
io->close();
pdatasinkdevice.clear();
}

void MskDemodulator::setAFC(bool state) { afc = state; }

void MskDemodulator::setCPUReduce(bool state) { cpuReduce = state; }
Expand Down Expand Up @@ -269,16 +249,6 @@ MskDemodulator::~MskDemodulator() {
delete marg;
}

void MskDemodulator::start() { open(QIODevice::WriteOnly); }

void MskDemodulator::stop() { close(); }

qint64 MskDemodulator::readData(char *data, qint64 maxlen) {
Q_UNUSED(data);
Q_UNUSED(maxlen);
return 0;
}

qint64 MskDemodulator::writeData(const char *data, qint64 len) {

bool sendscatterpoints = false;
Expand Down
14 changes: 3 additions & 11 deletions decode/mskdemodulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
#define MSKDEMODULATOR_H

#include "DSP.h"
#include <QIODevice>

#include <QObject>
#include <QVector>

#include <QPointer>

#include <QElapsedTimer>

class CoarseFreqEstimate;

class MskDemodulator : public QIODevice {
class MskDemodulator : public QObject {
Q_OBJECT
public:
struct Settings {
Expand All @@ -24,6 +21,7 @@ class MskDemodulator : public QIODevice {
int symbolspercycle;
double signalthreshold;
bool zmqAudio;

Settings() {
coarsefreqest_fft_power = 13; // 2^coarsefreqest_fft_power
freq_center = 1000; // Hz
Expand All @@ -38,12 +36,6 @@ class MskDemodulator : public QIODevice {
explicit MskDemodulator(QObject *parent);
~MskDemodulator();

void ConnectSinkDevice(QIODevice *datasinkdevice);
void DisconnectSinkDevice();

void start();
void stop();
qint64 readData(char *data, qint64 maxlen);
qint64 writeData(const char *data, qint64 len);
void setSettings(Settings settings);
void invalidatesettings();
Expand Down
32 changes: 1 addition & 31 deletions decode/oqpskdemodulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#define SPECTRUM_FFT_POWER 13

OqpskDemodulator::OqpskDemodulator(QObject *parent) : QIODevice(parent) {
OqpskDemodulator::OqpskDemodulator(QObject *parent) : QObject(parent) {
afc = false;

dcd = false;
Expand Down Expand Up @@ -124,26 +124,6 @@ OqpskDemodulator::~OqpskDemodulator() {
delete coarsefreqestimate;
}

/// Connects a sink devide to the modem for the demodulated data
void OqpskDemodulator::ConnectSinkDevice(QIODevice *_datasinkdevice) {
if (!_datasinkdevice)
return;
pdatasinkdevice = _datasinkdevice;
if (pdatasinkdevice.isNull())
return;
QIODevice *io = pdatasinkdevice.data();
io->open(QIODevice::WriteOnly); //!!!overrides the settings
}

/// Disconnects the sink devide from the modem
void OqpskDemodulator::DisconnectSinkDevice() {
if (pdatasinkdevice.isNull())
return;
QIODevice *io = pdatasinkdevice.data();
io->close();
pdatasinkdevice.clear();
}

void OqpskDemodulator::setAFC(bool state) { afc = state; }

void OqpskDemodulator::setCPUReduce(bool state) { cpuReduce = state; }
Expand Down Expand Up @@ -299,18 +279,8 @@ void OqpskDemodulator::CenterFreqChangedSlot(
emit Plottables(mixer2.GetFreqHz(), mixer_center.GetFreqHz(), lockingbw);
}

void OqpskDemodulator::start() { open(QIODevice::WriteOnly); }

void OqpskDemodulator::stop() { close(); }

double OqpskDemodulator::getCurrentFreq() { return mixer_center.GetFreqHz(); }

qint64 OqpskDemodulator::readData(char *data, qint64 maxlen) {
Q_UNUSED(data);
Q_UNUSED(maxlen);
return 0;
}

qint64 OqpskDemodulator::writeData(const char *data, qint64 len) {
if (!len)
return 0;
Expand Down
9 changes: 2 additions & 7 deletions decode/oqpskdemodulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
#include "DSP.h"
#include "coarsefreqestimate.h"
#include <QElapsedTimer>
#include <QIODevice>
#include <QObject>
#include <QPointer>
#include <QVector>
#include <assert.h>

class OqpskDemodulator : public QIODevice {
class OqpskDemodulator : public QObject {
Q_OBJECT
public:
struct Settings {
Expand All @@ -21,6 +20,7 @@ class OqpskDemodulator : public QIODevice {
double Fs;
double signalthreshold;
bool zmqAudio;

Settings() {
coarsefreqest_fft_power = 14; // 13;//2^coarsefreqest_fft_power
freq_center = 8000; // Hz
Expand All @@ -37,11 +37,6 @@ class OqpskDemodulator : public QIODevice {
void setCPUReduce(bool state);
void setSettings(Settings settings);
void invalidatesettings();
void ConnectSinkDevice(QIODevice *datasinkdevice);
void DisconnectSinkDevice();
void start();
void stop();
qint64 readData(char *data, qint64 maxlen);
qint64 writeData(const char *data, qint64 len);
double getCurrentFreq();
signals:
Expand Down

0 comments on commit b3fdaaa

Please sign in to comment.