public Settings() { string settingFileName = ConfigPath.GetConfigFilePath("agent.settings"); if (File.Exists(settingFileName)) { doc.Load(settingFileName); } var datacenters = doc.SelectNodes("//datacenter2"); foreach (XmlNode dcn in datacenters) { DataCenter2 dc = new DataCenter2(); dc.Ip = this.GetAttribute(dcn, "ip"); dc.Port = int.Parse(this.GetAttribute(dcn, "port", "0")); // dc.WirelessIp = this.GetAttribute(dcn, "wirelessip"); // dc.WirelessPort = int.Parse(this.GetAttribute(dcn, "wirelessport", "0")); dataCenters.Add(dc); } // Site var siteNode = doc.SelectNodes("//site")[0]; this.SysName = this.GetAttribute(siteNode, "sysname"); this.SysSt = this.GetAttribute(siteNode, "sysst"); this.Mn = this.GetAttribute(siteNode, "mn"); this.Sno = this.GetAttribute(siteNode, "sno"); this.LoadPassword(); // Devices var devices = doc.SelectNodes("//devices/device"); foreach (XmlNode deviceNode in devices) { Device device = this.ParseDeviceNode(deviceNode); this.devices.Add(device); var codes = deviceNode.SelectNodes("code"); foreach (XmlNode codeNode in codes) { string code = codeNode.InnerText; XmlNode fieldNode = codeNode.Attributes.GetNamedItem("field"); if (fieldNode != null) { device.AddCode(code, fieldNode.Value); } } } // Load NaI device config. // TODO: string configNaIPath = ConfigPath.GetDeviceConfigFilePath("scada.naidevice", "0.9"); DeviceEntry entry = LoadFromConfig("Scada.NaIDevice", configNaIPath); this.NaIDeviceSn = (StringValue)entry["DeviceSn"]; this.MinuteAdjust = (StringValue)entry["MinuteAdjust"]; }
public void LoadSettings() { string settingFileName = ConfigPath.GetConfigFilePath(AgentXml); if (File.Exists(settingFileName)) { doc.Load(settingFileName); } var datacenters = doc.SelectNodes("//datacenter2"); foreach (XmlNode dcn in datacenters) { DataCenter2 dc = new DataCenter2(); dc.BaseUrl = this.GetAttribute(dcn, "BaseUrl"); dataCenters.Add(dc); } // Site var siteNode = doc.SelectNodes("//site")[0]; this.SysName = this.GetAttribute(siteNode, "sysname"); this.SysSt = this.GetAttribute(siteNode, "sysst"); this.Mn = this.GetAttribute(siteNode, "mn"); this.Sno = this.GetAttribute(siteNode, "sno"); this.Station = this.GetAttribute(siteNode, "station"); // debug-data-time var devicesNode = doc.SelectNodes("//devices")[0]; string debugDataTime = this.GetAttribute(devicesNode, "use-debug-data-time"); if (!string.IsNullOrEmpty(debugDataTime)) { this.UseDebugDataTime = debugDataTime == "true"; } // Load Password this.LoadPassword(); // Devices var devices = doc.SelectNodes("//devices/device"); foreach (XmlNode deviceNode in devices) { Device device = this.ParseDeviceNode(deviceNode); this.devices.Add(device); var codes = deviceNode.SelectNodes("code"); foreach (XmlNode codeNode in codes) { string code = codeNode.InnerText; XmlNode fieldNode = codeNode.Attributes.GetNamedItem("field"); if (fieldNode != null) { XmlNode typeNode = codeNode.Attributes.GetNamedItem("type"); string dataType = "real"; if (typeNode != null) { dataType = typeNode.Value; } device.AddCode(code, fieldNode.Value, dataType); } } } // Load NaI device config. // TODO: string configLabrPath = ConfigPath.GetDeviceConfigFilePath(Devices.Labr, "0.9"); if (File.Exists(configLabrPath)) { DeviceEntry entry = LoadFromConfig(Devices.Labr, configLabrPath); this.NaIDeviceSn = (StringValue)entry["DeviceSn"]; this.MinuteAdjust = (StringValue)entry["MinuteAdjust"]; } }
public void LoadSettings() { string settingFileName = ConfigPath.GetConfigFilePath(AgentXml); if (File.Exists(settingFileName)) { doc.Load(settingFileName); } var datacenters = doc.SelectNodes("//datacenter2"); foreach (XmlNode dcn in datacenters) { DataCenter2 dc = new DataCenter2(); dc.BaseUrl = this.GetAttribute(dcn, "BaseUrl"); dataCenters.Add(dc); } // Site var siteNode = doc.SelectNodes("//site")[0]; this.SysName = this.GetAttribute(siteNode, "sysname"); this.SysSt = this.GetAttribute(siteNode, "sysst"); this.Mn = this.GetAttribute(siteNode, "mn"); this.Sno = this.GetAttribute(siteNode, "sno"); this.Station = this.GetAttribute(siteNode, "station"); // debug-data-time var devicesNode = doc.SelectNodes("//devices")[0]; string debugDataTime = this.GetAttribute(devicesNode, "use-debug-data-time"); if (!string.IsNullOrEmpty(debugDataTime)) { this.UseDebugDataTime = debugDataTime == "true"; } // Load Password this.LoadPassword(); // Devices var devices = doc.SelectNodes("//devices/device"); foreach (XmlNode deviceNode in devices) { Device device = this.ParseDeviceNode(deviceNode); this.devices.Add(device); var codes = deviceNode.SelectNodes("code"); foreach (XmlNode codeNode in codes) { string code = codeNode.InnerText; XmlNode fieldNode = codeNode.Attributes.GetNamedItem("field"); if (fieldNode != null) { XmlNode typeNode = codeNode.Attributes.GetNamedItem("type"); string dataType = "real"; if (typeNode != null) dataType = typeNode.Value; device.AddCode(code, fieldNode.Value, dataType); } } } // Load NaI device config. // TODO: string configLabrPath = ConfigPath.GetDeviceConfigFilePath(Devices.Labr, "0.9"); if (File.Exists(configLabrPath)) { DeviceEntry entry = LoadFromConfig(Devices.Labr, configLabrPath); this.NaIDeviceSn = (StringValue)entry["DeviceSn"]; this.MinuteAdjust = (StringValue)entry["MinuteAdjust"]; } }