mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-15 21:01:45 -05:00
DaemonSink (5)
This commit is contained in:
parent
29583e4d56
commit
354409a21a
@ -54,7 +54,7 @@ DaemonSink::DaemonSink(DeviceSourceAPI *deviceAPI) :
|
|||||||
m_sampleRate(48000),
|
m_sampleRate(48000),
|
||||||
m_sampleBytes(SDR_RX_SAMP_SZ == 24 ? 4 : 2),
|
m_sampleBytes(SDR_RX_SAMP_SZ == 24 ? 4 : 2),
|
||||||
m_nbBlocksFEC(0),
|
m_nbBlocksFEC(0),
|
||||||
m_txDelay(100),
|
m_txDelay(50),
|
||||||
m_dataAddress("127.0.0.1"),
|
m_dataAddress("127.0.0.1"),
|
||||||
m_dataPort(9090)
|
m_dataPort(9090)
|
||||||
{
|
{
|
||||||
@ -81,13 +81,16 @@ DaemonSink::~DaemonSink()
|
|||||||
delete m_channelizer;
|
delete m_channelizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DaemonSink::setTxDelay(int txDelay)
|
void DaemonSink::setTxDelay(int txDelay, int nbBlocksFEC)
|
||||||
{
|
{
|
||||||
double txDelayRatio = txDelay / 100.0;
|
double txDelayRatio = txDelay / 100.0;
|
||||||
double delay = m_sampleRate == 0 ? 1.0 : (127*127*txDelayRatio) / m_sampleRate;
|
double delay = m_sampleRate == 0 ? 1.0 : (127*127*txDelayRatio) / m_sampleRate;
|
||||||
delay /= 128 + m_settings.m_nbFECBlocks;
|
delay /= 128 + nbBlocksFEC;
|
||||||
m_txDelay = roundf(delay*1e6); // microseconds
|
m_txDelay = roundf(delay*1e6); // microseconds
|
||||||
qDebug() << "DaemonSink::setTxDelay: "<< txDelay << "% m_txDelay: " << m_txDelay << "us";
|
qDebug() << "DaemonSink::setTxDelay:"
|
||||||
|
<< " " << txDelay
|
||||||
|
<< "% m_txDelay: " << m_txDelay << "us"
|
||||||
|
<< " m_sampleRate: " << m_sampleRate << "S/s";
|
||||||
}
|
}
|
||||||
|
|
||||||
void DaemonSink::setNbBlocksFEC(int nbBlocksFEC)
|
void DaemonSink::setNbBlocksFEC(int nbBlocksFEC)
|
||||||
@ -183,6 +186,7 @@ void DaemonSink::feed(const SampleVector::const_iterator& begin, const SampleVec
|
|||||||
m_dataBlock->m_txControlBlock.m_dataAddress = m_dataAddress;
|
m_dataBlock->m_txControlBlock.m_dataAddress = m_dataAddress;
|
||||||
m_dataBlock->m_txControlBlock.m_dataPort = m_dataPort;
|
m_dataBlock->m_txControlBlock.m_dataPort = m_dataPort;
|
||||||
|
|
||||||
|
qDebug("DaemonSink::feed: m_dataBlock: %p m_dataQueue.sz: %d", m_dataBlock, m_dataQueue.size());
|
||||||
m_dataQueue.push(m_dataBlock);
|
m_dataQueue.push(m_dataBlock);
|
||||||
m_dataBlock = new SDRDaemonDataBlock(); // create a new one immediately
|
m_dataBlock = new SDRDaemonDataBlock(); // create a new one immediately
|
||||||
m_dataBlockMutex.unlock();
|
m_dataBlockMutex.unlock();
|
||||||
@ -241,6 +245,8 @@ bool DaemonSink::handleMessage(const Message& cmd __attribute__((unused)))
|
|||||||
setSampleRate(notif.getSampleRate());
|
setSampleRate(notif.getSampleRate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTxDelay(m_settings.m_txDelay, m_settings.m_nbFECBlocks);
|
||||||
|
|
||||||
if (m_guiMessageQueue)
|
if (m_guiMessageQueue)
|
||||||
{
|
{
|
||||||
MsgSampleRateNotification *msg = MsgSampleRateNotification::create(notif.getSampleRate());
|
MsgSampleRateNotification *msg = MsgSampleRateNotification::create(notif.getSampleRate());
|
||||||
@ -308,10 +314,11 @@ void DaemonSink::applySettings(const DaemonSinkSettings& settings, bool force)
|
|||||||
|
|
||||||
if ((m_settings.m_nbFECBlocks != settings.m_nbFECBlocks) || force) {
|
if ((m_settings.m_nbFECBlocks != settings.m_nbFECBlocks) || force) {
|
||||||
setNbBlocksFEC(settings.m_nbFECBlocks);
|
setNbBlocksFEC(settings.m_nbFECBlocks);
|
||||||
|
setTxDelay(settings.m_txDelay, settings.m_nbFECBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_settings.m_txDelay != settings.m_txDelay) || force) {
|
if ((m_settings.m_txDelay != settings.m_txDelay) || force) {
|
||||||
setTxDelay(settings.m_txDelay);
|
setTxDelay(settings.m_txDelay, settings.m_nbFECBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_settings.m_dataAddress != settings.m_dataAddress) || force) {
|
if ((m_settings.m_dataAddress != settings.m_dataAddress) || force) {
|
||||||
@ -359,7 +366,7 @@ int DaemonSink::webapiSettingsPutPatch(
|
|||||||
int txDelay = response.getDaemonSinkSettings()->getTxDelay();
|
int txDelay = response.getDaemonSinkSettings()->getTxDelay();
|
||||||
|
|
||||||
if (txDelay < 0) {
|
if (txDelay < 0) {
|
||||||
settings.m_txDelay = 100;
|
settings.m_txDelay = 50;
|
||||||
} else {
|
} else {
|
||||||
settings.m_txDelay = txDelay;
|
settings.m_txDelay = txDelay;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ public:
|
|||||||
void setSampleRate(uint32_t sampleRate) { m_sampleRate = sampleRate; }
|
void setSampleRate(uint32_t sampleRate) { m_sampleRate = sampleRate; }
|
||||||
|
|
||||||
void setNbBlocksFEC(int nbBlocksFEC);
|
void setNbBlocksFEC(int nbBlocksFEC);
|
||||||
void setTxDelay(int txDelay);
|
void setTxDelay(int txDelay, int nbBlocksFEC);
|
||||||
void setDataAddress(const QString& address) { m_dataAddress = address; }
|
void setDataAddress(const QString& address) { m_dataAddress = address; }
|
||||||
void setDataPort(uint16_t port) { m_dataPort = port; }
|
void setDataPort(uint16_t port) { m_dataPort = port; }
|
||||||
|
|
||||||
|
@ -83,6 +83,7 @@ bool DaemonSinkGUI::handleMessage(const Message& message)
|
|||||||
DaemonSink::MsgSampleRateNotification& notif = (DaemonSink::MsgSampleRateNotification&) message;
|
DaemonSink::MsgSampleRateNotification& notif = (DaemonSink::MsgSampleRateNotification&) message;
|
||||||
m_channelMarker.setBandwidth(notif.getSampleRate());
|
m_channelMarker.setBandwidth(notif.getSampleRate());
|
||||||
m_sampleRate = notif.getSampleRate();
|
m_sampleRate = notif.getSampleRate();
|
||||||
|
updateTxDelayTime();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (DaemonSink::MsgConfigureDaemonSink::match(message))
|
else if (DaemonSink::MsgConfigureDaemonSink::match(message))
|
||||||
@ -177,8 +178,8 @@ void DaemonSinkGUI::displaySettings()
|
|||||||
QString s = QString::number(128 + m_settings.m_nbFECBlocks, 'f', 0);
|
QString s = QString::number(128 + m_settings.m_nbFECBlocks, 'f', 0);
|
||||||
QString s1 = QString::number(m_settings.m_nbFECBlocks, 'f', 0);
|
QString s1 = QString::number(m_settings.m_nbFECBlocks, 'f', 0);
|
||||||
ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s).arg(s1));
|
ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s).arg(s1));
|
||||||
ui->txDelayText->setText(tr("%1").arg(m_settings.m_txDelay));
|
ui->txDelayText->setText(tr("%1%").arg(m_settings.m_txDelay));
|
||||||
updateTxDelayTooltip();
|
updateTxDelayTime();
|
||||||
blockApplySettings(false);
|
blockApplySettings(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,8 +266,8 @@ void DaemonSinkGUI::on_dataApplyButton_clicked(bool checked __attribute__((unuse
|
|||||||
void DaemonSinkGUI::on_txDelay_valueChanged(int value)
|
void DaemonSinkGUI::on_txDelay_valueChanged(int value)
|
||||||
{
|
{
|
||||||
m_settings.m_txDelay = value; // percentage
|
m_settings.m_txDelay = value; // percentage
|
||||||
ui->txDelayText->setText(tr("%1").arg(value));
|
ui->txDelayText->setText(tr("%1%").arg(value));
|
||||||
updateTxDelayTooltip();
|
updateTxDelayTime();
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,16 +279,16 @@ void DaemonSinkGUI::on_nbFECBlocks_valueChanged(int value)
|
|||||||
QString s = QString::number(nbOriginalBlocks + nbFECBlocks, 'f', 0);
|
QString s = QString::number(nbOriginalBlocks + nbFECBlocks, 'f', 0);
|
||||||
QString s1 = QString::number(nbFECBlocks, 'f', 0);
|
QString s1 = QString::number(nbFECBlocks, 'f', 0);
|
||||||
ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s).arg(s1));
|
ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s).arg(s1));
|
||||||
updateTxDelayTooltip();
|
updateTxDelayTime();
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DaemonSinkGUI::updateTxDelayTooltip()
|
void DaemonSinkGUI::updateTxDelayTime()
|
||||||
{
|
{
|
||||||
double txDelayRatio = m_settings.m_txDelay / 100.0;
|
double txDelayRatio = m_settings.m_txDelay / 100.0;
|
||||||
double delay = m_sampleRate == 0 ? 0.0 : (127*127*txDelayRatio) / m_sampleRate;
|
double delay = m_sampleRate == 0 ? 0.0 : (127*127*txDelayRatio) / m_sampleRate;
|
||||||
delay /= 128 + m_settings.m_nbFECBlocks;
|
delay /= 128 + m_settings.m_nbFECBlocks;
|
||||||
ui->txDelayText->setToolTip(tr("%1 us").arg(QString::number(delay*1e6, 'f', 0)));
|
ui->txDelayTime->setText(tr("%1µs").arg(QString::number(delay*1e6, 'f', 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DaemonSinkGUI::tick()
|
void DaemonSinkGUI::tick()
|
||||||
|
@ -75,7 +75,7 @@ private:
|
|||||||
void blockApplySettings(bool block);
|
void blockApplySettings(bool block);
|
||||||
void applySettings(bool force = false);
|
void applySettings(bool force = false);
|
||||||
void displaySettings();
|
void displaySettings();
|
||||||
void updateTxDelayTooltip();
|
void updateTxDelayTime();
|
||||||
|
|
||||||
void leaveEvent(QEvent*);
|
void leaveEvent(QEvent*);
|
||||||
void enterEvent(QEvent*);
|
void enterEvent(QEvent*);
|
||||||
|
@ -158,6 +158,13 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="nominalValuesLayout">
|
<layout class="QHBoxLayout" name="nominalValuesLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>FEC</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDial" name="nbFECBlocks">
|
<widget class="QDial" name="nbFECBlocks">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
@ -242,12 +249,28 @@
|
|||||||
<widget class="QLabel" name="txDelayText">
|
<widget class="QLabel" name="txDelayText">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>30</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>90</string>
|
<string>50%</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="txDelayTime">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>55</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>10000us</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
@ -34,7 +34,7 @@ DaemonSinkSettings::DaemonSinkSettings()
|
|||||||
void DaemonSinkSettings::resetToDefaults()
|
void DaemonSinkSettings::resetToDefaults()
|
||||||
{
|
{
|
||||||
m_nbFECBlocks = 0;
|
m_nbFECBlocks = 0;
|
||||||
m_txDelay = 100;
|
m_txDelay = 50;
|
||||||
m_dataAddress = "127.0.0.1";
|
m_dataAddress = "127.0.0.1";
|
||||||
m_dataPort = 9090;
|
m_dataPort = 9090;
|
||||||
m_rgbColor = QColor(140, 4, 4).rgb();
|
m_rgbColor = QColor(140, 4, 4).rgb();
|
||||||
@ -77,7 +77,7 @@ bool DaemonSinkSettings::deserialize(const QByteArray& data)
|
|||||||
m_nbFECBlocks = 0;
|
m_nbFECBlocks = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
d.readU32(2, &m_txDelay, 100);
|
d.readU32(2, &m_txDelay, 50);
|
||||||
d.readString(3, &m_dataAddress, "127.0.0.1");
|
d.readString(3, &m_dataAddress, "127.0.0.1");
|
||||||
d.readU32(4, &tmp, 0);
|
d.readU32(4, &tmp, 0);
|
||||||
|
|
||||||
|
@ -110,8 +110,7 @@ bool DaemonSinkThread::handleDataBlock(SDRDaemonDataBlock& dataBlock)
|
|||||||
{
|
{
|
||||||
// send block via UDP
|
// send block via UDP
|
||||||
m_socket->writeDatagram((const char*)&txBlockx[i], (qint64 ) SDRDaemonUdpSize, m_address, dataPort);
|
m_socket->writeDatagram((const char*)&txBlockx[i], (qint64 ) SDRDaemonUdpSize, m_address, dataPort);
|
||||||
//m_socket->SendDataGram((const char*)&txBlockx[i], (int) SDRDaemonUdpSize, m_address.toStdString(), (uint32_t) dataPort);
|
usleep(txDelay);
|
||||||
//usleep(txDelay);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user