/*
 * logman.h
 *
 *  Created on: 08-04-2014
 *      Author: Krzysztof Jakubczyk
 */

#ifndef LOGMAN_H_
#define LOGMAN_H_

#include "config.h"

// logic manager function flags
#define FUNCTION_NOT_INITIALIZED		0x0000
#define FUNCTION_ENABLED				0x0001
#define FUNCTION_IS_DDR					0x8000
#define FUNCTION_IS_REC_FLOAT			0x4000
#define FUNCTION_IS_DFR					0x2000
#define FUNCTION_IS_VIRT_IN				0x1000
#define FUNCTION_IS_LED					0x0800
#define FUNCTION_IS_MEASURAND			0x0400
#define FUNCTION_IS_REC_AN				0x0200
#define FUNCTION_IS_REC_BIN				0x0100
#define FUNCTION_IS_EVENT				0x0080
#define FUNCTION_IS_REL_OUT				0x0040
#define FUNCTION_IS_REC_BUF				0x0020
#define FUNCTION_IS_GOOSE				0x0010

// logman status
#define LOGMAN_STATUS_STARTED		0x00000001
#define LOGMAN_STATUS_SOFT_STARTED	0x00000002
#define LOGMAN_STATUS_PROFILING		0x00000004
#define LOGMAN_USING_IEC_SV			0x02000000
#define LOGMAN_USING_AN_GEN			0x04000000
#define LOGMAN_USING_DDR			0x08000000
#define LOGMAN_USING_DFR			0x10000000
#define LOGMAN_USING_VIRT_IN		0x20000000
#define LOGMAN_USING_EVENTS			0x40000000
#define LOGMAN_USING_LEDS			0x80000000

// logman requests
#define LOGMAN_REQUEST_START	0x00000001
#define LOGMAN_REQUEST_STOP		0x00000002

#define LOGMAN_BUFSIZE			65536-8192+1792+2560 //98304 +2048 dodano 26.08.2024 dla TZL-8
#define LOGMAN_NETSDATA_SIZE	1536//32768

#define LOGMAN_SOFT_START_TIME	200

extern u32 debug_size[8];

struct logman_profiler
{
	u16 t_cur;
	u16 t_max;
};

extern struct logman_profiler log_profile[MAX_LOG_ELEMENTS];

struct logic_element
{
	u16 flags;
	u8 el_num;
//	void (*fun_main_ptr)(void*,void*);
//	void (*fun_100hz_ptr)(void*,void*);
//	void (*fun_20hz_ptr)(void*,void*);
	void (*fun_args_ptr);
	void (*fun_log_ptr);
};

struct logic_manager
{
	u32 status;
	u32 requests;
	u16 cur_element_num;
	u8 *cur_buf_ptr;
	struct logic_element log_element[MAX_LOG_ELEMENTS];
	u8 buf[LOGMAN_BUFSIZE];
	u8 nets_data[LOGMAN_NETSDATA_SIZE];
	u8 soft_start_cnt;
};

extern struct logic_manager log_manager;

extern void logman_xkhz();
extern void logman_100hz();
extern void logman_20hz();
extern void logman_init();
extern void logman_reset();
extern void logman_stop();
extern int logman_start();
extern int logman_pushfunc(u16 fun_id,void *args, u32 args_size);

#endif /* LOGMAN_H_ */
