#ifndef CIRCUITCFG_H_
#define CIRCUITCFG_H_

#include "gType.h" 
#include "GraphBase.h"
#include "string.h"
#include "my_string.h"
#include "Device.h"
#include "EpDevice.h"
#include "StaticText.h"
#include "CtlPanel1.h"
#include "ProtoInnerCan.h"

class TCircuitCfg{
	public:
		int IsShow;
	
		unsigned int OnActive;
		TCtlPanel1 *aPanel;
	public:
		TStaticText Caption;
		TStaticText SText;

		u32 Color;
		u32 TextColor;
		u32 SelectedColor;
		u32 SelectedTextColor;
	
		int TabOrder;
	
		TRect Bound;	
		TRect RectCanvas;
	
		TRect Content;
		TRect RectPanel;
		
		TMyString Str;
	
		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 SmokeSensGrade;
			struct{
				union {
					unsigned short D16;
					struct{
						unsigned char LowB;
						unsigned char HiB;
					}D8;
				}Blue;
				union {
					unsigned short D16;
					struct{
						unsigned char LowB;
						unsigned char HiB;
					}D8;
				}Red;
			}SmokeBackGroundLight;
			struct{
				union {
					unsigned short D16;
					struct{
						unsigned char LowB;
						unsigned char HiB;
					}D8;
				}Blue;
				union {
					unsigned short D16;
					struct{
						unsigned char LowB;
						unsigned char HiB;
					}D8;
				}Red;
			}SmokeRefrence;
			unsigned char TempeSensType;
			struct{
				unsigned char Type;
				unsigned char Tone;
			}VaType;
		}UserSetData;
		
		union{
			unsigned int D32;
			struct{
				unsigned char pCtl;
				unsigned char P0;
				unsigned char P1;
				unsigned char P2;
			}Body;
		}aFullPath;
		
		unsigned int CtlIndex;
		int IsFastCmd;
		unsigned char Data[8];
		unsigned char RecRdy;
		unsigned char RecCmd;
		unsigned char RecData[8];
		
		unsigned char IsWait4CfgRpy;
		unsigned char IsWait4Read;
		unsigned char TipState;
		unsigned int WaitTick;
	private:
		void SetListColWidth(int w0, int w1, int w2, int w3, int w4,int w5,int w6, int w7, int w8, int w9);
	public:
		TCircuitCfg(){};
		TCircuitCfg(int x1, int y1, int aW, int aH, int OwnerX, int OwnerY, u32 aColor){
			Init(x1, y1, aW, aH, OwnerX, OwnerY, aColor);
		}
		void Init(int x1, int y1, int aW, int aH, int OwnerX, int OwnerY, u32 aColor);
	
		void SetAndShowCaption(unsigned char aType);
		
		void RenderBackGround(void);
		void RenderBackGround(unsigned int aClr);
		void DrawSelf(void);
		
		void RedrawSmokeSensValue();
		void RedrawTempeValue();
		void RedrawVaValue();
		
		void Show(void);
		void ReDraw(void);
		void FullRedraw(int Prm);
		void PanelCanvasOut();
		void DrawCaption2(void);
		void RedrawMethod();
		void RedrawP1();
		void RedrawDevType();
		void RedrawDataType();
		void RedrawDataValue();
		
		void PkgSetData();
		
		void ShowState();
		void ShowState(int Prm);
		
		void TextOut4All();
		void TextOut4SmokeSens();
		void TextOut4SmokeBackGroundLight();
		void TextOut4SmokeRefrence();
		void TextOut4Tempe();
		void TextOut4Va();
		void TextOut4InOutMdl();
		void TextOut4MotherBoard();
		void TextOut4Circuit();
		
		void TextOut4ModuleOutputChexk();
		void TextOut4ModuleOutputType();
		void TextOut4FloorDisplay();
		
		TGuiMsgReturn KeyIn(unsigned char aKey);
		
		void InitPanel();
		
		void Check4Selected(void);
		
		void SendCmdRead();
		void SendCmdCfg();
		void PushInnerCanData(unsigned char aCmd, unsigned char *Data);
		
		void Task1000Ms();
		
		int ExtRequst(unsigned char Prm);
		
};
		
#endif



