From 5a6c135083919c05baa47206d55138c4fe0310ef Mon Sep 17 00:00:00 2001 From: Manuel Pitz Date: Tue, 22 Mar 2022 18:15:28 +0100 Subject: [PATCH] add renumbering for decimate to allow detection of missed samples even if decimating --- include/villas/hooks/decimate.hpp | 1 + lib/hooks/decimate.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/villas/hooks/decimate.hpp b/include/villas/hooks/decimate.hpp index 03ea9e525..6d8f792a1 100644 --- a/include/villas/hooks/decimate.hpp +++ b/include/villas/hooks/decimate.hpp @@ -31,6 +31,7 @@ class DecimateHook : public LimitHook { protected: int ratio; + bool renumber; unsigned counter; public: diff --git a/lib/hooks/decimate.cpp b/lib/hooks/decimate.cpp index fc27af2a3..517e1c36d 100644 --- a/lib/hooks/decimate.cpp +++ b/lib/hooks/decimate.cpp @@ -21,6 +21,7 @@ *********************************************************************************/ #include +#include 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;