public bool LoadAlarmFromNode(XmlElement Node)//读取报警配置 { ListCond.Clear(); string xpath = "Alarms/Conditions"; XmlElement PrjNode = (XmlElement)Node.SelectSingleNode(xpath); foreach (XmlElement StaNode in PrjNode.ChildNodes) { Ccondition nCond = new Ccondition(); nCond.LoadFromNode(StaNode); ListCond.Add(nCond); } xpath = "Alarms/Vars"; PrjNode = (XmlElement)Node.SelectSingleNode(xpath); if (PrjNode != null) { foreach (XmlElement StaNode in PrjNode.ChildNodes) { foreach (CVar nVar in StaDevice.ListDevVar) { if (nVar.Name == StaNode.GetAttribute("Name")) { nVar.nVarAlarm = new CVarAlarm(); nVar.nVarAlarm.staName = Name; nVar.nVarAlarm.staAlarm = staAlarm; nVar.nVarAlarm.Name = StaNode.GetAttribute("Name"); nVar.nVarAlarm.LoadFromNode(StaNode); } } } } return(true); }
public bool GetAlarmFromXML()//获取报警配置 { XmlDocument MyXmlDoc = new XmlDocument(); MyXmlDoc.Load(CProject.sPrjPath + @"\Project\IO\Alarm.xml"); string xpath = "System/Project"; XmlElement childNode = (XmlElement)MyXmlDoc.SelectSingleNode(xpath); if (childNode == null) { return(false); } foreach (XmlElement StaNode in childNode.ChildNodes) { if (StaNode.Name != "Station") { continue; } foreach (CStation nSta in ListStation) { if (nSta.Name == StaNode.GetAttribute("Name")) { nSta.LoadAlarmFromNode(StaNode); break; } } } return(true); }