//Json轉換Xml
ModuleToLocalDataLoggerCommon.prototype._GetDataLogServiceXml_ = function()
{
	var LocalDataLogger = ModuleToLocalDataLoggerCommon.prototype._GetLocalDataLoggerJson_();
	var RuntimeVariableArray = new Array();
	RuntimeVariableArray = RuntimeVariableArray.concat(ModuleToLocalDataLoggerCommon.prototype._GetRtuToLocalDataLoggerVariableArray_());
	RuntimeVariableArray = RuntimeVariableArray.concat(ModuleToLocalDataLoggerCommon.prototype._GetTcpToLocalDataLoggerVariableArray_());
	var DeviceSDCardPath = ModuleToLocalDataLoggerCommon.prototype._GetDeviceSDCardPath_();
	
	var XmlObject=new Object();
	XmlObject["DataLogService"]=new Object();
	XmlObject["DataLogService"]["FileLogger"]=new Object();
	XmlObject["DataLogService"]["FileLogger"]["TaskName"]     = "DataLogTask";
	XmlObject["DataLogService"]["FileLogger"]["TaskID"]       = 1;
	XmlObject["DataLogService"]["FileLogger"]["StorageDevice "] = DeviceSDCardPath;
	XmlObject["DataLogService"]["FileLogger"]["LogPath"]      = "/mnt/" + LocalDataLogger["FolderName"] + "/log.csv";
	XmlObject["DataLogService"]["FileLogger"]["Rotation"]     = LocalDataLogger["FileLength"];
	XmlObject["DataLogService"]["FileLogger"]["Times"]        = "local";
	XmlObject["DataLogService"]["FileLogger"]["SpaceUsage"]   = LocalDataLogger["DiskUsageRate"];
	XmlObject["DataLogService"]["FileLogger"]["IntervalTime"] = LocalDataLogger["LogInterval"];
	XmlObject["DataLogService"]["FileLogger"]["IsLogAllItems"] = "False";
	XmlObject["DataLogService"]["FileLogger"]["LogItems"] = new Object();
	XmlObject["DataLogService"]["FileLogger"]["LogItems"]["Name"] = new Array();
	XmlObject["DataLogService"]["FileLogger"]["LogItems"]["Name"] = RuntimeVariableArray;
	var xotree = new XML.ObjTree();
	var xml = xotree.writeXML(XmlObject);
	return xml;
}
ModuleToLocalDataLoggerCommon.prototype._GetDeviceSDCardPath_ = function()
{
	if(Global_FlashInformation == "/dev/ubi0_0")
	{
		return "/dev/mmcblk0p1";
	}
	else
	{
		return "/dev/mmcblk1p1";
	}
}
ModuleToLocalDataLoggerCommon.prototype._GetLocalDataLoggerJson_ = function()
{
	var Class = new LoadFile();
	var Return = Class.ReadFile("./File/IoT_Platform/LocalDataLogger.json", new Object());
	return Return;
}

ModuleToLocalDataLoggerCommon.prototype._GetRtuToLocalDataLoggerVariableArray_ = function()
{
	var Return = new Array();
	var Class = new LoadFile();
	var JsonVariable = Class.ReadFile("./File/RTU_Module/RtuToLocalDataLoggerVariable.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++)
		{
			if(JsonVariable[number[i]][SystemVariable[j]]["LocalDataLoggerRecord"] == true)
			{
				var ModuleName = JsonTransformXml.prototype._GetModuleName_(Module, number[i]);
				var RuntimeVariable = "MRTU_No."+number[i]+"_"+ModuleName+"_"+SystemVariable[j].split("-")[0]+"."+ModuleVariable[number[i]][SystemVariable[j]]["VariableName"];
				Return.push(RuntimeVariable);
			}
		}
	}
	return Return;
}

ModuleToLocalDataLoggerCommon.prototype._GetTcpToLocalDataLoggerVariableArray_ = function()
{
	var Return = new Array();
	var Class = new LoadFile();
	var JsonVariable = Class.ReadFile("./File/TCP_Module/TcpToLocalDataLoggerVariable.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++)
		{
			if(JsonVariable[number[i]][SystemVariable[j]]["LocalDataLoggerRecord"] == true)
			{
				var ModuleName = JsonTransformXml.prototype._GetModuleName_(Module, number[i]);
				var RuntimeVariable = "MTCP_No."+number[i]+"_"+ModuleName+"_"+SystemVariable[j].split("-")[0]+"."+ModuleVariable[number[i]][SystemVariable[j]]["VariableName"];
				Return.push(RuntimeVariable);
			}
		}
	}
	return Return;
}