73 lines
1.7 KiB
C++
73 lines
1.7 KiB
C++
// 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 <memory>
|
|
#include <mutex>
|
|
|
|
/**
|
|
* \addtogroup dsp
|
|
* @{
|
|
*
|
|
* \addtogroup rt
|
|
* @{
|
|
*/
|
|
|
|
class RtAps : public ThreadedInDataHandler {
|
|
|
|
std::mutex _mtx;
|
|
std::unique_ptr<Filter> _filterPrototype;
|
|
std::vector<std::unique_ptr<Filter>> _freqWeightingFilter;
|
|
bool _data_ready = false;
|
|
std::unique_ptr<cube> _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<std::mutex> lck(_mtx);
|
|
if (freqWeightingFilter != nullptr) {
|
|
_filterPrototype = freqWeightingFilter->clone();
|
|
}
|
|
}
|
|
start();
|
|
}
|
|
~RtAps() {
|
|
std::scoped_lock<std::mutex> lck(_mtx);
|
|
stop();
|
|
}
|
|
|
|
/**
|
|
* @brief Get the latest estimate of the power spectra
|
|
*
|
|
* @return Optionally, if available, the latest values
|
|
*/
|
|
std::unique_ptr<cube> getCurrentValue();
|
|
|
|
bool inCallback_threaded(const DaqData &) override final;
|
|
void reset(const Daq *) override final;
|
|
};
|
|
|
|
/** @} */
|
|
/** @} */
|