//共用
TcpToMqttJsonCommon.prototype._GetMqttJsonGroupName_ = function()
{
	var Return=new Array();
	var Class = new LoadFile();
	var JSON = Class.ReadFile("./File/IoT_Platform/MqttJsonGroup.json", new Object());
	var Index=Object.keys(JSON);
	for(var i=0; i<Index.length; i++)
	{
		if(JSON[Index[i]]["Name"] != "")
		{
			Return.push(JSON[Index[i]]["Name"]);
		}
	}
	return Return;
}

TcpToMqttJsonCommon.prototype._GetAzureName_ = function()
{
	var Return=new Array();
	var Class = new LoadFile();
	var JSON = Class.ReadFile("./File/IoT_Platform/Microsoft_Azure_Platform.json", new Object());
	var Index=Object.keys(JSON);
	for(var i=0; i<Index.length; i++)
	{
		if(JSON[Index[i]]["Name"] != "")
		{
			Return.push(JSON[Index[i]]["Name"]+" (Azure)");
		}
	}
	return Return;
}

TcpToMqttJsonCommon.prototype._GetConnectionName_ = function()
{
	var Return = new Array();
	var MqttJsonGroupName = TcpToMqttJsonCommon.prototype._GetMqttJsonGroupName_();
	var AzureName = TcpToMqttJsonCommon.prototype._GetAzureName_();
	Return = MqttJsonGroupName.concat(AzureName);
	return Return;
}




















//更新頁
TcpToMqttJsonUpdatePage.prototype._SaveGlobalVariable_ = function(Row)
{
	var Class = new StepFlow();
	Class.LockAllUi();
	var ssocket = io.connect(), Index=0, Length=Row.length;
	Row.eq(Index).find(".Button").click();
	ssocket.emit("BackgroundExecution");
	ssocket.on("BackgroundExecution", function (Return) {
		if(Row.eq(Index).find(".Message").is(":visible") == true && 
		   Row.eq(Index).find(".Message").css("color") == "rgb(34, 119, 0)")//成功
		{
			Index++;
			Row.eq(Index).find(".Button").click();
			ssocket.emit("BackgroundExecution");
			if(Index==Length)
			{
				ssocket.emit("SocketClose");
				TcpToMqttJsonUpdatePage.prototype._ShowFirstPage_();
				Class.UnLockAllUi();
			}
		}
		else if(Index<Length)
		{
			ssocket.emit("BackgroundExecution");
		}
	});
}

TcpToMqttJsonUpdatePage.prototype._IsSaveGlobalVariable_ = function()
{
	var Return=false;
	var Class = new LoadFile();
	var Index = Class.ReadFile("./File/TCP_Module/Index.json", new Array());
	var Module = Class.ReadFile("./File/TCP_Module/Module.json", new Object());
	var Variable = Class.ReadFile("./File/TCP_Module/TcpVariable.json", new Object());
	var Setting = Class.ReadFile("./File/TCP_Module/TcpSetting.json", new Object());
	var MqttJsonGroup = Class.ReadFile("./File/IoT_Platform/MqttJsonGroup.json", new Object());
	var AzurePlatform = Class.ReadFile("./File/IoT_Platform/Microsoft_Azure_Platform.json", new Object());
	if(JSON.stringify(Index)==JSON.stringify(Global_TcpIndex) &&
	   JSON.stringify(Module)==JSON.stringify(Global_TcpModule) &&
	   JSON.stringify(Variable)==JSON.stringify(Global_TcpVariable) &&
	   JSON.stringify(Setting)==JSON.stringify(Global_TcpSetting) &&
	   JSON.stringify(MqttJsonGroup)==JSON.stringify(Global_MqttJsonGroup) &&
	   JSON.stringify(AzurePlatform)==JSON.stringify(Global_AzurePlatform))
	{
		Return=true;
	}
	return Return;
}

TcpToMqttJsonUpdatePage.prototype._ShowFirstPage_ = function()
{
	$("#Main_Center-Content").find(".Body").hide();
	$("#Main_Center-Content").find(".Body").eq(1).show();
	TcpToMqttJsonFirstPage.prototype._Initialization_();
}

