1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-02-03 09:44:01 -05:00

SDRdaemon plugin: added gauges for main buffer read vs writes

This commit is contained in:
Edouard Griffiths 2016-03-17 15:41:48 +01:00
parent 335ecea84a
commit 22c3078c3a
7 changed files with 109 additions and 8 deletions

View File

@ -61,7 +61,7 @@ SDRdaemonBuffer::SDRdaemonBuffer(uint32_t throttlems) :
m_skewCorrection(false),
m_readCount(0),
m_writeCount(0),
m_nbCycles(0)
m_nbCycles(0)
{
m_currentMeta.init();
}

View File

@ -80,6 +80,28 @@ public:
uint32_t getLz4SuccessfulDecodes() const { return m_nbLastLz4SuccessfulDecodes; }
void setAutoFollowRate(bool autoFollowRate) { m_autoFollowRate = autoFollowRate; }
/** Get buffer gauge value in % of buffer size ([-50:50])
* [-50:0] : write leads or read lags
* [0:50] : read leads or write lags
*/
inline int32_t getBufferGauge() const
{
if (m_rawSize)
{
int32_t val = ((m_writeIndex - m_readIndex) * 100) / m_rawSize;
if (val < 0) {
return (val < -50 ? 100 - val : val);
} else {
return (val > 50 ? val - 100 : val);
}
}
else
{
return -50;
}
}
static const int m_udpPayloadSize;
static const int m_sampleSize;
static const int m_iqSampleSize;

View File

@ -45,6 +45,7 @@ SDRdaemonGui::SDRdaemonGui(PluginAPI* pluginAPI, QWidget* parent) :
m_compressionRatio(1.0),
m_nbLz4DataCRCOK(0),
m_nbLz4SuccessfulDecodes(0),
m_bufferGauge(-50),
m_samplesCount(0),
m_tickCount(0),
m_address("127.0.0.1"),
@ -227,6 +228,7 @@ bool SDRdaemonGui::handleMessage(const Message& message)
m_nbLz4DataCRCOK = ((SDRdaemonInput::MsgReportSDRdaemonStreamTiming&)message).getLz4DataCRCOK();
m_nbLz4SuccessfulDecodes = ((SDRdaemonInput::MsgReportSDRdaemonStreamTiming&)message).getLz4SuccessfulDecodes();
m_bufferGauge = ((SDRdaemonInput::MsgReportSDRdaemonStreamTiming&)message).getBufferGauge();
updateWithStreamTime();
return true;
@ -384,6 +386,9 @@ void SDRdaemonGui::updateWithStreamTime()
s = QString::number(m_nbLz4SuccessfulDecodes, 'f', 0);
ui->lz4DecodesOKText->setText(tr("%1").arg(s));
ui->bufferGaugeNegative->setValue((m_bufferGauge < 0 ? 50 + m_bufferGauge : 0));
ui->bufferGaugePositive->setValue((m_bufferGauge < 0 ? 0 : 50 - m_bufferGauge));
}
void SDRdaemonGui::tick()

View File

@ -66,6 +66,7 @@ private:
uint32_t m_nbLz4DataCRCOK;
uint32_t m_nbLz4SuccessfulDecodes;
int32_t m_bufferGauge;
int m_samplesCount;
std::size_t m_tickCount;

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>398</width>
<height>156</height>
<height>175</height>
</rect>
</property>
<property name="minimumSize">
@ -29,7 +29,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -167,6 +176,63 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="bufferGaugesLayout">
<item>
<widget class="QProgressBar" name="bufferGaugeNegative">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="toolTip">
<string>Main buffer gauge: write leads read lags</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
<property name="invertedAppearance">
<bool>true</bool>
</property>
<property name="format">
<string>%v</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="bufferGaugePositive">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>10</height>
</size>
</property>
<property name="toolTip">
<string>Main buffer gauge: read leads write lags</string>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_freq_2">
<property name="orientation">

View File

@ -194,6 +194,7 @@ public:
float getLz4CompressionRatio() const { return m_compressionRatio; }
uint32_t getLz4DataCRCOK() const { return m_nbLz4CRCOK; }
uint32_t getLz4SuccessfulDecodes() const { return m_nbLz4SuccessfulDecodes; }
int32_t getBufferGauge() const { return m_bufferGauge; }
static MsgReportSDRdaemonStreamTiming* create(uint32_t tv_sec,
uint32_t tv_usec,
@ -202,7 +203,8 @@ public:
bool lz4,
float compressionRatio,
uint32_t nbLz4CRCOK,
uint32_t nbLz4SuccessfulDecodes)
uint32_t nbLz4SuccessfulDecodes,
int32_t bufferGauge)
{
return new MsgReportSDRdaemonStreamTiming(tv_sec,
tv_usec,
@ -211,7 +213,8 @@ public:
lz4,
compressionRatio,
nbLz4CRCOK,
nbLz4SuccessfulDecodes);
nbLz4SuccessfulDecodes,
bufferGauge);
}
protected:
@ -223,6 +226,7 @@ public:
float m_compressionRatio;
uint32_t m_nbLz4CRCOK;
uint32_t m_nbLz4SuccessfulDecodes;
int32_t m_bufferGauge;
MsgReportSDRdaemonStreamTiming(uint32_t tv_sec,
uint32_t tv_usec,
@ -231,7 +235,8 @@ public:
bool lz4,
float compressionRatio,
uint32_t nbLz4CRCOK,
uint32_t nbLz4SuccessfulDecodes) :
uint32_t nbLz4SuccessfulDecodes,
int32_t bufferGauge) :
Message(),
m_tv_sec(tv_sec),
m_tv_usec(tv_usec),
@ -240,7 +245,8 @@ public:
m_lz4(lz4),
m_compressionRatio(compressionRatio),
m_nbLz4CRCOK(nbLz4CRCOK),
m_nbLz4SuccessfulDecodes(nbLz4SuccessfulDecodes)
m_nbLz4SuccessfulDecodes(nbLz4SuccessfulDecodes),
m_bufferGauge(bufferGauge)
{ }
};

View File

@ -241,7 +241,8 @@ void SDRdaemonUDPHandler::tick()
m_sdrDaemonBuffer.isLz4Compressed(),
m_sdrDaemonBuffer.getCompressionRatio(),
m_sdrDaemonBuffer.getLz4DataCRCOK(),
m_sdrDaemonBuffer.getLz4SuccessfulDecodes());
m_sdrDaemonBuffer.getLz4SuccessfulDecodes(),
m_sdrDaemonBuffer.getBufferGauge());
m_outputMessageQueueToGUI->push(report);
}
}