/*
 * chka_ieee.h
 *
 *  Created on: 08-08-2018
 *      Author: Krzysztof Jakubczyk
 */

#ifndef CHKA_IEEE_H_
#define CHKA_IEEE_H_

#include "tdefs.h"
#include "helper.h"

//#include "pawel_usun_to.h"

#define CHKA_SIL_ZAL	0
#define CHKA_STALA		1
#define CHKA_IDMT		2
#define CHKA_INVERSE					3
#define CHKA_VERY_INVERSE				4
#define CHKA_EXTREMELY_INVERSE			5
#define CHKA_IEEE_MODERATELY_INVERSE	6
#define CHKA_IEEE_VERY_INVERSE			7
#define CHKA_IEEE_EXTREMELY_INVERSE		8

struct dane_wewnetrzne_chka_ieee
{
		short lp[3]; ///<licznik filtracji pobudzen
		u32 lp2[3]; ///<licznik filtracji pobudzen
		u8 p[4];
		u8 w[4];
		u32 t[3];
};

struct chka_ieee_logic
{
	struct binary_io stan_bl;
	struct binary_io test;
	struct binary_io P[4];
	struct binary_io W;
	struct binary_io Z;
	struct binary_io zezw[3];
	struct binary_io relax;

	float *We[3];
	float Wn;
	float Wn_hyst;
	u32 t0;
	float kTMS;
	float trTMS;
	struct dane_wewnetrzne_chka_ieee dw;
	u8 ieee_mi;
	u32 t_blok;
	u32 t_blok_max;
};

struct chka_ieee_io
{
	u32 stan_bl_in;
	u32 test_in;
	u32 wel1_float_in;
	u32 zezw_l1_in;
	u32 wel2_float_in;
	u32 zezw_l2_in;
	u32 wel3_float_in;
	u32 zezw_l3_in;
	u32 pl1_out;
	u32 pl2_out;
	u32 pl3_out;
	u32 p3f_out;
	u32 z3f_out;
	u32 w3f_out;
	u32 relax_out;
}__attribute__((__packed__));

struct chka_ieee_params
{
	u32 bity;
	u32 typ_chki;
	double Wn;
	double tr;
	double kp;
	double TMS;
	double k;
	double c;
	double alfa;
	double t_blok;
}__attribute__((__packed__));

struct chka_ieee_args
{
	struct chka_ieee_io io;
	struct chka_ieee_params params;
//	u16 crc;
}__attribute__((__packed__));

extern int chka_ieee_initlog(void *arguments, void *logic);
extern void chka_ieee(void *arguments, void *logic);

#endif /* CHKA_IEEE_H_ */

