JsonTransformXml.prototype._GetEipMqttMappingData_ = function(PrefixWord, ModuleIndex, MqttVariable, Variable, Module, MQTTServiceTask)
{
	var Index = ModuleIndex.split("_")[1];
	SystemVariable = Object.keys(MqttVariable[Index]);
	var Class = new LoadFile();
	var Global_EipSetting = Class.ReadFile("./File/EIP_Module/EipSetting.json", new Array());
	var ChannelModeType = parseInt(Global_EipSetting[Index]["ModeType"]);
	for(var j=0; j<ChannelModeType; j++)
	{
		if(MqttVariable[Index][SystemVariable[j]]["TransformMqtt"] == true)
		{
			MQTTMapping=new Object();
			MQTTMapping["Name"]     = PrefixWord+Index+"_"+JsonTransformXml.prototype._GetModuleName_(Module, Index)+"_"+SystemVariable[j].split("-")[0]+"."+Variable[Index][SystemVariable[j]]["VariableName"];
			MQTTMapping["PubTopic"] = MqttVariable[Index][SystemVariable[j]]["PublishTopic"];
			MQTTMapping["PubQoS"]   = MqttVariable[Index][SystemVariable[j]]["PublishQos"];
			MQTTMapping["SubTopic"] = MqttVariable[Index][SystemVariable[j]]["SubscribeTopic"];
			MQTTMapping["SubQoS"]   = MqttVariable[Index][SystemVariable[j]]["SubscribeQos"];
			MQTTMapping["DataType"] = JsonTransformXml.prototype._GetDataType_(SystemVariable[j].split("-")[1]);
			MQTTMapping["Property"] = JsonTransformXml.prototype._GetProperty_(SystemVariable[j].split("-")[0]);
			MQTTMapping["Retain"]   = JsonTransformXml.prototype._GetRetainNumber_(MqttVariable[Index][SystemVariable[j]]["Retain"]);
			MQTTServiceTask["MQTTMapping"].push(MQTTMapping);
		}
	}
}

Judgment.prototype._IsSaveEipMasterModuleGlobalVariable_ = function()
{
	var Return=false;
	var Class = new LoadFile();
	var Index = Class.ReadFile("./File/EIP_Module/Index.json", new Array());
	var Module = Class.ReadFile("./File/EIP_Module/Module.json", new Object());
	var Variable = Class.ReadFile("./File/EIP_Module/EipVariable.json", new Object());
	var Setting = Class.ReadFile("./File/EIP_Module/EipSetting.json", new Object());
	
	if(JSON.stringify(Index)==JSON.stringify(Global_EipIndex) &&
	   JSON.stringify(Module)==JSON.stringify(Global_EipModule) &&
	   JSON.stringify(Variable)==JSON.stringify(Global_EipVariable) &&
	   JSON.stringify(Setting)==JSON.stringify(Global_EipSetting))
	{
		Return=true;
	}
	return Return;
};
//Step
StepCommon.prototype._ChangeCurrentDivCss_ = function(that)
{
	$(that).css("border-bottom-color", "rgb(200,200,200)");
	$(that).css("color", "#000000");
};
StepCommon.prototype._ClearAllDivCss_ = function(DivId)
{
	var DivLength = $(DivId).find(".StepText").length;
	
	for(var i=0; i<DivLength; i++)
	{
		$(DivId).find(".StepText").eq(i).css("border-bottom-color", "rgb(251, 251, 251)");
		$(DivId).find(".StepText").eq(i).css("color", "rgb(112, 112, 112)");
	}
};
StepCommon.prototype._ChangeDivCss_ = function(that, DivId)
{
	StepCommon.prototype._ClearAllDivCss_(DivId);
	StepCommon.prototype._ChangeCurrentDivCss_(that);
};

//Menu
MenuCommon.prototype._RestorePageSize_ = function(that)
{
	$("#Main_Center-Content").css("border-left-width", "1px");
	$("#Main_Center-Content").css("width", "795px");
	$("#Main_Left-List").show();
};
MenuCommon.prototype._ChangeMouseoutDivCss_ = function(that)
{
	var color = $(that).css("border-bottom-color"); 
	if(color != "rgb(57, 93, 139)")
	{
		$(that).css("color", "rgb(112, 112, 112)");
		$(that).css("cursor", "default");
	}
};
MenuCommon.prototype._ChangeMouseoutDivCss_ = function(that)
{
	var color = $(that).css("border-bottom-color"); 
	if(color != "rgb(57, 93, 139)")
	{
		$(that).css("color", "rgb(112, 112, 112)");
		$(that).css("cursor", "default");
	}
};
MenuCommon.prototype._ChangeMouseoverDivCss_ = function(that)
{
	$(that).css("color", "#000000");
	$(that).css("cursor", "pointer");
};
MenuCommon.prototype._ChangeCurrentDivCss_ = function(that)
{
	$(that).css("border-bottom-color", "rgb(57, 93, 139)");
	$(that).css("color", "#000000");
};
MenuCommon.prototype._ClearAllDivCss_ = function(DivId)
{
	var DivLength = $(DivId).children("div").length;
	
	for(var i=0; i<DivLength; i++)
	{
		$(DivId).children("div").eq(i).css("border-bottom-color", "rgb(251, 251, 251)");
		$(DivId).children("div").eq(i).css("color", "rgb(112, 112, 112)");
	}
};
MenuCommon.prototype._ChangeDivCss_ = function(that, DivId)
{
	MenuCommon.prototype._ClearAllDivCss_(DivId);
	MenuCommon.prototype._ChangeCurrentDivCss_(that);
};
MenuCommon.prototype._LoadLeftListHtml_ = function(DivId, HtmlPath, Async)
{
	$(DivId).css('pointer-events', "none");
	$(DivId).css('opacity', 0.5);
	$(DivId).empty();
	var Class = new LoadHtml();  var Html;
	if(Async == true)
	{
		Html = {Input:null};
		Class.ReadTranslateAfterOfHtml(HtmlPath, Html);
		var SetInterval = setInterval(function(){
			if(Html["Input"] != null){
				clearInterval(SetInterval);
				$(DivId).append(Html["Input"]);
				$(DivId).css("width", "215px");
				$(DivId).css('opacity', 1);
				$(DivId).css('pointer-events', "visible");
			}
		},500);
	}
	else{
		Html = Class.ReadTranslateAfterOfHtml(HtmlPath);
		$(DivId).append(Html);
		$(DivId).css("width", "215px");
		$(DivId).css('opacity', 1);
		$(DivId).css('pointer-events', "visible");
	}
};

MenuCommon.prototype._LoadContentHtml_ = function(DivId, HtmlPath, Async)
{
	$(DivId).css('pointer-events', "none");
	$(DivId).css('opacity', 0.5);
	$(DivId).empty();
	var Class = new LoadHtml();  var Html;
	if(Async == true){
		Html = {Input:null};
		Class.ReadTranslateAfterOfHtml(HtmlPath, Html);
		var SetInterval = setInterval(function(){
			if(Html["Input"] != null){
				clearInterval(SetInterval);
				$(DivId).append(Html["Input"]);
				$(DivId).css("width", "795px");
				$(DivId).css('opacity', 1);
				$(DivId).css('pointer-events', "visible");
			}
		},500);
	}
	else{
		Html = Class.ReadTranslateAfterOfHtml(HtmlPath);
		$(DivId).append(Html);
		$(DivId).css("width", "795px");
		$(DivId).css("border-left", "1px solid #DBDBDB");
		$(DivId).css('opacity', 1);
		$(DivId).css('pointer-events', "visible");
	}
};

MenuCommon.prototype._LoadHtml_ = function(DivId, Html)
{
	var Class = new LoadHtml();
	$(DivId).css('pointer-events', "none");
	$(DivId).css('opacity', 0.5);
	$(DivId).empty();
	Html = LoadHtml.prototype._TranslateHtml_(Html);
	$(DivId).append(Html);
	if(DivId == "#Main_Left-List")
	{
		$(DivId).css("width", "215px");
		$(DivId).css('opacity', 1);
		$(DivId).css('pointer-events', "visible");		
	}
	else if(DivId == "#Main_Center-Content")
	{
		$(DivId).css("width", "795px");
		$(DivId).css("border-left", "1px solid #DBDBDB");
		$(DivId).css('opacity', 1);
		$(DivId).css('pointer-events', "visible");
	}
};
//List
ListCommon.prototype._ChangeCurrentDivCss_ = function(that)
{
	$(that).css("border-left-color", "rgb(57, 93, 139)");
	$(that).css("color", "#000000");
};
ListCommon.prototype._ClearAllDivCss_ = function(DivId)
{
	var DivLength = $(DivId).children("div").length;
	
	for(var i=0; i<DivLength; i++)
	{
		$(DivId).children("div").eq(i).css("border-left-color", "rgb(251, 251, 251)");
		$(DivId).children("div").eq(i).css("color", "rgb(112, 112, 112)");
	}
};
ListCommon.prototype._ChangeMouseoutDivCss_ = function(that)
{
	var color = $(that).css("border-left-color"); 
	if(color != "rgb(57, 93, 139)")
	{
		$(that).css("color", "rgb(112, 112, 112)");
		$(that).css("cursor", "default");
	}
};
ListCommon.prototype._ChangeMouseoverDivCss_ = function(that)
{
	$(that).css("color", "#000000");
	$(that).css("cursor", "pointer");
};
ListCommon.prototype._ChangeDivCss_ = function(that, DivId)
{
	ListCommon.prototype._ClearAllDivCss_(DivId);
	ListCommon.prototype._ChangeCurrentDivCss_(that);
};
ListCommon.prototype._SaveMasterRtuModule_ = function()
{
	var Class = new LoadFile();
	var Index = Class.ReadFile("./File/RTU_Module/Index.json", new Array());
	var Module = Class.ReadFile("./File/RTU_Module/Module.json", new Object());
	var Variable = Class.ReadFile("./File/RTU_Module/RtuVariable.json", new Object());
	var Setting = Class.ReadFile("./File/RTU_Module/RtuSetting.json", new Object());
	if(!(JSON.stringify(Index)==JSON.stringify(Global_RtuIndex) &&
	     JSON.stringify(Module)==JSON.stringify(Global_RtuModule) &&
	     JSON.stringify(Variable)==JSON.stringify(Global_RtuVariable) &&
	     JSON.stringify(Setting)==JSON.stringify(Global_RtuSetting)))
	{
		main_RtuModuleSaveButton_click();
	}
};
ListCommon.prototype._SaveMasterTcpModule_ = function()
{
	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());
	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)))
	{
		main_TcpModuleSaveButton_click();
	}
};
ListCommon.prototype._SaveMasterAsciiModule_ = function()
{
	var Class = new LoadFile();
	var Index = Class.ReadFile("./File/ASCII_Module/Index.json", new Array());
	var Module = Class.ReadFile("./File/ASCII_Module/Module.json", new Object());
	var Variable = Class.ReadFile("./File/ASCII_Module/AsciiVariable.json", new Object());
	var Setting = Class.ReadFile("./File/ASCII_Module/AsciiSetting.json", new Object());
	if(!(JSON.stringify(Index)==JSON.stringify(Global_AsciiIndex) &&
	     JSON.stringify(Module)==JSON.stringify(Global_AsciiModule) &&
	     JSON.stringify(Variable)==JSON.stringify(Global_AsciiVariable) &&
	     JSON.stringify(Setting)==JSON.stringify(Global_AsciiSetting)))
	{
		main_AsciiModuleSaveButton_click();
	}
};
ListCommon.prototype._SaveMqttModule_ = function()
{
	var Class = new LoadFile();
	var Index = Class.ReadFile("./File/MQTT_Module/Index.json", new Array());
	var Module = Class.ReadFile("./File/MQTT_Module/Module.json", new Object());
	var Variable = Class.ReadFile("./File/MQTT_Module/MqttVariable.json", new Object());
	var Setting = Class.ReadFile("./File/MQTT_Module/MqttSetting.json", new Object());
	if(!(JSON.stringify(Index)==JSON.stringify(Global_MqttIndex) &&
	     JSON.stringify(Module)==JSON.stringify(Global_MqttModule) &&
	     JSON.stringify(Variable)==JSON.stringify(Global_MqttVariable) &&
	     JSON.stringify(Setting)==JSON.stringify(Global_MqttSetting)))
	{
		main_MqttModuleSaveButton_click();
	}
};
ListCommon.prototype._SaveRemoteBroker_ = function()
{
	var Class = new LoadFile();
	var RemoteBroker = Class.ReadFile("./File/IoT_Platform/RemoteBroker.json", new Object());
	if(JSON.stringify(RemoteBroker)!=JSON.stringify(Global_RemoteBroker))
	{
		main_RemoteBrokerSaveButton_click();
	}
};
ListCommon.prototype._SaveMqttJsonConnection_ = function()
{
	var Class = new LoadFile();
	var MqttJsonGroup = Class.ReadFile("./File/IoT_Platform/MqttJsonGroup.json", new Object());
	if(JSON.stringify(MqttJsonGroup)!=JSON.stringify(Global_MqttJsonGroup))
	{
		main_MqttJsonGroupSave_click();
	}
	var AzurePlatform = Class.ReadFile("./File/IoT_Platform/Microsoft_Azure_Platform.json", new Object());
	if(JSON.stringify(AzurePlatform)!=JSON.stringify(Global_AzurePlatform))
	{
		main_AzurePlatformSaveButton_click();
	}
};
//Path
PathCommon.prototype._ChangeMouseoutDivCss_ = function(that)
{
	var color = $(that).css("border-bottom-color"); 
	if(color != "rgb(57, 93, 139)")
	{
		$(that).css("color", "rgb(112, 112, 112)");
		$(that).css("cursor", "default");
	}
};
PathCommon.prototype._ChangeMouseoverDivCss_ = function(that)
{
	$(that).css("color", "#000000");
	$(that).css("cursor", "pointer");
};

//LoadHtml
LoadHtml.prototype._ReadHtml_ = function(HtmlPath, Input)
{
	var Return = "";  var Async = false;
	if(typeof(Input) !== "undefined")  {Async = true;}
	$.ajax({
		url: HtmlPath,
		type:"GET",
		async: Async,
		cache:false,
		success: function(msg)
		{
			Return = msg;
			if(Async == true)
			{
				Input["Input"] = msg;
			}
		},
		error:function(xhr, ajaxOptions, thrownError)
		{
			console.log("ajax error:["+xhr + ":" + ajaxOptions + ":" + thrownError+"]");
		}
	});
	return Return;
};
LoadHtml.prototype._TranslateHtml_ = function(Html)
{
	var OldIndex=0, NewIndex=0, NewHtml="";
	while((NewIndex = Html.indexOf("[$^", OldIndex)) > 0 && Html.indexOf("^$]", OldIndex) >0)
	{
		ReplaceHtml = Html.substring(Html.indexOf("[$^", OldIndex), Html.indexOf("^$]", OldIndex)+3);
		NewHtml = Html.substring(Html.indexOf("[$^", OldIndex)+3, Html.indexOf("^$]", OldIndex));
		Html = Html.replace(ReplaceHtml, Global_TranslateJson[NewHtml]);
		OldIndex = NewIndex;
	}
	return Html;
};
LoadHtml.prototype._ReadTranslateAfterOfHtml_ = function(HtmlPath, Input)
{
	var Return;
	if(typeof(Input) != "undefined")
	{
		Return = {Input:null};
		LoadHtml.prototype._ReadHtml_(HtmlPath, Return);
		var SetInterval = setInterval(function()
		{
			if(Return["Input"] != null)
			{
				clearInterval(SetInterval);
				var TranslateHtml = LoadHtml.prototype._TranslateHtml_(Return["Input"]);
				Input["Input"] = TranslateHtml;
			}
		},500);
	}
	else
	{
		Return = LoadHtml.prototype._ReadHtml_(HtmlPath);
		Return = LoadHtml.prototype._TranslateHtml_(Return);
	}
	return Return;
};
LoadHtml.prototype._GetVariableTranslationHtml_ = function(VariableHtml)
{
	var Class = new LoadHtml();
	VariableHtml = LoadHtml.prototype._TranslateHtml_(VariableHtml);
	return VariableHtml;
};

//LoadFile
LoadFile.prototype._ReadFile_ = function(FilePath, NewType, Input)
{
	var Return = "";
	var Async = false;
	if(typeof(Input) != "undefined")  {Async = true;}
	$.ajax({
		url: FilePath,
		type:"GET",
		async: Async,
		cache:false,
		success: function(msg){
			Return = msg;
			if(Async == true)
			{
				Input["Input"] = msg;
			}
		},
		error:function(xhr, ajaxOptions, thrownError){
			console.log("ajax error:["+xhr + ":" + ajaxOptions + ":" + thrownError+"]");
			Input["Input"] = NewType;
		}
	});
	if(Return == "" && typeof(NewType) != "undefined")
	{
		Return = NewType;
	}
	return Return;
};
LoadFile.prototype._ReadXmlObject_ = function(FilePath, NewType, Input)
{
	var tree = new XML.ObjTree();
	var Return = "";
	$.ajax({
		url: FilePath,
		type:"GET",
		async: false,
		cache:false,
		dataType:"text",
		success: function(msg){
			Return = msg;
			if(typeof(Input) != "undefined")
			{
				Input["Input"] = tree.parseXML(msg);
			}
		},
		error:function(xhr, ajaxOptions, thrownError){
			console.log("ajax error:["+xhr + ":" + ajaxOptions + ":" + thrownError+"]");
		}
	});
	Return = tree.parseXML(Return);
	if(Return == "" && typeof(NewType) != "undefined")
	{
		Return = NewType;
	}
	return Return;
};
LoadFile.prototype._ReadTranslateAfterOfFileJson_ = function(FilePath, NewType)
{
	var Return = "";
	var Class=new LoadFile();
	var File=Class.ReadFile(FilePath, NewType);
	var ObjectString=JSON.stringify(File);
	Class=new LoadHtml();
	Return=Class.TranslateHtml(ObjectString);
	Return=jQuery.parseJSON(Return);
	if(Return == "" && typeof(NewType) != "undefined")
	{
		Return = NewType;
	}
	return Return;
};
LoadFile.prototype._GetWebAllLink_ = function()
{
	var Class = new Cgi();
	Class.RestApi("WebShell", new Array("LeftLisHtml.sh"), true, {"Input":null});
	Class.RestApi("WebShell", new Array("FunctionWizardHtml.sh"), true, {"Input":null});
	Class.RestApi("WebShell", new Array("StepFlowHtml.sh"), true, {"Input":null});
	Class.RestApi("WebShell", new Array("TopMenuHtml.sh"), true, {"Input":null});
	Class.RestApi("WebShell", new Array("Language"), true, {"Input":null});
	LoadFile.prototype._LoadHandmadeCss_();
	LoadFile.prototype._LoadGlobalVariable_();
	LoadFile.prototype._LoadHeadJs_();
	LoadFile.prototype._LoadJppJs_();
	LoadFile.prototype._LoadMainJs_();
};

LoadFile.prototype._LoadHandmadeCss_ = function()
{
	var Class = new Cgi();
	var Value = Class.RestApi("GetWebAllLink", new Array("css"), false);
	LoadFile.prototype._LoadCss_(Value);

	var Bar = new ProgressBar();
	setTimeout(function()
	{
		Bar.SetValue(22);
	},100);
};

LoadFile.prototype._LoadGlobalVariable_ = function()
{
	var Bar = new ProgressBar();
	var Result = {"Input": null};
	var Class = new Cgi();
	var Value = Class.RestApi("GetWebAllLink", new Array("GlobalVariable"), false);
	var SetInterval_1 = setInterval(function(){
		if(Bar.GetValue() == "22%")
		{
			clearInterval(SetInterval_1);
			LoadFile.prototype._LoadJavascript_(Value, Result);
		}
	},100);
	var SetInterval_2 = setInterval(function(){
		if(Result["Input"] == true)
		{
			clearInterval(SetInterval_2);
			Bar.SetValue(45);
		}
	},100);
};

LoadFile.prototype._LoadHeadJs_ = function()
{
	var Bar = new ProgressBar();
	var Result = {"Input": null};
	var Class = new Cgi();
	var Value = Class.RestApi("GetWebAllLink", new Array("head"), false);
	var SetInterval_1 = setInterval(function(){
		if(Bar.GetValue() == "45%")
		{
			clearInterval(SetInterval_1);
			LoadFile.prototype._LoadJavascript_(Value, Result);
		}
	},100);
	var SetInterval_2 = setInterval(function(){
		if(Result["Input"] == true)
		{
			clearInterval(SetInterval_2);
			Bar.SetValue(63);
		}
	},100);
};

LoadFile.prototype._LoadJppJs_ = function()
{
	var Bar = new ProgressBar();
	var Result = {"Input": null};
	var Class = new Cgi();
	var Value = Class.RestApi("GetWebAllLink", new Array("jpp"), false);
	var SetInterval_1 = setInterval(function(){
		if(Bar.GetValue() == "63%")
		{
			clearInterval(SetInterval_1);
			LoadFile.prototype._LoadJavascript_(Value, Result);
		}
	},100);
	var SetInterval_2 = setInterval(function(){
		if(Result["Input"] == true)
		{
			clearInterval(SetInterval_2);
			Bar.SetValue(81);
		}
	},100);
};

LoadFile.prototype._LoadMainJs_ = function()
{
	var Bar = new ProgressBar();
	var Result = {"Input": null};
	var Class = new Cgi();
	var Value = Class.RestApi("GetWebAllLink", new Array("Main"), false);
	var SetInterval_1 = setInterval(function(){
		if(Bar.GetValue() == "81%")
		{
			clearInterval(SetInterval_1);
			LoadFile.prototype._LoadJavascript_(Value, Result);
		}
	},100);
	var SetInterval_2 = setInterval(function(){
		if(Result["Input"] == true)
		{
			clearInterval(SetInterval_2);
			Bar.SetValue(100);
			main_Main_load();
		}
	},100);
};

LoadFile.prototype._LoadJavascript_ = function(LinkArray, Result)
{
	var Size = LinkArray.length;
	var Index = 1;
	var jsFile;
    for(var i=0; i<LinkArray.length; i++)
    {
    	//$.getScript(LinkArray[i]);
        jsFile = document.createElement("script");
        jsFile.setAttribute("type","text/javascript");
        jsFile.setAttribute("src", LinkArray[i]);
        jsFile.setAttribute("async", "false");
        document.getElementsByTagName("head")[0].appendChild(jsFile);
		jsFile.onload = jsFile.onreadystatechange = function(){
		if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete" ){ 
			jsFile.onload = jsFile.onreadystatechange = null;
			Index = Index + 1;
		}};
    }
	var SetInterval = setInterval(function(){
	if(Index == Size)
	{
		Result["Input"] = true;
		clearInterval(SetInterval);
	}},100);
};

LoadFile.prototype._LoadCss_ = function(LinkArray)
{
    var cssFile;
    for(var i=0; i<LinkArray.length; i++)
    {
        cssFile = document.createElement("link");
		cssFile.type = 'text/css';
		cssFile.rel  = "stylesheet";
		cssFile.href = LinkArray[i];
        document.getElementsByTagName("head")[0].appendChild(cssFile);
    }
};



















