//更新頁
PidOperationUpdatePage.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");
				PidOperationUpdatePage.prototype._ShowFirstPage_();
				Class.UnLockAllUi();
			}
		}
		else if(Index<Length)
		{
			ssocket.emit("BackgroundExecution");
		}
	});
}

PidOperationUpdatePage.prototype._IsSaveGlobalVariable_ = function()
{
	var Return=false;
	var Class = new Judgment();
	if(Class.IsSaveRtuMasterModuleGlobalVariable() == true &&
	   Class.IsSaveTcpMasterModuleGlobalVariable() == true &&
	   Class.IsSaveAsciiMasterModuleGlobalVariable() == true)
	{
		Return=true;
	}
	return Return;
}

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

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

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




















//第1頁
PidOperationFirstPage.prototype._AutomaticPidName_ = function()
{
	var Table = $("#Main_Center-Content").find(".Body").eq(1).find(".Table").eq(0);
	var Index = 1;
	var object = jQuery.parseJSON(JSON.stringify(Global_PidOperation));
	var number = Object.keys(object);
	var Name, NameArray=new Array();
	for(var i=0; i<number.length; i++)
	{
		NameArray.push(object[number[i]]["Name"]);
	}
	while(true)
	{
		Name = "Task"+Index;
		if(NameArray.indexOf(Name) == -1)
		{
			break;
		}
		Index++;
	}
	Table.find(".Row").eq(1).find(".Text").val(Name);
}

PidOperationFirstPage.prototype._BuildPidOperationObject_ = function(that)
{
	var number = Object.keys(Global_PidOperation);
	if(number.length == 0){
		number=1;
	}
	else if(number.length>0){
		number = Math.max.apply(null,number)+1;
	}
	if(typeof(Global_PidOperation[number]) == "undefined")
	{
		Global_PidOperation[number] = new Object();
		Global_PidOperation[number]["Name"] = $(that).closest(".Row").find(".Column").eq(2).find(".Text").val();
		Global_PidOperation[number]["InputModuleVariableIndex"] = "//";
		Global_PidOperation[number]["OutputModuleVariableIndex"] = "//";
		Global_PidOperation[number]["AutoTune"] = true;
		Global_PidOperation[number]["SampleTime"] = 500;
		Global_PidOperation[number]["SetValue"] = 0;
		Global_PidOperation[number]["ControllerMode"] = "DIRECT";
		Global_PidOperation[number]["Kp"] = 1;
		Global_PidOperation[number]["Ki"] = 1;
		Global_PidOperation[number]["Kd"] = 1;
		Global_PidOperation[number]["Max"] = 0;
		Global_PidOperation[number]["Min"] = 0;
	}
}

PidOperationFirstPage.prototype._ShowTable_ = function(number, DisplayNumber)
{
	var TableId="#PidTable";
	var GlobalVariable=Global_PidOperation;
	$(TableId).find(".DynamicRow").remove();
	var html = $(".Dynamic").html();
	var PageNumber = $("#Toolbar").find(".Text").val();
	var Start = (PageNumber-1)*DisplayNumber;
	if((number.length-Start)>DisplayNumber){
		var End = Start + DisplayNumber;
	}
	else{
		var End = number.length;
	}
	var index = 0;
	for(var i=Start; i<End && End!=0; i++)
	{
		$(TableId).append(html);
		$(TableId).find(".DynamicRow").eq(index).find(".Column").eq(0).text(number[i]);
		$(TableId).find(".DynamicRow").eq(index).find(".Column").eq(2).text(GlobalVariable[number[i]]["Name"]);
		index++;
	}
}

PidOperationFirstPage.prototype._UpdateTableToolbar_ = function(number, DisplayNumber)
{
	var NumberOfPages = Math.ceil(number.length/DisplayNumber);
	var Id = "#Toolbar";
	$(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);
	}
}

PidOperationFirstPage.prototype._RedisplayUi_ = function()
{
	var GlobalVariable=Global_PidOperation;
	var DisplayNumber = 10;
	var number = Object.keys(GlobalVariable);
	PidOperationFirstPage.prototype._UpdateTableToolbar_(number, DisplayNumber);
	PidOperationFirstPage.prototype._ShowTable_(number, DisplayNumber);
	var Table=$("#Main_Center-Content").find(".Body").eq(1).find(".Table").eq(0);
	Table.find(".Row").eq(0).find(":checkbox").prop("checked",false);
}

PidOperationFirstPage.prototype._AddNewRow_ = function(that)
{
	PidOperationFirstPage.prototype._CheckPidName_();
	var Id = "#PidTable";
	var ShowErrorMessage = $(Id).find(".Row").eq(0).find(".Message").is(":visible");
	if(ShowErrorMessage == true)	{return 0;}
	PidOperationFirstPage.prototype._BuildPidOperationObject_(that);
	PidOperationFirstPage.prototype._RedisplayUi_();
	PidOperationFirstPage.prototype._AutomaticPidName_();
}

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

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

PidOperationFirstPage.prototype._RemoveGlobalVariable_ = function(number)
{
	var AzureName = Global_PidOperation[number]["Name"];
	Global_PidOperation[number] = null;	delete Global_PidOperation[number];
}

PidOperationFirstPage.prototype._RemoveTickedPid_ = function()
{
	var Id = "#PidTable";
	var element = $(Id).find(".DynamicRow").find(":checked");
	var CheckedLength = element.length;
	for(var i=0; i<CheckedLength; i++)
	{
		var number = element.eq(i).closest(".DynamicRow").find(".Column").eq(0).text();
		PidOperationFirstPage.prototype._RemoveGlobalVariable_(number);
	}
}

PidOperationFirstPage.prototype._DeletePid_ = function()
{
	PidOperationFirstPage.prototype._RemoveTickedPid_();
	PidOperationFirstPage.prototype._RedisplayUi_();
}

PidOperationFirstPage.prototype._IsNameRepeat_ = function(Name)
{
	var GlobalVariable=Global_PidOperation;
	var Return=false;
	var Row = $("#Main_Center-Content").find(".Body").eq(1).find(".Form").eq(0).find(".Row");
	var CurrentlyNumber = Row.eq(0).find(".Text").val();
	var number = Object.keys(GlobalVariable);
	for(var i=0; i<number.length; i++)
	{
		if(Name == GlobalVariable[number[i]]["Name"])
		{
			Return=true;
			break;
		}
	}
	return Return;
}

PidOperationFirstPage.prototype._IsTickedPid_ = function()
{
	var Return=false;
	var Id = "#PidTable";
	if($(Id).find(".DynamicRow").find(":checked").length >0)
	{
		Return=true;
	}
	return Return;
}

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

