Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Functions
arctan-node.c File Reference

This file contains the implementation of custom node types. More...

#include <errno.h>
#include <stdio.h>
#include <math.h>
#include <sol-log.h>
#include <sol-mainloop.h>
#include <sol-flow.h>
#include "arctan-spec-gen.c"

Functions

static int logic_process (struct sol_flow_node *node, void *data, uint16_t port, uint16_t conn_id, const struct sol_flow_packet *packet)
 Logic: More...
 

Detailed Description

This file contains the implementation of custom node types.

It uses generated boilerplate from JSON which later modified to perform arctangent algorithm.

The instruction used to generate custom node template code from arctan-spec.json which eventually being included into arctan-node.c:

$ sol-flow-node-type-gen.py \ –prefix sol_flow_node_type –genspec-schema \ /usr/share/soletta/flow/schemas/node-type-genspec.schema \ arctan-spec.json \ arctan-spec-gen.h \ arctan-spec-gen.c \ arctan-spec-gen.json

The instruction to compile this custom node: $ gcc pkg-config --libs --cflags soletta \ -DSOL_FLOW_NODE_TYPE_MODULE_EXTERNAL=1 \ -shared -fPIC arctan-node.c -o arctangent.so

The location to install arctangent.so: $ install -m 0755 arctangent.so /usr/lib/soletta/modules/flow/

Function Documentation

static int logic_process ( struct sol_flow_node node,
void *  data,
uint16_t  port,
uint16_t  conn_id,
const struct sol_flow_packet packet 
)
static

Logic:

This node will receive a float input and then calculate the value of arctangent of it to be feed at the output port. Formula for arctangent power series and reciprocal arguments are as follows:

arctangent(x) = summation[(-1)^n * (z^(2n+1) / 2n+1)]

arctangent(x) = -(PI/2) - arctangent(1/x)

Detailed explanation can be refered at :

https://en.wikipedia.org/wiki/Inverse_trigonometric_functions

This node contains no data, it will recompute everything based on the last received packet, thus there is no node private data, open or close methods.

References sol_flow_packet_get_drange(), sol_flow_send_drange_value_packet(), SOL_INT_CHECK, and sol_drange::val.