mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-23 00:18:37 -05:00
SDRdaemon input: refactored plugin with nanomsg handling in core plugin
This commit is contained in:
parent
9213b3c0b2
commit
6d70a644dd
@ -50,11 +50,12 @@ SDRdaemonSourceGui::SDRdaemonSourceGui(DeviceUISet *deviceUISet, QWidget* parent
|
||||
QWidget(parent),
|
||||
ui(new Ui::SDRdaemonSourceGui),
|
||||
m_deviceUISet(deviceUISet),
|
||||
m_sampleSource(NULL),
|
||||
m_settings(),
|
||||
m_sampleSource(0),
|
||||
m_acquisition(false),
|
||||
m_streamSampleRate(0),
|
||||
m_streamCenterFrequency(0),
|
||||
m_lastEngineState((DSPDeviceSourceEngine::State)-1),
|
||||
m_sampleRate(0),
|
||||
m_centerFrequency(0),
|
||||
m_framesDecodingStatus(0),
|
||||
m_bufferLengthInSecs(0.0),
|
||||
m_bufferGauge(-50),
|
||||
@ -62,26 +63,14 @@ SDRdaemonSourceGui::SDRdaemonSourceGui(DeviceUISet *deviceUISet, QWidget* parent
|
||||
m_nbFECBlocks(0),
|
||||
m_samplesCount(0),
|
||||
m_tickCount(0),
|
||||
m_address("127.0.0.1"),
|
||||
m_dataPort(9090),
|
||||
m_controlPort(9091),
|
||||
m_addressEdited(false),
|
||||
m_dataPortEdited(false),
|
||||
m_initSendConfiguration(false),
|
||||
m_countUnrecoverable(0),
|
||||
m_countRecovered(0),
|
||||
m_doApplySettings(true),
|
||||
m_forceSettings(true),
|
||||
m_txDelay(0.0),
|
||||
m_dcBlock(false),
|
||||
m_iqCorrection(false)
|
||||
m_txDelay(0.0)
|
||||
{
|
||||
m_sender = nn_socket(AF_SP, NN_PAIR);
|
||||
assert(m_sender != -1);
|
||||
int millis = 500;
|
||||
int rc __attribute__((unused)) = nn_setsockopt (m_sender, NN_SOL_SOCKET, NN_SNDTIMEO, &millis, sizeof (millis));
|
||||
assert (rc == 0);
|
||||
|
||||
m_paletteGreenText.setColor(QPalette::WindowText, Qt::green);
|
||||
m_paletteWhiteText.setColor(QPalette::WindowText, Qt::white);
|
||||
|
||||
@ -98,6 +87,8 @@ SDRdaemonSourceGui::SDRdaemonSourceGui(DeviceUISet *deviceUISet, QWidget* parent
|
||||
ui->sampleRate->setColorMapper(ColorMapper(ColorMapper::GrayGreenYellow));
|
||||
ui->sampleRate->setValueRange(7, 32000U, 9999999U);
|
||||
|
||||
displaySettings();
|
||||
|
||||
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||
m_statusTimer.start(500);
|
||||
connect(&(m_deviceUISet->m_deviceSourceAPI->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
|
||||
@ -105,16 +96,13 @@ SDRdaemonSourceGui::SDRdaemonSourceGui(DeviceUISet *deviceUISet, QWidget* parent
|
||||
|
||||
m_sampleSource = (SDRdaemonSourceInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();
|
||||
|
||||
displaySettings();
|
||||
|
||||
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
|
||||
|
||||
m_eventsTime.start();
|
||||
displayEventCounts();
|
||||
displayEventTimer();
|
||||
|
||||
displaySettings();
|
||||
sendControl(true);
|
||||
m_forceSettings = true;
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -145,10 +133,9 @@ QString SDRdaemonSourceGui::getName() const
|
||||
|
||||
void SDRdaemonSourceGui::resetToDefaults()
|
||||
{
|
||||
blockApplySettings(true);
|
||||
m_settings.resetToDefaults();
|
||||
displaySettings();
|
||||
blockApplySettings(false);
|
||||
m_forceSettings = true;
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -159,37 +146,31 @@ QByteArray SDRdaemonSourceGui::serialize() const
|
||||
|
||||
bool SDRdaemonSourceGui::deserialize(const QByteArray& data)
|
||||
{
|
||||
blockApplySettings(true);
|
||||
qDebug("SDRdaemonSourceGui::deserialize");
|
||||
|
||||
if(m_settings.deserialize(data))
|
||||
if (m_settings.deserialize(data))
|
||||
{
|
||||
displaySettings();
|
||||
configureUDPLink();
|
||||
updateTxDelay();
|
||||
sendControl();
|
||||
blockApplySettings(false);
|
||||
sendControl(true);
|
||||
displaySettings();
|
||||
m_forceSettings = true;
|
||||
sendSettings();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
blockApplySettings(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
qint64 SDRdaemonSourceGui::getCenterFrequency() const
|
||||
{
|
||||
return m_centerFrequency;
|
||||
return m_streamCenterFrequency;
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::setCenterFrequency(qint64 centerFrequency)
|
||||
{
|
||||
m_settings.m_centerFrequency = centerFrequency;
|
||||
displaySettings();
|
||||
sendControl();
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
@ -203,20 +184,14 @@ bool SDRdaemonSourceGui::handleMessage(const Message& message)
|
||||
}
|
||||
else if (SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData::match(message))
|
||||
{
|
||||
int sampleRate = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData&)message).getSampleRate();
|
||||
|
||||
if (m_sampleRate != sampleRate)
|
||||
{
|
||||
m_sampleRate = sampleRate;
|
||||
updateTxDelay();
|
||||
sendControl();
|
||||
}
|
||||
|
||||
m_centerFrequency = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData&)message).getCenterFrequency();
|
||||
m_startingTimeStamp.tv_sec = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData&)message).get_tv_sec();
|
||||
m_startingTimeStamp.tv_usec = ((SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData&)message).get_tv_usec();
|
||||
|
||||
updateWithStreamData();
|
||||
qDebug() << "SDRdaemonSourceGui::handleMessage: SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData: "
|
||||
<< " : " << m_startingTimeStamp.tv_sec
|
||||
<< " : " << m_startingTimeStamp.tv_usec;
|
||||
|
||||
updateWithStreamTime();
|
||||
return true;
|
||||
}
|
||||
else if (SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming::match(message))
|
||||
@ -241,7 +216,6 @@ bool SDRdaemonSourceGui::handleMessage(const Message& message)
|
||||
{
|
||||
m_nbFECBlocks = nbFECBlocks;
|
||||
updateTxDelay();
|
||||
sendControl();
|
||||
}
|
||||
|
||||
updateWithStreamTime();
|
||||
@ -273,9 +247,17 @@ void SDRdaemonSourceGui::handleInputMessages()
|
||||
if (DSPSignalNotification::match(*message))
|
||||
{
|
||||
DSPSignalNotification* notif = (DSPSignalNotification*) message;
|
||||
m_deviceSampleRate = notif->getSampleRate();
|
||||
m_deviceCenterFrequency = notif->getCenterFrequency();
|
||||
|
||||
if (notif->getSampleRate() != m_streamSampleRate)
|
||||
{
|
||||
m_streamSampleRate = notif->getSampleRate();
|
||||
updateTxDelay();
|
||||
}
|
||||
|
||||
m_streamCenterFrequency = notif->getCenterFrequency();
|
||||
|
||||
qDebug("SDRdaemonGui::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
|
||||
|
||||
updateSampleRateAndFrequency();
|
||||
DSPSignalNotification *fwd = new DSPSignalNotification(*notif);
|
||||
m_sampleSource->getInputMessageQueue()->push(fwd);
|
||||
@ -294,17 +276,21 @@ void SDRdaemonSourceGui::handleInputMessages()
|
||||
|
||||
void SDRdaemonSourceGui::updateSampleRateAndFrequency()
|
||||
{
|
||||
m_deviceUISet->getSpectrum()->setSampleRate(m_deviceSampleRate);
|
||||
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
|
||||
ui->deviceRateText->setText(tr("%1k").arg((float)m_deviceSampleRate / 1000));
|
||||
m_deviceUISet->getSpectrum()->setSampleRate(m_streamSampleRate);
|
||||
m_deviceUISet->getSpectrum()->setCenterFrequency(m_streamCenterFrequency);
|
||||
ui->deviceRateText->setText(tr("%1k").arg((float)m_streamSampleRate / 1000));
|
||||
blockApplySettings(true);
|
||||
ui->centerFrequency->setValue(m_streamCenterFrequency / 1000);
|
||||
ui->freq->setValue(m_streamCenterFrequency / 1000);
|
||||
blockApplySettings(false);
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::updateTxDelay()
|
||||
{
|
||||
if (m_sampleRate == 0) {
|
||||
if (m_streamSampleRate == 0) {
|
||||
m_txDelay = 0.0; // 0 value will not set the Tx delay
|
||||
} else {
|
||||
m_txDelay = ((127*127*m_settings.m_txDelay) / m_sampleRate)/(128 + m_nbFECBlocks);
|
||||
m_txDelay = ((127*127*m_settings.m_txDelay) / m_streamSampleRate)/(128 + m_nbFECBlocks);
|
||||
}
|
||||
|
||||
ui->txDelayText->setToolTip(tr("%1 us").arg(QString::number(m_txDelay*1e6, 'f', 0)));
|
||||
@ -312,10 +298,12 @@ void SDRdaemonSourceGui::updateTxDelay()
|
||||
|
||||
void SDRdaemonSourceGui::displaySettings()
|
||||
{
|
||||
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
|
||||
ui->deviceRateText->setText(tr("%1k").arg(m_sampleRate / 1000.0));
|
||||
blockApplySettings(true);
|
||||
|
||||
ui->freq->setValue(m_settings.m_centerFrequency / 1000);
|
||||
ui->centerFrequency->setValue(m_streamCenterFrequency / 1000);
|
||||
ui->deviceRateText->setText(tr("%1k").arg(m_streamSampleRate / 1000.0));
|
||||
|
||||
ui->freq->setValue(m_streamCenterFrequency / 1000);
|
||||
ui->decim->setCurrentIndex(m_settings.m_log2Decim);
|
||||
ui->fcPos->setCurrentIndex(m_settings.m_fcPos);
|
||||
ui->sampleRate->setValue(m_settings.m_sampleRate);
|
||||
@ -336,124 +324,8 @@ void SDRdaemonSourceGui::displaySettings()
|
||||
|
||||
ui->dcOffset->setChecked(m_settings.m_dcBlock);
|
||||
ui->iqImbalance->setChecked(m_settings.m_iqCorrection);
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::sendControl(bool force)
|
||||
{
|
||||
QString remoteAddress;
|
||||
((SDRdaemonSourceInput *) m_sampleSource)->getRemoteAddress(remoteAddress);
|
||||
|
||||
if ((remoteAddress != m_remoteAddress) ||
|
||||
(m_settings.m_controlPort != m_controlSettings.m_controlPort) || force)
|
||||
{
|
||||
m_remoteAddress = remoteAddress;
|
||||
|
||||
int rc = nn_shutdown(m_sender, 0);
|
||||
|
||||
if (rc < 0) {
|
||||
qDebug() << "SDRdaemonSourceGui::sendControl: disconnection failed";
|
||||
} else {
|
||||
qDebug() << "SDRdaemonSourceGui::sendControl: disconnection successful";
|
||||
}
|
||||
|
||||
std::ostringstream os;
|
||||
os << "tcp://" << m_remoteAddress.toStdString() << ":" << m_settings.m_controlPort;
|
||||
std::string addrstrng = os.str();
|
||||
rc = nn_connect(m_sender, addrstrng.c_str());
|
||||
|
||||
if (rc < 0) {
|
||||
qDebug() << "SDRdaemonSourceGui::sendConfiguration: connexion to " << addrstrng.c_str() << " failed";
|
||||
QMessageBox::information(this, tr("Message"), tr("Cannot connect to remote control port"));
|
||||
} else {
|
||||
qDebug() << "SDRdaemonSourceGui::sendConfiguration: connexion to " << addrstrng.c_str() << " successful";
|
||||
}
|
||||
}
|
||||
|
||||
std::ostringstream os;
|
||||
int nbArgs = 0;
|
||||
|
||||
if ((m_settings.m_centerFrequency != m_controlSettings.m_centerFrequency) || force)
|
||||
{
|
||||
os << "freq=" << m_settings.m_centerFrequency;
|
||||
nbArgs++;
|
||||
}
|
||||
|
||||
if ((m_settings.m_sampleRate != m_controlSettings.m_sampleRate) || (m_settings.m_log2Decim != m_controlSettings.m_log2Decim) || force)
|
||||
{
|
||||
if (nbArgs > 0) os << ",";
|
||||
os << "srate=" << m_settings.m_sampleRate;
|
||||
nbArgs++;
|
||||
}
|
||||
|
||||
if ((m_settings.m_log2Decim != m_controlSettings.m_log2Decim) || force)
|
||||
{
|
||||
if (nbArgs > 0) os << ",";
|
||||
os << "decim=" << m_settings.m_log2Decim;
|
||||
nbArgs++;
|
||||
}
|
||||
|
||||
if ((m_settings.m_fcPos != m_controlSettings.m_fcPos) || force)
|
||||
{
|
||||
if (nbArgs > 0) os << ",";
|
||||
os << "fcpos=" << m_settings.m_fcPos;
|
||||
nbArgs++;
|
||||
}
|
||||
|
||||
if ((m_settings.m_nbFECBlocks != m_controlSettings.m_nbFECBlocks) || force)
|
||||
{
|
||||
if (nbArgs > 0) os << ",";
|
||||
os << "fecblk=" << m_settings.m_nbFECBlocks;
|
||||
nbArgs++;
|
||||
}
|
||||
|
||||
if (m_txDelay != 0.0)
|
||||
{
|
||||
if (nbArgs > 0) os << ",";
|
||||
os << "txdelay=" << (int) (m_txDelay*1e6);
|
||||
nbArgs++;
|
||||
m_txDelay = 0.0;
|
||||
}
|
||||
|
||||
if ((m_settings.m_specificParameters != m_controlSettings.m_specificParameters) || force)
|
||||
{
|
||||
if (m_settings.m_specificParameters.size() > 0)
|
||||
{
|
||||
if (nbArgs > 0) os << ",";
|
||||
os << m_settings.m_specificParameters.toStdString();
|
||||
nbArgs++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nbArgs > 0)
|
||||
{
|
||||
int config_size = os.str().size();
|
||||
int rc = nn_send(m_sender, (void *) os.str().c_str(), config_size, 0);
|
||||
|
||||
if (rc != config_size)
|
||||
{
|
||||
//QMessageBox::information(this, tr("Message"), tr("Cannot send message to remote control port"));
|
||||
qDebug() << "SDRdaemonSourceGui::sendControl: Cannot send message to remote control port."
|
||||
<< " remoteAddress: " << m_remoteAddress
|
||||
<< " remotePort: " << m_settings.m_controlPort
|
||||
<< " message: " << os.str().c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "SDRdaemonSourceGui::sendControl:"
|
||||
<< "remoteAddress:" << m_remoteAddress
|
||||
<< "remotePort:" << m_settings.m_controlPort
|
||||
<< "message:" << os.str().c_str();
|
||||
}
|
||||
}
|
||||
|
||||
m_controlSettings.m_address = m_settings.m_address;
|
||||
m_controlSettings.m_controlPort = m_settings.m_controlPort;
|
||||
m_controlSettings.m_centerFrequency = m_settings.m_centerFrequency;
|
||||
m_controlSettings.m_sampleRate = m_settings.m_sampleRate;
|
||||
m_controlSettings.m_log2Decim = m_settings.m_log2Decim;
|
||||
m_controlSettings.m_fcPos = m_settings.m_fcPos;
|
||||
m_controlSettings.m_nbFECBlocks = m_settings.m_nbFECBlocks;
|
||||
m_controlSettings.m_specificParameters = m_settings.m_specificParameters;
|
||||
blockApplySettings(false);
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::sendSettings()
|
||||
@ -466,12 +338,14 @@ void SDRdaemonSourceGui::on_applyButton_clicked(bool checked __attribute__((unus
|
||||
{
|
||||
m_settings.m_address = ui->address->text();
|
||||
|
||||
bool send = false;
|
||||
bool ctlOk;
|
||||
int udpCtlPort = ui->controlPort->text().toInt(&ctlOk);
|
||||
|
||||
if((ctlOk) && (udpCtlPort >= 1024) && (udpCtlPort < 65535))
|
||||
{
|
||||
m_settings.m_controlPort = udpCtlPort;
|
||||
send = true;
|
||||
}
|
||||
|
||||
bool dataOk;
|
||||
@ -480,22 +354,26 @@ void SDRdaemonSourceGui::on_applyButton_clicked(bool checked __attribute__((unus
|
||||
if((dataOk) && (udpDataPort >= 1024) && (udpDataPort < 65535))
|
||||
{
|
||||
m_settings.m_dataPort = udpDataPort;
|
||||
send = true;
|
||||
}
|
||||
|
||||
configureUDPLink();
|
||||
if (send) {
|
||||
sendSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_sendButton_clicked(bool checked __attribute__((unused)))
|
||||
{
|
||||
updateTxDelay();
|
||||
sendControl(true);
|
||||
m_forceSettings = true;
|
||||
sendSettings();
|
||||
ui->specificParms->setCursorPosition(0);
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_address_returnPressed()
|
||||
{
|
||||
m_settings.m_address = ui->address->text();
|
||||
configureUDPLink();
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_dataPort_returnPressed()
|
||||
@ -510,9 +388,8 @@ void SDRdaemonSourceGui::on_dataPort_returnPressed()
|
||||
else
|
||||
{
|
||||
m_settings.m_dataPort = udpDataPort;
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
configureUDPLink();
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_controlPort_returnPressed()
|
||||
@ -527,59 +404,52 @@ void SDRdaemonSourceGui::on_controlPort_returnPressed()
|
||||
else
|
||||
{
|
||||
m_settings.m_controlPort = udpCtlPort;
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
sendControl();
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_dcOffset_toggled(bool checked)
|
||||
{
|
||||
if (m_dcBlock != checked)
|
||||
{
|
||||
m_dcBlock = checked;
|
||||
configureAutoCorrections();
|
||||
}
|
||||
m_settings.m_dcBlock = checked;
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_iqImbalance_toggled(bool checked)
|
||||
{
|
||||
if (m_iqCorrection != checked)
|
||||
{
|
||||
m_iqCorrection = checked;
|
||||
configureAutoCorrections();
|
||||
}
|
||||
m_settings.m_iqCorrection = checked;
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_freq_changed(quint64 value)
|
||||
{
|
||||
m_settings.m_centerFrequency = value * 1000;
|
||||
sendControl();
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_sampleRate_changed(quint64 value)
|
||||
{
|
||||
m_settings.m_sampleRate = value;
|
||||
sendControl();
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_specificParms_returnPressed()
|
||||
{
|
||||
if ((ui->specificParms->text()).size() > 0) {
|
||||
m_settings.m_specificParameters = ui->specificParms->text();
|
||||
sendControl();
|
||||
sendSettings();
|
||||
}
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_decim_currentIndexChanged(int index __attribute__((unused)))
|
||||
{
|
||||
m_settings.m_log2Decim = ui->decim->currentIndex();
|
||||
sendControl();
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_fcPos_currentIndexChanged(int index __attribute__((unused)))
|
||||
{
|
||||
m_settings.m_fcPos = ui->fcPos->currentIndex();
|
||||
sendControl();
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_txDelay_valueChanged(int value)
|
||||
@ -587,7 +457,7 @@ void SDRdaemonSourceGui::on_txDelay_valueChanged(int value)
|
||||
m_settings.m_txDelay = value / 100.0;
|
||||
ui->txDelayText->setText(tr("%1").arg(value));
|
||||
updateTxDelay();
|
||||
sendControl();
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_nbFECBlocks_valueChanged(int value)
|
||||
@ -595,7 +465,7 @@ void SDRdaemonSourceGui::on_nbFECBlocks_valueChanged(int value)
|
||||
m_settings.m_nbFECBlocks = value;
|
||||
QString nstr = QString("%1").arg(m_settings.m_nbFECBlocks, 2, 10, QChar('0'));
|
||||
ui->nbFECBlocksText->setText(nstr);
|
||||
sendControl();
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::on_startStop_toggled(bool checked)
|
||||
@ -645,31 +515,10 @@ void SDRdaemonSourceGui::displayEventTimer()
|
||||
ui->eventCountsTimeText->setText(s_time);
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::configureUDPLink()
|
||||
{
|
||||
qDebug() << "SDRdaemonGui::configureUDPLink: " << m_settings.m_address.toStdString().c_str()
|
||||
<< " : " << m_settings.m_dataPort;
|
||||
|
||||
SDRdaemonSourceInput::MsgConfigureSDRdaemonUDPLink* message = SDRdaemonSourceInput::MsgConfigureSDRdaemonUDPLink::create(m_settings.m_address, m_settings.m_dataPort);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::configureAutoCorrections()
|
||||
{
|
||||
SDRdaemonSourceInput::MsgConfigureSDRdaemonAutoCorr* message = SDRdaemonSourceInput::MsgConfigureSDRdaemonAutoCorr::create(m_dcBlock, m_iqCorrection);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::updateWithAcquisition()
|
||||
{
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::updateWithStreamData()
|
||||
{
|
||||
ui->centerFrequency->setValue(m_centerFrequency / 1000);
|
||||
updateWithStreamTime();
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::updateWithStreamTime()
|
||||
{
|
||||
bool updateEventCounts = false;
|
||||
@ -724,39 +573,54 @@ void SDRdaemonSourceGui::updateWithStreamTime()
|
||||
|
||||
void SDRdaemonSourceGui::updateHardware()
|
||||
{
|
||||
qDebug() << "SDRdaemonSinkGui::updateHardware";
|
||||
SDRdaemonSourceInput::MsgConfigureSDRdaemonSource* message = SDRdaemonSourceInput::MsgConfigureSDRdaemonSource::create(m_settings, m_forceSettings);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
m_forceSettings = false;
|
||||
m_updateTimer.stop();
|
||||
if (m_doApplySettings)
|
||||
{
|
||||
qDebug() << "SDRdaemonSinkGui::updateHardware";
|
||||
SDRdaemonSourceInput::MsgConfigureSDRdaemonSource* message =
|
||||
SDRdaemonSourceInput::MsgConfigureSDRdaemonSource::create(m_settings, m_forceSettings);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
m_forceSettings = false;
|
||||
m_updateTimer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
void SDRdaemonSourceGui::updateStatus()
|
||||
{
|
||||
int state = m_deviceUISet->m_deviceSourceAPI->state();
|
||||
|
||||
if(m_lastEngineState != state)
|
||||
if (m_sampleSource->isStreaming())
|
||||
{
|
||||
switch(state)
|
||||
int state = m_deviceUISet->m_deviceSourceAPI->state();
|
||||
|
||||
if (m_lastEngineState != state)
|
||||
{
|
||||
case DSPDeviceSourceEngine::StNotStarted:
|
||||
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||
break;
|
||||
case DSPDeviceSourceEngine::StIdle:
|
||||
ui->startStop->setStyleSheet("QToolButton { background-color : blue; }");
|
||||
break;
|
||||
case DSPDeviceSourceEngine::StRunning:
|
||||
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
|
||||
break;
|
||||
case DSPDeviceSourceEngine::StError:
|
||||
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
|
||||
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceSourceAPI->errorMessage());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch(state)
|
||||
{
|
||||
case DSPDeviceSourceEngine::StNotStarted:
|
||||
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||
break;
|
||||
case DSPDeviceSourceEngine::StIdle:
|
||||
ui->startStop->setStyleSheet("QToolButton { background-color : blue; }");
|
||||
break;
|
||||
case DSPDeviceSourceEngine::StRunning:
|
||||
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
|
||||
break;
|
||||
case DSPDeviceSourceEngine::StError:
|
||||
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
|
||||
QMessageBox::information(this, tr("Message"), m_deviceUISet->m_deviceSourceAPI->errorMessage());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_lastEngineState = state;
|
||||
}
|
||||
|
||||
m_lastEngineState = state;
|
||||
ui->startStop->setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
|
||||
ui->startStop->setChecked(false);
|
||||
ui->startStop->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,18 +56,17 @@ private:
|
||||
|
||||
DeviceUISet* m_deviceUISet;
|
||||
SDRdaemonSourceSettings m_settings; //!< current settings
|
||||
SDRdaemonSourceSettings m_controlSettings; //!< settings last sent to device via control port
|
||||
SDRdaemonSourceInput* m_sampleSource;
|
||||
bool m_acquisition;
|
||||
int m_streamSampleRate; //!< Sample rate of received stream
|
||||
quint64 m_streamCenterFrequency; //!< Center frequency of received stream
|
||||
QTimer m_updateTimer;
|
||||
QTimer m_statusTimer;
|
||||
DeviceSampleSource* m_sampleSource;
|
||||
bool m_acquisition;
|
||||
int m_deviceSampleRate;
|
||||
quint64 m_deviceCenterFrequency; //!< Center frequency in device
|
||||
int m_lastEngineState;
|
||||
MessageQueue m_inputMessageQueue;
|
||||
|
||||
int m_sampleRate;
|
||||
quint64 m_centerFrequency;
|
||||
// int m_sampleRate;
|
||||
// quint64 m_centerFrequency;
|
||||
struct timeval m_startingTimeStamp;
|
||||
int m_framesDecodingStatus;
|
||||
bool m_allBlocksReceived;
|
||||
@ -85,14 +84,8 @@ private:
|
||||
int m_samplesCount;
|
||||
std::size_t m_tickCount;
|
||||
|
||||
QString m_address;
|
||||
QString m_remoteAddress;
|
||||
quint16 m_dataPort;
|
||||
quint16 m_controlPort;
|
||||
bool m_addressEdited;
|
||||
bool m_dataPortEdited;
|
||||
bool m_initSendConfiguration;
|
||||
int m_sender;
|
||||
|
||||
uint32_t m_countUnrecoverable;
|
||||
uint32_t m_countRecovered;
|
||||
@ -102,21 +95,14 @@ private:
|
||||
bool m_forceSettings;
|
||||
double m_txDelay;
|
||||
|
||||
bool m_dcBlock;
|
||||
bool m_iqCorrection;
|
||||
|
||||
QPalette m_paletteGreenText;
|
||||
QPalette m_paletteWhiteText;
|
||||
|
||||
void blockApplySettings(bool block);
|
||||
void displaySettings();
|
||||
void displayTime();
|
||||
void sendControl(bool force = false);
|
||||
void sendSettings();
|
||||
void configureUDPLink();
|
||||
void configureAutoCorrections();
|
||||
void updateWithAcquisition();
|
||||
void updateWithStreamData();
|
||||
void updateWithStreamTime();
|
||||
void updateSampleRateAndFrequency();
|
||||
void updateTxDelay();
|
||||
|
@ -143,7 +143,7 @@
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Record center frequency in kHz</string>
|
||||
<string>Remote center frequency in kHz</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -18,6 +18,14 @@
|
||||
#include <errno.h>
|
||||
#include <QDebug>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <nn.h>
|
||||
#include <pair.h>
|
||||
#else
|
||||
#include <nanomsg/nn.h>
|
||||
#include <nanomsg/pair.h>
|
||||
#endif
|
||||
|
||||
#include "SWGDeviceSettings.h"
|
||||
#include "SWGDeviceState.h"
|
||||
|
||||
@ -32,9 +40,6 @@
|
||||
#include "sdrdaemonsourceudphandler.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgConfigureSDRdaemonSource, Message)
|
||||
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgConfigureSDRdaemonUDPLink, Message)
|
||||
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgConfigureSDRdaemonAutoCorr, Message)
|
||||
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgConfigureSDRdaemonWork, Message)
|
||||
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgConfigureSDRdaemonStreamTiming, Message)
|
||||
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgReportSDRdaemonAcquisition, Message)
|
||||
MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData, Message)
|
||||
@ -44,19 +49,21 @@ MESSAGE_CLASS_DEFINITION(SDRdaemonSourceInput::MsgStartStop, Message)
|
||||
|
||||
SDRdaemonSourceInput::SDRdaemonSourceInput(DeviceSourceAPI *deviceAPI) :
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_address("127.0.0.1"),
|
||||
m_port(9090),
|
||||
m_settings(),
|
||||
m_SDRdaemonUDPHandler(0),
|
||||
m_deviceDescription(),
|
||||
m_startingTimeStamp(0),
|
||||
m_masterTimer(deviceAPI->getMasterTimer()),
|
||||
m_autoFollowRate(false),
|
||||
m_autoCorrBuffer(false)
|
||||
{
|
||||
m_sender = nn_socket(AF_SP, NN_PAIR);
|
||||
assert(m_sender != -1);
|
||||
int millis = 500;
|
||||
int rc __attribute__((unused)) = nn_setsockopt (m_sender, NN_SOL_SOCKET, NN_SNDTIMEO, &millis, sizeof (millis));
|
||||
assert (rc == 0);
|
||||
|
||||
m_sampleFifo.setSize(96000 * 4);
|
||||
//m_SDRdaemonUDPHandler = new SDRdaemonSourceUDPHandler(&m_sampleFifo, &m_inputMessageQueue, m_deviceAPI);
|
||||
m_SDRdaemonUDPHandler = new SDRdaemonSourceUDPHandler(&m_sampleFifo, m_deviceAPI);
|
||||
m_SDRdaemonUDPHandler->connectTimer(&m_masterTimer);
|
||||
|
||||
char recFileNameCStr[30];
|
||||
sprintf(recFileNameCStr, "test_%d.sdriq", m_deviceAPI->getDeviceUID());
|
||||
@ -79,23 +86,20 @@ void SDRdaemonSourceInput::destroy()
|
||||
|
||||
void SDRdaemonSourceInput::init()
|
||||
{
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(m_settings.m_sampleRate/(1<<m_settings.m_log2Decim), m_settings.m_centerFrequency);
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||
applySettings(m_settings, true);
|
||||
}
|
||||
|
||||
bool SDRdaemonSourceInput::start()
|
||||
{
|
||||
qDebug() << "SDRdaemonInput::start";
|
||||
MsgConfigureSDRdaemonWork *command = MsgConfigureSDRdaemonWork::create(true);
|
||||
getInputMessageQueue()->push(command);
|
||||
qDebug() << "SDRdaemonSourceInput::start";
|
||||
m_SDRdaemonUDPHandler->start();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SDRdaemonSourceInput::stop()
|
||||
{
|
||||
qDebug() << "SDRdaemonInput::stop";
|
||||
MsgConfigureSDRdaemonWork *command = MsgConfigureSDRdaemonWork::create(false);
|
||||
getInputMessageQueue()->push(command);
|
||||
qDebug() << "SDRdaemonSourceInput::stop";
|
||||
m_SDRdaemonUDPHandler->stop();
|
||||
}
|
||||
|
||||
void SDRdaemonSourceInput::setMessageQueueToGUI(MessageQueue *queue)
|
||||
@ -111,12 +115,20 @@ const QString& SDRdaemonSourceInput::getDeviceDescription() const
|
||||
|
||||
int SDRdaemonSourceInput::getSampleRate() const
|
||||
{
|
||||
return m_settings.m_sampleRate;
|
||||
if (m_SDRdaemonUDPHandler->getSampleRate()) {
|
||||
return m_SDRdaemonUDPHandler->getSampleRate();
|
||||
} else {
|
||||
return m_settings.m_sampleRate / (1<<m_settings.m_log2Decim);
|
||||
}
|
||||
}
|
||||
|
||||
quint64 SDRdaemonSourceInput::getCenterFrequency() const
|
||||
{
|
||||
return m_settings.m_centerFrequency;
|
||||
if (m_SDRdaemonUDPHandler->getCenterFrequency()) {
|
||||
return m_SDRdaemonUDPHandler->getCenterFrequency();
|
||||
} else {
|
||||
return m_settings.m_centerFrequency;
|
||||
}
|
||||
}
|
||||
|
||||
std::time_t SDRdaemonSourceInput::getStartingTimeStamp() const
|
||||
@ -124,14 +136,11 @@ std::time_t SDRdaemonSourceInput::getStartingTimeStamp() const
|
||||
return m_startingTimeStamp;
|
||||
}
|
||||
|
||||
void SDRdaemonSourceInput::getRemoteAddress(QString &s)
|
||||
bool SDRdaemonSourceInput::isStreaming() const
|
||||
{
|
||||
if (m_SDRdaemonUDPHandler) {
|
||||
m_SDRdaemonUDPHandler->getRemoteAddress(s);
|
||||
}
|
||||
return m_SDRdaemonUDPHandler->isStreaming();
|
||||
}
|
||||
|
||||
|
||||
bool SDRdaemonSourceInput::handleMessage(const Message& message)
|
||||
{
|
||||
if (DSPSignalNotification::match(message))
|
||||
@ -176,37 +185,10 @@ bool SDRdaemonSourceInput::handleMessage(const Message& message)
|
||||
else if (MsgConfigureSDRdaemonSource::match(message))
|
||||
{
|
||||
qDebug() << "SDRdaemonSourceInput::handleMessage:" << message.getIdentifier();
|
||||
//SDRdaemonSourceInput& conf = (MsgConfigureSDRdaemonFEC&) message;
|
||||
//applySettings(conf.getSettings(), conf.getForce());
|
||||
MsgConfigureSDRdaemonSource& conf = (MsgConfigureSDRdaemonSource&) message;
|
||||
applySettings(conf.getSettings(), conf.getForce());
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureSDRdaemonUDPLink::match(message))
|
||||
{
|
||||
MsgConfigureSDRdaemonUDPLink& conf = (MsgConfigureSDRdaemonUDPLink&) message;
|
||||
m_SDRdaemonUDPHandler->configureUDPLink(conf.getAddress(), conf.getPort());
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureSDRdaemonAutoCorr::match(message))
|
||||
{
|
||||
MsgConfigureSDRdaemonAutoCorr& conf = (MsgConfigureSDRdaemonAutoCorr&) message;
|
||||
bool dcBlock = conf.getDCBlock();
|
||||
bool iqImbalance = conf.getIQImbalance();
|
||||
m_deviceAPI->configureCorrections(dcBlock, iqImbalance);
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureSDRdaemonWork::match(message))
|
||||
{
|
||||
MsgConfigureSDRdaemonWork& conf = (MsgConfigureSDRdaemonWork&) message;
|
||||
bool working = conf.isWorking();
|
||||
|
||||
if (working) {
|
||||
m_SDRdaemonUDPHandler->start();
|
||||
} else {
|
||||
m_SDRdaemonUDPHandler->stop();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureSDRdaemonStreamTiming::match(message))
|
||||
{
|
||||
return true;
|
||||
@ -237,6 +219,154 @@ bool SDRdaemonSourceInput::handleMessage(const Message& message)
|
||||
}
|
||||
}
|
||||
|
||||
void SDRdaemonSourceInput::applySettings(const SDRdaemonSourceSettings& settings, bool force)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
bool changeTxDelay = false;
|
||||
std::ostringstream os;
|
||||
int nbArgs = 0;
|
||||
QString remoteAddress;
|
||||
m_SDRdaemonUDPHandler->getRemoteAddress(remoteAddress);
|
||||
|
||||
if ((m_settings.m_dcBlock != settings.m_dcBlock) || (m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
|
||||
{
|
||||
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
|
||||
qDebug("SDRdaemonSourceInput::applySettings: corrections: DC block: %s IQ imbalance: %s",
|
||||
m_settings.m_dcBlock ? "true" : "false",
|
||||
m_settings.m_iqCorrection ? "true" : "false");
|
||||
}
|
||||
|
||||
if (force || (m_settings.m_address != settings.m_address) || (m_settings.m_dataPort != settings.m_dataPort))
|
||||
{
|
||||
m_SDRdaemonUDPHandler->configureUDPLink(settings.m_address, settings.m_dataPort);
|
||||
m_SDRdaemonUDPHandler->getRemoteAddress(remoteAddress);
|
||||
}
|
||||
|
||||
if (force || (remoteAddress != m_remoteAddress) || (m_settings.m_controlPort != settings.m_controlPort))
|
||||
{
|
||||
int rc = nn_shutdown(m_sender, 0);
|
||||
|
||||
if (rc < 0) {
|
||||
qDebug() << "SDRdaemonSourceInput::applySettings: nn disconnection failed";
|
||||
} else {
|
||||
qDebug() << "SDRdaemonSourceInput::applySettings: nn disconnection successful";
|
||||
}
|
||||
|
||||
std::ostringstream os;
|
||||
os << "tcp://" << remoteAddress.toStdString() << ":" << m_settings.m_controlPort;
|
||||
std::string addrstrng = os.str();
|
||||
rc = nn_connect(m_sender, addrstrng.c_str());
|
||||
|
||||
if (rc < 0) {
|
||||
qDebug() << "SDRdaemonSourceInput::applySettings: nn connexion to " << addrstrng.c_str() << " failed";
|
||||
} else {
|
||||
qDebug() << "SDRdaemonSourceInput::applySettings: nn connexion to " << addrstrng.c_str() << " successful";
|
||||
}
|
||||
}
|
||||
|
||||
if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency))
|
||||
{
|
||||
os << "freq=" << settings.m_centerFrequency;
|
||||
nbArgs++;
|
||||
}
|
||||
|
||||
if (force || (m_settings.m_sampleRate != settings.m_sampleRate) || (m_settings.m_log2Decim != settings.m_log2Decim))
|
||||
{
|
||||
if (nbArgs > 0) os << ",";
|
||||
os << "srate=" << m_settings.m_sampleRate;
|
||||
nbArgs++;
|
||||
changeTxDelay = m_settings.m_sampleRate != settings.m_sampleRate;
|
||||
}
|
||||
|
||||
if (force || (m_settings.m_log2Decim != settings.m_log2Decim))
|
||||
{
|
||||
if (nbArgs > 0) os << ",";
|
||||
os << "decim=" << m_settings.m_log2Decim;
|
||||
nbArgs++;
|
||||
}
|
||||
|
||||
if ((m_settings.m_fcPos != settings.m_fcPos) || force)
|
||||
{
|
||||
if (nbArgs > 0) os << ",";
|
||||
os << "fcpos=" << m_settings.m_fcPos;
|
||||
nbArgs++;
|
||||
}
|
||||
|
||||
if (force || (m_settings.m_nbFECBlocks != settings.m_nbFECBlocks))
|
||||
{
|
||||
if (nbArgs > 0) os << ",";
|
||||
os << "fecblk=" << m_settings.m_nbFECBlocks;
|
||||
nbArgs++;
|
||||
changeTxDelay = true;
|
||||
}
|
||||
|
||||
if (force || (m_settings.m_txDelay != settings.m_txDelay))
|
||||
{
|
||||
changeTxDelay = true;
|
||||
}
|
||||
|
||||
if (changeTxDelay)
|
||||
{
|
||||
double delay = ((127*127*settings.m_txDelay) / settings.m_sampleRate)/(128 + settings.m_nbFECBlocks);
|
||||
qDebug("SDRdaemonSourceInput::applySettings: Tx delay: %f us", delay*1e6);
|
||||
|
||||
if (delay != 0.0)
|
||||
{
|
||||
if (nbArgs > 0) os << ",";
|
||||
os << "txdelay=" << (int) (delay*1e6);
|
||||
nbArgs++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_specificParameters != settings.m_specificParameters) || force)
|
||||
{
|
||||
if (settings.m_specificParameters.size() > 0)
|
||||
{
|
||||
if (nbArgs > 0) os << ",";
|
||||
os << settings.m_specificParameters.toStdString();
|
||||
nbArgs++;
|
||||
}
|
||||
}
|
||||
|
||||
if (nbArgs > 0)
|
||||
{
|
||||
int config_size = os.str().size();
|
||||
int rc = nn_send(m_sender, (void *) os.str().c_str(), config_size, 0);
|
||||
|
||||
if (rc != config_size)
|
||||
{
|
||||
qDebug() << "SDRdaemonSourceInput::applySettings: Cannot nn send to "
|
||||
<< " remoteAddress: " << remoteAddress
|
||||
<< " remotePort: " << settings.m_controlPort
|
||||
<< " message: " << os.str().c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "SDRdaemonSourceInput::applySettings: nn send to "
|
||||
<< "remoteAddress:" << remoteAddress
|
||||
<< "remotePort:" << settings.m_controlPort
|
||||
<< "message:" << os.str().c_str();
|
||||
}
|
||||
}
|
||||
|
||||
mutexLocker.unlock();
|
||||
m_settings = settings;
|
||||
m_remoteAddress = remoteAddress;
|
||||
|
||||
qDebug() << "SDRdaemonSourceInput::applySettings: "
|
||||
<< " m_address: " << m_settings.m_address
|
||||
<< " m_remoteAddress: " << m_remoteAddress
|
||||
<< " m_dataPort: " << m_settings.m_dataPort
|
||||
<< " m_controlPort: " << m_settings.m_controlPort
|
||||
<< " m_centerFrequency: " << m_settings.m_centerFrequency
|
||||
<< " m_sampleRate: " << m_settings.m_sampleRate
|
||||
<< " m_log2Decim: " << m_settings.m_log2Decim
|
||||
<< " m_fcPos: " << m_settings.m_fcPos
|
||||
<< " m_txDelay: " << m_settings.m_txDelay
|
||||
<< " m_nbFECBlocks: " << m_settings.m_nbFECBlocks
|
||||
<< " m_specificParameters: " << m_settings.m_specificParameters;
|
||||
}
|
||||
|
||||
int SDRdaemonSourceInput::webapiRunGet(
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage __attribute__((unused)))
|
||||
|
@ -55,71 +55,6 @@ public:
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgConfigureSDRdaemonUDPLink : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
const QString& getAddress() const { return m_address; }
|
||||
quint16 getPort() const { return m_port; }
|
||||
|
||||
static MsgConfigureSDRdaemonUDPLink* create(const QString& address, quint16 port)
|
||||
{
|
||||
return new MsgConfigureSDRdaemonUDPLink(address, port);
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_address;
|
||||
quint16 m_port;
|
||||
|
||||
MsgConfigureSDRdaemonUDPLink(const QString& address, quint16 port) :
|
||||
Message(),
|
||||
m_address(address),
|
||||
m_port(port)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgConfigureSDRdaemonAutoCorr : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
public:
|
||||
bool getDCBlock() const { return m_dcBlock; }
|
||||
bool getIQImbalance() const { return m_iqCorrection; }
|
||||
|
||||
static MsgConfigureSDRdaemonAutoCorr* create(bool dcBlock, bool iqImbalance)
|
||||
{
|
||||
return new MsgConfigureSDRdaemonAutoCorr(dcBlock, iqImbalance);
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_dcBlock;
|
||||
bool m_iqCorrection;
|
||||
|
||||
MsgConfigureSDRdaemonAutoCorr(bool dcBlock, bool iqImbalance) :
|
||||
Message(),
|
||||
m_dcBlock(dcBlock),
|
||||
m_iqCorrection(iqImbalance)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgConfigureSDRdaemonWork : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
bool isWorking() const { return m_working; }
|
||||
|
||||
static MsgConfigureSDRdaemonWork* create(bool working)
|
||||
{
|
||||
return new MsgConfigureSDRdaemonWork(working);
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_working;
|
||||
|
||||
MsgConfigureSDRdaemonWork(bool working) :
|
||||
Message(),
|
||||
m_working(working)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgConfigureSDRdaemonStreamTiming : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
@ -335,7 +270,7 @@ public:
|
||||
virtual int getSampleRate() const;
|
||||
virtual quint64 getCenterFrequency() const;
|
||||
std::time_t getStartingTimeStamp() const;
|
||||
void getRemoteAddress(QString &s);
|
||||
bool isStreaming() const;
|
||||
|
||||
virtual bool handleMessage(const Message& message);
|
||||
|
||||
@ -352,15 +287,16 @@ private:
|
||||
DeviceSourceAPI *m_deviceAPI;
|
||||
QMutex m_mutex;
|
||||
SDRdaemonSourceSettings m_settings;
|
||||
QString m_address;
|
||||
quint16 m_port;
|
||||
SDRdaemonSourceUDPHandler* m_SDRdaemonUDPHandler;
|
||||
QString m_remoteAddress;
|
||||
int m_sender;
|
||||
QString m_deviceDescription;
|
||||
std::time_t m_startingTimeStamp;
|
||||
const QTimer& m_masterTimer;
|
||||
bool m_autoFollowRate;
|
||||
bool m_autoCorrBuffer;
|
||||
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
||||
|
||||
void applySettings(const SDRdaemonSourceSettings& settings, bool force = false);
|
||||
};
|
||||
|
||||
#endif // INCLUDE_SDRDAEMONSOURCEINPUT_H
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
const PluginDescriptor SDRdaemonSourcePlugin::m_pluginDescriptor = {
|
||||
QString("SDRdaemon source input"),
|
||||
QString("3.8.6"),
|
||||
QString("3.9.0"),
|
||||
QString("(c) Edouard Griffiths, F4EXB"),
|
||||
QString("https://github.com/f4exb/sdrangel"),
|
||||
true,
|
||||
|
@ -26,15 +26,17 @@
|
||||
#include "sdrdaemonsourceinput.h"
|
||||
#include "sdrdaemonsourceudphandler.h"
|
||||
|
||||
SDRdaemonSourceUDPHandler::SDRdaemonSourceUDPHandler(SampleSinkFifo *sampleFifo, DeviceSourceAPI *devieAPI) :
|
||||
m_deviceAPI(devieAPI),
|
||||
SDRdaemonSourceUDPHandler::SDRdaemonSourceUDPHandler(SampleSinkFifo *sampleFifo, DeviceSourceAPI *deviceAPI) :
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_masterTimer(deviceAPI->getMasterTimer()),
|
||||
m_masterTimerConnected(false),
|
||||
m_running(false),
|
||||
m_sdrDaemonBuffer(m_rateDivider),
|
||||
m_dataSocket(0),
|
||||
m_dataAddress(QHostAddress::LocalHost),
|
||||
m_remoteAddress(QHostAddress::LocalHost),
|
||||
m_dataPort(9090),
|
||||
m_dataConnected(false),
|
||||
m_startInit(true),
|
||||
m_udpBuf(0),
|
||||
m_udpReadBytes(0),
|
||||
m_sampleFifo(sampleFifo),
|
||||
@ -54,6 +56,16 @@ SDRdaemonSourceUDPHandler::SDRdaemonSourceUDPHandler(SampleSinkFifo *sampleFifo,
|
||||
m_autoCorrBuffer(true)
|
||||
{
|
||||
m_udpBuf = new char[SDRdaemonSourceBuffer::m_udpPayloadSize];
|
||||
|
||||
#ifdef USE_INTERNAL_TIMER
|
||||
#warning "Uses internal timer"
|
||||
m_timer = new QTimer();
|
||||
m_timer->start(50);
|
||||
m_throttlems = m_timer->interval();
|
||||
#else
|
||||
m_throttlems = m_masterTimer.interval();
|
||||
#endif
|
||||
m_rateDivider = 1000 / m_throttlems;
|
||||
}
|
||||
|
||||
SDRdaemonSourceUDPHandler::~SDRdaemonSourceUDPHandler()
|
||||
@ -71,6 +83,10 @@ void SDRdaemonSourceUDPHandler::start()
|
||||
{
|
||||
qDebug("SDRdaemonSourceUDPHandler::start");
|
||||
|
||||
if (m_running) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_dataSocket)
|
||||
{
|
||||
m_dataSocket = new QUdpSocket(this);
|
||||
@ -93,16 +109,20 @@ void SDRdaemonSourceUDPHandler::start()
|
||||
}
|
||||
}
|
||||
|
||||
// Need to notify the DSP engine to actually start FIXME: may cause transient confusion because at this point sample rate and frequency are unknown
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(128000, 435000 * 1000); // Frequency in Hz for the DSP engine
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||
m_elapsedTimer.start();
|
||||
m_running = true;
|
||||
}
|
||||
|
||||
void SDRdaemonSourceUDPHandler::stop()
|
||||
{
|
||||
qDebug("SDRdaemonSourceUDPHandler::stop");
|
||||
|
||||
if (!m_running) {
|
||||
return;
|
||||
}
|
||||
|
||||
disconnectTimer();
|
||||
|
||||
if (m_dataConnected)
|
||||
{
|
||||
m_dataConnected = false;
|
||||
@ -115,7 +135,9 @@ void SDRdaemonSourceUDPHandler::stop()
|
||||
m_dataSocket = 0;
|
||||
}
|
||||
|
||||
m_startInit = true;
|
||||
m_centerFrequency = 0;
|
||||
m_samplerate = 0;
|
||||
m_running = false;
|
||||
}
|
||||
|
||||
void SDRdaemonSourceUDPHandler::configureUDPLink(const QString& address, quint16 port)
|
||||
@ -129,8 +151,8 @@ void SDRdaemonSourceUDPHandler::configureUDPLink(const QString& address, quint16
|
||||
m_dataAddress = QHostAddress::LocalHost;
|
||||
}
|
||||
|
||||
stop();
|
||||
m_dataPort = port;
|
||||
stop();
|
||||
start();
|
||||
}
|
||||
|
||||
@ -154,10 +176,8 @@ void SDRdaemonSourceUDPHandler::processData()
|
||||
{
|
||||
m_sdrDaemonBuffer.writeData(m_udpBuf);
|
||||
const SDRdaemonSourceBuffer::MetaDataFEC& metaData = m_sdrDaemonBuffer.getCurrentMeta();
|
||||
|
||||
bool change = false;
|
||||
// m_tv_sec = metaData.m_tv_sec;
|
||||
// m_tv_usec = metaData.m_tv_usec;
|
||||
|
||||
m_tv_sec = m_sdrDaemonBuffer.getTVOutSec();
|
||||
m_tv_usec = m_sdrDaemonBuffer.getTVOutUsec();
|
||||
|
||||
@ -173,14 +193,15 @@ void SDRdaemonSourceUDPHandler::processData()
|
||||
change = true;
|
||||
}
|
||||
|
||||
if (change || m_startInit)
|
||||
if (change && (m_samplerate != 0) && (m_centerFrequency != 0))
|
||||
{
|
||||
qDebug("SDRdaemonSourceUDPHandler::processData: m_samplerate: %u m_centerFrequency: %u kHz", m_samplerate, m_centerFrequency);
|
||||
|
||||
if (m_samplerate != 0)
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(m_samplerate, m_centerFrequency * 1000); // Frequency in Hz for the DSP engine
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||
|
||||
if (m_outputMessageQueueToGUI)
|
||||
{
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(m_samplerate, m_centerFrequency * 1000); // Frequency in Hz for the DSP engine
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||
SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData *report = SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamData::create(
|
||||
m_samplerate,
|
||||
m_centerFrequency * 1000, // Frequency in Hz for the GUI
|
||||
@ -188,25 +209,40 @@ void SDRdaemonSourceUDPHandler::processData()
|
||||
m_tv_usec);
|
||||
|
||||
m_outputMessageQueueToGUI->push(report);
|
||||
m_startInit = false;
|
||||
}
|
||||
|
||||
connectTimer();
|
||||
}
|
||||
}
|
||||
|
||||
void SDRdaemonSourceUDPHandler::connectTimer(const QTimer* timer)
|
||||
void SDRdaemonSourceUDPHandler::connectTimer()
|
||||
{
|
||||
qDebug() << "SDRdaemonSourceUDPHandler::connectTimer";
|
||||
if (!m_masterTimerConnected)
|
||||
{
|
||||
qDebug() << "SDRdaemonSourceUDPHandler::connectTimer";
|
||||
#ifdef USE_INTERNAL_TIMER
|
||||
#warning "Uses internal timer"
|
||||
m_timer = new QTimer();
|
||||
m_timer->start(50);
|
||||
m_throttlems = m_timer->interval();
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(tick()));
|
||||
connect(m_timer, SIGNAL(timeout()), this, SLOT(tick()));
|
||||
#else
|
||||
m_throttlems = timer->interval();
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(tick()));
|
||||
connect(&m_masterTimer, SIGNAL(timeout()), this, SLOT(tick()));
|
||||
#endif
|
||||
m_rateDivider = 1000 / m_throttlems;
|
||||
m_masterTimerConnected = true;
|
||||
}
|
||||
}
|
||||
|
||||
void SDRdaemonSourceUDPHandler::disconnectTimer()
|
||||
{
|
||||
if (m_masterTimerConnected)
|
||||
{
|
||||
qDebug() << "SDRdaemonSourceUDPHandler::disconnectTimer";
|
||||
#ifdef USE_INTERNAL_TIMER
|
||||
#warning "Uses internal timer"
|
||||
disconnect(m_timer, SIGNAL(timeout()), this, SLOT(tick()));
|
||||
#else
|
||||
disconnect(&m_masterTimer, SIGNAL(timeout()), this, SLOT(tick()));
|
||||
#endif
|
||||
m_masterTimerConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
void SDRdaemonSourceUDPHandler::tick()
|
||||
@ -237,24 +273,25 @@ void SDRdaemonSourceUDPHandler::tick()
|
||||
}
|
||||
else
|
||||
{
|
||||
int framesDecodingStatus;
|
||||
int minNbBlocks = m_sdrDaemonBuffer.getMinNbBlocks();
|
||||
int minNbOriginalBlocks = m_sdrDaemonBuffer.getMinOriginalBlocks();
|
||||
int nbOriginalBlocks = m_sdrDaemonBuffer.getCurrentMeta().m_nbOriginalBlocks;
|
||||
int nbFECblocks = m_sdrDaemonBuffer.getCurrentMeta().m_nbFECBlocks;
|
||||
m_tickCount = 0;
|
||||
|
||||
//framesDecodingStatus = (minNbOriginalBlocks == nbOriginalBlocks ? 2 : (minNbOriginalBlocks < nbOriginalBlocks - nbFECblocks ? 0 : 1));
|
||||
if (minNbBlocks < nbOriginalBlocks) {
|
||||
framesDecodingStatus = 0;
|
||||
} else if (minNbBlocks < nbOriginalBlocks + nbFECblocks) {
|
||||
framesDecodingStatus = 1;
|
||||
} else {
|
||||
framesDecodingStatus = 2;
|
||||
}
|
||||
|
||||
if (m_outputMessageQueueToGUI)
|
||||
{
|
||||
int framesDecodingStatus;
|
||||
int minNbBlocks = m_sdrDaemonBuffer.getMinNbBlocks();
|
||||
int minNbOriginalBlocks = m_sdrDaemonBuffer.getMinOriginalBlocks();
|
||||
int nbOriginalBlocks = m_sdrDaemonBuffer.getCurrentMeta().m_nbOriginalBlocks;
|
||||
int nbFECblocks = m_sdrDaemonBuffer.getCurrentMeta().m_nbFECBlocks;
|
||||
|
||||
//framesDecodingStatus = (minNbOriginalBlocks == nbOriginalBlocks ? 2 : (minNbOriginalBlocks < nbOriginalBlocks - nbFECblocks ? 0 : 1));
|
||||
if (minNbBlocks < nbOriginalBlocks) {
|
||||
framesDecodingStatus = 0;
|
||||
} else if (minNbBlocks < nbOriginalBlocks + nbFECblocks) {
|
||||
framesDecodingStatus = 1;
|
||||
} else {
|
||||
framesDecodingStatus = 2;
|
||||
}
|
||||
|
||||
SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming *report = SDRdaemonSourceInput::MsgReportSDRdaemonSourceStreamTiming::create(
|
||||
m_tv_sec,
|
||||
m_tv_usec,
|
||||
|
@ -39,24 +39,28 @@ public:
|
||||
SDRdaemonSourceUDPHandler(SampleSinkFifo* sampleFifo, DeviceSourceAPI *deviceAPI);
|
||||
~SDRdaemonSourceUDPHandler();
|
||||
void setMessageQueueToGUI(MessageQueue *queue) { m_outputMessageQueueToGUI = queue; }
|
||||
void connectTimer(const QTimer* timer);
|
||||
void start();
|
||||
void stop();
|
||||
void configureUDPLink(const QString& address, quint16 port);
|
||||
void getRemoteAddress(QString& s) const { s = m_remoteAddress.toString(); }
|
||||
int getNbOriginalBlocks() const { return SDRdaemonSourceBuffer::m_nbOriginalBlocks; }
|
||||
bool isStreaming() const { return m_masterTimerConnected; }
|
||||
int getSampleRate() const { return m_samplerate; }
|
||||
int getCenterFrequency() const { return m_centerFrequency * 1000; }
|
||||
public slots:
|
||||
void dataReadyRead();
|
||||
|
||||
private:
|
||||
DeviceSourceAPI *m_deviceAPI;
|
||||
const QTimer& m_masterTimer;
|
||||
bool m_masterTimerConnected;
|
||||
bool m_running;
|
||||
SDRdaemonSourceBuffer m_sdrDaemonBuffer;
|
||||
QUdpSocket *m_dataSocket;
|
||||
QHostAddress m_dataAddress;
|
||||
QHostAddress m_remoteAddress;
|
||||
quint16 m_dataPort;
|
||||
bool m_dataConnected;
|
||||
bool m_startInit;
|
||||
char *m_udpBuf;
|
||||
qint64 m_udpReadBytes;
|
||||
SampleSinkFifo *m_sampleFifo;
|
||||
@ -77,6 +81,8 @@ private:
|
||||
uint32_t m_rateDivider;
|
||||
bool m_autoCorrBuffer;
|
||||
|
||||
void connectTimer();
|
||||
void disconnectTimer();
|
||||
void processData();
|
||||
|
||||
private slots:
|
||||
|
Loading…
Reference in New Issue
Block a user