Navigation

core.math.vector3f64

Inputs

Name

Type

Title

Mandatory

Description

x

core.type.f64

X component

True

None

y

core.type.f64

Y component

True

None

z

core.type.f64

Z component

True

None

Outputs

Name

Type

Title

Description

v

<fspeclib.Structure object at 0x7f2b33a7cdf0>

3d vector

None

Parameters

Function has no parameters

State variables

Function has no state variables

Usage XML code snippet

core_math_vector3f64 snippet for FLOW configuration file
<f name="vector3f64" by_spec="core.math.vector3f64">
    <in alias="x">some_block_1/output</in>
    <in alias="y">some_block_2/output</in>
    <in alias="z">some_block_3/output</in>
</f>

Function’s artifacts

declaration.py
from fspeclib import *


Function(
    name='core.math.vector3f64',
    title=LocalizedString(
        en='Convert 3 scalars to 3d vector of f64'
    ),

    inputs=[
        Input(
            name='x',
            title='X component',
            value_type='core.type.f64'
        ),
        Input(
            name='y',
            title='Y component',
            value_type='core.type.f64'
        ),
        Input(
            name='z',
            title='Z component',
            value_type='core.type.f64'
        ),
    ],

    outputs=[
        Input(
            name='v',
            title='3d vector',
            value_type='core.type.v3f64'
        ),
    ],
)
core_math_vector3f64_exec.c
#include "core_math_vector3f64.h"

void core_math_vector3f64_exec(const core_math_vector3f64_inputs_t *i, core_math_vector3f64_outputs_t *o)
{
    o->v.x = i->x;
    o->v.y = i->y;
    o->v.z = i->z;
}
core_math_vector3f64.h
/**
 *  Automatically-generated file. Do not edit!
 */

#ifndef FSPEC_CORE_MATH_VECTOR3F64_H
#define FSPEC_CORE_MATH_VECTOR3F64_H

#include <stdint.h>
#include <eswb/types.h>

#include "function.h"

/* Include declaration of dependency types */
#include "core_type_f64.h"
#include "core_type_v3f64.h"

/**
 * @brief Inputs of `core.math.vector3f64` function
 */
typedef struct core_math_vector3f64_inputs_ {
    core_type_f64_t x;  /// X component
    core_type_f64_t y;  /// Y component
    core_type_f64_t z;  /// Z component

} core_math_vector3f64_inputs_t;

/**
 * @brief Outputs of `core.math.vector3f64` function
 */
typedef struct core_math_vector3f64_outputs_ {
    core_type_v3f64_t v; /// 3d vector

} core_math_vector3f64_outputs_t;

typedef struct core_math_vector3f64_eswb_descriptors_ {
    eswb_topic_descr_t in_x;
    eswb_topic_descr_t in_y;
    eswb_topic_descr_t in_z;
    eswb_topic_descr_t out_all;
} core_math_vector3f64_eswb_descriptors_t;

typedef struct core_math_vector3f64_interface_ {
    core_math_vector3f64_inputs_t i;
    core_math_vector3f64_outputs_t o;
    core_math_vector3f64_eswb_descriptors_t eswb_descriptors;
} core_math_vector3f64_interface_t;

void core_math_vector3f64_exec(const core_math_vector3f64_inputs_t *i, core_math_vector3f64_outputs_t *o);

#endif // FSPEC_CORE_MATH_VECTOR3F64_H
core_math_vector3f64_spec.c
/**
 *  Automatically-generated file. Do not edit!
 */

#include "core_math_vector3f64.h"
#include <eswb/types.h>

static const param_spec_t *params[1] = {
    NULL
};

static const input_spec_t i_x = {
    .name = "x",
    .annotation = "X component",
    .flags = 0
};

static const input_spec_t i_y = {
    .name = "y",
    .annotation = "Y component",
    .flags = 0
};

static const input_spec_t i_z = {
    .name = "z",
    .annotation = "Z component",
    .flags = 0
};

static const input_spec_t *inputs[4] = {
    &i_x,
    &i_y,
    &i_z,
    NULL
};

static const output_spec_t o_v = {
    .name = "v",
    .annotation = "3d vector",
    .flags = 0
};

static const output_spec_t *outputs[2] = {
    &o_v,
    NULL
};

fspec_rv_t core_math_vector3f64_call_init_inputs(
    void *dh,
    const func_conn_spec_t *conn_spec,
    eswb_topic_descr_t mounting_td
);

fspec_rv_t core_math_vector3f64_call_init_outputs(
    void *dh,
    const func_conn_spec_t *conn_spec,
    eswb_topic_descr_t mounting_td,
    const char *func_name
);

void core_math_vector3f64_call_exec(void *dh);

const function_spec_t atomic_core_math_vector3f64_spec = {
    .name = "core.math.vector3f64",
    .annotation = "Convert 3 scalars to 3d vector of f64",
    .inputs = inputs,
    .outputs = outputs,
    .params = params
};

const function_calls_t atomic_core_math_vector3f64_calls = {
    .interface_handle_size = sizeof(core_math_vector3f64_interface_t),
    .init = NULL,
    .init_inputs = core_math_vector3f64_call_init_inputs,
    .init_outputs = core_math_vector3f64_call_init_outputs,
    .pre_exec_init = NULL,
    .exec = core_math_vector3f64_call_exec,
    .set_params = NULL
};

