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

hooks: remove map hook

This commit is contained in:
Steffen Vogel 2018-08-06 11:06:44 +02:00
parent a1e47d2d72
commit 3bba9c16b0
3 changed files with 0 additions and 158 deletions

View file

@ -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
]
}
)
}

View file

@ -25,7 +25,6 @@ set(HOOK_SRC
decimate.c
drop.c
jitter_calc.c
map.c
restart.c
shift_seq.c
shift_ts.c

View file

@ -1,126 +0,0 @@
/** Override a value of the sample with a header, timestamp or statistic value.
*
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @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 <http://www.gnu.org/licenses/>.
*********************************************************************************/
/** @addtogroup hooks Hook functions
* @{
*/
#include <villas/plugin.h>
#include <villas/mapping.h>
#include <villas/list.h>
#include <villas/utils.h>
#include <villas/path.h>
#include <villas/sample.h>
#include <villas/node.h>
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);
/** @} */