mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
hooks: adapt to new signal code and separate node-type configuration into in/out sections
This commit is contained in:
parent
52c9639d9c
commit
1c59bb6d60
2 changed files with 24 additions and 10 deletions
|
@ -56,7 +56,22 @@ static int print_start(struct hook *h)
|
|||
struct print *p = (struct print *) h->_vd;
|
||||
int ret;
|
||||
|
||||
ret = io_init(&p->io, p->format, h->node, SAMPLE_HAS_ALL);
|
||||
struct list *signals;
|
||||
|
||||
if (h->node)
|
||||
signals = &h->node->signals;
|
||||
else if (h->path)
|
||||
signals = &h->path->signals;
|
||||
else
|
||||
signals = NULL;
|
||||
|
||||
ret = signals
|
||||
? io_init(&p->io, p->format, signals, SAMPLE_HAS_ALL)
|
||||
: io_init_auto(&p->io, p->format, DEFAULT_SAMPLE_LENGTH, SAMPLE_HAS_ALL);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = io_check(&p->io);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
@ -76,6 +91,10 @@ static int print_stop(struct hook *h)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = io_destroy(&p->io);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -127,7 +146,6 @@ static int print_process(struct hook *h, struct sample *smps[], unsigned *cnt)
|
|||
|
||||
static int print_destroy(struct hook *h)
|
||||
{
|
||||
int ret;
|
||||
struct print *p = (struct print *) h->_vd;
|
||||
|
||||
if (p->uri)
|
||||
|
@ -136,10 +154,6 @@ static int print_destroy(struct hook *h)
|
|||
if (p->prefix)
|
||||
free(p->prefix);
|
||||
|
||||
ret = io_destroy(&p->io);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,19 +70,19 @@ static int scale_process(struct hook *h, struct sample *smps[], unsigned *cnt)
|
|||
for (int k = 0; k < smps[i]->length; k++) {
|
||||
|
||||
switch (sample_format(smps[i], k)) {
|
||||
case SIGNAL_FORMAT_INTEGER:
|
||||
case SIGNAL_TYPE_INTEGER:
|
||||
smps[i]->data[k].i = smps[i]->data[k].i * p->scale + p->offset;
|
||||
break;
|
||||
|
||||
case SIGNAL_FORMAT_FLOAT:
|
||||
case SIGNAL_TYPE_FLOAT:
|
||||
smps[i]->data[k].f = smps[i]->data[k].f * p->scale + p->offset;
|
||||
break;
|
||||
|
||||
case SIGNAL_FORMAT_COMPLEX:
|
||||
case SIGNAL_TYPE_COMPLEX:
|
||||
smps[i]->data[k].z = smps[i]->data[k].z * p->scale + p->offset;
|
||||
break;
|
||||
|
||||
case SIGNAL_FORMAT_BOOLEAN:
|
||||
case SIGNAL_TYPE_BOOLEAN:
|
||||
smps[i]->data[k].b = smps[i]->data[k].b * p->scale + p->offset;
|
||||
break;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue