1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-08 17:46:03 -05:00
sdrangel/plugins/channelrx/demodm17/m17demodbaseband.h

143 lines
5.7 KiB
C
Raw Normal View History

2022-06-04 18:54:59 -04:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2022 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 INCLUDE_M17DEMODBASEBAND_H
#define INCLUDE_M17DEMODBASEBAND_H
#include <QObject>
#include <QRecursiveMutex>
2022-06-04 18:54:59 -04:00
#include "dsp/samplesinkfifo.h"
#include "dsp/downchannelizer.h"
2022-06-04 18:54:59 -04:00
#include "util/message.h"
#include "util/messagequeue.h"
#include "m17demodsink.h"
class ChannelAPI;
class M17DemodBaseband : public QObject
{
Q_OBJECT
public:
class MsgConfigureM17DemodBaseband : public Message {
MESSAGE_CLASS_DECLARATION
public:
const M17DemodSettings& getSettings() const { return m_settings; }
2022-07-10 16:15:58 -04:00
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
2022-06-04 18:54:59 -04:00
bool getForce() const { return m_force; }
2022-07-10 16:15:58 -04:00
static MsgConfigureM17DemodBaseband* create(const M17DemodSettings& settings, const QList<QString>& settingsKeys, bool force) {
return new MsgConfigureM17DemodBaseband(settings, settingsKeys, force);
2022-06-04 18:54:59 -04:00
}
private:
M17DemodSettings m_settings;
2022-07-10 16:15:58 -04:00
QList<QString> m_settingsKeys;
2022-06-04 18:54:59 -04:00
bool m_force;
2022-07-10 16:15:58 -04:00
MsgConfigureM17DemodBaseband(const M17DemodSettings& settings, const QList<QString>& settingsKeys, bool force) :
2022-06-04 18:54:59 -04:00
Message(),
m_settings(settings),
2022-07-10 16:15:58 -04:00
m_settingsKeys(settingsKeys),
2022-06-04 18:54:59 -04:00
m_force(force)
{ }
};
M17DemodBaseband();
~M17DemodBaseband();
void reset();
void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end);
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } //!< Get the queue for asynchronous inbound communication
int getChannelSampleRate() const;
int getAudioSampleRate() const { return m_sink.getAudioSampleRate(); }
double getMagSq() { return m_sink.getMagSq(); }
void getMagSqLevels(double& avg, double& peak, int& nbSamples) { m_sink.getMagSqLevels(avg, peak, nbSamples); }
bool getSquelchOpen() const { return m_sink.getSquelchOpen(); }
void setBasebandSampleRate(int sampleRate);
void setScopeXYSink(BasebandSampleSink* scopeSink) { m_sink.setScopeXYSink(scopeSink); }
void configureMyPosition(float myLatitude, float myLongitude) { m_sink.configureMyPosition(myLatitude, myLongitude); }
void setChannel(ChannelAPI *channel);
void setFifoLabel(const QString& label) { m_sampleFifo.setLabel(label); }
void setAudioFifoLabel(const QString& label) { m_sink.setAudioFifoLabel(label); }
void getDiagnostics(
bool& dcd,
float& evm,
float& deviation,
float& offset,
int& status,
2022-07-06 01:01:42 -04:00
int& sync_word_type,
float& clock,
int& sampleIndex,
int& syncIndex,
int& clockIndex,
int& viterbiCost
) const
{
2022-07-06 01:01:42 -04:00
m_sink.getDiagnostics(
dcd,
evm,
deviation,
offset,
status,
sync_word_type,
clock,
sampleIndex,
syncIndex,
clockIndex,
viterbiCost
);
}
2022-07-06 21:19:01 -04:00
void getBERT(uint32_t& bertErrors, uint32_t& bertBits) {
m_sink.getBERT(bertErrors, bertBits);
}
2022-07-09 04:56:16 -04:00
void resetPRBS() { m_sink.resetPRBS(); }
uint32_t getLSFCount() const { return m_sink.getLSFCount(); }
const QString& getSrcCall() const { return m_sink.getSrcCall(); }
const QString& getDestcCall() const { return m_sink.getDestcCall(); }
const QString& getTypeInfo() const { return m_sink.getTypeInfo(); }
2022-07-15 21:48:33 -04:00
const std::array<uint8_t, 14>& getMeta() const {return m_sink.getMeta(); }
bool getHasGNSS() const { return m_sink.getHasGNSS(); }
2022-06-08 22:49:41 -04:00
bool getStreamElsePacket() const { return m_sink.getStreamElsePacket(); }
uint16_t getCRC() const { return m_sink.getCRC(); }
2022-06-08 22:49:41 -04:00
int getStdPacketProtocol() const { return m_sink.getStdPacketProtocol(); }
2022-06-19 00:39:05 -04:00
void setDemodInputMessageQueue(MessageQueue *messageQueue) { m_sink.setDemodInputMessageQueue(messageQueue); }
2022-06-04 18:54:59 -04:00
private:
SampleSinkFifo m_sampleFifo;
DownChannelizer m_channelizer;
2022-06-04 18:54:59 -04:00
int m_channelSampleRate;
M17DemodSink m_sink;
MessageQueue m_inputMessageQueue; //!< Queue for asynchronous inbound communication
M17DemodSettings m_settings;
QRecursiveMutex m_mutex;
2022-06-04 18:54:59 -04:00
bool handleMessage(const Message& cmd);
2022-07-10 16:15:58 -04:00
void applySettings(const M17DemodSettings& settings, const QList<QString>& settingsKeys, bool force = false);
2022-06-04 18:54:59 -04:00
private slots:
void handleInputMessages();
void handleData(); //!< Handle data when samples have to be processed
};
#endif // INCLUDE_M17DEMODBASEBAND_H