/*
 * chka.h
 *
 *  Created on: 07-03-2018
 *      Author: Krzysztof Jakubczyk
 */

#ifndef CHKA_H_
#define CHKA_H_

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

#define CHKA_SIL_ZAL	0
#define CHKA_STALA		1
#define CHKA_IDMT		2

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

struct chka_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];

	float *We[3];
	float Wn;
	float Wn_hyst;
	u32 t0;
	struct dane_wewnetrzne_chka dw;
};

struct chka_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;
}__attribute__((__packed__));

struct chka_params
{
	u32 bity;
	u32 typ_chki;
	double Wn;
	double tm;
	double n;
	double t0;
	double k;
}__attribute__((__packed__));

struct chka_args
{
	struct chka_io io;
	struct chka_params params;
//	u16 crc;
}__attribute__((__packed__));

extern int chka_initlog(void *arguments, void *logic);
extern void chka(void *arguments, void *logic);

#endif /* CHKA_H_ */
