#include "RuntimeData.h"
#include "DevStartStop.h"

extern "C"{
	#include "user_norflash.h"
	#include "user_eeprom.h"
	#include "uart_key_drv.h"
}

#define TextTopOffSet	6
#define ListLineCnt	10

#define ipdWidth0  	400
#define ipdWidth1		390

#define dWdClr		clSkyBlue
#define dWdDisabelClr	clNearWhite

#define dWWidth	24
#define dWHeigh	24
#define dRoundR	7

static const unsigned char stCmd[8] = {221,222,223,224,225,226,227,228};
static const unsigned char stPrm[8] = {0,1,2,3,4,5,6,7};

static const unsigned char stHexNum[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
static const char CharBcdText[20]= {"0123456789*------\0"};

void TDevStartStop::DrawFixTextNoType()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "操作");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "启动", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "停止", 14, clNearBlack);
	}else{
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "Operation");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "Act", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "Stop", 14, clNearBlack);
	}
}

void TDevStartStop::DrawFixTextSmoker()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "灵敏度");
		TextRender_string24(Lv.Grid.Left[2] +28, Lv.Grid.Top[2] + 36, clNearWhite, ItemColor, "按设置键重新查询数据");

		TextRender_string24(Lv.Grid.Left[3] +10, Lv.Grid.Top[3] + 4, clNearWhite, ItemColor, "操作");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "启动", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "停止", 14, clNearBlack);
	}else{
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "SENSIT");
		TextRender_string24(Lv.Grid.Left[2] +28, Lv.Grid.Top[2] + 36, clNearWhite, ItemColor, "Set:Read");

		TextRender_string24(Lv.Grid.Left[3] +10, Lv.Grid.Top[3] + 4, clNearWhite, ItemColor, "Operation");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "Act", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "Stop", 14, clNearBlack);
	}	
}

void TDevStartStop::DrawFixTextTempe()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "探测类型");
		TextRender_string24(Lv.Grid.Left[2] +28, Lv.Grid.Top[2] + 40, clNearWhite, ItemColor, "按设置键重新查询数据");
	
		TextRender_string24(Lv.Grid.Left[3] +10, Lv.Grid.Top[3] + 4, clNearWhite, ItemColor, "操作");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "启动", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "停止", 14, clNearBlack);
	}else{
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "DET TYPE");
		TextRender_string24(Lv.Grid.Left[2] +28, Lv.Grid.Top[2] + 40, clNearWhite, ItemColor, "Set:Read");
	
		TextRender_string24(Lv.Grid.Left[3] +10, Lv.Grid.Top[3] + 4, clNearWhite, ItemColor, "Operation");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "Act", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "Stop", 14, clNearBlack);
	}	
}

void TDevStartStop::DrawFixTextHandPad()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "操作");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "启动", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "停止", 14, clNearBlack);
	}else{
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "Operation");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "Act", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "Stop", 14, clNearBlack);
	}	
}

void TDevStartStop::DrawFixTextHydrantPad()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "操作");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "启动", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "停止", 14, clNearBlack);
	}else{
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "Operation");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "Act", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "Stop", 14, clNearBlack);
	}	
}

void TDevStartStop::DrawFixTextModuleIn()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "定义类型");
		TextRender_string24(Lv.Grid.Left[3] +10, ModuleRectLv3.Top + 6, clNearWhite, ItemColor, "输入信号");
		TextRender_string24(Lv.Grid.Left[3] +42, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "反馈");
		TextRender_string24(Lv.Grid.Left[3] +140, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "报警");
		TextRender_string24(Lv.Grid.Left[3] +236, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "监管");
		//TextRender_string24(Lv.Grid.Left[3] +28, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "按设置键重新查询数据");
		TextRender_string24(Lv.Grid.Left[4] +6, ModuleRectLv4.Top + 8, clNearWhite, ItemColor, "操作");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "启动", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "停止", 14, clNearBlack);
	}else{
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "DEF TYPE");
		TextRender_string24(Lv.Grid.Left[3] +10, ModuleRectLv3.Top + 6, clNearWhite, ItemColor, "Signal");
		TextRender_string24(Lv.Grid.Left[3] +42, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "FBCK");
		TextRender_string24(Lv.Grid.Left[3] +140, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "FIRE");
		TextRender_string24(Lv.Grid.Left[3] +236, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "SUPV");
		//TextRender_string24(Lv.Grid.Left[3] +28, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "按设置键重新查询数据");
		TextRender_string24(Lv.Grid.Left[4] +6, ModuleRectLv4.Top + 8, clNearWhite, ItemColor, "OPR");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "Act", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "Stop", 14, clNearBlack);
	}	
}

void TDevStartStop::DrawFixTextModuleInOut()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "定义类型");
		TextRender_string24(Lv.Grid.Left[3] +10, ModuleRectLv3.Top + 6, clNearWhite, ItemColor, "输入信号");
		TextRender_string24(Lv.Grid.Left[3] +42, ModuleRectLv3.Top + 36, clSilver, ItemColor, "反馈");
		TextRender_string24(Lv.Grid.Left[3] +140, ModuleRectLv3.Top + 36, clSilver, ItemColor, "报警");
		TextRender_string24(Lv.Grid.Left[3] +236, ModuleRectLv3.Top + 36, clSilver, ItemColor, "监管");
		TextRender_string24(Lv.Grid.Left[3] +42, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "点动");
		//TextRender_string24(Lv.Grid.Left[3] +136, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "设置键重查询");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "启动", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "停止", 14, clNearBlack);
	}else{
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "DEF TYPE");
		TextRender_string24(Lv.Grid.Left[3] +10, ModuleRectLv3.Top + 6, clNearWhite, ItemColor, "Signal");
		TextRender_string24(Lv.Grid.Left[3] +42, ModuleRectLv3.Top + 36, clSilver, ItemColor, "FBCK");
		TextRender_string24(Lv.Grid.Left[3] +140, ModuleRectLv3.Top + 36, clSilver, ItemColor, "FIRE");
		TextRender_string24(Lv.Grid.Left[3] +236, ModuleRectLv3.Top + 36, clSilver, ItemColor, "SUPV");
		TextRender_string24(Lv.Grid.Left[3] +42, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "Pulse");
		//TextRender_string24(Lv.Grid.Left[3] +136, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "设置键重查询");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "Act", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "Stop", 14, clNearBlack);
	}	
}

void TDevStartStop::DrawFixTextModuleOut()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "定义类型");
		TextRender_string24(Lv.Grid.Left[3] +10, ModuleRectLv3.Top + 6, clNearWhite, ItemColor, "输入信号");
		TextRender_string24(Lv.Grid.Left[3] +42, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "反馈");
		TextRender_string24(Lv.Grid.Left[3] +140, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "报警");
		TextRender_string24(Lv.Grid.Left[3] +236, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "监管");
		TextRender_string24(Lv.Grid.Left[3] +42, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "点动");
		//TextRender_string24(Lv.Grid.Left[3] +136, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "设置键重查询");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "启动", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "停止", 14, clNearBlack);
	}else{
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "DEF TYPE");
		TextRender_string24(Lv.Grid.Left[3] +10, ModuleRectLv3.Top + 6, clNearWhite, ItemColor, "Signal");
		TextRender_string24(Lv.Grid.Left[3] +42, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "FBCK");
		TextRender_string24(Lv.Grid.Left[3] +140, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "FIRE");
		TextRender_string24(Lv.Grid.Left[3] +236, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "SUPV");
		TextRender_string24(Lv.Grid.Left[3] +42, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "Pulse");
		//TextRender_string24(Lv.Grid.Left[3] +136, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "设置键重查询");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "Act", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "Stop", 14, clNearBlack);
	}	
}

void TDevStartStop::DrawFixTextVa()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "控制");
		TextRender_string24(Lv.Grid.Left[2] +42, Lv.Grid.Top[2] + 38, clNearWhite, ItemColor, "联动");
		TextRender_string24(Lv.Grid.Left[3] +10, ModuleRectLv3.Top + 6, clNearWhite, ItemColor, "警报形式");
		TextRender_string24(Lv.Grid.Left[3] +42, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "声光");
		TextRender_string24(Lv.Grid.Left[3] +140, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "声");
		TextRender_string24(Lv.Grid.Left[3] +236, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "光");
		IList->Edit[0].Show();
		TextRender_string24(Lv.Grid.Left[3] +136, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "设置键重查询");
		TextRender_string24(Lv.Grid.Left[4] +10, ModuleRectLv4.Top + 6, clNearWhite, ItemColor, "操作");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "启动", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "停止", 14, clNearBlack);
	}else{
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "CTRL");
		TextRender_string24(Lv.Grid.Left[2] +42, Lv.Grid.Top[2] + 38, clNearWhite, ItemColor, "LINK");
		TextRender_string24(Lv.Grid.Left[3] +10, ModuleRectLv3.Top + 6, clNearWhite, ItemColor, "Alram Type");
		TextRender_string24(Lv.Grid.Left[3] +42, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "S+L");
		TextRender_string24(Lv.Grid.Left[3] +140, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "S");
		TextRender_string24(Lv.Grid.Left[3] +236, ModuleRectLv3.Top + 36, clNearWhite, ItemColor, "L");
		IList->Edit[0].Show();
		TextRender_string24(Lv.Grid.Left[3] +136, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "Set:Read");
		TextRender_string24(Lv.Grid.Left[4] +10, ModuleRectLv4.Top + 6, clNearWhite, ItemColor, "OPR");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "Act", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "Stop", 14, clNearBlack);
	}	
}

void TDevStartStop::DrawFixTextDisplayPad()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "显示匹配方式");
		TextRender_string24(Lv.Grid.Left[2] +42, Lv.Grid.Top[2] + 38, clNearWhite, ItemColor, "分区");
		TextRender_string24(Lv.Grid.Left[2] +140, Lv.Grid.Top[2] + 38, clNearWhite, ItemColor, "二次码");
		TextRender_string24(Lv.Grid.Left[3] +10, Lv.Grid.Top[3] + 6, clNearWhite, ItemColor, "显示范围");
		TextRender_string24(Lv.Grid.Left[4] +10, Lv.Grid.Top[4] + 6, clNearWhite, ItemColor, "操作");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "启动", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "停止", 14, clNearBlack);
	}else{
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "MATCH METHOD");
		TextRender_string24(Lv.Grid.Left[2] +42, Lv.Grid.Top[2] + 38, clNearWhite, ItemColor, "Zone");
		TextRender_string24(Lv.Grid.Left[2] +140, Lv.Grid.Top[2] + 38, clNearWhite, ItemColor, "AuxID");
		TextRender_string24(Lv.Grid.Left[3] +10, Lv.Grid.Top[3] + 6, clNearWhite, ItemColor, "DP-RANGE");
		TextRender_string24(Lv.Grid.Left[4] +10, Lv.Grid.Top[4] + 6, clNearWhite, ItemColor, "Operation");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "Act", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "Stop", 14, clNearBlack);
	}	
}

void TDevStartStop::DrawFixTextLinkagePowerSuply()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "操作");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "启动", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "停止", 14, clNearBlack);
	}else{
		TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "Operation");
		TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "Act", 14, clNearBlack);
		TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "Stop", 14, clNearBlack);
	}	
}

void TDevStartStop::Init(TDevProperty::THwDevType aDevType, int aMode)
{
	HwDevType = aDevType;
	IsPermission = 0;
	Tag.Reset();
	RuntimeData.Reset();
	PanelDrawData.TextDrawLine = 0;
	
	if(MainCtl.fData.Split.NetworkMode == 1){
		Tag.InxMin = 0;
	}else{
		Tag.InxMin = 1;
	}
	Tag.Inx = 1;
	
	CtlNumValid = 1;
	PortNumValid =1;
	AddrNumValid =1;
	IsSelfCtl = 1;
	
	CtlNum = MainCtl.fData.Split.MyNum;
	Path0 = 1;
	Path1 = 1;
}

void TDevStartStop::RenderBackGround(void)
{
	RectFillRender(ContentGeometry.Left, ContentGeometry.Top, ContentGeometry.Right, ContentGeometry.Bottom, ContentColor);
}

void TDevStartStop::RenderBackGround(unsigned int aClr)
{
	RectFillRender(ContentGeometry.Left, ContentGeometry.Top, ContentGeometry.Right, ContentGeometry.Bottom, aClr);
}

void TDevStartStop::FullRedraw(int Prm)
{
	if(Prm == 0){
		RenderBackGround();
		DrawSelf();
		RedrawCommonByExReturn();
		DrawHtInf(0);
		RedrawSmallPanelData();		
	}else
	if(Prm == 1){
		RectFillRender(GuiRedrawDataList[1][0], GuiRedrawDataList[1][1], GuiRedrawDataList[1][2], GuiRedrawDataList[1][3], ContentColor);
		for(int i=0; i<3; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
		if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
		RedrawCommonByExReturn();
		DrawHtInf(1);
		RedrawSmallPanelData();
		if(IsPermission)PmsIntervene4Gui.ReDraw4GuiRecall();
	}
}

void TDevStartStop::RedrawCommonByExReturn()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[0] + 10, Lv.Grid.Top[0] +6, clNearWhite, "回路号");
		TextRender_string24(Lv.Grid.Left[0] + 160, Lv.Grid.Top[0] +6, clNearWhite, "机器号");
		TextRender_string24(Lv.Grid.Left[0] + 400, Lv.Grid.Top[0] +6, clNearWhite, "类型:");
		TextRender_string24(Lv.Grid.Left[0] + 640, Lv.Grid.Top[0] +6, clNearWhite, "状态:");
		TextRender_string24(Lv.Grid.Left[0] + 10, Lv.Grid.Top[0] + 40, clNearWhite, "地址号");
		TextRender_string24(Lv.Grid.Left[0] + 280, Lv.Grid.Top[0] + 40, clNearWhite, "注释信息:");
		//User Code & Area Assign
		TextRender_string24(Lv.Grid.Left[1] + 10, Lv.Grid.Top[1] +6, clNearWhite, "二次码");
		TextRender_string24(Lv.Grid.Left[1] + 10, Lv.Grid.Top[1] +40, clNearWhite, "分区号");
		if(MainCtl.fData.Split.NetworkMode == 1)
			IList->STextCtlType.SetText("本集中机",24);
		else if(MainCtl.fData.Split.NetworkMode == 2){
			IList->STextCtlType.SetText("本区域机",24);
			IList->EditCtlNum.Enable = 0;
		}else{
			IList->STextCtlType.SetText("本单机",24);
			IList->EditCtlNum.Enable = 0;
		}
	}else{
		TextRender_string24(Lv.Grid.Left[0] + 10, Lv.Grid.Top[0] +6, clNearWhite, "LoopID");
		TextRender_string24(Lv.Grid.Left[0] + 160, Lv.Grid.Top[0] +6, clNearWhite, "CtlID");
		TextRender_string24(Lv.Grid.Left[0] + 400, Lv.Grid.Top[0] +6, clNearWhite, "TYPE:");
		TextRender_string24(Lv.Grid.Left[0] + 640, Lv.Grid.Top[0] +6, clNearWhite, "State");
		TextRender_string24(Lv.Grid.Left[0] + 10, Lv.Grid.Top[0] + 40, clNearWhite, "Addre");
		TextRender_string24(Lv.Grid.Left[0] + 280, Lv.Grid.Top[0] + 40, clNearWhite, "Note:");
		//User Code & Area Assign
		TextRender_string24(Lv.Grid.Left[1] + 10, Lv.Grid.Top[1] +6, clNearWhite, "AuxID");
		TextRender_string24(Lv.Grid.Left[1] + 10, Lv.Grid.Top[1] +40, clNearWhite, "Zone");
		if(MainCtl.fData.Split.NetworkMode == 1)
			IList->STextCtlType.SetText("MAINHOST",24);
		else if(MainCtl.fData.Split.NetworkMode == 2){
			IList->STextCtlType.SetText("REGIONAL",24);
			IList->EditCtlNum.Enable = 0;
		}else{
			IList->STextCtlType.SetText("ALONE",24);
			IList->EditCtlNum.Enable = 0;
		}
	}
	IList->EditCtlNum.Show();
	IList->EditPortNum.Show();
	IList->EditAddrNum.Show();
	IList->STextCtlType.Show();
	
	IList->STextDType.Show();
	IList->STextState.Show();
	IList->STextRegisted.Show();
	IList->EditDescpShow.Show();
		
	IList->EditUserCode.Show();
	IList->EditAreaAssign.Show();
}