//Type
Type.prototype._EnglishDigital_ = function(string)
{
    var Return=false;
	var re = /^.[A-Za-z0-9]+$/;
	if(re.test(string))
	{
		Return = true;
	}
	return Return;
};
Type.prototype._EnglishDigitalAndBottomline_ = function(string)
{
    var Return=false;
	var re = /^\w+$/;
	if(re.test(string))
	{
		Return = true;
	}
	return Return;
};
Type.prototype._CheckDomainIp_ = function(IP)
{
    var Return=false;
    var re = /^((\d)|(([1-9])\d)|(1\d\d)|(2(([0-4]\d)|5([0-5]))))\.((\d)|(([1-9])\d)|(1\d\d)|(2(([0-4]\d)|5([0-5]))))\.((\d)|(([1-9])\d)|(1\d\d)|(2(([0-4]\d)|5([0-5]))))\.((\d)|(([1-9])\d)|(1\d\d)|(2(([0-4]\d)|5([0-5]))))$/;
   	var re2 = /^((?:(?:(?:\w[\.\-\+]?)*)\w)+)((?:(?:(?:\w[\.\-\+]?){0,62})\w)+)\.(\w{2,6})$/;
	if( IP.match(re) || IP.match(re2) )
	{
		Return = true;
	}
	return Return;
};
Type.prototype._CheckIp_ = function(IP)
{
    var Return=false;
    var re = /^((\d)|(([1-9])\d)|(1\d\d)|(2(([0-4]\d)|5([0-5]))))\.((\d)|(([1-9])\d)|(1\d\d)|(2(([0-4]\d)|5([0-5]))))\.((\d)|(([1-9])\d)|(1\d\d)|(2(([0-4]\d)|5([0-5]))))\.((\d)|(([1-9])\d)|(1\d\d)|(2(([0-4]\d)|5([0-5]))))$/;
	if(IP.match(re))
	{
		Return = true;
	}
	return Return;
};
Type.prototype._CheckPositiveIntegersAndZero_ = function(number)
{
    var Return=false;
	var re = /^[1-9]d*|0$/;
	if(re.test(number))
	{
		Return = true;
	}
	return Return;
};
Type.prototype._CheckFloat_ = function(number)
{
    var Return=true;
	number = parseFloat(number);
	if(isNaN(number) == true)
	{
		Return = false;
	}
	return Return;
};
Type.prototype._CheckPositiveIntegers_ = function(number)
{
    var Return=false;
    var re = /^[0-9]*[1-9][0-9]*$/;
	if(re.test(number))
	{
		Return = true;
	}
	return Return;
};
Type.prototype._CheckChineseLanguage_ = function(string)
{
    var Return=false;
    var re = /[\u4e00-\u9fa5]/;
	if(re.test(string))
	{
		Return = true;
	}
	return Return;
};
Type.prototype._CheckSpecialSymbols_ = function(string)
{
    var Return=false;
    var re = /[ !@#$%^&*()+=\{}|;,.\\\/<>?~`:\'\"\[\]]/;
	if(re.test(string))
	{
		Return = true;
	}
	re = /[^\x00-\xff]/;
	if(re.test(string))
	{
		Return = true;
	}
	return Return;
};
Type.prototype._CheckSpecialSymbols_ExcludeBottomLineBrackets_ = function(string)
{
    var Return=false;
    var re = /[ !@#$%^&*+=\{}|;,.\\\/<>?~`:\'\"\[\]]/;
	if(re.test(string))
	{
		Return = true;
	}
	re = /[^\x00-\xff]/;
	if(re.test(string))
	{
		Return = true;
	}
	return Return;
};
Type.prototype._CheckMqttTopic_ = function(string)
{
    var Return=true;
    var re = /[#+]/;
	if(re.test(string))
	{
		Return = false;
	}
	else if(string == "")
	{
		Return = false;
	}
	return Return;
};
Type.prototype._CheckModbusDataModelMaxQuantity_ = function(DataType, Quantity)
{
    var Return=Quantity;
	if((DataType=="CoilStatus" || DataType=="InputStatus") && Quantity > 2000)
	{
		Return=2000;
	}
	else if((DataType=="HoldingRegisters" || DataType=="InputRegisters") && Quantity > 125)
	{
		Return=125;
	}
	return Return;
};

Type.prototype._CheckMqttDataModelMaxQuantity_ = function(Quantity)
{
    var Return = Quantity;
	if(Quantity > 1000)
	{
		Return = 1000;
	}
	return Return;
};

Dialog.prototype._CommonEnabled_ = function()
{
	$("#Main_Top-FunctionWizard").css('pointer-events', "visible");			$("#Main_Top-FunctionWizard").css('opacity', 1);
	$("#Main_Top-StepFlow").css('pointer-events', "visible");		$("#Main_Top-StepFlow").css('opacity', 1);
	$("#Main_Top-Menu").css('pointer-events', "visible");			$("#Main_Top-Menu").css('opacity', 1);
	$("#Main_Top-Path").css('pointer-events', "visible");			$("#Main_Top-Path").css('opacity', 1);
	$("#Main_Left-List").css('pointer-events', "visible");			$("#Main_Left-List").css('opacity', 1);
	$("#Main_Right-List").css('pointer-events', "visible");			$("#Main_Right-List").css('opacity', 1);
	$("#Main_Bottom-Information").css('pointer-events', "visible");	$("#Main_Bottom-Information").css('opacity', 1);
};
Dialog.prototype._CommonDisabled_ = function()
{
	$("#Main_Top-FunctionWizard").css('pointer-events', "none");			$("#Main_Top-FunctionWizard").css('opacity', 0.5);
	$("#Main_Top-StepFlow").css('pointer-events', "none");		$("#Main_Top-StepFlow").css('opacity', 0.5);
	$("#Main_Top-Menu").css('pointer-events', "none");			$("#Main_Top-Menu").css('opacity', 0.5);
	$("#Main_Top-Path").css('pointer-events', "none");			$("#Main_Top-Path").css('opacity', 0.5);
	$("#Main_Left-List").css('pointer-events', "none");			$("#Main_Left-List").css('opacity', 0.5);
	$("#Main_Right-List").css('pointer-events', "none");		$("#Main_Right-List").css('opacity', 0.5);
	$("#Main_Bottom-Information").css('pointer-events', "none");$("#Main_Bottom-Information").css('opacity', 0.5);
};

GetValue.prototype._GetRuntimeVariableName_ = function(ModuleType, ModuleIndex, VariableIndex)
{
	var Return;
	var GlobalModule=GetValue.prototype._GetGlobalModule_(ModuleType);
	var GlobalVariable=GetValue.prototype._GetGlobalVariable_(ModuleType);
	if(ModuleType == "Internal") 
	{
		var ModuleName = GetValue.prototype._GetRegisterModuleName_(GlobalModule, ModuleIndex);
	}
	else
	{
		var ModuleName=GetValue.prototype._GetModuleName_(GlobalModule, ModuleIndex);
	}
	var VariabName=GetValue.prototype._GetModuleVariableName_(GlobalVariable, ModuleIndex, VariableIndex);
	if(ModuleType == "Internal")
	{
		Return=ModuleType+"_No."+ModuleIndex+"_"+ModuleName+"."+VariabName;
	}
	else
	{
		Return=ModuleType+"_No."+ModuleIndex+"_"+ModuleName+"_"+VariableIndex.split("-")[0]+"."+VariabName;
	}
	return Return;
};

GetValue.prototype._GetRuntimeScalingVariableName_ = function(ModuleType, ModuleIndex, VariableIndex)
{
	var Return; var GlobalVariable;
	if( ModuleType == "MRTU" ) GlobalVariable = Global_RtuScalingVariable;
	if( ModuleType == "MTCP" ) GlobalVariable = Global_TcpScalingVariable;
	var GlobalModule=GetValue.prototype._GetGlobalModule_(ModuleType);
	var ModuleName=GetValue.prototype._GetModuleName_(GlobalModule, ModuleIndex);
	var VariabName=GetValue.prototype._GetModuleScalingVariableName_(GlobalVariable, ModuleIndex, VariableIndex);
	Return=ModuleType+"_No."+ModuleIndex+"_"+ModuleName+"_"+VariableIndex.split("-")[0]+"_Scale"+"."+VariabName;
	return Return;
};
GetValue.prototype._GetRuntimeBitwiseVariableName_ = function(BitwiseTag, ModuleType, ModuleIndex, VariableIndex)
{
	var Return; var GlobalVariable;
	if( ModuleType == "MRTU" ) GlobalVariable = Global_RtuBitwiseVariable;
	if( ModuleType == "MTCP" ) GlobalVariable = Global_TcpBitwiseVariable;
	var GlobalModule=GetValue.prototype._GetGlobalModule_(ModuleType);
	var ModuleName=GetValue.prototype._GetModuleName_(GlobalModule, ModuleIndex);
	var VariabNameExist=GetValue.prototype._GetModuleBitwiseVariableName_(GlobalVariable, BitwiseTag, ModuleIndex, VariableIndex);
	if(VariabNameExist == true) var VariabName = BitwiseTag;
	else                        return Return;
	Return=ModuleType+"_No."+ModuleIndex+"_"+ModuleName+"_"+VariableIndex.split("-")[0]+"_Bitwise"+"."+VariabName;
	return Return;
};
GetValue.prototype._GetModuleAllDeviceName_ = function(GlobalModule)
{
	var Return=new Array();
	if(typeof(GlobalModule) != "object")	{return 0;}
	var Return=Object.keys(GlobalModule);
	return Return;
};
GetValue.prototype._GetModuleDeviceName_ = function(GlobalModule, ModuleNumber)
{
	var Return;
	if(typeof(GlobalModule) != "object")	{return 0;}
	var DeviceName=Object.keys(GlobalModule);
	for(var i=0; i<DeviceName.length; i++)
	{
		var array=Object.keys(GlobalModule[DeviceName[i]]);
		if(array.indexOf(ModuleNumber) != -1)
		{
			Return=DeviceName[i];
		}
	}
	return Return;
};
GetValue.prototype._GetModuleAllNumber_ = function(GlobalModule)
{
	var Return=new Array();
	if(typeof(GlobalModule) != "object")	{return 0;}
	var AllDevice=Object.keys(GlobalModule);
	for(var i=0; i<AllDevice.length; i++)
	{
		var number=Object.keys(GlobalModule[AllDevice[i]]);
		Return = Return.concat(number);
	}
	return Return;
};
GetValue.prototype._GetModuleName_ = function(GlobalModule, ModuleNumber)
{
	var Return="";
	if(typeof(GlobalModule) != "object")	{return Return;}

	var AllDevice=Object.keys(GlobalModule);
	for(var i=0; i<AllDevice.length; i++)
	{
		var number=Object.keys(GlobalModule[AllDevice[i]]);
		for(var j=0; j<number.length; j++)
		{
			if(number[j].indexOf(ModuleNumber) != -1)
			{
				Return=GlobalModule[AllDevice[i]][number[j]]["ModuleName"];
				return Return;
			}
		}
	}
};
GetValue.prototype._GetRegisterModuleName_ = function(GlobalModule, ModuleNumber)
{
	var Return="";
	if(typeof(GlobalModule) != "object")	{return Return;}

		var number=Object.keys(GlobalModule);
		for(var j=0; j<number.length; j++)
		{
			if(number[j].indexOf(ModuleNumber) != -1)
			{
				Return=GlobalModule[number[j]]["ModuleName"];
				return Return;
			}
		}

};
GetValue.prototype._GetGlobalModule_ = function(ModuleType)
{
	var Return;
	if(ModuleType=="MRTU")			{Return=Global_RtuModule;}
	else if(ModuleType=="MTCP")		{Return=Global_TcpModule;}
	else if(ModuleType=="MASCII")	{Return=Global_AsciiModule;}
	else if(ModuleType=="MQTT")		{Return=Global_MqttModule;}
	else if(ModuleType=="EIP")		{Return=Global_EipModule;}
	else if(ModuleType=="Internal")	{Return=Global_RegisterModule;}
	else if(ModuleType=="MRTU Scaling")	{Return=Global_RtuModule;}
	else if(ModuleType=="MTCP Scaling")	{Return=Global_TcpModule;}
	return Return;
};
GetValue.prototype._GetGlobalVariable_ = function(ModuleType)
{
	var Return;
	if(ModuleType=="MRTU")			{Return=Global_RtuVariable;}
	else if(ModuleType=="MTCP")		{Return=Global_TcpVariable;}
	else if(ModuleType=="MASCII")	{Return=Global_AsciiVariable;}
	else if(ModuleType=="MQTT")		{Return=Global_MqttVariable;}
	else if(ModuleType=="EIP")		{Return=Global_EipVariable;}
	else if(ModuleType=="Internal")	{Return=Global_RegisterVariable;}
	else if(ModuleType=="MRTU Scaling")	{Return=Global_RtuScalingVariable;}
	else if(ModuleType=="MTCP Scaling")	{Return=Global_TcpScalingVariable;}
	return Return;
};
GetValue.prototype._GetModuleVariableAttribute_ = function(Attribute, Type)
{
	var Return;
	if(Attribute=="Read" && Type=="Bool")               {Return="DI";}
	else if(Attribute=="ReadWrite" && Type=="Bool")     {Return="DO";}
	else if(Attribute=="Read" && Type!="Bool")          {Return="AI";}
	else if(Attribute=="ReadWrite" && Type!="Bool")     {Return="AO";}
	return Return;
};
GetValue.prototype._GetModuleVariableReadWrite_ = function(Attribute)
{
	var Return;
	if(Attribute=="DI")        {Return="Read";}
	else if(Attribute=="DO")   {Return="ReadWrite";}
	else if(Attribute=="AI")   {Return="Read";}
	else if(Attribute=="AO")   {Return="ReadWrite";}
	return Return;
};
GetValue.prototype._GetModuleVariableIndex_ = function(GlobalVariable, ModuleNumber, PrefixVariableIndex, VariableName)
{
	var Return="";
	if(typeof(GlobalVariable) != "object" || 
	   typeof(GlobalVariable[ModuleNumber]) != "object")
	{
		return Return;
	}
	var VariableList=Object.keys(GlobalVariable[ModuleNumber]);
	for(var i=0; i<VariableList.length; i++)
	{
		var Name=GlobalVariable[ModuleNumber][VariableList[i]]["VariableName"];
		if(Name == VariableName && VariableList[i].indexOf(PrefixVariableIndex)!=-1)
		{
			Return=VariableList[i];
			break;
		}
	}
	return Return;
};
GetValue.prototype._GetModuleAllVariableIndex_ = function(ModuleType, ModuleNumber)
{
	var GlobalVariable=GetValue.prototype._GetGlobalVariable_(ModuleType);
	if(typeof(GlobalVariable[ModuleNumber]) != "object"){return 0;}
	
	var Class=new Algorithm();
	var Return=Object.keys(GlobalVariable[ModuleNumber]).sort(Class.StringNumberMixedSort());
	return Return;
};
GetValue.prototype._GetModuleVariableName_ = function(GlobalVariable, ModuleNumber, VariableIndex)
{
	var Return="";
	var array=VariableIndex.split("-");
	if(array.length != 3)
	{
		return Return;
	}
	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]]["VariableName"];
			break;
		}
	}
	return Return;
};
GetValue.prototype._GetModulePidScalingVariableName_ = function(GlobalVariable, ModuleNumber, VariableIndex)
{
	var Return="";
	var array=VariableIndex.split(".");
	if(array.length != 2)
	{
		return Return;
	}
	var VariableList=Object.keys(GlobalVariable[ModuleNumber]);
	for(var i=0; i<VariableList.length; i++)
	{
		if(VariableList[i].indexOf(array[0]) != -1)
		{
			Return=GlobalVariable[ModuleNumber][VariableList[i]]["ScaleVariableName"];
			break;
		}
	}
	return Return;
};
GetValue.prototype._GetModuleScalingVariableName_ = function(GlobalVariable, ModuleNumber, VariableIndex)
{
 var Return="";
 var array=VariableIndex.split("-");
 if(array.length != 3)
 {
  return Return;
 }
 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;
};


GetValue.prototype._GetBitwiseVariableFromGlobal_ = function(GlobalVariable, BitwiseTag)
{
	var Return=""; var BitNameId="";
	var ObjectKey = Object.keys(GlobalVariable);
	for(var i=0; i<ObjectKey.length; i++)
	{
		if(GlobalVariable[ObjectKey[i]] == BitwiseTag)
		{
			Return = BitwiseTag;
			break;
		}
	}
	return Return;
};
GetValue.prototype._GetModuleBitwiseVariableName_ = function(GlobalVariable, BitwiseTag, ModuleIndex, VariableIndex)
{
	var Return=false; 
	var VariableName; var Index = 0;
	var array=VariableIndex.split("-");
	if(array.length != 3)
	{
		return Return;
	}
	var VariableList=Object.keys(GlobalVariable[ModuleIndex]);
	for(var i=0; i<VariableList.length; i++)
	{
		if(VariableList[i].indexOf(VariableIndex) != -1)
		{
			VariableName = GetValue.prototype._GetBitwiseVariableFromGlobal_(GlobalVariable[ModuleIndex][VariableIndex], BitwiseTag);
			if( (VariableName != null) && (VariableName != '') )
			{
				Return=true;
				break;
			}
		}
	}
	return Return;
};
GetValue.prototype._GetModuleVariableNameArray_ = 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]+"-"+array[1]+"-";
	var VariableList=Object.keys(GlobalVariable[ModuleNumber]);
	for(var i=0; i<VariableList.length; i++)
	{
		if(VariableList[i].indexOf(VariableIndex) != -1)
		{
			Return.push(GlobalVariable[ModuleNumber][VariableList[i]]["VariableName"]);
		}
	}
	return Return;
};
GetValue.prototype._GetModuleAllVariableName_ = function(ModuleType, ModuleNumber, VariableIndexArray)
{
	var Return=new Array();
	var GlobalVariable=GetValue.prototype._GetGlobalVariable_(ModuleType);
	for(var i=0; i<VariableIndexArray.length; i++)
	{
		var VariableName=GlobalVariable[ModuleNumber][VariableIndexArray[i]]["VariableName"];
		Return.push(VariableName);
	}
	return Return;
};
GetValue.prototype._GetArrayComplement_ = function(FirstArray, SecondArray)
{
	var Return=new Array();
	for(var i=0; i<FirstArray.length; i++){
		if(SecondArray.indexOf(FirstArray[i]) == -1){
			Return.push(FirstArray[i]);
		}
	}
	return Return;
};
GetValue.prototype._GetArrayInteraction_ = function(FirstArray, SecondArray)
{
	var Return=new Array();
	for(var i=0; i<FirstArray.length; i++){
		if(SecondArray.indexOf(FirstArray[i]) != -1){
			Return.push(FirstArray[i]);
		}
	}
	return Return;
};

GetValue.prototype._ComPortCallback_ = function(ssocket, Callback)
{
	var Class=new Transmission();
	var JsonString1 = JSON.stringify(Global_ComPort);
	
	var Callback1=function(){Class.TransmissionJson(ssocket, "SaveComPortSetting", JsonString1, Callback);}
	return Callback1;
};

GetValue.prototype._RtuModuleCallback_ = function(ssocket, Callback)
{
	var Class=new Transmission();
	var JsonString1 = JSON.stringify(Global_RtuIndex);
	var JsonString2 = JSON.stringify(Global_RtuModule);
	var JsonString3 = JSON.stringify(Global_RtuVariable);
	var JsonString4 = JSON.stringify(Global_RtuSetting);

	var Callback1=function(){Class.TransmissionJson(ssocket, "SaveRtuIndex", JsonString1, Callback);}
	var Callback2=function(){Class.TransmissionJson(ssocket, "SaveRtuModule", JsonString2, Callback1);}
	var Callback3=function(){Class.TransmissionJson(ssocket, "SaveRtuVariable", JsonString3, Callback2);}
	var Callback4=function(){Class.TransmissionJson(ssocket, "SaveRtuSetting", JsonString4, Callback3);}

	return Callback4;
};

GetValue.prototype._TcpModuleCallback_ = function(ssocket, Callback)
{
	var Class=new Transmission();
	var JsonString1 = JSON.stringify(Global_TcpIndex);
	var JsonString2 = JSON.stringify(Global_TcpModule);
	var JsonString3 = JSON.stringify(Global_TcpVariable);
	var JsonString4 = JSON.stringify(Global_TcpSetting);

	var Callback1=function(){Class.TransmissionJson(ssocket, "SaveTcpIndex", JsonString1, Callback);}
	var Callback2=function(){Class.TransmissionJson(ssocket, "SaveTcpModule", JsonString2, Callback1);}
	var Callback3=function(){Class.TransmissionJson(ssocket, "SaveTcpVariable", JsonString3, Callback2);}
	var Callback4=function(){Class.TransmissionJson(ssocket, "SaveTcpSetting", JsonString4, Callback3);}
	
	return Callback4;
};

GetValue.prototype._AsciiModuleCallback_ = function(ssocket, Callback)
{
	var Class=new Transmission();
	var JsonString1 = JSON.stringify(Global_AsciiIndex);
	var JsonString2 = JSON.stringify(Global_AsciiModule);
	var JsonString3 = JSON.stringify(Global_AsciiVariable);
	var JsonString4 = JSON.stringify(Global_AsciiSetting);

	var Callback1=function(){Class.TransmissionJson(ssocket, "SaveAsciiIndex", JsonString1, Callback);}
	var Callback2=function(){Class.TransmissionJson(ssocket, "SaveAsciiModule", JsonString2, Callback1);}
	var Callback3=function(){Class.TransmissionJson(ssocket, "SaveAsciiVariable", JsonString3, Callback2);}
	var Callback4=function(){Class.TransmissionJson(ssocket, "SaveAsciiSetting", JsonString4, Callback3);}

	return Callback4;
};

GetValue.prototype._MqttModuleCallback_ = function(ssocket, Callback)
{	
	var Class=new Transmission();
	var JsonString1 = JSON.stringify(Global_MqttIndex);
	var JsonString2 = JSON.stringify(Global_MqttModule);
	var JsonString3 = JSON.stringify(Global_MqttVariable);
	var JsonString4 = JSON.stringify(Global_MqttSetting);

	var Callback1=function(){Class.TransmissionJson(ssocket, "SaveMqttIndex", JsonString1, Callback);}
	var Callback2=function(){Class.TransmissionJson(ssocket, "SaveMqttModule", JsonString2, Callback1);}
	var Callback3=function(){Class.TransmissionJson(ssocket, "SaveMqttVariable", JsonString3, Callback2);}
	var Callback4=function(){Class.TransmissionJson(ssocket, "SaveMqttSetting", JsonString4, Callback3);}

	return Callback4;
};

GetValue.prototype._AllModuleToOpcuaCallback_ = function(ssocket, Callback)
{
	var Class=new Transmission();
	var JsonString1 = JSON.stringify(Global_RtuToOpcuaVariable);
	var JsonString2 = JSON.stringify(Global_TcpToOpcuaVariable);
	var JsonString3 = JSON.stringify(Global_AsciiToOpcuaVariable);
	var Callback1=function(){Class.TransmissionJson(ssocket, "SaveRtuToOpcuaVariable", JsonString1, Callback);}
	var Callback2=function(){Class.TransmissionJson(ssocket, "SaveTcpToOpcuaVariable", JsonString2, Callback1);}
	var Callback3=function(){Class.TransmissionJson(ssocket, "SaveAsciiToOpcuaVariable", JsonString3, Callback2);}

	return Callback3;
};

GetValue.prototype._PidOperationCallback_ = function(ssocket, Callback)
{
	var Class=new Transmission();
	var JsonString1 = JSON.stringify(Global_PidOperation);
	var Callback1 = function(){Class.TransmissionJson(ssocket, "SavePidOperationVariable", JsonString1, Callback);}

	return Callback1;
};

GetValue.prototype._IftttConditionTriggerCallback_ = function(ssocket, Callback)
{
	var Class=new Transmission();
	var JsonString1 = JSON.stringify(Global_IftttConditionTriggerSetting);
	var JsonString2 = JSON.stringify(Global_IftttConditionTriggerVariable);
	var Callback1=function(){Class.TransmissionJson(ssocket, "SaveIftttConditionTriggerSetting", JsonString1, Callback);}
	var Callback2=function(){Class.TransmissionJson(ssocket, "SaveIftttConditionTriggerVariable", JsonString2, Callback1);}

	return Callback2;
};

GetValue.prototype._VariableTableXmlCallback_ = function(ssocket, Callback)
{
	var Class=new Transmission();
	var ClassXml=new JsonTransformXml();
	var Xml = ClassXml.TransformVariableXml();
	var Callback1 = function(){Class.TransmissionJson(ssocket, "SaveVariableTableXml", Xml, Callback);}
	return Callback1;
};

GetValue.prototype._ModbusDriCallback_ = function(ssocket, Callback)
{	
	var Class=new Transmission();
	var ClassXml=new JsonTransformXml();
	var Xml = ClassXml.TransformModbusDri();
	var Callback1 = function(){Class.TransmissionJson(ssocket, "SaveModbusDri", Xml, Callback);}
	return Callback1;
};

