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

add renumbering for decimate to allow detection of missed samples even if decimating

This commit is contained in:
Manuel Pitz 2022-03-22 18:15:28 +01:00
parent 76bfd3f6f4
commit 5a6c135083
2 changed files with 8 additions and 2 deletions

View file

@ -31,6 +31,7 @@ class DecimateHook : public LimitHook {
protected:
int ratio;
bool renumber;
unsigned counter;
public:

View file

@ -21,6 +21,7 @@
*********************************************************************************/
#include <villas/hooks/decimate.hpp>
#include <villas/sample.hpp>
namespace villas {
namespace node {
@ -43,8 +44,9 @@ void DecimateHook::parse(json_t *json)
Hook::parse(json);
ret = json_unpack_ex(json, &err, 0, "{ s: i }",
"ratio", &ratio
ret = json_unpack_ex(json, &err, 0, "{ s: i, s?: b }",
"ratio", &ratio,
"renumber", &renumber
);
if (ret)
throw ConfigError(json, err, "node-config-hook-decimate");
@ -56,6 +58,9 @@ Hook::Reason DecimateHook::process(struct Sample *smp)
{
assert(state == State::STARTED);
if (renumber)
smp->sequence /= ratio;
if (ratio && counter++ % ratio != 0)
return Hook::Reason::SKIP_SAMPLE;