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

io: add header to villas.human and json formats

This commit is contained in:
Steffen Vogel 2018-05-12 18:02:18 +02:00
parent 71218e939c
commit d5d446cca6
2 changed files with 34 additions and 2 deletions

View file

@ -28,6 +28,7 @@
#include <villas/formats/csv.h>
#include <villas/plugin.h>
#include <villas/sample.h>
#include <villas/signal.h>
#include <villas/timing.h>
size_t csv_sprint_single(struct io *io, char *buf, size_t len, struct sample *s)
@ -159,7 +160,22 @@ void csv_header(struct io *io)
{
FILE *f = io_stream_output(io);
fprintf(f, "# secs%cnsecs%coffset%csequence%cdata[]\n", CSV_SEPARATOR, CSV_SEPARATOR, CSV_SEPARATOR, CSV_SEPARATOR);
fprintf(f, "# secs%cnsecs%coffset%csequence", CSV_SEPARATOR, CSV_SEPARATOR, CSV_SEPARATOR);
if (io->output.signals) {
for (int i = 0; i < list_length(io->output.signals); i++) {
struct signal *s = (struct signal *) list_at(io->output.signals, i);
fprintf(f, "%c%s", CSV_SEPARATOR, s->name);
if (s->unit)
fprintf(f, "[%s]", s->unit);
}
}
else
fprintf(f, "%cdata[]", CSV_SEPARATOR);
fprintf(f, "\n");
}
static struct plugin p = {

View file

@ -29,6 +29,7 @@
#include <villas/utils.h>
#include <villas/timing.h>
#include <villas/sample.h>
#include <villas/signal.h>
#include <villas/formats/villas_human.h>
size_t villas_human_sprint_single(struct io *io, char *buf, size_t len, struct sample *s)
@ -190,7 +191,22 @@ void villas_human_header(struct io *io)
{
FILE *f = io_stream_output(io);
fprintf(f, "# %-20s\t\t%s\n", "sec.nsec+offset", "data[]");
fprintf(f, "# %-20s", "sec.nsec+offset");
if (io->output.signals) {
for (int i = 0; i < list_length(io->output.signals); i++) {
struct signal *s = (struct signal *) list_at(io->output.signals, i);
fprintf(f, "\t%s", s->name);
if (s->unit)
fprintf(f, "[%s]", s->unit);
}
}
else
fprintf(f, "\tdata[]");
fprintf(f, "\n");
}
static struct plugin p = {