SDRdaemonFEC: refactor to better look like SDRdaemonSink

pull/60/head
f4exb 2017-06-08 02:06:36 +02:00
rodzic 407976d4c3
commit 27eae5e3b4
4 zmienionych plików z 515 dodań i 238 usunięć

Wyświetl plik

@ -64,6 +64,8 @@ SDRdaemonFECGui::SDRdaemonFECGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
m_addressEdited(false), m_addressEdited(false),
m_dataPortEdited(false), m_dataPortEdited(false),
m_initSendConfiguration(false), m_initSendConfiguration(false),
m_doApplySettings(true),
m_forceSettings(true),
m_dcBlock(false), m_dcBlock(false),
m_iqCorrection(false) m_iqCorrection(false)
{ {
@ -86,6 +88,7 @@ SDRdaemonFECGui::SDRdaemonFECGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500); m_statusTimer.start(500);
connect(&(deviceAPI->getMainWindow()->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick())); connect(&(deviceAPI->getMainWindow()->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
m_sampleSource = new SDRdaemonFECInput(deviceAPI->getMainWindow()->getMasterTimer(), m_deviceAPI); m_sampleSource = new SDRdaemonFECInput(deviceAPI->getMainWindow()->getMasterTimer(), m_deviceAPI);
connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages())); connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
@ -99,6 +102,10 @@ SDRdaemonFECGui::SDRdaemonFECGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
m_deviceAPI->addSink(m_fileSink); m_deviceAPI->addSink(m_fileSink);
connect(m_deviceAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection); connect(m_deviceAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection);
displaySettings();
sendControl(true);
sendSettings();
} }
SDRdaemonFECGui::~SDRdaemonFECGui() SDRdaemonFECGui::~SDRdaemonFECGui()
@ -109,6 +116,11 @@ SDRdaemonFECGui::~SDRdaemonFECGui()
delete ui; delete ui;
} }
void SDRdaemonFECGui::blockApplySettings(bool block)
{
m_doApplySettings = !block;
}
void SDRdaemonFECGui::destroy() void SDRdaemonFECGui::destroy()
{ {
delete this; delete this;
@ -126,146 +138,164 @@ QString SDRdaemonFECGui::getName() const
void SDRdaemonFECGui::resetToDefaults() void SDRdaemonFECGui::resetToDefaults()
{ {
m_address = "127.0.0.1"; blockApplySettings(true);
m_remoteAddress = "127.0.0.1"; m_settings.resetToDefaults();
m_dataPort = 9090;
m_controlPort = 9091;
m_dcBlock = false;
m_iqCorrection = false;
displaySettings(); displaySettings();
blockApplySettings(false);
sendSettings();
} }
QByteArray SDRdaemonFECGui::serialize() const QByteArray SDRdaemonFECGui::serialize() const
{ {
bool ok; return m_settings.serialize();
SimpleSerializer s(1); // bool ok;
// SimpleSerializer s(1);
s.writeString(1, ui->address->text()); //
uint32_t uintval = ui->dataPort->text().toInt(&ok); // s.writeString(1, ui->address->text());
// uint32_t uintval = ui->dataPort->text().toInt(&ok);
if((!ok) || (uintval < 1024) || (uintval > 65535)) { //
uintval = 9090; // if((!ok) || (uintval < 1024) || (uintval > 65535)) {
} // uintval = 9090;
// }
s.writeU32(2, uintval); //
s.writeBool(3, m_dcBlock); // s.writeU32(2, uintval);
s.writeBool(4, m_iqCorrection); // s.writeBool(3, m_dcBlock);
// s.writeBool(4, m_iqCorrection);
uintval = ui->controlPort->text().toInt(&ok); //
// uintval = ui->controlPort->text().toInt(&ok);
if((!ok) || (uintval < 1024) || (uintval > 65535)) { //
uintval = 9091; // if((!ok) || (uintval < 1024) || (uintval > 65535)) {
} // uintval = 9091;
// }
s.writeU32(5, uintval); //
// s.writeU32(5, uintval);
uint32_t confFrequency = ui->freq->text().toInt(&ok); //
// uint32_t confFrequency = ui->freq->text().toInt(&ok);
if (ok) { //
s.writeU32(6, confFrequency); // if (ok) {
} // s.writeU32(6, confFrequency);
// }
s.writeU32(7, ui->decim->currentIndex()); //
s.writeU32(8, ui->fcPos->currentIndex()); // s.writeU32(7, ui->decim->currentIndex());
// s.writeU32(8, ui->fcPos->currentIndex());
uint32_t sampleRate = ui->sampleRate->text().toInt(&ok); //
// uint32_t sampleRate = ui->sampleRate->text().toInt(&ok);
if (ok) { //
s.writeU32(9, sampleRate); // if (ok) {
} // s.writeU32(9, sampleRate);
// }
s.writeString(10, ui->specificParms->text()); //
// s.writeString(10, ui->specificParms->text());
return s.final(); //
// return s.final();
} }
bool SDRdaemonFECGui::deserialize(const QByteArray& data) bool SDRdaemonFECGui::deserialize(const QByteArray& data)
{ {
SimpleDeserializer d(data); blockApplySettings(true);
QString address;
quint16 dataPort;
bool dcBlock;
bool iqCorrection;
uint32_t confFrequency;
uint32_t confSampleRate;
uint32_t confDecim;
uint32_t confFcPos;
QString confSpecificParms;
if (!d.isValid()) if(m_settings.deserialize(data))
{ {
resetToDefaults();
displaySettings(); displaySettings();
return false;
}
if (d.getVersion() == 1)
{
uint32_t uintval;
d.readString(1, &address, "127.0.0.1");
d.readU32(2, &uintval, 9090);
if ((uintval > 1024) && (uintval < 65536)) {
dataPort = uintval;
} else {
dataPort = 9090;
}
d.readBool(3, &dcBlock, false);
d.readBool(4, &iqCorrection, false);
d.readU32(5, &uintval, 9091);
if ((uintval > 1024) && (uintval < 65536)) {
m_controlPort = uintval;
} else {
m_controlPort = 9091;
}
d.readU32(6, &confFrequency, 435000);
d.readU32(7, &confDecim, 3);
d.readU32(8, &confFcPos, 2);
d.readU32(9, &confSampleRate, 1000);
d.readString(10, &confSpecificParms, "");
if ((address != m_address) || (dataPort != m_dataPort))
{
m_address = address;
m_dataPort = dataPort;
configureUDPLink(); configureUDPLink();
} blockApplySettings(false);
sendControl(true);
if ((dcBlock != m_dcBlock) || (iqCorrection != m_iqCorrection)) m_forceSettings = true;
{ sendSettings();
m_dcBlock = dcBlock;
m_iqCorrection = iqCorrection;
configureAutoCorrections();
}
displaySettings();
displayConfigurationParameters(confFrequency, confDecim, confFcPos, confSampleRate, confSpecificParms);
m_initSendConfiguration = true;
return true; return true;
} }
else else
{ {
resetToDefaults(); blockApplySettings(false);
displaySettings();
QString defaultSpecificParameters("");
displayConfigurationParameters(435000, 3, 2, 1000, defaultSpecificParameters);
m_initSendConfiguration = true;
return false; return false;
} }
// SimpleDeserializer d(data);
// QString address;
// quint16 dataPort;
// bool dcBlock;
// bool iqCorrection;
// uint32_t confFrequency;
// uint32_t confSampleRate;
// uint32_t confDecim;
// uint32_t confFcPos;
// QString confSpecificParms;
//
// if (!d.isValid())
// {
// resetToDefaults();
// displaySettings();
// return false;
// }
//
// if (d.getVersion() == 1)
// {
// uint32_t uintval;
// d.readString(1, &address, "127.0.0.1");
// d.readU32(2, &uintval, 9090);
//
// if ((uintval > 1024) && (uintval < 65536)) {
// dataPort = uintval;
// } else {
// dataPort = 9090;
// }
//
// d.readBool(3, &dcBlock, false);
// d.readBool(4, &iqCorrection, false);
// d.readU32(5, &uintval, 9091);
//
// if ((uintval > 1024) && (uintval < 65536)) {
// m_controlPort = uintval;
// } else {
// m_controlPort = 9091;
// }
//
// d.readU32(6, &confFrequency, 435000);
// d.readU32(7, &confDecim, 3);
// d.readU32(8, &confFcPos, 2);
// d.readU32(9, &confSampleRate, 1000);
// d.readString(10, &confSpecificParms, "");
//
// if ((address != m_address) || (dataPort != m_dataPort))
// {
// m_address = address;
// m_dataPort = dataPort;
// configureUDPLink();
// }
//
// if ((dcBlock != m_dcBlock) || (iqCorrection != m_iqCorrection))
// {
// m_dcBlock = dcBlock;
// m_iqCorrection = iqCorrection;
// configureAutoCorrections();
// }
//
// displaySettings();
// displayConfigurationParameters(confFrequency, confDecim, confFcPos, confSampleRate, confSpecificParms);
// m_initSendConfiguration = true;
// return true;
// }
// else
// {
// resetToDefaults();
// displaySettings();
// QString defaultSpecificParameters("");
// displayConfigurationParameters(435000, 3, 2, 1000, defaultSpecificParameters);
// m_initSendConfiguration = true;
// return false;
// }
} }
qint64 SDRdaemonFECGui::getCenterFrequency() const qint64 SDRdaemonFECGui::getCenterFrequency() const
{ {
return m_centerFrequency; return m_settings.m_centerFrequency;
} }
void SDRdaemonFECGui::setCenterFrequency(qint64 centerFrequency) void SDRdaemonFECGui::setCenterFrequency(qint64 centerFrequency)
{ {
m_centerFrequency = centerFrequency; m_settings.m_centerFrequency = centerFrequency;
displaySettings(); displaySettings();
sendControl();
sendSettings();
} }
bool SDRdaemonFECGui::handleMessage(const Message& message) bool SDRdaemonFECGui::handleMessage(const Message& message)
@ -357,136 +387,316 @@ void SDRdaemonFECGui::updateSampleRateAndFrequency()
void SDRdaemonFECGui::displaySettings() void SDRdaemonFECGui::displaySettings()
{ {
ui->address->setText(m_address); ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
ui->dataPort->setText(QString::number(m_dataPort)); // ui->sampleRate->setValue(m_settings.m_sampleRate);
ui->controlPort->setText(QString::number(m_controlPort)); ui->deviceRateText->setText(tr("%1k").arg(m_sampleRate / 1000.0));
ui->dcOffset->setChecked(m_dcBlock); // ui->txDelay->setValue(m_settings.m_txDelay*100);
ui->iqImbalance->setChecked(m_iqCorrection); // ui->txDelayText->setText(tr("%1").arg(m_settings.m_txDelay*100));
} // ui->nbFECBlocks->setValue(m_settings.m_nbFECBlocks);
void SDRdaemonFECGui::displayConfigurationParameters(uint32_t freq, ui->freq->setText(QString::number(m_settings.m_centerFrequency / 1000));
uint32_t log2Decim, ui->decim->setCurrentIndex(m_settings.m_log2Decim);
uint32_t fcPos, ui->fcPos->setCurrentIndex(m_settings.m_fcPos);
uint32_t sampleRate, ui->sampleRate->setText(QString::number(m_settings.m_sampleRate / 1000));
QString& specParms) ui->specificParms->setText(m_settings.m_specificParameters);
{
ui->freq->setText(QString::number(freq));
ui->decim->setCurrentIndex(log2Decim);
ui->fcPos->setCurrentIndex(fcPos);
ui->sampleRate->setText(QString::number(sampleRate));
ui->specificParms->setText(specParms);
ui->specificParms->setCursorPosition(0); ui->specificParms->setCursorPosition(0);
QString s0 = QString::number(128 + m_settings.m_nbFECBlocks, 'f', 0);
QString s1 = QString::number(m_settings.m_nbFECBlocks, 'f', 0);
ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s0).arg(s1));
ui->address->setText(m_settings.m_address);
ui->dataPort->setText(tr("%1").arg(m_settings.m_dataPort));
ui->controlPort->setText(tr("%1").arg(m_settings.m_controlPort));
ui->specificParms->setText(m_settings.m_specificParameters);
// ui->address->setText(m_address);
// ui->dataPort->setText(QString::number(m_dataPort));
// ui->controlPort->setText(QString::number(m_controlPort));
ui->dcOffset->setChecked(m_settings.m_dcBlock);
ui->iqImbalance->setChecked(m_settings.m_iqCorrection);
} }
void SDRdaemonFECGui::on_applyButton_clicked(bool checked __attribute__((unused))) void SDRdaemonFECGui::sendControl(bool force)
{
bool dataOk, ctlOk;
QString udpAddress = ui->address->text();
int udpDataPort = ui->dataPort->text().toInt(&dataOk);
int tcpCtlPort = ui->controlPort->text().toInt(&ctlOk);
if((!dataOk) || (udpDataPort < 1024) || (udpDataPort > 65535))
{
udpDataPort = 9090;
}
if((!ctlOk) || (tcpCtlPort < 1024) || (tcpCtlPort > 65535))
{
tcpCtlPort = 9091;
}
m_address = udpAddress;
m_dataPort = udpDataPort;
m_controlPort = tcpCtlPort;
if (m_addressEdited || m_dataPortEdited)
{
configureUDPLink();
m_addressEdited = false;
m_dataPortEdited = false;
}
}
void SDRdaemonFECGui::on_sendButton_clicked(bool checked __attribute__((unused)))
{
sendConfiguration();
ui->specificParms->setCursorPosition(0);
}
void SDRdaemonFECGui::sendConfiguration()
{ {
QString remoteAddress; QString remoteAddress;
((SDRdaemonFECInput *) m_sampleSource)->getRemoteAddress(remoteAddress); ((SDRdaemonFECInput *) m_sampleSource)->getRemoteAddress(remoteAddress);
if (remoteAddress != m_remoteAddress) if ((remoteAddress != m_remoteAddress) ||
(m_settings.m_controlPort != m_controlSettings.m_controlPort) || force)
{ {
m_remoteAddress = remoteAddress; m_remoteAddress = remoteAddress;
std::ostringstream os;
os << "tcp://" << m_remoteAddress.toStdString() << ":" << m_controlPort; int rc = nn_shutdown(m_sender, 0);
std::string addrstrng = os.str();
int rc = nn_connect(m_sender, addrstrng.c_str());
if (rc < 0) { if (rc < 0) {
qDebug() << "SDRdaemonGui::sendConfiguration: connexion to " << addrstrng.c_str() << " failed"; qDebug() << "SDRdaemonFECGui::sendControl: disconnection failed";
} else {
qDebug() << "SDRdaemonFECGui::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() << "SDRdaemonFECGui::sendConfiguration: connexion to " << addrstrng.c_str() << " failed";
QMessageBox::information(this, tr("Message"), tr("Cannot connect to remote control port")); QMessageBox::information(this, tr("Message"), tr("Cannot connect to remote control port"));
} else { } else {
qDebug() << "SDRdaemonGui::sendConfiguration: connexion to " << addrstrng.c_str() << " successful"; qDebug() << "SDRdaemonFECGui::sendConfiguration: connexion to " << addrstrng.c_str() << " successful";
} }
} }
std::ostringstream os; std::ostringstream os;
bool ok; int nbArgs = 0;
os << "decim=" << ui->decim->currentIndex() if ((m_settings.m_centerFrequency != m_controlSettings.m_centerFrequency) || force)
<< ",fcpos=" << ui->fcPos->currentIndex(); {
os << "freq=" << m_settings.m_centerFrequency;
uint64_t freq = ui->freq->text().toInt(&ok); nbArgs++;
if (ok) {
os << ",freq=" << freq*1000LL;
} else {
QMessageBox::information(this, tr("Message"), tr("Invalid frequency"));
} }
uint32_t srate = ui->sampleRate->text().toInt(&ok); if ((m_settings.m_sampleRate != m_controlSettings.m_sampleRate) || (m_settings.m_log2Decim != m_controlSettings.m_log2Decim) || force)
{
if (ok) { if (nbArgs > 0) os << ",";
os << ",srate=" << srate*1000; os << "srate=" << m_settings.m_sampleRate;
} else { nbArgs++;
QMessageBox::information(this, tr("Message"), tr("invalid sample rate"));
} }
if ((ui->specificParms->text()).size() > 0) { if ((m_settings.m_log2Decim != m_controlSettings.m_log2Decim) || force)
os << "," << ui->specificParms->text().toStdString(); {
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_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 config_size = os.str().size();
int rc = nn_send(m_sender, (void *) os.str().c_str(), config_size, 0); int rc = nn_send(m_sender, (void *) os.str().c_str(), config_size, 0);
if (rc != config_size) if (rc != config_size)
{ {
QMessageBox::information(this, tr("Message"), tr("Cannot send message to remote control port")); //QMessageBox::information(this, tr("Message"), tr("Cannot send message to remote control port"));
qDebug() << "SDRdaemonFECGui::sendControl: Cannot send message to remote control port."
<< " remoteAddress: " << m_remoteAddress
<< " remotePort: " << m_settings.m_controlPort
<< " message: " << os.str().c_str();
} }
else else
{ {
qDebug() << "SDRdaemonGui::sendConfiguration:" qDebug() << "SDRdaemonFECGui::sendControl:"
<< " remoteAddress: " << remoteAddress << "remoteAddress:" << m_remoteAddress
<< "remotePort:" << m_settings.m_controlPort
<< "message:" << os.str().c_str(); << "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_specificParameters = m_settings.m_specificParameters;
}
void SDRdaemonFECGui::sendSettings()
{
if(!m_updateTimer.isActive())
m_updateTimer.start(100);
}
//void SDRdaemonFECGui::displayConfigurationParameters(uint32_t freq,
// uint32_t log2Decim,
// uint32_t fcPos,
// uint32_t sampleRate,
// QString& specParms)
//{
// ui->freq->setText(QString::number(freq));
// ui->decim->setCurrentIndex(log2Decim);
// ui->fcPos->setCurrentIndex(fcPos);
// ui->sampleRate->setText(QString::number(sampleRate));
// ui->specificParms->setText(specParms);
// ui->specificParms->setCursorPosition(0);
//}
void SDRdaemonFECGui::on_applyButton_clicked(bool checked __attribute__((unused)))
{
m_settings.m_address = ui->address->text();
bool ctlOk;
int udpCtlPort = ui->controlPort->text().toInt(&ctlOk);
if((ctlOk) && (udpCtlPort >= 1024) && (udpCtlPort < 65535))
{
m_settings.m_controlPort = udpCtlPort;
}
bool dataOk;
int udpDataPort = ui->dataPort->text().toInt(&dataOk);
if((dataOk) && (udpDataPort >= 1024) && (udpDataPort < 65535))
{
m_settings.m_dataPort = udpDataPort;
}
configureUDPLink();
// bool dataOk, ctlOk;
// QString udpAddress = ui->address->text();
// int udpDataPort = ui->dataPort->text().toInt(&dataOk);
// int tcpCtlPort = ui->controlPort->text().toInt(&ctlOk);
//
// if((!dataOk) || (udpDataPort < 1024) || (udpDataPort > 65535))
// {
// udpDataPort = 9090;
// }
//
// if((!ctlOk) || (tcpCtlPort < 1024) || (tcpCtlPort > 65535))
// {
// tcpCtlPort = 9091;
// }
//
// m_address = udpAddress;
// m_dataPort = udpDataPort;
// m_controlPort = tcpCtlPort;
//
// if (m_addressEdited || m_dataPortEdited)
// {
// configureUDPLink();
// m_addressEdited = false;
// m_dataPortEdited = false;
// }
}
void SDRdaemonFECGui::on_sendButton_clicked(bool checked __attribute__((unused)))
{
sendControl(true);
// sendConfiguration();
ui->specificParms->setCursorPosition(0);
}
//void SDRdaemonFECGui::sendConfiguration()
//{
// QString remoteAddress;
// ((SDRdaemonFECInput *) m_sampleSource)->getRemoteAddress(remoteAddress);
//
// if (remoteAddress != m_remoteAddress)
// {
// m_remoteAddress = remoteAddress;
// std::ostringstream os;
// os << "tcp://" << m_remoteAddress.toStdString() << ":" << m_controlPort;
// std::string addrstrng = os.str();
// int rc = nn_connect(m_sender, addrstrng.c_str());
//
// if (rc < 0) {
// qDebug() << "SDRdaemonGui::sendConfiguration: connexion to " << addrstrng.c_str() << " failed";
// QMessageBox::information(this, tr("Message"), tr("Cannot connect to remote control port"));
// } else {
// qDebug() << "SDRdaemonGui::sendConfiguration: connexion to " << addrstrng.c_str() << " successful";
// }
// }
//
// std::ostringstream os;
// bool ok;
//
// os << "decim=" << ui->decim->currentIndex()
// << ",fcpos=" << ui->fcPos->currentIndex();
//
// uint64_t freq = ui->freq->text().toInt(&ok);
//
// if (ok) {
// os << ",freq=" << freq*1000LL;
// } else {
// QMessageBox::information(this, tr("Message"), tr("Invalid frequency"));
// }
//
// uint32_t srate = ui->sampleRate->text().toInt(&ok);
//
// if (ok) {
// os << ",srate=" << srate*1000;
// } else {
// QMessageBox::information(this, tr("Message"), tr("invalid sample rate"));
// }
//
// if ((ui->specificParms->text()).size() > 0) {
// os << "," << ui->specificParms->text().toStdString();
// }
//
// 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"));
// }
// else
// {
// qDebug() << "SDRdaemonGui::sendConfiguration:"
// << " remoteAddress: " << remoteAddress
// << " message: " << os.str().c_str();
// }
//}
void SDRdaemonFECGui::on_address_returnPressed() void SDRdaemonFECGui::on_address_returnPressed()
{ {
m_addressEdited = true; m_settings.m_address = ui->address->text();
configureUDPLink();
} }
void SDRdaemonFECGui::on_dataPort_returnPressed() void SDRdaemonFECGui::on_dataPort_returnPressed()
{ {
m_dataPortEdited = true; bool dataOk;
int udpDataPort = ui->dataPort->text().toInt(&dataOk);
if((!dataOk) || (udpDataPort < 1024) || (udpDataPort > 65535))
{
return;
}
else
{
m_settings.m_dataPort = udpDataPort;
}
configureUDPLink();
} }
void SDRdaemonFECGui::on_controlPort_returnPressed() void SDRdaemonFECGui::on_controlPort_returnPressed()
{ {
bool ctlOk;
int udpCtlPort = ui->controlPort->text().toInt(&ctlOk);
if((!ctlOk) || (udpCtlPort < 1024) || (udpCtlPort > 65535))
{
return;
}
else
{
m_settings.m_controlPort = udpCtlPort;
}
sendControl();
} }
void SDRdaemonFECGui::on_dcOffset_toggled(bool checked) void SDRdaemonFECGui::on_dcOffset_toggled(bool checked)
@ -509,22 +719,46 @@ void SDRdaemonFECGui::on_iqImbalance_toggled(bool checked)
void SDRdaemonFECGui::on_freq_returnPressed() void SDRdaemonFECGui::on_freq_returnPressed()
{ {
bool ok;
uint64_t freq = ui->freq->text().toInt(&ok);
if (ok)
{
m_settings.m_centerFrequency = freq * 1000;
sendControl();
}
} }
void SDRdaemonFECGui::on_sampleRate_returnPressed() void SDRdaemonFECGui::on_sampleRate_returnPressed()
{ {
bool ok;
uint32_t srate = ui->sampleRate->text().toInt(&ok);
if (ok)
{
m_settings.m_sampleRate = srate * 1000;
sendControl();
}
} }
void SDRdaemonFECGui::on_specificParms_returnPressed() void SDRdaemonFECGui::on_specificParms_returnPressed()
{ {
if ((ui->specificParms->text()).size() > 0) {
m_settings.m_specificParameters = ui->specificParms->text();
sendControl();
}
} }
void SDRdaemonFECGui::on_decim_currentIndexChanged(int index __attribute__((unused))) void SDRdaemonFECGui::on_decim_currentIndexChanged(int index __attribute__((unused)))
{ {
m_settings.m_log2Decim = ui->decim->currentIndex();
sendControl();
} }
void SDRdaemonFECGui::on_fcPos_currentIndexChanged(int index __attribute__((unused))) void SDRdaemonFECGui::on_fcPos_currentIndexChanged(int index __attribute__((unused)))
{ {
m_settings.m_fcPos = ui->fcPos->currentIndex();
sendControl();
} }
void SDRdaemonFECGui::on_startStop_toggled(bool checked) void SDRdaemonFECGui::on_startStop_toggled(bool checked)
@ -560,10 +794,10 @@ void SDRdaemonFECGui::on_record_toggled(bool checked)
void SDRdaemonFECGui::configureUDPLink() void SDRdaemonFECGui::configureUDPLink()
{ {
qDebug() << "SDRdaemonGui::configureUDPLink: " << m_address.toStdString().c_str() qDebug() << "SDRdaemonGui::configureUDPLink: " << m_settings.m_address.toStdString().c_str()
<< " : " << m_dataPort; << " : " << m_settings.m_dataPort;
SDRdaemonFECInput::MsgConfigureSDRdaemonUDPLink* message = SDRdaemonFECInput::MsgConfigureSDRdaemonUDPLink::create(m_address, m_dataPort); SDRdaemonFECInput::MsgConfigureSDRdaemonUDPLink* message = SDRdaemonFECInput::MsgConfigureSDRdaemonUDPLink::create(m_settings.m_address, m_settings.m_dataPort);
m_sampleSource->getInputMessageQueue()->push(message); m_sampleSource->getInputMessageQueue()->push(message);
} }
@ -585,11 +819,11 @@ void SDRdaemonFECGui::updateWithStreamData()
void SDRdaemonFECGui::updateWithStreamTime() void SDRdaemonFECGui::updateWithStreamTime()
{ {
if (m_initSendConfiguration) // if (m_initSendConfiguration)
{ // {
sendConfiguration(); // sendConfiguration();
m_initSendConfiguration = false; // m_initSendConfiguration = false;
} // }
quint64 startingTimeStampMsec = ((quint64) m_startingTimeStamp.tv_sec * 1000LL) + ((quint64) m_startingTimeStamp.tv_usec / 1000LL); quint64 startingTimeStampMsec = ((quint64) m_startingTimeStamp.tv_sec * 1000LL) + ((quint64) m_startingTimeStamp.tv_usec / 1000LL);
QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec); QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
@ -639,6 +873,15 @@ void SDRdaemonFECGui::updateWithStreamTime()
ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s).arg(s1)); ui->nominalNbBlocksText->setText(tr("%1/%2").arg(s).arg(s1));
} }
void SDRdaemonFECGui::updateHardware()
{
qDebug() << "SDRdaemonSinkGui::updateHardware";
SDRdaemonFECInput::MsgConfigureSDRdaemonFEC* message = SDRdaemonFECInput::MsgConfigureSDRdaemonFEC::create(m_settings, m_forceSettings);
m_sampleSource->getInputMessageQueue()->push(message);
m_forceSettings = false;
m_updateTimer.stop();
}
void SDRdaemonFECGui::updateStatus() void SDRdaemonFECGui::updateStatus()
{ {
int state = m_deviceAPI->state(); int state = m_deviceAPI->state();

Wyświetl plik

@ -52,6 +52,8 @@ private:
Ui::SDRdaemonFECGui* ui; Ui::SDRdaemonFECGui* ui;
DeviceSourceAPI* m_deviceAPI; DeviceSourceAPI* m_deviceAPI;
SDRdaemonFECSettings m_settings; //!< current settings
SDRdaemonFECSettings m_controlSettings; //!< settings last sent to device via control port
QTimer m_updateTimer; QTimer m_updateTimer;
QTimer m_statusTimer; QTimer m_statusTimer;
DeviceSampleSource* m_sampleSource; DeviceSampleSource* m_sampleSource;
@ -88,6 +90,8 @@ private:
bool m_dataPortEdited; bool m_dataPortEdited;
bool m_initSendConfiguration; bool m_initSendConfiguration;
int m_sender; int m_sender;
bool m_doApplySettings;
bool m_forceSettings;
bool m_dcBlock; bool m_dcBlock;
bool m_iqCorrection; bool m_iqCorrection;
@ -95,21 +99,24 @@ private:
QPalette m_paletteGreenText; QPalette m_paletteGreenText;
QPalette m_paletteWhiteText; QPalette m_paletteWhiteText;
void blockApplySettings(bool block);
void displaySettings(); void displaySettings();
void displayConfigurationParameters(uint32_t freq, // void displayConfigurationParameters(uint32_t freq,
uint32_t log2Decim, // uint32_t log2Decim,
uint32_t fcPos, // uint32_t fcPos,
uint32_t sampleRate, // uint32_t sampleRate,
QString& specParms); // QString& specParms);
void displayTime(); void displayTime();
void sendControl(bool force = false);
void sendSettings();
void configureUDPLink(); void configureUDPLink();
void configureAutoCorrections(); void configureAutoCorrections();
void updateWithAcquisition(); void updateWithAcquisition();
void updateWithStreamData(); void updateWithStreamData();
void updateWithStreamTime(); void updateWithStreamTime();
void sendConfiguration(); // void sendConfiguration();
void updateSampleRateAndFrequency(); void updateSampleRateAndFrequency();
private slots: private slots:
@ -129,6 +136,7 @@ private slots:
void on_fcPos_currentIndexChanged(int index); void on_fcPos_currentIndexChanged(int index);
void on_startStop_toggled(bool checked); void on_startStop_toggled(bool checked);
void on_record_toggled(bool checked); void on_record_toggled(bool checked);
void updateHardware();
void updateStatus(); void updateStatus();
void tick(); void tick();
}; };

Wyświetl plik

@ -29,6 +29,7 @@
#include "sdrdaemonfecgui.h" #include "sdrdaemonfecgui.h"
#include "sdrdaemonfecudphandler.h" #include "sdrdaemonfecudphandler.h"
MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgConfigureSDRdaemonFEC, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgConfigureSDRdaemonUDPLink, Message) MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgConfigureSDRdaemonUDPLink, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgConfigureSDRdaemonAutoCorr, Message) MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgConfigureSDRdaemonAutoCorr, Message)
MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgConfigureSDRdaemonWork, Message) MESSAGE_CLASS_DEFINITION(SDRdaemonFECInput::MsgConfigureSDRdaemonWork, Message)

Wyświetl plik

@ -24,11 +24,36 @@
#include <iostream> #include <iostream>
#include <stdint.h> #include <stdint.h>
#include "sdrdaemonfecsettings.h"
class DeviceSourceAPI; class DeviceSourceAPI;
class SDRdaemonFECUDPHandler; class SDRdaemonFECUDPHandler;
class SDRdaemonFECInput : public DeviceSampleSource { class SDRdaemonFECInput : public DeviceSampleSource {
public: public:
class MsgConfigureSDRdaemonFEC : public Message {
MESSAGE_CLASS_DECLARATION
public:
const SDRdaemonFECSettings& getSettings() const { return m_settings; }
bool getForce() const { return m_force; }
static MsgConfigureSDRdaemonFEC* create(const SDRdaemonFECSettings& settings, bool force = false)
{
return new MsgConfigureSDRdaemonFEC(settings, force);
}
private:
SDRdaemonFECSettings m_settings;
bool m_force;
MsgConfigureSDRdaemonFEC(const SDRdaemonFECSettings& settings, bool force) :
Message(),
m_settings(settings),
m_force(force)
{ }
};
class MsgConfigureSDRdaemonUDPLink : public Message { class MsgConfigureSDRdaemonUDPLink : public Message {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION