1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-14 04:11:48 -05:00

UDP Source: compiles

This commit is contained in:
f4exb 2015-12-02 02:28:31 +01:00
parent ffebc53586
commit 9ed6b40ba5
5 changed files with 189 additions and 352 deletions

View File

@ -16,14 +16,12 @@
#include "udpsrc.h" #include "udpsrc.h"
#include <QTcpServer> #include <QUdpSocket>
#include <QTcpSocket>
#include <QThread> #include <QThread>
#include "dsp/channelizer.h" #include "dsp/channelizer.h"
#include "udpsrcgui.h" #include "udpsrcgui.h"
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcConfigure, Message) MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcConfigure, Message)
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcConnection, Message)
MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcSpectrum, Message) MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcSpectrum, Message)
UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* spectrum) : UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* spectrum) :
@ -31,6 +29,8 @@ UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* s
{ {
setObjectName("UDPSrc"); setObjectName("UDPSrc");
m_socket = new QUdpSocket(this);
m_inputSampleRate = 96000; m_inputSampleRate = 96000;
m_sampleFormat = FormatSSB; m_sampleFormat = FormatSSB;
m_outputSampleRate = 48000; m_outputSampleRate = 48000;
@ -58,12 +58,13 @@ UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* s
UDPSrc::~UDPSrc() UDPSrc::~UDPSrc()
{ {
delete m_socket;
if (UDPFilter) delete UDPFilter; if (UDPFilter) delete UDPFilter;
} }
void UDPSrc::configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int udpPort, int boost) void UDPSrc::configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, QString& udpAddress, int udpPort, int boost)
{ {
Message* cmd = MsgUDPSrcConfigure::create(sampleFormat, outputSampleRate, rfBandwidth, udpPort, boost); Message* cmd = MsgUDPSrcConfigure::create(sampleFormat, outputSampleRate, rfBandwidth, udpAddress, udpPort, boost);
messageQueue->push(cmd); messageQueue->push(cmd);
} }
@ -105,39 +106,43 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
m_spectrum->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), positiveOnly); m_spectrum->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), positiveOnly);
} }
for(int i = 0; i < m_s16leSockets.count(); i++) if (m_sampleFormat == FormatSSB)
{ {
m_s16leSockets[i].socket->write((const char*)&m_sampleBuffer[0], m_sampleBuffer.size() * 4); for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it)
} {
if((m_sampleFormat == FormatSSB) && (m_ssbSockets.count() > 0)) {
for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) {
//Complex cj(it->real() / 30000.0, it->imag() / 30000.0); //Complex cj(it->real() / 30000.0, it->imag() / 30000.0);
Complex cj(it->real(), it->imag()); Complex cj(it->real(), it->imag());
int n_out = UDPFilter->runSSB(cj, &sideband, true); int n_out = UDPFilter->runSSB(cj, &sideband, true);
if (n_out) {
for (int i = 0; i < n_out; i+=2) { if (n_out)
{
for (int i = 0; i < n_out; i+=2)
{
//l = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32000.0; //l = (sideband[i].real() + sideband[i].imag()) * 0.7 * 32000.0;
//r = (sideband[i+1].real() + sideband[i+1].imag()) * 0.7 * 32000.0; //r = (sideband[i+1].real() + sideband[i+1].imag()) * 0.7 * 32000.0;
l = (sideband[i].real() + sideband[i].imag()) * 0.7; l = (sideband[i].real() + sideband[i].imag()) * 0.7;
r = (sideband[i+1].real() + sideband[i+1].imag()) * 0.7; r = (sideband[i+1].real() + sideband[i+1].imag()) * 0.7;
m_sampleBufferSSB.push_back(Sample(l, r)); m_sampleBufferSSB.push_back(Sample(l, r));
} }
for(int i = 0; i < m_ssbSockets.count(); i++)
m_ssbSockets[i].socket->write((const char*)&m_sampleBufferSSB[0], n_out * 2); m_socket->writeDatagram((const char*)&m_sampleBufferSSB[0], (qint64 ) (n_out * 2), m_udpAddress, m_udpPort);
m_sampleBufferSSB.clear(); m_sampleBufferSSB.clear();
} }
} }
} }
else if (m_sampleFormat == FormatNFM)
if((m_sampleFormat == FormatNFM) && (m_ssbSockets.count() > 0)) { {
for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) { for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it)
{
Complex cj(it->real() / 32768.0f, it->imag() / 32768.0f); Complex cj(it->real() / 32768.0f, it->imag() / 32768.0f);
// An FFT filter here is overkill, but was already set up for SSB // An FFT filter here is overkill, but was already set up for SSB
int n_out = UDPFilter->runFilt(cj, &sideband); int n_out = UDPFilter->runFilt(cj, &sideband);
if (n_out) {
if (n_out)
{
Real sum = 1.0; Real sum = 1.0;
for (int i = 0; i < n_out; i+=2) { for (int i = 0; i < n_out; i+=2)
{
l = m_this.real() * (m_last.imag() - sideband[i].imag()) l = m_this.real() * (m_last.imag() - sideband[i].imag())
- m_this.imag() * (m_last.real() - sideband[i].real()); - m_this.imag() * (m_last.real() - sideband[i].real());
m_last = sideband[i]; m_last = sideband[i];
@ -149,32 +154,25 @@ void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector:
} }
// TODO: correct levels // TODO: correct levels
m_scale = 24000 * udpFftLen / sum; m_scale = 24000 * udpFftLen / sum;
for(int i = 0; i < m_ssbSockets.count(); i++) m_socket->writeDatagram((const char*)&m_sampleBufferSSB[0], (qint64 ) (n_out * 2), m_udpAddress, m_udpPort);
m_ssbSockets[i].socket->write((const char*)&m_sampleBufferSSB[0], n_out * 2);
m_sampleBufferSSB.clear(); m_sampleBufferSSB.clear();
} }
} }
} }
else
{
m_socket->writeDatagram((const char*)&m_sampleBuffer[0], (qint64 ) (m_sampleBuffer.size() * 4), m_udpAddress, m_udpPort);
}
m_settingsMutex.unlock(); m_settingsMutex.unlock();
} }
void UDPSrc::start() void UDPSrc::start()
{ {
m_udpServer = new QTcpServer();
connect(m_udpServer, SIGNAL(newConnection()), this, SLOT(onNewConnection()));
connect(m_udpServer, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(onUdpServerError(QAbstractSocket::SocketError)));
m_udpServer->listen(QHostAddress::Any, m_udpPort);
} }
void UDPSrc::stop() void UDPSrc::stop()
{ {
closeAllSockets(&m_ssbSockets);
closeAllSockets(&m_s16leSockets);
if(m_udpServer->isListening())
m_udpServer->close();
delete m_udpServer;
} }
bool UDPSrc::handleMessage(const Message& cmd) bool UDPSrc::handleMessage(const Message& cmd)
@ -209,16 +207,14 @@ bool UDPSrc::handleMessage(const Message& cmd)
m_outputSampleRate = cfg.getOutputSampleRate(); m_outputSampleRate = cfg.getOutputSampleRate();
m_rfBandwidth = cfg.getRFBandwidth(); m_rfBandwidth = cfg.getRFBandwidth();
if (cfg.getUDPAddress() != m_udpAddress.toString())
{
m_udpAddress.setAddress(cfg.getUDPAddress());
}
if (cfg.getUDPPort() != m_udpPort) if (cfg.getUDPPort() != m_udpPort)
{ {
m_udpPort = cfg.getUDPPort(); m_udpPort = cfg.getUDPPort();
if(m_udpServer->isListening())
{
m_udpServer->close();
}
m_udpServer->listen(QHostAddress::Any, m_udpPort);
} }
m_boost = cfg.getBoost(); m_boost = cfg.getBoost();
@ -239,7 +235,9 @@ bool UDPSrc::handleMessage(const Message& cmd)
qDebug() << " - MsgUDPSrcConfigure: m_sampleFormat: " << m_sampleFormat qDebug() << " - MsgUDPSrcConfigure: m_sampleFormat: " << m_sampleFormat
<< " m_outputSampleRate: " << m_outputSampleRate << " m_outputSampleRate: " << m_outputSampleRate
<< " m_rfBandwidth: " << m_rfBandwidth << " m_rfBandwidth: " << m_rfBandwidth
<< " m_boost: " << m_boost; << " m_boost: " << m_boost
<< " m_udpAddress: " << cfg.getUDPAddress()
<< " m_udpPort: " << m_udpPort;
return true; return true;
} }
@ -265,104 +263,3 @@ bool UDPSrc::handleMessage(const Message& cmd)
} }
} }
} }
void UDPSrc::closeAllSockets(Sockets* sockets)
{
for(int i = 0; i < sockets->count(); ++i)
{
MsgUDPSrcConnection* msg = MsgUDPSrcConnection::create(false, sockets->at(i).id, QHostAddress(), 0);
m_uiMessageQueue->push(msg);
sockets->at(i).socket->close();
}
}
void UDPSrc::onNewConnection()
{
qDebug("UDPSrc::onNewConnection");
while(m_udpServer->hasPendingConnections())
{
qDebug("UDPSrc::onNewConnection: has a pending connection");
QTcpSocket* connection = m_udpServer->nextPendingConnection();
connection->setSocketOption(QAbstractSocket:: KeepAliveOption, 1);
connect(connection, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
switch(m_sampleFormat) {
case FormatNFM:
case FormatSSB:
{
quint32 id = (FormatSSB << 24) | m_nextSSBId;
MsgUDPSrcConnection* msg = MsgUDPSrcConnection::create(true, id, connection->peerAddress(), connection->peerPort());
m_nextSSBId = (m_nextSSBId + 1) & 0xffffff;
m_ssbSockets.push_back(Socket(id, connection));
m_uiMessageQueue->push(msg);
break;
}
case FormatS16LE:
{
qDebug("UDPSrc::onNewConnection: establish new S16LE connection");
quint32 id = (FormatS16LE << 24) | m_nextS16leId;
MsgUDPSrcConnection* msg = MsgUDPSrcConnection::create(true, id, connection->peerAddress(), connection->peerPort());
m_nextS16leId = (m_nextS16leId + 1) & 0xffffff;
m_s16leSockets.push_back(Socket(id, connection));
m_uiMessageQueue->push(msg);
break;
}
default:
delete connection;
break;
}
}
}
void UDPSrc::onDisconnected()
{
quint32 id;
QTcpSocket* socket = 0;
qDebug("UDPSrc::onDisconnected");
for(int i = 0; i < m_ssbSockets.count(); i++)
{
if(m_ssbSockets[i].socket == sender())
{
id = m_ssbSockets[i].id;
socket = m_ssbSockets[i].socket;
socket->close();
m_ssbSockets.removeAt(i);
break;
}
}
if(socket == 0)
{
for(int i = 0; i < m_s16leSockets.count(); i++)
{
if(m_s16leSockets[i].socket == sender())
{
qDebug("UDPSrc::onDisconnected: remove S16LE socket #%d", i);
id = m_s16leSockets[i].id;
socket = m_s16leSockets[i].socket;
socket->close();
m_s16leSockets.removeAt(i);
break;
}
}
}
if(socket != 0)
{
MsgUDPSrcConnection* msg = MsgUDPSrcConnection::create(false, id, QHostAddress(), 0);
m_uiMessageQueue->push(msg);
socket->deleteLater();
}
}
void UDPSrc::onUdpServerError(QAbstractSocket::SocketError socketError)
{
qDebug("UDPSrc::onUdpServerError: %s", qPrintable(m_udpServer->errorString()));
}

View File

@ -11,8 +11,7 @@
#define udpFftLen 2048 #define udpFftLen 2048
class QTcpServer; class QUdpSocket;
class QTcpSocket;
class UDPSrcGUI; class UDPSrcGUI;
class UDPSrc : public SampleSink { class UDPSrc : public SampleSink {
@ -29,7 +28,7 @@ public:
UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* spectrum); UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* spectrum);
virtual ~UDPSrc(); virtual ~UDPSrc();
void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int udpPort, int boost); void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, QString& udpAddress, int udpPort, int boost);
void setSpectrum(MessageQueue* messageQueue, bool enabled); void setSpectrum(MessageQueue* messageQueue, bool enabled);
Real getMagSq() const { return m_magsq; } Real getMagSq() const { return m_magsq; }
@ -38,35 +37,6 @@ public:
virtual void stop(); virtual void stop();
virtual bool handleMessage(const Message& cmd); virtual bool handleMessage(const Message& cmd);
class MsgUDPSrcConnection : public Message {
MESSAGE_CLASS_DECLARATION
public:
bool getConnect() const { return m_connect; }
quint32 getID() const { return m_id; }
const QHostAddress& getPeerAddress() const { return m_peerAddress; }
int getPeerPort() const { return m_peerPort; }
static MsgUDPSrcConnection* create(bool connect, quint32 id, const QHostAddress& peerAddress, int peerPort)
{
return new MsgUDPSrcConnection(connect, id, peerAddress, peerPort);
}
private:
bool m_connect;
quint32 m_id;
QHostAddress m_peerAddress;
int m_peerPort;
MsgUDPSrcConnection(bool connect, quint32 id, const QHostAddress& peerAddress, int peerPort) :
Message(),
m_connect(connect),
m_id(id),
m_peerAddress(peerAddress),
m_peerPort(peerPort)
{ }
};
protected: protected:
class MsgUDPSrcConfigure : public Message { class MsgUDPSrcConfigure : public Message {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION
@ -75,26 +45,29 @@ protected:
SampleFormat getSampleFormat() const { return m_sampleFormat; } SampleFormat getSampleFormat() const { return m_sampleFormat; }
Real getOutputSampleRate() const { return m_outputSampleRate; } Real getOutputSampleRate() const { return m_outputSampleRate; }
Real getRFBandwidth() const { return m_rfBandwidth; } Real getRFBandwidth() const { return m_rfBandwidth; }
const QString& getUDPAddress() const { return m_udpAddress; }
int getUDPPort() const { return m_udpPort; } int getUDPPort() const { return m_udpPort; }
int getBoost() const { return m_boost; } int getBoost() const { return m_boost; }
static MsgUDPSrcConfigure* create(SampleFormat sampleFormat, Real sampleRate, Real rfBandwidth, int udpPort, int boost) static MsgUDPSrcConfigure* create(SampleFormat sampleFormat, Real sampleRate, Real rfBandwidth, QString& udpAddress, int udpPort, int boost)
{ {
return new MsgUDPSrcConfigure(sampleFormat, sampleRate, rfBandwidth, udpPort, boost); return new MsgUDPSrcConfigure(sampleFormat, sampleRate, rfBandwidth, udpAddress, udpPort, boost);
} }
private: private:
SampleFormat m_sampleFormat; SampleFormat m_sampleFormat;
Real m_outputSampleRate; Real m_outputSampleRate;
Real m_rfBandwidth; Real m_rfBandwidth;
QString m_udpAddress;
int m_udpPort; int m_udpPort;
int m_boost; int m_boost;
MsgUDPSrcConfigure(SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int udpPort, int boost) : MsgUDPSrcConfigure(SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, QString& udpAddress, int udpPort, int boost) :
Message(), Message(),
m_sampleFormat(sampleFormat), m_sampleFormat(sampleFormat),
m_outputSampleRate(outputSampleRate), m_outputSampleRate(outputSampleRate),
m_rfBandwidth(rfBandwidth), m_rfBandwidth(rfBandwidth),
m_udpAddress(udpAddress),
m_udpPort(udpPort), m_udpPort(udpPort),
m_boost(boost) m_boost(boost)
{ } { }
@ -121,13 +94,15 @@ protected:
MessageQueue* m_uiMessageQueue; MessageQueue* m_uiMessageQueue;
UDPSrcGUI* m_udpSrcGUI; UDPSrcGUI* m_udpSrcGUI;
QUdpSocket *m_socket;
int m_inputSampleRate; int m_inputSampleRate;
int m_sampleFormat; int m_sampleFormat;
Real m_outputSampleRate; Real m_outputSampleRate;
Real m_rfBandwidth; Real m_rfBandwidth;
int m_udpPort; QHostAddress m_udpAddress;
quint16 m_udpPort;
int m_boost; int m_boost;
Real m_magsq; Real m_magsq;
@ -144,29 +119,10 @@ protected:
SampleSink* m_spectrum; SampleSink* m_spectrum;
bool m_spectrumEnabled; bool m_spectrumEnabled;
QTcpServer* m_udpServer;
struct Socket {
quint32 id;
QTcpSocket* socket;
Socket(quint32 _id, QTcpSocket* _socket) :
id(_id),
socket(_socket)
{ }
};
typedef QList<Socket> Sockets;
Sockets m_ssbSockets;
Sockets m_s16leSockets;
quint32 m_nextSSBId; quint32 m_nextSSBId;
quint32 m_nextS16leId; quint32 m_nextS16leId;
QMutex m_settingsMutex; QMutex m_settingsMutex;
void closeAllSockets(Sockets* sockets);
protected slots:
void onNewConnection();
void onDisconnected();
void onUdpServerError(QAbstractSocket::SocketError socketError);
}; };
#endif // INCLUDE_UDPSRC_H #endif // INCLUDE_UDPSRC_H