void TDevStartStop::DrawHtInf(int aPrm)
{
	PanelIsUsingText = 1;
	if(dType == dgTYPE_SMOKE_DETECTOR){
		if(aPrm == 0){
			for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			DrawFixTextSmoker();
		
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
		
			RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
			RectFillRender(Lv.PanelSmall.Left + 120, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 120 + 20, Lv.PanelSmall.Top + 6 + 20, clPurple);
		
			IList->Edit[0].Show();
		}else{
			DrawFixTextSmoker();
			IList->Edit[0].Show();
		}			
	}else
	if(dType == dgTYPE_TEMPE_DETECTOR){
		if(aPrm == 0){
			for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			DrawFixTextTempe();
			
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
			
			RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
			RectFillRender(Lv.PanelSmall.Left + 120, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 120 + 20, Lv.PanelSmall.Top + 6 + 20, clPurple);
			
			TextRender_string24(Lv.PanelSmall.Left +146, Lv.PanelSmall.Top + 4, clNearWhite, ItemColor, "T");
			TCircle::sRender(Lv.PanelSmall.Left + 218, Lv.PanelSmall.Top + 10, 2, clNearWhite, 0);
			TextRender_string24(Lv.PanelSmall.Left +222, Lv.PanelSmall.Top + 4, clNearWhite, ItemColor, "C");
			
			IList->Edit[0].Show(); 
		}else{
			DrawFixTextTempe();
			IList->Edit[0].Show();
		}
	}else
	if(dType == dgTYPE_HAND_REPORT){
		if(aPrm ==0){
			for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			DrawFixTextHandPad();
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
			RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
			IList->Edit[0].Show();
		}else{
			DrawFixTextHandPad();
			IList->Edit[0].Show();
		}
	}else
	if(dType == dgTYPE_FIRE_HydrantKp){
		if(aPrm == 0){
			for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			DrawFixTextHydrantPad();
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
			RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
			IList->Edit[0].Show();
		}else{
			DrawFixTextHydrantPad();
			IList->Edit[0].Show();
		}
	}else
	if(dType == dgTYPE_IN_MODULE){
		if(aPrm ==0){
			for(int i=2; i<3; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			RectFillRender(Lv.Grid.Left[3], ModuleRectLv3.Top, Lv.Grid.Right[3], ModuleRectLv3.Bottom, ItemColor);
			RectFillRender(Lv.Grid.Left[4], ModuleRectLv4.Top, Lv.Grid.Right[4], ModuleRectLv4.Bottom, ItemColor);
			DrawFixTextModuleIn();
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
			RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
			if(IsSelfCtl)IList->STextModuleInDefineType.Show();
			IList->Edit[0].Show();
			if(Path0 && (Path0 <= dPORT_MAX_COUNT))Data.ModuleSignalInType = Port[Path0-1].FuncSetByte[Path1-1]; else Data.ModuleSignalInType = 0;
			RedrawModuleInSignalInType();
		}else{
			if(LanguageEnCn==0){
				TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "定义类型");
			}else{
				TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "DEF TYPE");
			}
			RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
			if(IsSelfCtl)IList->STextModuleInDefineType.Show();
			IList->Edit[0].Show();	
		}
	}else
	if(dType == dgTYPE_OUT_MODULE){
		if(aPrm == 0){
			for(int i=2; i<3; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			RectFillRender(Lv.Grid.Left[3], ModuleRectLv3.Top, Lv.Grid.Right[3], ModuleRectLv3.Bottom, ItemColor);
			RectFillRender(Lv.Grid.Left[4], ModuleRectLv4.Top, Lv.Grid.Right[4], ModuleRectLv4.Bottom, ItemColor);
			DrawFixTextModuleOut();
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
			RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
			if(IsSelfCtl)IList->STextModuleInDefineType.Show();
			IList->Edit[0].Show();
			IList->STextModuleInDefineType.Show();
			if(Path0 && (Path0 <= dPORT_MAX_COUNT))Data.ModuleSignalOutType = Port[Path0-1].FuncSetByte[Path1-1]; else Data.ModuleSignalOutType = 0;
			RedrawModuleOutSignalType();
		}else{
			if(LanguageEnCn==0){
				TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "定义类型");
			}else{
				TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "DEF TYPE");
			}
			//TextRender_string24(Lv.Grid.Left[3] +136, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "设置键重查询");
			if(IsSelfCtl)IList->STextModuleInDefineType.Show();
			IList->Edit[0].Show();
			IList->STextModuleInDefineType.Show();		
		}
	}else
	if(dType == dgTYPE_INOUT_MODULE_NonSource){
		if(aPrm == 0){
			for(int i=2; i<3; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			RectFillRender(Lv.Grid.Left[3], ModuleRectLv3.Top, Lv.Grid.Right[3], ModuleRectLv3.Bottom, ItemColor);
			RectFillRender(Lv.Grid.Left[4], ModuleRectLv4.Top, Lv.Grid.Right[4], ModuleRectLv4.Bottom, ItemColor);
			DrawFixTextModuleInOut();
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
			RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
			if(IsSelfCtl)IList->STextModuleInDefineType.Show();
			IList->Edit[0].Show();
			IList->STextModuleInDefineType.Show();
			if(Path0 && (Path0 <= dPORT_MAX_COUNT))Data.ModuleSignalInOutType = Port[Path0-1].FuncSetByte[Path1-1]; else Data.ModuleSignalInOutType = 0;
			RedrawModuleInOutSignalType();
		}else{
			if(LanguageEnCn==0){
				TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "定义类型");
			}else{
				TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "DEF TYPE");
			}
			//TextRender_string24(Lv.Grid.Left[3] +136, ModuleRectLv3.Top + 72, clNearWhite, ItemColor, "设置键重查询");
			if(IsSelfCtl)IList->STextModuleInDefineType.Show();
			IList->Edit[0].Show();
			IList->STextModuleInDefineType.Show();		
		}
	}else
	if(dType == dgType_VAALRAM){
		if(aPrm == 0){
			for(int i=2; i<3; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			RectFillRender(Lv.Grid.Left[3], ModuleRectLv3.Top, Lv.Grid.Right[3], ModuleRectLv3.Bottom, ItemColor);
			RectFillRender(Lv.Grid.Left[4], ModuleRectLv4.Top, Lv.Grid.Right[4], ModuleRectLv4.Bottom, ItemColor);
			DrawFixTextVa();
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
			RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
			
			RedrawVaIs4Linkage();
			RedrawVaSetting();
		}else{
			if(LanguageEnCn==0){
				TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "控制");
				TextRender_string24(Lv.Grid.Left[2] +42, Lv.Grid.Top[2] + 38, clNearWhite, ItemColor, "联动");
			}else{
				TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "CTRL");
				TextRender_string24(Lv.Grid.Left[2] +42, Lv.Grid.Top[2] + 38, clNearWhite, ItemColor, "LINK");
			}
			IList->Edit[0].Show();
		}
	}else
	if(dType == dgTYPE_DISPLAY_PAD){
		if(aPrm == 0){
			for(int i=2; i<5; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			DrawFixTextDisplayPad();
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
			RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
			
			RedrawDisplayPadMatchData();
		}else{
			if(LanguageEnCn==0){
				TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "显示匹配方式");
				TextRender_string24(Lv.Grid.Left[2] +42, Lv.Grid.Top[2] + 38, clNearWhite, ItemColor, "分区");
				TextRender_string24(Lv.Grid.Left[2] +140, Lv.Grid.Top[2] + 38, clNearWhite, ItemColor, "二次码");
			}else{
				TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, "MATCH METHOD");
				TextRender_string24(Lv.Grid.Left[2] +42, Lv.Grid.Top[2] + 38, clNearWhite, ItemColor, "Zone");
				TextRender_string24(Lv.Grid.Left[2] +140, Lv.Grid.Top[2] + 38, clNearWhite, ItemColor, "AuxID");
			}			
		}
		RedrawDisplayPadMatchMode();
	}else
	if(dType == dgTYPE_LINKAGE_POWERSUPLY){
		if(aPrm == 0){
			for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			DrawFixTextLinkagePowerSuply();
			
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
			
			RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);	
		}else{
			DrawFixTextLinkagePowerSuply();	
		}
	}else{
		if(aPrm == 0){
			for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
			DrawFixTextNoType();
		}else{
			DrawFixTextNoType();
		}
	}		
}

void TDevStartStop::DrawState(unsigned char aSta)
{
	if(aSta & dEpStateBitFire){
		TCircle::sRender(IList->STextState.Bound.Left -12, IList->STextState.Bound.Top +14, 10, clRed, 0xF);
		if(LanguageEnCn==0)IList->STextState.SetText("报警", 24);
		else IList->STextState.SetText("Fire", 24); 
	}else 
	if(aSta & dEpStateBitStart){
		TCircle::sRender(IList->STextState.Bound.Left -12, IList->STextState.Bound.Top +14, 10, clOrange, 0xF);
		if(LanguageEnCn==0)IList->STextState.SetText("启动", 24);
		else IList->STextState.SetText("Act", 24);
	}else 
	if(aSta & dEpStateBitSv){
		TCircle::sRender(IList->STextState.Bound.Left -12, IList->STextState.Bound.Top +14, 10, clOrange, 0xF);
		if(LanguageEnCn==0)IList->STextState.SetText("监管", 24);
		else IList->STextState.SetText("SUPV", 24);
	}else 
	if(aSta & dEpStateBitFault){
		TCircle::sRender(IList->STextState.Bound.Left -12, IList->STextState.Bound.Top +14, 10, clOrange, 0xF);
		if(LanguageEnCn==0)IList->STextState.SetText("故障", 24);
		else IList->STextState.SetText("Fail", 24);
	}else 
	if(aSta & dEpStateBitFeedBack){
		TCircle::sRender(IList->STextState.Bound.Left -12, IList->STextState.Bound.Top +14, 10, clBlue, 0xF);
		if(LanguageEnCn==0)IList->STextState.SetText("反馈", 24);
		else IList->STextState.SetText("FBCK", 24);
	}else 
	if(aSta & dEpStateBitMask){
		TCircle::sRender(IList->STextState.Bound.Left -12, IList->STextState.Bound.Top +14, 10, clOrange, 0xF);
		if(LanguageEnCn==0)IList->STextState.SetText("屏蔽", 24);
		else IList->STextState.SetText("Mask", 24);
	}else{
		TCircle::sRender(IList->STextState.Bound.Left -12, IList->STextState.Bound.Top +14, 10, clDeepGreen, 0xF);
		if(LanguageEnCn==0)IList->STextState.SetText("正常", 24);
		else IList->STextState.SetText("IDLE", 24);
	}
	IList->STextState.Show();
}

void TDevStartStop::DrawStateNone()
{
	TCircle::sRender(IList->STextState.Bound.Left -12, IList->STextState.Bound.Top +14, 10, clDeepGreen, 0xF);
	IList->STextState.SetText("----", 24);
	IList->STextState.Show();
}

void TDevStartStop::DrawMac()
{
	unsigned char Num, Num10;
	TMyString::sClear(TextDraw);
	TMyString::sAddOnStr("MAC:", TextDraw);
	for(int i=0; i<6; i++){
		Num = RuntimeData.Mac[i] % 16;
		Num10 = RuntimeData.Mac[i] / 16 % 16;
		TMyString::sAddOnChar(stHexNum[Num10], TextDraw);
		TMyString::sAddOnChar(stHexNum[Num], TextDraw);
		if( (i&0x01) && (i<5) )TMyString::sAddOnChar(' ', TextDraw);
	}
	TextRender_string24(Lv.PanelSmall.Left + 256, Lv.PanelSmall.Top + 36, clNearWhite, SmallPanelColor, TextDraw);
}

void TDevStartStop::DelayMs(unsigned int aMs)
{
	volatile unsigned int mTick;
	volatile unsigned int Tick;
	for(Tick=0; Tick<aMs; Tick++){
		for(mTick=0; mTick<160000; mTick++);
		sys_error_led_task();
	}
}

void TDevStartStop::SetPath(unsigned char aCtlNum, unsigned char aPath0, unsigned char aPath1)
{
	unsigned char tP0, tP1, tT;
	this->CtlNum = aCtlNum;
	if(aPath0 && (aPath0 <= dPORT_MAX_COUNT)) PortNumValid = 1; else PortNumValid = 0;
	if(aPath1 && (aPath1 <= dEP_MAX_COUNT_PER_PORT)) AddrNumValid = 1; else AddrNumValid = 0;
	this->Path0 = aPath0;
	this->Path1 = aPath1;
	
	tP0 = aPath0-1;
	tP1 = aPath1-1;
	if(Port[tP0].ExistTable[tP1] == 0xA5){
		dType = Port[tP0].dTypeTable[tP1];
	}else{
		dType = 0;
	}
}

void TDevStartStop::Show(void)
{	
	RenderBackGround();
	DrawSelf();
	DrawCommonInfTitle();
	IsShow = 1;
}

void TDevStartStop::DrawSelf()
{
	RenderBackGround();
	RectFillRender(Lv.Caption.Left, Lv.Caption.Top, Lv.Caption.Right, Lv.Caption.Bottom, CaptionColor);
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Caption.Left + 10, Lv.Caption.Top +4, clNearWhite, CaptionColor, "回路->部件控制");
	}else{
		TextRender_string24(Lv.Caption.Left + 10, Lv.Caption.Top +4, clNearWhite, CaptionColor, "Loop->Device Control");
	}
	if(RunState == TRunModeCfg::RunModeAdjust){
		if(LanguageEnCn==0)
			TextRender_string24(Lv.Caption.Left + 10 + (14*12 + 20), Lv.Caption.Top +4, clRed, CaptionColor, "(注意:真实启动或停止)");
		else
			TextRender_string24(Lv.Caption.Left + 10 + (14*12 + 20), Lv.Caption.Top +4, clRed, CaptionColor, "(Notice:Real Action)");
	}
	for(int i=0; i<2; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
}

void TDevStartStop::DrawCommonInfTitle()
{
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[0] + 10, Lv.Grid.Top[0] +6, clNearWhite, "回路号");
		TextRender_string24(Lv.Grid.Left[0] + 160, Lv.Grid.Top[0] +6, clNearWhite, "机器号");
		
		
		TextRender_string24(Lv.Grid.Left[0] + 400, Lv.Grid.Top[0] +6, clNearWhite, "类型:");
		TextRender_string24(Lv.Grid.Left[0] + 640, Lv.Grid.Top[0] +6, clNearWhite, "状态:");
		
		TextRender_string24(Lv.Grid.Left[0] + 10, Lv.Grid.Top[0] + 40, clNearWhite, "地址号");
		TextRender_string24(Lv.Grid.Left[0] + 280, Lv.Grid.Top[0] + 40, clNearWhite, "注释信息:");
	}else{
		TextRender_string24(Lv.Grid.Left[0] + 10, Lv.Grid.Top[0] +6, clNearWhite, "LoopID");
		TextRender_string24(Lv.Grid.Left[0] + 160, Lv.Grid.Top[0] +6, clNearWhite, "CtlID");
		
		
		TextRender_string24(Lv.Grid.Left[0] + 400, Lv.Grid.Top[0] +6, clNearWhite, "Type:");
		TextRender_string24(Lv.Grid.Left[0] + 640, Lv.Grid.Top[0] +6, clNearWhite, "State");
		
		TextRender_string24(Lv.Grid.Left[0] + 10, Lv.Grid.Top[0] + 40, clNearWhite, "Addr");
		TextRender_string24(Lv.Grid.Left[0] + 280, Lv.Grid.Top[0] + 40, clNearWhite, "    Note:");
	}
	
	IList->STextCtlType.Init(Lv.Grid.Left[0] + 272, Lv.Grid.Top[0] + 2, 106, 30, 0, 0, clNearWhite, ItemColor);
	IList->STextDType.Init(Lv.Grid.Left[0] + 460, Lv.Grid.Top[0] + 2, 168, 30, 0, 0, clNearWhite, ItemColor);
	IList->STextState.Init(Lv.Grid.Left[0] + 730, Lv.Grid.Top[0] + 2, 68, 30, 0, 0, clNearWhite, ItemColor);
	IList->STextRegisted.Init(Lv.Grid.Left[0] + 160, Lv.Grid.Top[0] + 36, 120, 30, 0, 0, clNearWhite, ItemColor);
	IList->STextCtlNum.Init(Lv.Grid.Left[0] + 236, Lv.Grid.Top[0] + 6, 120, 30, 0, 0, clNearWhite, ItemColor);
	
	
	IList->EditCtlNum.Init(Lv.Grid.Left[0] + 232, Lv.Grid.Top[0] + 2, 36, 30, 0, 0, 1, clNearWhite);
	IList->EditPortNum.Init(Lv.Grid.Left[0] + 86, Lv.Grid.Top[0] + 2, 50, 30, 0, 0, 1, clNearWhite);
	IList->EditAddrNum.Init(Lv.Grid.Left[0] + 86, Lv.Grid.Top[0] + 36, 50, 30, 0, 0, 1, clNearWhite);
	IList->EditDescpShow.Init(Lv.Grid.Left[0] + 390, Lv.Grid.Top[0] + 36, 400, 30, 0, 0, 1, clNearWhite);
	
	IList->STextCtlType.Enable = 1;
	IList->STextCtlType.Visible = 1;
	IList->STextDType.Enable = 1;
	IList->STextDType.Visible =1;
	IList->STextState.Enable = 1;
	IList->STextState.Visible =1;
	IList->STextRegisted.Enable = 1;
	IList->STextRegisted.Visible =1;
	IList->STextCtlNum.Enable = 1;
	IList->STextCtlNum.Visible =1;
	
	IList->EditCtlNum.SetMaxLen(2);
	IList->EditPortNum.SetMaxLen(2);
	IList->EditAddrNum.SetMaxLen(3);
	IList->EditCtlNum.Enable = 1;
	IList->EditCtlNum.Visible = 1;
	IList->EditPortNum.Enable = 1;
	IList->EditPortNum.Visible = 1;
	IList->EditAddrNum.Enable = 1;
	IList->EditAddrNum.Visible = 1;
	IList->EditDescpShow.Enable = 0;
	IList->EditDescpShow.Visible = 1;
	
	//User Code & Area Assign
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[1] + 10, Lv.Grid.Top[1] +6, clNearWhite, "二次码");
		TextRender_string24(Lv.Grid.Left[1] + 10, Lv.Grid.Top[1] +40, clNearWhite, "分区号");
	}else{
		TextRender_string24(Lv.Grid.Left[1] + 10, Lv.Grid.Top[1] +6, clNearWhite, "AuxID");
		TextRender_string24(Lv.Grid.Left[1] + 10, Lv.Grid.Top[1] +40, clNearWhite, "Zone");
	}
	IList->EditUserCode.Init(Lv.Grid.Left[1] + 84, Lv.Grid.Top[1] + 6, 108, 30, 0, 0, 1, clNearWhite);
	IList->EditAreaAssign.Init(Lv.Grid.Left[1] + 84, Lv.Grid.Top[1] + 40, 108, 30, 0, 0, 1, clNearWhite);
	
	IList->EditUserCode.Enable = 1;
	IList->EditUserCode.Visible =1;
	IList->EditUserCode.SetMaxLen(8);
	IList->EditAreaAssign.Enable = 0;
	IList->EditAreaAssign.Visible =1;
	IList->EditAreaAssign.SetMaxLen(5);
	if(LanguageEnCn==0){
		if(MainCtl.fData.Split.NetworkMode == 1)
			IList->STextCtlType.SetText("本集中机",24);
		else if(MainCtl.fData.Split.NetworkMode == 2){
			IList->STextCtlType.SetText("本区域机",24);
			IList->EditCtlNum.Enable = 0;
		}else{
			IList->STextCtlType.SetText("本单机",24);
			IList->EditCtlNum.Enable = 0;
		}
	}else{
		if(MainCtl.fData.Split.NetworkMode == 1)
			IList->STextCtlType.SetText("MAINHOST",24);
		else if(MainCtl.fData.Split.NetworkMode == 2){
			IList->STextCtlType.SetText("REGIONAL",24);
			IList->EditCtlNum.Enable = 0;
		}else{
			IList->STextCtlType.SetText("ALONE",24);
			IList->EditCtlNum.Enable = 0;
		}
	}
	IList->STextCtlType.Show();
}

void TDevStartStop::ReDrawCommonInf()
{
	unsigned char tP0, tP1, Found, tType, tSta;
	unsigned int tAddr;
	//Draw Port Num

	Found = 0;
	if(CtlNum == MainCtl.fData.Split.MyNum){
		//Draw If Registed
		if(LanguageEnCn==0){
			if(MainCtl.fData.Split.NetworkMode == 1)
				IList->STextCtlType.SetText("本集中机",24);
			else if(MainCtl.fData.Split.NetworkMode == 2)
				IList->STextCtlType.SetText("本区域机",24);
			else
				IList->STextCtlType.SetText("本单机",24);
		}else{
			if(MainCtl.fData.Split.NetworkMode == 1)
				IList->STextCtlType.SetText("MAINHOST",24);
			else if(MainCtl.fData.Split.NetworkMode == 2){
				IList->STextCtlType.SetText("REGIONAL",24);
			}else{
				IList->STextCtlType.SetText("ALONE",24);
			}
		}
		IList->STextCtlType.Show();
		if( (Path0) && (Path0 <= dPORT_MAX_COUNT) ){
			if( (Path1) && (Path1 <= dEP_MAX_COUNT_PER_PORT) ){
				tP0 = Path0-1;
				tP1 = Path1-1;
				if(Port[tP0].ExistTable[tP1] == 0xA5){
					Found = 1;
					//if(Port[tP0].AssignType[tP1] != 0){
					//	tType = Port[tP0].AssignType[tP1];
					//}else{
						tType = Port[tP0].dTypeTable[tP1];
					//}
					tSta = Port[tP0].StateTable[tP1];
				}
			}
		}
		if(Found){
			if(LanguageEnCn==0)IList->STextDType.SetText(StrTypeShortName[tType],24);
			else IList->STextDType.SetText(StrTypeShortNameEn[tType],24);
			DrawState(tSta);
			if(LanguageEnCn==0)IList->STextRegisted.SetText("已注册", 24);
			else IList->STextRegisted.SetText("Registered ", 24);
			IsRegisted = 1;
		}else{
			IList->STextDType.SetText("----", 24);
			DrawStateNone();
			if(LanguageEnCn==0)IList->STextRegisted.SetText("未注册", 24);
			else IList->STextRegisted.SetText("Un Reg ", 24);
			IsRegisted = 0;
		}
		tAddr = dAddrSdRam_Descp + (tP0 * 256 * 32) + (tP1 * 32);
		for(int g=0; g<32; g++){
			IList->EditDescpShow.Str.Text[g] = *(volatile unsigned char *)(tAddr + g);
			if(  (IList->EditDescpShow.Str.Text[g] == '\0') || (IList->EditDescpShow.Str.Text[g] == 0) ){
				break;
			}
		}
		IList->EditDescpShow.Str.Text[32] = '\0';
		IList->EditDescpShow.Str.Text[33] = '\0';
		
		IList->EditUserCode.Str.FromUInt8Dg(Port[tP0].UcList[tP1].Full);
		IList->EditAreaAssign.Str.FromUInt4Dg(Port[tP0].Area[tP1]);
		
		IList->STextDType.Show();
		IList->STextRegisted.Show();
		IList->EditDescpShow.Show();
		
		IList->EditUserCode.Show();
		IList->EditAreaAssign.Show();
		
		Check4Selected();
		
	}else{
		IList->STextDType.SetText("----", 24);
		DrawStateNone();
		if( (CtlNum) && (CtlNum <= dNETWORK_MACHINE_COUNT) && (Path0) && (Path0 <= dPORT_MAX_COUNT) && (Path1) && (Path1 <= dEP_MAX_COUNT_PER_PORT) ){
			unsigned char aCn = CtlNum -1;
			unsigned char aP0 = Path0-1;
			unsigned char aP1 = Path1;
			unsigned int aAddr;
			if(aP0 < dPORT_MAX_COUNT){
				aAddr = dAddrSdRam_DescpNw + (aCn*dONE_CTRL_DESCP_BYTES)+(aP0*8192) + (aP1*32);
				for(int i=0; i<32; i++){
					IList->EditDescpShow.Str.Text[i] = *(volatile unsigned char *)(aAddr + i);
				}
				IList->EditDescpShow.Str.Text[32] = '\0';
			}
		}
		IList->STextDType.Show();
		IList->STextState.Show();
		IList->EditDescpShow.Show();
		Check4Selected();
	}
}


void TDevStartStop::RenewCommonInf()
{
	unsigned char tP0, tP1, Found, tType, tSta;
	unsigned int tAddr;
	//Draw Ctl Num
	IList->EditCtlNum.Str.FromUInt2Dg(CtlNum);
	IList->EditCtlNum.SetPstTail();
	IList->EditCtlNum.Show();
	if(IList->EditCtlNum.Selected)IList->EditCtlNum.ShowCursor();
	
	//Draw Port Num
	IList->EditPortNum.Str.FromUInt2Dg(Path0);
	IList->EditPortNum.SetPstTail();
	IList->EditPortNum.Show();
	if(IList->EditPortNum.Selected)IList->EditPortNum.ShowCursor();
	
	//Draw Addr Num
	IList->EditAddrNum.Str.FromUInt3Dg(Path1);
	IList->EditAddrNum.SetPstTail();
	IList->EditAddrNum.Show();
	if(IList->EditAddrNum.Selected)IList->EditAddrNum.ShowCursor();
	
	Found = 0;
	if(CtlNum == MainCtl.fData.Split.MyNum){
		//Draw If Registed
		if( (Path0) && (Path0 <= dPORT_MAX_COUNT) ){
			if( (Path1) && (Path1 <= dEP_MAX_COUNT_PER_PORT) ){
				tP0 = Path0-1;
				tP1 = Path1-1;
				if(Port[tP0].ExistTable[tP1] == 0xA5){
					Found = 1;
					//if(Port[tP0].AssignType[tP1] != 0){
					//	tType = Port[tP0].AssignType[tP1];
					//}else{
						tType = Port[tP0].dTypeTable[tP1];
						dType = tType;
					//}
					tSta = Port[tP0].StateTable[tP1];
				}
			}
		}
		if(Found){
			if(LanguageEnCn==0)IList->STextDType.SetText(StrTypeShortName[tType],24);
			else IList->STextDType.SetText(StrTypeShortNameEn[tType],24);
			DrawState(tSta);
			if(LanguageEnCn==0)IList->STextRegisted.SetText("已注册", 24);
			else IList->STextRegisted.SetText("Registered", 24);
			IsRegisted = 1;
		}else{
			IList->STextDType.SetText("----", 24);
			IList->STextState.SetText("----", 24);
			if(LanguageEnCn==0)IList->STextRegisted.SetText("未注册", 24);
			else IList->STextRegisted.SetText("Un Reg ", 24);
			IsRegisted = 0;
		}
		tAddr = dAddrSdRam_Descp + (tP0 * 256 * 32) + (tP1 * 32);
		for(int g=0; g<32; g++){
			IList->EditDescpShow.Str.Text[g] = *(volatile unsigned char *)(tAddr + g);
			if(  (IList->EditDescpShow.Str.Text[g] == '\0') || (IList->EditDescpShow.Str.Text[g] == 0) ){
				break;
			}
		}
		IList->EditDescpShow.Str.Text[32] = '\0';
		IList->EditDescpShow.Str.Text[33] = '\0';
		
		IList->EditUserCode.Str.FromUInt8Dg(Port[tP0].UcList[tP1].Full);
		IList->EditAreaAssign.Str.FromUInt4Dg(Port[tP0].Area[tP1]);
		
		IList->STextDType.Show();
		IList->STextState.Show();
		IList->STextRegisted.Show();
		IList->EditDescpShow.Show();
		
		IList->EditUserCode.Show();
		IList->EditAreaAssign.Show();
		
		Check4Selected();
	}
}


void TDevStartStop::RedrawModuleInSignalInType()
{
	if(Data.ModuleSignalInType == 1){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
	}else
	if(Data.ModuleSignalInType == 2){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);		
	}else
	if(Data.ModuleSignalInType == 4){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
	}else{
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
	}
}

void TDevStartStop::RedrawModuleInOutSignalType()
{
	if((Data.ModuleSignalInOutType & 0x07) == 1){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
	}else
	if((Data.ModuleSignalInOutType & 0x07) == 2){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);		
	}else
	if((Data.ModuleSignalInOutType & 0x07) == 4){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
	}else{
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
	}
	
	if(Data.ModuleSignalInOutType & 0x08){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 72, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
	}else{
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 72, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
	}
}

