1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00
VILLASnode/include/villas/hooks/pmu.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
1.6 KiB
C++
Raw Permalink Normal View History

2022-06-01 18:15:29 +02:00
/* PMU hook.
*
* Author: Manuel Pitz <manuel.pitz@eonerc.rwth-aachen.de>
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
2022-07-04 18:20:03 +02:00
* SPDX-License-Identifier: Apache-2.0
2022-06-01 18:15:29 +02:00
*/
#include <villas/dsp/window_cosine.hpp>
#include <villas/hook.hpp>
#include <villas/sample.hpp>
namespace villas {
namespace node {
class PmuHook : public MultiSignalHook {
protected:
enum class Status { INVALID, VALID };
struct Phasor {
double frequency;
double amplitude;
double phase;
double rocof; // Rate of change of frequency.
Status valid;
};
enum class WindowType { NONE, FLATTOP, HANN, HAMMING, NUTTAL, BLACKMAN };
enum class TimeAlign {
LEFT,
CENTER,
RIGHT,
};
std::vector<dsp::CosineWindow<double> *> windows;
dsp::Window<timespec> *windowsTs;
std::vector<Phasor> lastPhasors;
enum TimeAlign timeAlignType;
enum WindowType windowType;
unsigned sampleRate;
double phasorRate;
double nominalFreq;
double numberPlc;
unsigned windowSize;
bool channelNameEnable;
double angleUnitFactor;
uint64_t lastSequence;
timespec nextRun;
bool init;
unsigned initSampleCount;
// Correction factors.
double phaseOffset;
double amplitudeOffset;
double frequencyOffset;
double rocofOffset;
2022-06-01 18:15:29 +02:00
public:
PmuHook(Path *p, Node *n, int fl, int prio, bool en = true);
2022-06-01 18:15:29 +02:00
virtual void prepare();
2022-06-01 18:15:29 +02:00
virtual void parse(json_t *json);
2022-06-01 18:15:29 +02:00
virtual Hook::Reason process(struct Sample *smp);
2022-06-01 18:15:29 +02:00
virtual Phasor estimatePhasor(dsp::CosineWindow<double> *window,
Phasor lastPhasor);
2022-06-01 18:15:29 +02:00
};
} // namespace node
} // namespace villas