2020-08-30 22:03:41 +02:00
|
|
|
#ifndef AVERAGING_H
|
|
|
|
|
#define AVERAGING_H
|
|
|
|
|
|
|
|
|
|
#include "Device/device.h"
|
2022-03-17 18:24:18 +01:00
|
|
|
#include "VNA/vnadata.h"
|
2021-10-21 13:00:34 +02:00
|
|
|
|
2021-02-05 16:41:16 +01:00
|
|
|
#include <array>
|
2020-08-30 22:03:41 +02:00
|
|
|
#include <deque>
|
|
|
|
|
#include <complex>
|
|
|
|
|
|
|
|
|
|
class Averaging
|
|
|
|
|
{
|
|
|
|
|
public:
|
2021-12-01 22:11:50 +01:00
|
|
|
enum class Mode {
|
|
|
|
|
Mean,
|
|
|
|
|
Median
|
|
|
|
|
};
|
|
|
|
|
|
2020-08-30 22:03:41 +02:00
|
|
|
Averaging();
|
2020-10-29 19:27:04 +01:00
|
|
|
void reset(unsigned int points);
|
2020-08-30 22:03:41 +02:00
|
|
|
void setAverages(unsigned int a);
|
2022-03-17 18:24:18 +01:00
|
|
|
VNAData process(VNAData d);
|
2020-09-17 15:51:20 +02:00
|
|
|
Protocol::SpectrumAnalyzerResult process(Protocol::SpectrumAnalyzerResult d);
|
2020-10-29 19:27:04 +01:00
|
|
|
// Returns the number of averaged sweeps. Value is incremented whenever the last point of the sweep is added.
|
|
|
|
|
// Returned values are in range 0 to averages
|
2020-08-30 22:03:41 +02:00
|
|
|
unsigned int getLevel();
|
2020-10-29 19:27:04 +01:00
|
|
|
// Returns the number of the currently active sweep. Value is incremented whenever the the first point of the sweep is added
|
|
|
|
|
// Returned values are in range 0 (when no data has been added yet) to averages
|
|
|
|
|
unsigned int currentSweep();
|
2021-12-01 22:11:50 +01:00
|
|
|
Mode getMode() const;
|
|
|
|
|
void setMode(const Mode &value);
|
|
|
|
|
|
2020-08-30 22:03:41 +02:00
|
|
|
private:
|
|
|
|
|
std::vector<std::deque<std::array<std::complex<double>, 4>>> avg;
|
|
|
|
|
int maxPoints;
|
|
|
|
|
unsigned int averages;
|
2021-12-01 22:11:50 +01:00
|
|
|
Mode mode;
|
2020-08-30 22:03:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // AVERAGING_H
|