GetValue.prototype._UAServerDataXmlCallback_ = function(ssocket, Callback)
{	
	var Class=new Transmission();
	var ClassXml=new JsonTransformXml();
	var Xml = ClassXml.TransformUAServerDataXml();
	var Callback1 = function(){Class.TransmissionJson(ssocket, "SaveUAServerDataXml", Xml, Callback);}
	return Callback1;
};

GetValue.prototype._PidDriverDriCallback_ = function(ssocket, Callback)
{	
	var Class=new Transmission();
	var ClassXml=new JsonTransformXml();
	var Xml = ClassXml.TransformPidDriverDri();
	var Callback1 = function(){Class.TransmissionJson(ssocket, "SavePidDriverDri", Xml, Callback);}
	return Callback1;
};

GetValue.prototype._MethodTableXmlCallback_ = function(ssocket, Callback)
{	
	var Class=new Transmission();
	var ClassXml=new JsonTransformXml();
	var Xml = ClassXml.TransformMethodTableXml();
	var Callback1 = function(){Class.TransmissionJson(ssocket, "SaveMethodTableXml", Xml, Callback);}
	return Callback1;
};

GetValue.prototype._MqttServiceXmlCallback_ = function(ssocket, Callback)
{	
	var Class=new Transmission();
	var ClassXml=new JsonTransformXml();
	var Xml = ClassXml.TransformMqttServiceXml();
	var Callback1 = function(){Class.TransmissionJson(ssocket, "SaveMQTTServiceXml", Xml, Callback);}
	return Callback1;
};

GetValue.prototype._MqttDriCallback_ = function(ssocket, Callback)
{	
	var Class=new Transmission();
	var ClassXml=new JsonTransformXml();
	var Xml = ClassXml.TransformMqttDri();
	var Callback1 = function(){Class.TransmissionJson(ssocket, "SaveMqttDri", Xml, Callback);}
	return Callback1;
};

GetValue.prototype._CgiUrl_ = function()
{
	var PathName = location.pathname;
	var Return = "";
	if(PathName == "/" || PathName == "/Main.html")
	{
		Return = location.protocol+"//"+location.hostname+"/";
	}
	else
	{
		Return = location.protocol+"//"+location.hostname+PathName.replace("Main.html","");
	}
	return Return;
};

GetValue.prototype._SocketIo_ = function()
{
	var PathName = location.pathname;
	var Return = "";
	if(PathName == "/" || PathName == "/Main.html")
	{
		Return = io.connect();
	}
	else
	{
		PathName = PathName.replace("Main.html","") + 'socket.io';
		Return = io.connect(location.origin, {"path": PathName.toString(), "transports":['polling', "xhr-polling"]});
	}
	return Return;
};

Judgment.prototype._IsSaveRtuMasterModuleGlobalVariable_ = function()
{
	var Return=false;
	var Class = new LoadFile();
	var Index = Class.ReadFile("./File/RTU_Module/Index.json", new Array());
	var Module = Class.ReadFile("./File/RTU_Module/Module.json", new Object());
	var Variable = Class.ReadFile("./File/RTU_Module/RtuVariable.json", new Object());
	var Setting = Class.ReadFile("./File/RTU_Module/RtuSetting.json", new Object());
	
	if(JSON.stringify(Index)==JSON.stringify(Global_RtuIndex) &&
	   JSON.stringify(Module)==JSON.stringify(Global_RtuModule) &&
	   JSON.stringify(Variable)==JSON.stringify(Global_RtuVariable) &&
	   JSON.stringify(Setting)==JSON.stringify(Global_RtuSetting))
	{
		Return=true;
	}
	return Return;
};

Judgment.prototype._IsSaveTcpMasterModuleGlobalVariable_ = 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());
	
	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))
	{
		Return=true;
	}
	return Return;
};

Judgment.prototype._IsSaveAsciiMasterModuleGlobalVariable_ = function()
{
	var Return=false;
	var Class = new LoadFile();
	var Index = Class.ReadFile("./File/ASCII_Module/Index.json", new Array());
	var Module = Class.ReadFile("./File/ASCII_Module/Module.json", new Object());
	var Variable = Class.ReadFile("./File/ASCII_Module/AsciiVariable.json", new Object());
	var Setting = Class.ReadFile("./File/ASCII_Module/AsciiSetting.json", new Object());
	
	if(JSON.stringify(Index)==JSON.stringify(Global_AsciiIndex) &&
	   JSON.stringify(Module)==JSON.stringify(Global_AsciiModule) &&
	   JSON.stringify(Variable)==JSON.stringify(Global_AsciiVariable) &&
	   JSON.stringify(Setting)==JSON.stringify(Global_AsciiSetting))
	{
		Return=true;
	}
	return Return;
};

Judgment.prototype._IsSaveMqttModuleGlobalVariable_ = function()
{
	var Return=false;
	var Class = new LoadFile();
	var Index = Class.ReadFile("./File/MQTT_Module/Index.json", new Array());
	var Module = Class.ReadFile("./File/MQTT_Module/Module.json", new Object());
	var Variable = Class.ReadFile("./File/MQTT_Module/MqttVariable.json", new Object());
	var Setting = Class.ReadFile("./File/MQTT_Module/MqttSetting.json", new Object());
	
	if(JSON.stringify(Index)==JSON.stringify(Global_MqttIndex) &&
	   JSON.stringify(Module)==JSON.stringify(Global_MqttModule) &&
	   JSON.stringify(Variable)==JSON.stringify(Global_MqttVariable) &&
	   JSON.stringify(Setting)==JSON.stringify(Global_MqttSetting))
	{
		Return=true;
	}
	return Return;
};

Judgment.prototype._IsSaveRemoteBrokerGlobalVariable_ = function()
{
	var Return = false;
	var Class = new LoadFile();
	var RemoteBroker = Class.ReadFile("./File/IoT_Platform/RemoteBroker.json", new Object());
	
	if(JSON.stringify(RemoteBroker)	== JSON.stringify(Global_RemoteBroker))
	{
		Return = true;
	}
	return Return;
};

Judgment.prototype._IsSaveLocalBrokerGlobalVariable_ = function()
{
	var Return = false;
	var Class = new Cgi();
	var array = Class.RestApi("GetLocalBrokerSetting", new Array(), false);
	if(typeof(array) == "string")
	{
		var LocalBroker = Transform.prototype._ArrayStringToArray_(JSON.stringify(Global_LocalBroker));
		if(JSON.stringify(array) == JSON.stringify(LocalBroker))
		{
			Return = true;
		}
	}
	else
	{
		if(JSON.stringify(array) == JSON.stringify(Global_LocalBroker))  {Return = true;}
	}
	return Return;
};

Judgment.prototype._IsSaveOpcUaLocalServerGlobalVariable_ = function()
{	
	var Return = false;
	var Class = new LoadFile();
	var OpcUaLocalServer = Class.ReadXmlObject("./File/IoT_Platform/UAServerConfig.xml", new Object());
	
	if(JSON.stringify(OpcUaLocalServer)	== JSON.stringify(Global_OpcUaLocalServer))
	{
		Return = true;
	}
	return Return;
};

Transmission.prototype._TransmissionArray_ = function(Command, array, Result)
{
	var GetClass = new GetValue();
	var ssocket = GetClass.SocketIo();
	ssocket.emit(Command, array);
	ssocket.on(Command, function (Return)
	{
		Result["Input"] = Return;
		ssocket.emit("SocketClose");
	});
};

Transmission.prototype._TransmissionString_ = function(Command, string, Result)
{
	var GetClass = new GetValue();
	var ssocket = GetClass.SocketIo();
	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")
		{
			Result["Input"] = true;
			ssocket.emit("SocketClose");
		}
	});
};

Transmission.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();
		}
	});
};

Transmission.prototype._SaveOpcUaLocalServer_ = function()
{
	var xotree = new XML.ObjTree();
	var xml = xotree.writeXML(Global_OpcUaLocalServer);
	var array = new Array(xml);
	var GetClass = new GetValue();
	var ssocket = GetClass.SocketIo();
	ssocket.emit("SaveOpcUaLocalServer", array);
	ssocket.on('SaveOpcUaLocalServer', function (Return) {
		ssocket.emit("SocketClose");
	});
};

Transmission.prototype._SaveLocalBrokerSetting_ = function()
{
	var array = Global_LocalBroker;
	var GetClass = new GetValue();
	var ssocket = GetClass.SocketIo();
	ssocket.emit("SaveLocalBrokerSetting", array);
	ssocket.on('SaveLocalBrokerSetting', function (Return) {
		ssocket.emit("SocketClose");
	});
};

Transmission.prototype._SaveRemoteBrokerSetting_ = function()
{
	var array = new Array(Global_RemoteBroker);
	var GetClass = new GetValue();
	var ssocket = GetClass.SocketIo();
	ssocket.emit("SaveRemoteBrokerSetting", array);
	ssocket.on('SaveRemoteBrokerSetting', function (Return) {
		ssocket.emit("SocketClose");
	});
};

ClearService.prototype._DeleteModuleClearService_ = function(ModuleType, ModuleIndex)
{
	ClearService.prototype._ClearPidOperation_(ModuleType, ModuleIndex);
	ClearService.prototype._ClearIftttConditionTrigger_(ModuleType, ModuleIndex);
}
ClearService.prototype._ClearPidOperation_ = function(ModuleType, ModuleIndex, VariableIndex)
{
	var InputIndex, OutputIndex, Variable=Global_PidOperation, ModuleClear=null;
	if(typeof(VariableIndex) == "undefined"){
		ModuleClear=ModuleType+"/"+ModuleIndex;
	}
	var VariableClear=new Array();
	if(typeof(VariableIndex) == "object"){
		for(var i=0; i<VariableIndex.length; i++){
			VariableClear.push(ModuleType+"/"+ModuleIndex+"/"+VariableIndex[i]);
		}
	}
	var PidNumber=Object.keys(Variable);
	for(var i=0; i<PidNumber.length; i++){
		InputIndex = Variable[PidNumber[i]]["InputModuleVariableIndex"];
		OutputIndex = Variable[PidNumber[i]]["OutputModuleVariableIndex"];
		if(InputIndex.indexOf(ModuleClear)!=-1 || VariableClear.indexOf(InputIndex)!=-1)
		{
			Variable[PidNumber[i]]["InputModuleVariableIndex"]="//";
		}
		if(OutputIndex.indexOf(ModuleClear)!=-1 || VariableClear.indexOf(OutputIndex)!=-1)
		{
			Variable[PidNumber[i]]["OutputModuleVariableIndex"]="//";
		}
	}
};
ClearService.prototype._ClearIftttConditionTrigger_ = function(ModuleType, ModuleIndex, VariableIndex)
{
	var InputIndex, OutputIndex, Variable=Global_IftttConditionTriggerVariable, ModuleClear=null;
	if(typeof(VariableIndex) == "undefined"){
		ModuleClear=ModuleType+"/"+ModuleIndex
	}
	var VariableClear=new Array();
	if(typeof(VariableIndex) == "object"){
		for(var i=0; i<VariableIndex.length; i++){
			VariableClear.push(ModuleType+"/"+ModuleIndex+"/"+VariableIndex[i]);
		}
	}
	var number=Object.keys(Variable);
	for(var i=0; i<number.length; i++){
		IndexValue = Variable[number[i]]["IndexValue"];
		for(var j=0; j<IndexValue.length; j++)
		{
			if(IndexValue[j].indexOf(ModuleClear)!=-1 || VariableClear.indexOf(IndexValue[j])!=-1)
			{
				Variable[number[i]]["IndexValue"].splice(j,1);
				Variable[number[i]]["Condition"].splice(j,1);
				Variable[number[i]]["DefineMessage"].splice(j,1);
				j--;
			}
		}
	}
};

SynchronizeService.prototype._ChangeVariableSynchronizationService_ = function(ModuleType, OldObject, NewObject, number)
{
	SynchronizeService.prototype._SynchronizePidOperation_(ModuleType, OldObject, NewObject, number);
	SynchronizeService.prototype._SynchronizeIftttConditionTrigger_(ModuleType, OldObject, NewObject, number);
}
SynchronizeService.prototype._SynchronizePidOperation_ = function(ModuleType, OldObject, NewObject, number)
{	
	if(typeof(OldObject[number]) != "object" || typeof(NewObject[number]) != "object")
	{
		return 0;
	}
	var NewArray=Object.keys(NewObject[number]);
	var OldArray=Object.keys(OldObject[number]);
	var array=GetValue.prototype._GetArrayComplement_(OldArray, NewArray);
	var Class=new ClearService();
	Class.ClearPidOperation(ModuleType, number, array);
	Class=null;
};
SynchronizeService.prototype._SynchronizeIftttConditionTrigger_ = function(ModuleType, OldObject, NewObject, number)
{	
	if(typeof(OldObject[number]) != "object" || typeof(NewObject[number]) != "object")
	{
		return 0;
	}
	var NewArray=Object.keys(NewObject[number]);
	var OldArray=Object.keys(OldObject[number]);
	var array=GetValue.prototype._GetArrayComplement_(OldArray, NewArray);
	var Class=new ClearService();
	Class.ClearIftttConditionTrigger(ModuleType, number, array);
	Class=null;
};

Algorithm.prototype._StringNumberMixedSort_ = function()
{
	//https://stackoverflow.com/questions/2802341/javascript-natural-sort-of-alphanumerical-strings
	var Callback=function (a,b){return a.localeCompare(b, undefined, {numeric: true, sensitivity: 'base'});};
	return Callback;
};
//CGI
Cgi.prototype._Ajax_ = function(Url, Type, Async, Cache, Input)
{
	var Return = "";
	$.ajax({
		url: Url,
		type:Type,
		async: Async,
		cache: false,
		success: function(msg)
		{
			Return = msg;
			if(Async == true && typeof(Input) != "undefined")
			{
				Input["Input"] = msg;
			}
		},
		error:function(xhr, ajaxOptions, thrownError)
		{
			console.log("ajax error:["+xhr + ":" + ajaxOptions + ":" + thrownError+"]");
		}
	});
	return Return;
}

Cgi.prototype._RestApi_ = function(RestApi, ParameterArray, Async, Input)
{
	var Url = GetValue.prototype._CgiUrl_();
	Url = Url + "CGI?RestApi=" + RestApi + "&ParameterArray=";
	for(var i=0; i<ParameterArray.length; i++)
	{
		if(i == (ParameterArray.length-1))  {Url = Url + ParameterArray[i];}
		else                                {Url = Url + ParameterArray[i] + "$";}
	}
	var Return;
	if(Async == true)
	{
		Return = {Input:null};
		Cgi.prototype._Ajax_(Url, "GET", Async, false, Return);
		var SetInterval = setInterval(function(){
			if(Return["Input"] != null && typeof(Input) != "undefined")
			{
				clearInterval(SetInterval);
				Input["Input"] = Return["Input"];
			}
		},100);
	}
	else
	{
		Return = Cgi.prototype._Ajax_(Url, "GET", false, false);
	}
	return Return;
};
Cgi.prototype._Dbus_ = function(RestApi, ParameterArray, Async, Input)
{
	var Url = GetValue.prototype._CgiUrl_();
	Url = Url + "Dbus?RestApi="+ RestApi + "&ParameterArray=";
	for(var i=0; i<ParameterArray.length; i++)
	{
		if(i == (ParameterArray.length-1))  {Url = Url + ParameterArray[i];}
		else                                {Url = Url + ParameterArray[i] + "$";}
	}
	var Return;
	if(Async == true)
	{
		Return = {Input:null};
		Cgi.prototype._Ajax_(Url, "GET", Async, false, Return);
		var SetInterval = setInterval(function(){
			if(Return["Input"] != null && typeof(Input) != "undefined")
			{
				clearInterval(SetInterval);
				Input["Input"] = Return["Input"];
			}
		},100);
	}
	else
	{
		Return = Cgi.prototype._Ajax_(Url, "GET", false, false);
	}
	return Return;
};
Cgi.prototype._LoginStatus_ = function(LoginStatus, Async)
{
	if(typeof(LoginStatus) == "undefined")
	{
		LoginStatus="";
	}
	var Url = GetValue.prototype._CgiUrl_();
	Url = Url + "LoginStatus?Status="+LoginStatus;
	var Return = Cgi.prototype._Ajax_(Url, "GET", Async, false);
	return Return;
};

Cgi.prototype._TransferJsonString_ = function(RestApi, JsonString)
{
	var Return = "";  var Class = new Cgi();  var MaxLength=20000;  var Index=0;  var ParameterArray=new Array("Start","");
	Class.RestApi(RestApi, ParameterArray, false);
	var ArrayString = new Array();
	for(var i=0; i<JsonString.length; i=i+MaxLength){
		if(JsonString.length < MaxLength || i+MaxLength > JsonString.length)
		{
			ArrayString.push(JsonString.substring(i, JsonString.length));
			break;
		}
		else{
			ArrayString.push(JsonString.substring(i, i+MaxLength));
		}
	}
	for(var i=0; i<ArrayString.length; i++){
		if(i == (ArrayString.length - 1))
		{
			ParameterArray = new Array("End", ArrayString[i]);
		}
		else
		{
			ParameterArray = new Array("Send", ArrayString[i]);
		}
		var ReturnValue = Class.RestApi(RestApi, ParameterArray, false);
	}
	return Return;
};

Communication.prototype._PacketEncryption_ = function(Packet, Key)
{
	var textBytes = aesjs.utils.utf8.toBytes(Packet);
    var aesCtr = new aesjs.ModeOfOperation.ctr(Key, new aesjs.Counter(5));
    var encryptedBytes = aesCtr.encrypt(textBytes);
    var encryptedHex = aesjs.utils.hex.fromBytes(encryptedBytes);
    var encryptedBytes = aesjs.utils.hex.toBytes(encryptedHex);
    return encryptedBytes;
}

Communication.prototype._PacketDecryption_ = function(Packet, Key)
{
	try{
        var aesCtr = new aesjs.ModeOfOperation.ctr(Key, new aesjs.Counter(5));
        var decryptedBytes = aesCtr.decrypt(Packet);
        var decryptedText = aesjs.utils.utf8.fromBytes(decryptedBytes);
    }
    catch(error){
        return false;
    }
    try{
        decryptedText = JSON.parse(decryptedText);
    }
    catch(error){
    }
    return decryptedText;
}





















JsonTransformXml.prototype._TransformMethodTableXml_ = function()
{
	var Class = new LoadFile();
	var PidOperation = Class.ReadFile("./File/PID_Operation/PidOperation.json", new Object());
	var object=new Object();
	object["MethodTable"]=new Object();
	object["MethodTable"]["MethodName"]=new Array();
	var PidNumber = Object.keys(PidOperation);
	for(var i=0; i<PidNumber.length; i++)
	{
		if(PidOperation[PidNumber[i]]["InputModuleVariableIndex"] == "//" ||
		   PidOperation[PidNumber[i]]["OutputModuleVariableIndex"] == "//"){
			continue;
		}
		var RunMethodName="PID_"+PidOperation[PidNumber[i]]["Name"]+".Run";
		var StopMethodName="PID_"+PidOperation[PidNumber[i]]["Name"]+".Stop";
		object["MethodTable"]["MethodName"].push(RunMethodName);
		object["MethodTable"]["MethodName"].push(StopMethodName);
	}
	var xotree = new XML.ObjTree();
	var xml = xotree.writeXML(object);
	return xml;
}

JsonTransformXml.prototype._TransformPidDriverDri_ = function()
{
	var Class = new LoadFile();
	var PidOperation = Class.ReadFile("./File/PID_Operation/PidOperation.json", new Object());
	var object=new Object();
	object["PIDDriver"]=new Object();
	object["PIDDriver"]["PIDTask"]=new Array();
	var PIDTaskArray=new Array();
	var PidNumber = Object.keys(PidOperation);
	for(var i=0; i<PidNumber.length; i++)
	{
		if(PidOperation[PidNumber[i]]["InputModuleVariableIndex"] == "//" ||
		   PidOperation[PidNumber[i]]["OutputModuleVariableIndex"] == "//"){
			continue;
		}
		var obj=new Object();
		obj["TaskID"]=i;
		obj["InputVariable"]=new Object();
		var InputVariable=JsonTransformXml.prototype._GetPidModuleVariabName_(PidOperation[PidNumber[i]]["InputModuleVariableIndex"]);
		obj["InputVariable"]["VariableName"]=InputVariable;

		obj["OutputVariable"]=new Object();
		var OutputVariable=JsonTransformXml.prototype._GetPidModuleVariabName_(PidOperation[PidNumber[i]]["OutputModuleVariableIndex"]);
		obj["OutputVariable"]["VariableName"]=OutputVariable;
		
		obj["OutputMin"]=PidOperation[PidNumber[i]]["Min"];
		obj["OutputMax"]=PidOperation[PidNumber[i]]["Max"];
		
		obj["SetPoint"]=new Object();
		obj["SetPoint"]["VariableName"]="PID_"+PidOperation[PidNumber[i]]["Name"]+".SetPoint";
		
		obj["Kp"]=new Object();
		obj["Kp"]["VariableName"]="PID_"+PidOperation[PidNumber[i]]["Name"]+".Kp";
		
		obj["Ki"]=new Object();
		obj["Ki"]["VariableName"]="PID_"+PidOperation[PidNumber[i]]["Name"]+".Ki";
		
		obj["Kd"]=new Object();
		obj["Kd"]["VariableName"]="PID_"+PidOperation[PidNumber[i]]["Name"]+".Kd";
		
		obj["ControllerMode"]=new Object();
		obj["ControllerMode"]["VariableName"]="PID_"+PidOperation[PidNumber[i]]["Name"]+".ControllerMode";
		
		obj["SampleTime"]=new Object();
		obj["SampleTime"]["VariableName"]="PID_"+PidOperation[PidNumber[i]]["Name"]+".SampleTime";
		
		obj["AutoTune"]=new Object();
		obj["AutoTune"]["VariableName"]="PID_"+PidOperation[PidNumber[i]]["Name"]+".AutoTune";
		
		obj["Status"]=new Object();
		obj["Status"]["VariableName"]="PID_"+PidOperation[PidNumber[i]]["Name"]+".Status";
		
		obj["Method_Run"]=new Object();
		obj["Method_Run"]["MethodName"]="PID_"+PidOperation[PidNumber[i]]["Name"]+".Run";
		
		obj["Method_Stop"]=new Object();
		obj["Method_Stop"]["MethodName"]="PID_"+PidOperation[PidNumber[i]]["Name"]+".Stop";
		PIDTaskArray.push(obj);
	}
	object["PIDDriver"]["PIDTask"]=PIDTaskArray;	
	var xotree = new XML.ObjTree();
	var xml = xotree.writeXML(object);
	return xml;
}
JsonTransformXml.prototype._GetMqttCustomServiceTaskArray_ = function()
{
	var object = new Object();
	JsonTransformXml.prototype._GetMqttJsonGroupData_(object);
	JsonTransformXml.prototype._GetAzurePlatformData_(object);
	JsonTransformXml.prototype._InitialVariablePropertyDataType_(object);
	//JsonTransformXml.prototype._LinkRtuVariable_(object);
	//JsonTransformXml.prototype._LinkTcpVariable_(object);
	//JsonTransformXml.prototype._LinkAsciiVariable_(object);
	JsonTransformXml.prototype._LinkMqttCustomVariable_(object);
	var Return=JsonTransformXml.prototype._CreateMqttCustomServiceArray_(object);
	return Return;
}


