2022-10-06 19:13:21 +00:00
|
|
|
// 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
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2023-01-05 09:35:47 +00:00
|
|
|
/**
|
|
|
|
* @brief Real time spectral estimator using Welch method of spectral
|
|
|
|
* estimation.
|
|
|
|
*/
|
2023-06-09 08:43:04 +00:00
|
|
|
class RtAps : public ThreadedInDataHandler<RtAps> {
|
2022-10-06 19:13:21 +00:00
|
|
|
|
|
|
|
std::unique_ptr<Filter> _filterPrototype;
|
2022-10-16 16:39:13 +00:00
|
|
|
std::vector<std::unique_ptr<Filter>> _freqWeightingFilters;
|
2022-10-06 19:13:21 +00:00
|
|
|
|
2022-10-17 17:37:31 +00:00
|
|
|
/**
|
|
|
|
* @brief Storage for sensitivity values
|
|
|
|
*/
|
|
|
|
vd _sens;
|
|
|
|
|
2022-10-16 19:26:06 +00:00
|
|
|
/**
|
|
|
|
* @brief Mutex only for _ps. Other members are only accessed in thread.
|
|
|
|
*/
|
|
|
|
mutable std::mutex _ps_mtx;
|
2022-10-06 19:13:21 +00:00
|
|
|
AvPowerSpectra _ps;
|
|
|
|
|
2022-10-06 19:48:57 +00:00
|
|
|
public:
|
2022-10-06 19:13:21 +00:00
|
|
|
/**
|
|
|
|
* @brief Initialize RtAps.
|
|
|
|
*
|
|
|
|
* @param mgr StreamMgr singleton reference
|
|
|
|
* @param freqWeightingFilter Optionally: the frequency weighting filter.
|
|
|
|
* Nullptr should be given for Z-weighting.
|
2023-01-20 14:59:08 +00:00
|
|
|
*
|
|
|
|
* For all other arguments, see constructor of AvPowerSpectra
|
2022-10-06 19:13:21 +00:00
|
|
|
*/
|
2023-06-07 19:49:07 +00:00
|
|
|
RtAps(SmgrHandle mgr, const Filter *freqWeightingFilter, const us nfft = 2048,
|
2022-10-06 19:48:57 +00:00
|
|
|
const Window::WindowType w = Window::WindowType::Hann,
|
2022-10-11 12:50:44 +00:00
|
|
|
const d overlap_percentage = 50., const d time_constant = -1);
|
|
|
|
~RtAps();
|
2022-10-06 19:13:21 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the latest estimate of the power spectra
|
|
|
|
*
|
2022-10-16 19:26:06 +00:00
|
|
|
* @return If available, the latest estimate. If no estimate available, an
|
|
|
|
* empty ccube().
|
2022-10-06 19:13:21 +00:00
|
|
|
*/
|
2022-10-16 19:26:06 +00:00
|
|
|
ccube getCurrentValue() const;
|
2022-10-06 19:13:21 +00:00
|
|
|
|
2023-01-20 14:59:08 +00:00
|
|
|
/**
|
|
|
|
* @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.
|
|
|
|
*/
|
2023-06-09 08:43:04 +00:00
|
|
|
void inCallback(const DaqData & d);
|
|
|
|
void reset(const Daq *);
|
2022-10-06 19:13:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** @} */
|
|
|
|
/** @} */
|