View File

@ -51,6 +51,7 @@ void UDPSrcGUI::resetToDefaults()
ui->sampleFormat->setCurrentIndex(0); ui->sampleFormat->setCurrentIndex(0);
ui->sampleRate->setText("48000"); ui->sampleRate->setText("48000");
ui->rfBandwidth->setText("32000"); ui->rfBandwidth->setText("32000");
ui->udpAddress->setText("127.0.0.1");
ui->udpPort->setText("9999"); ui->udpPort->setText("9999");
ui->spectrumGUI->resetToDefaults(); ui->spectrumGUI->resetToDefaults();
ui->boost->setValue(1); ui->boost->setValue(1);
@ -71,6 +72,7 @@ QByteArray UDPSrcGUI::serialize() const
s.writeBlob(7, ui->spectrumGUI->serialize()); s.writeBlob(7, ui->spectrumGUI->serialize());
s.writeS32(8, (qint32)m_boost); s.writeS32(8, (qint32)m_boost);
s.writeS32(9, m_channelMarker.getCenterFrequency()); s.writeS32(9, m_channelMarker.getCenterFrequency());
s.writeString(10, m_udpAddress);
return s.final(); return s.final();
} }
@ -87,6 +89,7 @@ bool UDPSrcGUI::deserialize(const QByteArray& data)
if (d.getVersion() == 1) if (d.getVersion() == 1)
{ {
QByteArray bytetmp; QByteArray bytetmp;
QString strtmp;
qint32 s32tmp; qint32 s32tmp;
Real realtmp; Real realtmp;
@ -124,6 +127,8 @@ bool UDPSrcGUI::deserialize(const QByteArray& data)
ui->boost->setValue(s32tmp); ui->boost->setValue(s32tmp);
d.readS32(9, &s32tmp, 0); d.readS32(9, &s32tmp, 0);
m_channelMarker.setCenterFrequency(s32tmp); m_channelMarker.setCenterFrequency(s32tmp);
d.readString(10, &strtmp, "127.0.0.1");
ui->udpAddress->setText(strtmp);
blockApplySettings(false); blockApplySettings(false);
m_channelMarker.blockSignals(false); m_channelMarker.blockSignals(false);
@ -141,31 +146,7 @@ bool UDPSrcGUI::deserialize(const QByteArray& data)
bool UDPSrcGUI::handleMessage(const Message& message) bool UDPSrcGUI::handleMessage(const Message& message)
{ {
qDebug() << "UDPSrcGUI::handleMessage"; qDebug() << "UDPSrcGUI::handleMessage";
return false;
if (UDPSrc::MsgUDPSrcConnection::match(message))
{
UDPSrc::MsgUDPSrcConnection& con = (UDPSrc::MsgUDPSrcConnection&) message;
if(con.getConnect())
{
addConnection(con.getID(), con.getPeerAddress(), con.getPeerPort());
}
else
{
delConnection(con.getID());
}
qDebug() << "UDPSrcGUI::handleMessage: UDPSrc::MsgUDPSrcConnection: " << con.getConnect()
<< " ID: " << con.getID()
<< " peerAddress: " << con.getPeerAddress()
<< " peerPort: " << con.getPeerPort();
return true;
}
else
{
return false;
}
} }
void UDPSrcGUI::channelMarkerChanged() void UDPSrcGUI::channelMarkerChanged()
@ -264,6 +245,7 @@ void UDPSrcGUI::applySettings()
rfBandwidth = outputSampleRate; rfBandwidth = outputSampleRate;
} }
m_udpAddress = ui->udpAddress->text();
int udpPort = ui->udpPort->text().toInt(&ok); int udpPort = ui->udpPort->text().toInt(&ok);
if((!ok) || (udpPort < 1) || (udpPort > 65535)) if((!ok) || (udpPort < 1) || (udpPort > 65535))
@ -278,6 +260,7 @@ void UDPSrcGUI::applySettings()
ui->deltaMinus->setChecked(m_channelMarker.getCenterFrequency() < 0); ui->deltaMinus->setChecked(m_channelMarker.getCenterFrequency() < 0);
ui->sampleRate->setText(QString("%1").arg(outputSampleRate, 0)); ui->sampleRate->setText(QString("%1").arg(outputSampleRate, 0));
ui->rfBandwidth->setText(QString("%1").arg(rfBandwidth, 0)); ui->rfBandwidth->setText(QString("%1").arg(rfBandwidth, 0));
//ui->udpAddress->setText(m_udpAddress);
ui->udpPort->setText(QString("%1").arg(udpPort)); ui->udpPort->setText(QString("%1").arg(udpPort));
ui->boost->setValue(boost); ui->boost->setValue(boost);
m_channelMarker.disconnect(this, SLOT(channelMarkerChanged())); m_channelMarker.disconnect(this, SLOT(channelMarkerChanged()));
@ -317,6 +300,7 @@ void UDPSrcGUI::applySettings()
sampleFormat, sampleFormat,
outputSampleRate, outputSampleRate,
rfBandwidth, rfBandwidth,
m_udpAddress,
udpPort, udpPort,
boost); boost);
@ -393,24 +377,3 @@ void UDPSrcGUI::onMenuDoubleClicked()
bcsw->show(); bcsw->show();
} }
} }
void UDPSrcGUI::addConnection(quint32 id, const QHostAddress& peerAddress, int peerPort)
{
QStringList l;
l.append(QString("%1:%2").arg(peerAddress.toString()).arg(peerPort));
new QTreeWidgetItem(ui->connections, l, id);
ui->connectedClientsBox->setWindowTitle(tr("Connected Clients (%1)").arg(ui->connections->topLevelItemCount()));
}
void UDPSrcGUI::delConnection(quint32 id)
{
for(int i = 0; i < ui->connections->topLevelItemCount(); i++)
{
if(ui->connections->topLevelItem(i)->type() == (int)id)
{
delete ui->connections->topLevelItem(i);
ui->connectedClientsBox->setWindowTitle(tr("Connected Clients (%1)").arg(ui->connections->topLevelItemCount()));
return;
}
}
}