JsonTransformXml.prototype._GetMqttServiceTaskJsonArray_ = function()
{
	var object = new Object();
	JsonTransformXml.prototype._GetMqttJsonGroupData_(object);
	JsonTransformXml.prototype._GetAzurePlatformData_(object);
	JsonTransformXml.prototype._InitialVariablePropertyDataType_(object);
	JsonTransformXml.prototype._LinkRtuVariable_(object);
	JsonTransformXml.prototype._LinkTcpVariable_(object);
	JsonTransformXml.prototype._LinkAsciiVariable_(object);
	var Return=JsonTransformXml.prototype._CreateMqttServiceTaskJsonArray_(object);
	return Return;
}
JsonTransformXml.prototype._CreateMqttCustomServiceArray_ = function(object)
{
	var Name=Object.keys(object);
	var MQTTServiceTask_Custom=new Array();
	for(var i=0; i<Name.length; i++)
	{
		for(var j=0; j<object[Name[i]]["Broker"].length; j++)
		{
			var Task=new Object();
			Task=new Object();
			Task["TaskID"] = 1;
			Task["ScanRate"] = object[Name[i]]["ScanRate"];
			Task["DeadBand"] = object[Name[i]]["DeadBand"];
			Task["WillTopic"] = object[Name[i]]["WillTopic"];
			Task["Will"] = object[Name[i]]["Will"];

			//Broker 
			Task["Broker"]=new Object();
			Task["Broker"]["IP"]        = object[Name[i]]["Broker"][j]["IP"];
			Task["Broker"]["Port"]      = object[Name[i]]["Broker"][j]["Port"];
			Task["Broker"]["Keepalive"] = object[Name[i]]["Broker"][j]["Keepalive"];
			Task["Broker"]["Username"]  = object[Name[i]]["Broker"][j]["Username"];
			Task["Broker"]["Password"]  = object[Name[i]]["Broker"][j]["Password"];
			Task["Broker"]["isSecure"]  = JsonTransformXml.prototype._GetSecureNumber_(object[Name[i]]["Broker"][j]["isSecure"]);
			//Task["Broker"]["CACertFile"] = object[Name[i]]["Broker"][j]["CaCertFile"];
			//Task["Broker"]["CertFile"]   = object[Name[i]]["Broker"][j]["CertFile"];
			//Task["Broker"]["KeyFile"]    = object[Name[i]]["Broker"][j]["KeyFile"];
			//Task["Broker"]["ClientId"]  = object[Name[i]]["Broker"][j]["ClientId"];
			
			
			Task["PubTopic"] = object[Name[i]]["PubTopic"];
			Task["PubQoS"] = object[Name[i]]["PubQoS"];
			Task["Retain"] = object[Name[i]]["Retain"];

			Task["Context"] = object[Name[i]]["CustomFormat"];
			if(Task["Context"] == null || Task["Context"] == "undefined" || Task["Context"] == "")
			{
				break;
			}
			MQTTServiceTask_Custom.push(Task);
		}
	}
	return MQTTServiceTask_Custom;
}


JsonTransformXml.prototype._CreateMqttServiceTaskJsonArray_ = function(object)
{
	var Name=Object.keys(object);
	var MQTTServiceTask_JSON=new Array();
	for(var i=0; i<Name.length; i++)
	{
		for(var j=0; j<object[Name[i]]["Broker"].length; j++)
		{
			var Task=new Object();
			Task=new Object();
			Task["Broker"]=new Object();
			Task["Broker"]["IP"]        = object[Name[i]]["Broker"][j]["IP"];
			Task["Broker"]["Port"]      = object[Name[i]]["Broker"][j]["Port"];
			Task["Broker"]["Keepalive"] = object[Name[i]]["Broker"][j]["Keepalive"];
			Task["Broker"]["Username"]  = object[Name[i]]["Broker"][j]["Username"];
			Task["Broker"]["Password"]  = object[Name[i]]["Broker"][j]["Password"];
			Task["Broker"]["isSecure"]  = JsonTransformXml.prototype._GetSecureNumber_(object[Name[i]]["Broker"][j]["isSecure"]);
			Task["Broker"]["CACertFile"] = object[Name[i]]["Broker"][j]["CaCertFile"];
			Task["Broker"]["CertFile"]   = object[Name[i]]["Broker"][j]["CertFile"];
			Task["Broker"]["KeyFile"]    = object[Name[i]]["Broker"][j]["KeyFile"];
			Task["Broker"]["ClientId"]  = object[Name[i]]["Broker"][j]["ClientId"];
			Task["TaskID"] = object[Name[i]]["TaskID"];
			Task["SubTopic"] = object[Name[i]]["SubTopic"];
			Task["SubQoS"] = object[Name[i]]["SubQoS"];
			Task["PubTopic"] = object[Name[i]]["PubTopic"];
			Task["PubQoS"] = object[Name[i]]["PubQoS"];
			Task["Retain"] = object[Name[i]]["Retain"];
			Task["ScanRate"] = object[Name[i]]["ScanRate"];
			Task["DeadBand"] = object[Name[i]]["DeadBand"];
			Task["WillTopic"] = object[Name[i]]["WillTopic"];
			Task["Will"] = object[Name[i]]["Will"];
			if(object[Name[i]]["Timestamp"] == true) Task["Timestamp"] = 1;
			else                                     Task["Timestamp"] = 0;

			if(object[Name[i]]["CustomFormatter"] == 101)
			{
				Task["CustomFormatter"]=object[Name[i]]["CustomFormatter"];
				Task["CDSData"]=new Object();
				Task["CDSData"]["CompanyId"]=object[Name[i]]["CDSData"]["CompanyId"];
				Task["CDSData"]["EquipmentId"]=object[Name[i]]["CDSData"]["EquipmentId"];
				Task["CDSData"]["MessageCatalogId"]=object[Name[i]]["CDSData"]["MessageCatalogId"];
			}
			
			Task["MQTTMapping"]=new Array();
			if(object[Name[i]]["VariableName"].length == 0)	{continue;}
			for(var k=0; k<object[Name[i]]["VariableName"].length; k++)
			{
				var MQTTMapping=new Object();
				MQTTMapping["Name"]     = object[Name[i]]["VariableName"][k];
				MQTTMapping["DataType"] = object[Name[i]]["DataType"][k];
				MQTTMapping["Property"] = object[Name[i]]["Property"][k];
				MQTTMapping["Alias"]    = object[Name[i]]["Alias"][k];
				Task["MQTTMapping"].push(MQTTMapping);
			}
			MQTTServiceTask_JSON.push(Task);
		}
	}
	return MQTTServiceTask_JSON;
}

JsonTransformXml.prototype._InitialVariablePropertyDataType_ = function(object)
{
	var Name=Object.keys(object);
	for(var i=0; i<Name.length; i++)
	{
		object[Name[i]]["VariableName"]=new Array();
		object[Name[i]]["Alias"]=new Array();
		object[Name[i]]["Property"]=new Array();
		object[Name[i]]["DataType"]=new Array();
	}
}

JsonTransformXml.prototype._LinkRtuVariable_ = function(object)
{
	var Name=Object.keys(object);
	var Class = new LoadFile();
	var JsonVariable = Class.ReadFile("./File/RTU_Module/RtuToMqttJsonVariable.json", new Object());
	var Module = Class.ReadFile("./File/RTU_Module/Module.json", new Object());
	var ModuleVariable = Class.ReadFile("./File/RTU_Module/RtuVariable.json", new Object());
	var number=Object.keys(JsonVariable);
	for(var i=0; i<number.length; i++)
	{
		var SystemVariable=Object.keys(JsonVariable[number[i]]);
		for(var j=0; j<SystemVariable.length; j++)
		{
			for(var k=0; k<Name.length; k++)
			{
				if(JsonVariable[number[i]][SystemVariable[j]]["TransformMqttJson"] == true && 
				   JsonVariable[number[i]][SystemVariable[j]]["ConnectionGroup"] == Name[k])
				{
					var ModuleName = JsonTransformXml.prototype._GetModuleName_(Module, number[i]);
					object[Name[k]]["VariableName"].push("MRTU_No."+number[i]+"_"+ModuleName+"_"+SystemVariable[j].split("-")[0]+"."+ModuleVariable[number[i]][SystemVariable[j]]["VariableName"]);
					object[Name[k]]["Alias"].push(JsonVariable[number[i]][SystemVariable[j]]["Alias"]);
					object[Name[k]]["Property"].push(JsonTransformXml.prototype._GetProperty_(SystemVariable[j].split("-")[0]));
					object[Name[k]]["DataType"].push(JsonTransformXml.prototype._GetDataType_(SystemVariable[j].split("-")[1]));
				}
			}
		}
	}
}

JsonTransformXml.prototype._LinkTcpVariable_ = function(object)
{
	var Name=Object.keys(object);
	var Class = new LoadFile();
	var JsonVariable = Class.ReadFile("./File/TCP_Module/TcpToMqttJsonVariable.json", new Object());
	var Module = Class.ReadFile("./File/TCP_Module/Module.json", new Object());
	var ModuleVariable = Class.ReadFile("./File/TCP_Module/TcpVariable.json", new Object());
	var number=Object.keys(JsonVariable);
	for(var i=0; i<number.length; i++)
	{
		var SystemVariable=Object.keys(JsonVariable[number[i]]);
		for(var j=0; j<SystemVariable.length; j++)
		{
			for(var k=0; k<Name.length; k++)
			{
				if(JsonVariable[number[i]][SystemVariable[j]]["TransformMqttJson"] == true && 
				   JsonVariable[number[i]][SystemVariable[j]]["ConnectionGroup"] == Name[k])
				{
					var ModuleName = JsonTransformXml.prototype._GetModuleName_(Module, number[i]);
					object[Name[k]]["VariableName"].push("MTCP_No."+number[i]+"_"+ModuleName+"_"+SystemVariable[j].split("-")[0]+"."+ModuleVariable[number[i]][SystemVariable[j]]["VariableName"]);
					object[Name[k]]["Alias"].push(JsonVariable[number[i]][SystemVariable[j]]["Alias"]);
					object[Name[k]]["Property"].push(JsonTransformXml.prototype._GetProperty_(SystemVariable[j].split("-")[0]));
					object[Name[k]]["DataType"].push(JsonTransformXml.prototype._GetDataType_(SystemVariable[j].split("-")[1]));
				}
			}
		}
	}
}

JsonTransformXml.prototype._LinkMqttCustomVariable_ = function(object)
{
	var Name=Object.keys(object);
	var Class = new LoadFile();
	var CustomVariable = Class.ReadFile("./File/RemoteMQTTGroup/RemoteMqttGroup.json", new Object());
	var number=Object.keys(CustomVariable);
	for(var i=0; i<Name.length; i++)
	{
		
		for(var k=0; k<number.length; k++)
		{
			if(CustomVariable[number[k]]["TransformMqttCustom"] == true && 
			   CustomVariable[number[k]]["ConnectionGroup"] == Name[i])
			{
				object[Name[i]]["CustomFormat"] = new Array();
				object[Name[i]]["CustomFormat"].push(CustomVariable[number[k]]["DataMessage"]);
			}
		}
	}
}

JsonTransformXml.prototype._LinkAsciiVariable_ = function(object)
{
	var Name=Object.keys(object);
	var Class = new LoadFile();
	var JsonVariable = Class.ReadFile("./File/ASCII_Module/AsciiToMqttJsonVariable.json", new Object());
	var Module = Class.ReadFile("./File/ASCII_Module/Module.json", new Object());
	var ModuleVariable = Class.ReadFile("./File/ASCII_Module/AsciiVariable.json", new Object());
	var number=Object.keys(JsonVariable);
	for(var i=0; i<number.length; i++)
	{
		var SystemVariable=Object.keys(JsonVariable[number[i]]);
		for(var j=0; j<SystemVariable.length; j++)
		{
			for(var k=0; k<Name.length; k++)
			{
				if(JsonVariable[number[i]][SystemVariable[j]]["TransformMqttJson"] == true && 
				   JsonVariable[number[i]][SystemVariable[j]]["ConnectionGroup"] == Name[k])
				{
					var ModuleName = JsonTransformXml.prototype._GetModuleName_(Module, number[i]);
					object[Name[k]]["VariableName"].push("MASCII_No."+number[i]+"_"+ModuleName+"_"+SystemVariable[j].split("-")[0]+"."+ModuleVariable[number[i]][SystemVariable[j]]["VariableName"]);
					object[Name[k]]["Alias"].push(JsonVariable[number[i]][SystemVariable[j]]["Alias"]);
					object[Name[k]]["Property"].push(JsonTransformXml.prototype._GetProperty_(SystemVariable[j].split("-")[0]));
					object[Name[k]]["DataType"].push(JsonTransformXml.prototype._GetDataType_(SystemVariable[j].split("-")[1]));
				}
			}
		}
	}
}

JsonTransformXml.prototype._SetMqttJsonGroupClient_ = function(object, MqttJsonGroup)
{
	object["Broker"] = new Array();
	object["TaskID"]   = -1;
	object["SubTopic"] = MqttJsonGroup["SubscribeTopic"];
	object["SubQoS"]   = MqttJsonGroup["SubscribeQos"];
	object["PubTopic"] = MqttJsonGroup["PublishTopic"];
	object["PubQoS"]   = MqttJsonGroup["PublishQos"];
	object["Retain"]   = MqttJsonGroup["Retain"];
	object["ScanRate"] = MqttJsonGroup["ScanRate"];
	object["DeadBand"] = MqttJsonGroup["DeadBand"];
	object["WillTopic"]= MqttJsonGroup["WillTopic"];
	object["Will"]     = MqttJsonGroup["Will"];
	object["Timestamp"]= MqttJsonGroup["Timestamp"];
}

JsonTransformXml.prototype._SetMqttJsonGroupLocalBroker_ = function(object, LocalBroker)
{
	var BrokerObject=new Object();
	BrokerObject["IP"]        = document.location.hostname;
	BrokerObject["Port"]      = LocalBroker["port"];
	BrokerObject["Username"]  = LocalBroker["account"];
	BrokerObject["Password"]  = LocalBroker["password"];
	BrokerObject["Keepalive"] = 60;
	BrokerObject["isSecure"]  = JsonTransformXml.prototype._GetSecureNumber_(LocalBroker["isSecure"]);
	object["Broker"].push(BrokerObject);
}

JsonTransformXml.prototype._SetMqttJsonGroupRemoteBroker_ = function(object, RemoteBroker)
{
	var BrokerObject=new Object();
	BrokerObject["IP"]        = RemoteBroker["IP"];
	BrokerObject["Port"]      = RemoteBroker["Port"];
	BrokerObject["Keepalive"] = RemoteBroker["Keepalive"];
	BrokerObject["isSecure"]  = JsonTransformXml.prototype._GetSecureNumber_(RemoteBroker["isSecure"]);
	BrokerObject["CaCertFile"]  = RemoteBroker["CaCertFile"];
	BrokerObject["CertFile"]  = RemoteBroker["CertFile"];
	BrokerObject["KeyFile"]  = RemoteBroker["KeyFile"];
	BrokerObject["Username"]  = RemoteBroker["Username"];
	BrokerObject["Password"]  = RemoteBroker["Password"];
	object["Broker"].push(BrokerObject);
}

JsonTransformXml.prototype._GetMqttJsonGroupData_ = function(object)
{
	var LocalBroker = JsonTransformXml.prototype._GetLocalBrokerData_();
	var RemoteBroker = JsonTransformXml.prototype._GetRemoteBroker_();
	var Class = new LoadFile();
	var MqttJsonGroup = Class.ReadFile("./File/IoT_Platform/MqttJsonGroup.json", new Object());
	Class=null;
	var array = Object.keys(MqttJsonGroup);
	for(var i=0; i<array.length; i++){
		var Name = MqttJsonGroup[array[i]]["Name"];
		object[Name] = new Object();
		JsonTransformXml.prototype._SetMqttJsonGroupClient_(object[Name], MqttJsonGroup[array[i]]);
		var MqttConnection = MqttJsonGroup[array[i]]["MqttConnection"];
		for(var j=0; j<MqttConnection.length; j++)
		{
			var BrokerObject=new Object();
			if(MqttConnection[j].indexOf("(Local)") != -1){
				JsonTransformXml.prototype._SetMqttJsonGroupLocalBroker_(object[Name], LocalBroker);
			}
			var BrokerName = Object.keys(RemoteBroker);
			for(var k=0; k<BrokerName.length; k++)
			{
				if(MqttConnection[j] == BrokerName[k]){
					JsonTransformXml.prototype._SetMqttJsonGroupRemoteBroker_(object[Name], RemoteBroker[BrokerName[k]]);
				}
			}
		}
	}
}

JsonTransformXml.prototype._GetAzurePlatformData_ = function(object)
{
	var AzureBroker = JsonTransformXml.prototype._GetAzureBroker_();
	var Class = new LoadFile();
	var AzurePlatform = Class.ReadFile("./File/IoT_Platform/Microsoft_Azure_Platform.json", new Object());
	var array = Object.keys(AzurePlatform);
	for(var i=0; i<array.length; i++){
		var Name = AzurePlatform[array[i]]["Name"]+" (Azure)";
		object[Name] = new Object();  var BrokerObject=new Object();
		object[Name]["Broker"] = new Array();
		object[Name]["TaskID"]   = -1;
		object[Name]["SubTopic"] = "devices/"+AzureBroker[Name]["ClientId"]+"/messages/devicebound/";
		object[Name]["SubQoS"]   = 1;
		object[Name]["PubTopic"] = "devices/"+AzureBroker[Name]["ClientId"]+"/messages/events/";
		object[Name]["PubQoS"]   = 1;
		object[Name]["Retain"]   = 0;
		object[Name]["ScanRate"] = AzurePlatform[array[i]]["ScanRate"];
		object[Name]["DeadBand"] = AzurePlatform[array[i]]["DeadBand"];
		object[Name]["WillTopic"]= "";
		object[Name]["Will"]     = "";
		BrokerObject["IP"]        = AzureBroker[Name]["IP"];
		BrokerObject["Port"]      = AzureBroker[Name]["Port"];
		BrokerObject["CaCertFile"]  = AzurePlatform[array[i]]["CaCertFile"];
		BrokerObject["ClientId"]  = AzureBroker[Name]["ClientId"];
		BrokerObject["Keepalive"] = AzureBroker[Name]["Keepalive"];
		BrokerObject["isSecure"]  = JsonTransformXml.prototype._GetSecureNumber_(AzureBroker[Name]["isSecure"]);
		BrokerObject["Username"]  = AzureBroker[Name]["Username"];
		BrokerObject["Password"]  = AzureBroker[Name]["Password"];
		object[Name]["Broker"].push(BrokerObject);
		var CdsEnabled=AzurePlatform[array[i]]["CdsEnabled"];
		if(CdsEnabled==true)
		{
			object[Name]["CustomFormatter"]=101;
			object[Name]["CDSData"]=new Object();
			object[Name]["CDSData"]["CompanyId"]=AzurePlatform[array[i]]["CompanyId"];
			object[Name]["CDSData"]["EquipmentId"]=AzurePlatform[array[i]]["EquipmentId"];
			object[Name]["CDSData"]["MessageCatalogId"]=AzurePlatform[array[i]]["MessageId"];
		}
	}
}

JsonTransformXml.prototype._GetRemoteBroker_ = function()
{
	var Class = new LoadFile();
	var RemoteBroker = Class.ReadFile("./File/IoT_Platform/RemoteBroker.json", new Object());
	var number=Object.keys(RemoteBroker);
	var Return=new Object();
	for(var i=0; i<number.length; i++)
	{
		var Name = RemoteBroker[number[i]]["Name"]+" (Remote)";
		Return[Name]=new Object();
		Return[Name]["IP"]       =RemoteBroker[number[i]]["IP"];
		Return[Name]["Port"]     =RemoteBroker[number[i]]["Port"];
		Return[Name]["Keepalive"]=RemoteBroker[number[i]]["Keepalive"];
		Return[Name]["Username"] =RemoteBroker[number[i]]["Account"];
		Return[Name]["Password"] =RemoteBroker[number[i]]["Password"];
		Return[Name]["isSecure"] =JsonTransformXml.prototype._GetSecureNumber_(RemoteBroker[number[i]]["SSL/TLS"]);
		Return[Name]["CaCertFile"] =RemoteBroker[number[i]]["CaCertFile"];
		Return[Name]["CertFile"] =RemoteBroker[number[i]]["CertFile"];
		Return[Name]["KeyFile"] =RemoteBroker[number[i]]["KeyFile"];
	}
	return Return;
}

JsonTransformXml.prototype._GetAzureBroker_ = function()
{
	var Class = new LoadFile();
	var AzurePlatform = Class.ReadFile("./File/IoT_Platform/Microsoft_Azure_Platform.json", new Object());
	var number=Object.keys(AzurePlatform);
	var Return=new Object();
	for(var i=0; i<number.length; i++)
	{
		var Name = AzurePlatform[number[i]]["Name"]+" (Azure)";
		Return[Name]=new Object();		Return[Name]["IP"]       ="";
		Return[Name]["Port"]     ="";	Return[Name]["ClientId"] ="";
		Return[Name]["Keepalive"]="";	Return[Name]["Username"] ="";
		Return[Name]["Password"] ="";	Return[Name]["isSecure"] ="";
		var SasToken = AzurePlatform[number[i]]["SasToken"];
		SasToken = SasToken.split(";");
		if(SasToken.length != 3){
			continue;
		}
		Return[Name]["IP"]       =SasToken[0].replace("HostName=", "");
		Return[Name]["Port"]     =8883;
		Return[Name]["ClientId"] =SasToken[1].replace("DeviceId=", "");
		Return[Name]["Keepalive"]=AzurePlatform[number[i]]["Keepalive"];
		Return[Name]["Username"] =Return[Name]["IP"]+"/"+Return[Name]["ClientId"]+"/";
		Return[Name]["Password"] =SasToken[2].replace("SharedAccessSignature=", "");
		Return[Name]["isSecure"] =1;
	}
	return Return;
}


























JsonTransformXml.prototype._ArrangeConnection_ = function(Index, ObjArray, ToMqttSetting)
{
	for(var i=0; i<Index.length; i++)
	{
		var array = ToMqttSetting[Index[i]]["MqttConnection"];
		for(var j=0; j<array.length; j++)
		{
			var object=new Object;
			object["ScanRate"]      =ToMqttSetting[Index[i]]["ScanRate"];
			object["DeadBand"]      =ToMqttSetting[Index[i]]["DeadBand"];
			object["WillTopic"]     =ToMqttSetting[Index[i]]["WillTopic"];
			object["Will"]          =ToMqttSetting[Index[i]]["Will"];
			object["MqttConnection"]=array[j];
			ObjArray.push(object);
		}
	}
}

JsonTransformXml.prototype._RemoveDuplicateConnection_ = function(ObjArray)
{
	for(var i=0; i<ObjArray.length; i++)
	{
		for(var j=i+1; j<ObjArray.length; j++)
		{
			if(JSON.stringify(ObjArray[i])==JSON.stringify(ObjArray[j]))
			{
				ObjArray.splice(j,1);
				j--;
				continue;
			}
		}
	}
}

JsonTransformXml.prototype._RemoveUnusedConnection_ = function(object)
{
	var i=0;
	while(i < object["MQTTService"]["MQTTServiceTask"].length)
	{
		if(object["MQTTService"]["MQTTServiceTask"].length == 0)		{break;}
		if(object["MQTTService"]["MQTTServiceTask"][i]["MQTTMapping"].length == 0)
		{
			object["MQTTService"]["MQTTServiceTask"].splice(i,1);
			i--;
		}
		i++;
	}
}

JsonTransformXml.prototype._InitializeModuleIndex_ = function(ObjectArray)
{
	for(var i=0; i<ObjectArray.length; i++)
	{
		ObjectArray[i]["ModuleIndex"]=new Array();
	}
}

JsonTransformXml.prototype._RecordModuleIndex_ = function(ObjArray, ObjectArray, Index, ToMqttSetting, PrefixWord)
{
	for(var i=0; i<ObjArray.length; i++)
	{
		for(var j=0; j<Index.length; j++)
		{
			var array = ToMqttSetting[Index[j]]["MqttConnection"];
			for(var k=0; k<array.length; k++)
			{
				object=new Object;
				object["ScanRate"]      =ToMqttSetting[Index[j]]["ScanRate"];
				object["DeadBand"]      =ToMqttSetting[Index[j]]["DeadBand"];
				object["WillTopic"]     =ToMqttSetting[Index[j]]["WillTopic"];
				object["Will"]          =ToMqttSetting[Index[j]]["Will"];
				object["MqttConnection"]=array[k];
				if(JSON.stringify(ObjArray[i])==JSON.stringify(object))
				{
					ObjectArray[i]["ModuleIndex"].push(PrefixWord+"_"+Index[j]);
				}
			}
		}
	}
}