void TDevStartStop::RedrawModuleOutSignalType()
{
	if(0){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
	}else
	if(0){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);		
	}else
	if(0){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
	}else{
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, clSilver , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, clSilver , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, clSilver , 0);
	}
	
	if(Data.ModuleSignalOutType & 0x08){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 72, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
	}else{
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 72, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
	}
}

void TDevStartStop::RedrawVaIs4Linkage()
{
	if(Data.VaIs4Linkage){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[2] + 12, Lv.Grid.Top[2] + 38, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
	}else{
		TRoundSquare::sDrawBySize(Lv.Grid.Left[2] + 12, Lv.Grid.Top[2] + 38, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
	}
}

void TDevStartStop::RedrawVaSetting()
{
	if(Data.VaVisionType == 0){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
	}else
	if(Data.VaVisionType == 1){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);		
	}else
	if(Data.VaVisionType == 2){
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
	}else{
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 12, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 110, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[1] + 206, ModuleRectLv3.Top + 36, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
	}
	
	char *tText;
	if(Data.VaSoundType == 0){
		if(LanguageEnCn==0)tText="未知  "; else tText="Unknown";
	}else
	if(Data.VaSoundType == 1){
		if(LanguageEnCn==0)tText="119   "; else tText="Std";
	}else
	if(Data.VaSoundType == 2){
		if(LanguageEnCn==0)tText="滴滴  "; else tText="Beep ";
	}else
	if(Data.VaSoundType == 3){
		if(LanguageEnCn==0)tText="警报声"; else tText="ALERTS";
	}
	
	if(LanguageEnCn==0)tText="音调 0"; else tText="Tone 0";
	IList->Edit[0].SetText(tText ,24);
	IList->Edit[0].Show();
}

void TDevStartStop::RedrawDisplayPadMatchMode()
{
	if(Data.DisplayPadMatchMode){
		//1 By Area Num
		TRoundSquare::sDrawBySize(Lv.Grid.Left[2] + 12, Lv.Grid.Top[2] + 38, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[2] + 110, Lv.Grid.Top[2] + 38, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
	}else{
		//0 By User Code
		TRoundSquare::sDrawBySize(Lv.Grid.Left[2] + 12, Lv.Grid.Top[2] + 38, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		TRoundSquare::sDrawBySize(Lv.Grid.Left[2] + 110, Lv.Grid.Top[2] + 38, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
	}
}

void TDevStartStop::LoadUcBcdText(unsigned int aUcFull, char *pText)
{
	int i;
	unsigned int f, aOrd;
	f = aUcFull;
	for(i=0; i<8; i++){
		f = aUcFull;
		f >>= ((7-i)*4);
		aOrd = (f & 0x0000'000F);
		pText[i] = CharBcdText[aOrd];

	}
	pText[8] = '\0';
}

void TDevStartStop::RedrawDisplayPadMatchData()
{
	for(int i=3; i<4; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	if(LanguageEnCn==0){
		TextRender_string24(Lv.Grid.Left[3] +10, Lv.Grid.Top[3] + 6, clNearWhite, ItemColor, "显示范围");
		TRoundRect::sDrawBySize(Lv.Grid.Left[3] +226, Lv.Grid.Top[3] + 4, 54, 30, 7, clNearWhite, "保存", 4, clNearBlack);
	}else{
		TextRender_string24(Lv.Grid.Left[3] +10, Lv.Grid.Top[3] + 6, clNearWhite, ItemColor, "DP-RANGE");
		TRoundRect::sDrawBySize(Lv.Grid.Left[3] +226, Lv.Grid.Top[3] + 4, 54, 30, 7, clNearWhite, "Save", 4, clNearBlack);
	}
	if(Data.DisplayPadMatchMode){
		//1 By Area Num
		if(Data.DisplayPadAreaUsing[0])
			TRoundSquare::sDrawBySize(Lv.Grid.Left[3] + 6, Lv.Grid.Top[3] + 42, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		else
			TRoundSquare::sDrawBySize(Lv.Grid.Left[3] + 6, Lv.Grid.Top[3] + 42, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);			
		if(Data.DisplayPadAreaUsing[1])
			TRoundSquare::sDrawBySize(Lv.Grid.Left[3] + 104, Lv.Grid.Top[3] + 42, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		else
			TRoundSquare::sDrawBySize(Lv.Grid.Left[3] + 104, Lv.Grid.Top[3] + 42, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		if(Data.DisplayPadAreaUsing[2])
			TRoundSquare::sDrawBySize(Lv.Grid.Left[3] + 200, Lv.Grid.Top[3] + 42, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		else
			TRoundSquare::sDrawBySize(Lv.Grid.Left[3] + 200, Lv.Grid.Top[3] + 42, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		IList->Edit[0].Init(Lv.Grid.Left[3] + 34, Lv.Grid.Top[3] + 38, 60, 32, 0,0,1,ItemColor);
		IList->Edit[1].Init(Lv.Grid.Left[3] + 132, Lv.Grid.Top[3] + 38, 60, 32, 0,0,1,ItemColor);
		IList->Edit[2].Init(Lv.Grid.Left[3] + 228, Lv.Grid.Top[3] + 38, 60, 32, 0,0,1,ItemColor);
		IList->Edit[0].Str.Clear();
		IList->Edit[1].Str.Clear();
		IList->Edit[2].Str.Clear();
		IList->Edit[0].SetMaxLen(4);
		IList->Edit[1].SetMaxLen(4);
		IList->Edit[2].SetMaxLen(4);
		
		IList->Edit[0].Str.FromUInt4Dg(Data.DisplayPadArea0);
		IList->Edit[1].Str.FromUInt4Dg(Data.DisplayPadArea1);
		IList->Edit[2].Str.FromUInt4Dg(Data.DisplayPadArea2);
		
		IList->Edit[0].Show();
		IList->Edit[1].Show();
		IList->Edit[2].Show();
	}else{
		//0 By User Code
		if(Data.DisplayPadUserCodeUsing[0])
			TRoundSquare::sDrawBySize(Lv.Grid.Left[3] + 12, Lv.Grid.Top[3] + 42, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		else
			TRoundSquare::sDrawBySize(Lv.Grid.Left[3] + 12, Lv.Grid.Top[3] + 42, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		if(Data.DisplayPadUserCodeUsing[1])
			TRoundSquare::sDrawBySize(Lv.Grid.Left[3] + 154, Lv.Grid.Top[3] + 42, dWWidth, dWHeigh, dRoundR, dWdClr , 1);
		else
			TRoundSquare::sDrawBySize(Lv.Grid.Left[3] + 154, Lv.Grid.Top[3] + 42, dWWidth, dWHeigh, dRoundR, dWdDisabelClr , 0);
		IList->Edit[0].Init(Lv.Grid.Left[3] + 42, Lv.Grid.Top[3] + 38, 104, 32, 0,0,1,ItemColor);
		IList->Edit[1].Init(Lv.Grid.Left[3] + 184, Lv.Grid.Top[3] + 38, 104, 32, 0,0,1,ItemColor);
		
		IList->Edit[0].Str.Clear();
		IList->Edit[1].Str.Clear();
		IList->Edit[0].SetMaxLen(8);
		IList->Edit[1].SetMaxLen(8);
		
		LoadUcBcdText(Data.DisplayUserCode0, IList->Edit[0].Str.Text);
		LoadUcBcdText(Data.DisplayUserCode1, IList->Edit[1].Str.Text);
		
		IList->Edit[0].Show();
		IList->Edit[1].Show();
	}
}

void TDevStartStop::Redraw4NewLoad()
{
	char *tText;
	Data.Reset();
	switch(HwDevType){
		case TDevProperty::htNoType:
			//for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			//if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			//if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
		
			break;
		case TDevProperty::htSmoker:
			IList->Edit[0].Str.Clear();
			IList->Edit[0].Show();
			if(IsSelfCtl){
				SmokerRt.IsWait4ReadSens = 1;
				SmokerRt.IsWait4WriteSens = 0;
				SmokerRt.RecRdy = 0;
				SmokerRt.RecCmd = 0;
				SmokerRt.WaitTick = 0;
				SendSmokeCmdRead();
				if(LanguageEnCn==0)tText="获取中  ";else tText="Reading ";
				TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, tText);
			}else{
				TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, "--------");
			}
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			break;
		case TDevProperty::htTempe:
			IList->Edit[0].Str.Clear();
			IList->Edit[0].Show();
			if(IsSelfCtl){
				TempeRt.IsWait4ReadSensType = 1;
				TempeRt.RecRdy = 0;
				TempeRt.RecCmd = 0;
				TempeRt.WaitTick = 0;
				SendTempeCmdRead();
				if(LanguageEnCn==0)tText="获取中  ";else tText="Reading ";
				TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, tText);
			}else{
				TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, "--------");
			}
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			break;
		case TDevProperty::htHandPad:
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			break;
		case TDevProperty::htHydrantPad:
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			break;
		case TDevProperty::htModuleIn:
			if(IsSelfCtl){
				unsigned char tType = Port[Path0-1].AssignType[Path1-1];
				IList->Edit[0].Str.FromUInt3Dg(tType);
				if(LanguageEnCn==0){
					if(tType == 0){
						IList->STextModuleInDefineType.SetText("未指派类型", 24);
					}else{
						IList->STextModuleInDefineType.SetText(StrTypeShortName[tType] , 24);
					}
				}else{
					if(tType == 0){
						IList->STextModuleInDefineType.SetText("NONE TYPE ", 24);
					}else{
						IList->STextModuleInDefineType.SetText(StrTypeShortNameEn[tType] , 24);
					}
				}
			}else{
				IList->Edit[0].Str.FromStr("----");
				IList->STextModuleInDefineType.SetText("--------" , 24);
			}
			IList->Edit[0].Show();
			IList->STextModuleInDefineType.Show();
			
			if(IsSelfCtl){
				//ModuleInRt.IsWait4ReadSignalType = 1;
				//ModuleInRt.IsWait4WriteSignalType = 0;
				//ModuleInRt.RecRdy = 0;
				//ModuleInRt.RecCmd = 0;
				//ModuleInRt.WaitTick = 0;
				//SendModuleSignalInOutTypeRead();
				//TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "获取中  ");
				Data.ModuleSignalInType = Port[Path0-1].FuncSetByte[Path1-1];
				RedrawModuleInSignalInType();
			}else{
				TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "--------");
			}
	
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			break;
		case TDevProperty::htModuleInOut:
			if(IsSelfCtl){
				unsigned char tType = Port[Path0-1].AssignType[Path1-1];
				IList->Edit[0].Str.FromUInt3Dg(tType);
				if(LanguageEnCn==0){
					if(tType == 0){
						IList->STextModuleInDefineType.SetText("未指派类型", 24);
					}else{
						IList->STextModuleInDefineType.SetText(StrTypeShortName[tType] , 24);
					}
				}else{
					if(tType == 0){
						IList->STextModuleInDefineType.SetText("NONE TYPE ", 24);
					}else{
						IList->STextModuleInDefineType.SetText(StrTypeShortNameEn[tType] , 24);
					}
				}
			}else{
				IList->Edit[0].Str.FromStr("----");
				IList->STextModuleInDefineType.SetText("--------" , 24);
			}
			IList->Edit[0].Show();
			IList->STextModuleInDefineType.Show();
			
			if(IsSelfCtl){
				//ModuleInOutRt.IsWait4ReadSignalType = 1;
				//ModuleInOutRt.IsWait4WriteSignalType = 0;
				//ModuleInOutRt.RecRdy = 0;
				//ModuleInOutRt.RecCmd = 0;
				//ModuleInOutRt.WaitTick = 0;
				//SendModuleSignalInOutTypeRead();
				//TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "获取中  ");
				Data.ModuleSignalInOutType = Port[Path0-1].FuncSetByte[Path1-1];
				RedrawModuleInOutSignalType();
			}else{
				TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "--------");
			}
	
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			break;
		case TDevProperty::htModuleOut:
			if(IsSelfCtl){
				unsigned char tType = Port[Path0-1].AssignType[Path1-1];
				IList->Edit[0].Str.FromUInt3Dg(tType);
				if(LanguageEnCn==0){
					if(tType == 0){
						IList->STextModuleInDefineType.SetText("未指派类型", 24);
					}else{
						IList->STextModuleInDefineType.SetText(StrTypeShortName[tType] , 24);
					}
				}else{
					if(tType == 0){
						IList->STextModuleInDefineType.SetText("NONE TYPE ", 24);
					}else{
						IList->STextModuleInDefineType.SetText(StrTypeShortNameEn[tType] , 24);
					}
				}
			}else{
				IList->Edit[0].Str.FromStr("----");
				IList->STextModuleInDefineType.SetText("--------" , 24);
			}
			IList->Edit[0].Show();
			IList->STextModuleInDefineType.Show();
			
			if(IsSelfCtl){
				//ModuleOutRt.IsWait4ReadSignalType = 1;
				//ModuleOutRt.IsWait4WriteSignalType = 0;
				//ModuleOutRt.RecRdy = 0;
				//ModuleOutRt.RecCmd = 0;
				//ModuleOutRt.WaitTick = 0;
				//SendModuleSignalInOutTypeRead();
				//TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "获取中  ");
				Data.ModuleSignalOutType = Port[Path0-1].FuncSetByte[Path1-1];
				RedrawModuleOutSignalType();
			}else{
				TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "--------");
			}
	
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			break;
		case TDevProperty::htVa:
			IList->Edit[0].Show();
			if(IsSelfCtl){
				VaRt.IsWait4ReadVaSetting = 1;
				VaRt.IsWait4WriteVaSetting = 0;
				VaRt.RecRdy = 0;
				VaRt.RecCmd = 0;
				VaRt.WaitTick = 0;
				SendVaSettingRead();
				DrawVaReadWriteStates(5);
			}else{
				TextRender_string24(Lv.Grid.Left[3] +190, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "--------");
			}
	
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			break;
		case TDevProperty::htDisplayPad:
			RedrawDisplayPadMatchMode();
			RedrawDisplayPadMatchData();
	
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			break;
		case TDevProperty::htLinkagePowerSuply:
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			break;
		default :
			for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
			if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
			if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
			if(LanguageEnCn==0){
				TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "操作");
				TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "启动", 14, clNearBlack);
				TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "停止", 14, clNearBlack);
			}else{
				TextRender_string24(Lv.Grid.Left[2] +10, Lv.Grid.Top[2] + 4, clNearWhite, ItemColor, "Operation");
				TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, "Act ", 14, clNearBlack);
				TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, "Stop", 14, clNearBlack);

			}
			break;
	}
}