TcpToMqttJsonUpdatePage.prototype._Initialization_ = function()
{
	$("#Main_Center-Content").find(".Body").hide();
	$("#Main_Center-Content").find(".Body").eq(0).show();

	if(TcpToMqttJsonUpdatePage.prototype._IsSaveGlobalVariable_() == true)
	{
		TcpToMqttJsonUpdatePage.prototype._ShowFirstPage_();
		return 0;
	}
	var Row = $("#Main_Center-Content").find(".Body").eq(0).find(".Table").find(".Row");
	TcpToMqttJsonUpdatePage.prototype._SaveGlobalVariable_(Row);
}




















//第1頁
TcpToMqttJsonFirstPage.prototype._SetConnectionName_ = function(that)
{
	var number = $(that).closest(".DynamicRow").find(".Column").eq(0).text();
	if(typeof(Global_TcpToMqttJsonVariable[number]) != "object")	{return 0;}
	
	var Button = $(that).closest(".Column").find(".Button");
	var Combobox =  $(that).closest(".Column").find(".Select");
	var SystemVariable = Object.keys(Global_TcpToMqttJsonVariable[number]);
	var object=new Object();
	for(var i=0; i<SystemVariable.length; i++)
	{
		Global_TcpToMqttJsonVariable[number][SystemVariable[i]]["ConnectionGroup"] = Combobox.val();
	}
	Button.attr('disabled', true);
}

TcpToMqttJsonFirstPage.prototype._ChangeConnectionName_ = function(that)
{
	var number = $(that).closest(".DynamicRow").find(".Column").eq(0).text();
	if(typeof(Global_TcpToMqttJsonVariable[number]) != "object")	{return 0;}
	
	var Button = $(that).closest(".Column").find(".Button");
	var Combobox =  $(that).closest(".Column").find(".Select");
	var SystemVariable = Object.keys(Global_TcpToMqttJsonVariable[number]);
	var object=new Object();
	for(var i=0; i<SystemVariable.length; i++)
	{
		var ConnectionGroup=Global_TcpToMqttJsonVariable[number][SystemVariable[i]]["ConnectionGroup"]
		object[ConnectionGroup]=new Object();
	}
	var array=Object.keys(object);
	if(array.length == 1 && array[0] == Combobox.val()){
		Button.attr('disabled', true);
	}
	else{
		Button.attr('disabled', false);
	}
}

TcpToMqttJsonFirstPage.prototype._LoadConnectionName_ = function(index, number)
{
	var Button = $("#ModuleTable").find(".DynamicRow").eq(index).find(".Column").eq(3).find(".Button");
	var Combobox = $("#ModuleTable").find(".DynamicRow").eq(index).find(".Column").eq(3).find(".Select");
	var ConnectionName = TcpToMqttJsonCommon.prototype._GetConnectionName_();
	for(var i=0; i<ConnectionName.length; i++){
		Combobox.append($("<option></option>").attr("value",ConnectionName[i]).text(ConnectionName[i]));
	}
	Combobox.append($("<option></option>").attr("disabled",true).text("(Groups)"));
	Combobox.val("");
	if(typeof(Global_TcpToMqttJsonVariable[number]) !="object"){
		return 0;
	}
	TcpToMqttJsonFirstPage.prototype._ApplyButton_(index, number, Combobox);
}

TcpToMqttJsonFirstPage.prototype._ApplyButton_ = function(index, number, Combobox)
{
	var Button = $("#ModuleTable").find(".DynamicRow").eq(index).find(".Column").eq(3).find(".Button");
	var SystemVariable=Object.keys(Global_TcpToMqttJsonVariable[number]);
	var object=new Object();
	for(var i=0; i<SystemVariable.length; i++){
		var ConnectionGroup=Global_TcpToMqttJsonVariable[number][SystemVariable[i]]["ConnectionGroup"];
		object[ConnectionGroup]=new Object();
	}
	var array=Object.keys(object);
	if(array.length == 1 && array[0] != ""){
		Combobox.val(array[0]);
		Button.attr('disabled', true);
	}
	else if(array.length == 1 && array[0] == ""){
		Combobox.val(array[0]);
		Button.attr('disabled', false);
	}
	else if(array.length >1){
		Combobox.val("(Groups)");
		Button.attr('disabled', true);
	}
}