JsonTransformXml.prototype._ArrangeMqttServices_ = function()
{
	var obj = JsonTransformXml.prototype._GetMqttServiceTransformObject_();
	var RtuIndex = Object.keys(obj["RtuToMqttSetting"]);
	var TcpIndex = Object.keys(obj["TcpToMqttSetting"]);
	var AsciiIndex = Object.keys(obj["AsciiToMqttSetting"]);
	var EipIndex = Object.keys(obj["EipToMqttSetting"]);
	var ObjArray=new Array();
	JsonTransformXml.prototype._ArrangeConnection_(RtuIndex, ObjArray, obj["RtuToMqttSetting"]);
	JsonTransformXml.prototype._ArrangeConnection_(TcpIndex, ObjArray, obj["TcpToMqttSetting"]);
	JsonTransformXml.prototype._ArrangeConnection_(AsciiIndex, ObjArray, obj["AsciiToMqttSetting"]);
	JsonTransformXml.prototype._ArrangeConnection_(EipIndex, ObjArray, obj["EipToMqttSetting"]);
	JsonTransformXml.prototype._RemoveDuplicateConnection_(ObjArray);
	var ObjectArray = jQuery.parseJSON(JSON.stringify(ObjArray));
	JsonTransformXml.prototype._InitializeModuleIndex_(ObjectArray);
	JsonTransformXml.prototype._RecordModuleIndex_(ObjArray, ObjectArray, RtuIndex, obj["RtuToMqttSetting"], "Rtu");
	JsonTransformXml.prototype._RecordModuleIndex_(ObjArray, ObjectArray, TcpIndex, obj["TcpToMqttSetting"], "Tcp");
	JsonTransformXml.prototype._RecordModuleIndex_(ObjArray, ObjectArray, AsciiIndex, obj["AsciiToMqttSetting"], "Ascii");
	JsonTransformXml.prototype._RecordModuleIndex_(ObjArray, ObjectArray, EipIndex, obj["EipToMqttSetting"], "Eip");
	return ObjectArray;
}

JsonTransformXml.prototype._GetMqttConnectionData_ = function(ObjectArray, MQTTServiceTask, LocalBroker, RemoteBroker)
{
	if(ObjectArray["MqttConnection"].indexOf(" (Local)") != -1){
		MQTTServiceTask["Broker"]["IP"]        = document.location.hostname;
		MQTTServiceTask["Broker"]["Port"]      = LocalBroker["port"];
		MQTTServiceTask["Broker"]["Keepalive"] = 60;
		MQTTServiceTask["Broker"]["Username"]  = LocalBroker["account"];
		MQTTServiceTask["Broker"]["Password"]  = LocalBroker["password"];
		MQTTServiceTask["Broker"]["isSecure"]  = JsonTransformXml.prototype._GetSecureNumber_(LocalBroker["isSecure"]);
		JsonTransformXml.prototype._GetMqttMappingObject_(ObjectArray, MQTTServiceTask);
	}
	else if(ObjectArray["MqttConnection"].indexOf(" (Remote)") != -1){
		var Index = Object.keys(RemoteBroker);
		for(var j=0; j<Index.length; j++)
		{
			if((RemoteBroker[Index[j]]["Name"]+" (Remote)") == ObjectArray["MqttConnection"])
			{
				MQTTServiceTask["Broker"]["IP"]        = RemoteBroker[Index[j]]["IP"];
				MQTTServiceTask["Broker"]["Port"]      = RemoteBroker[Index[j]]["Port"];
				MQTTServiceTask["Broker"]["Keepalive"] = RemoteBroker[Index[j]]["Keepalive"];
				MQTTServiceTask["Broker"]["Username"]  = RemoteBroker[Index[j]]["Account"];
				MQTTServiceTask["Broker"]["Password"]  = RemoteBroker[Index[j]]["Password"];
				MQTTServiceTask["Broker"]["isSecure"]  = JsonTransformXml.prototype._GetSecureNumber_(RemoteBroker[Index[j]]["SSL/TLS"]);
				MQTTServiceTask["Broker"]["CACertFile"] = RemoteBroker[Index[j]]["CaCertFile"];
				MQTTServiceTask["Broker"]["CertFile"] = RemoteBroker[Index[j]]["CertFile"];
				MQTTServiceTask["Broker"]["KeyFile"] = RemoteBroker[Index[j]]["KeyFile"];
				JsonTransformXml.prototype._GetMqttMappingObject_(ObjectArray, MQTTServiceTask);
			}
		}
	}
}

JsonTransformXml.prototype._GetLocalBrokerData_ = function()
{
	var Return = new Object();
	var Class = new LoadFile();
	var MosquittoConf = Class.ReadFile("./File/IoT_Platform/mosquitto.conf", new Object());
	MosquittoConf = MosquittoConf.split("\n");
	for(var i=0; i<MosquittoConf.length; i++)
	{
		if(MosquittoConf[i].indexOf("port") != -1)
		{
			Return["port"] = parseInt(MosquittoConf[i].split(" ")[1]);
		}
		else if(MosquittoConf[i].indexOf("allow_anonymous") != -1)
		{
			MosquittoConf[i].split(" ")[1] == "true" ? (Return["isSecure"] = false) : (Return["isSecure"] = true);
		}
	}
	Return["account"]="";	Return["password"]="";
	if(Return["isSecure"] == true)
	{
		var Acl = Class.ReadFile("./File/IoT_Platform/acl", new Object());
		Return["account"] = Acl.split("\n")[0].split(" ")[1];
		var LocalBroker = Class.ReadFile("./File/IoT_Platform/LocalBroker.txt", new Object());
		Return["password"] = LocalBroker.split(" ")[1];
	}
	Class = null;
	return Return;
}

JsonTransformXml.prototype._GetMqttMappingData_ = function(PrefixWord, ModuleIndex, MqttVariable, Variable, Module, MQTTServiceTask)
{
	var Index = ModuleIndex.split("_")[1];
	if(typeof(MqttVariable[Index]) == "undefined")  {return;}
	SystemVariable = Object.keys(MqttVariable[Index]);
	for(var j=0; j<SystemVariable.length; j++)
	{
		if(MqttVariable[Index][SystemVariable[j]]["TransformMqtt"] == true)
		{
			MQTTMapping=new Object();
			MQTTMapping["Name"]     = PrefixWord+Index+"_"+JsonTransformXml.prototype._GetModuleName_(Module, Index)+"_"+SystemVariable[j].split("-")[0]+"."+Variable[Index][SystemVariable[j]]["VariableName"];
			MQTTMapping["PubTopic"] = MqttVariable[Index][SystemVariable[j]]["PublishTopic"];
			MQTTMapping["PubQoS"]   = MqttVariable[Index][SystemVariable[j]]["PublishQos"];
			MQTTMapping["SubTopic"] = MqttVariable[Index][SystemVariable[j]]["SubscribeTopic"];
			MQTTMapping["SubQoS"]   = MqttVariable[Index][SystemVariable[j]]["SubscribeQos"];
			MQTTMapping["DataType"] = JsonTransformXml.prototype._GetDataType_(SystemVariable[j].split("-")[1]);
			MQTTMapping["Property"] = JsonTransformXml.prototype._GetProperty_(SystemVariable[j].split("-")[0]);
			MQTTMapping["Retain"]   = JsonTransformXml.prototype._GetRetainNumber_(MqttVariable[Index][SystemVariable[j]]["Retain"]);
			MQTTServiceTask["MQTTMapping"].push(MQTTMapping);
		}
	}
}

JsonTransformXml.prototype._GetMqttMappingObject_ = function(ObjectArray, MQTTServiceTask)
{
	var Class = new LoadFile();
	var MqttVariable, Variable, Module;
	var MQTTMapping, Index, SystemVariable;
	var ModuleIndex = ObjectArray["ModuleIndex"];
	for(var i=0; i<ModuleIndex.length; i++)
	{
		if(ModuleIndex[i].indexOf("Rtu_") != -1){
			MqttVariable = Class.ReadFile("./File/RTU_Module/RtuToMqttVariable.json", new Object());
			Variable = Class.ReadFile("./File/RTU_Module/RtuVariable.json", new Object());
			Module = Class.ReadFile("./File/RTU_Module/Module.json", new Object());
			JsonTransformXml.prototype._GetMqttMappingData_("MRTU_No.", ModuleIndex[i], MqttVariable, Variable, Module, MQTTServiceTask);
		}
		else if(ModuleIndex[i].indexOf("Tcp_") != -1){
			MqttVariable = Class.ReadFile("./File/TCP_Module/TcpToMqttVariable.json", new Object());
			Variable = Class.ReadFile("./File/TCP_Module/TcpVariable.json", new Object());
			Module = Class.ReadFile("./File/TCP_Module/Module.json", new Object());
			JsonTransformXml.prototype._GetMqttMappingData_("MTCP_No.", ModuleIndex[i], MqttVariable, Variable, Module, MQTTServiceTask);
		}
		else if(ModuleIndex[i].indexOf("Ascii_") != -1){
			MqttVariable = Class.ReadFile("./File/ASCII_Module/AsciiToMqttVariable.json", new Object());
			Variable = Class.ReadFile("./File/ASCII_Module/AsciiVariable.json", new Object());
			Module = Class.ReadFile("./File/ASCII_Module/Module.json", new Object());
			JsonTransformXml.prototype._GetMqttMappingData_("MASCII_No.", ModuleIndex[i], MqttVariable, Variable, Module, MQTTServiceTask);
		}
		else if(ModuleIndex[i].indexOf("Eip_") != -1){
			MqttVariable = Class.ReadFile("./File/EIP_Module/EipToMqttVariable.json", new Object());
			Variable = Class.ReadFile("./File/EIP_Module/EipVariable.json", new Object());
			Module = Class.ReadFile("./File/EIP_Module/Module.json", new Object());
			JsonTransformXml.prototype._GetEipMqttMappingData_("EIP_No.", ModuleIndex[i], MqttVariable, Variable, Module, MQTTServiceTask);
		}
	}
}

JsonTransformXml.prototype._GetMqttServiceTaskObject_ = function(Protocol)
{
	var LocalBroker = JsonTransformXml.prototype._GetLocalBrokerData_();
	var Class = new LoadFile();
	var RemoteBroker = Class.ReadFile("./File/IoT_Platform/RemoteBroker.json", new Object());
	Class = null;
	var Index, MQTTServiceTask, MQTTServiceTaskArray = new Object();
	MQTTServiceTaskArray = new Array();
	var ObjectArray = JsonTransformXml.prototype._ArrangeMqttServices_();
	for(var i=0; i<ObjectArray.length; i++)
	{
		MQTTServiceTask = new Object();
		MQTTServiceTask["TaskID"]    = -1;
		MQTTServiceTask["ScanRate"]  = ObjectArray[i]["ScanRate"];
		MQTTServiceTask["DeadBand"]  = ObjectArray[i]["DeadBand"];
		MQTTServiceTask["WillTopic"] = ObjectArray[i]["WillTopic"];
		MQTTServiceTask["Will"]      = ObjectArray[i]["Will"];
		MQTTServiceTask["MQTTMapping"] = new Array();
		MQTTServiceTask["Broker"]=new Object();
		JsonTransformXml.prototype._GetMqttConnectionData_(ObjectArray[i], MQTTServiceTask, LocalBroker, RemoteBroker);
		MQTTServiceTaskArray.push(MQTTServiceTask);
	}
	return MQTTServiceTaskArray;
}

JsonTransformXml.prototype._InitializeTaskId_ = function(MQTTService)
{
	var Index=1;
	var Length=MQTTService["MQTTService"]["MQTTServiceTask"].length;
	for(var i=0; i<Length; i++)
	{
		MQTTService["MQTTService"]["MQTTServiceTask"][i]["TaskID"]=Index;
		Index++;
	}
	Length=MQTTService["MQTTService"]["MQTTServiceTask_JSON"].length;
	for(var i=0; i<Length; i++)
	{
		MQTTService["MQTTService"]["MQTTServiceTask_JSON"][i]["TaskID"]=Index;
		Index++;
	}
	Length=MQTTService["MQTTService"]["MQTTCustomServiceTask"].length;
	for(var i=0; i<Length; i++)
	{
		MQTTService["MQTTService"]["MQTTCustomServiceTask"][i]["TaskID"]=Index;
		Index++;
	}
}

JsonTransformXml.prototype._GetMqttServiceTransformObject_ = function()
{
	var Return=new Object();  var Class = new LoadFile();
	Return["RtuToMqttSetting"] = Class.ReadFile("./File/RTU_Module/RtuToMqttSetting.json", new Object());
	Return["RtuToMqttVariable"] = Class.ReadFile("./File/RTU_Module/RtuToMqttVariable.json", new Object());
	Return["TcpToMqttSetting"] = Class.ReadFile("./File/TCP_Module/TcpToMqttSetting.json", new Object());
	Return["TcpToMqttVariable"] = Class.ReadFile("./File/TCP_Module/TcpToMqttVariable.json", new Object());
	Return["AsciiToMqttSetting"] = Class.ReadFile("./File/ASCII_Module/AsciiToMqttSetting.json", new Object());
	Return["AsciiToMqttVariable"] = Class.ReadFile("./File/ASCII_Module/AsciiToMqttVariable.json", new Object());
	Return["EipToMqttSetting"] = Class.ReadFile("./File/EIP_Module/EipToMqttSetting.json", new Object());
	Return["EipToMqttVariable"] = Class.ReadFile("./File/EIP_Module/EipToMqttVariable.json", new Object());

	Class=null;
	return Return;
}

JsonTransformXml.prototype._TransformMqttServiceXml_ = function()
{	
	var obj = new Object();
	obj["MQTTService"] = new Object();
	obj["MQTTService"]["MQTTServiceTask"] = new Array();
	obj["MQTTService"]["MQTTServiceTask"] = JsonTransformXml.prototype._GetMqttServiceTaskObject_();
	JsonTransformXml.prototype._RemoveUnusedConnection_(obj);
	
	obj["MQTTService"]["MQTTServiceTask_JSON"] = new Array();
	obj["MQTTService"]["MQTTServiceTask_JSON"] = JsonTransformXml.prototype._GetMqttServiceTaskJsonArray_();

	obj["MQTTService"]["MQTTCustomServiceTask"] = new Array();
	obj["MQTTService"]["MQTTCustomServiceTask"] = JsonTransformXml.prototype._GetMqttCustomServiceTaskArray_();

	JsonTransformXml.prototype._InitializeTaskId_(obj);
	var xotree = new XML.ObjTree();
	var xml = xotree.writeXML(obj);
	return xml;
}

JsonTransformXml.prototype._GetUAServerDataXmlTransformObject_ = function()
{
	var Return=new Object();  var Class = new LoadFile();
	Return["RtuVariable"] = Class.ReadFile("./File/RTU_Module/RtuVariable.json", new Object());
	Return["RtuScalingVariable"] = Class.ReadFile("./File/RTU_Module/RtuScalingVariable.json", new Object());
	Return["RtuBitwiseVariable"] = Class.ReadFile("./File/RTU_Module/RtuBitwiseVariable.json", new Object());
	Return["RtuToOpcuaVariable"] = Class.ReadFile("./File/RTU_Module/RtuToOpcuaVariable.json", new Object());
	Return["RtuScalingToOpcuaVariable"] = Class.ReadFile("./File/RTU_Module/RtuScalingToOpcuaVariable.json", new Object());
	Return["RtuBitwiseToOpcuaVariable"] = Class.ReadFile("./File/RTU_Module/RtuBitwiseToOpcuaVariable.json", new Object());
	Return["RtuModule"] = Class.ReadFile("./File/RTU_Module/Module.json", new Object());

	Return["AsciiVariable"] = Class.ReadFile("./File/ASCII_Module/AsciiVariable.json", new Object());
	Return["AsciiToOpcuaVariable"] = Class.ReadFile("./File/ASCII_Module/AsciiToOpcuaVariable.json", new Object());
	Return["AsciiModule"] = Class.ReadFile("./File/ASCII_Module/Module.json", new Object());

	Return["TcpVariable"] = Class.ReadFile("./File/TCP_Module/TcpVariable.json", new Object());
	Return["TcpScalingVariable"] = Class.ReadFile("./File/TCP_Module/TcpScalingVariable.json", new Object());
	Return["TcpBitwiseVariable"] = Class.ReadFile("./File/TCP_Module/TcpBitwiseVariable.json", new Object());
	Return["TcpToOpcuaVariable"] = Class.ReadFile("./File/TCP_Module/TcpToOpcuaVariable.json", new Object());
	Return["TcpScalingToOpcuaVariable"] = Class.ReadFile("./File/TCP_Module/TcpScalingToOpcuaVariable.json", new Object());
	Return["TcpBitwiseToOpcuaVariable"] = Class.ReadFile("./File/TCP_Module/TcpBitwiseToOpcuaVariable.json", new Object());
	Return["TcpModule"] = Class.ReadFile("./File/TCP_Module/Module.json", new Object());

	Return["MqttVariable"] = Class.ReadFile("./File/MQTT_Module/MqttVariable.json", new Object());
	Return["MqttToOpcuaVariable"] = Class.ReadFile("./File/MQTT_Module/MqttToOpcuaVariable.json", new Object());
	Return["MqttModule"] = Class.ReadFile("./File/MQTT_Module/Module.json", new Object());

	Return["EipVariable"] = Class.ReadFile("./File/EIP_Module/EipVariable.json", new Object());
	Return["EipToOpcuaVariable"] = Class.ReadFile("./File/EIP_Module/EipToOpcuaVariable.json", new Object());
	Return["EipModule"] = Class.ReadFile("./File/EIP_Module/Module.json", new Object());

	Return["RegisterVariable"] = Class.ReadFile("./File/Register_Module/RegisterVariable.json", new Object());
	Return["RegisterToOpcuaVariable"] = Class.ReadFile("./File/Register_Module/RegisterToOpcuaVariable.json", new Object());
	Return["RegisterModule"] = Class.ReadFile("./File/Register_Module/Module.json", new Object());
	Class=null;
	return Return;
}

JsonTransformXml.prototype._GetBaseVariableData_ = function(ModuleType, Variable, SystemVariable, number, ModuleName, ToOpcuaVariable)
{
	var Return = new Array();
	var BaseVariableData, Name, MapVariable;
	for(var i=0; i<SystemVariable.length; i++)
	{
		if(ToOpcuaVariable[number][SystemVariable[i]]["TransformOpcUa"] == false)
		{
			continue;
		}
		BaseVariableData = new Object();
		BaseVariableData["UATypeId"] = JsonTransformXml.prototype._GetInputOutputData_(SystemVariable[i].split("-")[0])+SystemVariable[i].split("-")[1];
		Name = JsonTransformXml.prototype._GetClientVariablePrefixWords_(ModuleType, SystemVariable[i].split("-")[0])+"."+Variable[number][SystemVariable[i]]["VariableName"];
		BaseVariableData["Name"] = Name;
		
		MapVariable = ModuleType+"_No."+number+"_"+ModuleName+"_"+SystemVariable[i].split("-")[0]+"."+Variable[number][SystemVariable[i]]["VariableName"];

		BaseVariableData["MapVariable"] = MapVariable;
		BaseVariableData["StatusCode"] = 0;
		BaseVariableData["DefaultValue"] = 0;
		BaseVariableData["Description"] = Variable[number][SystemVariable[i]]["Description"];
		Return.push(BaseVariableData);
	}
	return Return;
}

JsonTransformXml.prototype._GetBaseEipVariableData_ = function(ModuleType, Variable, SystemVariable, number, ModuleName, ToOpcuaVariable)
{
	var Return = new Array();
	var BaseVariableData, Name, MapVariable;
	var ChannelModeType = parseInt(Global_EipSetting[number]["ModeType"]);
	for(var i=0; i<ChannelModeType; i++)
	{
		if(ToOpcuaVariable[number][SystemVariable[i]]["TransformOpcUa"] == false)
		{
			continue;
		}
		BaseVariableData = new Object();
		BaseVariableData["UATypeId"] = JsonTransformXml.prototype._GetInputOutputData_(SystemVariable[i].split("-")[0])+SystemVariable[i].split("-")[1];
		//Name = JsonTransformXml.prototype._GetClientVariablePrefixWords_(ModuleType, SystemVariable[i].split("-")[0])+"."+Variable[number][SystemVariable[i]]["VariableName"];
		Name = SystemVariable[i].split("-")[0] + "." + Variable[number][SystemVariable[i]]["VariableName"];
		
		BaseVariableData["Name"] = Name;
		MapVariable = ModuleType+"_No."+number+"_"+ModuleName+"_"+SystemVariable[i].split("-")[0]+"."+Variable[number][SystemVariable[i]]["VariableName"];
		BaseVariableData["MapVariable"] = MapVariable;
		BaseVariableData["StatusCode"] = 0;
		BaseVariableData["DefaultValue"] = 0;
		BaseVariableData["Description"] = Variable[number][SystemVariable[i]]["Description"];
		Return.push(BaseVariableData);
	}
	return Return;
}
JsonTransformXml.prototype._GetBaseRegisterVariableData_ = function(ModuleType, Variable, SystemVariable, number, ModuleName, ToOpcuaVariable)
{
	var Return = new Array();
	var BaseVariableData, Name, MapVariable;
	//var ChannelModeType = parseInt(Global_EipSetting[number]["ModeType"]);
	for(var i=0; i<SystemVariable.length; i++)
	{
		if(ToOpcuaVariable[number][SystemVariable[i]]["TransformOpcUa"] == false)
		{
			continue;
		}
		BaseVariableData = new Object();
		BaseVariableData["UATypeId"] = JsonTransformXml.prototype._GetInputOutputData_(SystemVariable[i].split("-")[0])+SystemVariable[i].split("-")[1];
		//Name = JsonTransformXml.prototype._GetClientVariablePrefixWords_(ModuleType, SystemVariable[i].split("-")[0])+"."+Variable[number][SystemVariable[i]]["VariableName"];
		Name = SystemVariable[i].split("-")[0] + "." + Variable[number][SystemVariable[i]]["VariableName"];
		
		BaseVariableData["Name"] = Name.split(".")[1];
		MapVariable = "Internal" + "_No."+number+"_"+ModuleName+"."+Variable[number][SystemVariable[i]]["VariableName"];
		BaseVariableData["MapVariable"] = MapVariable;
		BaseVariableData["StatusCode"] = 0;
		BaseVariableData["DefaultValue"] = 0;
		BaseVariableData["Description"] = Variable[number][SystemVariable[i]]["Description"];
		Return.push(BaseVariableData);
	}
	return Return;
}

JsonTransformXml.prototype._GetUA_MethodData_ = function(PidName)
{
	var Return=new Array();
	var UA_MethodData=new Object();
	UA_MethodData["Name"]="Run";
	UA_MethodData["Method"]="PID_"+PidName+".Run";
	Return.push(UA_MethodData);
	UA_MethodData=new Object();
	UA_MethodData["Name"]="Stop";
	UA_MethodData["Method"]="PID_"+PidName+".Stop";
	Return.push(UA_MethodData);
	return Return;
}

