mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
add avg capabilities
This commit is contained in:
parent
6e0c7a9fe7
commit
3a7ddb0f75
1 changed files with 5 additions and 3 deletions
|
@ -42,7 +42,7 @@ protected:
|
|||
unsigned idx;
|
||||
uint avg_length;//number of seconds over which the samplerate value will be averaged
|
||||
uint avg_pos;
|
||||
double *avg_array;
|
||||
double* avg_array;
|
||||
int lastSeqNr;
|
||||
unsigned edgeCounter;
|
||||
|
||||
|
@ -56,6 +56,7 @@ public:
|
|||
realSmpRateAvg(0),
|
||||
idx(0),
|
||||
avg_length(1),
|
||||
avg_pos(0),
|
||||
lastSeqNr(0),
|
||||
edgeCounter(0),
|
||||
realTime({ 0, 0 })
|
||||
|
@ -82,7 +83,7 @@ public:
|
|||
info("parsed config thresh=%f signal_index=%d", thresh, idx);
|
||||
|
||||
avg_array = new double[avg_length];
|
||||
avg_array = {0};
|
||||
//avg_array = {0};
|
||||
|
||||
|
||||
state = State::PARSED;
|
||||
|
@ -104,6 +105,7 @@ public:
|
|||
|
||||
realSmpRateAvg += (currentSmpRate - avg_array[avg_pos % avg_length]) / avg_length;
|
||||
avg_array[avg_pos % avg_length] = currentSmpRate;
|
||||
avg_pos++;
|
||||
}
|
||||
if (edgeCounter == 1) {
|
||||
auto now = time_now();
|
||||
|
@ -116,7 +118,7 @@ public:
|
|||
|
||||
lastSeqNr = seqNr;
|
||||
|
||||
info("Edge detected: seq=%u, realTime.sec=%ld, realTime.nsec=%ld, smpRate=%f", seqNr, realTime.tv_sec, realTime.tv_nsec, realSmpRateAvg);
|
||||
info("Edge detected: seq=%u, realTime.sec=%ld, realTime.nsec=%ld, smpRate=%f.10", seqNr, realTime.tv_sec, realTime.tv_nsec, realSmpRateAvg);
|
||||
|
||||
edgeCounter++;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue