mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-12 19:36:10 -05:00
SDRdaemon plugin: button to make auto follow stream sample rate optional
This commit is contained in:
parent
1e34641138
commit
763594c2f0
@ -55,7 +55,8 @@ SDRdaemonBuffer::SDRdaemonBuffer(uint32_t rateDivider) :
|
|||||||
m_readCycles(0),
|
m_readCycles(0),
|
||||||
m_lastWriteIndex(0),
|
m_lastWriteIndex(0),
|
||||||
m_skewRateSum(0.0),
|
m_skewRateSum(0.0),
|
||||||
m_skewRate(0.0)
|
m_skewRate(0.0),
|
||||||
|
m_autoFollowRate(false)
|
||||||
{
|
{
|
||||||
m_currentMeta.init();
|
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;
|
uint32_t frameSize = m_iqSampleSize * metaData->m_nbSamples * metaData->m_nbBlocks;
|
||||||
int sampleRate = metaData->m_sampleRate;
|
int sampleRate = metaData->m_sampleRate;
|
||||||
|
|
||||||
|
if (m_autoFollowRate)
|
||||||
|
{
|
||||||
if (sampleRate != m_sampleRateStream)
|
if (sampleRate != m_sampleRateStream)
|
||||||
{
|
{
|
||||||
m_sampleRateStream = sampleRate;
|
m_sampleRateStream = sampleRate;
|
||||||
@ -124,6 +127,11 @@ bool SDRdaemonBuffer::readMeta(char *array, uint32_t length)
|
|||||||
|
|
||||||
sampleRate += sampleRate * m_skewRate;
|
sampleRate += sampleRate * m_skewRate;
|
||||||
sampleRate = (sampleRate / m_rateDivider) * m_rateDivider;
|
sampleRate = (sampleRate / m_rateDivider) * m_rateDivider;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_sampleRateStream = sampleRate;
|
||||||
|
}
|
||||||
|
|
||||||
if (metaData->m_sampleBytes & 0x10)
|
if (metaData->m_sampleBytes & 0x10)
|
||||||
{
|
{
|
||||||
@ -268,7 +276,11 @@ uint8_t *SDRdaemonBuffer::readDataChunk()
|
|||||||
|
|
||||||
//qDebug("SDRdaemonBuffer::readDataChunk: %d / %d (%lf)", m_writeIndex, m_rawSize, oneCycleSkew);
|
//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;
|
m_skewRate = m_skewRateSum / m_readCycles;
|
||||||
if (m_skewRate > 0.2) {
|
if (m_skewRate > 0.2) {
|
||||||
|
@ -77,6 +77,7 @@ public:
|
|||||||
float getCompressionRatio() const { return (m_frameSize > 0 ? (float) m_lz4InSize / (float) m_frameSize : 1.0); }
|
float getCompressionRatio() const { return (m_frameSize > 0 ? (float) m_lz4InSize / (float) m_frameSize : 1.0); }
|
||||||
uint32_t getLz4DataCRCOK() const { return m_nbLastLz4CRCOK; }
|
uint32_t getLz4DataCRCOK() const { return m_nbLastLz4CRCOK; }
|
||||||
uint32_t getLz4SuccessfulDecodes() const { return m_nbLastLz4SuccessfulDecodes; }
|
uint32_t getLz4SuccessfulDecodes() const { return m_nbLastLz4SuccessfulDecodes; }
|
||||||
|
void setAutoFollowRate(bool autoFollowRate) { m_autoFollowRate = autoFollowRate; }
|
||||||
|
|
||||||
static const int m_udpPayloadSize;
|
static const int m_udpPayloadSize;
|
||||||
static const int m_sampleSize;
|
static const int m_sampleSize;
|
||||||
@ -127,6 +128,7 @@ private:
|
|||||||
uint32_t m_lastWriteIndex; //!< Write index at last skew estimation
|
uint32_t m_lastWriteIndex; //!< Write index at last skew estimation
|
||||||
double m_skewRateSum;
|
double m_skewRateSum;
|
||||||
double m_skewRate;
|
double m_skewRate;
|
||||||
|
bool m_autoFollowRate; //!< Aito follow stream sample rate else stick with meta data sample rate
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,7 +50,8 @@ SDRdaemonGui::SDRdaemonGui(PluginAPI* pluginAPI, QWidget* parent) :
|
|||||||
m_address("127.0.0.1"),
|
m_address("127.0.0.1"),
|
||||||
m_port(9090),
|
m_port(9090),
|
||||||
m_dcBlock(false),
|
m_dcBlock(false),
|
||||||
m_iqCorrection(false)
|
m_iqCorrection(false),
|
||||||
|
m_autoFollowRate(false)
|
||||||
{
|
{
|
||||||
m_startingTimeStamp.tv_sec = 0;
|
m_startingTimeStamp.tv_sec = 0;
|
||||||
m_startingTimeStamp.tv_usec = 0;
|
m_startingTimeStamp.tv_usec = 0;
|
||||||
@ -94,6 +95,7 @@ void SDRdaemonGui::resetToDefaults()
|
|||||||
m_port = 9090;
|
m_port = 9090;
|
||||||
m_dcBlock = false;
|
m_dcBlock = false;
|
||||||
m_iqCorrection = false;
|
m_iqCorrection = false;
|
||||||
|
m_autoFollowRate = false;
|
||||||
displaySettings();
|
displaySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +114,7 @@ QByteArray SDRdaemonGui::serialize() const
|
|||||||
s.writeU32(2, uintval);
|
s.writeU32(2, uintval);
|
||||||
s.writeBool(3, m_dcBlock);
|
s.writeBool(3, m_dcBlock);
|
||||||
s.writeBool(4, m_iqCorrection);
|
s.writeBool(4, m_iqCorrection);
|
||||||
|
s.writeBool(5, m_autoFollowRate);
|
||||||
|
|
||||||
return s.final();
|
return s.final();
|
||||||
}
|
}
|
||||||
@ -124,6 +127,7 @@ bool SDRdaemonGui::deserialize(const QByteArray& data)
|
|||||||
quint16 port;
|
quint16 port;
|
||||||
bool dcBlock;
|
bool dcBlock;
|
||||||
bool iqCorrection;
|
bool iqCorrection;
|
||||||
|
bool autoFollowRate;
|
||||||
|
|
||||||
if (!d.isValid())
|
if (!d.isValid())
|
||||||
{
|
{
|
||||||
@ -146,6 +150,7 @@ bool SDRdaemonGui::deserialize(const QByteArray& data)
|
|||||||
|
|
||||||
d.readBool(3, &dcBlock, false);
|
d.readBool(3, &dcBlock, false);
|
||||||
d.readBool(4, &iqCorrection, false);
|
d.readBool(4, &iqCorrection, false);
|
||||||
|
d.readBool(5, &autoFollowRate, false);
|
||||||
|
|
||||||
if ((address != m_address) || (port != m_port))
|
if ((address != m_address) || (port != m_port))
|
||||||
{
|
{
|
||||||
@ -161,6 +166,11 @@ bool SDRdaemonGui::deserialize(const QByteArray& data)
|
|||||||
configureAutoCorrections();
|
configureAutoCorrections();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_autoFollowRate != autoFollowRate) {
|
||||||
|
m_autoFollowRate = autoFollowRate;
|
||||||
|
configureAutoFollowRate();
|
||||||
|
}
|
||||||
|
|
||||||
displaySettings();
|
displaySettings();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -248,6 +258,7 @@ void SDRdaemonGui::displaySettings()
|
|||||||
ui->port->setText(QString::number(m_port));
|
ui->port->setText(QString::number(m_port));
|
||||||
ui->dcOffset->setChecked(m_dcBlock);
|
ui->dcOffset->setChecked(m_dcBlock);
|
||||||
ui->iqImbalance->setChecked(m_iqCorrection);
|
ui->iqImbalance->setChecked(m_iqCorrection);
|
||||||
|
ui->autoFollowRate->setChecked(m_autoFollowRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDRdaemonGui::on_applyButton_clicked(bool checked)
|
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()
|
void SDRdaemonGui::configureUDPLink()
|
||||||
{
|
{
|
||||||
qDebug() << "SDRdaemonGui::configureUDPLink: " << m_address.toStdString().c_str()
|
qDebug() << "SDRdaemonGui::configureUDPLink: " << m_address.toStdString().c_str()
|
||||||
@ -312,6 +331,12 @@ void SDRdaemonGui::configureAutoCorrections()
|
|||||||
m_sampleSource->getInputMessageQueue()->push(message);
|
m_sampleSource->getInputMessageQueue()->push(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDRdaemonGui::configureAutoFollowRate()
|
||||||
|
{
|
||||||
|
SDRdaemonInput::MsgConfigureSDRdaemonAutoFollowRate* message = SDRdaemonInput::MsgConfigureSDRdaemonAutoFollowRate::create(m_autoFollowRate);
|
||||||
|
m_sampleSource->getInputMessageQueue()->push(message);
|
||||||
|
}
|
||||||
|
|
||||||
void SDRdaemonGui::updateWithAcquisition()
|
void SDRdaemonGui::updateWithAcquisition()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -73,11 +73,13 @@ private:
|
|||||||
quint16 m_port;
|
quint16 m_port;
|
||||||
bool m_dcBlock;
|
bool m_dcBlock;
|
||||||
bool m_iqCorrection;
|
bool m_iqCorrection;
|
||||||
|
bool m_autoFollowRate;
|
||||||
|
|
||||||
void displaySettings();
|
void displaySettings();
|
||||||
void displayTime();
|
void displayTime();
|
||||||
void configureUDPLink();
|
void configureUDPLink();
|
||||||
void configureAutoCorrections();
|
void configureAutoCorrections();
|
||||||
|
void configureAutoFollowRate();
|
||||||
void updateWithAcquisition();
|
void updateWithAcquisition();
|
||||||
void updateWithStreamData();
|
void updateWithStreamData();
|
||||||
void updateWithStreamTime();
|
void updateWithStreamTime();
|
||||||
@ -87,6 +89,7 @@ private slots:
|
|||||||
void on_applyButton_clicked(bool checked);
|
void on_applyButton_clicked(bool checked);
|
||||||
void on_dcOffset_toggled(bool checked);
|
void on_dcOffset_toggled(bool checked);
|
||||||
void on_iqImbalance_toggled(bool checked);
|
void on_iqImbalance_toggled(bool checked);
|
||||||
|
void on_autoFollowRate_toggled(bool checked);
|
||||||
void on_address_textEdited(const QString& arg1);
|
void on_address_textEdited(const QString& arg1);
|
||||||
void on_port_textEdited(const QString& arg1);
|
void on_port_textEdited(const QString& arg1);
|
||||||
void tick();
|
void tick();
|
||||||
|
@ -2,6 +2,14 @@
|
|||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>SDRdaemonGui</class>
|
<class>SDRdaemonGui</class>
|
||||||
<widget class="QWidget" name="SDRdaemonGui">
|
<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">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>340</width>
|
<width>340</width>
|
||||||
@ -168,23 +176,6 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="streamLayout">
|
<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>
|
<item>
|
||||||
<widget class="QLabel" name="frameSizeText">
|
<widget class="QLabel" name="frameSizeText">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@ -302,6 +293,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -330,6 +331,23 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
<item>
|
||||||
<widget class="QLabel" name="compressionRatioText">
|
<widget class="QLabel" name="compressionRatioText">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonUDPLink, Message)
|
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonUDPLink, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonAutoCorr, Message)
|
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonAutoCorr, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonWork, Message)
|
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonWork, Message)
|
||||||
|
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonAutoFollowRate, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonStreamTiming, Message)
|
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgConfigureSDRdaemonStreamTiming, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgReportSDRdaemonAcquisition, Message)
|
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgReportSDRdaemonAcquisition, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgReportSDRdaemonStreamData, Message)
|
MESSAGE_CLASS_DEFINITION(SDRdaemonInput::MsgReportSDRdaemonStreamData, Message)
|
||||||
@ -113,6 +114,13 @@ bool SDRdaemonInput::handleMessage(const Message& message)
|
|||||||
DSPEngine::instance()->configureCorrections(dcBlock, iqImbalance);
|
DSPEngine::instance()->configureCorrections(dcBlock, iqImbalance);
|
||||||
return true;
|
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))
|
else if (MsgConfigureSDRdaemonWork::match(message))
|
||||||
{
|
{
|
||||||
MsgConfigureSDRdaemonWork& conf = (MsgConfigureSDRdaemonWork&) message;
|
MsgConfigureSDRdaemonWork& conf = (MsgConfigureSDRdaemonWork&) message;
|
||||||
|
@ -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 {
|
class MsgConfigureSDRdaemonStreamTiming : public Message {
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
void configureUDPLink(const QString& address, quint16 port);
|
void configureUDPLink(const QString& address, quint16 port);
|
||||||
|
void setAutoFollowRate(bool autoFollowRate) { m_sdrDaemonBuffer.setAutoFollowRate(autoFollowRate); }
|
||||||
public slots:
|
public slots:
|
||||||
void dataReadyRead();
|
void dataReadyRead();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user