JsonTransformXml.prototype._GetAnalogItemData_ = function(ModuleVariableIndex, PidNumber, PidOperationVariable)
{
	var Return = new Array();
	var OutputArray = ModuleVariableIndex.split("/");
	var ModuleType = OutputArray[0];
	var ModuleIndex = OutputArray[1];
	var VariableIndex = OutputArray[2];
	var AnalogItemData = new Object();
	var GlobalModule = GetValue.prototype._GetGlobalModule_(ModuleType);
	var ModuleName = GetValue.prototype._GetModuleName_(GlobalModule, ModuleIndex);
	var GlobalVariable=GetValue.prototype._GetGlobalVariable_(ModuleType);
	if(ModuleType=="MRTU Scaling" || ModuleType=="MTCP Scaling")
	{
		ModuleType = ModuleType.split(" ")[0];
		var VariableName=GetValue.prototype._GetModulePidScalingVariableName_(GlobalVariable, ModuleIndex, VariableIndex);
	}
	else
	{
		var VariableName=GetValue.prototype._GetModuleVariableName_(GlobalVariable, ModuleIndex, VariableIndex);
	}
	ModuleType = OutputArray[0];;
	AnalogItemData["UATypeId"]=JsonTransformXml.prototype._GetInputOutputData_(VariableIndex.split("-")[0])+VariableIndex.split("-")[1];
	AnalogItemData["Name"]=JsonTransformXml.prototype._GetClientVariablePrefixWords_(ModuleType, VariableIndex.split("-")[0])+"."+VariableName;
	if(ModuleType=="MRTU Scaling" || ModuleType=="MTCP Scaling")
	{
		ModuleType = ModuleType.split(" ")[0];
		AnalogItemData["MapVariable"]=ModuleType+"_No."+ModuleIndex+"_"+ModuleName+"_"+VariableIndex.split("-")[0]+"_Scale."+VariableName;
	}
	else
	{
		AnalogItemData["MapVariable"]=ModuleType+"_No."+ModuleIndex+"_"+ModuleName+"_"+VariableIndex.split("-")[0]+"."+VariableName;
	}
	AnalogItemData["StatusCode"]=0;
	AnalogItemData["DefaultValue"]=0;
	AnalogItemData["Range"]=new Object();
	AnalogItemData["Range"]["LowLimit"]=PidOperationVariable[PidNumber]["Min"];
	AnalogItemData["Range"]["HighLimit"]=PidOperationVariable[PidNumber]["Max"];
	Return.push(AnalogItemData);
	return Return;
}

JsonTransformXml.prototype._GetPidOperationBaseVariableData_ = function(Module, ModuleVariableIndex, PidName)
{
	var Return = new Array();
	var ModuleType=ModuleVariableIndex.split("/")[0];
	var ModuleIndex=ModuleVariableIndex.split("/")[1];
	var SystemVariable=ModuleVariableIndex.split("/")[2];
	var VirtualPoint = new Array("SetPoint", "Kp", "Ki", "Kd", "ControllerMode", "SampleTime", "AutoTune", "Status");
	var ComparisonValue = new Array("SetValue", "Kp", "Ki", "Kd", "ControllerMode", "SampleTime", "AutoTune", "Status");
	var InputOutputData = new Array("OutputData_Double", "OutputData_Double", "OutputData_Double", "OutputData_Double", "OutputData_Bool", "OutputData_Double", "OutputData_Bool", "InputData_Bool");
	var BaseVariableData, Name, MapVariable;
	BaseVariableData = new Object();
	BaseVariableData["UATypeId"] = JsonTransformXml.prototype._GetInputOutputData_(SystemVariable.split("-")[0])+SystemVariable.split("-")[1];
	var GlobalVariable=GetValue.prototype._GetGlobalVariable_(ModuleType);
	if(ModuleType=="MRTU Scaling" || ModuleType=="MTCP Scaling")
	{
		var ModuleVariableName=GetValue.prototype._GetModulePidScalingVariableName_(GlobalVariable, ModuleIndex, SystemVariable);
	}
	else
	{
		var ModuleVariableName=GetValue.prototype._GetModuleVariableName_(GlobalVariable, ModuleIndex, SystemVariable);
	}
	Name = JsonTransformXml.prototype._GetClientVariablePrefixWords_(ModuleType, SystemVariable.split("-")[0])+"."+ModuleVariableName;
	BaseVariableData["Name"] = Name;
	var ModuleName = JsonTransformXml.prototype._GetModuleName_(Module, ModuleIndex);

	if(ModuleType=="MRTU Scaling" || ModuleType=="MTCP Scaling")
	{
		ModuleType = ModuleType.split(" ")[0];
		MapVariable = ModuleType+"_No."+ModuleIndex+"_"+ModuleName+"_"+SystemVariable.split("-")[0]+"_Scale."+ModuleVariableName;
	}
	else
	{
		MapVariable = ModuleType+"_No."+ModuleIndex+"_"+ModuleName+"_"+SystemVariable.split("-")[0]+"."+ModuleVariableName;

	}
		BaseVariableData["MapVariable"] = MapVariable;
	BaseVariableData["StatusCode"] = 0;
	BaseVariableData["DefaultValue"] = 0;
	Return.push(BaseVariableData);
	for(var i=0; i<VirtualPoint.length; i++)
	{
		BaseVariableData = new Object();
		BaseVariableData["UATypeId"] = InputOutputData[i];
		BaseVariableData["Name"] = ComparisonValue[i];
		MapVariable = "PID_"+PidName+"."+VirtualPoint[i];
		BaseVariableData["MapVariable"] = MapVariable;
		BaseVariableData["StatusCode"] = 0;
		BaseVariableData["DefaultValue"] = 0;
		Return.push(BaseVariableData);
	}
	return Return;
}

JsonTransformXml.prototype._CheckBitwiseGlobalVariableExist_ = function(GlobalVariable, SystemVariable, VariableName)
{
	var Return; 

	if(typeof(GlobalVariable[SystemVariable][VariableName]) != "undefined")
	{
		Return = true;
	}
	return Return;
}

JsonTransformXml.prototype._BitwiseVariablePretreatment_ = function(number, Variable, ToOpcuaVariable)
{
	var Return=new Array(); var BitTotalNumber = 0; var BitNameId = ""; var VariableExist;
	var SystemVariable = Object.keys(ToOpcuaVariable[number]);
	for(var i=0; i<SystemVariable.length; i++)
	{
		if(Variable[number][SystemVariable[i]]["DataType"] == "Short" || Variable[number][SystemVariable[i]]["DataType"]== "Unsigned Short") BitTotalNumber = 16;
		else if(Variable[number][SystemVariable[i]]["DataType"] == "Long" || Variable[number][SystemVariable[i]]["DataType"] == "Unsigned Long")  BitTotalNumber = 32;
		for(var j=0; j<BitTotalNumber; j++)
		{
			BitNameId = "BitTagName-" + j.toString();
			VariableExist = JsonTransformXml.prototype._CheckBitwiseGlobalVariableExist_(ToOpcuaVariable[number], SystemVariable[i], BitNameId);
			if(VariableExist == true)
			{
				Obj = new Object();
				Obj["SystemVariable"]=SystemVariable[i];
				Obj["VariableName"]=Variable[number][SystemVariable[i]][BitNameId];
				Obj["GlobalIndexName"]=BitNameId;
				Obj["TransformOpcUa"]=ToOpcuaVariable[number][SystemVariable[i]][BitNameId];
				Obj["Description"]=Variable[number][SystemVariable[i]]["Description"];
				Return.push(Obj);
			}
		}
	}
	return Return;
}

JsonTransformXml.prototype._GetBitwiseVariableData_ = function(ModuleType, Variable, SystemVariable, number, ModuleName, ToOpcuaVariable)
{
	var Return = new Array();
	var BaseVariableData, Name, MapVariable;
	var BitwiseTotalTag = JsonTransformXml.prototype._BitwiseVariablePretreatment_(number, Variable, ToOpcuaVariable);
	for(var i=0; i<BitwiseTotalTag.length; i++)
	{
		if(BitwiseTotalTag[i]["TransformOpcUa"] == false)
		{
			continue;
		}
		BaseVariableData = new Object();
		BaseVariableData["UATypeId"] = JsonTransformXml.prototype._GetInputOutputData_(BitwiseTotalTag[i]["SystemVariable"].split("-")[0])+"Bool";
		Name = JsonTransformXml.prototype._GetClientVariablePrefixWords_(ModuleType, BitwiseTotalTag[i]["SystemVariable"].split("-")[0])+"."+BitwiseTotalTag[i]["VariableName"];
		Name = Name.split(".")[0] + "_Bitwise." + Name.split(".")[1];
		BaseVariableData["Name"] = Name;
		MapVariable = ModuleType+"_No."+number+"_"+ModuleName+"_"+BitwiseTotalTag[i]["SystemVariable"].split("-")[0]+"_Bitwise"+"."+BitwiseTotalTag[i]["VariableName"];
		BaseVariableData["MapVariable"] = MapVariable;
		BaseVariableData["StatusCode"] = 0;
		BaseVariableData["DefaultValue"] = 0;
		BaseVariableData["Description"] = BitwiseTotalTag[i]["Description"];
		Return.push(BaseVariableData);
	}
	return Return;
}
JsonTransformXml.prototype._GetBitwiseVariable_ = function(ModuleType, Obj)
{
	var Return;

	if(ModuleType=="MRTU")
	{
		Return = Obj["RtuBitwiseVariable"];
	}
	else if(ModuleType=="MTCP")
	{
		Return = Obj["TcpBitwiseVariable"];
	}

	return Return;
}
JsonTransformXml.prototype._GetBitwiseToOpcuaVariable_ = function(ModuleType, Obj)
{
	var Return;

	if(ModuleType=="MRTU")
	{
		Return = Obj["RtuBitwiseToOpcuaVariable"];
	}
	else if(ModuleType=="MTCP")
	{
		Return = Obj["TcpBitwiseToOpcuaVariable"];
	}

	return Return;
}
JsonTransformXml.prototype._GetBitwise_Objectdata_ = function(ModuleType, Obj, number, ModuleName)
{
	var Return;

	var Variable = JsonTransformXml.prototype._GetBitwiseVariable_(ModuleType, Obj);
	var ToOpcuaVariable = JsonTransformXml.prototype._GetBitwiseToOpcuaVariable_(ModuleType, Obj);
	if(typeof(ToOpcuaVariable[number]) != "object") {return 0;}
	var SystemVariable = Object.keys(ToOpcuaVariable[number]);

	Return = JsonTransformXml.prototype._GetBitwiseVariableData_(ModuleType, Variable, SystemVariable, number, ModuleName, ToOpcuaVariable);

	return Return;
}

JsonTransformXml.prototype._GetScalingVariableData_ = function(ModuleType, Variable, SystemVariable, number, ModuleName, ToOpcuaVariable)
{
	var Return = new Array();
	var BaseVariableData, Name, MapVariable;
	for(var i=0; i<SystemVariable.length; i++)
	{
		if(ToOpcuaVariable[number][SystemVariable[i]]["TransformOpcUa"] == false)
		{
			continue;
		}
		BaseVariableData = new Object();
		BaseVariableData["UATypeId"] = JsonTransformXml.prototype._GetInputOutputData_(SystemVariable[i].split("-")[0])+"Float";
		Name = JsonTransformXml.prototype._GetClientVariablePrefixWords_(ModuleType, SystemVariable[i].split("-")[0])+"."+Variable[number][SystemVariable[i]]["ScaleVariableName"];
		Name = Name.split(".")[0] + "_Scale." + Name.split(".")[1];
		BaseVariableData["Name"] = Name;
		MapVariable = ModuleType+"_No."+number+"_"+ModuleName+"_"+SystemVariable[i].split("-")[0]+"_Scale"+"."+Variable[number][SystemVariable[i]]["ScaleVariableName"];
		BaseVariableData["MapVariable"] = MapVariable;
		BaseVariableData["StatusCode"] = 0;
		BaseVariableData["DefaultValue"] = 0;
		BaseVariableData["Description"] = Variable[number][SystemVariable[i]]["Description"];
		Return.push(BaseVariableData);
	}
	return Return;
}

JsonTransformXml.prototype._GetScalingVariable_ = function(ModuleType, Obj)
{
	var Return;

	if(ModuleType=="MRTU")
	{
		Return = Obj["RtuScalingVariable"];
	}
	else if(ModuleType=="MTCP")
	{
		Return = Obj["TcpScalingVariable"];
	}

	return Return;
}
JsonTransformXml.prototype._GetScalingToOpcuaVariable_ = function(ModuleType, Obj)
{
	var Return;

	if(ModuleType=="MRTU")
	{
		Return = Obj["RtuScalingToOpcuaVariable"];
	}
	else if(ModuleType=="MTCP")
	{
		Return = Obj["TcpScalingToOpcuaVariable"];
	}

	return Return;
}
JsonTransformXml.prototype._GetScaling_Objectdata_ = function(ModuleType, Obj, number, ModuleName)
{
	var Return;

	var Variable = JsonTransformXml.prototype._GetScalingVariable_(ModuleType, Obj);
	var ToOpcuaVariable = JsonTransformXml.prototype._GetScalingToOpcuaVariable_(ModuleType, Obj);
	if(typeof(ToOpcuaVariable[number]) != "object") {return 0;}
	var SystemVariable = Object.keys(ToOpcuaVariable[number]);

	Return = JsonTransformXml.prototype._GetScalingVariableData_(ModuleType, Variable, SystemVariable, number, ModuleName, ToOpcuaVariable);

	return Return;
}
JsonTransformXml.prototype._GetPidScaling_Objectdata_ = function(ModuleType, Obj, number, ModuleName)
{
	var Return;

	var Variable = JsonTransformXml.prototype._GetScalingVariable_(ModuleType, Obj);
	var ToOpcuaVariable = JsonTransformXml.prototype._GetScalingToOpcuaVariable_(ModuleType, Obj);
	if(typeof(ToOpcuaVariable[number]) != "object") {return 0;}
	var SystemVariable = Object.keys(ToOpcuaVariable[number]);

	Return = JsonTransformXml.prototype._GetScalingVariableData_(ModuleType, Variable, SystemVariable, number, ModuleName, ToOpcuaVariable);

	return Return;
}

JsonTransformXml.prototype._GetVariable_ = function(ModuleType, Obj)
{
	var Return;

	if(ModuleType=="MRTU")
	{
		Return = Obj["RtuVariable"];
	}
	else if(ModuleType=="MASCII")
	{
		Return = Obj["AsciiVariable"];
	}
	else if(ModuleType=="MTCP")
	{
		Return = Obj["TcpVariable"];
	}
	else if(ModuleType=="MQTT")
	{
		Return = Obj["MqttVariable"];
	}
	return Return;
}
JsonTransformXml.prototype._GetToOpcuaVariable_ = function(ModuleType, Obj)
{
	var Return;

	if(ModuleType=="MRTU")
	{
		Return = Obj["RtuToOpcuaVariable"];
	}
	else if(ModuleType=="MASCII")
	{
		Return = Obj["AsciiToOpcuaVariable"];
	}
	else if(ModuleType=="MTCP")
	{
		Return = Obj["TcpToOpcuaVariable"];
	}
	else if(ModuleType=="MQTT")
	{
		Return = Obj["MqttToOpcuaVariable"];
	}
	return Return;
}
JsonTransformXml.prototype._GetModule_ = function(ModuleType, Obj)
{
	var Return;

	if(ModuleType=="MRTU")
	{
		Return = Obj["RtuModule"];
	}
	else if(ModuleType=="MASCII")
	{
		Return = Obj["AsciiModule"];
	}
	else if(ModuleType=="MTCP")
	{
		Return = Obj["TcpModule"];
	}
	else if(ModuleType=="MQTT")
	{
		Return = Obj["MqttModule"];
	}
	return Return;
}
JsonTransformXml.prototype._GetUA_Objectdata_ = function(ModuleType, Obj)
{
	var Return = new Array();
	ToOpcuaVariable = JsonTransformXml.prototype._GetToOpcuaVariable_(ModuleType, Obj);
	Module = JsonTransformXml.prototype._GetModule_(ModuleType, Obj);
	Variable = JsonTransformXml.prototype._GetVariable_(ModuleType, Obj);
	var number = Object.keys(ToOpcuaVariable);
	for(var i=0; i<number.length; i++)
	{
		var ModuleName = JsonTransformXml.prototype._GetModuleName_(Module, number[i]);
		var UA_Objectdata = new Object();
		UA_Objectdata["Name"]=ModuleType+"_No."+number[i]+"_"+ModuleName;
		UA_Objectdata["ObjectType"] = 1;
		UA_Objectdata["LocalId"] = "en";
		UA_Objectdata["BaseVariableData"] = new Array();
		var SystemVariable = Object.keys(ToOpcuaVariable[number[i]]);
		UA_Objectdata["BaseVariableData"] = JsonTransformXml.prototype._GetBaseVariableData_(ModuleType, Variable, SystemVariable, number[i], ModuleName, ToOpcuaVariable);
		if( (ModuleType=="MTCP") || (ModuleType=="MRTU") )
		{
			UA_Objectdata["BaseVariableData"].push(JsonTransformXml.prototype._GetScaling_Objectdata_(ModuleType, Obj, number[i], ModuleName));
			UA_Objectdata["BaseVariableData"].push(JsonTransformXml.prototype._GetBitwise_Objectdata_(ModuleType, Obj, number[i], ModuleName));
			//UA_Objectdata["BaseVariableData"].push(JsonTransformXml.prototype._GetPidScaling_Objectdata_(ModuleType, Obj, number[i], ModuleName));
		}



		if(UA_Objectdata["BaseVariableData"].length > 0)
		{
			Return.push(UA_Objectdata);
		}
	}
	return Return;
}
JsonTransformXml.prototype._GetEipUA_Objectdata_ = function(ModuleType, Module, Variable, ToOpcuaVariable)
{
	var Return = new Array();
	var number = Object.keys(ToOpcuaVariable);
	var Class = new LoadFile();	
	var EipSetting = Class.ReadFile("./File/EIP_Module/EipSetting.json", new Object());
	for(var i=0; i<number.length; i++)
	{
		var ModuleName = EipSetting[number[i]]["NickName"];
		var UA_Objectdata = new Object();
		UA_Objectdata["Name"]=ModuleType+"_No."+number[i]+"_"+ModuleName;
		UA_Objectdata["ObjectType"] = 1;
		UA_Objectdata["LocalId"] = "en";
		UA_Objectdata["BaseVariableData"] = new Array();
		var SystemVariable = Object.keys(ToOpcuaVariable[number[i]]);
		UA_Objectdata["BaseVariableData"] = JsonTransformXml.prototype._GetBaseEipVariableData_(ModuleType, Variable, SystemVariable, number[i], ModuleName, ToOpcuaVariable);
		if(UA_Objectdata["BaseVariableData"].length > 0)
		{
			Return.push(UA_Objectdata);
		}
	}
	return Return;
}

JsonTransformXml.prototype._GetRegisterUA_Objectdata_ = function(ModuleType, Module, Variable, ToOpcuaVariable)
{
	var Return = new Array();
	var number = Object.keys(ToOpcuaVariable);
	var Class = new LoadFile();	
	var RegisterModule = Class.ReadFile("./File/Register_Module/Module.json", new Object());
	for(var i=0; i<number.length; i++)
	{
		var ModuleName = RegisterModule[number[i]]["ModuleName"];
		var UA_Objectdata = new Object();
		UA_Objectdata["Name"] = "Internal" +"_No." + number[i] + "_" + ModuleName;
		UA_Objectdata["ObjectType"] = 1;
		UA_Objectdata["LocalId"] = "en";
		UA_Objectdata["BaseVariableData"] = new Array();
		var SystemVariable = Object.keys(ToOpcuaVariable[number[i]]);
		UA_Objectdata["BaseVariableData"] = JsonTransformXml.prototype._GetBaseRegisterVariableData_(ModuleType, Variable, SystemVariable, number[i], ModuleName, ToOpcuaVariable);
		if(UA_Objectdata["BaseVariableData"].length > 0)
		{
			Return.push(UA_Objectdata);
		}
	}
	return Return;
}

JsonTransformXml.prototype._GetPidUA_Objectdata_ = function()
{
	var Return = new Array(), Class = new LoadFile();
	var VirtualPoint = new Array("Min", "Max", "SetPoint", "Kp", "Ki", "Kd", "ControllerMode", "SampleTime", "AutoTune", "Status");
	var ComparisonValue = new Array("Min", "Max", "SetValue", "Kp", "Ki", "Kd", "ControllerMode", "SampleTime", "AutoTune", "Status");
	var PidOperation = Class.ReadFile("./File/PID_Operation/PidOperation.json", new Object());
	var PidNumber = Object.keys(PidOperation);
	var PidName, ModuleType, ModuleName, ModuleIndex, ModuleVariableIndex;
	for(var i=0; i<PidNumber.length; i++)
	{
		if(PidOperation[PidNumber[i]]["InputModuleVariableIndex"] == "//" ||
		   PidOperation[PidNumber[i]]["OutputModuleVariableIndex"] == "//"){
			continue;
		}
		PidName=PidOperation[PidNumber[i]]["Name"];
		ModuleVariableIndex=PidOperation[PidNumber[i]]["InputModuleVariableIndex"];
		var InputArray=ModuleVariableIndex.split("/");
		ModuleType = InputArray[0];
		ModuleIndex= InputArray[1];
		var Module=GetValue.prototype._GetGlobalModule_(ModuleType);
		ModuleName=JsonTransformXml.prototype._GetModuleName_(Module, ModuleIndex);
		var UA_Objectdata = new Object();
		UA_Objectdata["Name"]="PID_"+PidName;
		UA_Objectdata["ObjectType"] = 1;
		UA_Objectdata["LocalId"] = "en";
		UA_Objectdata["BaseVariableData"] = new Array();
		UA_Objectdata["AnalogItemData"] = new Array();
		UA_Objectdata["UA_MethodData"] = new Array();
		UA_Objectdata["BaseVariableData"] = JsonTransformXml.prototype._GetPidOperationBaseVariableData_(Module, ModuleVariableIndex, PidName);

		ModuleVariableIndex=PidOperation[PidNumber[i]]["OutputModuleVariableIndex"];
		UA_Objectdata["AnalogItemData"] = JsonTransformXml.prototype._GetAnalogItemData_(ModuleVariableIndex, PidNumber[i], PidOperation);
		UA_Objectdata["UA_MethodData"] = JsonTransformXml.prototype._GetUA_MethodData_(PidName);
		if(UA_Objectdata["BaseVariableData"].length > 0)
		{
			Return.push(UA_Objectdata);
		}
	}
	return Return;
}

JsonTransformXml.prototype._GetUA_ServiceData_ = function(UA_Objectdata)
{
	var UA_ServiceData = new Object();
	UA_ServiceData["UA_ServiceData"] = new Object();
	UA_ServiceData["UA_ServiceData"]["UA_NodeManagerData"] = new Object();
	UA_ServiceData["UA_ServiceData"]["UA_NodeManagerData"]["NameSpaceUri"] = "UAServer/IOmodule";
	UA_ServiceData["UA_ServiceData"]["UA_NodeManagerData"]["ManagerTypeId"] = 0;
	UA_ServiceData["UA_ServiceData"]["UA_NodeManagerData"]["FiresEvents"] = 0;
	UA_ServiceData["UA_ServiceData"]["UA_NodeManagerData"]["TableSize"] = 20000;
	UA_ServiceData["UA_ServiceData"]["UA_NodeManagerData"]["UA_Objectdata"] = new Array();
	UA_ServiceData["UA_ServiceData"]["UA_NodeManagerData"]["UA_Objectdata"] = UA_Objectdata;
	return UA_ServiceData;
}

JsonTransformXml.prototype._TransformUAServerConfigXml_ = function()
{
	var Class = new LoadFile();
	var XmlObject = Class.ReadXmlObject("./File/IoT_Platform/UAServerConfig.xml", new Object());
	XmlObject["OpcServerConfig"]["UaServerConfig"]["UaEndpoint"]["CertificateStore"]["OpenSSLStore"]["CertificateTrustListLocation"]="/app/Certificates/OPCUA/trusted/";

	var xotree = new XML.ObjTree();
	var xml = xotree.writeXML(XmlObject);
	var array = new Array(xml);
	return array;
}

JsonTransformXml.prototype._TransformUAServerDataXml_ = function()
{
	var UA_Objectdata = new Array();

	var Obj = JsonTransformXml.prototype._GetUAServerDataXmlTransformObject_();

	UA_Objectdata = UA_Objectdata.concat(JsonTransformXml.prototype._GetUA_Objectdata_("MRTU", Obj));
	UA_Objectdata = UA_Objectdata.concat(JsonTransformXml.prototype._GetUA_Objectdata_("MASCII", Obj));
	UA_Objectdata = UA_Objectdata.concat(JsonTransformXml.prototype._GetUA_Objectdata_("MTCP", Obj));
	UA_Objectdata = UA_Objectdata.concat(JsonTransformXml.prototype._GetUA_Objectdata_("MQTT", Obj));

	UA_Objectdata = UA_Objectdata.concat(JsonTransformXml.prototype._GetPidUA_Objectdata_());
	UA_Objectdata = UA_Objectdata.concat(JsonTransformXml.prototype._GetEipUA_Objectdata_("EIP", Obj["EipModule"], Obj["EipVariable"], Obj["EipToOpcuaVariable"]));
	UA_Objectdata = UA_Objectdata.concat(JsonTransformXml.prototype._GetRegisterUA_Objectdata_("Register", Obj["RegisterModule"], Obj["RegisterVariable"], Obj["RegisterToOpcuaVariable"]));


	//UA_Objectdata = UA_Objectdata.concat(JsonTransformXml.prototype._GetUA_Objectdata_("MRTU Scaling", Obj));
	//UA_Objectdata = UA_Objectdata.concat(JsonTransformXml.prototype._GetUA_Objectdata_("MTCP Scaling", Obj));

	var UA_ServiceData = JsonTransformXml.prototype._GetUA_ServiceData_(UA_Objectdata);
	
	var xotree = new XML.ObjTree();
	var xml = xotree.writeXML(UA_ServiceData);
	return xml;
}