//______________________________________________________________________________________________________________________________
void TDevStartStop::ClearSelected()
{
	char *tText;
	switch(Tag.Inx){
		case 0:
			IList->EditCtlNum.Selected = 0;
			IList->EditCtlNum.Show();
			break;
		case 1:
			IList->EditPortNum.Selected = 0;
			IList->EditPortNum.Show();
			break;
		case 2:
			IList->EditAddrNum.Selected = 0;
			IList->EditAddrNum.Show();
			break;
		case 3:
			IList->EditUserCode.Selected = 0;
			IList->EditUserCode.Show();
			break;
		case 4:
			if(LanguageEnCn==0)tText="启动"; else tText="Act ";
			TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clNearWhite, tText, 14, clNearBlack);
			break;
		case 5:
			if(LanguageEnCn==0)tText="停止"; else tText="Stop";
			TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clNearWhite, tText, 14, clNearBlack);
			break;
	}
}

void TDevStartStop::Check4Selected()
{
	char *tText;
	switch(Tag.Inx){
		case 0:
			IList->EditCtlNum.Selected = 1;
			IList->EditCtlNum.SetPstTail();
			IList->EditCtlNum.Show();
			IList->EditCtlNum.ShowCursor();
			break;
		case 1:
			IList->EditPortNum.Selected = 1;
			IList->EditPortNum.SetPstTail();
			IList->EditPortNum.Show();
			IList->EditPortNum.ShowCursor();
			break;
		case 2:
			IList->EditAddrNum.Selected = 1;
			IList->EditAddrNum.SetPstTail();
			IList->EditAddrNum.Show();
			IList->EditAddrNum.ShowCursor();
			break;
		case 3:
			IList->EditUserCode.Selected = 1;
			IList->EditUserCode.SetPstTail();
			IList->EditUserCode.Show();
			IList->EditUserCode.ShowCursor();
			break;
		case 4:
			if(LanguageEnCn==0)tText="启动"; else tText="Act ";
			TRoundRect::sDrawBySize(PtStart.x, PtStart.y, 76, 30, 7, clDeepBlue, tText, 14, clNearWhite);
			break;
		case 5:
			if(LanguageEnCn==0)tText="停止"; else tText="Stop";
			TRoundRect::sDrawBySize(PtStop.x, PtStop.y, 76, 30, 7, clDeepBlue, tText, 14, clNearWhite);
			break;
	}
}

void TDevStartStop::PermissionCmdReturnDraw()
{
	int x,y;
	Check4Selected();
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(PanelIsUsingText){
		for(int i=0; i<8; i++){
			y = Lv.Panel.Top + 1;
			y = y + i * 27;
			x = Lv.Panel.Left + 2;
			if(EdittingDescp == 0){
				if( (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) )
					TextRender_string24(x,y,clNearBlack, IList->TextOut[i]);
			}
		}
	}
}

void TDevStartStop::ReDrawPanel()
{
	PermissionCmdReturnDraw();
}
//_____________________________________________________________________________________________________________________________


void TDevStartStop::ResetTargetData()
{
	RuntimeData.Reset();
	IList->RealtimeData.Reset();
	IList->TextOutClear();
	PanelDrawData.ResetNotFull();
	switch(HwDevType){
		case TDevProperty::htNoType:
			
			break;
		case TDevProperty::htSmoker:
			if(MainCtl.fData.Split.MyNum == CtlNum){
				RealTimeSendCmd(1);
				SendSmokeCmdRead();
			}
			break;
		case TDevProperty::htTempe:
			if(MainCtl.fData.Split.MyNum == CtlNum){
				RealTimeSendCmd(1);
				SendTempeCmdRead();
			}
			break;
		case TDevProperty::htHandPad:
			if(MainCtl.fData.Split.MyNum == CtlNum){
				RealTimeSendCmd(1);
			}
			break;
		case TDevProperty::htHydrantPad:
			if(MainCtl.fData.Split.MyNum == CtlNum){
				RealTimeSendCmd(1);
			}
			break;
		case TDevProperty::htModuleIn:
			if(MainCtl.fData.Split.MyNum == CtlNum){
				RealTimeSendCmd(1);
				SendModuleSignalInOutTypeRead();
			}
			break;
		case TDevProperty::htModuleInOut:
			if(MainCtl.fData.Split.MyNum == CtlNum){
				RealTimeSendCmd(1);
				SendModuleSignalInOutTypeRead();
			}
			break;
		case TDevProperty::htModuleOut:
				
			break;
		case TDevProperty::htVa:
			if(MainCtl.fData.Split.MyNum == CtlNum){
				RealTimeSendCmd(1);
				SendVaSettingRead();
			}
			break;
		case TDevProperty::htDisplayPad:
			if(MainCtl.fData.Split.MyNum == CtlNum){
				RealTimeSendCmd(1);
			}				
			break;
		case TDevProperty::htLinkagePowerSuply:
			if(MainCtl.fData.Split.MyNum == CtlNum){
				RealTimeSendCmd(1);
			}				
			break;
		default :
			
			break;
	}
}


void TDevStartStop::Init4DType()
{
	Data.Reset();
	RectFillRender(Lv.Grid.Left[0], Lv.Grid.Top[3], Lv.Grid.Right[3], Lv.Grid.Bottom[4], ContentColor);
	if(dType == dgTYPE_SMOKE_DETECTOR){
		PtStart.x = Lv.Grid.Left[3] + 56;
		PtStart.y = Lv.Grid.Top[3] + 38;
		PtStop.x = Lv.Grid.Left[3] + 180;
		PtStop.y = Lv.Grid.Top[3] + 38;
		PanelDrawData.TextDrawLine = 0;
		HwDevType = TDevProperty::htSmoker;
		InitHtSmoker();
		ResetTargetData();
		RealTimeSendCmd(1);
		
	}else
	if(dType == dgTYPE_TEMPE_DETECTOR){
		PtStart.x = Lv.Grid.Left[3] + 56;
		PtStart.y = Lv.Grid.Top[3] + 38;
		PtStop.x = Lv.Grid.Left[3] + 180;
		PtStop.y = Lv.Grid.Top[3] + 38;
		PanelDrawData.TextDrawLine = 0;
		HwDevType = TDevProperty::htTempe;
		InitHtTempe();
		ResetTargetData();
	}else
	if(dType == dgTYPE_HAND_REPORT){
		PtStart.x = Lv.Grid.Left[2] + 56;
		PtStart.y = Lv.Grid.Top[2] + 38;
		PtStop.x = Lv.Grid.Left[2] + 180;
		PtStop.y = Lv.Grid.Top[2] + 38;
		PanelDrawData.TextDrawLine = 0;
		HwDevType = TDevProperty::htHandPad;
		InitHtHandPad();
		ResetTargetData();
	}else
	if(dType == dgTYPE_FIRE_HydrantKp){
		PtStart.x = Lv.Grid.Left[2] + 56;
		PtStart.y = Lv.Grid.Top[2] + 38;
		PtStop.x = Lv.Grid.Left[2] + 180;
		PtStop.y = Lv.Grid.Top[2] + 38;
		PanelDrawData.TextDrawLine = 0;
		HwDevType = TDevProperty::htHydrantPad;
		InitHtHydrantPad();
		ResetTargetData();
	}else
	if(dType == dgTYPE_IN_MODULE){
		PtStart.x = ModuleRectLv4.Left + 56;
		PtStart.y = ModuleRectLv4.Top + 6;
		PtStop.x = ModuleRectLv4.Left + 180;
		PtStop.y = ModuleRectLv4.Top + 6;
		PanelDrawData.TextDrawLine = 0;
		HwDevType = TDevProperty::htModuleIn;
		InitHtModuleIn();
		ResetTargetData();
	}else
	if(dType == dgTYPE_OUT_MODULE){
		PtStart.x = ModuleRectLv4.Left + 56;
		PtStart.y = ModuleRectLv4.Top + 6;
		PtStop.x = ModuleRectLv4.Left + 180;
		PtStop.y = ModuleRectLv4.Top + 6;
		PanelDrawData.TextDrawLine = 0;
		HwDevType = TDevProperty::htModuleOut;
		InitHtModuleOut();
		ResetTargetData();
	}else
	if(dType == dgTYPE_INOUT_MODULE_NonSource){
		PtStart.x = ModuleRectLv4.Left + 56;
		PtStart.y = ModuleRectLv4.Top + 6;
		PtStop.x = ModuleRectLv4.Left + 180;
		PtStop.y = ModuleRectLv4.Top + 6;
		PanelDrawData.TextDrawLine = 0;
		HwDevType = TDevProperty::htModuleInOut;
		InitHtModuleInOut();
		ResetTargetData();
	}else
	if(dType == dgType_VAALRAM){
		PtStart.x = ModuleRectLv4.Left + 76;
		PtStart.y = ModuleRectLv4.Top + 6;
		PtStop.x = ModuleRectLv4.Left + 190;
		PtStop.y = ModuleRectLv4.Top + 6;
		PanelDrawData.TextDrawLine = 0;
		HwDevType = TDevProperty::htVa;
		InitHtVa();
		ResetTargetData();
	}else
	if(dType == dgTYPE_DISPLAY_PAD){
		PtStart.x = Lv.Grid.Left[4] + 76;
		PtStart.y = Lv.Grid.Top[4] + 36;
		PtStop.x = Lv.Grid.Left[4] + 190;
		PtStop.y = Lv.Grid.Top[4] + 36;
		PanelDrawData.TextDrawLine = 0;
		HwDevType = TDevProperty::htDisplayPad;
		InitHtDisplayPad();
		ResetTargetData();
	}else
	if(dType == dgTYPE_LINKAGE_POWERSUPLY){
		PtStart.x = Lv.Grid.Left[2] + 56;
		PtStart.y = Lv.Grid.Top[2] + 38;
		PtStop.x = Lv.Grid.Left[2] + 180;
		PtStop.y = Lv.Grid.Top[2] + 38;
		PanelDrawData.TextDrawLine = 0;
		HwDevType = TDevProperty::htLinkagePowerSuply;
		InitHtLinkagePowerSuply();
		ResetTargetData();
	}else{
		PtStart.x = Lv.Grid.Left[2] + 56;
		PtStart.y = Lv.Grid.Top[2] + 38;
		PtStop.x = Lv.Grid.Left[2] + 180;
		PtStop.y = Lv.Grid.Top[2] + 38;
		PanelDrawData.TextDrawLine = 0;
		HwDevType = TDevProperty::htNoType;
		ResetTargetData();
		InitNoType();
	}		
}

void TDevStartStop::ClearCommonInf()
{
	IList->STextDType.SetText("------",24);
	IList->STextState.SetText("----", 24);
	IList->STextRegisted.SetText("------", 24);
	IList->EditDescpShow.Str.Text[0] = '\0';
	IList->EditDescpShow.Str.Text[1] = '\0';
	IList->EditUserCode.Str.FromStr("--------");
	IList->EditAreaAssign.Str.FromStr("----");
		
	IList->STextDType.Show();
	TCircle::sRender(IList->STextState.Bound.Left -12, IList->STextState.Bound.Top +14, 10, ItemColor, 0xF);
	IList->STextState.Show();
	IList->STextRegisted.Show();
	IList->EditDescpShow.Show();
	IList->EditUserCode.Show();
	IList->EditAreaAssign.Show();

}

void TDevStartStop::InitNoType()
{
	PanelIsUsingText = 1;
	for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
	
	DrawFixTextNoType();
}

void TDevStartStop::InitHtSmoker()
{
	PanelIsUsingText = 1;
	
	for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	
	DrawFixTextSmoker();
	
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
	
	RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
	RectFillRender(Lv.PanelSmall.Left + 120, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 120 + 20, Lv.PanelSmall.Top + 6 + 20, clPurple);
	
	IList->Edit[0].Init(Lv.Grid.Left[2] +86, Lv.Grid.Top[2] + 4, 100,30,0,0,1,clNearBlack);
	IList->Edit[0].Enable = 0;
	IList->Edit[0].Str.Clear();
	IList->Edit[0].Show(); 
	
	if(IsSelfCtl){
		SmokerRt.IsWait4ReadSens = 1;
		SmokerRt.IsWait4WriteSens = 0;
		SmokerRt.RecRdy = 0;
		SmokerRt.RecCmd = 0;
		SmokerRt.WaitTick = 0;
		char *tText;
		if(LanguageEnCn==0)tText="获取中  "; else tText="Reading ";
		TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, tText);
	}else{
		TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, "--------");
	}
}

void TDevStartStop::InitHtTempe()
{
	PanelIsUsingText = 1;
	
	for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	
	DrawFixTextTempe();
	
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
	
	RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
	//RectFillRender(Lv.PanelSmall.Left + 120, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 120 + 20, Lv.PanelSmall.Top + 6 + 20, clPurple);
	
	IList->Edit[0].Init(Lv.Grid.Left[2] +116, Lv.Grid.Top[2] + 4, 60,30,0,0,1,clNearBlack);
	IList->Edit[0].Enable = 0;
	IList->Edit[0].Str.Clear();
	IList->Edit[0].Show(); 
	
	if(IsSelfCtl){
		TempeRt.IsWait4ReadSensType = 1;
		TempeRt.RecRdy = 0;
		TempeRt.RecCmd = 0;
		TempeRt.WaitTick = 0;
		char *tText;
		if(LanguageEnCn==0)tText="获取中  "; else tText="Reading ";
		TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, tText);
	}else{
		TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, "--------");
	}
}

void TDevStartStop::InitHtHandPad()
{
	PanelIsUsingText = 1;
	
	for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	
	DrawFixTextHandPad();
	
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
	
	RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);

	
	IList->Edit[0].Init(Lv.Grid.Left[2] +116, Lv.Grid.Top[2] + 4, 60,30,0,0,1,clNearBlack);
	IList->Edit[0].Enable = 0;
	IList->Edit[0].Str.Clear();
}

void TDevStartStop::InitHtHydrantPad()
{
	PanelIsUsingText = 1;
	
	for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	
	DrawFixTextHydrantPad();
	
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
	
	RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);

	IList->Edit[0].Init(Lv.Grid.Left[2] +116, Lv.Grid.Top[2] + 4, 60,30,0,0,1,clNearBlack);
	IList->Edit[0].Enable = 0;
	IList->Edit[0].Str.Clear();
}

