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

json.reserve: fix parsing of timestamp and values

This commit is contained in:
Steffen Vogel 2018-05-26 02:23:00 +02:00
parent 3fad36b62b
commit f054d92845

View file

@ -39,7 +39,7 @@ static int json_reserve_pack_sample(struct io *io, json_t **j, struct sample *sm
struct signal *sig;
if (smp->flags & SAMPLE_HAS_ORIGIN)
json_created = json_real(time_to_double(&smp->ts.origin));
json_created = json_integer(time_to_double(&smp->ts.origin) * 1e3);
if (smp->flags & SAMPLE_HAS_SEQUENCE)
json_sequence = json_integer(smp->sequence);
@ -175,7 +175,7 @@ static int json_reserve_unpack_sample(struct io *io, json_t *json_smp, struct sa
const char *name, *unit = NULL;
double value;
ret = json_unpack_ex(json_value, &err, 0, "{ s: s, s?: s, s: f, s?: F }",
ret = json_unpack_ex(json_value, &err, 0, "{ s: s, s?: s, s: F, s?: F }",
"name", &name,
"unit", &unit,
"value", &value,
@ -211,7 +211,7 @@ static int json_reserve_unpack_sample(struct io *io, json_t *json_smp, struct sa
smp->flags |= SAMPLE_HAS_VALUES;
if (created > 0) {
smp->ts.origin = time_from_double(created);
smp->ts.origin = time_from_double(created * 1e-3);
smp->flags |= SAMPLE_HAS_ORIGIN;
}