JsonTransformXml.prototype._TransformModbusDri_ = function(Protocol)
{
	var ModbusTask = new Array();
	var ModbusDriver = new Object();
	ModbusDriver["ModbusDriver"] = new Object();
	ModbusDriver["ModbusDriver"]["ModbusTask"] = new Array();

	var Obj = JsonTransformXml.prototype._GetModbusDriTransformObject_(Protocol);
	ModbusTask = JsonTransformXml.prototype._GetModbusRtuTask_(Obj["RtuModule"], Obj["RtuVariable"], Obj["RtuSetting"]);
	ModbusTask = ModbusTask.concat(JsonTransformXml.prototype._GetModbusAsciiTask_(Obj["AsciiModule"], Obj["AsciiVariable"], Obj["AsciiSetting"]));
	ModbusTask = ModbusTask.concat(JsonTransformXml.prototype._GetModbusTcpTask_(Obj["TcpModule"], Obj["TcpVariable"], Obj["TcpSetting"]));
	ModbusDriver["ModbusDriver"]["ModbusTask"] = ModbusTask;
	
	ModbusDriver = JsonTransformXml.prototype._SortTaskId_(ModbusDriver);
	
	var xotree = new XML.ObjTree();
	var xml = xotree.writeXML(ModbusDriver);
	return xml;
}

JsonTransformXml.prototype._SortTaskId_ = function(object)
{
	var length = object["ModbusDriver"]["ModbusTask"].length;
	for(var i=0; i<length; i++)
	{
		object["ModbusDriver"]["ModbusTask"][i]["TaskId"] = i;
	}
	return object;
}

JsonTransformXml.prototype._GetModbusDriTransformObject_ = function()
{
	var Return=new Object();  var Class = new LoadFile();
	Return["RtuModule"] = Class.ReadFile("./File/RTU_Module/Module.json", new Object());
	Return["RtuVariable"] = Class.ReadFile("./File/RTU_Module/RtuVariable.json", new Object());
	Return["RtuSetting"] = Class.ReadFile("./File/RTU_Module/RtuSetting.json", new Object());
	Return["AsciiModule"] = Class.ReadFile("./File/ASCII_Module/Module.json", new Object());
	Return["AsciiVariable"] = Class.ReadFile("./File/ASCII_Module/AsciiVariable.json", new Object());
	Return["AsciiSetting"] = Class.ReadFile("./File/ASCII_Module/AsciiSetting.json", new Object());
	Return["TcpModule"] = Class.ReadFile("./File/TCP_Module/Module.json", new Object());
	Return["TcpVariable"] = Class.ReadFile("./File/TCP_Module/TcpVariable.json", new Object());
	Return["TcpSetting"] = Class.ReadFile("./File/TCP_Module/TcpSetting.json", new Object());
	Class=null;
	return Return;
}

JsonTransformXml.prototype._GetThereAreVariablesInTheModuleIndex_ = function(Module, Variable, ComPort)
{
	var number = Object.keys(Module[ComPort]);
	var NeedNumber = new Array();
	for(var i=0; i<number.length; i++)
	{
		if(typeof(Variable[number[i]]) == "object")
		{
			NeedNumber.push(number[i]);
		}
	}
	return NeedNumber;
}

JsonTransformXml.prototype._GetTheVariableGroupNumberInTheSingleModule_ = function(Variable, NeedNumber)
{
	var GroupNumber=new Object();
	var SystemVariable = Object.keys(Variable[NeedNumber]);
	for(var j=0; j<SystemVariable.length; j++)
	{
		var ModbusGroupNumber = Variable[NeedNumber][SystemVariable[j]]["ModbusGroupNumber"];
		GroupNumber[ModbusGroupNumber]=new Object();
	}
	GroupNumber = Object.keys(GroupNumber);
	return GroupNumber;
}

JsonTransformXml.prototype._GetRetryCount_ = function(Container, Setting)
{
	if( typeof(Setting["Retry"]) == "undefined" ) return;
	if( Setting["Retry"] == true )
	{
		if( (Container["DataModel"] == 1) || (Container["DataModel"] == 3) )
		{
			Container["ReWriteCount"] = Setting["RetryCount"];
		}
	}
	return;
}

JsonTransformXml.prototype._GetMbItem_ = function(GroupNumber, ModuleType, Module, Variable, NeedNumber)
{
	var Return=new Object();
	var MbItemArray=new Array();
	var DataModel;
	var SystemVariable = Object.keys(Variable[NeedNumber]);
	for(var k=0; k<SystemVariable.length; k++)
	{
		if(GroupNumber == Variable[NeedNumber][SystemVariable[k]]["ModbusGroupNumber"])
		{
			var obj = new Object();
			DataModel = SystemVariable[k].split("-")[0];
			obj["Address"]=Variable[NeedNumber][SystemVariable[k]]["Address"];
			obj["DataType"]=JsonTransformXml.prototype._GetDataType_(SystemVariable[k].split("-")[1]);
			obj["Swap"]=JsonTransformXml.prototype._GetSwap_(Variable[NeedNumber][SystemVariable[k]]["Swap"]);
			obj["Name"]=ModuleType+"_No."+NeedNumber+"_"+Module[NeedNumber]["ModuleName"]+"_"+DataModel+"."+Variable[NeedNumber][SystemVariable[k]]["VariableName"];
			MbItemArray.push(obj);
		}
	}
	Return["MbItem"] = MbItemArray;  Return["DataModel"] = DataModel;
	return Return;
}

JsonTransformXml.prototype._GetMbGroup_ = function(NeedNumber, ModuleType, Module, Setting, Variable)
{
	var MbGroup = new Object();
	MbGroup["MbGroup"] = new Array();
	for(var i=0; i<NeedNumber.length; i++){
		var SystemVariable = Object.keys(Variable[NeedNumber[i]]);
		var GroupNumber = JsonTransformXml.prototype._GetTheVariableGroupNumberInTheSingleModule_(Variable, NeedNumber[i]);
		for(var j=0; j<GroupNumber.length; j++)
		{
			var Container=new Object();
			Container["MbItem"]=new Array();
			var obj = JsonTransformXml.prototype._GetMbItem_(GroupNumber[j], ModuleType, Module, Variable, NeedNumber[i]);
			var MbItemArray = obj["MbItem"];
			Container["Name"] = NeedNumber[i];
			Container["DataModel"] = JsonTransformXml.prototype._GetDataModel_(obj["DataModel"]);
			Container["MbItem"].push(MbItemArray);
			Container["ResponseTimeout"] = Setting[NeedNumber[i]]["Timeout"];
			Container["SlaveId"] = Setting[NeedNumber[i]]["SlaveId"];
			JsonTransformXml.prototype._GetRetryCount_(Container, Setting[NeedNumber[i]]);
			Container["StartAddress"] = MbItemArray[0]["Address"];
			var DataTypeNumber=JsonTransformXml.prototype._GetModbusAddressInterval_(MbItemArray[0]["DataType"]);
			Container["Length"] = DataTypeNumber*MbItemArray.length;
			MbGroup["MbGroup"].push(Container);
		}
	}
	return MbGroup["MbGroup"];
}

JsonTransformXml.prototype._GetModbusLanTask_=function(ModuleType, Setting, MbGroupArray, NeedNumber)
{
	if(MbGroupArray.length == 0)	{return;}
	var ModbusTask=new Object();
	ModbusTask["TaskName"] = "Task";
	ModbusTask["TaskId"] = -1;
	ModbusTask["PollingRate"] = Setting[NeedNumber]["PollingRate"];
	ModbusTask["Connecter"] = new Object();
	ModbusTask["Connecter"]["ProtocolType"] = JsonTransformXml.prototype._GetModbusProtocolType_(ModuleType);
	ModbusTask["Connecter"]["Ethernet"] = new Object();
	ModbusTask["Connecter"]["Ethernet"]["IP"] = Setting[NeedNumber]["IP"];
	ModbusTask["Connecter"]["Ethernet"]["Port"] = Setting[NeedNumber]["Port"];
	ModbusTask["MbGroup"] = new Array();
	ModbusTask["MbGroup"] = MbGroupArray;
	return ModbusTask;
}

JsonTransformXml.prototype._GetModbusComPortTask_=function(ModuleType, MbGroupArray, ComPort)
{
	if(MbGroupArray.length == 0)	{return;}
	
	var Class = new LoadFile();
	var ComPortSetting = Class.ReadFile("./File/ComPortInterfaceSetting.json", new Object());
	
	var ModbusTask=new Object();
	ModbusTask["TaskName"] = "Task";
	ModbusTask["TaskId"] = -1;
	ModbusTask["PollingRate"] = ComPortSetting[ComPort]["PollingRate"];

	ModbusTask["Connecter"] = new Object();
	ModbusTask["Connecter"]["ProtocolType"] = JsonTransformXml.prototype._GetModbusProtocolType_(ModuleType);
	ModbusTask["Connecter"]["Serial"] = new Object();
	ModbusTask["Connecter"]["Serial"]["DeviceName"] = ComPortSetting[ComPort]["DevicePath"];
	ModbusTask["Connecter"]["Serial"]["Baud"]       = ComPortSetting[ComPort]["BaudRate"];
	ModbusTask["Connecter"]["Serial"]["Parity"]     = JsonTransformXml.prototype._GetModbusParity_(ComPortSetting[ComPort]["Parity"]);
	ModbusTask["Connecter"]["Serial"]["DataBit"]    = ComPortSetting[ComPort]["DataBits"];
	ModbusTask["Connecter"]["Serial"]["StopBit"]    = ComPortSetting[ComPort]["StopBits"];
	ModbusTask["MbGroup"] = new Array();
	ModbusTask["MbGroup"] = MbGroupArray;
	Class=null;
	return ModbusTask;
}

JsonTransformXml.prototype._GetModbusTcpTask_ = function(Module, Variable, Setting)
{
	var LAN = Object.keys(Module);
	var ModbusTaskArray = new Array();
	var NeedNumber = new Array();
	var ModbusGroupNumber=new Object();
	var ModuleType="MTCP";
	for(var i=0; i<LAN.length; i++)
	{
		var NeedNumber = JsonTransformXml.prototype._GetThereAreVariablesInTheModuleIndex_(Module, Variable, LAN[i]);
		for(var j=0; j<NeedNumber.length; j++)
		{
			var NumberArray = new Array(NeedNumber[j]);
			var MbGroupArray = JsonTransformXml.prototype._GetMbGroup_(NumberArray, ModuleType, Module[LAN[i]], Setting, Variable);
			var ModbusTask = JsonTransformXml.prototype._GetModbusLanTask_(ModuleType, Setting, MbGroupArray, NeedNumber[j]);
			if(ModbusTask != null)
			{
				ModbusTaskArray.push(ModbusTask);
			}
		}
	}
	return ModbusTaskArray;
}

JsonTransformXml.prototype._GetModbusAsciiTask_ = function(Module, Variable, Setting)
{
	var ComPort = Object.keys(Module);
	var ModbusTaskArray = new Array();
	var NeedNumber = new Array();
	var ModbusGroupNumber=new Object();
	var ModuleType="MASCII";
	for(var i=0; i<ComPort.length; i++)
	{
		var NeedNumber = JsonTransformXml.prototype._GetThereAreVariablesInTheModuleIndex_(Module, Variable, ComPort[i]);
		var MbGroupArray = JsonTransformXml.prototype._GetMbGroup_(NeedNumber, ModuleType, Module[ComPort[i]], Setting, Variable);
		var ModbusTask = JsonTransformXml.prototype._GetModbusComPortTask_(ModuleType, MbGroupArray, ComPort[i]);
		if(ModbusTask != null)
		{
			ModbusTaskArray.push(ModbusTask);
		}
	}
	return ModbusTaskArray;
}

JsonTransformXml.prototype._GetModbusRtuTask_ = function(Module, Variable, Setting)
{
	var ComPort = Object.keys(Module);
	var ModbusTaskArray = new Array();
	var NeedNumber = new Array();
	var ModbusGroupNumber=new Object();
	var ModuleType="MRTU";
	for(var i=0; i<ComPort.length; i++)
	{
		var NeedNumber = JsonTransformXml.prototype._GetThereAreVariablesInTheModuleIndex_(Module, Variable, ComPort[i]);
		var MbGroupArray = JsonTransformXml.prototype._GetMbGroup_(NeedNumber, ModuleType, Module[ComPort[i]], Setting, Variable);
		var ModbusTask = JsonTransformXml.prototype._GetModbusComPortTask_(ModuleType, MbGroupArray, ComPort[i]);
		if(ModbusTask != null)
		{
			ModbusTaskArray.push(ModbusTask);
		}
	}
	return ModbusTaskArray;
}

JsonTransformXml.prototype._TransformMqttDri_ = function(Protocol)
{
	var Obj  = JsonTransformXml.prototype._GetMqttModuleJsonObject_();
	var LAN = Object.keys(Obj["Module"]); //LAN1,LAN2,LAN3
	var NeedNumber=new Array();
	for(var i=0; i<LAN.length; i++)
	{
		var ModuleIndex=JsonTransformXml.prototype._GetThereAreVariablesInTheModuleIndex_(Obj["Module"], Obj["Variable"], LAN[i]);
		NeedNumber = NeedNumber.concat(ModuleIndex);
	}
	var PreliminaryData=JsonTransformXml.prototype._GetMqttPreliminaryData_(NeedNumber, Obj["Setting"]);
	var DetailData=JsonTransformXml.prototype._GetMqttDetailData_(PreliminaryData, Obj["Variable"]);
	
	var MQTTTask 	= new Array();
	var MQTTDriver 	= new Object();
	MQTTDriver["MQTTDriver"] = new Object();
	MQTTDriver["MQTTDriver"]["MQTTTask"] = new Array();
	
	MQTTTask = JsonTransformXml.prototype._GetMqttTask_(DetailData);
	MQTTDriver["MQTTDriver"]["MQTTTask"] = MQTTTask;

	var xotree = new XML.ObjTree();
	var xml = xotree.writeXML(MQTTDriver);
	return xml;
}

JsonTransformXml.prototype._GetMqttPreliminaryData_ = function(ModuleIndexArray, SettingObject)
{
	var Return=new Object();
	for(var i=0; i<ModuleIndexArray.length; i++)
	{
		var MqttConnection = SettingObject[ModuleIndexArray[i]]["MqttConnection"];
		for(var j=0;j<MqttConnection.length; j++)
		{
			if(typeof(Return[MqttConnection[j]]) == "undefined")
			{
				Return[MqttConnection[j]]=new Object();
				Return[MqttConnection[j]]["ModuleIndex"]=new Array();
			}
			Return[MqttConnection[j]]["ModuleIndex"].push(ModuleIndexArray[i]);
		}
	}
	return Return;
}

JsonTransformXml.prototype._GetMqttDetailData_ = function(PreliminaryData, VariableObject)
{
	var Return=new Array();
	var LocalBroker = JsonTransformXml.prototype._GetLocalBrokerData_();
	var Class = new LoadFile();
	var RemoteBroker = Class.ReadFile("./File/IoT_Platform/RemoteBroker.json", new Object());
	Class = new GetValue();
	var Broker=Object.keys(PreliminaryData);
	for(var i=0; i<Broker.length; i++)
	{
		var obj=new Object();
		if(Broker[i] == "Broker (Local)")
		{
			obj["IP"]       =document.location.hostname;
			obj["Port"]     =LocalBroker["port"];
			obj["Keepalive"]=60;
			obj["Username"] =LocalBroker["account"];
			obj["Password"] =LocalBroker["password"];
			obj["isSecure"] =JsonTransformXml.prototype._GetSecureNumber_(LocalBroker["isSecure"]);
		}
		else if(Broker[i].indexOf(" (Remote)") != -1)
		{
			var Index = Object.keys(RemoteBroker);
			for(var j=0; j<Index.length; j++)
			{
				if((RemoteBroker[Index[j]]["Name"]+" (Remote)") == Broker[i])
				{
					obj["IP"]        = RemoteBroker[Index[j]]["IP"];
					obj["Port"]      = RemoteBroker[Index[j]]["Port"];
					obj["Keepalive"] = RemoteBroker[Index[j]]["Keepalive"];
					obj["Username"]  = RemoteBroker[Index[j]]["Account"];
					obj["Password"]  = RemoteBroker[Index[j]]["Password"];
					obj["isSecure"]  = JsonTransformXml.prototype._GetSecureNumber_(RemoteBroker[Index[j]]["SSL/TLS"]);
					obj["CaCertFile"] = RemoteBroker[Index[j]]["CaCertFile"];
					obj["CertFile"]  = RemoteBroker[Index[j]]["CertFile"];
					obj["KeyFile"]  = RemoteBroker[Index[j]]["KeyFile"];
				}
			}
		}
		obj["VariableName"]=new Array();  obj["SubscribeTopic"]=new Array();  obj["SubscribeQoS"]=new Array();
		obj["PublishTopic"]=new Array();  obj["PublishQoS"]=new Array();  obj["Retain"]=new Array(); obj["VariableIndex"]=new Array();
		var ModuleIndex=PreliminaryData[Broker[i]]["ModuleIndex"];
		for(var j=0; j<ModuleIndex.length; j++)
		{
			var VariableIndex=Object.keys(VariableObject[ModuleIndex[j]]);
			for(var z=0; z<VariableIndex.length; z++)
			{
				var RuntimeVariableName=Class.GetRuntimeVariableName("MQTT", ModuleIndex[j], VariableIndex[z]);
				obj["VariableName"].push(RuntimeVariableName);
				obj["SubscribeTopic"].push(VariableObject[ModuleIndex[j]][VariableIndex[z]]["SubscribeTopic"]);
				obj["SubscribeQoS"].push(VariableObject[ModuleIndex[j]][VariableIndex[z]]["SubscribeQoS"]);
				obj["PublishTopic"].push(VariableObject[ModuleIndex[j]][VariableIndex[z]]["PublishTopic"]);
				obj["PublishQoS"].push(VariableObject[ModuleIndex[j]][VariableIndex[z]]["PublishQoS"]);
				obj["Retain"].push(JsonTransformXml.prototype._GetRetainNumber_(VariableObject[ModuleIndex[j]][VariableIndex[z]]["Retain"]));
				obj["VariableIndex"].push(VariableIndex[z]);				
			}
		}
		Return.push(jQuery.parseJSON(JSON.stringify(obj)));
	}
	return Return;
}
JsonTransformXml.prototype._GetMqttModuleJsonObject_ = function()
{
	var Return = new Object();  var Class = new LoadFile();
	Return["Module"] 	= Class.ReadFile("./File/MQTT_Module/Module.json", new Object());
	Return["Variable"] 	= Class.ReadFile("./File/MQTT_Module/MqttVariable.json", new Object());
	Return["Setting"] 	= Class.ReadFile("./File/MQTT_Module/MqttSetting.json", new Object());
	Class = null;
	return Return;
}
JsonTransformXml.prototype._GetMqttTask_ = function(DetailData)
{
	var Index=Object.keys(DetailData);
	var MQTTTask = new Array();
	for(var i=0; i<Index.length; i++)
	{
		var Obj=new Object();
		Obj["TaskID"]=i;
		Obj["Connecter"]=new Object();
		Obj["Connecter"]["IP"]       =DetailData[Index[i]]["IP"];
		Obj["Connecter"]["Port"]     =DetailData[Index[i]]["Port"];
		Obj["Connecter"]["Keepalive"]=DetailData[Index[i]]["Keepalive"];
		Obj["Connecter"]["Username"] =DetailData[Index[i]]["Username"];
		Obj["Connecter"]["Password"] =DetailData[Index[i]]["Password"];
		Obj["Connecter"]["isSecure"] =DetailData[Index[i]]["isSecure"];
		if(typeof(DetailData[Index[i]]["CaCertFile"]) != "undefined")
		{
			Obj["Connecter"]["CACertFile"] =DetailData[Index[i]]["CaCertFile"];
			Obj["Connecter"]["CertFile"] =DetailData[Index[i]]["CertFile"];
			Obj["Connecter"]["KeyFile"] =DetailData[Index[i]]["KeyFile"];
		}
		Obj["MQItem"]=new Array();
		for(var j=0; j<DetailData[Index[i]]["VariableName"].length; j++)
		{
			var object=new Object();
			object["Name"]    =DetailData[Index[i]]["VariableName"][j];
			object["SubTopic"]=DetailData[Index[i]]["SubscribeTopic"][j];
			object["SubQoS"]  =DetailData[Index[i]]["SubscribeQoS"][j];
			object["PubTopic"]=DetailData[Index[i]]["PublishTopic"][j];
			object["PubQoS"]  =DetailData[Index[i]]["PublishQoS"][j];
			object["Property"]=JsonTransformXml.prototype._GetProperty_(DetailData[Index[i]]["VariableIndex"][j].split("-")[0]);
			object["DataType"]=JsonTransformXml.prototype._GetDataType_(DetailData[Index[i]]["VariableIndex"][j].split("-")[1]);
			object["Retain"]  =DetailData[Index[i]]["Retain"][j];
			Obj["MQItem"].push(jQuery.parseJSON(JSON.stringify(object)));
		}
		MQTTTask.push(jQuery.parseJSON(JSON.stringify(Obj)));
	}	
	return MQTTTask;
}

JsonTransformXml.prototype._TransformVariableXml_ = function()
{
	var Variable = new Object();
	Variable["DataTable"] = new Object();
	Variable["DataTable"]["Data"] = new Array();
	var array = new Array();
	var Class = new LoadFile();
	var Module = Class.ReadFile("./File/ASCII_Module/Module.json", new Object());
	var VariableObject = Class.ReadFile("./File/ASCII_Module/AsciiVariable.json", new Object());
	array = JsonTransformXml.prototype._GetVariableXmlItem_("MASCII", Module, VariableObject);
	
	Module = Class.ReadFile("./File/RTU_Module/Module.json", new Object());
	VariableObject = Class.ReadFile("./File/RTU_Module/RtuVariable.json", new Object());
	array = array.concat(JsonTransformXml.prototype._GetVariableXmlItem_("MRTU", Module, VariableObject));
	
	Module = Class.ReadFile("./File/TCP_Module/Module.json", new Object());
	VariableObject = Class.ReadFile("./File/TCP_Module/TcpVariable.json", new Object());
	array = array.concat(JsonTransformXml.prototype._GetVariableXmlItem_("MTCP", Module, VariableObject));

	Module = Class.ReadFile("./File/MQTT_Module/Module.json", new Object());
	VariableObject = Class.ReadFile("./File/MQTT_Module/MqttVariable.json", new Object());
	array = array.concat(JsonTransformXml.prototype._GetVariableXmlItem_("MQTT", Module, VariableObject));
	
	Module = Class.ReadFile("./File/EIP_Module/Module.json", new Object());
	VariableObject = Class.ReadFile("./File/EIP_Module/EipVariable.json", new Object());
	array = array.concat(JsonTransformXml.prototype._GetEipVariableXmlItem_("EIP", Module, VariableObject));

	Module = Class.ReadFile("./File/Register_Module/Module.json", new Object());
	VariableObject = Class.ReadFile("./File/Register_Module/RegisterVariable.json", new Object());
	array = array.concat(JsonTransformXml.prototype._GetRegisterVariableXmlItem_("Register", Module, VariableObject));


	array = array.concat(JsonTransformXml.prototype._GetVirtualVariableXmlItem_());
	Class = null;
	
	Variable["DataTable"]["Data"] = array;
	var xotree = new XML.ObjTree();
	var xml = xotree.writeXML(Variable);
	return xml;
}
JsonTransformXml.prototype._GetRegisterVariableXmlItem_ = function(ModuleType, Module, Variable)
{
	var Return = new Array();
	var Information = new Array();
	var ComPort = Object.keys(Module);
	var number = Object.keys(Variable);
	var ModuleName;
	var Class = new LoadFile();	
	var RegisterModule = Class.ReadFile("./File/Register_Module/Module.json", new Object());
	for(var i=0; i<number.length; i++)
	{
		ModuleName = RegisterModule[number[i]]["ModuleName"];
		Information = JsonTransformXml.prototype._CollectRegisterVariableInformation_(Variable, number[i]);
		Return = Return.concat(JsonTransformXml.prototype._RegisterCombinationData_(ModuleType, number[i], ModuleName, Information));
	}
	return Return;
}
JsonTransformXml.prototype._CollectRegisterVariableInformation_ = function(Variable, number)
{
	var Return=new Array();
	var Information=new Array();
	var SystemVariable = Object.keys(Variable[number]);
	var length = SystemVariable.length;
	for(var j=0; j<length; j++)
	{
		if(typeof(Variable[number][SystemVariable[j]]) == "object" && 
		   typeof(Variable[number][SystemVariable[j]]["VariableName"]) == "string" &&
		   Variable[number][SystemVariable[j]]["VariableName"] != "")
		{
			Information=new Array();
			Information.push(Variable[number][SystemVariable[j]]["VariableName"]);
			Information.push(SystemVariable[j].split("-")[0]);
			Information.push(JsonTransformXml.prototype._GetDataType_(SystemVariable[j].split("-")[1]));
			Information.push(Variable[number][SystemVariable[j]]["Description"]);
			Information.push(Variable[number][SystemVariable[j]]["Number"]);
			Return.push(Information);
		}
	}
	return Return;
}





