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

json: accept integers for floating point settings

This commit is contained in:
Steffen Vogel 2017-09-04 23:16:58 +02:00
parent a45b39b07a
commit 12973f9088
7 changed files with 17 additions and 17 deletions

View file

@ -55,7 +55,7 @@ static int shift_ts_parse(struct hook *h, json_t *cfg)
int ret;
json_error_t err;
ret = json_unpack_ex(cfg, &err, 0, "{ s?: s, s: f }",
ret = json_unpack_ex(cfg, &err, 0, "{ s?: s, s: F }",
"mode", &mode,
"offset", &offset
);

View file

@ -24,7 +24,7 @@ int cbuilder_parse(struct node *n, json_t *cfg)
size_t index;
json_error_t err;
ret = json_unpack_ex(cfg, &err, 0, "{ s: f, s: s, s: b }",
ret = json_unpack_ex(cfg, &err, 0, "{ s: F, s: s, s: b }",
"timestep", &cb->timestep,
"model", &model,
"parameters", &cfg_params
@ -62,7 +62,7 @@ int cbuilder_start(struct node *n)
/* Initialize mutex and cv */
pthread_mutex_init(&cb->mtx, NULL);
cb->eventfd = eventfd(0, 0);
if (cb->eventfd < 0)
return -1;
@ -84,7 +84,7 @@ int cbuilder_stop(struct node *n)
{
int ret;
struct cbuilder *cb = n->_vd;
ret = close(cb->eventfd);
if (ret)
return ret;
@ -98,14 +98,14 @@ int cbuilder_read(struct node *n, struct sample *smps[], unsigned cnt)
{
struct cbuilder *cb = n->_vd;
struct sample *smp = smps[0];
uint64_t cntr;
read(cb->eventfd, &cntr, sizeof(cntr));
/* Wait for completion of step */
pthread_mutex_lock(&cb->mtx);
float data[smp->capacity];
smp->length = cb->model->read(data, smp->capacity);
@ -113,7 +113,7 @@ int cbuilder_read(struct node *n, struct sample *smps[], unsigned cnt)
/* Cast float -> double */
for (int i = 0; i < smp->length; i++)
smp->data[i].f = data[i];
smp->sequence = cb->step;
cb->read = cb->step;
@ -129,14 +129,14 @@ int cbuilder_write(struct node *n, struct sample *smps[], unsigned cnt)
struct sample *smp = smps[0];
pthread_mutex_lock(&cb->mtx);
float flt = smp->data[0].f;
cb->model->write(&flt, smp->length);
cb->model->code();
cb->step++;
uint64_t incr = 1;
write(cb->eventfd, &incr, sizeof(incr));
@ -148,7 +148,7 @@ int cbuilder_write(struct node *n, struct sample *smps[], unsigned cnt)
int cbuilder_fd(struct node *n)
{
struct cbuilder *cb = n->_vd;
return cb->eventfd;
}

View file

@ -90,7 +90,7 @@ int file_parse(struct node *n, json_t *cfg)
f->epoch_mode = FILE_EPOCH_DIRECT;
f->flush = 0;
ret = json_unpack_ex(cfg, &err, 0, "{ s: s, s?: b, s?: s, s?: f, s?: s, s?: f, s?: s }",
ret = json_unpack_ex(cfg, &err, 0, "{ s: s, s?: b, s?: s, s?: F, s?: s, s?: F, s?: s }",
"uri", &uri_tmpl,
"flush", &f->flush,
"eof", &eof,

View file

@ -418,7 +418,7 @@ int ngsi_parse(struct node *n, json_t *cfg)
i->timeout = 1; /* default value */
i->rate = 5; /* default value */
ret = json_unpack_ex(cfg, &err, 0, "{ s?: s, s: s, s: s, s: s, s?: b, s?: f, s?: f }",
ret = json_unpack_ex(cfg, &err, 0, "{ s?: s, s: s, s: s, s: s, s?: b, s?: F, s?: F }",
"access_token", &i->access_token,
"endpoint", &i->endpoint,
"entity_id", &i->entity_id,
@ -576,7 +576,7 @@ int ngsi_write(struct node *n, struct sample *smps[], unsigned cnt)
int ngsi_fd(struct node *n)
{
struct ngsi *i = n->_vd;
return task_fd(&i->task);
}

View file

@ -67,7 +67,7 @@ int signal_parse(struct node *n, json_t *cfg)
s->stddev = 0.2;
s->offset = 0;
ret = json_unpack_ex(cfg, &err, 0, "{ s?: s, s?: b, s?: i, s?: i, s?: f, s?: f, s?: f, s?: f, s?: f }",
ret = json_unpack_ex(cfg, &err, 0, "{ s?: s, s?: b, s?: i, s?: i, s?: F, s?: F, s?: F, s?: F, s?: F }",
"signal", &type,
"realtime", &s->rt,
"limit", &s->limit,

View file

@ -88,7 +88,7 @@ int stats_node_parse(struct node *n, json_t *cfg)
const char *node;
ret = json_unpack_ex(cfg, &err, 0, "{ s: s, s: f }",
ret = json_unpack_ex(cfg, &err, 0, "{ s: s, s: F }",
"node", &node,
"rate", &s->rate
);

View file

@ -75,7 +75,7 @@ int test_rtt_parse(struct node *n, json_t *cfg)
t->cooldown = 1.0;
ret = json_unpack_ex(cfg, &err, 0, "{ s?: i, s?: s, s?: s, s: f, s: o, s: o }",
ret = json_unpack_ex(cfg, &err, 0, "{ s?: i, s?: s, s?: s, s: F, s: o, s: o }",
"limit", &limit,
"output", &output,
"format", &format,