#ifndef IDIBUS_3Thermo1HT_H_
#define IDIBUS_3Thermo1HT_H_

#include "IdiBusSlave.h"				//	Common slave defines
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#define IDIBUS_CUSTDEF_ERCODE_THERMO_CHANNEL_NO_SENSOR						100U
#define IDIBUS_CUSTDEF_ERCODE_THERMO_CHANNEL_NO_DATA						101U
#define IDIBUS_CUSTDEF_ERCODE_THERMO_CHANNEL_OVER_UNDER_VOLTAGE				102U
#define IDIBUS_CUSTDEF_ERCODE_THERMO_CHANNEL_TC_OUT_OF_RANGE				103U
#define IDIBUS_CUSTDEF_ERCODE_THERMO_CHANNEL_CJ_OUT_OF_RANGE				104U
#define IDIBUS_CUSTDEF_ERCODE_THERMO_CHANNEL_AUTOCONVERSION_ENABLED			105U	
#define IDIBUS_CUSTDEF_ERCODE_THERMO_CHANNEL_ONESHOT_IN_PROGRESS			106U	
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
enum IDIBUS_3Thermo1HT_MODULE_DEVICES_LIST {	//	Describe devices on module
	IDIBUS_3Thermo1HT_THERMO_DEV = 0,			//	Thermocouple device ID
	IDIBUS_3Thermo1HT_HEATER_DEV,			//	Heater device ID
	IDIBUS_3Thermo1HT_DEVICES_NUMBER			//	Device count on module
	};

enum {									//	Describe channel configuration for device (3Thermo1HT)
	IDIBUS_3Thermo1HT_Thermo_CH0_NUM = 0,			//	Name for 1st channel
	IDIBUS_3Thermo1HT_Thermo_CH1_NUM,				//			 2nd ...
	IDIBUS_3Thermo1HT_Thermo_CH2_NUM,				//
	IDIBUS_3Thermo1HT_Thermo_CH_COUNT				// Module channel count
	};

class IdiBus_3Thermo1HT_ThermoChannel: public IdiBusChannel {
	public:
		IdiBus_3Thermo1HT_ThermoChannel(void);
		int32_t Temperature;		//	Last temperature 
		int16_t CJTemperature;		//	Last temperature 
}; 

class IdiBus_3Thermo1HT_ThermoDevice : public IdiBusDevice {									
	public:																	
		IdiBus_3Thermo1HT_ThermoDevice (void *ParentModule) : IdiBusDevice (ParentModule) {}

		uint8_t startOneShotConversion(uint8_t ChNum);
		uint8_t changeAutomatiocConversionState(uint8_t ChNum);
		uint8_t getTemperature(uint8_t ChNum);										
		uint8_t getCJTemperature(uint8_t ChNum);										

		void	startAllOneShotConversions();
		void	changeAllAutomatiocConversionStates();
		void    getAllChTemperature(void);												
		void    getAllChCJTemperature(void);											
			
	
		IdiBus_3Thermo1HT_ThermoChannel  getChData(uint8_t ChNum);				
	
	protected :																
		IdiBus_3Thermo1HT_ThermoChannel  CH[IDIBUS_3Thermo1HT_Thermo_CH_COUNT];						
		virtual IdiBusChannel *getChannel(uint8_t Num);

		void    setAllChErr(uint8_t ErrCode);									
};

class IdiBus_3Thermo1HT : public IdiBusSlave {
	public:
		IdiBus_3Thermo1HT (IdiBusSerialLine *SlaveLine, uint8_t SlaveAddress) : IdiBusSlave(SlaveLine, SlaveAddress), THERMO_DEV(this)/*, INPV_DEV(this)*/  {}
		IdiBus_3Thermo1HT() : IdiBusSlave(), THERMO_DEV(this)/*, INPV_DEV(this)*/ {}

		virtual IdiBusDevice *getDevice(uint8_t Num);

		IdiBus_3Thermo1HT_ThermoDevice THERMO_DEV;		 		
};

#endif /* IDIBUS_43Thermo1HT_H_ */