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:
parent
76bfd3f6f4
commit
5a6c135083
2 changed files with 8 additions and 2 deletions
|
@ -31,6 +31,7 @@ class DecimateHook : public LimitHook {
|
|||
|
||||
protected:
|
||||
int ratio;
|
||||
bool renumber;
|
||||
unsigned counter;
|
||||
|
||||
public:
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue