/// <summary> /// Creates a logical device (LD) node for IEC type tree and returns it /// </summary> /// <param name="reader"></param> /// <returns> a LD node </returns> private void CreateLogicalDevicesIEC(NodeBase root, IEnumerable <XElement> elements, XNamespace ns) { foreach (XElement ld in elements) { //NodeLD logicalDevice = new NodeLD(String.Concat(root.Name, ld.Attribute("inst").Value)); NodeLD logicalDevice = new NodeLD(ld.Attribute("inst").Value); root.AddChildNode(logicalDevice); CreateLogicalNodesIEC(logicalDevice, from el in ld.Elements() where el.Name.LocalName.StartsWith("LN") select el, ns); } }
void createModelDevices(NodeLD ld, IedModel model) { LogicalDevice ldevice = new LogicalDevice(ld.Name, model); ld.SCLServerModelObject = ldevice; foreach (NodeLN ln in ld.GetChildNodes()) { createModelNodes(ln, ldevice); } }
/// <summary> /// Creates a logical device (LD) node and returns it /// </summary> /// <param name="reader"></param> /// <returns> a LD node </returns> private NodeLD CreateLogicalDevice(XmlReader reader, string _iedName) { reader.Read(); var logicalDevice = new NodeLD(String.Concat(_iedName, reader.GetAttribute("inst"))); while (reader.Read()) { // if a logical node element, create and add a LN child node if (reader.IsStartElement() && reader.Name.StartsWith("LN")) { logicalDevice.AddChildNode(CreateLogicalNode2(reader.ReadSubtree())); } } logicalDevice.SortImmediateChildren(); // alphabetical sort return(logicalDevice); }
public void BuildIECModelFromMMSModel() { iec.DefineNVL = ied.DefineNVL; iec.Revision = ied.Revision; iec.VendorName = ied.VendorName; iec.ModelName = ied.ModelName; foreach (NodeLD ld in ied.GetChildNodes()) // LD level { NodeLD ild = new NodeLD(ld.Name); ild.IsIecModel = true; ild = (NodeLD)iec.AddChildNode(ild); foreach (NodeLN ln in ld.GetChildNodes()) // LN level { NodeLN iln = new NodeLN(ln.Name); iln.IsIecModel = true; iln = (NodeLN)ild.AddChildNode(iln); foreach (NodeFC fc in ln.GetChildNodes()) // FC level - skipping { if (fc.Name == "RP" || fc.Name == "BR") { continue; } // keep knowing FC for DA foreach (NodeDO dO in fc.GetChildNodes()) // DO level { NodeDO ido = new NodeDO(dO.Name); ido.IsIecModel = true; // AddChildNode returns original object if the same name found (new object is forgotten) ido = (NodeDO)iln.AddChildNode(ido); // At this point, it can happen that we get DO more than once (same DO in several FC) // For DOs, this is ok, FC is not relevant for DOs // Next level is peculiar: can be DO (subDataObject) or a DA // At this point, we will distinguish between DO and DA as follows: // At the first guess, we suppose DA // We will LINK the corresponding DA from MMS tree, and record the FC // If another object with the same name comes in (from another FC branch in MMS tree) // That means that we are not DA but DO (multiple FCs) // And this all has to be done recursively foreach (NodeBase da in dO.GetChildNodes()) { recursiveLinkDA(da, ido, fc); } } } } } // Add rcbs to LNs foreach (NodeLD ld in urcbs.GetChildNodes()) // LD level { foreach (NodeRCB urcb in ld.GetChildNodes()) { NodeBase ln = iec.FindNodeByAddress(ld.Name, urcb.Name.Remove(urcb.Name.IndexOf("$"))); if (ln != null) { ln.LinkChildNodeByName(urcb); } } } foreach (NodeLD ld in brcbs.GetChildNodes()) // LD level { foreach (NodeRCB brcb in ld.GetChildNodes()) { NodeBase ln = iec.FindNodeByAddress(ld.Name, brcb.Name.Remove(brcb.Name.IndexOf("$"))); if (ln != null) { ln.LinkChildNodeByName(brcb); } } } // Add datasets to LNs foreach (NodeLD ld in lists.GetChildNodes()) // LD level { foreach (NodeVL vl in ld.GetChildNodes()) { NodeBase ln = iec.FindNodeByAddress(ld.Name, vl.Name.Remove(vl.Name.IndexOf("$"))); if (ln != null) { ln.LinkChildNodeByName(vl); } } } }