// вгв
#ifndef _MEASURE
#define _MEASURE

interrupt void cpu_timer1_isr_SENS(void);

void Init_sensors(void);
void Init_sensors_more(void);
void Init_packMask(void);
void Temper_count(int chan, int ovn);
void Current_count(int chan);
void Power_count(int chan);
void calc_sensor_koef(void);
void Is_Voltage_Hi(void);
void calc_volta_edge(void);

int er_anal(int term, unsigned int * count, long edge, int pre);

typedef union
{
	struct
	{
		unsigned int Tear	:1;
		unsigned int res	:1;
		unsigned int Wry	:1;
		unsigned int Out	:1;
		unsigned int Over	:1;
		unsigned int Hyper	:1;
		unsigned int Contr	:1;
		unsigned int res2	:1;

		unsigned int Stop	:1;
		unsigned int Ready	:1;
		unsigned int Discr1	:1;
		unsigned int Discr2	:1;
		unsigned int Discr3	:1;
		unsigned int Discr4	:1;
		unsigned int Ignor	:1;
		unsigned int Bypas	:1;

	} bit;
	unsigned int all;

#define Imit Discr4

} ERROR;

typedef union
{
	struct
	{
		unsigned int Error		:1;
		unsigned int Alarm		:1;
		unsigned int OverHeat	:1;
		unsigned int SubHeat	:1;
		unsigned int OutHeat	:1;
		unsigned int Test_lamp	:1;

	} bit;
	unsigned int all;

} FLAG;

#define NOER	0xE000//C
#define EROR	0x01FF

#define READY_FREQ	(500.0	* 2)// Гц
#define BLINK_FREQ	2		// Гц
#define	BLINK_TIME (READY_FREQ / BLINK_FREQ)

#define CANPOWSE 20

#define ADC_FREQ	3750 //3885.0//777//2000//20000	//777	//3885	// Гц (777*5)
#define DAC_FREQ	200//5		// Гц

#define LOAD_TIME	30//15		// sec

extern unsigned int Caliber_time;

#define SENS_ERR_WAIT	10

#define maximum_bright	10

#define Pi		3.1415926535897932384626433832795
#define Pi_2	1.5707963267948966192313216916398

#define ZERO	27

#define	Cooling		5		// (°С) Гистерезис по снатию перегрева

#define COSPi6	0.86602540378443864676372317075294

#define RADIX2	1.4142135623730950488016887242097

#define POWER_380	0	// питание 380В
#define POWER_38O	1	// питание 380В
#define	CURRENT		2	// ток
#define	VOLTAGE		3	// напражение
#define POWER_31	4	// питание 31В
#define POWER_27	5	// питание 24В
#define POWER_24	6	// питание 24В
#define POWER_15	7	// питание 15В
#define TERMO_AD	8	// термодатчик мелкосхема
#define TERMO_RS	9	// терморезистор
#define TRM_OBEH	10	// термодатчик овен

extern int TPL_CANS,tpl_cans;

extern int READY;

extern FILTERBAT filter[];
extern FILTERBAT adc_filter[];
extern FILTERBAT out_filter[];

extern int sens_type[];
extern int ext_temp[], ext_diag[];

extern unsigned long Lonely;
extern unsigned int CanPowse,CanGO;
extern unsigned int Maska[][8];

#endif 	//_MEASURE
