lasp/cpp_src/dsp/lasp_rtaps.h

78 lines
1.8 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
* @{
*/
/**
* @brief Real time spectral estimator using Welch method of spectral
* estimation.
*/
class RtAps : public ThreadedInDataHandler<RtAps> {
std::unique_ptr<Filter> _filterPrototype;
std::vector<std::unique_ptr<Filter>> _freqWeightingFilters;
/**
* @brief Storage for sensitivity values
*/
vd _sens;
/**
* @brief Mutex only for _ps. Other members are only accessed in thread.
*/
mutable std::mutex _ps_mtx;
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.
*
* For all other arguments, see constructor of AvPowerSpectra
*/
RtAps(SmgrHandle 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);
~RtAps();
/**
* @brief Get the latest estimate of the power spectra
*
* @return If available, the latest estimate. If no estimate available, an
* empty ccube().
*/
ccube getCurrentValue() const;
/**
* @brief Implements the work to to when new DaqData arrives
*
* @param d DaqData to use for computing/updating spectra
*
* @return true if stream should continue.
*/
void inCallback(const DaqData & d);
void reset(const Daq *);
};
/** @} */
/** @} */