TcpToMqttJsonFirstPage.prototype._ChangeCheckbox_ = function(that)
{
	var Bool = $(that).closest(".DynamicRow").find(".Column").eq(4).find(":checkbox").prop("checked");
	var number = $(that).closest(".DynamicRow").find(".Column").eq(0).text();
	if(typeof(Global_TcpToMqttJsonVariable[number])!="object"){
		return;
	}
	var SystemVariable = Object.keys(Global_TcpVariable[number]);
	for(var i=0; i<SystemVariable.length; i++)
	{
		Global_TcpToMqttJsonVariable[number][SystemVariable[i]]["TransformMqttJson"] = Bool;
	}
}

TcpToMqttJsonFirstPage.prototype._ChangeAllCheckbox_ = function(that)
{
	var ModuleTableId = $(that).closest(".Table").attr("id");
	var Bool = $(that).closest(".Row").find(":checkbox").prop("checked");
	var Element = $("#"+ModuleTableId).find(".DynamicRow");
	for(var i=0; i<Element.length; i++)
	{
		if(Element.eq(i).find(":checkbox").prop("checked") != Bool)
		{
			Element.eq(i).find(":checkbox").prop("checked",Bool);
			var that = Element.eq(i).find(":checkbox");
			TcpToMqttJsonFirstPage.prototype._ChangeCheckbox_(that);
		}
	}
}

TcpToMqttJsonFirstPage.prototype._IsAllTransformMqttJson_ = function(number)
{
	var Return=false;
	if(typeof(Global_TcpToMqttJsonVariable[number]) != "object")
	{
		return Return;
	}
	var SystemVariable=Object.keys(Global_TcpToMqttJsonVariable[number]);
	if(SystemVariable.length==0)
	{
		return Return;
	}
	for(var i=0; i<SystemVariable.length; i++)
	{
		if(Global_TcpToMqttJsonVariable[number][SystemVariable[i]]["TransformMqttJson"]==false)
		{
			return Return;
		}
	}
	Return=true;
	return Return;
}

TcpToMqttJsonFirstPage.prototype._GetAllModuleData_ = function()
{
	var Return = new Object();
	var DeviceName = Object.keys(Global_TcpModule);
	for(var i=0; i<DeviceName.length; i++)
	{
		var nmuber = Object.keys(Global_TcpModule[DeviceName[i]]);
		for(var j=0; j<nmuber.length; j++)
		{
			Return[nmuber[j]] = new Object();
			Return[nmuber[j]] = jQuery.parseJSON(JSON.stringify(Global_TcpModule[DeviceName[i]][nmuber[j]]));
		}
	}
	return Return;
}

TcpToMqttJsonFirstPage.prototype._GetAllDeviceName_ = function()
{
	var Return=Object.keys(Global_TcpModule);
	return Return;
}

TcpToMqttJsonFirstPage.prototype._GetAllNumber_ = function()
{
	var AllDeviceName = TcpToMqttJsonFirstPage.prototype._GetAllDeviceName_();
	var ObjectKey = new Array();
	for(var i=0; i<AllDeviceName.length; i++)
	{
		if(typeof(Global_TcpModule[AllDeviceName[i]]) == "object")
		{
			ObjectKey = ObjectKey.concat(Object.keys(Global_TcpModule[AllDeviceName[i]]));
		}
	}
	ObjectKey = ObjectKey.sort(function (a, b) {return a - b});
	return ObjectKey;
}

TcpToMqttJsonFirstPage.prototype._ShowTable_ = function(ObjectKey, DisplayNumber)
{
	var AllModuleData = TcpToMqttJsonFirstPage.prototype._GetAllModuleData_();
	$("#ModuleTable").find(".DynamicRow").remove();
	var html = $(".Dynamic").html();
	var PageNumber = $("#ModuleToolbar").find(".Text").val();
	var Start = (PageNumber-1)*DisplayNumber;
	if((ObjectKey.length-Start)>DisplayNumber){
		var End = Start + DisplayNumber;
	}
	else{
		var End = ObjectKey.length;
	}
	var index = 0;
	for(var i=Start; i<End && End!=0; i++)
	{
		$("#ModuleTable").append(html);
		$("#ModuleTable").find(".DynamicRow").eq(index).find(".Column").eq(0).text(ObjectKey[i]);
		$("#ModuleTable").find(".DynamicRow").eq(index).find(".Column").eq(1).text(AllModuleData[ObjectKey[i]]["ModuleName"]);
		TcpToMqttJsonFirstPage.prototype._LoadConnectionName_(index, ObjectKey[i]);
		var Bool = TcpToMqttJsonFirstPage.prototype._IsAllTransformMqttJson_(ObjectKey[i]);
		$("#ModuleTable").find(".DynamicRow").eq(index).find(".Column").eq(4).find(":checkbox").prop("checked",Bool);
		index++;
	}
}

TcpToMqttJsonFirstPage.prototype._UpdateTableToolbar_ = function(ObjectKey, DisplayNumber)
{
	var NumberOfPages = Math.ceil(ObjectKey.length/DisplayNumber);
	var Id = "#ModuleToolbar";
	$(Id).find("label").eq(1).text(NumberOfPages);
	var CurrentlyPage = $(Id).find(".Text").val();
	CurrentlyPage = parseInt(CurrentlyPage);
	if(CurrentlyPage>NumberOfPages)
	{
		$(Id).find(".Text").val(NumberOfPages);
	}
	else if(CurrentlyPage<=0 || isNaN(CurrentlyPage)==true)
	{
		$(Id).find(".Text").val(1);
	}
	else
	{
		$(Id).find(".Text").val(CurrentlyPage);
	}
}

TcpToMqttJsonFirstPage.prototype._RedisplayUi_ = function()
{
	var DisplayNumber = 20;//RTU 20 TCP 40 ASCII 20
	var ObjectKey = TcpToMqttJsonFirstPage.prototype._GetAllNumber_();
	TcpToMqttJsonFirstPage.prototype._UpdateTableToolbar_(ObjectKey, DisplayNumber);
	TcpToMqttJsonFirstPage.prototype._ShowTable_(ObjectKey, DisplayNumber);
	var Id = "#ModuleTable";
	$(Id).find(".Row").eq(0).find(":checkbox").prop("checked",false);
}

TcpToMqttJsonFirstPage.prototype._ShowPreviousPage_ = function()
{
	var Id = "#ModuleToolbar";
	var CurrentlyPage = $(Id).find(".Text").val();
	$(Id).find(".Text").val(parseInt(CurrentlyPage)-1);
	TcpToMqttJsonFirstPage.prototype._RedisplayUi_();
}

TcpToMqttJsonFirstPage.prototype._ShowNextPage_ = function()
{
	var Id = "#ModuleToolbar";
	var CurrentlyPage = $(Id).find(".Text").val();
	$(Id).find(".Text").val(parseInt(CurrentlyPage)+1);
	TcpToMqttJsonFirstPage.prototype._RedisplayUi_();
}

TcpToMqttJsonFirstPage.prototype._Initialization_ = function()
{
	TcpToMqttJsonFirstPage.prototype._RedisplayUi_();
}

TcpToMqttJsonFirstPage.prototype._TransmissionJson_ = function(ssocket, Command, string, Callback)
{
	var Length=20000, index=0;  var array = new Array("Start","");
	ssocket.emit(Command, array);	
	ssocket.on(Command, function (Return) {
		if(Return == "Start" || Return == "Send")
		{
			if(string.length > (index+Length)){
				array = new Array("Send", string.substring(index, index+Length));
			}
			else if(string.length <= (index+Length)){
				array = new Array("End", string.substring(index, string.length));
			}
			index = index + Length;
			ssocket.emit(Command, array);	
		}
		else if(Return == "End")
		{
			Callback();
		}
	});
}

TcpToMqttJsonFirstPage.prototype._SaveFinished_ = function(that, ssocket)
{
	$(that).closest('.Row').find(".Loading").hide();
	$(that).closest('.Row').find(".Message").eq(1).show();
	ssocket.emit("SaveFinished");
	ssocket.on("SaveFinished", function (Return) {
		if(Return == true)
		{
			$(that).closest('.Row').find(".Message").hide();
			$(that).closest('.Row').find(".Message").eq(0).show();
		}
		else
		{
			$(that).closest('.Row').find(".Message").hide();
			$(that).closest('.Row').find(".Message").eq(2).show();
		}
		ssocket.emit("SocketClose");
	});
}

TcpToMqttJsonFirstPage.prototype._SaveStart_ = function(that, ssocket)
{
	ssocket.emit("BackgroundExecution");
	ssocket.on("BackgroundExecution", function (Return) {
	if(Return == true)
	{
		var Callback0 = function(){TcpToMqttJsonFirstPage.prototype._SaveFinished_(that, ssocket);}
		var JsonString = JSON.stringify(Global_TcpToMqttJsonVariable);
		$(that).closest('.Row').find(".Message").hide();
		$(that).closest('.Row').find(".Loading").show();
		TcpToMqttJsonFirstPage.prototype._TransmissionJson_(ssocket, "SaveTcpToMqttJsonVariable", JsonString, Callback0);
	}
	});
}

TcpToMqttJsonFirstPage.prototype._EditButton_ = function(that)
{
	$(that).closest(".Column").find(".Message").show();
	var ssocket = io.connect();
	ssocket.emit("BackgroundExecution");
	ssocket.on("BackgroundExecution", function (Return) {
	if(Return == true)
	{
		$("#Main_Center-Content").find(".Body").eq(2).find(".Message").hide();
		var number = parseInt($(that).closest(".DynamicRow").find(".Column").eq(0).text());
		$("#Main_Center-Content").find(".Body").eq(1).hide();
		TcpToMqttJsonSecondPage.prototype._HideColumn_();
		$("#Main_Center-Content").find(".Body").eq(2).show();
		var Name = $("#Main_Center-Content").find(".Body").eq(2).find(".FormTitle").eq(0).text();
		var Class = new Path();
		Class.LoadPathHtml(Name, 2);
		Class = null;
		TcpToMqttJsonSecondPage.prototype._SetInitialValue_(number);
		$(that).closest(".Column").find(".Message").hide();
	}
	});
}

TcpToMqttJsonFirstPage.prototype._SaveButton_ = function(that)
{
	$(that).closest('.Row').find(".Loading").hide();
	$(that).closest('.Row').find(".Message").hide();
	var ssocket = io.connect();
	TcpToMqttJsonFirstPage.prototype._SaveStart_(that, ssocket);
}




















//第2頁
TcpToMqttJsonSecondPage.prototype._LoadConnectionName_ = function(Index, ConnectionGroup)
{
	var Combobox = $("#VariableTable").find(".DynamicRow").eq(Index).find(".Column").eq(5).find(".Select");
	var ConnectionName = TcpToMqttJsonCommon.prototype._GetConnectionName_();
	for(var i=0; i<ConnectionName.length; i++)
	{
		Combobox.append($("<option></option>").attr("value",ConnectionName[i]).text(ConnectionName[i]));
	}
	Combobox.val(ConnectionGroup);
}

TcpToMqttJsonSecondPage.prototype._VariableTableAddNewRow_ = function(number)
{
	if(typeof(Global_TcpToMqttJsonVariable[number]) != "object")	{return 0;}
	var html="", TempHtml = $("#Main_Center-Content").find(".Body").eq(2).find(".Dynamic").html();
	var SystemVariable = Object.keys(Global_TcpToMqttJsonVariable[number]);
	for(var i=0; i<SystemVariable.length; i++)
	{
		html = html + TempHtml;
	}
	$("#VariableTable").append(html);
}

