/*
 * sum_flt_3f.c
 *
 *  Created on: 30-07-2019
 *      Author: Krzysztof Jakubczyk
 */

#include <math.h>

#include "tdefs.h"
#include "misc.h"

#include "helper.h"
#include "sum_flt_3f.h"

int sum_flt_3f_initlog(void *arguments, void *logic)
{
	struct sum_flt_3f_args *args = (struct sum_flt_3f_args *)arguments;
	struct sum_flt_3f_logic *log = (struct sum_flt_3f_logic *)logic;

	if(set_float_ptr(args->io.in_l1a_float_in,&log->in_l1a))
		return -1;
	if(set_float_ptr(args->io.in_l1b_float_in,&log->in_l1b))
		return -1;

	if(set_float_ptr(args->io.in_l2a_float_in,&log->in_l2a))
		return -1;
	if(set_float_ptr(args->io.in_l2b_float_in,&log->in_l2b))
		return -1;

	if(set_float_ptr(args->io.in_l3a_float_in,&log->in_l3a))
		return -1;
	if(set_float_ptr(args->io.in_l3b_float_in,&log->in_l3b))
		return -1;

	if(set_float_ptr(args->io.in_3i0a_float_in,&log->in_3i0a))
		return -1;
	if(set_float_ptr(args->io.in_3i0b_float_in,&log->in_3i0b))
		return -1;

	if(set_float_ptr(args->io.out_l1_float_out,&log->out_l1))
		return -1;
	if(set_float_ptr(args->io.out_l2_float_out,&log->out_l2))
		return -1;
	if(set_float_ptr(args->io.out_l3_float_out,&log->out_l3))
		return -1;
	if(set_float_ptr(args->io.out_3i0_float_out,&log->out_3i0))
		return -1;

	return 0;
}

void sum_flt_3f(void *arguments, void *logic)
{
	struct sum_flt_3f_logic *log = (struct sum_flt_3f_logic *)logic;
	struct sum_flt_3f_args *args = (struct sum_flt_3f_args *)arguments;
	float m1 = args->params.m1;
	float m2 = args->params.m2;

	*log->out_l1=*log->in_l1a*m1 + *log->in_l1b*m2;
	*log->out_l2=*log->in_l2a*m1 + *log->in_l2b*m2;
	*log->out_l3=*log->in_l3a*m1 + *log->in_l3b*m2;
	*log->out_3i0=*log->in_3i0a*m1 + *log->in_3i0b*m2;
}
