#ifndef PACKAGE
#define PACKAGE

#define BALSAM	167

#if BALSAM == 167
#define OBOROT	STRAIGHT
#define CALIB_RS
#define OWEN
#endif
#if BALSAM == 166
#define OBOROT	REVERSE
#endif
#if BALSAM == 165
#define OBOROT	STRAIGHT
#endif
#if BALSAM == 164
#define OBOROT	REVERSE
#endif

#define ONBOARDCALIBER
#define TERMOPAIR	14
#define CURRENTOS	(TERMOPAIR*2)

//-----------------------------------------------
#define adr_TRN1	1
#define adr_TRN2	2
#define adr_POW1	3
#define adr_POW2	4
#define adr_LOA1	5
#define adr_LOA2	6
#define adr_ENG1	7
#define adr_PULT	8
#define adr_SHKF	9
//-------------------
#define adr_REC1	0xff
#define adr_REC2	0xff
#define adr_INV1	0xff
#define adr_INV2	0xff
#define adr_BRK1	0xff
#define adr_BRK2	0xff
#define adr_ENG2	0xff
#define adr_PLT1	0xff
#define adr_PLT2	0xff
#define adr_DSTR	0xff

//-----------------------------------------------
#define dsk_COMM	1
#define dsk_BKSD	2
#define dsk_BKST	3
#define dsk_EPLT	4
#define dsk_SHKF	5
#define dsk_LOAD	6
//-----------------------------------------------

//-----------------------------------------------
#define	TPL_TRN 10
#if BALSAM == 167
#define	TPL_POW 7
#define	OWEN_DT 2
#else
#define	TPL_POW 8
#define	OWEN_DT 0
#endif
#define	TPL_ENG 8
#define	TPL_SHK 15
//-----------------------------------------------

#define Modbus ((WORDE *)modbus)

#define start_error		0x00
#define start_data		0x18
#define start_hi_edge	0x30
#define start_lo_edge	0x48

#define sens_error		((ERROR *)(modbus+start_error))
#define sens_data		(modbus+start_data)
#define sens_hi_edge	(modbus+start_hi_edge)
#define sens_lo_edge	(modbus+start_lo_edge)

#define InputRep0	Modbus[0].bit.bitA
#define InputRep1	Modbus[0].bit.bitB
#define InputRep2	Modbus[0].bit.bitC

#define Inputs	Modbus[0x10]
#define Buttons	Modbus[0x16]

#define Jumpers	modbus[0x17]

#define bTestLamp	Buttons.bit.bit0
#define bSecretBt	Buttons.bit.bit1
#define bTermoCal	Buttons.bit.bit2

#define	Cancount	(modbus+0x60)	//	пауза между I посылками CAN
#define	Bright		(modbus+0x62)	//	аркость сигнальных лампочек
#define	Brightness	 modbus[0x62]	//	аркость сигнальных лампочек

#define	Owncount	modbus[0x63]	//	пауза между опросами OWEN

/*	Не врема!
#define	DAC_go	 	modbus[0x64]	//	начало зарада
#define	DAC_stop	modbus[0x65]	//	конец зарада
*/

#define m_FAST 0
#define m_SLOW 1

#define Zero_lev	(modbus+0x70)

#define DAC_20	modbus[0x6E]
#define DAC_04	modbus[0x6F]

#define DAC_max()	modbus[0x78]	//	751//0x0000  804
#define DAC_min()	modbus[0x79]	//	2162//0x0FFF 2373
#define DAC_cal()	modbus[0x7A]

#define	Caliber	(modbus+0x74)

#define K380_1	Caliber[0]
#define K380_2	Caliber[1]

#define KPOW_1	Caliber[0]
#define KPOW_2	Caliber[1]
#define KPOW_3	Caliber[2]
#define KPOW_4	Caliber[3]

#define NormaU	Caliber[8]
#define DeltaU	Caliber[9]

#define	TCaliber	(modbus+0x78)

#define K300_1	TCaliber[0]
#define K300_2	TCaliber[1]
#define K400_1	TCaliber[2]
#define K400_2	TCaliber[3]

#define K100_1	TCaliber[0]
#define K100_2	TCaliber[1]
#define K150_1	TCaliber[2]
#define K150_2	TCaliber[3]

#define K100_D	TCaliber[0]
#define K150_D	TCaliber[1]

#define LastMode	Modbus[126].all

#define Commands	Modbus[127].all
#define cTestLamp	Modbus[127].bit.bit0
#define cDefParam	Modbus[127].bit.bit1
#define cSaveParam	Modbus[127].bit.bit2
#define cLoadParam	Modbus[127].bit.bit3

#define cTermoCal	Modbus[127].bit.bit4
#define cKoefCalc	Modbus[127].bit.bit5

#define cUMPreset	Modbus[127].bit.bit6
#define cUMPstart	Modbus[127].bit.bit7
#define cInitDac	Modbus[127].bit.bit8
#define cCalibrDac	Modbus[127].bit.bit9

#define cSecretBt	Modbus[127].bit.bitA
#define cLiteFire	Modbus[127].bit.bitB
#define cRawMeat	Modbus[127].bit.bitC

#define cReset		Modbus[127].bit.bitF

#endif	//PACKAGE

