LibreVNA/Software/PC_Application/averaging.h

43 lines
1.2 KiB
C
Raw Normal View History

#ifndef AVERAGING_H
#define AVERAGING_H
2022-08-05 02:12:15 +08:00
#include "Device/virtualdevice.h"
2021-10-21 19:00:34 +08:00
2021-02-05 23:41:16 +08:00
#include <array>
#include <deque>
#include <complex>
class Averaging
{
public:
2021-12-02 05:11:50 +08:00
enum class Mode {
Mean,
Median
};
Averaging();
void reset(unsigned int points);
void setAverages(unsigned int a);
2022-08-05 02:12:15 +08:00
VirtualDevice::VNAMeasurement process(VirtualDevice::VNAMeasurement d);
2022-08-04 23:31:24 +08:00
VirtualDevice::SAMeasurement process(VirtualDevice::SAMeasurement d);
// 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
unsigned int getLevel();
// 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-02 05:11:50 +08:00
Mode getMode() const;
void setMode(const Mode &value);
private:
2022-08-05 18:20:41 +08:00
void process(unsigned int pointNum, std::vector<std::complex<double> > &data);
2022-08-05 02:12:15 +08:00
2022-08-04 23:31:24 +08:00
std::vector<std::deque<std::vector<std::complex<double>>>> avg;
int maxPoints;
2022-08-05 18:20:41 +08:00
unsigned int numMeasurements;
unsigned int averages;
2021-12-02 05:11:50 +08:00
Mode mode;
};
#endif // AVERAGING_H