mirror of
				https://github.com/f4exb/sdrangel.git
				synced 2025-11-04 05:30:32 -05:00 
			
		
		
		
	New UDP source channel plugin. For now a copy of TCP source plugin
This commit is contained in:
		
							parent
							
								
									f981773f81
								
							
						
					
					
						commit
						34e6c93a89
					
				@ -5,6 +5,7 @@ add_subdirectory(am)
 | 
				
			|||||||
add_subdirectory(nfm)
 | 
					add_subdirectory(nfm)
 | 
				
			||||||
add_subdirectory(ssb)
 | 
					add_subdirectory(ssb)
 | 
				
			||||||
add_subdirectory(tcpsrc)
 | 
					add_subdirectory(tcpsrc)
 | 
				
			||||||
 | 
					add_subdirectory(udpsrc)
 | 
				
			||||||
add_subdirectory(wfm)
 | 
					add_subdirectory(wfm)
 | 
				
			||||||
add_subdirectory(chanalyzer)
 | 
					add_subdirectory(chanalyzer)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										47
									
								
								plugins/channel/udpsrc/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								plugins/channel/udpsrc/CMakeLists.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,47 @@
 | 
				
			|||||||
 | 
					project(udpsrc)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set(udpsrc_SOURCES
 | 
				
			||||||
 | 
						udpsrc.cpp
 | 
				
			||||||
 | 
						udpsrcgui.cpp
 | 
				
			||||||
 | 
						udpsrcplugin.cpp
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set(udpsrc_HEADERS
 | 
				
			||||||
 | 
						udpsrc.h
 | 
				
			||||||
 | 
						udpsrcgui.h
 | 
				
			||||||
 | 
						udpsrcplugin.h
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set(udpsrc_FORMS
 | 
				
			||||||
 | 
						udpsrcgui.ui
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					include_directories(
 | 
				
			||||||
 | 
						.
 | 
				
			||||||
 | 
						${CMAKE_CURRENT_BINARY_DIR}
 | 
				
			||||||
 | 
						${CMAKE_SOURCE_DIR}/include
 | 
				
			||||||
 | 
						${CMAKE_SOURCE_DIR}/include-gpl
 | 
				
			||||||
 | 
						${OPENGL_INCLUDE_DIR}
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include(${QT_USE_FILE})
 | 
				
			||||||
 | 
					add_definitions(${QT_DEFINITIONS})
 | 
				
			||||||
 | 
					add_definitions(-DQT_PLUGIN)
 | 
				
			||||||
 | 
					add_definitions(-DQT_SHARED)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#qt5_wrap_cpp(udpsrc_HEADERS_MOC ${udpsrc_HEADERS})
 | 
				
			||||||
 | 
					qt5_wrap_ui(udpsrc_FORMS_HEADERS ${udpsrc_FORMS})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					add_library(demodudpsrc SHARED
 | 
				
			||||||
 | 
						${udpsrc_SOURCES}
 | 
				
			||||||
 | 
						${udpsrc_HEADERS_MOC}
 | 
				
			||||||
 | 
						${udpsrc_FORMS_HEADERS}
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					target_link_libraries(demodudpsrc
 | 
				
			||||||
 | 
						${QT_LIBRARIES}
 | 
				
			||||||
 | 
						${OPENGL_LIBRARIES}
 | 
				
			||||||
 | 
						sdrbase
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					qt5_use_modules(demodudpsrc Core Widgets OpenGL Network)
 | 
				
			||||||
							
								
								
									
										368
									
								
								plugins/channel/udpsrc/udpsrc.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										368
									
								
								plugins/channel/udpsrc/udpsrc.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,368 @@
 | 
				
			|||||||
 | 
					// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
 | 
				
			||||||
 | 
					// (C) 2015 John Greb                                                            //
 | 
				
			||||||
 | 
					//                                                                               //
 | 
				
			||||||
 | 
					// This program is free software; you can redistribute it and/or modify          //
 | 
				
			||||||
 | 
					// it under the terms of the GNU General Public License as published by          //
 | 
				
			||||||
 | 
					// the Free Software Foundation as version 3 of the License, or                  //
 | 
				
			||||||
 | 
					//                                                                               //
 | 
				
			||||||
 | 
					// This program is distributed in the hope that it will be useful,               //
 | 
				
			||||||
 | 
					// but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | 
				
			||||||
 | 
					// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | 
				
			||||||
 | 
					// GNU General Public License V3 for more details.                               //
 | 
				
			||||||
 | 
					//                                                                               //
 | 
				
			||||||
 | 
					// You should have received a copy of the GNU General Public License             //
 | 
				
			||||||
 | 
					// along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | 
				
			||||||
 | 
					///////////////////////////////////////////////////////////////////////////////////
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "udpsrc.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QTcpServer>
 | 
				
			||||||
 | 
					#include <QTcpSocket>
 | 
				
			||||||
 | 
					#include <QThread>
 | 
				
			||||||
 | 
					#include "dsp/channelizer.h"
 | 
				
			||||||
 | 
					#include "udpsrcgui.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcConfigure, Message)
 | 
				
			||||||
 | 
					MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcConnection, Message)
 | 
				
			||||||
 | 
					MESSAGE_CLASS_DEFINITION(UDPSrc::MsgUDPSrcSpectrum, Message)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					UDPSrc::UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* tcpSrcGUI, SampleSink* spectrum) :
 | 
				
			||||||
 | 
						m_settingsMutex(QMutex::Recursive)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						setObjectName("TCPSrc");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						m_inputSampleRate = 96000;
 | 
				
			||||||
 | 
						m_sampleFormat = FormatSSB;
 | 
				
			||||||
 | 
						m_outputSampleRate = 48000;
 | 
				
			||||||
 | 
						m_rfBandwidth = 32000;
 | 
				
			||||||
 | 
						m_tcpPort = 9999;
 | 
				
			||||||
 | 
						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_tcpSrcGUI = tcpSrcGUI;
 | 
				
			||||||
 | 
						m_spectrum = spectrum;
 | 
				
			||||||
 | 
						m_spectrumEnabled = false;
 | 
				
			||||||
 | 
						m_nextSSBId = 0;
 | 
				
			||||||
 | 
						m_nextS16leId = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						m_last = 0;
 | 
				
			||||||
 | 
						m_this = 0;
 | 
				
			||||||
 | 
						m_scale = 0;
 | 
				
			||||||
 | 
						m_boost = 0;
 | 
				
			||||||
 | 
						m_magsq = 0;
 | 
				
			||||||
 | 
						m_sampleBufferSSB.resize(tcpFftLen);
 | 
				
			||||||
 | 
						TCPFilter = new fftfilt(0.3 / 48.0, 16.0 / 48.0, tcpFftLen);
 | 
				
			||||||
 | 
						// if (!TCPFilter) segfault;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					UDPSrc::~UDPSrc()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (TCPFilter) delete TCPFilter;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrc::configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort, int boost)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						Message* cmd = MsgUDPSrcConfigure::create(sampleFormat, outputSampleRate, rfBandwidth, tcpPort, boost);
 | 
				
			||||||
 | 
						messageQueue->push(cmd);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrc::setSpectrum(MessageQueue* messageQueue, bool enabled)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						Message* cmd = MsgUDPSrcSpectrum::create(enabled);
 | 
				
			||||||
 | 
						messageQueue->push(cmd);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrc::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool positiveOnly)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						Complex ci;
 | 
				
			||||||
 | 
						fftfilt::cmplx* sideband;
 | 
				
			||||||
 | 
						Real l, r;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						m_sampleBuffer.clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						m_settingsMutex.lock();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Rtl-Sdr uses full 16-bit scale; FCDPP does not
 | 
				
			||||||
 | 
						//int rescale = 32768 * (1 << m_boost);
 | 
				
			||||||
 | 
						int rescale = (1 << m_boost);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for(SampleVector::const_iterator it = begin; it < end; ++it) {
 | 
				
			||||||
 | 
							//Complex c(it->real() / 32768.0f, it->imag() / 32768.0f);
 | 
				
			||||||
 | 
							Complex c(it->real(), it->imag());
 | 
				
			||||||
 | 
							c *= m_nco.nextIQ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if(m_interpolator.interpolate(&m_sampleDistanceRemain, c, &ci))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								m_magsq = ((ci.real()*ci.real() +  ci.imag()*ci.imag())*rescale*rescale) / (1<<30);
 | 
				
			||||||
 | 
								m_sampleBuffer.push_back(Sample(ci.real() * rescale, ci.imag() * rescale));
 | 
				
			||||||
 | 
								m_sampleDistanceRemain += m_inputSampleRate / m_outputSampleRate;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if((m_spectrum != 0) && (m_spectrumEnabled))
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							m_spectrum->feed(m_sampleBuffer.begin(), m_sampleBuffer.end(), positiveOnly);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for(int i = 0; i < m_s16leSockets.count(); i++)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							m_s16leSockets[i].socket->write((const char*)&m_sampleBuffer[0], m_sampleBuffer.size() * 4);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						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(), it->imag());
 | 
				
			||||||
 | 
								int n_out = TCPFilter->runSSB(cj, &sideband, true);
 | 
				
			||||||
 | 
								if (n_out) {
 | 
				
			||||||
 | 
									for (int i = 0; i < n_out; i+=2) {
 | 
				
			||||||
 | 
										//l = (sideband[i].real() + sideband[i].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;
 | 
				
			||||||
 | 
										r = (sideband[i+1].real() + sideband[i+1].imag()) * 0.7;
 | 
				
			||||||
 | 
										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_sampleBufferSSB.clear();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if((m_sampleFormat == FormatNFM) && (m_ssbSockets.count() > 0)) {
 | 
				
			||||||
 | 
							for(SampleVector::const_iterator it = m_sampleBuffer.begin(); it != m_sampleBuffer.end(); ++it) {
 | 
				
			||||||
 | 
								Complex cj(it->real() / 32768.0f, it->imag() / 32768.0f);
 | 
				
			||||||
 | 
								// An FFT filter here is overkill, but was already set up for SSB
 | 
				
			||||||
 | 
								int n_out = TCPFilter->runFilt(cj, &sideband);
 | 
				
			||||||
 | 
								if (n_out) {
 | 
				
			||||||
 | 
									Real sum = 1.0;
 | 
				
			||||||
 | 
									for (int i = 0; i < n_out; i+=2) {
 | 
				
			||||||
 | 
										l = m_this.real() * (m_last.imag() - sideband[i].imag())
 | 
				
			||||||
 | 
										  - m_this.imag() * (m_last.real() - sideband[i].real());
 | 
				
			||||||
 | 
										m_last = sideband[i];
 | 
				
			||||||
 | 
										r = m_last.real() * (m_this.imag() - sideband[i+1].imag())
 | 
				
			||||||
 | 
										  - m_last.imag() * (m_this.real() - sideband[i+1].real());
 | 
				
			||||||
 | 
										m_this = sideband[i+1];
 | 
				
			||||||
 | 
										m_sampleBufferSSB.push_back(Sample(l * m_scale, r * m_scale));
 | 
				
			||||||
 | 
										sum += m_this.real() * m_this.real() + m_this.imag() * m_this.imag(); 
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									// TODO: correct levels
 | 
				
			||||||
 | 
									m_scale = 24000 * tcpFftLen / sum;
 | 
				
			||||||
 | 
									for(int i = 0; i < m_ssbSockets.count(); i++)
 | 
				
			||||||
 | 
										m_ssbSockets[i].socket->write((const char*)&m_sampleBufferSSB[0], n_out * 2);
 | 
				
			||||||
 | 
									m_sampleBufferSSB.clear();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						m_settingsMutex.unlock();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrc::start()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						m_tcpServer = new QTcpServer();
 | 
				
			||||||
 | 
						connect(m_tcpServer, SIGNAL(newConnection()), this, SLOT(onNewConnection()));
 | 
				
			||||||
 | 
						connect(m_tcpServer, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(onTcpServerError(QAbstractSocket::SocketError)));
 | 
				
			||||||
 | 
						m_tcpServer->listen(QHostAddress::Any, m_tcpPort);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrc::stop()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						closeAllSockets(&m_ssbSockets);
 | 
				
			||||||
 | 
						closeAllSockets(&m_s16leSockets);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if(m_tcpServer->isListening())
 | 
				
			||||||
 | 
							m_tcpServer->close();
 | 
				
			||||||
 | 
						delete m_tcpServer;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool UDPSrc::handleMessage(const Message& cmd)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						qDebug() << "UDPSrc::handleMessage";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (Channelizer::MsgChannelizerNotification::match(cmd))
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							Channelizer::MsgChannelizerNotification& notif = (Channelizer::MsgChannelizerNotification&) cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							m_settingsMutex.lock();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							m_inputSampleRate = notif.getSampleRate();
 | 
				
			||||||
 | 
							m_nco.setFreq(-notif.getFrequencyOffset(), m_inputSampleRate);
 | 
				
			||||||
 | 
							m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.0);
 | 
				
			||||||
 | 
							m_sampleDistanceRemain = m_inputSampleRate / m_outputSampleRate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							m_settingsMutex.unlock();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							qDebug() << "TCPSrc::handleMessage: MsgChannelizerNotification: m_inputSampleRate: " << m_inputSampleRate
 | 
				
			||||||
 | 
									<< " frequencyOffset: " << notif.getFrequencyOffset();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (MsgUDPSrcConfigure::match(cmd))
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							MsgUDPSrcConfigure& cfg = (MsgUDPSrcConfigure&) cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							m_settingsMutex.lock();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							m_sampleFormat = cfg.getSampleFormat();
 | 
				
			||||||
 | 
							m_outputSampleRate = cfg.getOutputSampleRate();
 | 
				
			||||||
 | 
							m_rfBandwidth = cfg.getRFBandwidth();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (cfg.getTCPPort() != m_tcpPort)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								m_tcpPort = cfg.getTCPPort();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if(m_tcpServer->isListening())
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									m_tcpServer->close();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								m_tcpServer->listen(QHostAddress::Any, m_tcpPort);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							m_boost = cfg.getBoost();
 | 
				
			||||||
 | 
							m_interpolator.create(16, m_inputSampleRate, m_rfBandwidth / 2.0);
 | 
				
			||||||
 | 
							m_sampleDistanceRemain = m_inputSampleRate / m_outputSampleRate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (m_sampleFormat == FormatSSB)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								TCPFilter->create_filter(0.3 / 48.0, m_rfBandwidth / 2.0 / m_outputSampleRate);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								TCPFilter->create_filter(0.0, m_rfBandwidth / 2.0 / m_outputSampleRate);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							m_settingsMutex.unlock();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							qDebug() << "  - MsgTCPSrcConfigure: m_sampleFormat: " << m_sampleFormat
 | 
				
			||||||
 | 
									<< " m_outputSampleRate: " << m_outputSampleRate
 | 
				
			||||||
 | 
									<< " m_rfBandwidth: " << m_rfBandwidth
 | 
				
			||||||
 | 
									<< " m_boost: " << m_boost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else if (MsgUDPSrcSpectrum::match(cmd))
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							MsgUDPSrcSpectrum& spc = (MsgUDPSrcSpectrum&) cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							m_spectrumEnabled = spc.getEnabled();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							qDebug() << "  - MsgTCPSrcSpectrum: m_spectrumEnabled: " << m_spectrumEnabled;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if(m_spectrum != 0)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
							   return m_spectrum->handleMessage(cmd);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return false;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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_tcpServer->hasPendingConnections())
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							qDebug("UDPSrc::onNewConnection: has a pending connection");
 | 
				
			||||||
 | 
							QTcpSocket* connection = m_tcpServer->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::onTcpServerError(QAbstractSocket::SocketError socketError)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						qDebug("UDPSrc::onTcpServerError: %s", qPrintable(m_tcpServer->errorString()));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										172
									
								
								plugins/channel/udpsrc/udpsrc.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										172
									
								
								plugins/channel/udpsrc/udpsrc.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,172 @@
 | 
				
			|||||||
 | 
					#ifndef INCLUDE_TCPSRC_H
 | 
				
			||||||
 | 
					#define INCLUDE_TCPSRC_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QMutex>
 | 
				
			||||||
 | 
					#include <QHostAddress>
 | 
				
			||||||
 | 
					#include "dsp/samplesink.h"
 | 
				
			||||||
 | 
					#include "dsp/nco.h"
 | 
				
			||||||
 | 
					#include "dsp/fftfilt.h"
 | 
				
			||||||
 | 
					#include "dsp/interpolator.h"
 | 
				
			||||||
 | 
					#include "util/message.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define tcpFftLen 2048
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class QTcpServer;
 | 
				
			||||||
 | 
					class QTcpSocket;
 | 
				
			||||||
 | 
					class UDPSrcGUI;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class UDPSrc : public SampleSink {
 | 
				
			||||||
 | 
						Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						enum SampleFormat {
 | 
				
			||||||
 | 
							FormatSSB,
 | 
				
			||||||
 | 
							FormatNFM,
 | 
				
			||||||
 | 
							FormatS16LE,
 | 
				
			||||||
 | 
							FormatNone
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						UDPSrc(MessageQueue* uiMessageQueue, UDPSrcGUI* udpSrcGUI, SampleSink* spectrum);
 | 
				
			||||||
 | 
						virtual ~UDPSrc();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void configure(MessageQueue* messageQueue, SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort, int boost);
 | 
				
			||||||
 | 
						void setSpectrum(MessageQueue* messageQueue, bool enabled);
 | 
				
			||||||
 | 
						Real 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 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:
 | 
				
			||||||
 | 
						class MsgUDPSrcConfigure : public Message {
 | 
				
			||||||
 | 
							MESSAGE_CLASS_DECLARATION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public:
 | 
				
			||||||
 | 
							SampleFormat getSampleFormat() const { return m_sampleFormat; }
 | 
				
			||||||
 | 
							Real getOutputSampleRate() const { return m_outputSampleRate; }
 | 
				
			||||||
 | 
							Real getRFBandwidth() const { return m_rfBandwidth; }
 | 
				
			||||||
 | 
							int getTCPPort() const { return m_tcpPort; }
 | 
				
			||||||
 | 
							int getBoost() const { return m_boost; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							static MsgUDPSrcConfigure* create(SampleFormat sampleFormat, Real sampleRate, Real rfBandwidth, int tcpPort, int boost)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return new MsgUDPSrcConfigure(sampleFormat, sampleRate, rfBandwidth, tcpPort, boost);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private:
 | 
				
			||||||
 | 
							SampleFormat m_sampleFormat;
 | 
				
			||||||
 | 
							Real m_outputSampleRate;
 | 
				
			||||||
 | 
							Real m_rfBandwidth;
 | 
				
			||||||
 | 
							int m_tcpPort;
 | 
				
			||||||
 | 
							int m_boost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							MsgUDPSrcConfigure(SampleFormat sampleFormat, Real outputSampleRate, Real rfBandwidth, int tcpPort, int boost) :
 | 
				
			||||||
 | 
								Message(),
 | 
				
			||||||
 | 
								m_sampleFormat(sampleFormat),
 | 
				
			||||||
 | 
								m_outputSampleRate(outputSampleRate),
 | 
				
			||||||
 | 
								m_rfBandwidth(rfBandwidth),
 | 
				
			||||||
 | 
								m_tcpPort(tcpPort),
 | 
				
			||||||
 | 
								m_boost(boost)
 | 
				
			||||||
 | 
							{ }
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						class MsgUDPSrcSpectrum : public Message {
 | 
				
			||||||
 | 
							MESSAGE_CLASS_DECLARATION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public:
 | 
				
			||||||
 | 
							bool getEnabled() const { return m_enabled; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							static MsgUDPSrcSpectrum* create(bool enabled)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return new MsgUDPSrcSpectrum(enabled);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private:
 | 
				
			||||||
 | 
							bool m_enabled;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							MsgUDPSrcSpectrum(bool enabled) :
 | 
				
			||||||
 | 
								Message(),
 | 
				
			||||||
 | 
								m_enabled(enabled)
 | 
				
			||||||
 | 
							{ }
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						MessageQueue* m_uiMessageQueue;
 | 
				
			||||||
 | 
						UDPSrcGUI* m_tcpSrcGUI;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int m_inputSampleRate;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int m_sampleFormat;
 | 
				
			||||||
 | 
						Real m_outputSampleRate;
 | 
				
			||||||
 | 
						Real m_rfBandwidth;
 | 
				
			||||||
 | 
						int m_tcpPort;
 | 
				
			||||||
 | 
						int m_boost;
 | 
				
			||||||
 | 
						Real m_magsq;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						Real m_scale;
 | 
				
			||||||
 | 
						Complex m_last, m_this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						NCO m_nco;
 | 
				
			||||||
 | 
						Interpolator m_interpolator;
 | 
				
			||||||
 | 
						Real m_sampleDistanceRemain;
 | 
				
			||||||
 | 
						fftfilt* TCPFilter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						SampleVector m_sampleBuffer;
 | 
				
			||||||
 | 
						SampleVector m_sampleBufferSSB;
 | 
				
			||||||
 | 
						SampleSink* m_spectrum;
 | 
				
			||||||
 | 
						bool m_spectrumEnabled;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						QTcpServer* m_tcpServer;
 | 
				
			||||||
 | 
						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_nextS16leId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						QMutex m_settingsMutex;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void closeAllSockets(Sockets* sockets);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					protected slots:
 | 
				
			||||||
 | 
						void onNewConnection();
 | 
				
			||||||
 | 
						void onDisconnected();
 | 
				
			||||||
 | 
						void onTcpServerError(QAbstractSocket::SocketError socketError);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // INCLUDE_TCPSRC_H
 | 
				
			||||||
							
								
								
									
										416
									
								
								plugins/channel/udpsrc/udpsrcgui.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										416
									
								
								plugins/channel/udpsrc/udpsrcgui.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,416 @@
 | 
				
			|||||||
 | 
					#include "udpsrcgui.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "plugin/pluginapi.h"
 | 
				
			||||||
 | 
					#include "dsp/threadedsamplesink.h"
 | 
				
			||||||
 | 
					#include "dsp/channelizer.h"
 | 
				
			||||||
 | 
					#include "dsp/spectrumvis.h"
 | 
				
			||||||
 | 
					#include "dsp/dspengine.h"
 | 
				
			||||||
 | 
					#include "util/simpleserializer.h"
 | 
				
			||||||
 | 
					#include "util/db.h"
 | 
				
			||||||
 | 
					#include "gui/basicchannelsettingswidget.h"
 | 
				
			||||||
 | 
					#include "ui_udpsrcgui.h"
 | 
				
			||||||
 | 
					#include "mainwindow.h"
 | 
				
			||||||
 | 
					#include "udpsrc.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					UDPSrcGUI* UDPSrcGUI::create(PluginAPI* pluginAPI)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						UDPSrcGUI* gui = new UDPSrcGUI(pluginAPI);
 | 
				
			||||||
 | 
						return gui;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::destroy()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						delete this;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::setName(const QString& name)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						setObjectName(name);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					qint64 UDPSrcGUI::getCenterFrequency() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return m_channelMarker.getCenterFrequency();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::setCenterFrequency(qint64 centerFrequency)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						m_channelMarker.setCenterFrequency(centerFrequency);
 | 
				
			||||||
 | 
						applySettings();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QString UDPSrcGUI::getName() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return objectName();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::resetToDefaults()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						blockApplySettings(true);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
						ui->sampleFormat->setCurrentIndex(0);
 | 
				
			||||||
 | 
						ui->sampleRate->setText("48000");
 | 
				
			||||||
 | 
						ui->rfBandwidth->setText("32000");
 | 
				
			||||||
 | 
						ui->udpPort->setText("9999");
 | 
				
			||||||
 | 
						ui->spectrumGUI->resetToDefaults();
 | 
				
			||||||
 | 
						ui->boost->setValue(1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						blockApplySettings(false);
 | 
				
			||||||
 | 
						applySettings();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QByteArray UDPSrcGUI::serialize() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						SimpleSerializer s(1);
 | 
				
			||||||
 | 
						s.writeBlob(1, saveState());
 | 
				
			||||||
 | 
						s.writeS32(2, m_channelMarker.getCenterFrequency());
 | 
				
			||||||
 | 
						s.writeS32(3, m_sampleFormat);
 | 
				
			||||||
 | 
						s.writeReal(4, m_outputSampleRate);
 | 
				
			||||||
 | 
						s.writeReal(5, m_rfBandwidth);
 | 
				
			||||||
 | 
						s.writeS32(6, m_tcpPort);
 | 
				
			||||||
 | 
						s.writeBlob(7, ui->spectrumGUI->serialize());
 | 
				
			||||||
 | 
						s.writeS32(8, (qint32)m_boost);
 | 
				
			||||||
 | 
						s.writeS32(9, m_channelMarker.getCenterFrequency());
 | 
				
			||||||
 | 
						return s.final();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool UDPSrcGUI::deserialize(const QByteArray& data)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						SimpleDeserializer d(data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (!d.isValid())
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							resetToDefaults();
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (d.getVersion() == 1)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							QByteArray bytetmp;
 | 
				
			||||||
 | 
							qint32 s32tmp;
 | 
				
			||||||
 | 
							Real realtmp;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
							blockApplySettings(true);
 | 
				
			||||||
 | 
							m_channelMarker.blockSignals(true);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
							d.readBlob(1, &bytetmp);
 | 
				
			||||||
 | 
							restoreState(bytetmp);
 | 
				
			||||||
 | 
							d.readS32(2, &s32tmp, 0);
 | 
				
			||||||
 | 
							m_channelMarker.setCenterFrequency(s32tmp);
 | 
				
			||||||
 | 
							d.readS32(3, &s32tmp, UDPSrc::FormatSSB);
 | 
				
			||||||
 | 
							switch(s32tmp) {
 | 
				
			||||||
 | 
								case UDPSrc::FormatSSB:
 | 
				
			||||||
 | 
									ui->sampleFormat->setCurrentIndex(0);
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								case UDPSrc::FormatNFM:
 | 
				
			||||||
 | 
									ui->sampleFormat->setCurrentIndex(1);
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								case UDPSrc::FormatS16LE:
 | 
				
			||||||
 | 
									ui->sampleFormat->setCurrentIndex(2);
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								default:
 | 
				
			||||||
 | 
									ui->sampleFormat->setCurrentIndex(0);
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							d.readReal(4, &realtmp, 48000);
 | 
				
			||||||
 | 
							ui->sampleRate->setText(QString("%1").arg(realtmp, 0));
 | 
				
			||||||
 | 
							d.readReal(5, &realtmp, 32000);
 | 
				
			||||||
 | 
							ui->rfBandwidth->setText(QString("%1").arg(realtmp, 0));
 | 
				
			||||||
 | 
							d.readS32(6, &s32tmp, 9999);
 | 
				
			||||||
 | 
							ui->udpPort->setText(QString("%1").arg(s32tmp));
 | 
				
			||||||
 | 
							d.readBlob(7, &bytetmp);
 | 
				
			||||||
 | 
							ui->spectrumGUI->deserialize(bytetmp);
 | 
				
			||||||
 | 
							d.readS32(8, &s32tmp, 1);
 | 
				
			||||||
 | 
							ui->boost->setValue(s32tmp);
 | 
				
			||||||
 | 
							d.readS32(9, &s32tmp, 0);
 | 
				
			||||||
 | 
							m_channelMarker.setCenterFrequency(s32tmp);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
							blockApplySettings(false);
 | 
				
			||||||
 | 
							m_channelMarker.blockSignals(false);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
							applySettings();
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							resetToDefaults();
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool UDPSrcGUI::handleMessage(const Message& message)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						qDebug() << "TCPSrcGUI::handleMessage";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						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: TCPSrc::MsgTCPSrcConnection: " << con.getConnect()
 | 
				
			||||||
 | 
									<< " ID: " << con.getID()
 | 
				
			||||||
 | 
									<< " peerAddress: " << con.getPeerAddress()
 | 
				
			||||||
 | 
									<< " peerPort: " << con.getPeerPort();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return true;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::channelMarkerChanged()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						applySettings();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::tick()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						Real powDb = CalcDb::dbPower(m_tcpSrc->getMagSq());
 | 
				
			||||||
 | 
						m_channelPowerDbAvg.feed(powDb);
 | 
				
			||||||
 | 
						ui->channelPower->setText(QString::number(m_channelPowerDbAvg.average(), 'f', 1));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					UDPSrcGUI::UDPSrcGUI(PluginAPI* pluginAPI, QWidget* parent) :
 | 
				
			||||||
 | 
						RollupWidget(parent),
 | 
				
			||||||
 | 
						ui(new Ui::UDPSrcGUI),
 | 
				
			||||||
 | 
						m_pluginAPI(pluginAPI),
 | 
				
			||||||
 | 
						m_tcpSrc(0),
 | 
				
			||||||
 | 
						m_channelMarker(this),
 | 
				
			||||||
 | 
						m_channelPowerDbAvg(40,0),
 | 
				
			||||||
 | 
						m_basicSettingsShown(false),
 | 
				
			||||||
 | 
						m_doApplySettings(true)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						ui->setupUi(this);
 | 
				
			||||||
 | 
						ui->connectedClientsBox->hide();
 | 
				
			||||||
 | 
						connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
 | 
				
			||||||
 | 
						connect(this, SIGNAL(menuDoubleClickEvent()), this, SLOT(onMenuDoubleClicked()));
 | 
				
			||||||
 | 
						setAttribute(Qt::WA_DeleteOnClose, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						m_spectrumVis = new SpectrumVis(ui->glSpectrum);
 | 
				
			||||||
 | 
						m_tcpSrc = new UDPSrc(m_pluginAPI->getMainWindowMessageQueue(), this, m_spectrumVis);
 | 
				
			||||||
 | 
						m_channelizer = new Channelizer(m_tcpSrc);
 | 
				
			||||||
 | 
						m_threadedChannelizer = new ThreadedSampleSink(m_channelizer, this);
 | 
				
			||||||
 | 
						DSPEngine::instance()->addThreadedSink(m_threadedChannelizer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ui->deltaFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
 | 
				
			||||||
 | 
						ui->deltaFrequency->setValueRange(7, 0U, 9999999U);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ui->glSpectrum->setCenterFrequency(0);
 | 
				
			||||||
 | 
						ui->glSpectrum->setSampleRate(ui->sampleRate->text().toInt());
 | 
				
			||||||
 | 
						ui->glSpectrum->setDisplayWaterfall(true);
 | 
				
			||||||
 | 
						ui->glSpectrum->setDisplayMaxHold(true);
 | 
				
			||||||
 | 
						m_spectrumVis->configure(m_spectrumVis->getInputMessageQueue(), 64, 10, FFTWindow::BlackmanHarris);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ui->glSpectrum->connectTimer(m_pluginAPI->getMainWindow()->getMasterTimer());
 | 
				
			||||||
 | 
						connect(&m_pluginAPI->getMainWindow()->getMasterTimer(), SIGNAL(timeout()), this, SLOT(tick()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						//m_channelMarker = new ChannelMarker(this);
 | 
				
			||||||
 | 
						m_channelMarker.setBandwidth(16000);
 | 
				
			||||||
 | 
						m_channelMarker.setCenterFrequency(0);
 | 
				
			||||||
 | 
						m_channelMarker.setColor(Qt::green);
 | 
				
			||||||
 | 
						m_channelMarker.setVisible(true);
 | 
				
			||||||
 | 
						connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
 | 
				
			||||||
 | 
						m_pluginAPI->addChannelMarker(&m_channelMarker);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						ui->spectrumGUI->setBuddies(m_spectrumVis->getInputMessageQueue(), m_spectrumVis, ui->glSpectrum);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						applySettings();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					UDPSrcGUI::~UDPSrcGUI()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						m_pluginAPI->removeChannelInstance(this);
 | 
				
			||||||
 | 
						DSPEngine::instance()->removeThreadedSink(m_threadedChannelizer);
 | 
				
			||||||
 | 
						delete m_threadedChannelizer;
 | 
				
			||||||
 | 
						delete m_channelizer;
 | 
				
			||||||
 | 
						delete m_tcpSrc;
 | 
				
			||||||
 | 
						delete m_spectrumVis;
 | 
				
			||||||
 | 
						//delete m_channelMarker;
 | 
				
			||||||
 | 
						delete ui;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::blockApplySettings(bool block)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    m_doApplySettings = !block;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::applySettings()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (m_doApplySettings)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							bool ok;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							Real outputSampleRate = ui->sampleRate->text().toDouble(&ok);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if((!ok) || (outputSampleRate < 1000))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								outputSampleRate = 48000;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							Real rfBandwidth = ui->rfBandwidth->text().toDouble(&ok);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if((!ok) || (rfBandwidth > outputSampleRate))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								rfBandwidth = outputSampleRate;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							int tcpPort = ui->udpPort->text().toInt(&ok);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if((!ok) || (tcpPort < 1) || (tcpPort > 65535))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								tcpPort = 9999;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							int boost = ui->boost->value();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							setTitleColor(m_channelMarker.getColor());
 | 
				
			||||||
 | 
							ui->deltaFrequency->setValue(abs(m_channelMarker.getCenterFrequency()));
 | 
				
			||||||
 | 
							ui->deltaMinus->setChecked(m_channelMarker.getCenterFrequency() < 0);
 | 
				
			||||||
 | 
							ui->sampleRate->setText(QString("%1").arg(outputSampleRate, 0));
 | 
				
			||||||
 | 
							ui->rfBandwidth->setText(QString("%1").arg(rfBandwidth, 0));
 | 
				
			||||||
 | 
							ui->udpPort->setText(QString("%1").arg(tcpPort));
 | 
				
			||||||
 | 
							ui->boost->setValue(boost);
 | 
				
			||||||
 | 
							m_channelMarker.disconnect(this, SLOT(channelMarkerChanged()));
 | 
				
			||||||
 | 
							m_channelMarker.setBandwidth((int)rfBandwidth);
 | 
				
			||||||
 | 
							connect(&m_channelMarker, SIGNAL(changed()), this, SLOT(channelMarkerChanged()));
 | 
				
			||||||
 | 
							ui->glSpectrum->setSampleRate(outputSampleRate);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							m_channelizer->configure(m_channelizer->getInputMessageQueue(),
 | 
				
			||||||
 | 
								outputSampleRate,
 | 
				
			||||||
 | 
								m_channelMarker.getCenterFrequency());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							UDPSrc::SampleFormat sampleFormat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							switch(ui->sampleFormat->currentIndex())
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								case 0:
 | 
				
			||||||
 | 
									sampleFormat = UDPSrc::FormatSSB;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								case 1:
 | 
				
			||||||
 | 
									sampleFormat = UDPSrc::FormatNFM;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								case 2:
 | 
				
			||||||
 | 
									sampleFormat = UDPSrc::FormatS16LE;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								default:
 | 
				
			||||||
 | 
									sampleFormat = UDPSrc::FormatSSB;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							m_sampleFormat = sampleFormat;
 | 
				
			||||||
 | 
							m_outputSampleRate = outputSampleRate;
 | 
				
			||||||
 | 
							m_rfBandwidth = rfBandwidth;
 | 
				
			||||||
 | 
							m_tcpPort = tcpPort;
 | 
				
			||||||
 | 
							m_boost = boost;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							m_tcpSrc->configure(m_tcpSrc->getInputMessageQueue(),
 | 
				
			||||||
 | 
								sampleFormat,
 | 
				
			||||||
 | 
								outputSampleRate,
 | 
				
			||||||
 | 
								rfBandwidth,
 | 
				
			||||||
 | 
								tcpPort,
 | 
				
			||||||
 | 
								boost);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ui->applyBtn->setEnabled(false);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::on_deltaMinus_toggled(bool minus)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int deltaFrequency = m_channelMarker.getCenterFrequency();
 | 
				
			||||||
 | 
						bool minusDelta = (deltaFrequency < 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (minus ^ minusDelta) // sign change
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							m_channelMarker.setCenterFrequency(-deltaFrequency);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::on_deltaFrequency_changed(quint64 value)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (ui->deltaMinus->isChecked()) {
 | 
				
			||||||
 | 
							m_channelMarker.setCenterFrequency(-value);
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							m_channelMarker.setCenterFrequency(value);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::on_sampleFormat_currentIndexChanged(int index)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						ui->applyBtn->setEnabled(true);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::on_sampleRate_textEdited(const QString& arg1)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						ui->applyBtn->setEnabled(true);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::on_rfBandwidth_textEdited(const QString& arg1)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						ui->applyBtn->setEnabled(true);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::on_udpPort_textEdited(const QString& arg1)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						ui->applyBtn->setEnabled(true);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::on_applyBtn_clicked()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						applySettings();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::on_boost_valueChanged(int value)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						ui->boost->setValue(value);
 | 
				
			||||||
 | 
						ui->boostText->setText(QString("%1").arg(value));
 | 
				
			||||||
 | 
						ui->applyBtn->setEnabled(true);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::onWidgetRolled(QWidget* widget, bool rollDown)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if ((widget == ui->spectrumBox) && (m_tcpSrc != 0))
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							m_tcpSrc->setSpectrum(m_tcpSrc->getInputMessageQueue(), rollDown);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcGUI::onMenuDoubleClicked()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (!m_basicSettingsShown)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							m_basicSettingsShown = true;
 | 
				
			||||||
 | 
							BasicChannelSettingsWidget* bcsw = new BasicChannelSettingsWidget(&m_channelMarker, this);
 | 
				
			||||||
 | 
							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;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										85
									
								
								plugins/channel/udpsrc/udpsrcgui.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								plugins/channel/udpsrc/udpsrcgui.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,85 @@
 | 
				
			|||||||
 | 
					#ifndef INCLUDE_TCPSRCGUI_H
 | 
				
			||||||
 | 
					#define INCLUDE_TCPSRCGUI_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QHostAddress>
 | 
				
			||||||
 | 
					#include "gui/rollupwidget.h"
 | 
				
			||||||
 | 
					#include "plugin/plugingui.h"
 | 
				
			||||||
 | 
					#include "dsp/channelmarker.h"
 | 
				
			||||||
 | 
					#include "dsp/movingaverage.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "udpsrc.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class PluginAPI;
 | 
				
			||||||
 | 
					class ThreadedSampleSink;
 | 
				
			||||||
 | 
					class Channelizer;
 | 
				
			||||||
 | 
					class UDPSrc;
 | 
				
			||||||
 | 
					class SpectrumVis;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					namespace Ui {
 | 
				
			||||||
 | 
						class UDPSrcGUI;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class UDPSrcGUI : public RollupWidget, public PluginGUI {
 | 
				
			||||||
 | 
						Q_OBJECT
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						static UDPSrcGUI* create(PluginAPI* pluginAPI);
 | 
				
			||||||
 | 
						void destroy();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void setName(const QString& name);
 | 
				
			||||||
 | 
						QString getName() const;
 | 
				
			||||||
 | 
						virtual qint64 getCenterFrequency() const;
 | 
				
			||||||
 | 
						virtual void setCenterFrequency(qint64 centerFrequency);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void resetToDefaults();
 | 
				
			||||||
 | 
						QByteArray serialize() const;
 | 
				
			||||||
 | 
						bool deserialize(const QByteArray& data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						virtual bool handleMessage(const Message& message);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private slots:
 | 
				
			||||||
 | 
						void channelMarkerChanged();
 | 
				
			||||||
 | 
						void on_deltaFrequency_changed(quint64 value);
 | 
				
			||||||
 | 
						void on_deltaMinus_toggled(bool minus);
 | 
				
			||||||
 | 
						void on_sampleFormat_currentIndexChanged(int index);
 | 
				
			||||||
 | 
						void on_sampleRate_textEdited(const QString& arg1);
 | 
				
			||||||
 | 
						void on_rfBandwidth_textEdited(const QString& arg1);
 | 
				
			||||||
 | 
						void on_udpPort_textEdited(const QString& arg1);
 | 
				
			||||||
 | 
						void on_applyBtn_clicked();
 | 
				
			||||||
 | 
						void onWidgetRolled(QWidget* widget, bool rollDown);
 | 
				
			||||||
 | 
						void onMenuDoubleClicked();
 | 
				
			||||||
 | 
						void on_boost_valueChanged(int value);
 | 
				
			||||||
 | 
						void tick();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						Ui::UDPSrcGUI* ui;
 | 
				
			||||||
 | 
						PluginAPI* m_pluginAPI;
 | 
				
			||||||
 | 
						UDPSrc* m_tcpSrc;
 | 
				
			||||||
 | 
						ChannelMarker m_channelMarker;
 | 
				
			||||||
 | 
						MovingAverage<Real> m_channelPowerDbAvg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// settings
 | 
				
			||||||
 | 
						UDPSrc::SampleFormat m_sampleFormat;
 | 
				
			||||||
 | 
						Real m_outputSampleRate;
 | 
				
			||||||
 | 
						Real m_rfBandwidth;
 | 
				
			||||||
 | 
						int m_boost;
 | 
				
			||||||
 | 
						int m_tcpPort;
 | 
				
			||||||
 | 
						bool m_basicSettingsShown;
 | 
				
			||||||
 | 
						bool m_doApplySettings;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// RF path
 | 
				
			||||||
 | 
						ThreadedSampleSink* m_threadedChannelizer;
 | 
				
			||||||
 | 
						Channelizer* m_channelizer;
 | 
				
			||||||
 | 
						SpectrumVis* m_spectrumVis;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						explicit UDPSrcGUI(PluginAPI* pluginAPI, QWidget* parent = 0);
 | 
				
			||||||
 | 
						virtual ~UDPSrcGUI();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void blockApplySettings(bool block);
 | 
				
			||||||
 | 
						void applySettings();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void addConnection(quint32 id, const QHostAddress& peerAddress, int peerPort);
 | 
				
			||||||
 | 
						void delConnection(quint32 id);
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // INCLUDE_TCPSRCGUI_H
 | 
				
			||||||
							
								
								
									
										454
									
								
								plugins/channel/udpsrc/udpsrcgui.ui
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										454
									
								
								plugins/channel/udpsrc/udpsrcgui.ui
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,454 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<ui version="4.0">
 | 
				
			||||||
 | 
					 <class>UDPSrcGUI</class>
 | 
				
			||||||
 | 
					 <widget class="RollupWidget" name="UDPSrcGUI">
 | 
				
			||||||
 | 
					  <property name="geometry">
 | 
				
			||||||
 | 
					   <rect>
 | 
				
			||||||
 | 
					    <x>0</x>
 | 
				
			||||||
 | 
					    <y>0</y>
 | 
				
			||||||
 | 
					    <width>400</width>
 | 
				
			||||||
 | 
					    <height>443</height>
 | 
				
			||||||
 | 
					   </rect>
 | 
				
			||||||
 | 
					  </property>
 | 
				
			||||||
 | 
					  <property name="windowTitle">
 | 
				
			||||||
 | 
					   <string>UDP Sample Source</string>
 | 
				
			||||||
 | 
					  </property>
 | 
				
			||||||
 | 
					  <widget class="QWidget" name="widget" native="true">
 | 
				
			||||||
 | 
					   <property name="geometry">
 | 
				
			||||||
 | 
					    <rect>
 | 
				
			||||||
 | 
					     <x>10</x>
 | 
				
			||||||
 | 
					     <y>5</y>
 | 
				
			||||||
 | 
					     <width>201</width>
 | 
				
			||||||
 | 
					     <height>142</height>
 | 
				
			||||||
 | 
					    </rect>
 | 
				
			||||||
 | 
					   </property>
 | 
				
			||||||
 | 
					   <property name="windowTitle">
 | 
				
			||||||
 | 
					    <string>Settings</string>
 | 
				
			||||||
 | 
					   </property>
 | 
				
			||||||
 | 
					   <layout class="QGridLayout" name="gridLayout">
 | 
				
			||||||
 | 
					    <property name="leftMargin">
 | 
				
			||||||
 | 
					     <number>2</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="topMargin">
 | 
				
			||||||
 | 
					     <number>2</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="rightMargin">
 | 
				
			||||||
 | 
					     <number>2</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="bottomMargin">
 | 
				
			||||||
 | 
					     <number>2</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="spacing">
 | 
				
			||||||
 | 
					     <number>3</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <item row="1" column="0">
 | 
				
			||||||
 | 
					     <widget class="QLabel" name="label">
 | 
				
			||||||
 | 
					      <property name="text">
 | 
				
			||||||
 | 
					       <string>Sample Format</string>
 | 
				
			||||||
 | 
					      </property>
 | 
				
			||||||
 | 
					     </widget>
 | 
				
			||||||
 | 
					    </item>
 | 
				
			||||||
 | 
					    <item row="2" column="0">
 | 
				
			||||||
 | 
					     <widget class="QComboBox" name="sampleFormat">
 | 
				
			||||||
 | 
					      <property name="currentIndex">
 | 
				
			||||||
 | 
					       <number>2</number>
 | 
				
			||||||
 | 
					      </property>
 | 
				
			||||||
 | 
					      <item>
 | 
				
			||||||
 | 
					       <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="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 row="1" column="1">
 | 
				
			||||||
 | 
					     <widget class="QLabel" name="label_2">
 | 
				
			||||||
 | 
					      <property name="text">
 | 
				
			||||||
 | 
					       <string>Samplerate (Hz)</string>
 | 
				
			||||||
 | 
					      </property>
 | 
				
			||||||
 | 
					     </widget>
 | 
				
			||||||
 | 
					    </item>
 | 
				
			||||||
 | 
					    <item row="3" column="0">
 | 
				
			||||||
 | 
					     <widget class="QLabel" name="label_4">
 | 
				
			||||||
 | 
					      <property name="text">
 | 
				
			||||||
 | 
					       <string>UDP Port</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="4" column="0">
 | 
				
			||||||
 | 
					     <widget class="QLineEdit" name="udpPort">
 | 
				
			||||||
 | 
					      <property name="text">
 | 
				
			||||||
 | 
					       <string>9999</string>
 | 
				
			||||||
 | 
					      </property>
 | 
				
			||||||
 | 
					     </widget>
 | 
				
			||||||
 | 
					    </item>
 | 
				
			||||||
 | 
					    <item row="5" 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="0" column="0">
 | 
				
			||||||
 | 
					     <layout class="QHBoxLayout" name="DeltaFrequencyLayout">
 | 
				
			||||||
 | 
					      <item>
 | 
				
			||||||
 | 
					       <widget class="QToolButton" name="deltaMinus">
 | 
				
			||||||
 | 
					        <property name="text">
 | 
				
			||||||
 | 
					         <string>...</string>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					        <property name="icon">
 | 
				
			||||||
 | 
					         <iconset>
 | 
				
			||||||
 | 
					          <selectedoff>:/plus.png</selectedoff>
 | 
				
			||||||
 | 
					          <selectedon>:/minus.png</selectedon>
 | 
				
			||||||
 | 
					         </iconset>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					        <property name="checkable">
 | 
				
			||||||
 | 
					         <bool>true</bool>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					        <property name="checked">
 | 
				
			||||||
 | 
					         <bool>false</bool>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					       </widget>
 | 
				
			||||||
 | 
					      </item>
 | 
				
			||||||
 | 
					      <item>
 | 
				
			||||||
 | 
					       <widget class="ValueDial" name="deltaFrequency" native="true">
 | 
				
			||||||
 | 
					        <property name="sizePolicy">
 | 
				
			||||||
 | 
					         <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
 | 
				
			||||||
 | 
					          <horstretch>0</horstretch>
 | 
				
			||||||
 | 
					          <verstretch>0</verstretch>
 | 
				
			||||||
 | 
					         </sizepolicy>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					        <property name="minimumSize">
 | 
				
			||||||
 | 
					         <size>
 | 
				
			||||||
 | 
					          <width>32</width>
 | 
				
			||||||
 | 
					          <height>16</height>
 | 
				
			||||||
 | 
					         </size>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					        <property name="font">
 | 
				
			||||||
 | 
					         <font>
 | 
				
			||||||
 | 
					          <family>Monospace</family>
 | 
				
			||||||
 | 
					          <pointsize>10</pointsize>
 | 
				
			||||||
 | 
					         </font>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					        <property name="cursor">
 | 
				
			||||||
 | 
					         <cursorShape>SizeVerCursor</cursorShape>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					        <property name="focusPolicy">
 | 
				
			||||||
 | 
					         <enum>Qt::StrongFocus</enum>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					        <property name="toolTip">
 | 
				
			||||||
 | 
					         <string>Demod shift frequency from center in Hz</string>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					       </widget>
 | 
				
			||||||
 | 
					      </item>
 | 
				
			||||||
 | 
					      <item>
 | 
				
			||||||
 | 
					       <widget class="QLabel" name="deltaUnits">
 | 
				
			||||||
 | 
					        <property name="palette">
 | 
				
			||||||
 | 
					         <palette>
 | 
				
			||||||
 | 
					          <active>
 | 
				
			||||||
 | 
					           <colorrole role="Text">
 | 
				
			||||||
 | 
					            <brush brushstyle="SolidPattern">
 | 
				
			||||||
 | 
					             <color alpha="255">
 | 
				
			||||||
 | 
					              <red>26</red>
 | 
				
			||||||
 | 
					              <green>26</green>
 | 
				
			||||||
 | 
					              <blue>26</blue>
 | 
				
			||||||
 | 
					             </color>
 | 
				
			||||||
 | 
					            </brush>
 | 
				
			||||||
 | 
					           </colorrole>
 | 
				
			||||||
 | 
					           <colorrole role="BrightText">
 | 
				
			||||||
 | 
					            <brush brushstyle="SolidPattern">
 | 
				
			||||||
 | 
					             <color alpha="255">
 | 
				
			||||||
 | 
					              <red>255</red>
 | 
				
			||||||
 | 
					              <green>255</green>
 | 
				
			||||||
 | 
					              <blue>255</blue>
 | 
				
			||||||
 | 
					             </color>
 | 
				
			||||||
 | 
					            </brush>
 | 
				
			||||||
 | 
					           </colorrole>
 | 
				
			||||||
 | 
					          </active>
 | 
				
			||||||
 | 
					          <inactive>
 | 
				
			||||||
 | 
					           <colorrole role="Text">
 | 
				
			||||||
 | 
					            <brush brushstyle="SolidPattern">
 | 
				
			||||||
 | 
					             <color alpha="255">
 | 
				
			||||||
 | 
					              <red>26</red>
 | 
				
			||||||
 | 
					              <green>26</green>
 | 
				
			||||||
 | 
					              <blue>26</blue>
 | 
				
			||||||
 | 
					             </color>
 | 
				
			||||||
 | 
					            </brush>
 | 
				
			||||||
 | 
					           </colorrole>
 | 
				
			||||||
 | 
					           <colorrole role="BrightText">
 | 
				
			||||||
 | 
					            <brush brushstyle="SolidPattern">
 | 
				
			||||||
 | 
					             <color alpha="255">
 | 
				
			||||||
 | 
					              <red>255</red>
 | 
				
			||||||
 | 
					              <green>255</green>
 | 
				
			||||||
 | 
					              <blue>255</blue>
 | 
				
			||||||
 | 
					             </color>
 | 
				
			||||||
 | 
					            </brush>
 | 
				
			||||||
 | 
					           </colorrole>
 | 
				
			||||||
 | 
					          </inactive>
 | 
				
			||||||
 | 
					          <disabled>
 | 
				
			||||||
 | 
					           <colorrole role="Text">
 | 
				
			||||||
 | 
					            <brush brushstyle="SolidPattern">
 | 
				
			||||||
 | 
					             <color alpha="255">
 | 
				
			||||||
 | 
					              <red>118</red>
 | 
				
			||||||
 | 
					              <green>118</green>
 | 
				
			||||||
 | 
					              <blue>117</blue>
 | 
				
			||||||
 | 
					             </color>
 | 
				
			||||||
 | 
					            </brush>
 | 
				
			||||||
 | 
					           </colorrole>
 | 
				
			||||||
 | 
					           <colorrole role="BrightText">
 | 
				
			||||||
 | 
					            <brush brushstyle="SolidPattern">
 | 
				
			||||||
 | 
					             <color alpha="255">
 | 
				
			||||||
 | 
					              <red>255</red>
 | 
				
			||||||
 | 
					              <green>255</green>
 | 
				
			||||||
 | 
					              <blue>255</blue>
 | 
				
			||||||
 | 
					             </color>
 | 
				
			||||||
 | 
					            </brush>
 | 
				
			||||||
 | 
					           </colorrole>
 | 
				
			||||||
 | 
					          </disabled>
 | 
				
			||||||
 | 
					         </palette>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					        <property name="font">
 | 
				
			||||||
 | 
					         <font>
 | 
				
			||||||
 | 
					          <pointsize>8</pointsize>
 | 
				
			||||||
 | 
					         </font>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					        <property name="text">
 | 
				
			||||||
 | 
					         <string> Hz</string>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					       </widget>
 | 
				
			||||||
 | 
					      </item>
 | 
				
			||||||
 | 
					     </layout>
 | 
				
			||||||
 | 
					    </item>
 | 
				
			||||||
 | 
					    <item row="0" column="1">
 | 
				
			||||||
 | 
					     <layout class="QHBoxLayout" name="ChannelPowerLayout">
 | 
				
			||||||
 | 
					      <item>
 | 
				
			||||||
 | 
					       <spacer name="horizontalSpacer">
 | 
				
			||||||
 | 
					        <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">
 | 
				
			||||||
 | 
					         <string>0.0</string>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					       </widget>
 | 
				
			||||||
 | 
					      </item>
 | 
				
			||||||
 | 
					      <item>
 | 
				
			||||||
 | 
					       <widget class="QLabel" name="channelPowerUnits">
 | 
				
			||||||
 | 
					        <property name="text">
 | 
				
			||||||
 | 
					         <string> dB</string>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					       </widget>
 | 
				
			||||||
 | 
					      </item>
 | 
				
			||||||
 | 
					     </layout>
 | 
				
			||||||
 | 
					    </item>
 | 
				
			||||||
 | 
					    <item row="5" column="1">
 | 
				
			||||||
 | 
					     <layout class="QHBoxLayout" name="BoostLayout">
 | 
				
			||||||
 | 
					      <item>
 | 
				
			||||||
 | 
					       <widget class="QLabel" name="boostLabel">
 | 
				
			||||||
 | 
					        <property name="text">
 | 
				
			||||||
 | 
					         <string>Boost</string>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					       </widget>
 | 
				
			||||||
 | 
					      </item>
 | 
				
			||||||
 | 
					      <item>
 | 
				
			||||||
 | 
					       <widget class="QSlider" name="boost">
 | 
				
			||||||
 | 
					        <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">
 | 
				
			||||||
 | 
					         <string>0</string>
 | 
				
			||||||
 | 
					        </property>
 | 
				
			||||||
 | 
					       </widget>
 | 
				
			||||||
 | 
					      </item>
 | 
				
			||||||
 | 
					     </layout>
 | 
				
			||||||
 | 
					    </item>
 | 
				
			||||||
 | 
					   </layout>
 | 
				
			||||||
 | 
					  </widget>
 | 
				
			||||||
 | 
					  <widget class="QWidget" name="spectrumBox" native="true">
 | 
				
			||||||
 | 
					   <property name="geometry">
 | 
				
			||||||
 | 
					    <rect>
 | 
				
			||||||
 | 
					     <x>15</x>
 | 
				
			||||||
 | 
					     <y>160</y>
 | 
				
			||||||
 | 
					     <width>231</width>
 | 
				
			||||||
 | 
					     <height>156</height>
 | 
				
			||||||
 | 
					    </rect>
 | 
				
			||||||
 | 
					   </property>
 | 
				
			||||||
 | 
					   <property name="windowTitle">
 | 
				
			||||||
 | 
					    <string>Channel Spectrum</string>
 | 
				
			||||||
 | 
					   </property>
 | 
				
			||||||
 | 
					   <layout class="QVBoxLayout" name="verticalLayout_2">
 | 
				
			||||||
 | 
					    <property name="spacing">
 | 
				
			||||||
 | 
					     <number>3</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="leftMargin">
 | 
				
			||||||
 | 
					     <number>2</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="topMargin">
 | 
				
			||||||
 | 
					     <number>2</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="rightMargin">
 | 
				
			||||||
 | 
					     <number>2</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="bottomMargin">
 | 
				
			||||||
 | 
					     <number>2</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <item>
 | 
				
			||||||
 | 
					     <widget class="GLSpectrum" name="glSpectrum" native="true"/>
 | 
				
			||||||
 | 
					    </item>
 | 
				
			||||||
 | 
					    <item>
 | 
				
			||||||
 | 
					     <widget class="GLSpectrumGUI" name="spectrumGUI" native="true"/>
 | 
				
			||||||
 | 
					    </item>
 | 
				
			||||||
 | 
					   </layout>
 | 
				
			||||||
 | 
					  </widget>
 | 
				
			||||||
 | 
					  <widget class="QWidget" name="connectedClientsBox" native="true">
 | 
				
			||||||
 | 
					   <property name="geometry">
 | 
				
			||||||
 | 
					    <rect>
 | 
				
			||||||
 | 
					     <x>15</x>
 | 
				
			||||||
 | 
					     <y>330</y>
 | 
				
			||||||
 | 
					     <width>274</width>
 | 
				
			||||||
 | 
					     <height>101</height>
 | 
				
			||||||
 | 
					    </rect>
 | 
				
			||||||
 | 
					   </property>
 | 
				
			||||||
 | 
					   <property name="windowTitle">
 | 
				
			||||||
 | 
					    <string>Connected Clients (0)</string>
 | 
				
			||||||
 | 
					   </property>
 | 
				
			||||||
 | 
					   <layout class="QVBoxLayout" name="verticalLayout">
 | 
				
			||||||
 | 
					    <property name="spacing">
 | 
				
			||||||
 | 
					     <number>3</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="leftMargin">
 | 
				
			||||||
 | 
					     <number>2</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="topMargin">
 | 
				
			||||||
 | 
					     <number>2</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="rightMargin">
 | 
				
			||||||
 | 
					     <number>2</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <property name="bottomMargin">
 | 
				
			||||||
 | 
					     <number>2</number>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					    <item>
 | 
				
			||||||
 | 
					     <widget class="QTreeWidget" name="connections">
 | 
				
			||||||
 | 
					      <property name="maximumSize">
 | 
				
			||||||
 | 
					       <size>
 | 
				
			||||||
 | 
					        <width>400</width>
 | 
				
			||||||
 | 
					        <height>100</height>
 | 
				
			||||||
 | 
					       </size>
 | 
				
			||||||
 | 
					      </property>
 | 
				
			||||||
 | 
					      <property name="rootIsDecorated">
 | 
				
			||||||
 | 
					       <bool>false</bool>
 | 
				
			||||||
 | 
					      </property>
 | 
				
			||||||
 | 
					      <property name="itemsExpandable">
 | 
				
			||||||
 | 
					       <bool>false</bool>
 | 
				
			||||||
 | 
					      </property>
 | 
				
			||||||
 | 
					      <attribute name="headerVisible">
 | 
				
			||||||
 | 
					       <bool>false</bool>
 | 
				
			||||||
 | 
					      </attribute>
 | 
				
			||||||
 | 
					      <column>
 | 
				
			||||||
 | 
					       <property name="text">
 | 
				
			||||||
 | 
					        <string>IP:Port</string>
 | 
				
			||||||
 | 
					       </property>
 | 
				
			||||||
 | 
					      </column>
 | 
				
			||||||
 | 
					     </widget>
 | 
				
			||||||
 | 
					    </item>
 | 
				
			||||||
 | 
					   </layout>
 | 
				
			||||||
 | 
					  </widget>
 | 
				
			||||||
 | 
					 </widget>
 | 
				
			||||||
 | 
					 <customwidgets>
 | 
				
			||||||
 | 
					  <customwidget>
 | 
				
			||||||
 | 
					   <class>ValueDial</class>
 | 
				
			||||||
 | 
					   <extends>QWidget</extends>
 | 
				
			||||||
 | 
					   <header>gui/valuedial.h</header>
 | 
				
			||||||
 | 
					   <container>1</container>
 | 
				
			||||||
 | 
					  </customwidget>
 | 
				
			||||||
 | 
					  <customwidget>
 | 
				
			||||||
 | 
					   <class>GLSpectrum</class>
 | 
				
			||||||
 | 
					   <extends>QWidget</extends>
 | 
				
			||||||
 | 
					   <header>gui/glspectrum.h</header>
 | 
				
			||||||
 | 
					   <container>1</container>
 | 
				
			||||||
 | 
					  </customwidget>
 | 
				
			||||||
 | 
					  <customwidget>
 | 
				
			||||||
 | 
					   <class>GLSpectrumGUI</class>
 | 
				
			||||||
 | 
					   <extends>QWidget</extends>
 | 
				
			||||||
 | 
					   <header>gui/glspectrumgui.h</header>
 | 
				
			||||||
 | 
					   <container>1</container>
 | 
				
			||||||
 | 
					  </customwidget>
 | 
				
			||||||
 | 
					  <customwidget>
 | 
				
			||||||
 | 
					   <class>RollupWidget</class>
 | 
				
			||||||
 | 
					   <extends>QWidget</extends>
 | 
				
			||||||
 | 
					   <header>gui/rollupwidget.h</header>
 | 
				
			||||||
 | 
					   <container>1</container>
 | 
				
			||||||
 | 
					  </customwidget>
 | 
				
			||||||
 | 
					 </customwidgets>
 | 
				
			||||||
 | 
					 <tabstops>
 | 
				
			||||||
 | 
					  <tabstop>sampleFormat</tabstop>
 | 
				
			||||||
 | 
					  <tabstop>udpPort</tabstop>
 | 
				
			||||||
 | 
					  <tabstop>sampleRate</tabstop>
 | 
				
			||||||
 | 
					  <tabstop>rfBandwidth</tabstop>
 | 
				
			||||||
 | 
					  <tabstop>applyBtn</tabstop>
 | 
				
			||||||
 | 
					  <tabstop>connections</tabstop>
 | 
				
			||||||
 | 
					 </tabstops>
 | 
				
			||||||
 | 
					 <resources>
 | 
				
			||||||
 | 
					  <include location="../../../sdrbase/resources/res.qrc"/>
 | 
				
			||||||
 | 
					 </resources>
 | 
				
			||||||
 | 
					 <connections/>
 | 
				
			||||||
 | 
					</ui>
 | 
				
			||||||
							
								
								
									
										55
									
								
								plugins/channel/udpsrc/udpsrcplugin.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								plugins/channel/udpsrc/udpsrcplugin.cpp
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,55 @@
 | 
				
			|||||||
 | 
					#include "udpsrcplugin.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QtPlugin>
 | 
				
			||||||
 | 
					#include <QAction>
 | 
				
			||||||
 | 
					#include "plugin/pluginapi.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "udpsrcgui.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const PluginDescriptor UDPSrcPlugin::m_pluginDescriptor = {
 | 
				
			||||||
 | 
						QString("UDP Channel Source"),
 | 
				
			||||||
 | 
						QString("---"),
 | 
				
			||||||
 | 
						QString("(c) Edouard Griffiths, F4EXB"),
 | 
				
			||||||
 | 
						QString("https://github.com/f4exb/sdrangel"),
 | 
				
			||||||
 | 
						true,
 | 
				
			||||||
 | 
						QString("https://github.com/f4exb/sdrangel")
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					UDPSrcPlugin::UDPSrcPlugin(QObject* parent) :
 | 
				
			||||||
 | 
						QObject(parent)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const PluginDescriptor& UDPSrcPlugin::getPluginDescriptor() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return m_pluginDescriptor;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcPlugin::initPlugin(PluginAPI* pluginAPI)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						m_pluginAPI = pluginAPI;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// register TCP Channel Source
 | 
				
			||||||
 | 
						QAction* action = new QAction(tr("&UDP Source"), this);
 | 
				
			||||||
 | 
						connect(action, SIGNAL(triggered()), this, SLOT(createInstanceUDPSrc()));
 | 
				
			||||||
 | 
						m_pluginAPI->registerChannel("sdrangel.channel.udpsrc", this, action);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PluginGUI* UDPSrcPlugin::createChannel(const QString& channelName)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if(channelName == "sdrangel.channel.udpsrc") {
 | 
				
			||||||
 | 
							UDPSrcGUI* gui = UDPSrcGUI::create(m_pluginAPI);
 | 
				
			||||||
 | 
							m_pluginAPI->registerChannelInstance("sdrangel.channel.udpsrc", gui);
 | 
				
			||||||
 | 
							m_pluginAPI->addChannelRollup(gui);
 | 
				
			||||||
 | 
							return gui;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UDPSrcPlugin::createInstanceUDPSrc()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						UDPSrcGUI* gui = UDPSrcGUI::create(m_pluginAPI);
 | 
				
			||||||
 | 
						m_pluginAPI->registerChannelInstance("sdrangel.channel.udpsrc", gui);
 | 
				
			||||||
 | 
						m_pluginAPI->addChannelRollup(gui);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										29
									
								
								plugins/channel/udpsrc/udpsrcplugin.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								plugins/channel/udpsrc/udpsrcplugin.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,29 @@
 | 
				
			|||||||
 | 
					#ifndef INCLUDE_UDPSRCPLUGIN_H
 | 
				
			||||||
 | 
					#define INCLUDE_UDPSRCPLUGIN_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QObject>
 | 
				
			||||||
 | 
					#include "plugin/plugininterface.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class UDPSrcPlugin : public QObject, PluginInterface {
 | 
				
			||||||
 | 
						Q_OBJECT
 | 
				
			||||||
 | 
						Q_INTERFACES(PluginInterface)
 | 
				
			||||||
 | 
						Q_PLUGIN_METADATA(IID "sdrangel.demod.udpsrc")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						explicit UDPSrcPlugin(QObject* parent = 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const PluginDescriptor& getPluginDescriptor() const;
 | 
				
			||||||
 | 
						void initPlugin(PluginAPI* pluginAPI);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						PluginGUI* createChannel(const QString& channelName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						static const PluginDescriptor m_pluginDescriptor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						PluginAPI* m_pluginAPI;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private slots:
 | 
				
			||||||
 | 
						void createInstanceUDPSrc();
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif // INCLUDE_UDPSRCPLUGIN_H
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user