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

TCP source: removed references to GUI and main window in sources and restore TCP socket processing

This commit is contained in:
f4exb 2017-10-07 11:07:46 +02:00
parent 875593af15
commit 6e7deef7e0
3 changed files with 65 additions and 46 deletions

View File

@ -26,7 +26,7 @@ MESSAGE_CLASS_DEFINITION(TCPSrc::MsgConfigureChannelizer, Message)
MESSAGE_CLASS_DEFINITION(TCPSrc::MsgTCPSrcConnection, Message)
MESSAGE_CLASS_DEFINITION(TCPSrc::MsgTCPSrcSpectrum, Message)
TCPSrc::TCPSrc(MessageQueue* uiMessageQueue, BasebandSampleSink* spectrum) :
TCPSrc::TCPSrc(BasebandSampleSink* spectrum) :
m_settingsMutex(QMutex::Recursive)
{
setObjectName("TCPSrc");
@ -40,7 +40,6 @@ TCPSrc::TCPSrc(MessageQueue* uiMessageQueue, BasebandSampleSink* spectrum) :
m_nco.setFreq(0, m_inputSampleRate);
m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.0);
m_sampleDistanceRemain = m_inputSampleRate / m_outputSampleRate;
m_uiMessageQueue = uiMessageQueue;
m_spectrum = spectrum;
m_spectrumEnabled = false;
m_nextSSBId = 0;
@ -289,12 +288,16 @@ void TCPSrc::closeAllSockets(Sockets* sockets)
for(int i = 0; i < sockets->count(); ++i)
{
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();
}
}
void TCPSrc::onNewConnection()
{
qDebug("TCPSrc::onNewConnection");
@ -318,10 +321,15 @@ void TCPSrc::processNewConnection()
case TCPSrcSettings::FormatSSB:
{
quint32 id = (TCPSrcSettings::FormatSSB << 24) | m_nextSSBId;
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(true, id, connection->peerAddress(), connection->peerPort());
m_nextSSBId = (m_nextSSBId + 1) & 0xffffff;
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;
}
@ -329,10 +337,15 @@ void TCPSrc::processNewConnection()
{
qDebug("TCPSrc::processNewConnection: establish new S16LE connection");
quint32 id = (TCPSrcSettings::FormatS16LE << 24) | m_nextS16leId;
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(true, id, connection->peerAddress(), connection->peerPort());
m_nextS16leId = (m_nextS16leId + 1) & 0xffffff;
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;
}
@ -348,6 +361,11 @@ void TCPSrc::onDisconnected()
qDebug("TCPSrc::onDisconnected");
MsgTCPSrcConnection *cmd = MsgTCPSrcConnection::create(false, 0, QHostAddress::Any, 0);
getInputMessageQueue()->push(cmd);
if (getMessageQueueToGUI()) { // Propagate to GUI
getMessageQueueToGUI()->push(cmd);
}
}
void TCPSrc::processDeconnection()
@ -389,7 +407,12 @@ void TCPSrc::processDeconnection()
if(socket != 0)
{
MsgTCPSrcConnection* msg = MsgTCPSrcConnection::create(false, id, QHostAddress(), 0);
m_uiMessageQueue->push(msg);
getInputMessageQueue()->push(msg);
if (getMessageQueueToGUI()) { // Propagate to GUI
getMessageQueueToGUI()->push(msg);
}
socket->deleteLater();
}
}

View File

@ -69,17 +69,6 @@ public:
{ }
};
TCPSrc(MessageQueue* uiMessageQueue, BasebandSampleSink* spectrum);
virtual ~TCPSrc();
void setSpectrum(MessageQueue* messageQueue, bool enabled);
double getMagSq() const { return m_magsq; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
virtual void stop();
virtual bool handleMessage(const Message& cmd);
class MsgTCPSrcConnection : public Message {
MESSAGE_CLASS_DECLARATION
@ -109,6 +98,17 @@ public:
{ }
};
TCPSrc(BasebandSampleSink* spectrum);
virtual ~TCPSrc();
void setSpectrum(MessageQueue* messageQueue, bool enabled);
double getMagSq() const { return m_magsq; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly);
virtual void start();
virtual void stop();
virtual bool handleMessage(const Message& cmd);
protected:
class MsgTCPSrcSpectrum : public Message {
MESSAGE_CLASS_DECLARATION
@ -149,8 +149,6 @@ protected:
{ }
};
MessageQueue* m_uiMessageQueue;
TCPSrcSettings m_settings;
int m_inputSampleRate;

View File

@ -85,8 +85,6 @@ bool TCPSrcGUI::deserialize(const QByteArray& data)
bool TCPSrcGUI::handleMessage(const Message& message)
{
qDebug() << "TCPSrcGUI::handleMessage";
if (TCPSrc::MsgTCPSrcConnection::match(message))
{
TCPSrc::MsgTCPSrcConnection& con = (TCPSrc::MsgTCPSrcConnection&) message;
@ -144,7 +142,7 @@ TCPSrcGUI::TCPSrcGUI(PluginAPI* pluginAPI, DeviceSourceAPI *deviceAPI, QWidget*
setAttribute(Qt::WA_DeleteOnClose, true);
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_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
m_deviceAPI->addThreadedSink(m_threadedChannelizer);