1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-10 10:33:29 -05:00

SDRdaemon plugin: button to make auto follow stream sample rate optional

This commit is contained in:
f4exb 2016-03-11 05:25:25 +01:00
parent 1e34641138
commit 763594c2f0
8 changed files with 115 additions and 27 deletions

View File

@ -55,7 +55,8 @@ SDRdaemonBuffer::SDRdaemonBuffer(uint32_t rateDivider) :
m_readCycles(0),
m_lastWriteIndex(0),
m_skewRateSum(0.0),
m_skewRate(0.0)
m_skewRate(0.0),
m_autoFollowRate(false)
{
m_currentMeta.init();
}
@ -113,6 +114,8 @@ bool SDRdaemonBuffer::readMeta(char *array, uint32_t length)
uint32_t frameSize = m_iqSampleSize * metaData->m_nbSamples * metaData->m_nbBlocks;
int sampleRate = metaData->m_sampleRate;
if (m_autoFollowRate)
{
if (sampleRate != m_sampleRateStream)
{
m_sampleRateStream = sampleRate;
@ -124,6 +127,11 @@ bool SDRdaemonBuffer::readMeta(char *array, uint32_t length)
sampleRate += sampleRate * m_skewRate;
sampleRate = (sampleRate / m_rateDivider) * m_rateDivider;
}
else
{
m_sampleRateStream = sampleRate;
}
if (metaData->m_sampleBytes & 0x10)
{
@ -268,7 +276,11 @@ uint8_t *SDRdaemonBuffer::readDataChunk()
//qDebug("SDRdaemonBuffer::readDataChunk: %d / %d (%lf)", m_writeIndex, m_rawSize, oneCycleSkew);
if (m_readCycles && ((m_writeIndex < m_rawSize / 10) || (m_rawSize - m_writeIndex < m_rawSize / 10)))
if (!m_autoFollowRate)
{
m_skewRate = 0.0;
}
else if (m_readCycles && ((m_writeIndex < m_rawSize / 10) || (m_rawSize - m_writeIndex < m_rawSize / 10)))
{
m_skewRate = m_skewRateSum / m_readCycles;
if (m_skewRate > 0.2) {

View File

@ -77,6 +77,7 @@ public:
float getCompressionRatio() const { return (m_frameSize > 0 ? (float) m_lz4InSize / (float) m_frameSize : 1.0); }
uint32_t getLz4DataCRCOK() const { return m_nbLastLz4CRCOK; }
uint32_t getLz4SuccessfulDecodes() const { return m_nbLastLz4SuccessfulDecodes; }
void setAutoFollowRate(bool autoFollowRate) { m_autoFollowRate = autoFollowRate; }
static const int m_udpPayloadSize;
static const int m_sampleSize;
@ -127,6 +128,7 @@ private:
uint32_t m_lastWriteIndex; //!< Write index at last skew estimation
double m_skewRateSum;
double m_skewRate;
bool m_autoFollowRate; //!< Aito follow stream sample rate else stick with meta data sample rate
};

View File

@ -50,7 +50,8 @@ SDRdaemonGui::SDRdaemonGui(PluginAPI* pluginAPI, QWidget* parent) :
m_address("127.0.0.1"),
m_port(9090),
m_dcBlock(false),
m_iqCorrection(false)
m_iqCorrection(false),
m_autoFollowRate(false)
{
m_startingTimeStamp.tv_sec = 0;
m_startingTimeStamp.tv_usec = 0;
@ -94,6 +95,7 @@ void SDRdaemonGui::resetToDefaults()
m_port = 9090;
m_dcBlock = false;
m_iqCorrection = false;
m_autoFollowRate = false;
displaySettings();
}
@ -112,6 +114,7 @@ QByteArray SDRdaemonGui::serialize() const
s.writeU32(2, uintval);
s.writeBool(3, m_dcBlock);
s.writeBool(4, m_iqCorrection);
s.writeBool(5, m_autoFollowRate);
return s.final();
}
@ -124,6 +127,7 @@ bool SDRdaemonGui::deserialize(const QByteArray& data)
quint16 port;
bool dcBlock;
bool iqCorrection;
bool autoFollowRate;
if (!d.isValid())
{
@ -146,6 +150,7 @@ bool SDRdaemonGui::deserialize(const QByteArray& data)
d.readBool(3, &dcBlock, false);
d.readBool(4, &iqCorrection, false);
d.readBool(5, &autoFollowRate, false);
if ((address != m_address) || (port != m_port))
{
@ -161,6 +166,11 @@ bool SDRdaemonGui::deserialize(const QByteArray& data)
configureAutoCorrections();
}
if (m_autoFollowRate != autoFollowRate) {
m_autoFollowRate = autoFollowRate;
configureAutoFollowRate();
}
displaySettings();
return true;
}
@ -248,6 +258,7 @@ void SDRdaemonGui::displaySettings()
ui->port->setText(QString::number(m_port));
ui->dcOffset->setChecked(m_dcBlock);
ui->iqImbalance->setChecked(m_iqCorrection);
ui->autoFollowRate->setChecked(m_autoFollowRate);
}
void SDRdaemonGui::on_applyButton_clicked(bool checked)
@ -297,6 +308,14 @@ void SDRdaemonGui::on_iqImbalance_toggled(bool checked)
}
}
void SDRdaemonGui::on_autoFollowRate_toggled(bool checked)
{
if (m_autoFollowRate != checked) {
m_autoFollowRate = checked;
configureAutoFollowRate();
}
}
void SDRdaemonGui::configureUDPLink()
{
qDebug() << "SDRdaemonGui::configureUDPLink: " << m_address.toStdString().c_str()
@ -312,6 +331,12 @@ void SDRdaemonGui::configureAutoCorrections()
m_sampleSource->getInputMessageQueue()->push(message);
}
void SDRdaemonGui::configureAutoFollowRate()
{
SDRdaemonInput::MsgConfigureSDRdaemonAutoFollowRate* message = SDRdaemonInput::MsgConfigureSDRdaemonAutoFollowRate::create(m_autoFollowRate);
m_sampleSource->getInputMessageQueue()->push(message);
}
void SDRdaemonGui::updateWithAcquisition()
{
}