JsonTransformXml.prototype._GetEipVariableXmlItem_ = function(ModuleType, Module, Variable)
{
	var Return = new Array();
	var Information = new Array();
	var ComPort = Object.keys(Module);
	var number = Object.keys(Variable);
	var ModuleName;
	var Class = new LoadFile();	
	var EipSetting = Class.ReadFile("./File/EIP_Module/EipSetting.json", new Object());
	for(var i=0; i<number.length; i++)
	{
		ModuleName = EipSetting[number[i]]["NickName"];
		Information = JsonTransformXml.prototype._CollectEipVariableInformation_(Variable, number[i]);
		Return = Return.concat(JsonTransformXml.prototype._CombinationData_(ModuleType, number[i], ModuleName, Information));
	}
	return Return;
}

JsonTransformXml.prototype._GetVariableXmlItem_ = function(ModuleType, Module, Variable)
{
	var Return = new Array();
	var Information = new Array();
	var ComPort = Object.keys(Module);
	var number = Object.keys(Variable);
	var ModuleName;
	for(var i=0; i<number.length; i++)
	{
		ModuleName = JsonTransformXml.prototype._CollectModuleName_(Module, ComPort, number[i]);
		Information = JsonTransformXml.prototype._CollectVariableInformation_(Variable, number[i]);
		Return = Return.concat(JsonTransformXml.prototype._CombinationData_(ModuleType, number[i], ModuleName, Information));
	}
	return Return;
}

JsonTransformXml.prototype._GetVirtualVariableXmlItem_ = function()
{
	var Return = new Array(), Class = new LoadFile();
	var PidOperation=Class.ReadFile("./File/PID_Operation/PidOperation.json", new Object());
	var VirtualPoint = new Array("Min", "Max", "SetPoint", "Kp", "Ki", "Kd", "ControllerMode", "SampleTime", "AutoTune", "Status");
	var ComparisonValue = new Array("Min", "Max", "SetValue", "Kp", "Ki", "Kd", "ControllerMode", "SampleTime", "AutoTune", "Status");
	var Access = new Array(0, 0, 2, 2, 2, 2, 2, 2, 2, 0);
	var Type = new Array(11, 11, 11, 11, 11, 11, 1, 6, 1, 1);
	var PidNumber = Object.keys(PidOperation);
	for(var i=0; i<PidNumber.length; i++){
		if(PidOperation[PidNumber[i]]["InputModuleVariableIndex"] == "//" ||
		   PidOperation[PidNumber[i]]["OutputModuleVariableIndex"] == "//"){
			continue;
		}
		for(var j=0; j<VirtualPoint.length; j++){
			var DefaultValue=PidOperation[PidNumber[i]][ComparisonValue[j]];
			if(ComparisonValue[j] == "AutoTune"){
				DefaultValue=JsonTransformXml.prototype._GetPidAutoTune_(DefaultValue);
			}
			else if(ComparisonValue[j] == "ControllerMode"){
				DefaultValue=JsonTransformXml.prototype._GetPidControllerMode_(DefaultValue);
			}
			var obj = new Object();
			obj["Identifier"] = 1;
			obj["NameId"] = "PID_"+PidOperation[PidNumber[i]]["Name"]+"."+VirtualPoint[j];
			obj["Access"] = Access[j];
			obj["Type"] = Type[j];
			obj["Size"] = 1;
			obj["DefaultValue"] = DefaultValue;
			Return.push(obj);
		}
	}
	return Return;
}

JsonTransformXml.prototype._CombinationScaleVariableData_ = function(ModuleType, number, ModuleName, Information)
{
	var Return=new Array();
	for(var j=0; j<Information.length; j++)
	{
		if( Information[j][8] == true )
		{
			var obj = new Object();
			obj["NameId"]            = ModuleType+"_No."+number+"_"+ModuleName+"_"+Information[j][0]+"_Scale"+"."+Information[j][4];
			obj["Access"]            = JsonTransformXml.prototype._GetReadWriteType_(Information[j][0]);
			obj["ReferenceVariable"] = ModuleType+"_No."+number+"_"+ModuleName+"_"+Information[j][0]+"."+Information[j][1];
			obj["OriginalMin"]       = Information[j][2];
			obj["OriginalMax"]       = Information[j][3];
			obj["TargetMin"]         = Information[j][5];
			obj["TargetMax"]         = Information[j][6];
			obj["OffsetValue"]       = Information[j][7];
			obj["Description"]       = Information[j][9];
			Return.push(obj);
		}
	}
	return Return;
}

JsonTransformXml.prototype._CollectScaleVariableInformation_ = function(Variable, number)
{
	var Return=new Array();
	var Information=new Array();
	var SystemVariable = Object.keys(Variable[number]);
	for(var j=0; j<SystemVariable.length; j++)
	{
		if(typeof(Variable[number][SystemVariable[j]]) == "object" && 
		   typeof(Variable[number][SystemVariable[j]]["VariableName"]) == "string" &&
		   Variable[number][SystemVariable[j]]["VariableName"] != "")
		{
			Information=new Array();
			Information.push(SystemVariable[j].split("-")[0]);
			Information.push(Variable[number][SystemVariable[j]]["VariableName"]);
			Information.push(Variable[number][SystemVariable[j]]["InputDataMin"]);
			Information.push(Variable[number][SystemVariable[j]]["InputDataMax"]);
			Information.push(Variable[number][SystemVariable[j]]["ScaleVariableName"]);
			Information.push(Variable[number][SystemVariable[j]]["OutputDataMin"]);
			Information.push(Variable[number][SystemVariable[j]]["OutputDataMax"]);
			Information.push(Variable[number][SystemVariable[j]]["Offset"]);
			Information.push(Variable[number][SystemVariable[j]]["TransformScaling"]);
			Information.push(Variable[number][SystemVariable[j]]["Description"]);
			Return.push(Information);
		}
	}
	return Return;
}

JsonTransformXml.prototype._GetScaleVariableXmlItem_ = function(ModuleType, Module, Variable)
{
	var Return = new Array();
	var Information = new Array();
	var ComPort = Object.keys(Module);
	var number = Object.keys(Variable);
	var ModuleName;
	for(var i=0; i<number.length; i++)
	{
		ModuleName = JsonTransformXml.prototype._CollectModuleName_(Module, ComPort, number[i]);
		Information = JsonTransformXml.prototype._CollectScaleVariableInformation_(Variable, number[i]);
		Return = Return.concat(JsonTransformXml.prototype._CombinationScaleVariableData_(ModuleType, number[i], ModuleName, Information));
	}
	return Return;
}

JsonTransformXml.prototype._TransformScaleVariableTableXml_ = function()
{
	var Variable = new Object();
	Variable["ScaleDataTable"] = new Object();
	Variable["ScaleDataTable"]["ScaleData"] = new Array();
	var array = new Array();
	var Class = new LoadFile();
	var Module = Class.ReadFile("./File/TCP_Module/Module.json", new Object());
	var VariableObject = Class.ReadFile("./File/TCP_Module/TcpScalingVariable.json", new Object());
	array = JsonTransformXml.prototype._GetScaleVariableXmlItem_("MTCP", Module, VariableObject);

	var Module = Class.ReadFile("./File/RTU_Module/Module.json", new Object());
	var VariableObject = Class.ReadFile("./File/RTU_Module/RtuScalingVariable.json", new Object());
	array = array.concat(JsonTransformXml.prototype._GetScaleVariableXmlItem_("MRTU", Module, VariableObject));

	Variable["ScaleDataTable"]["ScaleData"] = array;
	var xotree = new XML.ObjTree();
	var xml = xotree.writeXML(Variable);
	return xml;
}

JsonTransformXml.prototype._CombinationBitwiseVariableData_ = function(ModuleType, number, ModuleName, Information)
{
	var Return=new Array();
	for(var i=0; i<Information.length; i++)
	{
		for(var j=3; j<Information[i].length; j=j+2)
		{
			if(Information[i][j] != null && Information[i][j] != '')
			{
				var obj = new Object();
				obj["NameId"]            = ModuleType+"_No."+number+"_"+ModuleName+"_"+Information[i][0]+"_Bitwise"+"."+Information[i][j];
				obj["ReferenceVariable"] = ModuleType+"_No."+number+"_"+ModuleName+"_"+Information[i][0]+"."+Information[i][1];
				obj["BitShift"]          = Information[i][j+1];
				obj["Description"]       = Information[i][2];
				Return.push(obj);
			}
		}
	}
	return Return;
}

JsonTransformXml.prototype._CollectBitNameTagInformation_ = function(Information, Variable)
{
	var Return=new Array();
	var BitNameId = "";
	var BitTotalNumber = 0;

	if(Variable["DataType"] == "Short" || Variable["DataType"] == "Unsigned Short") BitTotalNumber = 16;
	else if(Variable["DataType"] == "Long" || Variable["DataType"] == "Unsigned Long")  BitTotalNumber = 32;
	for(var i=0; i<BitTotalNumber; i++)
	{
		BitNameId = "BitTagName-" + i.toString();
		if(Variable[BitNameId] != null && Variable[BitNameId] != '')
		{
			Information.push(Variable[BitNameId]);
			Information.push(i);
		}
	}
}

JsonTransformXml.prototype._CollectBitwiseVariableInformation_ = function(Variable, number)
{
	var Return=new Array();
	var Information=new Array();
	var SystemVariable = Object.keys(Variable[number]);
	for(var j=0; j<SystemVariable.length; j++)
	{
		if(typeof(Variable[number][SystemVariable[j]]) == "object" && 
		   typeof(Variable[number][SystemVariable[j]]["VariableName"]) == "string" &&
		   Variable[number][SystemVariable[j]]["VariableName"] != "")
		{
			Information=new Array();
			Information.push(SystemVariable[j].split("-")[0]);
			Information.push(Variable[number][SystemVariable[j]]["VariableName"]);
			Information.push(Variable[number][SystemVariable[j]]["Description"]);
			JsonTransformXml.prototype._CollectBitNameTagInformation_(Information, Variable[number][SystemVariable[j]]);
			Return.push(Information);
		}
	}
	return Return;
}

JsonTransformXml.prototype._GetBitwiseVariableXmlItem_ = function(ModuleType, Module, Variable)
{
	var Return = new Array();
	var Information = new Array();
	var ComPort = Object.keys(Module);
	var number = Object.keys(Variable);
	var ModuleName;
	for(var i=0; i<number.length; i++)
	{
		ModuleName = JsonTransformXml.prototype._CollectModuleName_(Module, ComPort, number[i]);
		Information = JsonTransformXml.prototype._CollectBitwiseVariableInformation_(Variable, number[i]);
		Return = Return.concat(JsonTransformXml.prototype._CombinationBitwiseVariableData_(ModuleType, number[i], ModuleName, Information));
	}
	return Return;
}

JsonTransformXml.prototype._TransformBitwiseVariableTableXml_ = function()
{
	var Variable = new Object();
	Variable["BitwiseDataTable"] = new Object();
	Variable["BitwiseDataTable"]["BitwiseData"] = new Array();
	var array = new Array();
	var Class = new LoadFile();
	var Module = Class.ReadFile("./File/TCP_Module/Module.json", new Object());
	var VariableObject = Class.ReadFile("./File/TCP_Module/TcpBitwiseVariable.json", new Object());
	array = JsonTransformXml.prototype._GetBitwiseVariableXmlItem_("MTCP", Module, VariableObject);

	var Module = Class.ReadFile("./File/RTU_Module/Module.json", new Object());
	var VariableObject = Class.ReadFile("./File/RTU_Module/RtuBitwiseVariable.json", new Object());
	array = array.concat(JsonTransformXml.prototype._GetBitwiseVariableXmlItem_("MRTU", Module, VariableObject));

	Variable["BitwiseDataTable"]["BitwiseData"] = array;
	var xotree = new XML.ObjTree();
	var xml = xotree.writeXML(Variable);
	return xml;
}

JsonTransformXml.prototype._CollectModuleName_ = function(Module, ComPort, number)
{
	for(var j=0; j<ComPort.length; j++)
	{
		if(typeof(Module[ComPort[j]][number]) == "object" && 
		   typeof(Module[ComPort[j]][number]["ModuleName"]) == "string")
		{
			ModuleName = Module[ComPort[j]][number]["ModuleName"];
		}
	}
	return ModuleName;
}

JsonTransformXml.prototype._CollectEipVariableInformation_ = function(Variable, number)
{
	var Return=new Array();
	var Information=new Array();
	var SystemVariable = Object.keys(Variable[number]);
	var length = parseInt(Global_EipSetting[number]["ModeType"].split("-")[0]);
	for(var j=0; j<length; j++)
	{
		if(typeof(Variable[number][SystemVariable[j]]) == "object" && 
		   typeof(Variable[number][SystemVariable[j]]["VariableName"]) == "string" &&
		   Variable[number][SystemVariable[j]]["VariableName"] != "")
		{
			Information=new Array();
			Information.push(Variable[number][SystemVariable[j]]["VariableName"]);
			Information.push(SystemVariable[j].split("-")[0]);
			Information.push(JsonTransformXml.prototype._GetDataType_(SystemVariable[j].split("-")[1]));
			Information.push(Variable[number][SystemVariable[j]]["Description"]);
			Return.push(Information);
		}
	}
	return Return;
}

JsonTransformXml.prototype._CollectVariableInformation_ = function(Variable, number)
{
	var Return=new Array();
	var Information=new Array();
	var SystemVariable = Object.keys(Variable[number]);
	for(var j=0; j<SystemVariable.length; j++)
	{
		if(typeof(Variable[number][SystemVariable[j]]) == "object" && 
		   typeof(Variable[number][SystemVariable[j]]["VariableName"]) == "string" &&
		   Variable[number][SystemVariable[j]]["VariableName"] != "")
		{
			Information=new Array();
			Information.push(Variable[number][SystemVariable[j]]["VariableName"]);
			Information.push(SystemVariable[j].split("-")[0]);
			Information.push(JsonTransformXml.prototype._GetDataType_(SystemVariable[j].split("-")[1]));
			Information.push(Variable[number][SystemVariable[j]]["Description"]);
			Return.push(Information);
		}
	}
	return Return;
}

JsonTransformXml.prototype._CombinationData_ = function(ModuleType, number, ModuleName, Information)
{
	var Return=new Array();
	for(var j=0; j<Information.length; j++)
	{
		var obj = new Object();
		obj["Identifier"] = 0;
		obj["NameId"] = ModuleType+"_No."+number+"_"+ModuleName+"_"+Information[j][1]+"."+Information[j][0];
		obj["Access"] = JsonTransformXml.prototype._GetReadWriteType_(Information[j][1]);
		obj["Type"] = Information[j][2];
		obj["Size"] = 1;
		obj["DefaultValue"] = 0;
		if(Information[j][3] != "")
		{
			obj["Description"] = Information[j][3];
		}
		Return.push(obj);
	}
	return Return;
}
JsonTransformXml.prototype._RegisterCombinationData_ = function(ModuleType, number, ModuleName, Information)
{
	var Return=new Array();
	for(var j=0; j<Information.length; j++)
	{
		var obj = new Object();
		obj["Identifier"] = 1;
		obj["NameId"] = "Internal" + "_No." + number + "_" + ModuleName + "." + Information[j][0];
		obj["Access"] = JsonTransformXml.prototype._GetReadWriteType_(Information[j][1]);
		obj["Type"] = Information[j][2];
		obj["Size"] = 1;
		obj["DefaultValue"] = 0;
		if(Information[j][3] != "")
		{
			obj["Description"] = Information[j][3];
		}
		Return.push(obj);
	}
	return Return;
}


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

JsonTransformXml.prototype._GetModbusAddressInterval_ = function(DataTypeNumber)
{
	var Return;
	switch(parseInt(DataTypeNumber))
	{
		case 6:
		case 7:
		case 10:
			Return = 2;
		break;
		case 11:
			Return = 4;
		break;
		default:
			Return = 1;
	}
	return Return;
}

JsonTransformXml.prototype._GetInputOutputData_ = function(string)
{
	var Return;
	if(string == "DO")		{Return = "OutputData_";}
	else if(string == "DI")	{Return = "InputData_";}
	else if(string == "AO")	{Return = "OutputData_";}
	else if(string == "AI")	{Return = "InputData_";}
	return Return;
}

JsonTransformXml.prototype._GetModbusParity_ = function(string)
{
	var Return;
	if(string == "None")		{Return = "N";}
	else if(string == "Odd")	{Return = "O";}
	else if(string == "Even")	{Return = "E";}
	return Return;
}

JsonTransformXml.prototype._GetModbusProtocolType_ = function(string)
{
	var Return;
	if(string == "MRTU")		{Return = 0;}
	else if(string == "MTCP")	{Return = 1;}
	else if(string == "MASCII")	{Return = 2;}
	return Return;
}

JsonTransformXml.prototype._GetSwap_ = function(bool)
{
	var Return;
	if(bool == false)			{Return = 0;}
	else if(bool == true)		{Return = 1;}
	return Return;
}

JsonTransformXml.prototype._GetDataModel_ = function(string)
{
	var Return;
	if(string == "DO")		{Return = 1;}
	else if(string == "DI")	{Return = 0;}
	else if(string == "AO")	{Return = 3;}
	else if(string == "AI")	{Return = 2;}
	return Return;
}

JsonTransformXml.prototype._GetReadWriteType_ = function(string)
{
	var Return;
	if(string == "DO")			{Return = 2;}
	else if(string == "DI")		{Return = 0;}
	else if(string == "AO")		{Return = 2;}
	else if(string == "AI")		{Return = 0;}
	return Return;
}

JsonTransformXml.prototype._GetDataType_ = function(string)
{
	var Return;
	if(string == "Bool")				{Return = 1;}
	else if(string == "SByte")			{Return = 2;}
	else if(string == "Byte")			{Return = 3;}
	else if(string == "Short")			{Return = 4;}
	else if(string == "Unsigned Short")	{Return = 5;}
	else if(string == "Long")			{Return = 6;}
	else if(string == "Unsigned Long")	{Return = 7;}
	else if(string == "Int64")			{Return = 8;}
	else if(string == "Unsigned Int64")	{Return = 9;}
	else if(string == "Float")			{Return = 10;}
	else if(string == "Double")			{Return = 11;}
	else if(string == "String")			{Return = 12;}
	else if(string == "Unknow_Type")	{Return = 999;}
	return Return;
}

JsonTransformXml.prototype._GetClientVariablePrefixWords_ = function(ModuleType, string)
{
	var Return;
	if(ModuleType=="MRTU" || ModuleType=="MTCP" || ModuleType=="MASCII" || ModuleType=="EIP" || ModuleType=="MRTU Scaling" || ModuleType=="MTCP Scaling")
	{
		if(string == "DO")			{Return = "Coil_Status";}
		else if(string == "DI")		{Return = "Input_Status";}
		else if(string == "AO")		{Return = "Holding_Registers";}
		else if(string == "AI")		{Return = "Input_Registers";}
	}
	else if(ModuleType=="MQTT")
	{
		if(string == "DO")			{Return = "DIO";}
		else if(string == "DI")		{Return = "DI";}
		else if(string == "AO")		{Return = "AIO";}
		else if(string == "AI")		{Return = "AI";}
	}
	return Return;
}

JsonTransformXml.prototype._GetProperty_ = function(Attribute)
{
	var Property;
	Attribute = JsonTransformXml.prototype._GetReadWriteType_(Attribute);
	switch(parseInt(Attribute))
	{
		case 0:
			Property = 1;
		break;
		case 1:
			Property = 2;
		break;
		case 2:
			Property = 3;
		break;
	}
	return Property;
}

JsonTransformXml.prototype._GetRetainNumber_ = function(Retain)
{
	var RetainNumber;
	if(Retain == false)			{RetainNumber = 0;}
	else if(Retain == true)		{RetainNumber = 1;}
	return RetainNumber;
}

JsonTransformXml.prototype._GetSecureNumber_ = function(SecureBool)
{
	var Return;
	if(SecureBool==false || SecureBool=="false")	{Return = 0;}
	else if(SecureBool==true || SecureBool=="true")	{Return = 1;}
	return Return;
}

JsonTransformXml.prototype._GetPidAutoTune_ = function(Bool)
{
	var Return;
	if(Bool==false |Bool=="false")		{Return = 0;}
	else if(Bool==true || Bool=="true")	{Return = 1;}
	return Return;
}

JsonTransformXml.prototype._GetPidControllerMode_ = function(ControllerMode)
{
	var Return;
	if(ControllerMode=="DIRECT")		{Return = 0;}
	else if(ControllerMode=="REVERSE")	{Return = 1;}
	return Return;
}

JsonTransformXml.prototype._GetPidModuleVariabName_ = function(ModuleVariableIndex)
{
	if(ModuleVariableIndex == "//"){
		return 0;
	}
	var Return;
	var array=ModuleVariableIndex.split("/");
	var ModuleType=array[0];
	var ModuleIndex=array[1];
	var VariableIndex=array[2];
	if(array[0] == "MRTU Scaling" || array[0] == "MTCP Scaling")
	{

		var Module=GetValue.prototype._GetGlobalModule_(ModuleType);
		var ModuleName=JsonTransformXml.prototype._GetModuleName_(Module, ModuleIndex);
		var Variable=GetValue.prototype._GetGlobalVariable_(ModuleType);
		var VariableName=GetValue.prototype._GetModulePidScalingVariableName_(Variable, ModuleIndex, VariableIndex);
		ModuleType = ModuleType.split(" ")[0];
		Return=ModuleType+"_No."+ModuleIndex+"_"+ModuleName+"_"+VariableIndex.split("-")[0]+"_Scale."+VariableName;

	}
	else
	{
		var Module=GetValue.prototype._GetGlobalModule_(ModuleType);
		var ModuleName=JsonTransformXml.prototype._GetModuleName_(Module, ModuleIndex);
		var Variable=GetValue.prototype._GetGlobalVariable_(ModuleType);
		var VariableName=GetValue.prototype._GetModuleVariableName_(Variable, ModuleIndex, VariableIndex);
		Return=ModuleType+"_No."+ModuleIndex+"_"+ModuleName+"_"+VariableIndex.split("-")[0]+"."+VariableName;
	}
	return Return;
}