Consolidate spectrum collector message handling.

This commit is contained in:
Jared Boone 2016-01-12 10:32:00 -08:00
parent a577bc9664
commit b993e3d73e
10 changed files with 37 additions and 62 deletions

View File

@ -47,17 +47,14 @@ void NarrowbandAMAudio::execute(const buffer_c8_t& buffer) {
void NarrowbandAMAudio::on_message(const Message* const message) { void NarrowbandAMAudio::on_message(const Message* const message) {
switch(message->id) { switch(message->id) {
case Message::ID::UpdateSpectrum: case Message::ID::UpdateSpectrum:
channel_spectrum.update(); case Message::ID::SpectrumStreamingConfig:
channel_spectrum.on_message(message);
break; break;
case Message::ID::AMConfigure: case Message::ID::AMConfigure:
configure(*reinterpret_cast<const AMConfigureMessage*>(message)); configure(*reinterpret_cast<const AMConfigureMessage*>(message));
break; break;
case Message::ID::SpectrumStreamingConfig:
streaming_config(*reinterpret_cast<const SpectrumStreamingConfigMessage*>(message));
break;
default: default:
break; break;
} }
@ -88,11 +85,3 @@ void NarrowbandAMAudio::configure(const AMConfigureMessage& message) {
configured = true; configured = true;
} }
void NarrowbandAMAudio::streaming_config(const SpectrumStreamingConfigMessage& message) {
if( message.mode == SpectrumStreamingConfigMessage::Mode::Running ) {
channel_spectrum.start();
} else {
channel_spectrum.stop();
}
}

View File

@ -60,8 +60,6 @@ private:
bool configured { false }; bool configured { false };
void configure(const AMConfigureMessage& message); void configure(const AMConfigureMessage& message);
void streaming_config(const SpectrumStreamingConfigMessage& message);
}; };
#endif/*__PROC_AM_AUDIO_H__*/ #endif/*__PROC_AM_AUDIO_H__*/

View File

@ -47,17 +47,14 @@ void NarrowbandFMAudio::execute(const buffer_c8_t& buffer) {
void NarrowbandFMAudio::on_message(const Message* const message) { void NarrowbandFMAudio::on_message(const Message* const message) {
switch(message->id) { switch(message->id) {
case Message::ID::UpdateSpectrum: case Message::ID::UpdateSpectrum:
channel_spectrum.update(); case Message::ID::SpectrumStreamingConfig:
channel_spectrum.on_message(message);
break; break;
case Message::ID::NBFMConfigure: case Message::ID::NBFMConfigure:
configure(*reinterpret_cast<const NBFMConfigureMessage*>(message)); configure(*reinterpret_cast<const NBFMConfigureMessage*>(message));
break; break;
case Message::ID::SpectrumStreamingConfig:
streaming_config(*reinterpret_cast<const SpectrumStreamingConfigMessage*>(message));
break;
default: default:
break; break;
} }
@ -91,11 +88,3 @@ void NarrowbandFMAudio::configure(const NBFMConfigureMessage& message) {
configured = true; configured = true;
} }
void NarrowbandFMAudio::streaming_config(const SpectrumStreamingConfigMessage& message) {
if( message.mode == SpectrumStreamingConfigMessage::Mode::Running ) {
channel_spectrum.start();
} else {
channel_spectrum.stop();
}
}

View File

@ -59,8 +59,6 @@ private:
bool configured { false }; bool configured { false };
void configure(const NBFMConfigureMessage& message); void configure(const NBFMConfigureMessage& message);
void streaming_config(const SpectrumStreamingConfigMessage& message);
}; };
#endif/*__PROC_NFM_AUDIO_H__*/ #endif/*__PROC_NFM_AUDIO_H__*/

View File