PidOperationFirstPage.prototype._CheckPidName_ = function()
{
	var Id = "#PidTable";
	$(Id).find(".Message").hide();
	var Row=$(Id).find(".Row");
	var Name = Row.eq(1).find(".Text").val();
	var Class = new Type();
	if(Class.EnglishDigitalAndBottomline(Name) == false)
	{
		Row.eq(0).find(".Message").eq(0).show();
	}
	Class = null;
	if(PidOperationFirstPage.prototype._IsNameRepeat_(Name) == true)
	{
		Row.eq(0).find(".Message").eq(1).show();
	}
}

PidOperationFirstPage.prototype._SaveStart_ = function(that, ssocket)
{
	ssocket.emit("BackgroundExecution");
	ssocket.on("BackgroundExecution", function (Return) {
	if(Return == true)
	{
		var Callback0 = function(){PidOperationFirstPage.prototype._SaveFinished_(that, ssocket);}

		var JsonString0 = JSON.stringify(Global_PidOperation);

		$(that).closest('.Row').find(".Message").hide();
		$(that).closest('.Row').find(".Loading").show();
		var Class=new Transmission();
		Class.TransmissionJson(ssocket, "SavePidOperationVariable", JsonString0, Callback0);
		Class=null;
	}
	});
}

PidOperationFirstPage.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");
	});
}