const function_handler_t atomic_core_math_vector3f64_handler = {
    .spec = &atomic_core_math_vector3f64_spec,
    .calls = &atomic_core_math_vector3f64_calls,
    .extension_handler = NULL
};
core_math_vector3f64_interface.c
/**
 *  Automatically-generated file. Do not edit!
 */

#include "core_math_vector3f64.h"

#include "error.h"
#include <eswb/api.h>
#include <eswb/topic_proclaiming_tree.h>
#include <eswb/errors.h>

int core_math_vector3f64_interface_inputs_init(
    core_math_vector3f64_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_x = fspec_find_path2connect(conn_spec,"x");
    const char *topic_path_in_y = fspec_find_path2connect(conn_spec,"y");
    const char *topic_path_in_z = fspec_find_path2connect(conn_spec,"z");

    // Connecting mandatory input "x"
    if (topic_path_in_x != NULL) {
        rv = eswb_connect_nested(mounting_td, topic_path_in_x, &interface->eswb_descriptors.in_x);
        if(rv != eswb_e_ok) {
            error("failed connect input \"x\" to topic \"%s\": %s", topic_path_in_x, eswb_strerror(rv));
            errcnt_no_topic++;
        }
    } else {
        error("mandatory input \"x\" is not speicifed");
        errcnt_no_input++;
    }

    // Connecting mandatory input "y"
    if (topic_path_in_y != NULL) {
        rv = eswb_connect_nested(mounting_td, topic_path_in_y, &interface->eswb_descriptors.in_y);
        if(rv != eswb_e_ok) {
            error("failed connect input \"y\" to topic \"%s\": %s", topic_path_in_y, eswb_strerror(rv));
            errcnt_no_topic++;
        }
    } else {
        error("mandatory input \"y\" is not speicifed");
        errcnt_no_input++;
    }

    // Connecting mandatory input "z"
    if (topic_path_in_z != NULL) {
        rv = eswb_connect_nested(mounting_td, topic_path_in_z, &interface->eswb_descriptors.in_z);
        if(rv != eswb_e_ok) {
            error("failed connect input \"z\" to topic \"%s\": %s", topic_path_in_z, eswb_strerror(rv));
            errcnt_no_topic++;
        }
    } else {
        error("mandatory input \"z\" 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_math_vector3f64_interface_inputs_update(core_math_vector3f64_interface_t *interface)
{
    eswb_rv_t rv;

    rv = eswb_read(interface->eswb_descriptors.in_x, &interface->i.x);
    if(rv != eswb_e_ok) {
        /*FIXME nothing to do yet*/
    }

    rv = eswb_read(interface->eswb_descriptors.in_y, &interface->i.y);
    if(rv != eswb_e_ok) {
        /*FIXME nothing to do yet*/
    }

    rv = eswb_read(interface->eswb_descriptors.in_z, &interface->i.z);
    if(rv != eswb_e_ok) {
        /*FIXME nothing to do yet*/
    }

    return 0;
}

fspec_rv_t core_math_vector3f64_interface_outputs_init(
    core_math_vector3f64_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, 5);
    core_math_vector3f64_outputs_t out;
    eswb_rv_t rv;

    topic_proclaiming_tree_t *rt = usr_topic_set_struct(cntx, out, func_name);

    topic_proclaiming_tree_t* v_s_root = usr_topic_add_struct_child(cntx, rt, core_math_vector3f64_outputs_t, v, "v", tt_struct);
    usr_topic_add_struct_child(cntx, v_s_root, core_type_v3f64_t, x, "x", tt_double);
    usr_topic_add_struct_child(cntx, v_s_root, core_type_v3f64_t, y, "y", tt_double);
    usr_topic_add_struct_child(cntx, v_s_root, core_type_v3f64_t, z, "z", 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_math_vector3f64_interface_outputs_update(core_math_vector3f64_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_math_vector3f64_interface_update(core_math_vector3f64_interface_t *interface)
{
    core_math_vector3f64_interface_inputs_update(interface);
    core_math_vector3f64_exec(&interface->i, &interface->o);
    core_math_vector3f64_interface_outputs_update(interface);
}

fspec_rv_t core_math_vector3f64_call_init_inputs(
    void *dh,
    const func_conn_spec_t *conn_spec,
    eswb_topic_descr_t mounting_td
)
{
    core_math_vector3f64_interface_t *interface = (core_math_vector3f64_interface_t*) dh;
    return core_math_vector3f64_interface_inputs_init(interface, conn_spec, mounting_td);
}

fspec_rv_t core_math_vector3f64_call_init_outputs(
    void *dh,
    const func_conn_spec_t *conn_spec,
    eswb_topic_descr_t mounting_td,
    const char *func_name
)
{
    core_math_vector3f64_interface_t *interface = (core_math_vector3f64_interface_t*) dh;
    return core_math_vector3f64_interface_outputs_init(interface, conn_spec, mounting_td, func_name);
}

void core_math_vector3f64_call_exec(void *dh)
{
    core_math_vector3f64_interface_t *interface = (core_math_vector3f64_interface_t*) dh;
    core_math_vector3f64_interface_update(interface);
}