public int AddLN(tLN lnode) { var ln = new tLN(); if (lnode == null) { ln.inst = (uint)(++tLDevice.nln); if (templates != null) { int i = templates.GetLNType("TEMPLATE.LNTYPE0"); System.Console.WriteLine("Index of lntmpl = " + i); if (i >= 0) { ln.lnClass = templates.LNodeType[i].lnClass; ln.lnType = templates.LNodeType[i].id; } else { tLNodeType lnt = new tLNodeType(); lnt.iedType = this.inst; lnt.lnClass = "TMPL"; lnt.id = "TEMPLATE.LNTYPE0"; var ig = templates.AddLNodeType(lnt); if (ig == -1) { return(-1); } ln.lnClass = lnt.lnClass; ln.lnType = lnt.id; } } else { ln.lnClass = "TMPL"; ln.lnType = "TEMPLATE.LNTYPE0"; } } else { ln = lnode; } int index = -1; if (this.LN == null) { this.LN = new tLN[1]; this.LN[0] = ln; index = 0; } else { System.Array.Resize <tLN>(ref this.lnField, this.lnField.Length + 1); index = this.lnField.Length - 1; lnField[index] = ln; } return(index); }
/// <summary> /// Use this constructor to create a new LN and verify if it is Valid, if there's no other /// LN in the LD with the same prefix, class and instance. Check Status property in order /// to know its status. /// </summary> /// <param name="ld"> /// A <see cref="tLDevice"/> to be used to check for duplicated instances. /// </param> /// <param name="lnClass"> /// A <see cref="System.String"/> with the name of the LN Class as on IEC 61850-7-x /// </param> /// <param name="prefix"> /// A <see cref="System.String"/> with the prefix on LN Class. /// </param> /// <param name="inst"> /// A <see cref="System.UInt32"/> with the instance number of the LN Class. /// </param> /// <param name="lnType"> /// A <see cref="tLNodeType"/> reference to instantied. /// </param> public tLN(tLDevice ld, string lnClass, string prefix, uint inst, tLNodeType lnType) { if (ld == null) { return; } if (lnType == null) { return; } if (inst == 0) { this.inst = ++index; } else { this.inst = inst; } this.lnClass = lnClass; this.lnType = lnType.id; // Search for duplicated LN if (ld.LN != null) { for (int i = 0; i < ld.LN.GetLength(0); i++) { tLN ln = ld.LN[i]; if (ln.prefix == this.prefix && ln.inst == this.inst && ln.lnClass == this.lnClass) { this.status = tStatusEnum.Invalid; break; } } this.status = tStatusEnum.Valid; } }
/// <summary> /// Use this constructor to create a new tLNode to be used on SCL's Substation section. /// </summary> /// <param name="ied"> /// A <see cref="tIED"/> witch contains the referer LD and LN in a configured system. Use null if no IED is /// referer because you are creating a Specification. /// </param> /// <param name="ld"> /// A <see cref="tLDevice"/> reference witch contains a LN to be referer in a configured system. Use null if no IED is /// referer because you are creating a Specification. /// </param> /// <param name="ln"> /// A <see cref="tLN"/> reference in configured system. Use null if no IED is /// referer because you are creating a Specification. /// </param> public tLNode(tIED ied, tLDevice ld, tLN ln) { if (ied != null) { this.iedNameField = ied.name; if(ld != null) this.ldInstField = ld.inst; else this.ldInstField = ""; } else this.iedNameField = "None"; if(ln != null) { this.lnInstField = (string) System.Convert.ChangeType(this.tLN.inst, typeof(string)); this.lnClassField = this.tLN.lnClass; this.lnTypeField = this.tLN.lnType; } else { this.ldInstField = ""; this.prefixField = ""; this.lnClass = "XSWI"; } }
public int AddLDevice(string inst, string ap, tDataTypeTemplates tpl) { if (tpl == null) { return(-1); } if (accessPointField == null) { AddAP(ap); } var ld = new tLDevice(); if (inst == null) { ld.inst = "TEMPLATE_LD" + (++tIED.nld).ToString(); } else { ld.inst = inst; } tLNodeType tln0; int lnt0 = tpl.GetLNType("TEMPLATE.LLN0"); if (lnt0 != -1) { tln0 = tpl.LNodeType [lnt0]; } else { tln0 = new tLNodeType(name, "LLN0", name + ".LLN0"); tpl.AddLNodeType(tln0); } tLNodeType tln; int lnt = tpl.GetLNType("TEMPLATE.LPHD"); if (lnt != -1) { tln = tpl.LNodeType [lnt]; } else { tln = new tLNodeType(name, "LPHD", name + ".LPHD"); tpl.AddLNodeType(tln); } var ln0 = new LN0(); ln0.lnType = tln0.id; ld.LN0 = ln0; var ln = new tLN(); ln.inst = 1; ln.lnType = tln.id; ln.lnClass = tln.lnClass; ld.AddLN(ln); int api = this.GetAP(ap); if (api == -1) { api = this.AddAP(ap); } return(this.AccessPoint[api].Server.AddLDevice(ld)); }