PidOperationFirstPage.prototype._EditButton_ = function(that)
{
	$("#Main_Center-Content").find(".Body").eq(2).find(".Message").hide();
	var number = $(that).closest(".DynamicRow").find(".Column").eq(0).text();
	$("#Main_Center-Content").find(".Body").eq(1).hide();
	$("#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;
	PidOperationSecondPage.prototype._Initialization_(number);
}

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



















//第2頁
PidOperationSecondPage.prototype._GetModuleName_ = function(ModuleType, ModuleNumber)
{
	var Return="";
	var ModuleVariable=PidOperationSecondPage.prototype._GetModuleVariable_(ModuleType);
	var Class=new GetValue();
	var Return=Class.GetModuleName(ModuleVariable, ModuleNumber);
	Class=null;
	return Return;
}

PidOperationSecondPage.prototype._GetVariableName_ = function(ModuleType, ModuleNumber, VariableIndex)
{
	var Return="";
	var GlobalVariable=PidOperationSecondPage.prototype._GetGlobalVariable_(ModuleType);
	var Class=new GetValue();
	if(ModuleType == "MRTU Scaling" || ModuleType == "MTCP Scaling")
	{
		var Return=PidOperationSecondPage.prototype._GetModuleScalingVariableName_(GlobalVariable, ModuleNumber, VariableIndex)
	}
	else
	{
		var Return=Class.GetModuleVariableName(GlobalVariable, ModuleNumber, VariableIndex);
	}
	Class=null;
	return Return;
}

PidOperationSecondPage.prototype._GetModuleVariable_ = function(Module)
{
	var Return;
	if(Module=="MRTU" || Module=="MRTU Scaling")			{Return=Global_RtuModule;}
	else if(Module=="MTCP"|| Module=="MTCP Scaling")		{Return=Global_TcpModule;}
	else if(Module=="MASCII"|| Module=="MASCII Scaling")	{Return=Global_AsciiModule;}
	return Return;
}

PidOperationSecondPage.prototype._GetGlobalVariable_ = function(Module)
{	
	var Return;
	if(Module=="MRTU")			{Return=Global_RtuVariable;}
	else if(Module=="MTCP")		{Return=Global_TcpVariable;}
	else if(Module=="MASCII")	{Return=Global_AsciiVariable;}
	else if(Module=="MRTU Scaling")	{Return=Global_RtuScalingVariable;}
	else if(Module=="MTCP Scaling")	{Return=Global_TcpScalingVariable;}
	return Return;
}

PidOperationSecondPage.prototype._GetVariableIndexPrefixWord_ = function(that)
{
	var Return="";
	var VariableAttribute=$(that).closest(".Form").find(".Row").eq(1).find("table").find("tr").eq(0).find("Select").val();
	var VariableType=$(that).closest(".Form").find(".Row").eq(1).find("table").find("tr").eq(1).find("Select").val();

	var Class=new GetValue();
	var DIO_AIO=Class.GetModuleVariableAttribute(VariableAttribute, VariableType);
	Return=DIO_AIO+"-"+VariableType+"-";
	Class=null;
	return Return;
}

PidOperationSecondPage.prototype._SetOtherFormValue_ = function(number)
{
	var Variable=Global_PidOperation;
	var Form=$("#Main_Center-Content").find(".Body").eq(2).find(".Form");
	var PidName=Variable[number]["Name"];
	Form.eq(0).find(".Row").eq(0).find(".Text").val(number);
	Form.eq(0).find(".Row").eq(1).find(".Text").val(PidName);
}

PidOperationSecondPage.prototype._SetInputFormValue_ = function(number)
{
	var Variable=Global_PidOperation;
	var Form=$("#Main_Center-Content").find(".Body").eq(2).find(".Form");
	var ModuleVariableIndex = Variable[number]["InputModuleVariableIndex"];
	var array=ModuleVariableIndex.split("/");
	if(array[0] == "MRTU Scaling" || array[0] == "MTCP Scaling")
	{
		array[2] = array[2].split(/[-.]/);
		array[2] = array[2][0] + "-Float-" + array[2][2];
	}
	Form.eq(1).find(".Row").eq(0).find("tr").eq(0).find(".Select").val(array[0]);
	Form.eq(1).find(".Row").eq(0).find("tr").eq(1).find(".Select").val(array[1]);
	var ModuleName=PidOperationSecondPage.prototype._GetModuleName_(array[0], array[1]);
	Form.eq(1).find(".Row").eq(0).find("tr").eq(2).find(".Text").val(ModuleName);

	var Class=new GetValue();
	var ReadWrite=Class.GetModuleVariableReadWrite(array[2].split("-")[0]);
	Form.eq(1).find(".Row").eq(1).find("tr").eq(0).find(".Select").val(ReadWrite);
	Form.eq(1).find(".Row").eq(1).find("tr").eq(1).find(".Select").val(array[2].split("-")[1]);
	var VariableName=PidOperationSecondPage.prototype._GetVariableName_(array[0], array[1], array[2]);
	Form.eq(1).find(".Row").eq(1).find("tr").eq(2).find(".Select").val(VariableName);
	Class=null;
	Form.eq(1).find(".Row").eq(2).find(":checkbox").attr("checked", Variable[number]["AutoTune"]);
	Form.eq(1).find(".Row").eq(3).find(".Text").val(Variable[number]["SampleTime"]);
	Form.eq(1).find(".Row").eq(4).find(".Text").val(Variable[number]["SetValue"]);
	Form.eq(1).find(".Row").eq(5).find(".Select").val(Variable[number]["ControllerMode"]);
	Form.eq(1).find(".Row").eq(6).find(".Text").val(Variable[number]["Kp"]);
	Form.eq(1).find(".Row").eq(7).find(".Text").val(Variable[number]["Ki"]);
	Form.eq(1).find(".Row").eq(8).find(".Text").val(Variable[number]["Kd"]);
}

PidOperationSecondPage.prototype._SetOutputFormValue_ = function(number)
{
	var Variable=Global_PidOperation;
	var Form=$("#Main_Center-Content").find(".Body").eq(2).find(".Form");
	var ModuleVariableIndex = Variable[number]["OutputModuleVariableIndex"];
	var array=ModuleVariableIndex.split("/");
	if(array[0] == "MRTU Scaling" || array[0] == "MTCP Scaling")
	{
		array[2] = array[2].split(/[-.]/);
		array[2] = array[2][0] + "-Float-" + array[2][2];
	}
	Form.eq(2).find(".Row").eq(0).find("tr").eq(0).find(".Select").val(array[0]);
	Form.eq(2).find(".Row").eq(0).find("tr").eq(1).find(".Select").val(array[1]);
		
	var ModuleName=PidOperationSecondPage.prototype._GetModuleName_(array[0], array[1]);
	Form.eq(2).find(".Row").eq(0).find("tr").eq(2).find(".Text").val(ModuleName);

	var Class=new GetValue();
	var ReadWrite=Class.GetModuleVariableReadWrite(array[2].split("-")[0]);
	Form.eq(2).find(".Row").eq(1).find("tr").eq(0).find(".Select").val(ReadWrite);
	Form.eq(2).find(".Row").eq(1).find("tr").eq(1).find(".Select").val(array[2].split("-")[1]);
	var VariableName=PidOperationSecondPage.prototype._GetVariableName_(array[0], array[1], array[2]);
	Form.eq(2).find(".Row").eq(1).find("tr").eq(2).find(".Select").val(VariableName);
	Class=null;
	Form.eq(2).find(".Row").eq(2).find(".Text").val(Variable[number]["Max"]);
	Form.eq(2).find(".Row").eq(3).find(".Text").val(Variable[number]["Min"]);
}

PidOperationSecondPage.prototype._HideErrorMessage_ = function()
{
	var Body=$("#Main_Center-Content").find(".Body").eq(2);
	var Form=Body.find(".Form");
	Form.eq(1).find(".Message").hide();
	Form.eq(2).find(".Message").hide();
}

PidOperationSecondPage.prototype._Initialization_ = function(number)
{
	PidOperationSecondPage.prototype._HideErrorMessage_();
	PidOperationSecondPage.prototype._LoadModuleType_();
	
	PidOperationSecondPage.prototype._SetOtherFormValue_(number);
	
	PidOperationSecondPage.prototype._LoadInputData_(number);
	PidOperationSecondPage.prototype._SetInputFormValue_(number);

	PidOperationSecondPage.prototype._CheckAutoTune_();

	PidOperationSecondPage.prototype._LoadOutputData_(number);
	PidOperationSecondPage.prototype._SetOutputFormValue_(number);
	
//	PidOperationSecondPage.prototype._SelectModuleType_();
	
	PidOperationSecondPage.prototype._ShowInputErrorMessage_();
	PidOperationSecondPage.prototype._ShowOutputErrorMessage_();
}

PidOperationSecondPage.prototype._LoadInputData_ = function(number)
{
	var InputModuleVariableIndex=Global_PidOperation[number]["InputModuleVariableIndex"];
	var InputModuleType=InputModuleVariableIndex.split("/")[0];
	var InputModuleNumber=InputModuleVariableIndex.split("/")[1];
	var InputVariableIndex=InputModuleVariableIndex.split("/")[2];
	var InputModuleSelect=$("#Main_Center-Content").find(".Body").eq(2).find(".Form").eq(1).find(".Row").eq(0).find("table").find("tr").eq(0).find(".Select");
	PidOperationSecondPage.prototype._LoadModuleNumber_(InputModuleType, InputModuleSelect);
	PidOperationSecondPage.prototype._LoadInputVariableAttribute_(InputModuleType);
	PidOperationSecondPage.prototype._LoadVariableType_(InputModuleType, InputModuleSelect);
	PidOperationSecondPage.prototype._LoadVariableName_(InputModuleType, InputModuleNumber, InputVariableIndex, InputModuleSelect);
}

PidOperationSecondPage.prototype._LoadOutputData_ = function(number)
{
	var OutputModuleVariableIndex=Global_PidOperation[number]["OutputModuleVariableIndex"];
	var OutputModuleType=OutputModuleVariableIndex.split("/")[0];
	var OutputModuleNumber=OutputModuleVariableIndex.split("/")[1];
	var OutputVariableIndex=OutputModuleVariableIndex.split("/")[2];
	var OutputModuleSelect=$("#Main_Center-Content").find(".Body").eq(2).find(".Form").eq(2).find(".Row").eq(0).find("table").find("tr").eq(0).find(".Select");
	PidOperationSecondPage.prototype._LoadModuleNumber_(OutputModuleType, OutputModuleSelect);
	PidOperationSecondPage.prototype._LoadOutputVariableAttribute_(OutputModuleType);
	PidOperationSecondPage.prototype._LoadVariableType_(OutputModuleType, OutputModuleSelect);
	PidOperationSecondPage.prototype._LoadVariableName_(OutputModuleType, OutputModuleNumber, OutputVariableIndex, OutputModuleSelect);
}

PidOperationSecondPage.prototype._LoadModuleType_ = function()
{
	var Class=new LoadFile();
	var ModuleType = Class.ReadFile("./File/PID_Operation/ModuleType.json");
	var Value = ModuleType["Value"];
	var Text = ModuleType["Text"];
	var InputForm = $("#Main_Center-Content").find(".Body").eq(2).find(".Form").eq(1);
	var OutputForm = $("#Main_Center-Content").find(".Body").eq(2).find(".Form").eq(2);
	var InputSelect = InputForm.find(".Row").eq(0).find("table").find("tr").eq(0).find(".Select");
	var OutputSelect = OutputForm.find(".Row").eq(0).find("table").find("tr").eq(0).find(".Select");
	InputSelect.empty();
	OutputSelect.empty();
	for(var i=0; i<Value.length; i++)
	{
		InputSelect.append($("<option></option>").attr("value",Value[i]).text(Text[i]));
		OutputSelect.append($("<option></option>").attr("value",Value[i]).text(Text[i]));
	}
}

PidOperationSecondPage.prototype._LoadModuleNumber_ = function(ModuleType, that)
{
	var ModuleVariable=PidOperationSecondPage.prototype._GetModuleVariable_(ModuleType);
	var Class=new GetValue();
	var ModuleNumber=Class.GetModuleAllNumber(ModuleVariable);

	var Tr=$(that).closest(".Form").find(".Row").eq(0).find("table").find("tr");
	var Select = Tr.eq(1).find(".Select");
	Select.empty();
	if(ModuleNumber.length == 0)
	{
		return 0;
	}
	for(var i=0; i<ModuleNumber.length; i++)
	{
		Select.append($("<option></option>").attr("value",ModuleNumber[i]).text(ModuleNumber[i]));
	}
	Class=null;
}

PidOperationSecondPage.prototype._LoadInputVariableAttribute_ = function(ModuleType)
{
	var Class=new LoadFile();
	var VariableAttribute=Class.ReadTranslateAfterOfFileJson("./File/PID_Operation/InputVariableAttribute.json");

	var InputForm = $("#Main_Center-Content").find(".Body").eq(2).find(".Form").eq(1);
	if(ModuleType =="")
	{
		ModuleType=InputForm.find(".Row").eq(0).find("tr").eq(0).find(".Select").val();
	}
	var Value=VariableAttribute[ModuleType]["Value"];
	var Text=VariableAttribute[ModuleType]["Text"];
	var InputSelect = InputForm.find(".Row").eq(1).find("table").find("tr").eq(0).find(".Select");
	InputSelect.empty();
	for(var i=0; i<Value.length; i++)
	{
		InputSelect.append($("<option></option>").attr("value",Value[i]).text(Text[i]));
	}
}

PidOperationSecondPage.prototype._LoadOutputVariableAttribute_ = function(ModuleType)
{
	var Class=new LoadFile();
	var VariableAttribute=Class.ReadTranslateAfterOfFileJson("./File/PID_Operation/OutputVariableAttribute.json");
	
	var OutputForm = $("#Main_Center-Content").find(".Body").eq(2).find(".Form").eq(2);
	if(ModuleType =="")
	{
		ModuleType=OutputForm.find(".Row").eq(0).find("tr").eq(0).find(".Select").val();
	}
	var Value=VariableAttribute[ModuleType]["Value"];
	var Text=VariableAttribute[ModuleType]["Text"];
	var OutputSelect = OutputForm.find(".Row").eq(1).find("table").find("tr").eq(0).find(".Select");
	OutputSelect.empty();
	for(var i=0; i<Value.length; i++)
	{
		OutputSelect.append($("<option></option>").attr("value",Value[i]).text(Text[i]));
	}
}

PidOperationSecondPage.prototype._LoadVariableType_ = function(ModuleType, that)
{
	var Class=new LoadFile();
	var VariableType = Class.ReadFile("./File/PID_Operation/VariableType.json");
	
	if(typeof(VariableType[ModuleType]) != "object")	{return 0;}
	
	var Value = VariableType[ModuleType]["Value"];
	var Text = VariableType[ModuleType]["Text"];
	
	var Tr=$(that).closest(".Form").find(".Row").eq(1).find("table").find("tr");
	var Select = Tr.eq(1).find(".Select");
	Select.empty();
	for(var i=0; i<Value.length; i++)
	{
		Select.append($("<option></option>").attr("value",Value[i]).text(Text[i]));
	}
}

PidOperationSecondPage.prototype._LoadVariableName_ = function(ModuleType, ModuleNumber, VariableIndex, that)
{
	if(ModuleType == "MRTU Scaling" || ModuleType == "MTCP Scaling")
	{
		PidOperationSecondPage.prototype._ScalingLoadVariableName_(ModuleType, ModuleNumber, VariableIndex, that);
	}
	else
	{
		var ModuleVariable=PidOperationSecondPage.prototype._GetGlobalVariable_(ModuleType);
		var Class=new GetValue();
		var Variable=Class.GetModuleVariableNameArray(ModuleVariable, ModuleNumber, VariableIndex);

		var Tr=$(that).closest(".Form").find(".Row").eq(1).find("table").find("tr");
		var Select = Tr.eq(2).find(".Select");
		Select.empty();
		for(var i=0; i<Variable.length; i++)
		{
			Select.append($("<option></option>").attr("value",Variable[i]).text(Variable[i]));
		}
	}
}
PidOperationSecondPage.prototype._ScalingLoadVariableName_ = function(ModuleType, ModuleNumber, VariableIndex, that)
{
	var ScalingModuleVariable=PidOperationSecondPage.prototype._GetGlobalVariable_(ModuleType);
	var Variable=PidOperationSecondPage.prototype._GetModuleScalingVariableNameArray_(ScalingModuleVariable, ModuleNumber, VariableIndex);

	var Tr=$(that).closest(".Form").find(".Row").eq(1).find("table").find("tr");
	var Select = Tr.eq(2).find(".Select");
	Select.empty();
	for(var i=0; i<Variable.length; i++)
	{
		Select.append($("<option></option>").attr("value",Variable[i]).text(Variable[i]));
	}
}
PidOperationSecondPage.prototype._GetModuleScalingVariableNameArray_ = function(GlobalVariable, ModuleNumber, VariableIndex)
{
	var Return=new Array();
	if(typeof(GlobalVariable) != "object" || 
	   typeof(GlobalVariable[ModuleNumber]) != "object")
	{
		return Return;
	}
	var array=VariableIndex.split("-");
	if(array.length != 3)
	{
		return Return;
	}
	VariableIndex=array[0]+"-Float-";
	var VariableList=Object.keys(GlobalVariable[ModuleNumber]);
	var ScalingVariableList = VariableList.slice();
	
	for(var i=0; i<ScalingVariableList.length; i++)
	{
		var ScalingArray=ScalingVariableList[i].split("-");
		ScalingVariableList[i] = ScalingArray[0]+"-Float-" + ScalingArray[2];
	}
	
	for(var i=0; i<VariableList.length; i++)
	{
		if(ScalingVariableList[i].indexOf(VariableIndex) != -1)
		if(GlobalVariable[ModuleNumber][VariableList[i]]["TransformScaling"] == true)
		{
			Return.push(GlobalVariable[ModuleNumber][VariableList[i]]["ScaleVariableName"]);
		}
	}
	return Return;
};
PidOperationSecondPage.prototype._GetModuleScalingVariableName_ = function(GlobalVariable, ModuleNumber, VariableIndex)
{
	var Return="";
	var array=VariableIndex.split("-");
	if(array.length != 3)
	{
		return Return;
	}
	var VariableList=Object.keys(GlobalVariable[ModuleNumber]);
	var ScalingVariableList = VariableList.slice();
	for(var i=0; i<ScalingVariableList.length; i++)
	{
		var ScalingArray=ScalingVariableList[i].split("-");
		ScalingVariableList[i] = ScalingArray[0]+"-Float-" + ScalingArray[2];
	}
	for(var i=0; i<VariableList.length; i++)
	{
		if(ScalingVariableList[i].indexOf(VariableIndex) != -1)
		if(GlobalVariable[ModuleNumber][VariableList[i]]["TransformScaling"] == true)
		{
			Return=GlobalVariable[ModuleNumber][VariableList[i]]["ScaleVariableName"];
		}
	}
	/*var VariableList=Object.keys(GlobalVariable[ModuleNumber]);
	for(var i=0; i<VariableList.length; i++)
	{
		if(VariableList[i].indexOf(VariableIndex) != -1)
		{
			Return=GlobalVariable[ModuleNumber][VariableList[i]]["ScaleVariableName"];
			break;
		}
	}*/
	return Return;
};

PidOperationSecondPage.prototype._GetScalingGlobalVariable_ = function(Module)
{	
	var Return;
	if(Module=="MRTU")			{Return=Global_RtuScalingVariable;}
	else if(Module=="MTCP")		{Return=Global_TcpScalingVariable;}
	//else if(Module=="MASCII")	{Return=Global_AsciiVariable;}
	return Return;
}
PidOperationSecondPage.prototype._LoadModuleName_ = function(ModuleType, that)
{
	var ModuleVariable=PidOperationSecondPage.prototype._GetModuleVariable_(ModuleType);
	var Select=$(that).closest("table").find("tr").eq(1).find(".Select");
	var ModuleNumber=Select.val();
	var Class=new GetValue();
	var ModuleName=Class.GetModuleName(ModuleVariable, ModuleNumber);
	
	var Text = $(that).closest("table").find("tr").eq(2).find(".Text");
	Text.val(ModuleName);
	Class=null;
}

PidOperationSecondPage.prototype._ShowInputErrorMessage_ = function()
{
	var Form=$("#Main_Center-Content").find(".Body").eq(2).find(".Form");
	var ModuleType=Form.eq(1).find(".Row").eq(0).find("tr").eq(0).find(".Select").val();
	var ModuleNumber=Form.eq(1).find(".Row").eq(0).find("tr").eq(1).find(".Select").val();
	var ModuleName=Form.eq(1).find(".Row").eq(0).find("tr").eq(2).find(".Text").val();
	
	var VariableAttribute=Form.eq(1).find(".Row").eq(1).find("tr").eq(0).find(".Select").val();
	var VariableType=Form.eq(1).find(".Row").eq(1).find("tr").eq(1).find(".Select").val();
	var VariableName=Form.eq(1).find(".Row").eq(1).find("tr").eq(2).find(".Select").val();
	
	if(ModuleType=="" || ModuleType==null)               {Form.eq(1).find(".Row").eq(0).find("tr").eq(0).find(".Message").show();}
	if(ModuleNumber=="" || ModuleNumber==null)           {Form.eq(1).find(".Row").eq(0).find("tr").eq(1).find(".Message").show();}
	if(ModuleName=="" || ModuleName==null)               {Form.eq(1).find(".Row").eq(0).find("tr").eq(2).find(".Message").show();}
	
	if(VariableAttribute=="" || VariableAttribute==null) {Form.eq(1).find(".Row").eq(1).find("tr").eq(0).find(".Message").show();}
	if(VariableType=="" || VariableType==null)           {Form.eq(1).find(".Row").eq(1).find("tr").eq(1).find(".Message").show();}
	if(VariableName=="" || VariableName==null)           {Form.eq(1).find(".Row").eq(1).find("tr").eq(2).find(".Message").show();}
}

PidOperationSecondPage.prototype._ShowOutputErrorMessage_ = function()
{
	var Form=$("#Main_Center-Content").find(".Body").eq(2).find(".Form");
	var ModuleType=Form.eq(2).find(".Row").eq(0).find("tr").eq(0).find(".Select").val();
	var ModuleNumber=Form.eq(2).find(".Row").eq(0).find("tr").eq(1).find(".Select").val();
	var ModuleName=Form.eq(2).find(".Row").eq(0).find("tr").eq(2).find(".Text").val();
	
	var VariableAttribute=Form.eq(2).find(".Row").eq(1).find("tr").eq(0).find(".Select").val();
	var VariableType=Form.eq(2).find(".Row").eq(1).find("tr").eq(1).find(".Select").val();
	var VariableName=Form.eq(2).find(".Row").eq(1).find("tr").eq(2).find(".Select").val();
	
	if(ModuleType=="" || ModuleType==null)               {Form.eq(2).find(".Row").eq(0).find("tr").eq(0).find(".Message").show();}
	if(ModuleNumber=="" || ModuleNumber==null)           {Form.eq(2).find(".Row").eq(0).find("tr").eq(1).find(".Message").show();}
	if(ModuleName=="" || ModuleName==null)               {Form.eq(2).find(".Row").eq(0).find("tr").eq(2).find(".Message").show();}
	
	if(VariableAttribute=="" || VariableAttribute==null) {Form.eq(2).find(".Row").eq(1).find("tr").eq(0).find(".Message").show();}
	if(VariableType=="" || VariableType==null)           {Form.eq(2).find(".Row").eq(1).find("tr").eq(1).find(".Message").show();}
	if(VariableName=="" || VariableName==null)           {Form.eq(2).find(".Row").eq(1).find("tr").eq(2).find(".Message").show();}
}

PidOperationSecondPage.prototype._IsNameRepeat_ = function(Name)
{
	var Return=false;
	var Variable=Global_PidOperation;
	var Row = $("#Main_Center-Content").find(".Body").eq(2).find(".Form").eq(0).find(".Row");
	var CurrentlyNumber = Row.eq(0).find(".Text").val();
	var number = Object.keys(Variable);
	for(var i=0; i<number.length; i++)
	{
		if(number[i] == CurrentlyNumber)
		{
			continue;
		}	
		if(Name == Variable[number[i]]["Name"])
		{
			Return=true;
			break;
		}
	}
	return Return;
}

PidOperationSecondPage.prototype._CheckPidName_ = function(that)
{
	$(that).closest(".Row").find(".Message").hide();
	var Name = $(that).closest(".Row").find(".Text").val();
	var Class = new Type();
	if(Class.EnglishDigitalAndBottomline(Name) == false)
	{
		$(that).closest(".Row").find(".Message").eq(0).show();
	}
	Class = null;
	if(PidOperationSecondPage.prototype._IsNameRepeat_(Name) == true)
	{
		$(that).closest(".Row").find(".Message").eq(1).show();
	}
}

PidOperationSecondPage.prototype._CheckSampleTime_ = function(that)
{
	var Class = new Type();
	var SampleTime = $(that).val();
	SampleTime = parseInt(SampleTime);
	if(Class.CheckPositiveIntegers(SampleTime) == false)
	{
		SampleTime=500;
	}
	if(SampleTime < 20)
	{
		SampleTime=20;
	}
	if(SampleTime > 1000)
	{
		SampleTime=1000;
	}
	$(that).val(SampleTime);
	Class = null;
}

PidOperationSecondPage.prototype._CheckKp_ = function(that)
{
	var Kp = $(that).val();
	var Class = new Type();
	Kp = parseFloat(Kp);
	if(Class.CheckFloat(Kp) == false)
	{
		Kp=1;
	}
	Kp = parseFloat(Kp.toFixed(2));
	$(that).val(Kp);
	Class=null;
}

PidOperationSecondPage.prototype._CheckKi_ = function(that)
{
	var Ki = $(that).val();
	var Class = new Type();
	Ki = parseFloat(Ki);
	if(Class.CheckFloat(Ki) == false)
	{
		Ki=1;
	}
	Ki = parseFloat(Ki.toFixed(2));
	$(that).val(Ki);
	Class=null;
}

PidOperationSecondPage.prototype._CheckKd_ = function(that)
{
	var Kd = $(that).val();
	var Class = new Type();
	Kd = parseFloat(Kd);
	if(Class.CheckFloat(Kd) == false)
	{
		Kd=1;
	}
	Kd = parseFloat(Kd.toFixed(2));
	$(that).val(Kd);
	Class=null;
}

PidOperationSecondPage.prototype._CheckSetValue_ = function(that)
{
	var SetValue = $(that).val();
	var Class = new Type();
	SetValue = parseFloat(SetValue);
	if(Class.CheckFloat(SetValue) == false)
	{
		SetValue=0;
	}
	SetValue = parseFloat(SetValue.toFixed(2));
	$(that).val(SetValue);
	Class=null;
}

PidOperationSecondPage.prototype._CheckMin_ = function(that)
{	
	var Max = $(that).closest(".Form").find(".Row").eq(2).find(".Text").val();
	var Min = $(that).val();
	var Class = new Type();
	Max = parseFloat(Max);
	Min = parseFloat(Min);
	if(Class.CheckFloat(Min) == false)	{Min=0;}
	if(Class.CheckFloat(Max) == false)	{Max=0;}
	
	if(Max < Min)
	{
		Min=Max;
	}
	Min = parseFloat(Min.toFixed(2));
	$(that).val(Min);
	Class=null;
}

PidOperationSecondPage.prototype._CheckMax_ = function(that)
{
	var Min = $(that).closest(".Form").find(".Row").eq(3).find(".Text").val();
	var Max = $(that).val();
	var Class = new Type();
	Min = parseFloat(Min);
	Max = parseFloat(Max);
	
	if(Class.CheckFloat(Min) == false)	{Min=0;}
	if(Class.CheckFloat(Max) == false)	{Max=0;}
	
	if(Min > Max)
	{
		Max=Min;
	}
	Max = parseFloat(Max.toFixed(2));
	$(that).val(Max);
	Class=null;
}

PidOperationSecondPage.prototype._CheckAutoTune_ = function()
{
	var Kp=$("#Main_Center-Content").find(".Body").eq(2).find(".Form").eq(1).find(".Row").eq(6).find(".Text");
	var Ki=$("#Main_Center-Content").find(".Body").eq(2).find(".Form").eq(1).find(".Row").eq(7).find(".Text");
	var Kd=$("#Main_Center-Content").find(".Body").eq(2).find(".Form").eq(1).find(".Row").eq(8).find(".Text");
	var Bool=$("#Main_Center-Content").find(".Body").eq(2).find(".Form").eq(1).find(".Row").eq(2).find(":checkbox").prop("checked");
	if(Bool== true)
	{
		Kp.prop( "disabled", true);
		Ki.prop( "disabled", true);
		Kd.prop( "disabled", true);
	}
	else if(Bool== false)
	{
		Kp.prop( "disabled", false);
		Ki.prop( "disabled", false);
		Kd.prop( "disabled", false);
	}

	Class=null;
}

PidOperationSecondPage.prototype._ChangeInputModuleType_ = function(ModuleType, that)
{
	PidOperationSecondPage.prototype._LoadModuleNumber_(ModuleType, that);
	PidOperationSecondPage.prototype._LoadModuleName_(ModuleType, that);
	
	PidOperationSecondPage.prototype._LoadInputVariableAttribute_(ModuleType);
	PidOperationSecondPage.prototype._LoadVariableType_(ModuleType, that);
	
	var ModuleNumber=$(that).closest(".Form").find(".Row").eq(0).find("table").find("tr").eq(1).find("Select").val();
	var VariableIndex=PidOperationSecondPage.prototype._GetVariableIndexPrefixWord_(that);
	PidOperationSecondPage.prototype._LoadVariableName_(ModuleType, ModuleNumber, VariableIndex, that);
	
	PidOperationSecondPage.prototype._HideErrorMessage_();
	PidOperationSecondPage.prototype._ShowInputErrorMessage_();
	PidOperationSecondPage.prototype._ShowOutputErrorMessage_();
}

PidOperationSecondPage.prototype._ChangeOutputModuleType_ = function(ModuleType, that)
{
	PidOperationSecondPage.prototype._LoadModuleNumber_(ModuleType, that);
	PidOperationSecondPage.prototype._LoadModuleName_(ModuleType, that);
	
	PidOperationSecondPage.prototype._LoadOutputVariableAttribute_(ModuleType);
	PidOperationSecondPage.prototype._LoadVariableType_(ModuleType, that);
	
	var ModuleNumber=$(that).closest(".Form").find(".Row").eq(0).find("table").find("tr").eq(1).find("Select").val();
	var VariableIndex=PidOperationSecondPage.prototype._GetVariableIndexPrefixWord_(that);
	PidOperationSecondPage.prototype._LoadVariableName_(ModuleType, ModuleNumber, VariableIndex, that);
	
	PidOperationSecondPage.prototype._HideErrorMessage_();
	PidOperationSecondPage.prototype._ShowInputErrorMessage_();
	PidOperationSecondPage.prototype._ShowOutputErrorMessage_();
}

PidOperationSecondPage.prototype._ChangeModuleNumber_ = function(ModuleType, that)
{
	PidOperationSecondPage.prototype._LoadModuleName_(ModuleType, that);
	
	var ModuleNumber=$(that).closest(".Form").find(".Row").eq(0).find("table").find("tr").eq(1).find("Select").val();
	var VariableIndex=PidOperationSecondPage.prototype._GetVariableIndexPrefixWord_(that);
	PidOperationSecondPage.prototype._LoadVariableName_(ModuleType, ModuleNumber, VariableIndex, that);
	
	PidOperationSecondPage.prototype._HideErrorMessage_();
	PidOperationSecondPage.prototype._ShowInputErrorMessage_();
	PidOperationSecondPage.prototype._ShowOutputErrorMessage_();
}

PidOperationSecondPage.prototype._ChangeVariableAttribute_ = function(ModuleType, that)
{	
	var ModuleNumber=$(that).closest(".Form").find(".Row").eq(0).find("table").find("tr").eq(1).find("Select").val();
	var VariableIndex=PidOperationSecondPage.prototype._GetVariableIndexPrefixWord_(that);
	PidOperationSecondPage.prototype._LoadVariableName_(ModuleType, ModuleNumber, VariableIndex, that);
	
	PidOperationSecondPage.prototype._HideErrorMessage_();
	PidOperationSecondPage.prototype._ShowInputErrorMessage_();
	PidOperationSecondPage.prototype._ShowOutputErrorMessage_();
}

PidOperationSecondPage.prototype._ChangeVariableType_ = function(ModuleType, that)
{
	PidOperationSecondPage.prototype._ChangeVariableAttribute_(ModuleType, that);
}

PidOperationSecondPage.prototype._ModifyInputDataObject_ = function(Form, Variable, PidNumber)
{
	var ModuleType       =Form.eq(1).find(".Row").eq(0).find("tr").eq(0).find(".Select").val();
	var ModuleNumber     =Form.eq(1).find(".Row").eq(0).find("tr").eq(1).find(".Select").val();

	var VariableAttribute=Form.eq(1).find(".Row").eq(1).find("tr").eq(0).find(".Select").val();
	var VariableType     =Form.eq(1).find(".Row").eq(1).find("tr").eq(1).find(".Select").val();
	var VariableName     =Form.eq(1).find(".Row").eq(1).find("tr").eq(2).find(".Select").val();
	
	var Class=new GetValue();	
	var GlobalVariable=PidOperationSecondPage.prototype._GetGlobalVariable_(ModuleType);
	var PrefixVariableIndex=Class.GetModuleVariableAttribute(VariableAttribute, VariableType);
	PrefixVariableIndex=PrefixVariableIndex+"-"+VariableType+"-";
	var VariableIndex=Class.GetModuleVariableIndex(GlobalVariable, ModuleNumber, PrefixVariableIndex, VariableName);
	Class=null;
	Variable[PidNumber]["InputModuleVariableIndex"]=ModuleType+"/"+ModuleNumber+"/"+VariableIndex;
	Variable[PidNumber]["AutoTune"]                =Form.eq(1).find(".Row").eq(2).find(":checkbox").prop("checked");
	Variable[PidNumber]["SampleTime"]              =parseInt(Form.eq(1).find(".Row").eq(3).find(".Text").val());
	Variable[PidNumber]["SetValue"]                =parseFloat(Form.eq(1).find(".Row").eq(4).find(".Text").val());
	Variable[PidNumber]["ControllerMode"]          =Form.eq(1).find(".Row").eq(5).find(".Select").val();
	Variable[PidNumber]["Ki"]                      =parseFloat(Form.eq(1).find(".Row").eq(7).find(".Text").val());
	Variable[PidNumber]["Kp"]                      =parseFloat(Form.eq(1).find(".Row").eq(6).find(".Text").val());
	Variable[PidNumber]["Kd"]                      =parseFloat(Form.eq(1).find(".Row").eq(8).find(".Text").val());
}
PidOperationSecondPage.prototype._ModifyScalingInputDataObject_ = function(Form, Variable, PidNumber)
{
	var ModuleType       =Form.eq(1).find(".Row").eq(0).find("tr").eq(0).find(".Select").val();
	var ModuleNumber     =Form.eq(1).find(".Row").eq(0).find("tr").eq(1).find(".Select").val();

	var VariableAttribute=Form.eq(1).find(".Row").eq(1).find("tr").eq(0).find(".Select").val();
	var VariableType     =Form.eq(1).find(".Row").eq(1).find("tr").eq(1).find(".Select").val();
	var VariableName     =Form.eq(1).find(".Row").eq(1).find("tr").eq(2).find(".Select").val();
	
	var Class=new GetValue();	
	var GlobalVariable=PidOperationSecondPage.prototype._GetGlobalVariable_(ModuleType);
	var PrefixVariableIndex=Class.GetModuleVariableAttribute(VariableAttribute, VariableType);
	PrefixVariableIndex=PrefixVariableIndex+"-"+VariableType+"-";
	var VariableIndex = PidOperationSecondPage.prototype._GetScalingModuleVariableIndex_(GlobalVariable, ModuleNumber, PrefixVariableIndex, VariableName);
	Class=null;
	Variable[PidNumber]["InputModuleVariableIndex"]=ModuleType+"/"+ModuleNumber+"/"+VariableIndex;
	Variable[PidNumber]["AutoTune"]                =Form.eq(1).find(".Row").eq(2).find(":checkbox").prop("checked");
	Variable[PidNumber]["SampleTime"]              =parseInt(Form.eq(1).find(".Row").eq(3).find(".Text").val());
	Variable[PidNumber]["SetValue"]                =parseFloat(Form.eq(1).find(".Row").eq(4).find(".Text").val());
	Variable[PidNumber]["ControllerMode"]          =Form.eq(1).find(".Row").eq(5).find(".Select").val();
	Variable[PidNumber]["Ki"]                      =parseFloat(Form.eq(1).find(".Row").eq(7).find(".Text").val());
	Variable[PidNumber]["Kp"]                      =parseFloat(Form.eq(1).find(".Row").eq(6).find(".Text").val());
	Variable[PidNumber]["Kd"]                      =parseFloat(Form.eq(1).find(".Row").eq(8).find(".Text").val());
}
PidOperationSecondPage.prototype._GetScalingModuleVariableIndex_ = function(GlobalVariable, ModuleNumber, PrefixVariableIndex, VariableName)
{
	var Return="";
	if(typeof(GlobalVariable) != "object" || 
	   typeof(GlobalVariable[ModuleNumber]) != "object")
	{
		return Return;
	}
	var VariableList=Object.keys(GlobalVariable[ModuleNumber]);
	var ScalingVariableList = VariableList.slice();
	for(var i=0; i<ScalingVariableList.length; i++)
	{
		var ScalingArray=ScalingVariableList[i].split("-");
		ScalingVariableList[i] = ScalingArray[0]+"-Float-" + ScalingArray[2];
	}
	for(var i=0; i<VariableList.length; i++)
	{
		var Name=GlobalVariable[ModuleNumber][VariableList[i]]["ScaleVariableName"];
		if(Name == VariableName && ScalingVariableList[i].indexOf(PrefixVariableIndex)!=-1)
		{
			Return=VariableList[i] + "." + VariableName;
			break;
		}
	}
	return Return;
}

PidOperationSecondPage.prototype._ModifyOutputDataObject_ = function(Form, Variable, PidNumber)
{
	var ModuleType       =Form.eq(2).find(".Row").eq(0).find("tr").eq(0).find(".Select").val();
	var ModuleNumber     =Form.eq(2).find(".Row").eq(0).find("tr").eq(1).find(".Select").val();

	var VariableAttribute=Form.eq(2).find(".Row").eq(1).find("tr").eq(0).find(".Select").val();
	var VariableType     =Form.eq(2).find(".Row").eq(1).find("tr").eq(1).find(".Select").val();
	var VariableName     =Form.eq(2).find(".Row").eq(1).find("tr").eq(2).find(".Select").val();
	
	var Class=new GetValue();	
	var GlobalVariable=PidOperationSecondPage.prototype._GetGlobalVariable_(ModuleType);
	var PrefixVariableIndex=Class.GetModuleVariableAttribute(VariableAttribute, VariableType);
	PrefixVariableIndex=PrefixVariableIndex+"-"+VariableType+"-";
	var VariableIndex=Class.GetModuleVariableIndex(GlobalVariable, ModuleNumber, PrefixVariableIndex, VariableName);
	Class=null;
	Variable[PidNumber]["OutputModuleVariableIndex"]=ModuleType+"/"+ModuleNumber+"/"+VariableIndex;
	Variable[PidNumber]["Max"]=parseFloat(Form.eq(2).find(".Row").eq(2).find(".Text").val());
	Variable[PidNumber]["Min"]=parseFloat(Form.eq(2).find(".Row").eq(3).find(".Text").val());
}
PidOperationSecondPage.prototype._ModifyScalingOutputDataObject_ = function(Form, Variable, PidNumber)
{
	var ModuleType       =Form.eq(2).find(".Row").eq(0).find("tr").eq(0).find(".Select").val();
	var ModuleNumber     =Form.eq(2).find(".Row").eq(0).find("tr").eq(1).find(".Select").val();

	var VariableAttribute=Form.eq(2).find(".Row").eq(1).find("tr").eq(0).find(".Select").val();
	var VariableType     =Form.eq(2).find(".Row").eq(1).find("tr").eq(1).find(".Select").val();
	var VariableName     =Form.eq(2).find(".Row").eq(1).find("tr").eq(2).find(".Select").val();
	
	var Class=new GetValue();	
	var GlobalVariable=PidOperationSecondPage.prototype._GetGlobalVariable_(ModuleType);
	var PrefixVariableIndex=Class.GetModuleVariableAttribute(VariableAttribute, VariableType);
	PrefixVariableIndex=PrefixVariableIndex+"-"+VariableType+"-";
	var VariableIndex = PidOperationSecondPage.prototype._GetScalingModuleVariableIndex_(GlobalVariable, ModuleNumber, PrefixVariableIndex, VariableName);
	Class=null;
	Variable[PidNumber]["OutputModuleVariableIndex"]=ModuleType+"/"+ModuleNumber+"/"+VariableIndex;
	Variable[PidNumber]["Max"]=parseFloat(Form.eq(2).find(".Row").eq(2).find(".Text").val());
	Variable[PidNumber]["Min"]=parseFloat(Form.eq(2).find(".Row").eq(3).find(".Text").val());
}

PidOperationSecondPage.prototype._ModifyPidOperationObject_ = function(that)
{
	var Form=$("#Main_Center-Content").find(".Body").eq(2).find(".Form");

	var Variable=Global_PidOperation;
	var PidNumber=Form.eq(0).find(".Row").eq(0).find(".Text").val();
	var PidName=Form.eq(0).find(".Row").eq(1).find(".Text").val();
	Variable[PidNumber]["Name"]=PidName;
	var ModuleType       =Form.eq(1).find(".Row").eq(0).find("tr").eq(0).find(".Select").val();
	if(ModuleType == "MRTU Scaling" || ModuleType == "MTCP Scaling")
	{
		PidOperationSecondPage.prototype._ModifyScalingInputDataObject_(Form, Variable, PidNumber);
	}
	else
	{
		PidOperationSecondPage.prototype._ModifyInputDataObject_(Form, Variable, PidNumber);
	}
	var ModuleType       =Form.eq(2).find(".Row").eq(0).find("tr").eq(0).find(".Select").val();
	if(ModuleType == "MRTU Scaling" || ModuleType == "MTCP Scaling")
	{
		PidOperationSecondPage.prototype._ModifyScalingOutputDataObject_(Form, Variable, PidNumber);
	}
	else
	{
		PidOperationSecondPage.prototype._ModifyOutputDataObject_(Form, Variable, PidNumber);
	}
}

PidOperationSecondPage.prototype._SelectModuleType_ = function()
{
	var Value;
	var InputForm=$("#Main_Center-Content").find(".Body").eq(2).find(".Form");
	var InputModuleType=InputForm.eq(1).find(".Row").eq(0).find("tr").eq(0).find(".Select").val();
	if(InputModuleType == "" || InputModuleType==null)
	{
		Value=InputForm.eq(2).find(".Row").eq(0).find("tr").eq(0).find(".Select").find("option").eq(0).val();
		InputForm.eq(1).find(".Row").eq(0).find("tr").eq(0).find(".Select").val(Value).change();
	}
	var OutputForm=$("#Main_Center-Content").find(".Body").eq(2).find(".Form");
	var OutputModuleType=OutputForm.eq(2).find(".Row").eq(0).find("tr").eq(0).find(".Select").val();
	if(OutputModuleType == "" || OutputModuleType==null)
	{
		Value=OutputForm.eq(2).find(".Row").eq(0).find("tr").eq(0).find(".Select").find("option").eq(0).val();
		OutputForm.eq(2).find(".Row").eq(0).find("tr").eq(0).find(".Select").val(Value).change();
	}
}

PidOperationSecondPage.prototype._ConfirmButton_ = function(that)
{
	$(that).closest(".Form").find(".Message").hide();
	var Element = $("#Main_Center-Content").find(".Body").eq(2).find(".Message");
	for(var i=0; i<Element.length; i++)
	{
		if(Element.eq(i).is(":visible") == true && Element.eq(i).css("color") != "rgb(34, 119, 0)"){
			$(that).closest(".Form").find(".Message").eq(1).show();
			return 0;
		}
	}
	PidOperationSecondPage.prototype._ModifyPidOperationObject_(that);
	$("#Main_Center-Content").find(".Body").eq(2).hide();
	$("#Main_Center-Content").find(".Body").eq(1).show();
	PidOperationFirstPage.prototype._Initialization_();
	var Class = new Path();
	Class.LoadPathHtml($("#Left-List-PID").text(), 1, "main_PathPidOperation_click(this)");
	Class = null;
}

PidOperationSecondPage.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-PID").text(), 1, "main_PathPidOperation_click(this)");
	Class = null;
}