2017-03-25 21:11:52 +01:00
|
|
|
/** Sample value remapping for mux.
|
|
|
|
*
|
2017-04-03 09:01:14 +02:00
|
|
|
* @file
|
2017-03-25 21:11:52 +01:00
|
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
|
|
|
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
2017-04-27 12:56:43 +02:00
|
|
|
* @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.
|
2017-05-05 19:24:16 +00:00
|
|
|
*
|
2017-04-27 12:56:43 +02:00
|
|
|
* 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.
|
2017-05-05 19:24:16 +00:00
|
|
|
*
|
2017-04-27 12:56:43 +02:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-03-25 21:11:52 +01:00
|
|
|
*********************************************************************************/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-08-03 00:19:27 +02:00
|
|
|
#include <jansson.h>
|
2017-03-25 21:11:52 +01:00
|
|
|
|
2018-06-29 09:06:04 +02:00
|
|
|
#include <villas/stats.h>
|
|
|
|
#include <villas/common.h>
|
|
|
|
#include <villas/list.h>
|
2017-03-25 21:11:52 +01:00
|
|
|
|
2018-06-28 13:42:50 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2017-03-25 21:11:52 +01:00
|
|
|
/* Forward declarations */
|
|
|
|
struct stats;
|
|
|
|
struct node;
|
|
|
|
struct sample;
|
|
|
|
struct list;
|
|
|
|
|
|
|
|
struct mapping_entry {
|
2017-08-28 12:48:15 +02:00
|
|
|
struct node *node;
|
2017-08-28 14:35:50 +02:00
|
|
|
|
2018-06-29 08:37:14 +02:00
|
|
|
int offset; /**< Offset of this mapping entry within sample::data */
|
|
|
|
int length; /**< The number of values which is covered by this mapping entry. */
|
2017-03-25 21:11:52 +01:00
|
|
|
|
|
|
|
enum {
|
|
|
|
MAPPING_TYPE_DATA,
|
|
|
|
MAPPING_TYPE_STATS,
|
2017-08-28 14:35:50 +02:00
|
|
|
MAPPING_TYPE_HDR,
|
|
|
|
MAPPING_TYPE_TS
|
2017-03-25 21:11:52 +01:00
|
|
|
} type;
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
int offset;
|
|
|
|
} data;
|
2017-08-28 14:35:50 +02:00
|
|
|
|
2017-03-25 21:11:52 +01:00
|
|
|
struct {
|
|
|
|
enum stats_id id;
|
|
|
|
enum stats_type {
|
|
|
|
MAPPING_STATS_TYPE_LAST,
|
|
|
|
MAPPING_STATS_TYPE_HIGHEST,
|
|
|
|
MAPPING_STATS_TYPE_LOWEST,
|
|
|
|
MAPPING_STATS_TYPE_MEAN,
|
|
|
|
MAPPING_STATS_TYPE_VAR,
|
|
|
|
MAPPING_STATS_TYPE_STDDEV,
|
|
|
|
MAPPING_STATS_TYPE_TOTAL
|
|
|
|
} type;
|
|
|
|
} stats;
|
2017-08-28 14:35:50 +02:00
|
|
|
|
2017-03-25 21:11:52 +01:00
|
|
|
struct {
|
|
|
|
enum header_type {
|
2017-08-28 14:35:50 +02:00
|
|
|
MAPPING_HDR_LENGTH,
|
|
|
|
MAPPING_HDR_SEQUENCE,
|
2017-08-30 16:37:19 +02:00
|
|
|
MAPPING_HDR_FORMAT
|
2017-03-25 21:11:52 +01:00
|
|
|
} id;
|
2017-08-28 14:35:50 +02:00
|
|
|
} hdr;
|
|
|
|
|
2017-03-25 21:11:52 +01:00
|
|
|
struct {
|
|
|
|
enum timestamp_type {
|
2017-08-28 14:35:50 +02:00
|
|
|
MAPPING_TS_ORIGIN,
|
|
|
|
MAPPING_TS_RECEIVED,
|
|
|
|
MAPPING_TS_SEND
|
2017-03-25 21:11:52 +01:00
|
|
|
} id;
|
2017-08-28 14:35:50 +02:00
|
|
|
} ts;
|
2017-03-25 21:11:52 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-06-29 08:37:14 +02:00
|
|
|
int mapping_remap(struct list *m, struct sample *remapped, struct sample *original, struct stats *s);
|
2017-08-30 23:52:32 +02:00
|
|
|
|
2018-07-03 20:43:05 +02:00
|
|
|
int mapping_update(struct mapping_entry *e, struct sample *remapped, struct sample *original, struct stats *s);
|
2017-03-25 21:11:52 +01:00
|
|
|
|
2017-08-28 14:35:50 +02:00
|
|
|
int mapping_parse(struct mapping_entry *e, json_t *cfg, struct list *nodes);
|
2017-03-25 21:11:52 +01:00
|
|
|
|
2017-08-28 14:35:50 +02:00
|
|
|
int mapping_parse_str(struct mapping_entry *e, const char *str, struct list *nodes);
|
2017-08-31 09:42:36 +02:00
|
|
|
|
|
|
|
int mapping_parse_list(struct list *l, json_t *cfg, struct list *nodes);
|
2018-06-28 13:42:50 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|