TcpToMqttJsonSecondPage.prototype._SetVariableTableNewRowValue_ = function(number)
{
	if(typeof(Global_TcpToMqttJsonVariable[number]) != "object")	{return 0;}
	var Variable = Global_TcpVariable[number];
	var Class=new Algorithm();
	var SystemVariable = Object.keys(Global_TcpToMqttJsonVariable[number]).sort(Class.StringNumberMixedSort());
	var Row = $("#VariableTable").find(".DynamicRow");
	for(var i=0; i<SystemVariable.length; i++)
	{
		Row.eq(i).find(".Column").eq(0).text(SystemVariable[i]);
		Row.eq(i).find(".Column").eq(1).find(".Text").val(Variable[SystemVariable[i]]["VariableName"]);
		Row.eq(i).find(".Column").eq(2).find(".Text").val(Global_TcpToMqttJsonVariable[number][SystemVariable[i]]["Alias"]);
		var ReadWriteType = TcpToMqttJsonSecondPage.prototype._GetReadWriteType_(SystemVariable[i].split("-")[0]);
		Row.eq(i).find(".Column").eq(3).find(".Select").val(ReadWriteType);
		Row.eq(i).find(".Column").eq(4).text(SystemVariable[i].split("-")[1]);
		TcpToMqttJsonSecondPage.prototype._LoadConnectionName_(i, Global_TcpToMqttJsonVariable[number][SystemVariable[i]]["ConnectionGroup"]);
		var Bool = Global_TcpToMqttJsonVariable[number][SystemVariable[i]]["TransformMqttJson"];
		Row.eq(i).find(".Column").eq(6).find(".Checkbox").prop("checked",Bool);
	}
}

TcpToMqttJsonSecondPage.prototype._GetModuleName_ = function(number)
{
	var Return="";
	var DeviceName = Object.keys(Global_TcpModule);
	for(var i=0; i<DeviceName.length; i++)
	{
		if(typeof(Global_TcpModule[DeviceName[i]][number]) == "object")
		{
			Return = Global_TcpModule[DeviceName[i]][number]["ModuleName"];
			break;
		}
	}
	return Return;
}

TcpToMqttJsonSecondPage.prototype._ClearTable_ = function(number)
{
	$("#VariableTable").find(".Row").eq(0).find(".Checkbox").prop("checked",false);
	$("#VariableTable").find(".DynamicRow").remove();
}

TcpToMqttJsonSecondPage.prototype._SetVariableTableInitialValue_ = function(number)
{
	TcpToMqttJsonSecondPage.prototype._VariableTableAddNewRow_(number);
	TcpToMqttJsonSecondPage.prototype._SetVariableTableNewRowValue_(number);
}

TcpToMqttJsonSecondPage.prototype._SetFormInitialValue_ = function(number)
{
	var ModuleName=TcpToMqttJsonSecondPage.prototype._GetModuleName_(number);
	var ContentSettings = $("#Main_Center-Content").find(".Body").eq(2).find(".Form").eq(0).find(".Row");
	ContentSettings.eq(0).find(".Text").val(number);
	ContentSettings.eq(1).find(".Text").val(ModuleName);
}

TcpToMqttJsonSecondPage.prototype._SetInitialValue_ = function(number)
{
	TcpToMqttJsonSecondPage.prototype._ClearTable_(number);
	TcpToMqttJsonSecondPage.prototype._SetFormInitialValue_(number);
	TcpToMqttJsonSecondPage.prototype._SetVariableTableInitialValue_(number);
}

TcpToMqttJsonSecondPage.prototype._ModifyTcpToMqttJsonVariableObject_ = function(number)
{
	var Row = $("#VariableTable").find(".DynamicRow");
	for(var i=0; i<Row.length; i++)
	{
		var SystemVariable = Row.eq(i).find(".Column").eq(0).text();
		var Alias = Row.eq(i).find(".Column").eq(2).find(".Text").val();
		var ConnectionGroup = Row.eq(i).find(".Column").eq(5).find(".Select").val();
		if(ConnectionGroup == null)
		{
			ConnectionGroup="";
		};
		var Bool = Row.eq(i).find(":checkbox").prop("checked");
		Global_TcpToMqttJsonVariable[number][SystemVariable]["Alias"] = Alias;
		Global_TcpToMqttJsonVariable[number][SystemVariable]["ConnectionGroup"] = ConnectionGroup;
		Global_TcpToMqttJsonVariable[number][SystemVariable]["TransformMqttJson"] = Bool;
	}
}

TcpToMqttJsonSecondPage.prototype._ConfirmButton_ = function(that)
{
	$(that).closest(".Row").find(".Message").hide();
	var Bool=TcpToMqttJsonSecondPage.prototype._AllDataIsCorrect_();
	if(Bool==false)
	{
		$(that).closest(".Row").find(".Message").show();
		return 0;
	}
	var ContentSettings = $("#Main_Center-Content").find(".Body").eq(2).find(".Form").eq(0).find(".Row");
	var number = parseInt(ContentSettings.eq(0).find(".Text").val());
	TcpToMqttJsonSecondPage.prototype._ModifyTcpToMqttJsonVariableObject_(number);
	$("#Main_Center-Content").find(".Body").eq(2).hide();
	$("#Main_Center-Content").find(".Body").eq(1).show();
	TcpToMqttJsonFirstPage.prototype._RedisplayUi_();
	var Class = new Path();
	Class.LoadPathHtml($("#Left-List-TcpToMqttJson").text(), 1, "main_PathTcpToMqttJson_click(this)");
	Class = null;
}

TcpToMqttJsonSecondPage.prototype._NoConfirmButton_ = function()
{
	$("#Main_Center-Content").find(".Body").eq(2).hide();
	$("#Main_Center-Content").find(".Body").eq(1).show();
	var Class = new Path();
	Class.LoadPathHtml($("#Left-List-TcpToMqttJson").text(), 1, "main_PathTcpToMqttJson_click(this)");
	Class = null;
}

TcpToMqttJsonSecondPage.prototype._ShowColumn_ = function()
{
	$("#VariableTable").find(".Row").find(".TitleColumn").eq(3).show();
	$("#VariableTable").find(".Row").find(".TitleColumn").eq(4).show();
	var DynamicRow = $("#VariableTable").find(".DynamicRow");
	for(var i=0; i<DynamicRow.length; i++)
	{
		DynamicRow.eq(i).find(".Column").eq(3).show();
		DynamicRow.eq(i).find(".Column").eq(4).show();
	}
}

TcpToMqttJsonSecondPage.prototype._HideColumn_ = function()
{
	$("#VariableTable").find(".Row").find(".TitleColumn").eq(3).hide();
	$("#VariableTable").find(".Row").find(".TitleColumn").eq(4).hide();
	var DynamicRow = $("#VariableTable").find(".DynamicRow");
	for(var i=0; i<DynamicRow.length; i++)
	{
		DynamicRow.eq(i).find(".Column").eq(3).hide();
		DynamicRow.eq(i).find(".Column").eq(4).hide();
	}
}

TcpToMqttJsonSecondPage.prototype._GetReadWriteType_ = function(string)
{
	var Return;
	if(string == "DO")			{Return = "ReadWrite";}
	else if(string == "DI")		{Return = "Read";}
	else if(string == "AO")		{Return = "ReadWrite";}
	else if(string == "AI")		{Return = "Read";}
	return Return;
}

TcpToMqttJsonSecondPage.prototype._AllDataIsCorrect_ = function()
{
	var Return = true;
	var length = $("#VariableTable").find(".DynamicRow").length;
	for(var i=0; i<length; i++)
	{
		var ShowMessage = $("#VariableTable").find(".DynamicRow").eq(i).find(".Message").eq(0).is(":visible");
		if(ShowMessage == true)
		{
			Return = false;
		}
	}
	return Return;
}

TcpToMqttJsonSecondPage.prototype._CheckAlias_ = function(that)
{
	$(that).closest(".Column").find(".Message").hide();
	var Name = $(that).closest(".Column").find(".Text").val();
	var Class = new Type();
	if(Name == "")
	{
		$(that).closest(".Column").find(".Message").show();
	}
	else if(Class.CheckSpecialSymbols(Name) == true)
	{
		$(that).closest(".Column").find(".Message").show();
	}
	else if(Class.CheckChineseLanguage(Name) == true)
	{
		$(that).closest(".Column").find(".Message").show();
	}
	Class = null;
}