View File

@ -73,11 +73,13 @@ private:
quint16 m_port;
bool m_dcBlock;
bool m_iqCorrection;
bool m_autoFollowRate;
void displaySettings();
void displayTime();
void configureUDPLink();
void configureAutoCorrections();
void configureAutoFollowRate();
void updateWithAcquisition();
void updateWithStreamData();
void updateWithStreamTime();
@ -87,6 +89,7 @@ private slots:
void on_applyButton_clicked(bool checked);
void on_dcOffset_toggled(bool checked);
void on_iqImbalance_toggled(bool checked);
void on_autoFollowRate_toggled(bool checked);
void on_address_textEdited(const QString& arg1);
void on_port_textEdited(const QString& arg1);
void tick();

View File

@ -2,6 +2,14 @@
<ui version="4.0">
<class>SDRdaemonGui</class>
<widget class="QWidget" name="SDRdaemonGui">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>398</width>
<height>156</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>340</width>
@ -168,23 +176,6 @@
</item>
<item>
<layout class="QHBoxLayout" name="streamLayout">
<item>
<widget class="QToolButton" name="streamLocked">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Stream locked status i.e. synced with meta data</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/locked.png</normaloff>:/locked.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="frameSizeText">
<property name="minimumSize">
@ -302,6 +293,16 @@
</property>
</spacer>
</item>
<item>
<widget class="ButtonSwitch" name="autoFollowRate">
<property name="toolTip">
<string>Follow stream sample rate automatically</string>
</property>
<property name="text">
<string>Auto</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
@ -330,6 +331,23 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="streamLocked">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Stream locked status i.e. synced with meta data</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/locked.png</normaloff>:/locked.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="compressionRatioText">
<property name="minimumSize">

View File

@ -30,6 +30,7 @@
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonUDPLink, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonAutoCorr, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonWork, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonAutoFollowRate, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonStreamTiming, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgReportSDRdaemonAcquisition, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgReportSDRdaemonStreamData, Message)
@ -113,6 +114,13 @@ bool SDRdaemonInput::handleMessage(const Message& message)
DSPEngine::instance()->configureCorrections(dcBlock, iqImbalance);
return true;
}
else if (MsgConfigureSDRdaemonAutoFollowRate::match(message))
{
MsgConfigureSDRdaemonAutoFollowRate& conf = (MsgConfigureSDRdaemonAutoFollowRate&) message;
bool autoFollowRate = conf.autoFollowRate();
m_SDRdaemonUDPHandler->setAutoFollowRate(autoFollowRate);
return true;
}
else if (MsgConfigureSDRdaemonWork::match(message))
{
MsgConfigureSDRdaemonWork& conf = (MsgConfigureSDRdaemonWork&) message;

View File

@ -93,6 +93,26 @@ public:
{ }
};
class MsgConfigureSDRdaemonAutoFollowRate : public Message {
MESSAGE_CLASS_DECLARATION
public:
bool autoFollowRate() const { return m_autoFollowRate; }
static MsgConfigureSDRdaemonAutoFollowRate* create(bool autoFollowRate)
{
return new MsgConfigureSDRdaemonAutoFollowRate(autoFollowRate);
}
private:
bool m_autoFollowRate;
MsgConfigureSDRdaemonAutoFollowRate(bool autoFollowRate) :
Message(),
m_autoFollowRate(autoFollowRate)
{ }
};
class MsgConfigureSDRdaemonStreamTiming : public Message {
MESSAGE_CLASS_DECLARATION

View File

@ -39,7 +39,7 @@ public:
void start();
void stop();
void configureUDPLink(const QString& address, quint16 port);
void setAutoFollowRate(bool autoFollowRate) { m_sdrDaemonBuffer.setAutoFollowRate(autoFollowRate); }
public slots:
void dataReadyRead();