View File

@ -44,6 +44,7 @@ private slots:
void on_sampleFormat_currentIndexChanged(int index); void on_sampleFormat_currentIndexChanged(int index);
void on_sampleRate_textEdited(const QString& arg1); void on_sampleRate_textEdited(const QString& arg1);
void on_rfBandwidth_textEdited(const QString& arg1); void on_rfBandwidth_textEdited(const QString& arg1);
void on_udpAddress_textEdited(const QString& arg1);
void on_udpPort_textEdited(const QString& arg1); void on_udpPort_textEdited(const QString& arg1);
void on_applyBtn_clicked(); void on_applyBtn_clicked();
void onWidgetRolled(QWidget* widget, bool rollDown); void onWidgetRolled(QWidget* widget, bool rollDown);
@ -63,6 +64,7 @@ private:
Real m_outputSampleRate; Real m_outputSampleRate;
Real m_rfBandwidth; Real m_rfBandwidth;
int m_boost; int m_boost;
QString m_udpAddress;
int m_udpPort; int m_udpPort;
bool m_basicSettingsShown; bool m_basicSettingsShown;
bool m_doApplySettings; bool m_doApplySettings;
@ -77,9 +79,6 @@ private:
void blockApplySettings(bool block); void blockApplySettings(bool block);
void applySettings(); void applySettings();
void addConnection(quint32 id, const QHostAddress& peerAddress, int peerPort);
void delConnection(quint32 id);
}; };
#endif // INCLUDE_UDPSRCGUI_H #endif // INCLUDE_UDPSRCGUI_H

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>294</width>
<height>443</height> <height>434</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -18,7 +18,7 @@
<rect> <rect>
<x>10</x> <x>10</x>
<y>5</y> <y>5</y>
<width>201</width> <width>241</width>
<height>142</height> <height>142</height>
</rect> </rect>
</property> </property>
@ -44,83 +44,84 @@
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Sample Format</string> <string>Format</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item row="0" column="1">
<widget class="QComboBox" name="sampleFormat"> <layout class="QHBoxLayout" name="ChannelPowerLayout">
<property name="currentIndex">
<number>2</number>
</property>
<item> <item>
<property name="text"> <spacer name="horizontalSpacer">
<string>S16LE SSB</string> <property name="orientation">
</property> <enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item> </item>
<item> <item>
<property name="text"> <widget class="QLabel" name="channelPower">
<string>S16LE NFM</string> <property name="toolTip">
</property> <string>Channel power</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>0.0</string>
</property>
</widget>
</item> </item>
<item> <item>
<property name="text"> <widget class="QLabel" name="channelPowerUnits">
<string>S16LE I/Q</string> <property name="text">
</property> <string> dB</string>
</property>
</widget>
</item> </item>
</widget> </layout>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="rfBandwidth">
<property name="text">
<string>32000</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>RF Bandwidth (Hz)</string>
</property>
</widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
<string>Samplerate (Hz)</string> <string>Rate (Hz)</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="7" column="1">
<widget class="QLabel" name="label_4"> <layout class="QHBoxLayout" name="BoostLayout">
<property name="text"> <item>
<string>UDP Port</string> <widget class="QLabel" name="boostLabel">
</property> <property name="text">
</widget> <string>Boost</string>
</item> </property>
<item row="2" column="1"> </widget>
<widget class="QLineEdit" name="sampleRate"> </item>
<property name="text"> <item>
<string>48000</string> <widget class="QSlider" name="boost">
</property> <property name="maximum">
</widget> <number>3</number>
</item> </property>
<item row="4" column="0"> <property name="pageStep">
<widget class="QLineEdit" name="udpPort"> <number>1</number>
<property name="text"> </property>
<string>9999</string> <property name="orientation">
</property> <enum>Qt::Horizontal</enum>
</widget> </property>
</item> </widget>
<item row="5" column="0"> </item>
<widget class="QPushButton" name="applyBtn"> <item>
<property name="enabled"> <widget class="QLabel" name="boostText">
<bool>false</bool> <property name="text">
</property> <string>0</string>
<property name="text"> </property>
<string>Apply</string> </widget>
</property> </item>
</widget> </layout>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<layout class="QHBoxLayout" name="DeltaFrequencyLayout"> <layout class="QHBoxLayout" name="DeltaFrequencyLayout">
@ -252,69 +253,90 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="0" column="1"> <item row="5" column="0">
<layout class="QHBoxLayout" name="ChannelPowerLayout"> <layout class="QHBoxLayout" name="PortLayout">
<item> <item>
<spacer name="horizontalSpacer"> <widget class="QLabel" name="udpPortlabel">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="channelPower">
<property name="toolTip">
<string>Channel power</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text"> <property name="text">
<string>0.0</string> <string>Port</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="channelPowerUnits"> <widget class="QLineEdit" name="udpPort">
<property name="text"> <property name="text">
<string> dB</string> <string>9999</string>
</property> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</item> </item>
<item row="5" column="1"> <item row="5" column="1">
<layout class="QHBoxLayout" name="BoostLayout"> <widget class="QLineEdit" name="rfBandwidth">
<property name="text">
<string>32000</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QPushButton" name="applyBtn">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>RF BW (Hz)</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="sampleRate">
<property name="text">
<string>48000</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QComboBox" name="sampleFormat">
<property name="currentIndex">
<number>2</number>
</property>
<item> <item>
<widget class="QLabel" name="boostLabel"> <property name="text">
<string>S16LE SSB</string>
</property>
</item>
<item>
<property name="text">
<string>S16LE NFM</string>
</property>
</item>
<item>
<property name="text">
<string>S16LE I/Q</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="AddressLayout">
<item>
<widget class="QLabel" name="Addresslabel">
<property name="text"> <property name="text">
<string>Boost</string> <string>Addr</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QSlider" name="boost"> <widget class="QLineEdit" name="udpAddress">
<property name="maximum">
<number>3</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="boostText">
<property name="text"> <property name="text">
<string>0</string> <string>127.0.0.1</string>
</property> </property>
</widget> </widget>
</item> </item>