// вгв
#ifndef _MEASURE
#define _MEASURE

interrupt void cpu_timer1_isr_SENS(void);

void Init_sensors(void);
void Init_packMask(void);
void measure_all(void);
void Temper_count(int chan);
void Current_count(int chan);
void Power_count(int chan);
void Init_sensors_more(void);

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


typedef union
{
	struct
	{
		unsigned int Tear	:1;
		unsigned int res1	: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;

} 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	0xC000
#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	5000//3885//777//2000//20000	//777	//3885	// Гц (777*5)
#define DAC_FREQ	300//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 tmp_T_0		84.31		//	68Om
#define tmp_T_1		234.19		//	100Om
#define tmp_A1_0	540.0		// канал 1 68Ом
#define tmp_A2_0	500.0		// канал 1 100Ом
#define tmp_A1_1	1055.0		// канал 2 68Ом
#define tmp_A2_1	1060.0		// канал 2 100Ом

#define ZERO	27

#define mka300	2040
#define mka400	2700

#define C100	1540
#define C150	2310

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

#define COSPi6	0.86602540378443864676372317075294

#define RADIX2	1.4142135623730950488016887242097

#define POWER_380	1	// питание 380В
#define POWER_38O	2	// питание 380В
#define POWER_31	3	// питание 31В
#define POWER_27	4	// питание 24В
#define POWER_24	5	// питание 24В
#define POWER_15	6	// питание 15В
#define TERMO_AD	7	// термодатчик мелкосхема

#define	CURRENT		0	// ток
#define	VOLTAGE		1	// напражение

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 ERROR * sens_error;
extern int * sens_hi_edge;
extern int * sens_lo_edge;

extern unsigned long WAKEpowse;
extern unsigned long STOPpowse;

extern float tmpK1,tmpK2;
extern float tmpK1_50,tmpK2_50;

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

#endif 	//_MEASURE