void TDevStartStop::InitHtModuleIn()
{
	PanelIsUsingText = 1;
	
	for(int i=2; i<3; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	RectFillRender(Lv.Grid.Left[3], ModuleRectLv3.Top, Lv.Grid.Right[3], ModuleRectLv3.Bottom, ItemColor);
	RectFillRender(Lv.Grid.Left[4], ModuleRectLv4.Top, Lv.Grid.Right[4], ModuleRectLv4.Bottom, ItemColor);
	
	DrawFixTextModuleIn();
	
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
	
	RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
	
	IList->Edit[0].Init(Lv.Grid.Left[2] +110, Lv.Grid.Top[2] + 4, 48,30,0,0,1,clNearBlack);
	IList->Edit[0].Enable = 0;
	IList->Edit[0].Str.Clear();
	IList->STextModuleInDefineType.Init(Lv.Grid.Left[2] +4, Lv.Grid.Top[2] + 40, 196,30,0,0,clNearWhite,ItemColor);
	if(IsSelfCtl){
		unsigned char tType = Port[Path0-1].AssignType[Path1-1];
		IList->Edit[0].Str.FromUInt3Dg(tType);
		if(LanguageEnCn==0){
			if(tType == 0){
				IList->STextModuleInDefineType.SetText("未指派类型", 24);
			}else{
				IList->STextModuleInDefineType.SetText(StrTypeShortName[tType] , 24);
			}
		}else{
			if(tType == 0){
				IList->STextModuleInDefineType.SetText("Nont Type ", 24);
			}else{
				IList->STextModuleInDefineType.SetText(StrTypeShortNameEn[tType] , 24);
			}
		}
	}else{
		IList->Edit[0].Str.FromStr("----");
		IList->STextModuleInDefineType.SetText("--------" , 24);
	}
	IList->Edit[0].Show();
	IList->STextModuleInDefineType.Show();
	if(IsSelfCtl){
		//ModuleInRt.IsWait4ReadSignalType = 1;
		//ModuleInRt.IsWait4WriteSignalType = 0;
		//ModuleInRt.RecRdy = 0;
		//ModuleInRt.RecCmd = 0;
		//ModuleInRt.WaitTick = 0;
		//TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "获取中  ");
		Data.ModuleSignalInType = Port[Path0-1].FuncSetByte[Path1-1];
	}else{
		TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "--------");
	}
	
	RedrawModuleInSignalInType();
}

void TDevStartStop::InitHtModuleInOut()
{
	PanelIsUsingText = 1;
	
	for(int i=2; i<3; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	RectFillRender(Lv.Grid.Left[3], ModuleRectLv3.Top, Lv.Grid.Right[3], ModuleRectLv3.Bottom, ItemColor);
	RectFillRender(Lv.Grid.Left[4], ModuleRectLv4.Top, Lv.Grid.Right[4], ModuleRectLv4.Bottom, ItemColor);
	
	DrawFixTextModuleInOut();
	
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
	
	RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
	
	IList->Edit[0].Init(Lv.Grid.Left[2] +110, Lv.Grid.Top[2] + 4, 48,30,0,0,1,clNearBlack);
	IList->Edit[0].Enable = 0;
	IList->Edit[0].Str.Clear();
	IList->STextModuleInDefineType.Init(Lv.Grid.Left[2] +4, Lv.Grid.Top[2] + 40, 160,30,0,0,clNearWhite,ItemColor);
	if(IsSelfCtl){
		unsigned char tType = Port[Path0-1].AssignType[Path1-1];
		IList->Edit[0].Str.FromUInt3Dg(tType);
		if(LanguageEnCn==0){
			if(tType == 0){
				IList->STextModuleInDefineType.SetText("未指派类型", 24);
			}else{
				IList->STextModuleInDefineType.SetText(StrTypeShortName[tType] , 24);
			}
		}else{
			if(tType == 0){
				IList->STextModuleInDefineType.SetText("None Type ", 24);
			}else{
				IList->STextModuleInDefineType.SetText(StrTypeShortNameEn[tType] , 24);
			}

		}
	}else{
		IList->Edit[0].Str.FromStr("----");
		IList->STextModuleInDefineType.SetText("--------" , 24);
	}
	IList->Edit[0].Show();
	IList->STextModuleInDefineType.Show();
	
	if(IsSelfCtl){
		//ModuleInOutRt.IsWait4ReadSignalType = 1;
		//ModuleInOutRt.IsWait4WriteSignalType = 0;
		//ModuleInOutRt.RecRdy = 0;
		//ModuleInOutRt.RecCmd = 0;
		//ModuleInOutRt.WaitTick = 0;
		//TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "获取中  ");
		Data.ModuleSignalInOutType = Port[Path0-1].FuncSetByte[Path1-1];
	}else{
		TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "--------");
	}
	
	RedrawModuleInOutSignalType();
}

void TDevStartStop::InitHtModuleOut()
{
	PanelIsUsingText = 1;
	
	for(int i=2; i<3; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	RectFillRender(Lv.Grid.Left[3], ModuleRectLv3.Top, Lv.Grid.Right[3], ModuleRectLv3.Bottom, ItemColor);
	RectFillRender(Lv.Grid.Left[4], ModuleRectLv4.Top, Lv.Grid.Right[4], ModuleRectLv4.Bottom, ItemColor);
	
	DrawFixTextModuleOut();
	
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
	
	RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
	
	IList->Edit[0].Init(Lv.Grid.Left[2] +110, Lv.Grid.Top[2] + 4, 48,30,0,0,1,clNearBlack);
	IList->Edit[0].Enable = 0;
	IList->Edit[0].Str.Clear();
	IList->STextModuleInDefineType.Init(Lv.Grid.Left[2] +4, Lv.Grid.Top[2] + 40, 160,30,0,0,clNearWhite,ItemColor);
	if(IsSelfCtl){
		unsigned char tType = Port[Path0-1].AssignType[Path1-1];
		IList->Edit[0].Str.FromUInt3Dg(tType);
		if(LanguageEnCn==0){
			if(tType == 0){
				IList->STextModuleInDefineType.SetText("未指派类型", 24);
			}else{
				IList->STextModuleInDefineType.SetText(StrTypeShortName[tType] , 24);
			}
		}else{
			if(tType == 0){
				IList->STextModuleInDefineType.SetText("None Type", 24);
			}else{
				IList->STextModuleInDefineType.SetText(StrTypeShortNameEn[tType] , 24);
			}
		}
	}else{
		IList->Edit[0].Str.FromStr("----");
		IList->STextModuleInDefineType.SetText("--------" , 24);
	}
	IList->Edit[0].Show();
	IList->STextModuleInDefineType.Show();
	
	if(IsSelfCtl){
		//ModuleOutRt.IsWait4ReadSignalType = 1;
		//ModuleOutRt.IsWait4WriteSignalType = 0;
		//ModuleOutRt.RecRdy = 0;
		//ModuleOutRt.RecCmd = 0;
		//ModuleOutRt.WaitTick = 0;
		//TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "获取中  ");
		Data.ModuleSignalOutType = Port[Path0-1].FuncSetByte[Path1-1];
	}else{
		TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "--------");
	}
	
	RedrawModuleOutSignalType();
}

void TDevStartStop::InitHtVa()
{
	char *tText;
	PanelIsUsingText = 1;
	
	for(int i=2; i<3; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	RectFillRender(Lv.Grid.Left[3], ModuleRectLv3.Top, Lv.Grid.Right[3], ModuleRectLv3.Bottom, ItemColor);
	RectFillRender(Lv.Grid.Left[4], ModuleRectLv4.Top, Lv.Grid.Right[4], ModuleRectLv4.Bottom, ItemColor);
	
	DrawFixTextVa();

	IList->Edit[0].Init(Lv.Grid.Left[3] +10, ModuleRectLv3.Top + 72, 100,30,0,0,1,clNearBlack);
	IList->Edit[0].Enable = 0;
	IList->Edit[0].Str.Clear();
	IList->Edit[0].Show();
	
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
	
	RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
	
	if(IsSelfCtl){
		VaRt.IsWait4ReadVaSetting = 1;
		VaRt.IsWait4WriteVaSetting = 0;
		VaRt.RecRdy = 0;
		VaRt.RecCmd = 0;
		VaRt.WaitTick = 0;
		DrawVaReadWriteStates(5);
	}else{
		TextRender_string24(Lv.Grid.Left[3] +190, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "--------");
	}
	
	RedrawVaIs4Linkage();
	RedrawVaSetting();
}

void TDevStartStop::InitHtDisplayPad()
{
	PanelIsUsingText = 1;
	
	for(int i=2; i<5; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	DrawFixTextDisplayPad();
	
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
	
	RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
	
	RedrawDisplayPadMatchMode();
	RedrawDisplayPadMatchData();
}


void TDevStartStop::InitHtLinkagePowerSuply()
{
	PanelIsUsingText = 1;
	
	for(int i=2; i<Lv.Grid.UsingCount; i++)RectFillRender(Lv.Grid.Left[i], Lv.Grid.Top[i], Lv.Grid.Right[i], Lv.Grid.Bottom[i], ItemColor);
	DrawFixTextLinkagePowerSuply();
	
	if(Lv.Panel.Active)RectFillRender(Lv.Panel.Left, Lv.Panel.Top, Lv.Panel.Right, Lv.Panel.Bottom, PanelColor);
	if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
	
	RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);
}

void TDevStartStop::ReReadCmdSend()
{
	char *tText;
	if(IsSelfCtl == 0){
		TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, "--------");
		return;
	}
	if(dType == dgTYPE_SMOKE_DETECTOR){
		SmokerRt.IsWait4ReadSens = 1;
		SmokerRt.IsWait4WriteSens = 0;
		SmokerRt.RecRdy = 0;
		SmokerRt.RecCmd = 0;
		SmokerRt.WaitTick = 0;
		SendSmokeCmdRead();
		if(LanguageEnCn==0)tText="获取中  "; else tText="Reading ";
		TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, tText);
	}else
	if(dType == dgTYPE_TEMPE_DETECTOR){
		TempeRt.IsWait4ReadSensType = 1;
		TempeRt.RecRdy = 0;
		TempeRt.RecCmd = 0;
		TempeRt.WaitTick = 0;
		SendTempeCmdRead();
		if(LanguageEnCn==0)tText="获取中  "; else tText="Reading ";
		TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, tText);
	}else
	if(dType == dgTYPE_IN_MODULE){
		//ModuleInRt.IsWait4ReadSignalType = 1;
		//ModuleInRt.IsWait4WriteSignalType = 0;
		//ModuleInRt.RecRdy = 0;
		//ModuleInRt.RecCmd = 0;
		//ModuleInRt.WaitTick = 0;
		//SendModuleSignalInOutTypeRead();
		//TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "获取中  ");
	}else
	if(dType == dgTYPE_OUT_MODULE){
		//ModuleOutRt.IsWait4ReadSignalType = 1;
		//ModuleOutRt.IsWait4WriteSignalType = 0;
		//ModuleOutRt.RecRdy = 0;
		//ModuleOutRt.RecCmd = 0;
		//ModuleOutRt.WaitTick = 0;
		//SendModuleSignalInOutTypeRead();
		//TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "获取中  ");
	}else
	if(dType == dgTYPE_INOUT_MODULE_NonSource){
		//ModuleInOutRt.IsWait4ReadSignalType = 1;
		//ModuleInOutRt.IsWait4WriteSignalType = 0;
		//ModuleInOutRt.RecRdy = 0;
		//ModuleInOutRt.RecCmd = 0;
		//ModuleInOutRt.WaitTick = 0;
		//SendModuleSignalInOutTypeRead();
		//TextRender_string24(Lv.Grid.Left[3] +160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "获取中  ");
	}else
	if(dType == dgType_VAALRAM){
		VaRt.IsWait4ReadVaSetting = 1;
		VaRt.IsWait4WriteVaSetting = 0;
		VaRt.RecRdy = 0;
		VaRt.RecCmd = 0;
		VaRt.WaitTick = 0;
		SendVaSettingRead();
		DrawVaReadWriteStates(5);
	}
}


TGuiMsgReturn TDevStartStop::KeyIn(unsigned char aKey)
{
	TGuiMsgReturn aMsg = guiMsgNone;
	TGuiMsgReturn PmsRtnMsg = guiMsgNone;
	int HasPrcKey = 0;
	if(IsPermission){
		PmsRtnMsg = PmsIntervene4Gui.KeyIn(aKey);
		if(PmsRtnMsg == guiMsgOkAndReturn){
			//Enter And Run Go
			IsPermission = 0;
			PermissionCmdReturnDraw();
			PermissionCmdGO();
		}else
		if(PmsRtnMsg == guiMsgReturn){
			//Not Enter Redraw
			IsPermission = 0;
			PermissionCmdReturnDraw();
		}
	}else{
		switch(aKey){
			case '0':
			case '1':
			case '2':
			case '3':
			case '4':
			case '5':
			case '6':
			case '7':
			case '8':
			case '9':
			case VK_LEFT:
			case VK_RIGHT:
			case VK_DELETE:
				if(VK_LEFT == aKey){
					if(Tag.Inx == 0){
						if(IList->EditCtlNum.Pst < 0){
							if(CtlNumValid){
								ClearSelected();
								Tag.Inx = 1;
								Check4Selected();
								HasPrcKey = 1;
							}
						}
					}else
					if(Tag.Inx == 5){
						ClearSelected();
						Tag.Inx = 4;
						Check4Selected();
						HasPrcKey = 1;
					}
				}else
				if(VK_RIGHT == aKey){
					if(Tag.Inx == 1){
						if(IList->EditPortNum.Pst >= IList->EditPortNum.Str.GetEndPst()){
							if(Tag.InxMin == 0){
								if(PortNumValid){
									ClearSelected();
									Tag.Inx = 0;
									Check4Selected();
									HasPrcKey = 1;
								}
							}
						}
					}else
					if(Tag.Inx == 4){
						ClearSelected();
						Tag.Inx = 5;
						Check4Selected();
						HasPrcKey = 1;
					}
				}
				if( HasPrcKey == 0)
					KeyInCommonEdit(aKey);
				break;
			case VK_UP:
				if(Tag.Inx > Tag.InxMin){
					if(Tag.Inx == 1){
						if(PortNumValid){
							ClearSelected();
							Tag.Inx--;
							Check4Selected();
						}
					}else
					if(Tag.Inx == 2){
						if(AddrNumValid){
							ClearSelected();
							Tag.Inx--;
							Check4Selected();
						}
					}else{
						ClearSelected();
						Tag.Inx--;
						Check4Selected();
					}
				}
				break;
			case VK_DOWN:
				if(Tag.Inx < 5){
					if(Tag.Inx == 0){
						if(CtlNumValid){
							ClearSelected();
							Tag.Inx++;
							Check4Selected();
						}
					}else
					if(Tag.Inx == 1){
						if(PortNumValid){
							ClearSelected();
							Tag.Inx++;
							Check4Selected();
						}
					}else
					if(Tag.Inx == 2){
						if(AddrNumValid){
							ClearSelected();
							Tag.Inx++;
							Check4Selected();
						}
					}else{
						ClearSelected();
						Tag.Inx++;
						Check4Selected();
					}
				}
				break;
			case VK_TAB:
				PanelIsUsingText = PanelIsUsingText ? 0 : 1;
				break;
			case dfKEY_SETUP:
				ReReadCmdSend();
				break;
			case dfKEY_QUERY:
				PanelDrawData.DesertTextHex = PanelDrawData.DesertTextHex ? 0: 1;
				break;
			case VK_EXECUTE:
				KeyInCommonEnter(aKey);
				break;
			case VK_RETURN:
				IsShow = 0;
				aMsg = guiMsgReturn;
				break;
		}
	}
	return aMsg;
}


