#ifndef IDIBUS_4CNT_H_
#define IDIBUS_4CNT_H_

#include "IdiBusSlave.h"				//	Common slave defines
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#define IDIBUS_CUSTDEF_ERCODE_COUNTER_CHANNEL_NOT_INITED						100U
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
enum IDIBUS_4CNT_MODULE_DEVICES_LIST {	//	Describe devices on module
	IDIBUS_4CNT_CNTRL_DEV = 0,			//	COUNTER device ID
	IDIBUS_4CNT_DEVICES_NUMBER			//	Device count on module	
	};

enum {									// Describe channel configuration for device (COUNTER)	
	IDIBUS_4CNT_CH1_NUM = 0,			// Name for 1st channel
	IDIBUS_4CNT_CH2_NUM,				//			2nd ...
	IDIBUS_4CNT_CH3_NUM,				//
	IDIBUS_4CNT_CH4_NUM,				//
	IDIBUS_4CNT_CH_COUNT,				// Channel count
	};

typedef struct {
	uint32_t Counter;					// Last returned value
	uint8_t MMES_Error;					// Last error
} IDIBUS_4CNT_DATA_TYPE;				// Data structure for COUNTER channels

class IdiBus_4CNT : public IdiBusSlave {									//	COUNTER module class
	public:																	//	Public methods
 		IdiBus_4CNT ( IdiBusSerialLine *SlaveLine, uint8_t SlaveAddress);		// Init object with specified bus line and addr 
		IdiBus_4CNT();															// init without specified line and addr (default value line=NULL,addr=1)
		 
		uint8_t getChCounts(uint8_t ChNum);										//	Sends MMES and get Counts on ch (writes to CH structure and returns MMES error code)
		void    getAllChsCounts(void);											//	Sends MMES and get Counts on ch (writes to CH structure)
		
		uint8_t initCh(uint8_t ChNum);											// Inits specified counter channel on module
		void    initAllChs(void);												// Inits all counters on module

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