GSF.PhasorProtocols.IEC61850_90_5.DigitalDefinition.SetLabel C# (CSharp) Method

SetLabel() public method

Sets the individual labels for specified bit in this DigitalDefinition.

In the final version of the protocol each digital bit can be labeled, but we read them out as one big string in the "Label" property so this property allows individual access to each label.

Note that the draft 6 implementation of the protocol supports one label for all 16-bits, however draft 7 (i.e., version 1) supports a label for each of the 16 bits.

public SetLabel ( int index, string value ) : void
index int Index of desired bit label to access.
value string Value of the bit label to assign.
return void
        public void SetLabel(int index, string value)
        {
            if (index < 0 || index >= LabelCount)
                throw new IndexOutOfRangeException("Invalid label index specified.  Note that there are " + LabelCount + " labels per digital available in " + DraftRevision + " of the IEC 61850-90-5 protocol");

            if (value.Trim().Length > 16)
                throw new OverflowException("Individual label length cannot exceed " + 16);
            else
            {
                string current = Label.PadRight(MaximumLabelLength);
                string left = "";
                string right = "";

                if (index > 0)
                    left = current.Substring(0, index * 16);

                if (index < 15)
                    right = current.Substring((index + 1) * 16);

                Label = left + value.GetValidLabel().PadRight(16) + right;
            }
        }