TGuiMsgReturn TDevStartStop::KeyInCommonEdit(unsigned char aKey)
{
	int tVal;
	unsigned char tP0, tP1, NewType, IsNewTarget;
	TGuiMsgReturn aMsg = guiMsgNone;
	int HasPrcKey = 0;
	if(Tag.Inx == 0){
		//Ctl Num
		pNumFound = 0;
		IsNewTarget = 0;
		IList->EditCtlNum.KeyIn(aKey);
		tVal = IList->EditCtlNum.Str.ToInteger();
		if(tVal == MainCtl.fData.Split.MyNum){
			if(LanguageEnCn==0)IList->STextCtlType.SetText("本集中机",24);
			else IList->STextCtlType.SetText("MainHost",24);
			IList->EditCtlNum.SelectedColor = clBlue;
			IsSelfCtl = 1;
			CtlNumValid =1;
			if(CtlNum != tVal){
				CtlNum = tVal;
				ClearReqDataState();
				ReDrawCommonInf();
				Check4Selected();
				RealTimeSendCmdAbort();
				tP0 = Path0-1;
				tP1 = Path1-1;
				if(Port[tP0].ExistTable[tP1] == 0xA5){
					NewType = Port[tP0].dTypeTable[tP1];
				}else{
					NewType = 0;
					Init4DType();
				}
				if(NewType == dType){
					//Load New Addr Inf
					Redraw4NewLoad();
					//UpdataOnlineData();
				}else{
					//Load 4 New Type
					dType = NewType;
					Init4DType();
				}
				ResetTargetData();
			}
		}else{
			if( (tVal >0) && (tVal <=dNETWORK_MACHINE_COUNT)){
				pNumFound = 1;
			}
			if(pNumFound){
				if(LanguageEnCn==0)IList->STextCtlType.SetText("区域机  ",24);
				else IList->STextCtlType.SetText("REGIONAL",24);
				IList->EditCtlNum.SelectedColor = clBlue;
				CtlNumValid =1;
			}else{
				if(LanguageEnCn==0)IList->STextCtlType.SetText("无效机号",24);
				else IList->STextCtlType.SetText("Invalid",24);
				IList->EditCtlNum.SelectedColor = clRed;
				CtlNumValid =0;
			}
			IsSelfCtl = 0;
			if(CtlNum != tVal){
				CtlNum = tVal;
				ClearReqDataState();
				ReDrawCommonInf();
				Check4Selected();
				RealTimeSendCmdAbort();

				NewType = 0;
				if(NewType == dType){
					//Load New Addr Inf
					//Redraw4NewLoad();
					//UpdataOnlineData();
				}else{
					//Load 4 New Type
					dType = NewType;
					Init4DType();
				}
				ResetTargetData();
			}
		}
		IList->EditCtlNum.Show();
		IList->STextCtlType.Show();
	}else
	if(Tag.Inx == 1){
		//Port Num
		IsNewTarget = 0;
		IList->EditPortNum.KeyIn(aKey);
		tVal = IList->EditPortNum.Str.ToInteger();
		if( (tVal >0) && (tVal <= dPORT_MAX_COUNT) )PortNumValid = 1; else PortNumValid = 0;
		if(IsSelfCtl){
			if( PortNumValid && AddrNumValid){
				if(Path0 != tVal){
					ClearReqDataState();
					Path0 = tVal;
					IList->EditPortNum.SelectedColor = clBlue;
					ReDrawCommonInf();
					Check4Selected();
					RealTimeSendCmdAbort();
					tP0 = Path0-1;
					tP1 = Path1-1;
					if(Port[tP0].ExistTable[tP1] == 0xA5){
						NewType = Port[tP0].dTypeTable[tP1];
					}else{
						NewType = 0;
						Init4DType();
					}
					if(NewType == dType){
						//Load New Addr Inf
						Redraw4NewLoad();
						//UpdataOnlineData();
					}else{
						//Load 4 New Type
						dType = NewType;
						Init4DType();
					}
					ResetTargetData();
				}
			}else{
				ClearReqDataState();
				Path0 = 0;
				if(dType != 0){
					dType = 0;
					Init4DType();
				}
				RealTimeSendCmdAbort();
				IList->EditPortNum.SelectedColor = clRed;
				ClearCommonInf();
			}
		}else{
			if( PortNumValid && AddrNumValid){
				if(Path0 != tVal){
					ClearReqDataState();
					Path0 = tVal;
					IList->EditPortNum.SelectedColor = clBlue;
					ReDrawCommonInf();
					Check4Selected();
					RealTimeSendCmdAbort();
					NewType = 0;
					Init4DType();
					if(NewType == dType){
						//Load New Addr Inf
						Redraw4NewLoad();
						//UpdataOnlineData();
					}else{
						//Load 4 New Type
						dType = NewType;
						Init4DType();
					}
					ResetTargetData();
				}
			}else{
				ClearReqDataState();
				Path0 = 0;
				if(dType != 0){
					dType = 0;
					Init4DType();
				}
				RealTimeSendCmdAbort();
				IList->EditPortNum.SelectedColor = clRed;
				ClearCommonInf();
			}
		}
		IList->EditPortNum.Show();
	}else
	if(Tag.Inx == 2){
		//Addr Num
		if(HasPrcKey == 0){
			IsNewTarget = 0;
			IList->EditAddrNum.KeyIn(aKey);
			tVal = IList->EditAddrNum.Str.ToInteger();
			if( (tVal >0) && (tVal <= dEP_MAX_COUNT_PER_PORT) )AddrNumValid = 1; else AddrNumValid = 0;
			if(IsSelfCtl){
				if( PortNumValid && AddrNumValid){
					if(Path1 != tVal){
						ClearReqDataState();
						Path1 = tVal;
						IList->EditAddrNum.SelectedColor = clBlue;
						ReDrawCommonInf();
						Check4Selected();
						RealTimeSendCmdAbort();
						tP0 = Path0-1;
						tP1 = Path1-1;
						if(Port[tP0].ExistTable[tP1] == 0xA5){
							NewType = Port[tP0].dTypeTable[tP1];
						}else{
							NewType = 0;
							Init4DType();
						}
						if(NewType == dType){
							//Load New Addr Inf
							
							Redraw4NewLoad();
							//UpdataOnlineData();
						}else{
							//Load 4 New Type
							dType = NewType;
							Init4DType();
						}
						ResetTargetData();
					}
				}else{
					ClearReqDataState();
					Path1 = 0;
					if(dType != 0){
						dType = 0;
						Init4DType();
					}
					RealTimeSendCmdAbort();
					IList->EditAddrNum.SelectedColor = clRed;
					ClearCommonInf();
				}
			}else{
				if( PortNumValid && AddrNumValid){
					if(Path1 != tVal){
						ClearReqDataState();
						Path1 = tVal;
						IList->EditAddrNum.SelectedColor = clBlue;
						ReDrawCommonInf();
						Check4Selected();
						RealTimeSendCmdAbort();
						NewType = 0;
						Init4DType();
						if(NewType == dType){
							//Load New Addr Inf
							Redraw4NewLoad();
							//UpdataOnlineData();
						}else{
							//Load 4 New Type
							dType = NewType;
							Init4DType();
						}
						ResetTargetData();
					}
				}else{
					ClearReqDataState();
					Path1 = 0;
					if(dType != 0){
						dType = 0;
						Init4DType();
					}
					RealTimeSendCmdAbort();
					IList->EditAddrNum.SelectedColor = clRed;
					ClearCommonInf();
				}
			}
			IList->EditAddrNum.Show();
		}
	}else
	if(Tag.Inx == 3){
		//User Code Here
		IList->EditUserCode.KeyIn(aKey);
		IList->EditUserCode.Show();
	}
	return aMsg;
}

TGuiMsgReturn TDevStartStop::KeyInCommonEnter(unsigned char aKey)
{
	int aVal;
	TGuiMsgReturn aMsg = guiMsgNone;
	if(Tag.Inx == 0){
		//Ctl Num
	}else
	if(Tag.Inx == 1){
		//Port Num
	}else
	if(Tag.Inx == 2){
		//Addr Num
	}else
	if(Tag.Inx == 3){
		//User Code
		unsigned char tP0, tP1;
		int Found =0;
		int x;
		aVal = IList->EditUserCode.Str.ToInteger();
		for(int i=0; i<dPORT_MAX_COUNT; i++){
			if(MainCtl.fData.Split.ExistTablePort[i]){
				if( (aVal >= Port[i].UserCodeMin) && (aVal <= Port[i].UserCodeMax) ){
					for(x=0; x<dEP_MAX_COUNT_PER_PORT; x++){
						if(aVal == Port[i].UcList[x].Full){
							Found =1;
							CtlNum = MainCtl.fData.Split.MyNum;
							Path0 = i +1;
							Path1 = x +1;
							break;
						}
					}
				}
			}
			if(Found )break;
		}
		if(Found){
			unsigned char NewType;
			IList->EditPortNum.Color = clDeepGreen;
			IList->EditAddrNum.Color = clDeepGreen;
			IList->EditUserCode.SelectedColor = clDeepGreen;
			IList->EditPortNum.Show();
			IList->EditAddrNum.Show();
			IList->EditUserCode.Show();
			DelayMs(150);
			IList->EditPortNum.Color = clNearWhite;
			IList->EditAddrNum.Color = clNearWhite;
			IList->EditUserCode.SelectedColor = clBlue;
			IList->EditPortNum.Show();
			IList->EditAddrNum.Show();
			IList->EditUserCode.Show();
			
			CtlNumValid = 1;
			PortNumValid =1;
			AddrNumValid =1;
			
			ClearReqDataState();
			IList->EditCtlNum.Str.FromUInt2Dg(CtlNum);
			IList->EditPortNum.Str.FromUInt2Dg(Path0);
			IList->EditAddrNum.Str.FromUInt3Dg(Path1);
			IList->EditCtlNum.Show();
			IList->EditPortNum.Show();
			IList->EditAddrNum.Show();
			ReDrawCommonInf();
			Check4Selected();
			RealTimeSendCmdAbort();
			tP0 = Path0-1;
			tP1 = Path1-1;
			if(Port[tP0].ExistTable[tP1] == 0xA5){
				NewType = Port[tP0].dTypeTable[tP1];
			}else{
				NewType = 0;
				Init4DType();
			}
			if(NewType == dType){
				//Load New Addr Inf
				Redraw4NewLoad();
				//UpdataOnlineData();
			}else{
				//Load 4 New Type
				dType = NewType;
				Init4DType();
			}
			ResetTargetData();
		}else{
			IList->EditUserCode.SelectedColor = clRed;
			IList->EditUserCode.Show();
			DelayMs(150);
			IList->EditUserCode.SelectedColor = clBlue;
			IList->EditUserCode.Show();
		}
	}else
	if(Tag.Inx == 4){
		//Start
		if(SystemPermission >1){
			if(CtlNumValid && Path0 && Path1 && (Path0 <= dPORT_MAX_COUNT) && (Path1<=dEP_MAX_COUNT_PER_PORT) ){
				SendStartStopCmd(1);
			}
		}else{
			if(CtlNumValid && Path0 && Path1 && (Path0 <= dPORT_MAX_COUNT) && (Path1<=dEP_MAX_COUNT_PER_PORT) ){
				IsPermission = 1;
				PermissionCmd = TDevProperty::pcStart;
				PmsIntervene4Gui.Show4Gui(Lv.Panel.Left + 16, Lv.Panel.Top + 16, Lv.Panel.Width -34, 140, 2);
			}
		}
	}else
	if(Tag.Inx == 5){
		//Stop
		if(SystemPermission >1){
			if(CtlNumValid && Path0 && Path1 && (Path0 <= dPORT_MAX_COUNT) && (Path1<=dEP_MAX_COUNT_PER_PORT) ){
				SendStartStopCmd(0);
			}
		}else{
			if(CtlNumValid && Path0 && Path1 && (Path0 <= dPORT_MAX_COUNT) && (Path1<=dEP_MAX_COUNT_PER_PORT) ){
				IsPermission = 1;
				PermissionCmd = TDevProperty::pcStop;
				PmsIntervene4Gui.Show4Gui(Lv.Panel.Left + 16, Lv.Panel.Top + 16, Lv.Panel.Width -34, 140, 2);
			}
		}
	}
	return aMsg;
}

void TDevStartStop::RedrawSmallPanelData()
{
	if(Lv.Panel.Active)RectFillRender(Lv.PanelSmall.Left, Lv.PanelSmall.Top, Lv.PanelSmall.Right, Lv.PanelSmall.Bottom, SmallPanelColor);
	if(IsSelfCtl){	
		RectFillRender(Lv.PanelSmall.Left + 10, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 10 + 20, Lv.PanelSmall.Top + 6 + 20, clGreen);	
		TMyString::sClear(TextDraw);
		TMyString::sFrom2Dg(RuntimeData.voltage % 100, TextDraw);
		TMyString::sAddOnChar('.', TextDraw);
		TMyString::sAddOn1Dg(0, TextDraw);
		TMyString::sAddOnChar('V', TextDraw);
		TextRender_string24(Lv.PanelSmall.Left + 32, Lv.PanelSmall.Top + 4, clNearWhite, SmallPanelColor, TextDraw);
		if(Port[Path0-1].StateTable[Path1-1] & dEpStateBitStart){
			RectFillRender(Lv.PanelSmall.Left + 120, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 120 + 20, Lv.PanelSmall.Top + 6 + 20, clRed);
			RectFillRender(Lv.PanelSmall.Left + 230, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 230 + 20, Lv.PanelSmall.Top + 6 + 20, clNearWhite);
			if(LanguageEnCn==0){
				TextRender_string24(Lv.PanelSmall.Left + 146, Lv.PanelSmall.Top + 4, clNearWhite, SmallPanelColor, "已启动");
				TextRender_string24(Lv.PanelSmall.Left + 256, Lv.PanelSmall.Top + 4, clNearWhite, SmallPanelColor, "未停止  ");
			}else{
				TextRender_string24(Lv.PanelSmall.Left + 146, Lv.PanelSmall.Top + 4, clNearWhite, SmallPanelColor, "Actived");
				TextRender_string24(Lv.PanelSmall.Left + 256, Lv.PanelSmall.Top + 4, clNearWhite, SmallPanelColor, "Not Stop");
			}
		}else{
			RectFillRender(Lv.PanelSmall.Left + 120, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 120 + 20, Lv.PanelSmall.Top + 6 + 20, clNearWhite );
			RectFillRender(Lv.PanelSmall.Left + 230, Lv.PanelSmall.Top + 6, Lv.PanelSmall.Left + 230 + 20, Lv.PanelSmall.Top + 6 + 20, clRed );
			if(LanguageEnCn==0){
				TextRender_string24(Lv.PanelSmall.Left + 146, Lv.PanelSmall.Top + 4, clNearWhite, SmallPanelColor, "未启动");
				TextRender_string24(Lv.PanelSmall.Left + 256, Lv.PanelSmall.Top + 4, clNearWhite, SmallPanelColor, "已停止");
			}else{
				TextRender_string24(Lv.PanelSmall.Left + 146, Lv.PanelSmall.Top + 4, clNearWhite, SmallPanelColor, "Idle");
				TextRender_string24(Lv.PanelSmall.Left + 256, Lv.PanelSmall.Top + 4, clNearWhite, SmallPanelColor, "Stop");
			}
		}
		unsigned char Num, Num10;
		TMyString::sClear(TextDraw);
		TMyString::sAddOnStr("MAC:", TextDraw);
		for(int i=0; i<6; i++){
			Num = RuntimeData.Mac[i] % 16;
			Num10 = RuntimeData.Mac[i] / 16 % 16;
			TMyString::sAddOnChar(stHexNum[Num10], TextDraw);
			TMyString::sAddOnChar(stHexNum[Num], TextDraw);
			if( (i&0x01) && (i<5) )TMyString::sAddOnChar(' ', TextDraw);
		}
		TextRender_string24(Lv.PanelSmall.Left + 280, Lv.PanelSmall.Top + 36, clNearWhite, SmallPanelColor, TextDraw);
	}else{
		TMyString::sClear(TextDraw);
		if(LanguageEnCn==0)TMyString::sAddOnStr("远程机状态未知,请查阅启动事件窗口", TextDraw);
		else TMyString::sAddOnStr("The net machine status is unknown", TextDraw);
		TextRender_string24(Lv.PanelSmall.Left + 20, Lv.PanelSmall.Top + 6, clNearWhite, SmallPanelColor, TextDraw);
	}
}