@ -74,17 +74,14 @@ void WidebandFMAudio::execute(const buffer_c8_t& buffer) {
void WidebandFMAudio::on_message(const Message* const message) { void WidebandFMAudio::on_message(const Message* const message) {
switch(message->id) { switch(message->id) {
case Message::ID::UpdateSpectrum: case Message::ID::UpdateSpectrum:
channel_spectrum.update(); case Message::ID::SpectrumStreamingConfig:
channel_spectrum.on_message(message);
break; break;
case Message::ID::WFMConfigure: case Message::ID::WFMConfigure:
configure(*reinterpret_cast<const WFMConfigureMessage*>(message)); configure(*reinterpret_cast<const WFMConfigureMessage*>(message));
break; break;
case Message::ID::SpectrumStreamingConfig:
streaming_config(*reinterpret_cast<const SpectrumStreamingConfigMessage*>(message));
break;
default: default:
break; break;
} }
@ -119,11 +116,3 @@ void WidebandFMAudio::configure(const WFMConfigureMessage& message) {
configured = true; configured = true;
} }
void WidebandFMAudio::streaming_config(const SpectrumStreamingConfigMessage& message) {
if( message.mode == SpectrumStreamingConfigMessage::Mode::Running ) {
channel_spectrum.start();
} else {
channel_spectrum.stop();
}
}

View File

@ -62,8 +62,6 @@ private:
bool configured { false }; bool configured { false };
void configure(const WFMConfigureMessage& message); void configure(const WFMConfigureMessage& message);
void streaming_config(const SpectrumStreamingConfigMessage& message);
}; };
#endif/*__PROC_WFM_AUDIO_H__*/ #endif/*__PROC_WFM_AUDIO_H__*/

View File

@ -64,22 +64,11 @@ void WidebandSpectrum::execute(const buffer_c8_t& buffer) {
void WidebandSpectrum::on_message(const Message* const message) { void WidebandSpectrum::on_message(const Message* const message) {
switch(message->id) { switch(message->id) {
case Message::ID::UpdateSpectrum: case Message::ID::UpdateSpectrum:
channel_spectrum.update();
break;
case Message::ID::SpectrumStreamingConfig: case Message::ID::SpectrumStreamingConfig:
streaming_config(*reinterpret_cast<const SpectrumStreamingConfigMessage*>(message)); channel_spectrum.on_message(message);
break; break;
default: default:
break; break;
} }
} }
void WidebandSpectrum::streaming_config(const SpectrumStreamingConfigMessage& message) {
if( message.mode == SpectrumStreamingConfigMessage::Mode::Running ) {
channel_spectrum.start();
} else {
channel_spectrum.stop();
}
}

View File

@ -42,7 +42,6 @@ private:
std::array<complex16_t, 256> spectrum; std::array<complex16_t, 256> spectrum;
void streaming_config(const SpectrumStreamingConfigMessage& message);
size_t phase = 0; size_t phase = 0;
}; };

View File

@ -29,6 +29,29 @@
#include <algorithm> #include <algorithm>
void SpectrumCollector::on_message(const Message* const message) {
switch(message->id) {
case Message::ID::UpdateSpectrum:
update();
break;
case Message::ID::SpectrumStreamingConfig:
set_state(*reinterpret_cast<const SpectrumStreamingConfigMessage*>(message));
break;
default:
break;
}
}
void SpectrumCollector::set_state(const SpectrumStreamingConfigMessage& message) {
if( message.mode == SpectrumStreamingConfigMessage::Mode::Running ) {
start();
} else {
stop();
}
}
void SpectrumCollector::start() { void SpectrumCollector::start() {
streaming = true; streaming = true;
ChannelSpectrumConfigMessage message { &fifo }; ChannelSpectrumConfigMessage message { &fifo };

View File

@ -39,8 +39,7 @@ public:
{ {
} }
void start(); void on_message(const Message* const message);
void stop();
void set_decimation_factor(const size_t decimation_factor); void set_decimation_factor(const size_t decimation_factor);
@ -50,8 +49,6 @@ public:
const uint32_t filter_stop_frequency const uint32_t filter_stop_frequency
); );
void update();
private: private:
BlockDecimator<256> channel_spectrum_decimator; BlockDecimator<256> channel_spectrum_decimator;
ChannelSpectrumFIFO fifo; ChannelSpectrumFIFO fifo;
@ -64,6 +61,12 @@ private:
uint32_t channel_filter_stop_frequency { 0 }; uint32_t channel_filter_stop_frequency { 0 };
void post_message(const buffer_c16_t& data); void post_message(const buffer_c16_t& data);
void set_state(const SpectrumStreamingConfigMessage& message);
void start();
void stop();
void update();
}; };
#endif/*__SPECTRUM_COLLECTOR_H__*/ #endif/*__SPECTRUM_COLLECTOR_H__*/