#ifndef IDIBUS_4ADC_H_
#define IDIBUS_4ADC_H_

#include "IdiBusSlave.h"				//	Common slave defines
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#define IDIBUS_CUSTDEF_ERCODE_ADC_NOT_INITED						100U
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
enum IDIBUS_4ADC_MODULE_DEVICES_LIST {	//	Describe devices on module
	IDIBUS_4ADC_CNTRL_DEV = 0,			//	ADC device ID
	IDIBUS_4ADC_DEVICES_NUMBER			//	Device count on module
	};

enum {									//	Describe channel configuration for device (ADC)
	IDIBUS_4ADC_CH1_NUM = 0,			//	Name for 1st channel
	IDIBUS_4ADC_CH2_NUM,				//			 2nd ...
	IDIBUS_4ADC_CH3_NUM,				//
	IDIBUS_4ADC_CH4_NUM,				//
	IDIBUS_4ADC_12V_NUM,				//	Name for 12v adc channel
	IDIBUS_4ADC_24V_NUM,				//	Name for 24v adc channel
	IDIBUS_4ADC_CH_COUNT,				//	Channel count
	};

typedef struct {
	uint16_t Voltage;		//	Last voltage
	uint8_t MMES_Error;		//	Last error
} IDIBUS_4ADC_DATA_TYPE;	//	Data structure for ADC channels

class IdiBus_4ADC : public IdiBusSlave {									//	ADC module class
	public:																	//	Public methods 
 		IdiBus_4ADC ( IdiBusSerialLine *SlaveLine, uint8_t SlaveAddress);		// Init object with specified bus line and addr
		IdiBus_4ADC();															// init without specified line and addr (default value line=NULL,addr=1)
		 	
		uint8_t getChVoltage(uint8_t ChNum);									// Sends MMES and gets Ch voltage (writes to CH structure and return error code)
		void    getAllAdcVoltage(void);											// Sends MMES and gets all Ch voltages (writes to CH structure)
			
		void    initAllChs(void);												// Inits all adc channels on module
	
		IDIBUS_4ADC_DATA_TYPE  getChData(uint8_t ChNum);						// Returns data structure for ADC channel
	
	protected :																// 'Private' methods and structures
		IDIBUS_4ADC_DATA_TYPE  CH[IDIBUS_4ADC_CH_COUNT];						// Data structure array
			
		void    setAllChErr(uint8_t ErrCode);									// Set error code for all channels
};

#endif /* IDIBUS_4ADC_H_ */