#ifndef DIGITALEVENT_LIB_H
#define DIGITALEVENT_LIB_H

#ifndef NULL
#define NULL 0
#endif

#define EVENTS_WARRINGACKTIME_PRESCALE				600000U

#include "ModBusObject_V1.hpp"
#include "ModBusObject_V2.hpp"

enum Events_TresholdsTypes
{
	Event_TresholdFormat_Integer,
	Event_TresholdFormat_Float,

	Event_TresholdFormat_Count
};

enum Events_AlarmDirection
{
	LowThen,
	HightThen
};

enum EventsType
{
	Warning,
	Alarm
};

enum EventsAbsolute
{

	Signed,
	Absolute
};

enum EventsTimePrescale
{
	EventStart,
	EventEnd
};

typedef struct
{
	bool isActive;
} 	FO_Bits_Events;

typedef struct
{
	float CriticalValues[3];
} 	FO_Regs_Events;

typedef struct
{
	bool isEnable;
	bool isAlarmEnable;
	bool isAckEnable;
} FI_Bits_Events;

typedef struct
{
	unsigned short 	TimePrescale[2];
	float 			Prescale;
} FI_Regs_Events;

typedef struct
{
	bool isDefaultsApply;
	bool isWarning;
} SI_Bits_Events;

typedef struct
{
	bool isAlarm;
} SO_Bits_Events;

#ifdef __cplusplus

typedef ModBusObject
<
	ModBusInputBits<SI_Bits_Events,	FR<FI_Bits_Events> >,
	ModBusInputRegs<FR<FI_Regs_Events> >,
	ModBusOutputBits<SO_Bits_Events, FR<FO_Bits_Events> >,
	ModBusOutputRegs<FR<FO_Regs_Events>	>
> ModBusEventsV1_t;


typedef ModBusDirect
<
	ModBusSram
	<
		ModBusIB<SI_Bits_Events>,
		ModBusOB<SO_Bits_Events>
	>,
	ModBusFram
	<
		ModBusIB<FI_Bits_Events>,
		ModBusIR<FI_Regs_Events>,
		ModBusOB<FO_Bits_Events>,
		ModBusOR<FO_Regs_Events>
	>
> ModBusEventsV2_t;

typedef ModBusFram
<
	ModBusIB<FI_Bits_Events>,
	ModBusIR<FI_Regs_Events>,
	ModBusOB<FO_Bits_Events>,
	ModBusOR<FO_Regs_Events>
> EventsFram_t;

typedef ModBusSram
<
	ModBusIB<SI_Bits_Events>,
	ModBusOB<SO_Bits_Events>
> EventsSram_t;

#endif

#endif
