mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 17:58:43 -05:00
TCP source: removed references to GUI and main window in sources and restore TCP socket processing
This commit is contained in:
parent
875593af15
commit
6e7deef7e0
@ -26,7 +26,7 @@ MESSAGE_CLASS_DEFINITION(TCPSrc::MsgConfigureChannelizer, Message)
|
|||||||
MESSAGE_CLASS_DEFINITION(TCPSrc::MsgTCPSrcConnection, Message)
|
MESSAGE_CLASS_DEFINITION(TCPSrc::MsgTCPSrcConnection, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(TCPSrc::MsgTCPSrcSpectrum, Message)
|
MESSAGE_CLASS_DEFINITION(TCPSrc::MsgTCPSrcSpectrum, Message)
|
||||||
|
|
||||||
TCPSrc::TCPSrc(MessageQueue* uiMessageQueue, BasebandSampleSink* spectrum) :
|
TCPSrc::TCPSrc(BasebandSampleSink* spectrum) :
|
||||||
m_settingsMutex(QMutex::Recursive)
|
m_settingsMutex(QMutex::Recursive)
|
||||||
{
|
{
|
||||||
setObjectName("TCPSrc");
|
setObjectName("TCPSrc");
|
||||||
@ -40,7 +40,6 @@ TCPSrc::TCPSrc(MessageQueue* uiMessageQueue, BasebandSampleSink* spectrum) :
|
|||||||
m_nco.setFreq(0, m_inputSampleRate);
|
m_nco.setFreq(0, m_inputSampleRate);
|
||||||
m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.0);
|
m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.0);
|
||||||
m_sampleDistanceRemain = m_inputSampleRate / m_outputSampleRate;
|
m_sampleDistanceRemain = m_inputSampleRate / m_outputSampleRate;
|
||||||
m_uiMessageQueue = uiMessageQueue;
|
|
||||||
m_spectrum = spectrum;
|
m_spectrum = spectrum;
|
||||||
m_spectrumEnabled = false;
|
m_spectrumEnabled = false;
|
||||||
m_nextSSBId = 0;
|
m_nextSSBId = 0;
|
||||||
@ -289,12 +288,16 @@ void TCPSrc::closeAllSockets(Sockets* sockets)
|
|||||||
for(int i = 0; i < sockets->count(); ++i)
|
for(int i = 0; i < sockets->count(); ++i)
|
||||||
{
|
{
|
||||||
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(false, sockets->at(i).id, QHostAddress(), 0);
|
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(false, sockets->at(i).id, QHostAddress(), 0);
|
||||||
m_uiMessageQueue->push(msg);
|
getInputMessageQueue()->push(msg);
|
||||||
|
|
||||||
|
if (getMessageQueueToGUI()) { // Propagate to GUI
|
||||||
|
getMessageQueueToGUI()->push(msg);
|
||||||
|
}
|
||||||
|
|
||||||
sockets->at(i).socket->close();
|
sockets->at(i).socket->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TCPSrc::onNewConnection()
|
void TCPSrc::onNewConnection()
|
||||||
{
|
{
|
||||||
qDebug("TCPSrc::onNewConnection");
|
qDebug("TCPSrc::onNewConnection");
|
||||||
@ -318,10 +321,15 @@ void TCPSrc::processNewConnection()
|
|||||||
case TCPSrcSettings::FormatSSB:
|
case TCPSrcSettings::FormatSSB:
|
||||||
{
|
{
|
||||||
quint32 id = (TCPSrcSettings::FormatSSB << 24) | m_nextSSBId;
|
quint32 id = (TCPSrcSettings::FormatSSB << 24) | m_nextSSBId;
|
||||||
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(true, id, connection->peerAddress(), connection->peerPort());
|
|
||||||
m_nextSSBId = (m_nextSSBId + 1) & 0xffffff;
|
m_nextSSBId = (m_nextSSBId + 1) & 0xffffff;
|
||||||
m_ssbSockets.push_back(Socket(id, connection));
|
m_ssbSockets.push_back(Socket(id, connection));
|
||||||
m_uiMessageQueue->push(msg);
|
|
||||||
|
if (getMessageQueueToGUI()) // Notify GUI of peer details
|
||||||
|
{
|
||||||
|
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(true, id, connection->peerAddress(), connection->peerPort());
|
||||||
|
getMessageQueueToGUI()->push(msg);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,10 +337,15 @@ void TCPSrc::processNewConnection()
|
|||||||
{
|
{
|
||||||
qDebug("TCPSrc::processNewConnection: establish new S16LE connection");
|
qDebug("TCPSrc::processNewConnection: establish new S16LE connection");
|
||||||
quint32 id = (TCPSrcSettings::FormatS16LE << 24) | m_nextS16leId;
|
quint32 id = (TCPSrcSettings::FormatS16LE << 24) | m_nextS16leId;
|
||||||
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(true, id, connection->peerAddress(), connection->peerPort());
|
|
||||||
m_nextS16leId = (m_nextS16leId + 1) & 0xffffff;
|
m_nextS16leId = (m_nextS16leId + 1) & 0xffffff;
|
||||||
m_s16leSockets.push_back(Socket(id, connection));
|
m_s16leSockets.push_back(Socket(id, connection));
|
||||||
m_uiMessageQueue->push(msg);
|
|
||||||
|
if (getMessageQueueToGUI()) // Notify GUI of peer details
|
||||||
|
{
|
||||||
|
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(true, id, connection->peerAddress(), connection->peerPort());
|
||||||
|
getMessageQueueToGUI()->push(msg);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,6 +361,11 @@ void TCPSrc::onDisconnected()
|
|||||||
qDebug("TCPSrc::onDisconnected");
|
qDebug("TCPSrc::onDisconnected");
|
||||||
MsgTCPSrcConnection *cmd = MsgTCPSrcConnection::create(false, 0, QHostAddress::Any, 0);
|
MsgTCPSrcConnection *cmd = MsgTCPSrcConnection::create(false, 0, QHostAddress::Any, 0);
|
||||||
getInputMessageQueue()->push(cmd);
|
getInputMessageQueue()->push(cmd);
|
||||||
|
|
||||||
|
if (getMessageQueueToGUI()) { // Propagate to GUI
|
||||||
|
getMessageQueueToGUI()->push(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TCPSrc::processDeconnection()
|
void TCPSrc::processDeconnection()
|
||||||
@ -388,9 +406,14 @@ void TCPSrc::processDeconnection()
|
|||||||
|
|
||||||
if(socket != 0)
|
if(socket != 0)
|
||||||
{
|
{
|
||||||
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(false, id, QHostAddress(), 0);
|
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(false, id, QHostAddress(), 0);
|
||||||
m_uiMessageQueue->push(msg);
|
getInputMessageQueue()->push(msg);
|
||||||
socket->deleteLater();
|
|
||||||
|
if (getMessageQueueToGUI()) { // Propagate to GUI
|
||||||
|
getMessageQueueToGUI()->push(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
socket->deleteLater();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,36 @@ public:
|
|||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
TCPSrc(MessageQueue* uiMessageQueue, BasebandSampleSink* spectrum);
|
class MsgTCPSrcConnection : 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 MsgTCPSrcConnection* create(bool connect, quint32 id, const QHostAddress& peerAddress, int peerPort)
|
||||||
|
{
|
||||||
|
return new MsgTCPSrcConnection(connect, id, peerAddress, peerPort);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_connect;
|
||||||
|
quint32 m_id;
|
||||||
|
QHostAddress m_peerAddress;
|
||||||
|
int m_peerPort;
|
||||||
|
|
||||||
|
MsgTCPSrcConnection(bool connect, quint32 id, const QHostAddress& peerAddress, int peerPort) :
|
||||||
|
Message(),
|
||||||
|
m_connect(connect),
|
||||||
|
m_id(id),
|
||||||
|
m_peerAddress(peerAddress),
|
||||||
|
m_peerPort(peerPort)
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
|
TCPSrc(BasebandSampleSink* spectrum);
|
||||||
virtual ~TCPSrc();
|
virtual ~TCPSrc();
|
||||||
|
|
||||||
void setSpectrum(MessageQueue* messageQueue, bool enabled);
|
void setSpectrum(MessageQueue* messageQueue, bool enabled);
|
||||||
@ -80,35 +109,6 @@ public:
|
|||||||
virtual void stop();
|
virtual void stop();
|
||||||
virtual bool handleMessage(const Message& cmd);
|
virtual bool handleMessage(const Message& cmd);
|
||||||
|
|
||||||
class MsgTCPSrcConnection : 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 MsgTCPSrcConnection* create(bool connect, quint32 id, const QHostAddress& peerAddress, int peerPort)
|
|
||||||
{
|
|
||||||
return new MsgTCPSrcConnection(connect, id, peerAddress, peerPort);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_connect;
|
|
||||||
quint32 m_id;
|
|
||||||
QHostAddress m_peerAddress;
|
|
||||||
int m_peerPort;
|
|
||||||
|
|
||||||
MsgTCPSrcConnection(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 MsgTCPSrcSpectrum : public Message {
|
class MsgTCPSrcSpectrum : public Message {
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
@ -149,8 +149,6 @@ protected:
|
|||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
MessageQueue* m_uiMessageQueue;
|
|
||||||
|
|
||||||
TCPSrcSettings m_settings;
|
TCPSrcSettings m_settings;
|
||||||
|
|
||||||
int m_inputSampleRate;
|
int m_inputSampleRate;
|
||||||
|
@ -85,8 +85,6 @@ bool TCPSrcGUI::deserialize(const QByteArray& data)
|
|||||||
|
|
||||||
bool TCPSrcGUI::handleMessage(const Message& message)
|
bool TCPSrcGUI::handleMessage(const Message& message)
|
||||||
{
|
{
|
||||||
qDebug() << "TCPSrcGUI::handleMessage";
|
|
||||||
|
|
||||||
if (TCPSrc::MsgTCPSrcConnection::match(message))
|
if (TCPSrc::MsgTCPSrcConnection::match(message))
|
||||||
{
|
{
|
||||||
TCPSrc::MsgTCPSrcConnection& con = (TCPSrc::MsgTCPSrcConnection&) message;
|
TCPSrc::MsgTCPSrcConnection& con = (TCPSrc::MsgTCPSrcConnection&) message;
|
||||||
@ -144,7 +142,7 @@ TCPSrcGUI::TCPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget*
|
|||||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
|
||||||
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
|
m_spectrumVis = new SpectrumVis(ui->glSpectrum);
|
||||||
m_tcpSrc = new TCPSrc(m_pluginAPI->getMainWindowMessageQueue(), m_spectrumVis);
|
m_tcpSrc = new TCPSrc(m_spectrumVis);
|
||||||
m_channelizer = new DownChannelizer(m_tcpSrc);
|
m_channelizer = new DownChannelizer(m_tcpSrc);
|
||||||
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
||||||
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
|
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
|
||||||
|
Loading…
Reference in New Issue
Block a user