void TDevStartStop::DrawVaReadWriteStates()
{
	char *tText;
	if(VaReadWriteSta ==0 ){
		//TextRender_string24(Lv.Grid.Left[3] + 190, Lv.Grid.Top[2] + 6, clNearWhite, 	ItemColor, 	"        ");
		if(LanguageEnCn==0)tText ="        "; else tText="        ";
	}else
	if(VaReadWriteSta == 1){
		//TextRender_string24(Lv.Grid.Left[3] + 190, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, 	"读取成功");
		if(LanguageEnCn==0)tText ="读取成功"; else tText="Read OK ";
	}else 
	if(VaReadWriteSta == 2){
		//TextRender_string24(Lv.Grid.Left[3] + 190, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, 	"读取失败");
		if(LanguageEnCn==0)tText ="读取失败"; else tText="Read Err";
	}else
	if(VaReadWriteSta == 3){
		//TextRender_string24(Lv.Grid.Left[3] + 190, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, 	"保存成功");
		if(LanguageEnCn==0)tText ="保存成功"; else tText="Save OK ";
	}else
	if(VaReadWriteSta == 4){
		//TextRender_string24(Lv.Grid.Left[3] + 190, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, 	"保存失败");
		if(LanguageEnCn==0)tText ="保存失败"; else tText="Save Err";
	}else
	if(VaReadWriteSta == 5){
		//TextRender_string24(Lv.Grid.Left[3] + 190, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, 	"获取中  ");
		if(LanguageEnCn==0)tText ="获取中  "; else tText="Reading ";
	}else
	if(VaReadWriteSta == 6){
		//TextRender_string24(Lv.Grid.Left[3] + 190, Lv.Grid.Top[2] + 6, clNearWhite, ItemColor, 	"写入中  ");
		if(LanguageEnCn==0)tText ="写入中  "; else tText="Writing ";
	}
	TextRender_string24(Lv.Grid.Left[3] + 190, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, tText);
}


void TDevStartStop::DrawVaReadWriteStates(unsigned char aNewState)
{
	VaReadWriteSta = aNewState;
	DrawVaReadWriteStates();
}

void TDevStartStop::Task1000Ms()
{
	char *tText;
	if(IsShow == 0) return;
	if( (IsSelfCtl) and (Path0) and (Path1 ) ){
		if( (Path0 <= dPORT_MAX_COUNT) && (Path1 <= dEP_MAX_COUNT_PER_PORT) ){
			if(IsRegisted){
				const unsigned char tSta = Port[Path0-1].StateTable[Path1-1];
				DrawState(tSta);
			}
		}
	}
	switch(HwDevType){
		case TDevProperty::htNoType:
			
			break;
		case TDevProperty::htSmoker:
			if(SmokerRt.IsWait4ReadSens){
				if(SmokerRt.RecRdy){
					if(SmokerRt.RecCmd == cmQuerySens){
						SmokerRt.RecRdy = 0;
						SmokerRt.IsWait4ReadSens = 0;
						//Add Record Here
						if(ProcessingRt.DataType == 1){
							if(ProcessingRt.dValGot[0] == dSmokeSensGrade_MarkValue[1] )Data.SmokerSens = 1;
							else if(ProcessingRt.dValGot[0] == dSmokeSensGrade_MarkValue[2] )Data.SmokerSens = 2;
							else if(ProcessingRt.dValGot[0] == dSmokeSensGrade_MarkValue[3] )Data.SmokerSens = 3;
							else if(ProcessingRt.dValGot[0] == dSmokeSensGrade_MarkValue[4] )Data.SmokerSens = 4;
							else Data.SmokerSens = 5;
							if(Data.SmokerSens == 1){
								if(LanguageEnCn==0)tText="灵敏  ";
								else tText="Normal";
							}else
							if(Data.SmokerSens == 2){
								if(LanguageEnCn==0)tText="中灵敏";
								else tText="Middle";
							}else
							if(Data.SmokerSens == 3){
								if(LanguageEnCn==0)tText="高灵敏";
								else tText="ExHigh";
							}else
							if(Data.SmokerSens == 4){
								if(LanguageEnCn==0)tText="超灵敏";
								else tText="Ultra";
							}else{
								if(LanguageEnCn==0)tText="未知  ";
								else tText="UnKnown";
							}
							IList->Edit[0].Str.FromStr(tText);
							IList->Edit[0].Show();
							if( (IsHotKeyCheckingPermission == 0) && (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) ){
								if(LanguageEnCn==0)tText="读取成功"; else tText="Read OK ";
								TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, tText); 
							}
						}
					}
					SmokerRt.RecRdy = 0;
				}
				SmokerRt.WaitTick ++;
				if(SmokerRt.WaitTick > 6){
					SmokerRt.IsWait4ReadSens = 0;
					if( (IsHotKeyCheckingPermission == 0) && (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) ){
						if(LanguageEnCn==0)tText="读取失败"; else tText="Read Err";
						TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, tText);
					}
				}
			}
			break;
		case TDevProperty::htTempe:
			if(TempeRt.IsWait4ReadSensType){
				if(TempeRt.RecRdy){
					if(TempeRt.RecCmd == cmQueryStaticData){
						TempeRt.RecRdy = 0;
						TempeRt.IsWait4ReadSensType = 0;
						//Add Record Here
						if(1){
							if(Data.TempeSenType == 1){
								IList->Edit[0].Str.FromStr("A1");
							}else
							if(Data.TempeSenType == 2){
								IList->Edit[0].Str.FromStr("A1R");
							}else
							if(Data.TempeSenType == 3){
								IList->Edit[0].Str.FromStr("A1S");
							}else
							if(Data.TempeSenType == 4){
								IList->Edit[0].Str.FromStr("A2");
							}else
							if(Data.TempeSenType == 5){
								IList->Edit[0].Str.FromStr("A2R");
							}else
							if(Data.TempeSenType == 6){
								IList->Edit[0].Str.FromStr("A2S");
							}else
							if(Data.TempeSenType == 7){
								IList->Edit[0].Str.FromStr("B");
							}else
							if(Data.TempeSenType == 8){
								IList->Edit[0].Str.FromStr("BR");
							}else
							if(Data.TempeSenType == 9){
								IList->Edit[0].Str.FromStr("BS");
							}else{
								if(LanguageEnCn==0)IList->Edit[0].Str.FromStr("未知  ");
								else IList->Edit[0].Str.FromStr("UnKnown");
							}
							IList->Edit[0].Show();
							if( (IsHotKeyCheckingPermission == 0) && (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) ){
								if(LanguageEnCn==0)tText="读取成功"; else tText="Read OK ";
								TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, tText); 
							}
						}			
					}
					TempeRt.RecRdy = 0;
				}
				TempeRt.WaitTick ++;
				if(TempeRt.WaitTick > 6){
					TempeRt.IsWait4ReadSensType = 0;
					if( (IsHotKeyCheckingPermission == 0) && (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) ){
						if(LanguageEnCn==0)tText="读取失败"; else tText="Read Err";
						TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, tText);
					}
				}
			}
			/*if( (Data.GotTempeSensType[0] == 0xF1) && (Data.GotTempeSensType[4] == 0) ){
				if( (Data.GotTempeSensType[1] == Path0) && (Data.GotTempeSensType[2] == Path1) ){
					Data.TempeSenType = Data.GotTempeSensType[3];
						//1～9=A1、A1R、A1S、A2、A2R、A2S、B、BR、BS
					if(Data.TempeSenType == 1){
						IList->Edit[0].Str.FromStr("A1");
					}else
					if(Data.TempeSenType == 2){
						IList->Edit[0].Str.FromStr("A1R");
					}else
					if(Data.TempeSenType == 3){
						IList->Edit[0].Str.FromStr("A1S");
					}else
					if(Data.TempeSenType == 4){
						IList->Edit[0].Str.FromStr("A2");
					}else
					if(Data.TempeSenType == 5){
						IList->Edit[0].Str.FromStr("A2R");
					}else
					if(Data.TempeSenType == 6){
						IList->Edit[0].Str.FromStr("A2S");
					}else
					if(Data.TempeSenType == 7){
						IList->Edit[0].Str.FromStr("B");
					}else
					if(Data.TempeSenType == 8){
						IList->Edit[0].Str.FromStr("BR");
					}else
					if(Data.TempeSenType == 9){
						IList->Edit[0].Str.FromStr("BS");
					}else{
						IList->Edit[0].Str.FromStr("未知  ");
					}
					if( (IsHotKeyCheckingPermission == 0) && (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) ){
						IList->Edit[0].Show();
						TextRender_string24(IList->Edit[0].Bound.Right + 6, IList->Edit[0].Bound.Top + 4, clNearWhite, ItemColor, "读取成功"); 
						Data.GotTempeSensType[4] =1;
					}
				}
			}*/
			break;
		case TDevProperty::htHandPad:
			break;
		case TDevProperty::htHydrantPad:
			break;
		case TDevProperty::htModuleIn:
			/*if(ModuleInRt.IsWait4ReadSignalType){
				if(ModuleInRt.RecRdy){
					if(ModuleInRt.RecCmd == cmQuerySens){
						ModuleInRt.RecRdy = 0;
						ModuleInRt.IsWait4ReadSignalType = 0;
						//Add Record Here
						if(ProcessingRt.DataType == 1){
							Data.ModuleSignalInType = RecData[4];
							RedrawModuleInSignalInType();
							if( (IsHotKeyCheckingPermission == 0) && (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) ){
								TextRender_string24(Lv.Grid.Left[3] + 160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "读取成功"); 
							}else{
								TextRender_string24(Lv.Grid.Left[3] + 160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "读取成功");
							}
						}
					}
					ModuleInRt.RecRdy = 0;
				}
				ModuleInRt.WaitTick ++;
				if(ModuleInRt.WaitTick > 6){
					ModuleInRt.IsWait4ReadSignalType = 0;
					if( (IsHotKeyCheckingPermission == 0) && (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) ){
						TextRender_string24(Lv.Grid.Left[3] + 160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "读取失败");
					}else{
						TextRender_string24(Lv.Grid.Left[3] + 160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "读取失败");
					}
				}
			}*/
			break;
		case TDevProperty::htModuleInOut:
			/*if(ModuleInOutRt.IsWait4ReadSignalType){
				if(ModuleInOutRt.RecRdy){
					if(ModuleInOutRt.RecCmd == cmQuerySens){
						ModuleInOutRt.RecRdy = 0;
						ModuleInOutRt.IsWait4ReadSignalType = 0;
						//Add Record Here
						if(ProcessingRt.DataType == 1){
							Data.ModuleSignalInType = RecData[4];
							RedrawModuleInSignalInType();
							if( (IsHotKeyCheckingPermission == 0) && (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) ){
								TextRender_string24(Lv.Grid.Left[3] + 160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "读取成功");
							}else{
								TextRender_string24(Lv.Grid.Left[3] + 160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "读取成功");
							}								
						}
					}
					ModuleInOutRt.RecRdy = 0;
				}
				ModuleInOutRt.WaitTick ++;
				if(ModuleInOutRt.WaitTick > 6){
					ModuleInOutRt.IsWait4ReadSignalType = 0;
					if( (IsHotKeyCheckingPermission == 0) && (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) ){
						TextRender_string24(Lv.Grid.Left[3] + 160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "读取失败");
					}else{
						TextRender_string24(Lv.Grid.Left[3] + 160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "读取失败");
					}
				}
			}*/
			break;
		case TDevProperty::htModuleOut:
			/*if(ModuleOutRt.IsWait4ReadSignalType){
				if(ModuleOutRt.RecRdy){
					if(ModuleOutRt.RecCmd == cmQuerySens){
						ModuleOutRt.RecRdy = 0;
						ModuleOutRt.IsWait4ReadSignalType = 0;
						//Add Record Here
						if(ProcessingRt.DataType == 1){
							Data.ModuleSignalInType = RecData[4];
							RedrawModuleInSignalInType();
							if( (IsHotKeyCheckingPermission == 0) && (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) ){
								TextRender_string24(Lv.Grid.Left[3] + 160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "读取成功");
							}else{
								TextRender_string24(Lv.Grid.Left[3] + 160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "读取成功");
							}								
						}
					}
					ModuleOutRt.RecRdy = 0;
				}
				ModuleOutRt.WaitTick ++;
				if(ModuleOutRt.WaitTick > 6){
					ModuleOutRt.IsWait4ReadSignalType = 0;
					if( (IsHotKeyCheckingPermission == 0) && (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) ){
						TextRender_string24(Lv.Grid.Left[3] + 160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "读取失败");
					}else{
						TextRender_string24(Lv.Grid.Left[3] + 160, ModuleRectLv3.Top + 4, clNearWhite, ItemColor, "读取失败");
					}
				}
			}*/			
			break;
		case TDevProperty::htVa:
			if(VaRt.IsWait4ReadVaSetting){
				if(VaRt.RecRdy){
					if(VaRt.RecCmd == cmQueryStaticData){
						VaRt.IsWait4ReadVaSetting = 0;	
						if( (IsHotKeyCheckingPermission == 0) && (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) ){
							RedrawVaIs4Linkage();
							RedrawVaSetting();
							DrawVaReadWriteStates(1);
						}else{
							VaReadWriteSta =1;
						}
					}
					VaRt.RecRdy = 0;
				}
				VaRt.WaitTick ++;
				if(VaRt.WaitTick > 6){
					VaRt.IsWait4ReadVaSetting = 0;
					if( (IsHotKeyCheckingPermission == 0) && (IsSelfChecking == 0) && (PmsIntervene.IsShow == 0) ){
						DrawVaReadWriteStates(2);
					}else{
						VaReadWriteSta =2;
					}
				}
			}		
			break;
		case TDevProperty::htDisplayPad:
			break;
		case TDevProperty::htLinkagePowerSuply:
			break;
		default :
			
			break;
	}
	RedrawSmallPanelData();
}

int TDevStartStop::ExtRequst(unsigned char Prm)
{	
	IsShow = 0;
	return 0;
}







