- Atomic functions catalog >
- core.cont.mux
core.cont.mux¶
Inputs¶
Name |
Type |
Title |
Mandatory |
Description |
---|---|---|---|---|
input0 |
core.type.f64 |
Input 1 |
True |
None |
input1 |
core.type.f64 |
Input 2 |
True |
None |
select |
core.type.bool |
Select input |
True |
None |
Outputs¶
Name |
Type |
Title |
Description |
---|---|---|---|
output |
core.type.f64 |
Output |
None |
Parameters¶
Function has no parameters
State variables¶
Function has no state variables
Usage XML code snippet¶
core_cont_mux snippet for FLOW configuration file¶
<f name="mux" by_spec="core.cont.mux">
<in alias="input0">some_block_1/output</in>
<in alias="input1">some_block_2/output</in>
<in alias="select">some_block_3/output</in>
</f>
Function’s artifacts¶
- Declaration for core_cont_mux
- Implementation for core_cont_mux
- Header of core_cont_mux
- Specification of core_cont_mux
- Interface of core_cont_mux
declaration.py¶
from fspeclib import *
Function(
name='core.cont.mux',
title=LocalizedString(
en='Multiplexor, 2ch'
),
description=None,
inputs=[
Input(
name='input0',
title='Input 1',
value_type='core.type.f64'
),
Input(
name='input1',
title='Input 2',
value_type='core.type.f64'
),
Input(
name='select',
title='Select input',
value_type='core.type.bool'
)
],
outputs=[
Output(
name='output',
title='Output',
value_type='core.type.f64'
)
]
)
core_cont_mux_exec.c¶
#include "core_cont_mux.h"
void core_cont_mux_exec(const core_cont_mux_inputs_t *i, core_cont_mux_outputs_t *o)
{
o->output = i->select ? i->input1 : i->input0;
}
core_cont_mux.h¶
/**
* Automatically-generated file. Do not edit!
*/
#ifndef FSPEC_CORE_CONT_MUX_H
#define FSPEC_CORE_CONT_MUX_H
#include <stdint.h>
#include <eswb/types.h>
#include "function.h"
/* Include declaration of dependency types */
#include "core_type_bool.h"
#include "core_type_f64.h"
/**
* @brief Inputs of `core.cont.mux` function
*/
typedef struct core_cont_mux_inputs_ {
core_type_f64_t input0; /// Input 1
core_type_f64_t input1; /// Input 2
core_type_bool_t select; /// Select input
} core_cont_mux_inputs_t;
/**
* @brief Outputs of `core.cont.mux` function
*/
typedef struct core_cont_mux_outputs_ {
core_type_f64_t output; /// Output
} core_cont_mux_outputs_t;
typedef struct core_cont_mux_eswb_descriptors_ {
eswb_topic_descr_t in_input0;
eswb_topic_descr_t in_input1;
eswb_topic_descr_t in_select;
eswb_topic_descr_t out_all;
} core_cont_mux_eswb_descriptors_t;
typedef struct core_cont_mux_interface_ {
core_cont_mux_inputs_t i;
core_cont_mux_outputs_t o;
core_cont_mux_eswb_descriptors_t eswb_descriptors;
} core_cont_mux_interface_t;
void core_cont_mux_exec(const core_cont_mux_inputs_t *i, core_cont_mux_outputs_t *o);
#endif // FSPEC_CORE_CONT_MUX_H
core_cont_mux_spec.c¶
/**
* Automatically-generated file. Do not edit!
*/
#include "core_cont_mux.h"
#include <eswb/types.h>
static const param_spec_t *params[1] = {
NULL
};
static const input_spec_t i_input0 = {
.name = "input0",
.annotation = "Input 1",
.flags = 0
};
static const input_spec_t i_input1 = {
.name = "input1",
.annotation = "Input 2",
.flags = 0
};
static const input_spec_t i_select = {
.name = "select",
.annotation = "Select input",
.flags = 0
};
static const input_spec_t *inputs[4] = {
&i_input0,
&i_input1,
&i_select,
NULL
};
static const output_spec_t o_output = {
.name = "output",
.annotation = "Output",
.flags = 0
};
static const output_spec_t *outputs[2] = {
&o_output,
NULL
};
fspec_rv_t core_cont_mux_call_init_inputs(void *dh, const func_conn_spec_t *conn_spec, eswb_topic_descr_t mounting_td);
fspec_rv_t core_cont_mux_call_init_outputs(
void *dh,
const func_conn_spec_t *conn_spec,
eswb_topic_descr_t mounting_td,
const char *func_name
);
void core_cont_mux_call_exec(void *dh);
const function_spec_t atomic_core_cont_mux_spec = {
.name = "core.cont.mux",
.annotation = "Multiplexor, 2ch",
.inputs = inputs,
.outputs = outputs,
.params = params
};
const function_calls_t atomic_core_cont_mux_calls = {
.interface_handle_size = sizeof(core_cont_mux_interface_t),
.init = NULL,
.init_inputs = core_cont_mux_call_init_inputs,
.init_outputs = core_cont_mux_call_init_outputs,
.pre_exec_init = NULL,
.exec = core_cont_mux_call_exec,
.set_params = NULL
};
const function_handler_t atomic_core_cont_mux_handler = {
.spec = &atomic_core_cont_mux_spec,
.calls = &atomic_core_cont_mux_calls,
.extension_handler = NULL
};
core_cont_mux_interface.c¶
/**
* Automatically-generated file. Do not edit!
*/
#include "core_cont_mux.h"
#include "error.h"
#include <eswb/api.h>
#include <eswb/topic_proclaiming_tree.h>
#include <eswb/errors.h>
int core_cont_mux_interface_inputs_init(
core_cont_mux_interface_t *interface,
const func_conn_spec_t *conn_spec,
eswb_topic_descr_t mounting_td
)
{
eswb_rv_t rv;
int errcnt_no_topic = 0;
int errcnt_no_input = 0;
const char *topic_path_in_input0 = fspec_find_path2connect(conn_spec,"input0");
const char *topic_path_in_input1 = fspec_find_path2connect(conn_spec,"input1");
const char *topic_path_in_select = fspec_find_path2connect(conn_spec,"select");
// Connecting mandatory input "input0"
if (topic_path_in_input0 != NULL) {
rv = eswb_connect_nested(mounting_td, topic_path_in_input0, &interface->eswb_descriptors.in_input0);
if(rv != eswb_e_ok) {
error("failed connect input \"input0\" to topic \"%s\": %s", topic_path_in_input0, eswb_strerror(rv));
errcnt_no_topic++;
}
} else {
error("mandatory input \"input0\" is not speicifed");
errcnt_no_input++;
}
// Connecting mandatory input "input1"
if (topic_path_in_input1 != NULL) {
rv = eswb_connect_nested(mounting_td, topic_path_in_input1, &interface->eswb_descriptors.in_input1);
if(rv != eswb_e_ok) {
error("failed connect input \"input1\" to topic \"%s\": %s", topic_path_in_input1, eswb_strerror(rv));
errcnt_no_topic++;
}
} else {
error("mandatory input \"input1\" is not speicifed");
errcnt_no_input++;
}
// Connecting mandatory input "select"
if (topic_path_in_select != NULL) {
rv = eswb_connect_nested(mounting_td, topic_path_in_select, &interface->eswb_descriptors.in_select);
if(rv != eswb_e_ok) {
error("failed connect input \"select\" to topic \"%s\": %s", topic_path_in_select, eswb_strerror(rv));
errcnt_no_topic++;
}
} else {
error("mandatory input \"select\" is not speicifed");
errcnt_no_input++;
}
if ((errcnt_no_input > 0) || (errcnt_no_topic > 0)) {
if (errcnt_no_input > errcnt_no_topic) {
return fspec_rv_no_input;
} else {
return fspec_rv_no_topic;
}
}
return fspec_rv_ok;
}
fspec_rv_t core_cont_mux_interface_inputs_update(core_cont_mux_interface_t *interface)
{
eswb_rv_t rv;
rv = eswb_read(interface->eswb_descriptors.in_input0, &interface->i.input0);
if(rv != eswb_e_ok) {
/*FIXME nothing to do yet*/
}
rv = eswb_read(interface->eswb_descriptors.in_input1, &interface->i.input1);
if(rv != eswb_e_ok) {
/*FIXME nothing to do yet*/
}
rv = eswb_read(interface->eswb_descriptors.in_select, &interface->i.select);
if(rv != eswb_e_ok) {
/*FIXME nothing to do yet*/
}
return 0;
}
fspec_rv_t core_cont_mux_interface_outputs_init(
core_cont_mux_interface_t *interface,
const func_conn_spec_t *conn_spec,
eswb_topic_descr_t mounting_td,
const char *func_name
)
{
TOPIC_TREE_CONTEXT_LOCAL_DEFINE(cntx, 2);
core_cont_mux_outputs_t out;
eswb_rv_t rv;
topic_proclaiming_tree_t *rt = usr_topic_set_struct(cntx, out, func_name);
usr_topic_add_struct_child(cntx, rt, core_cont_mux_outputs_t, output, "output", tt_double);
rv = eswb_proclaim_tree(mounting_td, rt, cntx->t_num, &interface->eswb_descriptors.out_all);
if (rv != eswb_e_ok) {
return fspec_rv_publish_err;
}
return fspec_rv_ok;
}
fspec_rv_t core_cont_mux_interface_outputs_update(core_cont_mux_interface_t *interface)
{
eswb_rv_t rv;
rv = eswb_update_topic(interface->eswb_descriptors.out_all, &interface->o);
if (rv != eswb_e_ok) {
return 1;
}
return 0;
}
void core_cont_mux_interface_update(core_cont_mux_interface_t *interface)
{
core_cont_mux_interface_inputs_update(interface);
core_cont_mux_exec(&interface->i, &interface->o);
core_cont_mux_interface_outputs_update(interface);
}
fspec_rv_t core_cont_mux_call_init_inputs(void *dh, const func_conn_spec_t *conn_spec, eswb_topic_descr_t mounting_td)
{
core_cont_mux_interface_t *interface = (core_cont_mux_interface_t*) dh;
return core_cont_mux_interface_inputs_init(interface, conn_spec, mounting_td);
}
fspec_rv_t core_cont_mux_call_init_outputs(
void *dh,
const func_conn_spec_t *conn_spec,
eswb_topic_descr_t mounting_td,
const char *func_name
)
{
core_cont_mux_interface_t *interface = (core_cont_mux_interface_t*) dh;
return core_cont_mux_interface_outputs_init(interface, conn_spec, mounting_td, func_name);
}
void core_cont_mux_call_exec(void *dh)
{
core_cont_mux_interface_t *interface = (core_cont_mux_interface_t*) dh;
core_cont_mux_interface_update(interface);
}