DSD demod: implemented signal format dependent status text

This commit is contained in:
f4exb 2016-04-23 06:27:28 +02:00
parent 837c22fd67
commit cb69b55911
6 changed files with 132 additions and 6 deletions

View File

@ -33,8 +33,14 @@ public:
void resetAudio() { m_decoder.resetAudio(); }
int getInLevel() const { return m_decoder.getInLevel(); }
int getSamplesPerSymbol() const { return m_decoder.getSamplesPerSymbol(); }
DSDcc::DSDDecoder::DSDSyncType getSyncType() const { return m_decoder.getSyncType(); }
DSDcc::DSDDecoder::DSDStationType getStationType() const { return m_decoder.getStationType(); }
const char *getFrameTypeText() const { return m_decoder.getFrameTypeText(); }
const char *getModulationText() const { return m_decoder.getModulationText(); }
const char *getSlot0Text() const { return m_decoder.getSlot0Text(); }
const char *getSlot1Text() const { return m_decoder.getSlot1Text(); }
const DSDcc::DSDDstar& getDStarDecoder() const { return m_decoder.getDStarDecoder(); }
void setAudioGain(float gain) { m_decoder.setAudioGain(gain); }

View File

@ -95,6 +95,7 @@ void DSDDemod::configure(MessageQueue* messageQueue,
void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst)
{
Complex ci;
int samplesPerSymbol = m_dsdDecoder.getSamplesPerSymbol();
m_settingsMutex.lock();
m_scopeSampleBuffer.clear();
@ -147,10 +148,10 @@ void DSDDemod::feed(const SampleVector::const_iterator& begin, const SampleVecto
m_sampleBuffer[m_sampleBufferIndex] = sample;
if (m_sampleBufferIndex < 20) {
delayedSample = m_sampleBuffer[(1<<17) - 20 + m_sampleBufferIndex];
if (m_sampleBufferIndex < samplesPerSymbol) {
delayedSample = m_sampleBuffer[(1<<17) - samplesPerSymbol + m_sampleBufferIndex]; // wrap
} else {
delayedSample = m_sampleBuffer[m_sampleBufferIndex - 20];
delayedSample = m_sampleBuffer[m_sampleBufferIndex - samplesPerSymbol];
}
Sample s(sample, delayedSample); // I=signal, Q=signal delayed by 20 samples (2400 baud: lowest rate)

View File

@ -58,7 +58,7 @@ public:
m_dsdDemodGUI = dsdDemodGUI;
}
Real getMagSq() { return m_magsq; }
Real getMagSq() { return m_movingAverage.average(); }
bool getSquelchOpen() const { return m_squelchOpen; }
const DSDDecoder& getDecoder() const { return m_dsdDecoder; }

View File

@ -250,6 +250,7 @@ DSDDemodGUI::DSDDemodGUI(PluginAPI* pluginAPI, QWidget* parent) :
m_channelMarker(this),
m_basicSettingsShown(false),
m_doApplySettings(true),
m_signalFormat(signalFormatNone),
m_squelchOpen(false),
m_channelPowerDbAvg(20,0),
m_tickCount(0)
@ -353,6 +354,80 @@ void DSDDemodGUI::blockApplySettings(bool block)
m_doApplySettings = !block;
}
void DSDDemodGUI::formatStatusText()
{
switch (m_dsdDemod->getDecoder().getSyncType())
{
case DSDcc::DSDDecoder::DSDSyncDMRDataN:
case DSDcc::DSDDecoder::DSDSyncDMRDataP:
case DSDcc::DSDDecoder::DSDSyncDMRVoiceN:
case DSDcc::DSDDecoder::DSDSyncDMRVoiceP:
if (m_signalFormat != signalFormatDMR)
{
memcpy(m_formatStatusText, "Station: ", 9);
memcpy(&m_formatStatusText[12], "TDMA: ", 6);
}
switch (m_dsdDemod->getDecoder().getStationType())
{
case DSDcc::DSDDecoder::DSDBaseStation:
memcpy(&m_formatStatusText[9], "BS ", 3);
break;
case DSDcc::DSDDecoder::DSDMobileStation:
memcpy(&m_formatStatusText[9], "MS ", 3);
break;
default:
memcpy(&m_formatStatusText[9], "NA ", 3);
break;
}
memcpy(&m_formatStatusText[18], m_dsdDemod->getDecoder().getSlot0Text(), 7);
m_formatStatusText[25] = ' ';
memcpy(&m_formatStatusText[26], m_dsdDemod->getDecoder().getSlot1Text(), 7);
m_formatStatusText[33] = '\0';
m_signalFormat = signalFormatDMR;
break;
case DSDcc::DSDDecoder::DSDSyncDStarHeaderN:
case DSDcc::DSDDecoder::DSDSyncDStarHeaderP:
case DSDcc::DSDDecoder::DSDSyncDStarN:
case DSDcc::DSDDecoder::DSDSyncDStarP:
if (m_signalFormat != signalFormatDStar)
{
strcpy(m_formatStatusText, "RPT1: ________ RPT2: ________ YOUR: ________ MY: ________/____");
}
{
const std::string& rpt1 = m_dsdDemod->getDecoder().getDStarDecoder().getRpt1();
const std::string& rpt2 = m_dsdDemod->getDecoder().getDStarDecoder().getRpt2();
const std::string& mySign = m_dsdDemod->getDecoder().getDStarDecoder().getMySign();
const std::string& yrSign = m_dsdDemod->getDecoder().getDStarDecoder().getYourSign();
if (rpt1.length() > 0) { // 0 or 8
memcpy(&m_formatStatusText[6], rpt1.c_str(), 8);
}
if (rpt2.length() > 0) { // 0 or 8
memcpy(&m_formatStatusText[21], rpt2.c_str(), 8);
}
if (yrSign.length() > 0) { // 0 or 8
memcpy(&m_formatStatusText[36], yrSign.c_str(), 8);
}
if (mySign.length() > 0) { // 0 or 13
memcpy(&m_formatStatusText[49], mySign.c_str(), 13);
}
}
m_signalFormat = signalFormatDStar;
break;
default:
m_signalFormat = signalFormatNone;
m_formatStatusText[0] = '\0';
break;
}
m_formatStatusText[80] = '\0'; // guard
}
void DSDDemodGUI::tick()
{
Real powDb = CalcDb::dbPower(m_dsdDemod->getMagSq());
@ -382,6 +457,10 @@ void DSDDemodGUI::tick()
ui->inLevelText->setText(QString::number(m_dsdDemod->getDecoder().getInLevel()));
ui->syncText->setText(QString(m_dsdDemod->getDecoder().getFrameTypeText()));
ui->modulationText->setText(QString(m_dsdDemod->getDecoder().getModulationText()));
formatStatusText();
ui->formatStatusText->setText(QString(m_formatStatusText));
m_tickCount = 0;
}
}

View File

@ -55,6 +55,7 @@ public:
private slots:
void viewChanged();
void formatStatusText();
void on_deltaFrequency_changed(quint64 value);
void on_deltaMinus_toggled(bool minus);
void on_rfBW_valueChanged(int index);
@ -69,11 +70,20 @@ private slots:
void tick();
private:
typedef enum
{
signalFormatNone,
signalFormatDMR,
signalFormatDStar
} SignalFormat;
Ui::DSDDemodGUI* ui;
PluginAPI* m_pluginAPI;
ChannelMarker m_channelMarker;
bool m_basicSettingsShown;
bool m_doApplySettings;
char m_formatStatusText[80+1]; //!< Fixed signal format dependent status text
SignalFormat m_signalFormat;
ThreadedSampleSink* m_threadedChannelizer;
Channelizer* m_channelizer;

View File

@ -36,12 +36,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>501</width>
<width>521</width>
<height>171</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -577,6 +577,36 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="formatStatusLayout">
<item>
<widget class="QLabel" name="formatStatusText">
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>___</string>
</property>
</widget>
</item>
<item>
<spacer name="formatStatusSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="verticalWidget" native="true">