/*
 * measurand.h
 *
 *  Created on: 07-10-2014
 *      Author: Krzysztof Jakubczyk
 */

#ifndef MEASURAND_H_
#define MEASURAND_H_

#include "tdefs.h"

#define MAX_MEASURANDS_COUNT	64

struct measurands_table
{
	u16 count;
	float *value[MAX_MEASURANDS_COUNT];
	float *value_pri[MAX_MEASURANDS_COUNT];
	float *value_sec[MAX_MEASURANDS_COUNT];
	u8 id[MAX_MEASURANDS_COUNT];
}__attribute__((__packed__));

struct measurand_logic
{
	float *esk_ptr;
	float calculated;
	float calculated_pri;
	float calculated_sec;
	struct analog_in_params *an_params;
};

struct measurand_io
{
	u32 esk_float_in;
	u32 param_an_ptr_in;
}__attribute__((__packed__));

#define MEASURAND_SQRT				0x01
#define MEASURAND_NO_PRI_SEC	 	0x02
#define MEASURAND_LIMITED_OUTPUT 	0x04

struct measurand_params
{
	u32 id;
	u32 bits;
	double minval;
}__attribute__((__packed__));

struct measurand_args
{
	struct measurand_io io;
	struct measurand_params params;
//	u16 crc;
}__attribute__((__packed__));

extern volatile struct measurands_table measurands;

extern void measurand_100hz(void *args, void *logic);
extern int measurand_initlog(void *args, void *logic);

#endif /* MEASURAND_H_ */
