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

node: inherit certain configuration settings for directions

This commit is contained in:
Steffen Vogel 2018-05-26 01:10:33 +02:00
parent acee6a5bed
commit 6a7821467a

View file

@ -93,10 +93,21 @@ static int node_direction_parse(struct node_direction *nd, struct node *n, json_
{
int ret;
json_error_t err;
json_t *json_hooks = NULL;
json_t *json_signals = NULL;
json_error_t err;
nd->cfg = cfg;
/* Before we start parsing, we will fill in a few default settings from the node config */
const char *fields[] = { "builtin", "vectorize", "signals", "hooks" };
for (int i = 0; i < ARRAY_LEN(fields); i++) {
json_t *json_field_dir = json_object_get(cfg, fields[i]);
json_t *json_field_node = json_object_get(n->cfg, fields[i]);
if (json_field_node && !json_field_dir)
json_object_set(cfg, fields[i], json_field_node);
}
ret = json_unpack_ex(cfg, &err, 0, "{ s?: o, s?: o, s?: i, s?: b }",
"hooks", &json_hooks,
@ -228,6 +239,8 @@ int node_parse(struct node *n, json_t *cfg, const char *name)
nt = node_type_lookup(type);
assert(nt == n->_vt);
n->cfg = cfg;
if (json_in) {
ret = node_direction_parse(&n->in, n, json_in);
if (ret)
@ -244,7 +257,6 @@ int node_parse(struct node *n, json_t *cfg, const char *name)
if (ret)
error("Failed to parse node '%s'", node_name(n));
n->cfg = cfg;
n->state = STATE_PARSED;
return ret;