Exemplo n.º 1
0
        public int AddLDevice(tLDevice ld)
        {
            int index = -1;

            if (lDeviceField == null)
            {
                lDeviceField     = new tLDevice[1];
                lDeviceField [0] = ld;
                index            = 0;
            }
            else
            {
                System.Array.Resize <tLDevice> (ref this.lDeviceField,
                                                this.lDeviceField.Length + 1);
                index = this.lDeviceField.Length - 1;
                this.lDeviceField [index] = ld;
            }
            return(index);
        }
Exemplo n.º 2
0
        /// <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;
            }
        }
Exemplo n.º 3
0
		/// <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";
			}
		}
Exemplo n.º 4
0
        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));
        }