From 3bba9c16b0428f1efb4e17c253511c615aa81f74 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Mon, 6 Aug 2018 11:06:44 +0200 Subject: [PATCH] hooks: remove map hook --- etc/example.conf | 31 ---------- lib/hooks/CMakeLists.txt | 1 - lib/hooks/map.c | 126 --------------------------------------- 3 files changed, 158 deletions(-) delete mode 100644 lib/hooks/map.c diff --git a/etc/example.conf b/etc/example.conf index 7510c3198..9ea618331 100644 --- a/etc/example.conf +++ b/etc/example.conf @@ -423,37 +423,6 @@ paths = ( mode = "origin", # Shift origin timestam of samples by +10 seconds offset = 10 # Seconds - }, - { # Remap values within a sample. - type = "map", # The values of the new samples are constructed - # from a concatenation of the following mapping entries. - map = [ - "data[0]", # The first value of the original sample - "data[2-5]", # Values 3-6 of the original sample - "hdr.sequence", # The sequence no of the original sample - "hdr.length", # The number of values of the original sample - "hdr.id", # The id of the original sample - "hdr.format", # A bitmask of the format of each value - "ts.origin", # The timestamp as sent by the origin simulator - "ts.received", # The timestamp of the arrival time of the original sample - "ts.send", # The timestamp when this sample was sent (does not work) - - # Statistics of the current path. Allowed stats are: - # owd One-way-delay (OWD) of received messages - # gap_sample Inter-message timestamps (as sent by remote) - # gap_received Inter-message arrival time (as seen by this instance) - # reordered Reordered samples and the distance between them - # skipped Skipped samples by hooks and the distance between them - - # For each stats the following details are available: - "stats.owd.last", # The last ovserved value - "stats.owd.highest", # The highest observed value - "stats.owd.lowest", # The lowest observed value - "stats.owd.mean", # The average observed value - "stats.owd.var", # The variance of the observed value - "stats.owd.stddev", # The standard deviation of the observed value - "stats.owd.total" # The total number ob observed values - ] } ) } diff --git a/lib/hooks/CMakeLists.txt b/lib/hooks/CMakeLists.txt index 636405ba0..59b7649f4 100644 --- a/lib/hooks/CMakeLists.txt +++ b/lib/hooks/CMakeLists.txt @@ -25,7 +25,6 @@ set(HOOK_SRC decimate.c drop.c jitter_calc.c - map.c restart.c shift_seq.c shift_ts.c diff --git a/lib/hooks/map.c b/lib/hooks/map.c deleted file mode 100644 index a178a237c..000000000 --- a/lib/hooks/map.c +++ /dev/null @@ -1,126 +0,0 @@ -/** Override a value of the sample with a header, timestamp or statistic value. - * - * @author Steffen Vogel - * @copyright 2017, Institute for Automation of Complex Power Systems, EONERC - * @license GNU General Public License (version 3) - * - * VILLASnode - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - *********************************************************************************/ - -/** @addtogroup hooks Hook functions - * @{ - */ - -#include -#include -#include -#include -#include -#include -#include - -struct map { - struct list mapping; - - struct stats *stats; -}; - -static int map_init(struct hook *h) -{ - struct map *m = (struct map *) h->_vd; - - m->stats = NULL; /** @todo */ - - return list_init(&m->mapping); -} - -static int map_destroy(struct hook *h) -{ - struct map *m = (struct map *) h->_vd; - - return list_destroy(&m->mapping, NULL, true); -} - -static int map_parse(struct hook *h, json_t *cfg) -{ - int ret; - struct map *m = (struct map *) h->_vd; - json_error_t err; - json_t *json_mapping; - - ret = json_unpack_ex(cfg, &err, 0, "{ s: o }", - "map", &json_mapping - ); - if (ret) - jerror(&err, "Failed to parse configuration of hook '%s'", plugin_name(h->_vt)); - - ret = mapping_parse_list(&m->mapping, json_mapping, NULL); - if (ret) - return ret; - - return 0; -} - -static int map_process(struct hook *h, struct sample *smps[], unsigned *cnt) -{ - int ret; - struct map *m = (struct map *) h->_vd; - struct sample *tmp[*cnt]; - struct pool *p; - - if (*cnt <= 0) - return 0; - - p = sample_pool(smps[0]); - if (!p) - return -1; - - ret = sample_alloc_many(p, tmp, *cnt); - if (ret != *cnt) - return ret; - - for (int i = 0; i < *cnt; i++) { - tmp[i]->format = 0; - tmp[i]->length = 0; - - mapping_remap(&m->mapping, tmp[i], smps[i], m->stats); - - SWAP(smps[i], tmp[i]); - } - - sample_free_many(tmp, *cnt); - - return 0; -} - -static struct plugin p = { - .name = "map", - .description = "Remap values and / or add header, timestamp values to the sample", - .type = PLUGIN_TYPE_HOOK, - .hook = { - .flags = HOOK_PATH, - .priority = 99, - .init = map_init, - .destroy= map_destroy, - .parse = map_parse, - .process= map_process, - .size = sizeof(struct map) - } -}; - -REGISTER_PLUGIN(&p); - -/** @} */