// lasp_threadedaps.h // // Author: J.A. de Jong - ASCEE // // Description: Real Time Spectrum Viewer #pragma once #include "lasp_avpowerspectra.h" #include "lasp_filter.h" #include "lasp_mathtypes.h" #include "lasp_threadedindatahandler.h" #include #include /** * \addtogroup dsp * @{ * * \addtogroup rt * @{ */ class RtAps : public ThreadedInDataHandler { std::mutex _mtx; std::unique_ptr _filterPrototype; std::vector> _freqWeightingFilter; bool _data_ready = false; std::unique_ptr _latest_est; AvPowerSpectra _ps; public: /** * @brief Initialize RtAps. * * @param mgr StreamMgr singleton reference * @param freqWeightingFilter Optionally: the frequency weighting filter. * Nullptr should be given for Z-weighting. * @param For all other arguments, see constructor of AvPowerSpectra */ RtAps(StreamMgr &mgr, const Filter *freqWeightingFilter, const us nfft = 2048, const Window::WindowType w = Window::WindowType::Hann, const d overlap_percentage = 50., const d time_constant = -1) : ThreadedInDataHandler(mgr), _ps(nfft, w, overlap_percentage, time_constant) { { std::scoped_lock lck(_mtx); if (freqWeightingFilter != nullptr) { _filterPrototype = freqWeightingFilter->clone(); } } start(); } ~RtAps() { std::scoped_lock lck(_mtx); stop(); } /** * @brief Get the latest estimate of the power spectra * * @return Optionally, if available, the latest values */ std::unique_ptr getCurrentValue(); bool inCallback_threaded(const DaqData &) override final; void reset(const Daq *) override final; }; /** @} */ /** @} */