#ifndef DEVPROPERTY_H_
#define DEVPROPERTY_H_


#include "gType.h" 
#include "GraphLow.h"
#include "GraphBase.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "my_string.h"
#include "Device.h"
#include "EpDevice.h"
#include "StaticText.h"
#include "TEdit.h"
#include "CtlPanel1.h"

#define dCurveGridClr	clBlack

//For Query Device Function to PopUp Show One Device Property   Key:Value      Edit or View
class TDevProperty{
	public:
		static constexpr unsigned short hList[12] = {72,72,72,72,	72,72,34,34,	34,34,34,34};
		static constexpr unsigned short wList[12] = {800,290,290,290,	290,290,290,290,	290,290,290,290};
		static constexpr TLv Lv = {
			.Caption.Left = 0,
			.Caption.Top = 36,
			.Caption.Width = 800,
			.Caption.Heigh = 32,
			.Caption.Right = 800 -0 -1,
			.Caption.Bottom = 36 + 32,
			
			.Grid.Left = {0,0,0,0,	0,0,0,0,	0,0,0,0},
			.Grid.Right = {wList[0]-1,wList[1]-1,wList[2]-1,wList[3]-1,	wList[4]-1,wList[5]-1,wList[6]-1,wList[7]-1,	wList[8]-1,wList[9]-1,wList[10]-1,wList[11]-1},
			.Grid.Top[0] = (36 + 32 +2),
			.Grid.Top[1] = (36 + 32 +2) + (2 + hList[0]),
			.Grid.Top[2] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]),
			.Grid.Top[3] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]),
			.Grid.Top[4] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]),
			.Grid.Top[5] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]),
			.Grid.Top[6] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]),
			.Grid.Top[7] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]),
			.Grid.Top[8] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]),
			.Grid.Top[9] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + (2 + hList[8]),
			.Grid.Top[10] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + (2 + hList[8]) + (2 + hList[9]),
			.Grid.Top[11] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + (2 + hList[8]) + (2 + hList[9]) + (2 + hList[10]),
				
			.Grid.Bottom[0] = (36 + 32 +2) + hList[0],
			.Grid.Bottom[1] = (36 + 32 +2) + (2 + hList[0]) + hList[1],
			.Grid.Bottom[2] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + hList[2],
			.Grid.Bottom[3] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + hList[3],
			.Grid.Bottom[4] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + hList[4],
			.Grid.Bottom[5] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + hList[5],
			.Grid.Bottom[6] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + hList[6],
			.Grid.Bottom[7] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + hList[7],
			.Grid.Bottom[8] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + hList[8],
			.Grid.Bottom[9] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + (2 + hList[8]) + hList[9],
			.Grid.Bottom[10] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + (2 + hList[8]) + (2 + hList[9]) + hList[10],
			.Grid.Bottom[11] = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + (2 + hList[4]) + (2 + hList[5]) + (2 + hList[6]) + (2 + hList[7]) + (2 + hList[8]) + (2 + hList[9]) + (2 + hList[10]) + hList[11],
			
			.Grid.UsingCount = 5,
			
			.Panel.Active = 1,
			.Panel.ItemType = piMemo,
			.Panel.Left = wList[1] + 6,
			.Panel.Top = (36 + 32 +2) + hList[0] +6,
			.Panel.Width = 502,
			.Panel.Heigh = 220,
			.Panel.Right = wList[1] + 6 + 502 -1,
			.Panel.Bottom = (36 + 32 +2) + hList[0] +6 + 220 -1,
			
			.PanelSmall.Active = 1,
			.PanelSmall.Left = wList[1] + 6,
			.PanelSmall.Top = (36 + 32 +2) + hList[0] +6 + 220 -1 + 1,
			.PanelSmall.Width = 502,
			.PanelSmall.Heigh = 72,
			.PanelSmall.Right = wList[1] + 6 + 502 -1,
			.PanelSmall.Bottom = (36 + 32 +2) + hList[0] +6 + 220 -1 + 1 + 72 -1,
		};
		static constexpr TRect ModuleRectLv3 = {
			.Top = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]),
			.Bottom = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + hList[3] + 30, 
			
		};
		static constexpr TRect ModuleRectLv4 = {
			.Top = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + 30,
			.Bottom = (36 + 32 +2) + (2 + hList[0]) + (2 + hList[1]) + (2 + hList[2]) + (2 + hList[3]) + hList[4], 
		};
		static const unsigned int LvGridHighBottom3 = 102;
		static constexpr unsigned char dTypeList[256] = {
			dgTYPE_SMOKE_DETECTOR,
			dgTYPE_TEMPE_DETECTOR,
			dgType_VAALRAM,
		};
		static constexpr unsigned char dSmokeSensGrade_MarkValue[8] = {
			//100, 75, 50, 25
			0, 100, 75, 50, 25, 0, 0, 0
		};
		enum THwDevType{
			htNoType = 0,
			htSmoker = 1,
			htTempe =2,
			htHandPad,
			htHydrantPad,
			htModuleIn,
			htModuleInOut,
			htModuleOut,
			htVa,
			htDisplayPad,
			htLinkagePowerSuply
		};
		enum TPermissionCmd{
			pcWriteDescp = 0,
			pcWriteUserCode = 1,
			pcWriteAssignType,
			pcWriteAreaInx,
			pcWriteSmokerSens,
			pcWriteTempeSensType,
			pcWriteModuleDefineType,
			pcWriteModuleSignalInType,
			pcWriteModuleSignalInOutType,
			pcWriteModuleSignalOutType,
			pcWriteVaIsLinkageAble,
			pcWriteVaSetting,
			pcWriteDisplayPadMatchData,
			pcLightUp,
			pcSimAlram,
			pcSimStart,
			pcSimInputActive,
			pcDisplayPadMute,
			pcDownLoadDescp,
			pcStart,
			pcStop,
			pcEditDescp,
			pcWriteNoTypeSignalInOutType,
		};
		enum TDrawTextType{
			dtNone = 0,
			dtHex =1,
			dtDec =2
		};
		static char Text4CmpInc[16];
	private:
		int EnterMethod;
		int IsPermission;
		TPermissionCmd PermissionCmd;
		int EdittingDescp;
		int IsExtInput;
		unsigned char PortNumValid;
		unsigned char AddrNumValid;
		unsigned char PanelIsUsingText;
		TStaticText Caption;
	
		unsigned int Index;
		unsigned int  BorderWidth;
	
		TRect Bound;
		TRect Content;
		TRect ValueArea;
		TRect RectCaption;
	
		unsigned int Color;
		unsigned int xKey;
		unsigned int xValue;
		unsigned int yLine[8];
		
		struct{
			unsigned char InxMin;
			unsigned char InxMax;
			unsigned char Inx;
			void Reset(){
				InxMin = 0;
				InxMax =2;
			}
		}Tag;
		
		union{
			unsigned char D8[256];
			unsigned short D16[128];
			unsigned int  D32[64];
		}ReadWriteData;
		TUserCode aUcSetting;
		unsigned char AssignTypeSetting; 
		unsigned short AreaNum;
		
		unsigned char RecData[8];
		
		union{
			unsigned int D32;
			struct{
				unsigned char pCtl;
				unsigned char P0;
				unsigned char P1;
				unsigned char P2;
			}Body;
		}aFullPath;
		
		char TextTmp[24];
		struct{
			int TextDrawLine;
			int FigInx;
			unsigned char IsHexList[8];
			unsigned char LinePiece[4];
			unsigned char DesertTextHex;
			unsigned char UsingTextHex;
			void Reset(){
				for(int i=0; i<8; i++)IsHexList[i]=dtNone;
				LinePiece[0]=0;LinePiece[1]=0;LinePiece[2]=0;LinePiece[3]=0;
				TextDrawLine = 0;
				FigInx = 0;
				//DesertTextHex = 0;
				//UsingTextHex = 0;
			}
			void ResetNotFull(){
				TextDrawLine = 0;
				FigInx = 0;
				LinePiece[0]=0;LinePiece[1]=0;LinePiece[2]=0;LinePiece[3]=0;
			}
		}PanelDrawData;
		
		struct{
			unsigned int Color[4];
			int UsingDataTypeCnt;
			int MaxDataLen;
			int DataLen;
			int CurrentPst;
			int HasDrawOutline;
			struct{
				int PstStart;
				int PstEnd;
			}HasDraw;
			
			float Scaling[4];
			
			struct{
				short Width;
				short Height;
				short OrgX;
				short OrgY;
				short MaxX;
				short MaxY;
			}Canvas;
			
			short Left;
			short Top;
			short Right;
			short Bottom;
			short Width;
			short Height;
			
			short GridX[16];
			short GridY[16];
			short GridXCount;
			short GridYCount;
			short GridXWidth;
			short GridYHeight;
			
			struct{
				unsigned char DataAva[4];
				short IR;
				short Blue;
				short MVal;
				short Dump0;
			}Smoke;
			struct{
				unsigned char DataAva[4];
				short Val;
				short Celsius;
				short Dump0;
				short Dump1;
			}Tempe;
			unsigned short HasUpdate;
		}Curve;
	public:
		static class TItemList	*sIList;
		class TItemList	*IList;
		int IsShow;
		TCtlPanel1	*aPanel;
		unsigned char CtlNum;
		unsigned char Path0;
		unsigned char Path1;
		unsigned char dType;
		unsigned char IsRegisted;
	
		unsigned char SmokerReadWriteSta;
		unsigned char TempeReadSta;
		unsigned char VaReadWriteSta;
		unsigned char DisplayPadReadWriteSta;
		unsigned char DisplayPadDownloadDescpSta;
		
		THwDevType HwDevType;
		TRootDevice *RootDev;
		TEpDevice *EpDev;
	
		TDisplayPadSetting DpSetting;
	
		struct{
			TUserCode UserCode;
			unsigned char NoTypeSignalInOutType;
			unsigned char SmokerSens;
			unsigned char TempeSenType;
			unsigned char ModuleDefineType;
			
			unsigned char ModuleSignalInType;
			unsigned char ModuleSignalInOutType;
			unsigned char ModuleSignalOutType;
			unsigned char VaIs4Linkage;
			
			unsigned char VaVisionType;
			unsigned char VaSoundType;
			unsigned char DisplayPadMatchMode;	//0:By User Code;	1:By Area Assign
			unsigned char DumpChar0;
			
			unsigned char DisplayPadAreaUsing[4];
			unsigned char DisplayPadUserCodeUsing[4];
			unsigned short DisplayPadArea0;
			unsigned short DisplayPadArea1;
			unsigned short DisplayPadArea2;
			unsigned short DumpShort0;
			unsigned int DisplayUserCode0;
			unsigned int DisplayUserCode1;
			unsigned char GotTempeSensType[8];
			void Reset(){
				UserCode.Full =0;
				NoTypeSignalInOutType =0;
				SmokerSens = 0;
				TempeSenType = 0;
				ModuleDefineType =0;
				ModuleSignalInType =0;
				ModuleSignalInOutType =0;
				ModuleSignalOutType =0;
				VaIs4Linkage =0;
				VaVisionType =0;
				VaSoundType =0;
				DisplayPadMatchMode =0;	//0:By User Code;	1:By Area Assign
				DisplayPadAreaUsing[0] = 0;
				DisplayPadAreaUsing[1] = 0;
				DisplayPadAreaUsing[2] = 0;
				DisplayPadUserCodeUsing[0] = 0;
				DisplayPadUserCodeUsing[1] = 0;
				DisplayPadArea0 =0;
				DisplayPadArea1 =0;
				DisplayPadArea2 =0;
				DisplayUserCode0 =0;
				DisplayUserCode1 =0;
				GotTempeSensType[0] =0;
				GotTempeSensType[1] =0;
				GotTempeSensType[2] =0;
				GotTempeSensType[3] =0;
				GotTempeSensType[4] =0;
			}
		}Data;
		struct{
			unsigned char VaIs4Linkage;
			unsigned char VaVisionType;
			unsigned char VaSoundType;
			unsigned char Dump0;
		}ExData;
		struct{
			unsigned short voltage;
			unsigned short SmokerPrmM;
			unsigned short SmokerIR;
			unsigned short SmokerBL;
			unsigned short TempeOriginData;
			unsigned short TempeCelsiusData;
			unsigned short ModuleInAdVal; 
			unsigned short DisplayPadAlramCount;
			unsigned short BatVoltage;
			unsigned short BatEnergy;
			unsigned short OutputVoltage;
			unsigned short OutputCurrent;
			unsigned short PwrLoaddingPercent;
			unsigned char MacHasUpdate;
			unsigned char MacPath0;
			unsigned char MacPath1;
			unsigned char DumpByte;
			unsigned char Mac[8];
			void Reset(){
				voltage =0;
				SmokerPrmM =0;
				SmokerIR =0;
				SmokerBL =0;
				TempeOriginData =0;
				TempeCelsiusData =0;
				ModuleInAdVal =0;
				DisplayPadAlramCount =0;
				BatVoltage =0;
				BatEnergy =0;
				OutputVoltage =0;
				OutputCurrent =0;
				PwrLoaddingPercent =0;
				MacHasUpdate =0;
				MacPath0=0;
				MacPath1=0;
				for(int i=0; i<8; i++)Mac[i] =0;
			}
		}RuntimeData;
		unsigned char CommData[16];
		struct{
			unsigned char Method;
			unsigned char P0;
			unsigned char P1;
			unsigned char DevType;
			unsigned char DataType;

			unsigned char dVal[4];
			unsigned char dValGot[4];
			unsigned char dType;
		}ProcessingRt;
		struct{
			unsigned char  IsWait4ReadOutputLineCheck;
			unsigned char  RecRdy;
			unsigned char  RecCmd;
			unsigned char  WaitTick;
			unsigned char  IsToCheck;
		}NoTypeRt;
		struct{
			unsigned char  IsWait4ReadSens;
			unsigned char  IsWait4WriteSens; 
			unsigned char  RecRdy;
			unsigned char  RecCmd;
			unsigned char  WaitTick;
		}SmokerRt;
		struct{
			unsigned char  IsWait4ReadSensType;
			unsigned char  RecRdy;
			unsigned char  RecCmd;
			unsigned char  WaitTick;
		}TempeRt;
		struct{
			unsigned char  IsWait4ReadSignalType;
			unsigned char  IsWait4WriteSignalType;
			unsigned char  RecRdy;
			unsigned char  RecCmd;
			unsigned char  WaitTick;
		}ModuleInRt;
		struct{
			unsigned char  IsWait4ReadStaticData;
			unsigned char  IsWait4WriteStaticData;
			unsigned char  RecRdy;
			unsigned char  RecCmd;
			unsigned char  WaitTick;
			unsigned char  rOutputType;
			unsigned char  wOutputType;
			unsigned char  rCheck;
			unsigned char  wCheck;
		}ModuleInOutRt;
		struct{
			unsigned char  IsWait4ReadStaticData;
			unsigned char  IsWait4WriteStaticData;
			unsigned char  RecRdy;
			unsigned char  RecCmd;
			unsigned char  WaitTick;
			unsigned char  rOutputType;
			unsigned char  wOutputType;
			unsigned char  rCheck;
			unsigned char  wCheck;
		}ModuleOutRt;
		struct{
			unsigned char  IsWait4ReadVaSetting;
			unsigned char  IsWait4WriteVaSetting;
			unsigned char  RecRdy;
			unsigned char  RecCmd;
			unsigned char  WaitTick;
		}VaRt;
		struct{
			unsigned char  IsMute;
			unsigned char  IsDownloadDescp;
			unsigned char  RecRdy;
			unsigned char  RecCmd;
			unsigned char  WaitTick;
			char DescpText[36];
		}DisplayPadRt;
		char TextDraw[40];
		char DebugBytes[16];
		struct{
			unsigned char HasOn;
			unsigned char PNum;
			unsigned char P0;
			unsigned char P1;
		}HasLightOn;
		unsigned char DevLightOn;
	public:
		TDevProperty(){};
		void Init(THwDevType aDevType, int aMode);
		static void sDelayMs(unsigned int aMs);
			
		void RenderBackGround(void);
		void RenderBackGround(unsigned int aClr);
		void SetEditMode(unsigned int aMode); 
		
		void DrawSelf(void);
		void DrawCaption(void);
		void RenderProperty(unsigned int DrawType);	//DrawType=1:Draw Key;   DrawType=2:Draw Value;    DrawType=3:Draw Key & Value
		void DrawStrKey(void);
		void DrawStrValue(void);
		void Show(void);
		void FullRedraw(int Prm);
			
		void DrawStateCn(unsigned char aSta);
		void DrawStateEn(unsigned char aSta);
		void DrawState(unsigned char aSta);
		void DrawMac();
			
		void DisplayPadShowDownloadDescpSta();
		void DisplayPadShowDownloadDescpSta(unsigned char aSta);
		
		void Redraw4NoTypeSmallPanelWithNoData();
		void Redraw4SmokerSmallPanelData();
		void Redraw4TempeSmallPanelData();
		void Redraw4HandPadSmallPanelData();
		void Redraw4HydrantPadSmallPanelData();
		void Redraw4ModuleInSmallPanelData();
		void Redraw4ModuleInOutSmallPanelData();
		void Redraw4ModuleOutSmallPanelData();
		void Redraw4VaSmallPanelData();
		void Redraw4DisplayPadSmallPanelData();
		void Redraw4LinkagePowerSuplySmallPanelData();
			
		void ReDrawCommonInf();
		void ClearCommonInf();
		
		void Redraw4NewLoad();
		void Redraw4NoTypeNewLoad();
		void Redraw4SmokerNewLoad();
		void Redraw4TempeNewLoad();
		void Redraw4HandPadNewLoad();
		void Redraw4HydrantPadNewLoad();
		void Redraw4ModuleInNewLoad();
		void Redraw4ModuleInOutNewLoad();
		void Redraw4ModuleOutNewLoad();
		void Redraw4VaNewLoad();
		void Redraw4DisplayPadNewLoad();
		void Redraw4LinkagePowerSuplyNewLoad();
			
		void SetPath(unsigned char aCtlNum, unsigned char Path0, unsigned char Path1);
			
		void UpdataOnlineData();
		void DrawCommonInfTitle();
		void RedrawCommonInfTitle();
		void RenewCommonInf();
		void Redraw4DescpEdit();
		void ReLoadAndDrawDescp();
		void ReadAllEpUserCode();
			
		void Init4DType();
		void InitNoType();
		void InitHtSmoker();
		void InitHtTempe();
		void InitHtHandPad();
		void InitHtHydrantPad();
		void InitHtModuleIn();
		void InitHtModuleInOut();
		void InitHtModuleOut();
		void InitHtVa();
		void InitHtDisplayPad();
		void InitHtLinkagePowerSuply();
		
		void EditDescpReturnHtNoType();
		void EditDescpReturnHtSmoker();
		void EditDescpReturnHtTempe();
		void EditDescpReturnHtHandPad();
		void EditDescpReturnHtHydrantPad();
		void EditDescpReturnHtModuleIn();
		void EditDescpReturnHtModuleInOut();
		void EditDescpReturnHtModuleOut();
		void EditDescpReturnHtVa();
		void EditDescpReturnHtDisplayPad();
		void EditDescpReturnHtLinkagePowerSuply();
		
		void ClearSelected();
		void ClearSelectedNoType();		
		void ClearSelectedHtSmoker();
		void ClearSelectedHtTempe();
		void ClearSelectedHtHandPad();
		void ClearSelectedHtHydrantPad();
		void ClearSelectedHtModuleIn();
		void ClearSelectedHtModuleInOut();
		void ClearSelectedHtModuleOut();
		void ClearSelectedHtVa();
		void ClearSelectedHtDisplayPad();
		void ClearSelectedHtLinkagePowerSuply();
		
		void Check4Selected();
		void Check4SelectedNoType();
		void Check4SelectedHtSmoker();
		void Check4SelectedHtTempe();
		void Check4SelectedHtHandPad();
		void Check4SelectedHtHydrantPad();
		void Check4SelectedHtModuleIn();
		void Check4SelectedHtModuleInOut();
		void Check4SelectedHtModuleOut();
		void Check4SelectedHtVa();
		void Check4SelectedHtDisplayPad();
		void Check4SelectedHtLinkagePowerSuply();
		
		void DrawLightOnStateSmoke(int aPrm =0);
		void DrawLightOnStateTempe(int aPrm =0);
		void DrawLightOnStateHandPad(int aPrm =0);
		void DrawLightOnStateHydrantPad(int aPrm =0);
		void DrawLightOnStateModuleIn(int aPrm =0);
		void DrawLightOnStateModuleInOut(int aPrm =0);
		void DrawLightOnStateModuleOut(int aPrm =0);
		
		void DrawCommonInfTitleFixText();
		void DrawFixTextNoType();
		void DrawFixTextSmoker();
		void DrawFixTextTempe();
		void DrawFixTextHandPad();
		void DrawFixTextHydrantPad();
		void DrawFixTextModuleIn();
		void DrawFixTextModuleInOut();
		void DrawFixTextModuleOut();
		void DrawFixTextVa();
		void DrawFixTextDisplayPad();
		void DrawFixTextLinkagePowerSuply();

		TGuiMsgReturn KeyInHtNoType(unsigned char aKey);
		TGuiMsgReturn KeyInHtSmoker(unsigned char aKey);
		TGuiMsgReturn KeyInHtTempe(unsigned char aKey);
		TGuiMsgReturn KeyInHtHandPad(unsigned char aKey);
		TGuiMsgReturn KeyInHtHydrantPad(unsigned char aKey);
		TGuiMsgReturn KeyInHtModuleIn(unsigned char aKey);
		TGuiMsgReturn KeyInHtModuleInOut(unsigned char aKey);
		TGuiMsgReturn KeyInHtModuleOut(unsigned char aKey);
		TGuiMsgReturn KeyInHtVa(unsigned char aKey);
		TGuiMsgReturn KeyInHtDisplayPad(unsigned char aKey);
		TGuiMsgReturn KeyInHtLinkagePowerSuply(unsigned char aKey);
		
		TGuiMsgReturn KeyIn(unsigned char aKey);
		TGuiMsgReturn KeyInCommonEdit(unsigned char aKey);
		TGuiMsgReturn KeyInCommonEnter(unsigned char aKey);
			
		void SetEnterMethod(int aMt);
			
		void InitPanel();
		
		void SendSmokeCmdRead();
		void SendTempeCmdRead();
		void SendSmokeCmdCfg();
		void SendTempeCmdCfg();
		void SendModuleSignalInOutTypeRead();
		void SendModuleSignalInOutTypeWrite();
		void SendModuleSignalOutTypeRead();
		void SendModuleSignalOutTypeWrite();
		void SendVaSettingRead();
		void SendVaSettingWrite();
		void SendDisplayPadDescpDownload();
		
		void SendReqMac();
		void SendCmdLightOn();
		void SendCmdLightOff();
		void SendCmdMuteBroadcast();
		void SendCmdMute();
		void SendDisplayPadMute();
		void SendLinkagePowerSuplyMute();
		
		void RedrawSmokeSensValue();
		void RedrawTempeSensType();
		void RedrawModuleInDefineType();
		void RedrawModuleInSignalInType();
		void RedrawModuleInOutDefineType();
		void RedrawModuleOutDefineType();
		void RedrawModuleInOutSignalType();
		void RedrawModuleOutSignalType();
		void RedrawVaIs4Linkage();
		void RedrawVaSetting();
		void RedrawDisplayPadMatchMode();
		void RedrawDisplayPadMatchData();
		
		void ResetTargetData();
		void RealTimeSendCmd(const int StartStop);
		void RealTimeSendCmdAbort();
		void RunTimeSendCmd(const int StartStop);
		
		void PushInnerCanData(unsigned char aCmd, unsigned char *pData);
		void PushSmokeCanData(unsigned char aCmd, unsigned char *pData);
		void PushTempeCanData(unsigned char aCmd, unsigned char *pData);
		void PushModuleInCanData(unsigned char aCmd, unsigned char *pData);
		void PushModuleInOutCanData(unsigned char aCmd, unsigned char *pData);
		void PushModuleOutCanData(unsigned char aCmd, unsigned char *pData);
		void PushVaCanData(unsigned char aCmd, unsigned char *pData);
		void PushDisplayPadCanData(unsigned char aCmd, unsigned char *pData);
		void PushLinkagePowerSuplyCanData(unsigned char aCmd, unsigned char *pData);
		
		void PushInnerCanRuntimeData(unsigned char aCmd, unsigned char *pData);
		
		void PushOneRealDataReport(u8 aP0, u8 aP1, u8 aInx, u8 D0, u8 D1, u8 D2, u8 D3);
		void RuntimeDataPrc(u8 aInx, u8 D0, u8 D1, u8 D2, u8 D3);
		

		
		void PermissionCmdGO();
		void PermissionCmdReturnDraw();
		void ReDrawPanel();
		void RedrawPanelData();
		
		void LoadUcBcdText(unsigned int aUcFull, char * pText);
		unsigned int RestoreUcBcdText(char * pText);
		
		void ClearReqDataState();		
		void FullRedrawNoType(int Prm);
		void FullRedrawhtSmoker(int Prm);
		void FullRedrawhtTempe(int Prm);
		void FullRedrawhtHandPad(int Prm);
		void FullRedrawhtHydrantPad(int Prm);
		void FullRedrawhtModuleIn(int Prm);
		void FullRedrawhtModuleInOut(int Prm);
		void FullRedrawhtModuleOut(int Prm);
		void FullRedrawhtVa(int Prm);
		void FullRedrawhtDisplayPad(int Prm);
		void FullRedrawhtLinkagePowerSuply(int Prm);
		
		void DrawSmokerReadWriteStates();
		void DrawSmokerReadWriteStates(unsigned char aNewState);
		void DrawTempeReadStates();
		void DrawTempeReadStates(unsigned char aNewState);
		void DrawVaReadWriteStates();
		void DrawVaReadWriteStates(unsigned char aNewState);
		void DrawDisplayPadReadWriteStates();
		void DrawDisplayPadReadWriteStates(unsigned char aNewState);
		
		void FireSimulation(unsigned char CtlNum, unsigned char aP0, unsigned char aP1, unsigned char aType=0, unsigned int aUcCode=0, unsigned short aArea=0);
		
		void CurveInit(short aLeft, short aTop, short aWidth, short aHeight, short aDataTypeCnt);
		void CurveSetMargin(short aLeft, short aTop, short aRight, short aBottom);
		void CurveSetGrid(short xCnt, short yCnt, short xWidth, short yHeight);
		void CurveSetColor(u32 aClr0, u32 aClr1, u32 aClr2, u32 aClr3);
		void CurveSetScaling();
		void CurvePutDataSmoke(unsigned short aD0, unsigned short aD1, unsigned short aD2, unsigned short aD3);
		void CurvePutDataTempe(unsigned short aD0, unsigned short aD1, unsigned short aD2, unsigned short aD3);
		void CurveDrawText();
		void CurveDrawOutline();
		void CurveDrawGrid();
		void CurveRecover();
		void CurveDrawData();
		void CurveDrawLastData();
		void CurveDraw(int IsFullRedraw);
		void CurveHide();
		
		void SimFire(unsigned char aP0, unsigned char aP1);
		void SimStart(unsigned char aP0, unsigned char aP1);
		void SimSv(unsigned char aP0, unsigned char aP1);
		void SimFeedBack(unsigned char aP0, unsigned char aP1);

		void Task1000Ms();
		void Task1000MsNoType();
		void Task1000MsSmoker();
		void Task1000MsTempe();
		void Task1000MsHandPad();
		void Task1000MsHydrantPad();
		void Task1000MsModuleIn();
		void Task1000MsModuleInOut();
		void Task1000MsModuleOut();
		void Task1000MsVa();
		void Task1000MsDisplayPad();
		void Task1000MsLinkagePowerSuply();
		
		void RedrawNoTypeDefineType();
		void RedrawNoTypeSignalType();
		
		void WriteAUserCode2Flash(unsigned char aPath0, unsigned char aAddr, TUserCode aUc);
		void WriteAAssignType2Flash(unsigned char aPath0, unsigned char aAddr, unsigned char aNewAssignType);
		void WriteAreaNum2Flash(unsigned char aPath0, unsigned char aAddr, unsigned short aNum);
		
		static void sWriteAuxIdAssignTypeSignalType(unsigned char aPath0);
		static void sWriteAuxIdAssignTypeSignalTypeDefault(unsigned char aPath0);
		
		static void sWriteAreaNumOnePort(unsigned char aPort);
		static void sWriteAreaNumDefault();
		
		static void sRecoverSetDefault();
		
		void WriteNoTypeInOutSignal();
		void WriteMouelaInputSignal();
		void WriteMouelaInOutSignal();
		void WriteMouelaOutSignal();
		void WriteDisplayPadMatchData();
		
		int ExtRequst(unsigned char Prm){
			RealTimeSendCmdAbort();
			IsShow = 0; 
			return 0;
		}
};
		
		
		
		
		
		
#endif
		
		
		