#ifndef EPDEVICE_H_
#define EPDEVICE_H_

#include "gvalue.h"
#include "gType.h"
#include "my_string.h"

#define dEpDevTypeMin	dgTYPE_COMM_CHANNEL	//13
#define dEpDevTypeMax	dgTYPE_DISPLAY_PAD_I	//23	

typedef union{
	unsigned int D32[2];
	unsigned char D8[8];
	struct{
		unsigned char Sensitivity;
		unsigned char UpPoint;
		unsigned char DownPoint;
		unsigned char Pollute ;
		unsigned char IRVal;
		unsigned char BlueVal;
		unsigned char P1;
		unsigned char P2;
	}Smoke;
	struct{
		unsigned char AlarmPoint;
		unsigned char WarningPoint;
		unsigned char HoldTime_100mS;
		unsigned char DegVal;
	}Tempe;
	struct{
		unsigned char Sensitivity;
		unsigned char UpPoint;
		unsigned char DownPoint;
		unsigned char Pollute ;

		unsigned char AlarmPoint;
		unsigned char WarningPoint;
		unsigned char HoldTime_100mS;
		unsigned char DegVal;
	}SmokeTempe;
	struct{
		unsigned char OnOff;
	}HandReport;
	struct{
		unsigned char OnOff[4];
	}IsoInput;
	struct{
		unsigned char OnOff[4];
	}IsoOutput;
	struct{
		unsigned char InOnOff[2];
		unsigned char OutOnOff[2];
	}IsoIo;
	struct{
		unsigned char BellOnOff;
		unsigned char LumOnOff;
	}VaAlram;
	struct{
		unsigned char Lum;
		unsigned char Size;
		unsigned char *pchar;
	}Display;
	struct{
		unsigned char AlarmPoint;
		unsigned char WarningPoint;
		unsigned char Rsv0;
		unsigned char Rsv1;
		unsigned short dVal;
		unsigned short dump0;
	}Quake;
	struct{
		unsigned char AlarmPoint;
		unsigned char WarningPoint;
		unsigned char Rsv0;
		unsigned char Rsv1;
		unsigned short dVal;
		unsigned short dump0;
	}Radar;
}TEpPrm;


typedef union{
	unsigned int  D32;
	unsigned char D8[4];
	struct{
		unsigned char dType;
		unsigned char Id;
		unsigned char PortNum;
		unsigned char Flag;
		//unsigned int UserCode;
	}Split;
}TEpData;

class TEpDevice {
	public:
		//TEpData fData;
		//TEpPrm  fPrm;
		//unsigned short DynamicsFlag;
		//unsigned char NotUpdataHours;
		//unsigned char Not2;
	private:
		unsigned int Calc_Addr4EpData(void);
		unsigned int Calc_Addr4EpDataPage(void);
		unsigned int Calc_Addr4EpDataSector(void);
		unsigned int Calc_D4K_PageIndex(void);
		void Copy_DataFrom4KData(unsigned int *D4K);
		void Write_DataTo4KData(unsigned int *D4K);

	public:
		TEpDevice(void){
			//fData.D32= 0;

			//fPrm.D32[0] = 0;
			//fPrm.D32[1] = 0;
		}
		void AssignByData(unsigned int *da);
		
		void PrintSensitivity(TMyString *Str0);
		void PrintProperty(TMyString *Str0, TMyString *Str1, TMyString *Str2);			//UserCode Id dType
		void PrintAttribute(TMyString *Str0, TMyString *Str1, TMyString *Str2, TMyString *Str3);
		void PrintAttribute(TMyString *Str0, TMyString *Str1, TMyString *Str2, TMyString *Str3, TMyString *Str4, TMyString *Str5, TMyString *Str6, TMyString *Str7 );
		void PrintAttributeWithAName(TMyString *Str0, TMyString *Str1, TMyString *Str2, TMyString *Str3);
		void PrintAttributeWithAName(TMyString *Str0, TMyString *Str1, TMyString *Str2, TMyString *Str3, TMyString *Str4, TMyString *Str5, TMyString *Str6, TMyString *Str7 );
		void PrintDynamicsData(TMyString *Str0, TMyString *Str1, TMyString *Str2, TMyString *Str3, TMyString *Str4, TMyString *Str5);
		
		void GetDescp(char *StrGot);
		void SetDescp(char *StrPut);
		
		void SetSmokePrm(unsigned char aSensitivity, unsigned char TimeDelay, unsigned short A, unsigned short B);
		void GetSmokePrm(TEpDevice *aInstantial);
		
		void SetTempePrm(unsigned char aSensitivity, unsigned char Prm1, unsigned short Prm2, unsigned short Prm3);
		void GetTempePrm(unsigned char *pSensitivity, unsigned char *pPrm1, unsigned short *pPrm2, unsigned short *pPrm3);
		
		unsigned int GetInputModuleChannelCount(void);
		unsigned int GetOutputModuleChannelCount(void);
		unsigned int GetInOutModuleInChannelCount(void);
		unsigned int GetInOutModuleOutChannelCount(void);
		void SetInputModuleChannelCount(unsigned int aCount);
		void SetOutputModuleChannelCount(unsigned int aCount);
		void SetInOutModuleInChannelCount(unsigned int aCount);
		void SetInOutModuleOutChannelCount(unsigned int aCount);
		
};



#endif

