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

Websocket spectrum: implemented start/stop server from spectrum GUI

This commit is contained in:
f4exb 2020-05-02 00:35:47 +02:00
parent 3730cbf865
commit 13ace213a7
5 changed files with 32 additions and 42 deletions

View File

@ -72,18 +72,6 @@ SpectrumVis::~SpectrumVis()
fftFactory->releaseEngine(m_settings.m_fftSize, false, m_fftEngineSequence); fftFactory->releaseEngine(m_settings.m_fftSize, false, m_fftEngineSequence);
} }
void SpectrumVis::openWSSpectrum()
{
MsgConfigureWSpectrumOpenClose *cmd = new MsgConfigureWSpectrumOpenClose(true);
getInputMessageQueue()->push(cmd);
}
void SpectrumVis::closeWSSpectrum()
{
MsgConfigureWSpectrumOpenClose *cmd = new MsgConfigureWSpectrumOpenClose(false);
getInputMessageQueue()->push(cmd);
}
void SpectrumVis::configure( void SpectrumVis::configure(
int fftSize, int fftSize,
float refLevel, float refLevel,

View File

@ -47,8 +47,7 @@ public:
const GLSpectrumSettings& getSettings() const { return m_settings; } const GLSpectrumSettings& getSettings() const { return m_settings; }
bool getForce() const { return m_force; } bool getForce() const { return m_force; }
static MsgConfigureSpectrumVis* create(const GLSpectrumSettings& settings, bool force) static MsgConfigureSpectrumVis* create(const GLSpectrumSettings& settings, bool force) {
{
return new MsgConfigureSpectrumVis(settings, force); return new MsgConfigureSpectrumVis(settings, force);
} }
@ -82,6 +81,26 @@ public:
{ } { }
}; };
class MsgConfigureWSpectrumOpenClose : public Message
{
MESSAGE_CLASS_DECLARATION
public:
Real getOpenClose() const { return m_openClose; }
static MsgConfigureWSpectrumOpenClose* create(bool openClose) {
return new MsgConfigureWSpectrumOpenClose(openClose);
}
private:
bool m_openClose;
MsgConfigureWSpectrumOpenClose(bool openClose) :
Message(),
m_openClose(openClose)
{}
};
enum AvgMode enum AvgMode
{ {
AvgModeNone, AvgModeNone,
@ -94,8 +113,6 @@ public:
virtual ~SpectrumVis(); virtual ~SpectrumVis();
void setGLSpectrum(GLSpectrumInterface* glSpectrum) { m_glSpectrum = glSpectrum; } void setGLSpectrum(GLSpectrumInterface* glSpectrum) { m_glSpectrum = glSpectrum; }
void openWSSpectrum();
void closeWSSpectrum();
void configure( void configure(
int fftSize, int fftSize,
@ -136,22 +153,6 @@ private:
Real m_scalef; Real m_scalef;
}; };
class MsgConfigureWSpectrumOpenClose : public Message
{
MESSAGE_CLASS_DECLARATION
public:
MsgConfigureWSpectrumOpenClose(bool openClose) :
Message(),
m_openClose(openClose)
{}
Real getOpenClose() const { return m_openClose; }
private:
bool m_openClose;
};
class MsgConfigureWSpectrum : public Message class MsgConfigureWSpectrum : public Message
{ {
MESSAGE_CLASS_DECLARATION MESSAGE_CLASS_DECLARATION

View File

@ -57,6 +57,7 @@ void WSSpectrum::closeSocket()
{ {
if (m_webSocketServer) if (m_webSocketServer)
{ {
qDebug() << "WSSpectrum::closeSocket: stopping spectrum server listening at " << m_listeningAddress.toString() << " on port " << m_port;
delete m_webSocketServer; delete m_webSocketServer;
m_webSocketServer = nullptr; m_webSocketServer = nullptr;
} }

View File

@ -201,16 +201,6 @@ void GLSpectrumGUI::applySettings()
{ {
SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(m_settings, false); SpectrumVis::MsgConfigureSpectrumVis *msg = SpectrumVis::MsgConfigureSpectrumVis::create(m_settings, false);
m_spectrumVis->getInputMessageQueue()->push(msg); m_spectrumVis->getInputMessageQueue()->push(msg);
// m_spectrumVis->configure(
// m_settings.m_fftSize,
// m_settings.m_refLevel,
// m_settings.m_powerRange,
// m_settings.m_fftOverlap,
// getAveragingValue(m_settings.m_averagingIndex, m_settings.m_averagingMode),
// (SpectrumVis::AvgMode) m_settings.m_averagingMode,
// (FFTWindow::Function) m_settings.m_fftWindow,
// m_settings.m_linear
// );
} }
} }
@ -257,6 +247,15 @@ void GLSpectrumGUI::on_linscale_toggled(bool checked)
applySettings(); applySettings();
} }
void GLSpectrumGUI::on_wsSpectrum_toggled(bool checked)
{
if (m_spectrumVis)
{
SpectrumVis::MsgConfigureWSpectrumOpenClose *msg = SpectrumVis::MsgConfigureWSpectrumOpenClose::create(checked);
m_spectrumVis->getInputMessageQueue()->push(msg);
}
}
void GLSpectrumGUI::on_refLevel_valueChanged(int value) void GLSpectrumGUI::on_refLevel_valueChanged(int value)
{ {
m_settings.m_refLevel = value; m_settings.m_refLevel = value;

View File

@ -93,6 +93,7 @@ private slots:
void on_averagingMode_currentIndexChanged(int index); void on_averagingMode_currentIndexChanged(int index);
void on_averaging_currentIndexChanged(int index); void on_averaging_currentIndexChanged(int index);
void on_linscale_toggled(bool checked); void on_linscale_toggled(bool checked);
void on_wsSpectrum_toggled(bool checked);
void on_waterfall_toggled(bool checked); void on_waterfall_toggled(bool checked);
void on_histogram_toggled(bool checked); void on_histogram_toggled(bool checked);