lasp/src/lasp/dsp/lasp_rtaps.cpp

84 lines
2.2 KiB
C++

#define DEBUGTRACE_ENABLED
#include "lasp_rtaps.h"
#include "debugtrace.hpp"
#include <mutex>
using std::cerr;
using std::endl;
RtAps::RtAps(StreamMgr &mgr, const Filter *freqWeightingFilter,
const us nfft,
const Window::WindowType w,
const d overlap_percentage, const d time_constant)
: ThreadedInDataHandler(mgr),
_ps(nfft, w, overlap_percentage, time_constant) {
/* if (freqWeightingFilter != nullptr) { */
/* _filterPrototype = freqWeightingFilter->clone(); */
/* } */
start();
}
RtAps::~RtAps() {
std::scoped_lock<std::mutex> lck(_mtx);
stop();
}
bool RtAps::inCallback_threaded(const DaqData &data) {
DEBUGTRACE_ENTER;
std::scoped_lock<std::mutex> lck(_mtx);
dmat fltdata = data.toFloat();
data.print();
/* const us nchannels = fltdata.n_cols; */
/* if (_filterPrototype) { */
/* // Adjust number of filters, if necessary */
/* if (nchannels > _freqWeightingFilter.size()) { */
/* while (nchannels > _freqWeightingFilter.size()) { */
/* _freqWeightingFilter.emplace_back(_filterPrototype->clone()); */
/* } */
/* for (auto &filter : _freqWeightingFilter) { */
/* filter->reset(); */
/* } */
/* } */
/* // Apply filtering */
/* #pragma omp parallel for */
/* for (us i = 0; i < nchannels; i++) { */
/* vd col = fltdata.col(i); */
/* _freqWeightingFilter.at(i)->filter(col); */
/* fltdata.col(i) = col; */
/* } */
/* } // End of if(_filterPrototype) */
_ps.compute(fltdata);
return true;
}
void RtAps::reset(const Daq *daq) { // Explicitly say
// to GCC that
// the argument is
// not used.
DEBUGTRACE_ENTER;
std::scoped_lock<std::mutex> lck(_mtx);
_ps.reset();
}
std::unique_ptr<ccube> RtAps::getCurrentValue() {
/* DEBUGTRACE_ENTER; */
std::scoped_lock<std::mutex> lck(_mtx);
auto est = _ps.get_est();
return std::make_unique<ccube>(est.value_or(ccube()));
/* return std::move(_latest_est); */
/* if (_latest_est) { */
/* return std::make_unique<cube>(cube(*_latest_est)); */
/* } else */
/* return nullptr; */
}