#ifndef IDIBUS_2SALT_H_
#define IDIBUS_2SALT_H_

#include "IdiBusSlave.h"				//	Common slave defines
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#define IDIBUS_CUSTDEF_ERCODE_SALTMETER_POWEROFF								100U
#define IDIBUS_CUSTDEF_ERCODE_SALTMETER_CHANNEL_CAPTURE_IN_PROGRESS				101U
#define IDIBUS_CUSTDEF_ERCODE_SALTMETER_CHANNEL_NOT_SELECTED					102U
#define IDIBUS_CUSTDEF_ERCODE_SALTMETER_CHANNEL_NO_VALID_DATA					103U
#define IDIBUS_CUSTDEF_ERCODE_SALTMETER_CHANNEL_NO_STABLE_DATA					104U
#define IDIBUS_CUSTDEF_ERCODE_SALTMETER_TWI_ERROR								106U
#define IDIBUS_CUSTDEF_ERCODE_SALTMETER_TWI_BUSY								107U
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
enum IDIBUS_2SALT_MODULE_DEVICES_LIST {	//	Describe devices on module
	IDIBUS_2SALT_CNTRL_DEV = 0,			//	SALT device ID
	IDIBUS_2SALT_DEVICES_NUMBER			//	Device count on module	
	};

enum {									// Describe channel configuration for device (SALT)	
	IDIBUS_2SALT_CH0_NUM = 0,			// Name for 1st channel
	IDIBUS_2SALT_CH1_NUM,				//			2nd ...
	IDIBUS_2SALT_CH_COUNT,				// Channel count
	};

typedef struct {
	uint16_t Voltage;					// Last returned value
	uint8_t MMES_Error;					// Last error
} IDIBUS_2SALT_DATA_TYPE;				// Data structure for SALT channels

class IdiBus_2SALT : public IdiBusSlave {									//	SALT module class
	public:																	//	Public methods
 		IdiBus_2SALT ( IdiBusSerialLine *SlaveLine, uint8_t SlaveAddress);		// Init object with specified bus line and addr 
		IdiBus_2SALT();															// init without specified line and addr (default value line=NULL,addr=1)
		 
		uint8_t getChSaltData(uint8_t ChNum);										//	Sends MMES and get Counts on ch (writes to CH structure and returns MMES error code)
		void    getAllChsSaltData(void);											//	Sends MMES and get Counts on ch (writes to CH structure)

		uint8_t startOneShot(uint8_t ChNum);
		void	startAllOneShot(void);
		
		uint8_t setCh(uint8_t ChNum, uint8_t state);							// Inits specified counter channel on module
		void    setAllCh(uint8_t state);										// Inits all counters on module

		IDIBUS_2SALT_DATA_TYPE  getChData(uint8_t ChNum);						// Returns data structure
	
	protected:																// 'Private' methods and structures			
		IDIBUS_2SALT_DATA_TYPE  CH[IDIBUS_2SALT_CH_COUNT];						// Data structure array
		
		void    setAllChErr(uint8_t ErrCode);									// Set error code for all channels
};
#endif
