Esempio n. 1
0
            /// <summary>
            /// Get an element of an array or structure
            /// </summary>
            /// <returns>
            /// the MmsValue element.
            /// </returns>
            /// <param name='index'>
            /// index of the element starting with 0
            /// </param>
            /// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
            /// <exception cref="MmsValueException">This exception is thrown if the index is out of range.</exception>
            public MmsValue GetElement(int index)
            {
                MmsType type = GetType();

                if ((type == MmsType.MMS_ARRAY) || (type == MmsType.MMS_STRUCTURE))
                {
                    if ((index >= 0) && (index < Size()))
                    {
                        IntPtr value = MmsValue_getElement(valueReference, index);

                        if (value == IntPtr.Zero)
                        {
                            return(null);
                        }
                        else
                        {
                            return(new MmsValue(value));
                        }
                    }
                    else
                    {
                        throw new MmsValueException("Index out of bounds");
                    }
                }
                else
                {
                    throw new MmsValueException("Value is of wrong type");
                }
            }
Esempio n. 2
0
            /// <summary>
            /// Sets the element of an array or structure
            /// </summary>
            /// <remarks>
            /// After calling this function the native memory of the element will be managed by the array or structure.
            /// Therefore an element can only be used in a single array or structure.
            /// When the value is required in multiple arrays or structures
            /// a clone has to be created before using this function!
            /// To be save, always use a clone for setting the element.
            /// </remarks>
            /// <param name="index">index of the element starting with 0</param>
            /// <param name="elementValue">MmsValue instance that will be used as element value</param>
            /// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
            /// <exception cref="MmsValueException">This exception is thrown if the index is out of range.</exception>
            public void SetElement(int index, MmsValue elementValue)
            {
                MmsType elementType = GetType();

                if ((elementType == MmsType.MMS_ARRAY) || (elementType == MmsType.MMS_STRUCTURE))
                {
                    if ((index >= 0) && (index < Size()))
                    {
                        if (elementValue != null)
                        {
                            MmsValue_setElement(valueReference, index, elementValue.valueReference);

                            /* will be deleted by structure */
                            elementValue.responsableForDeletion = false;
                        }
                        else
                        {
                            MmsValue_setElement(valueReference, index, IntPtr.Zero);
                        }
                    }
                    else
                    {
                        throw new MmsValueException("Index out of bounds");
                    }
                }
                else
                {
                    throw new MmsValueException("Value is of wrong type");
                }
            }
Esempio n. 3
0
            void mmsValueInit()
            {
                sDataAttribute sda = (sDataAttribute)Marshal.PtrToStructure(self, typeof(sDataAttribute));

                if (sda.mmsValue != IntPtr.Zero)
                {
                    mmsValue = new MmsValue(sda.mmsValue);
                    mmsType  = mmsValue.GetType();
                }
            }
Esempio n. 4
0
            /// <summary>
            /// Sets the element of an array of structure
            /// </summary>
            /// <param name="index">index of the element starting with 0</param>
            /// <param name="elementValue">MmsValue instance that will be used as element value</param>
            /// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
            /// <exception cref="MmsValueException">This exception is thrown if the index is out of range.</exception>
            public void SetElement(int index, MmsValue elementValue)
            {
                MmsType elementType = GetType();

                if ((elementType == MmsType.MMS_ARRAY) || (elementType == MmsType.MMS_STRUCTURE))
                {
                    if ((index >= 0) && (index < Size()))
                    {
                        MmsValue_setElement(valueReference, index, elementValue.valueReference);
                    }
                    else
                    {
                        throw new MmsValueException("Index out of bounds");
                    }
                }
                else
                {
                    throw new MmsValueException("Value is of wrong type");
                }
            }
Esempio n. 5
0
            /// <summary>
            /// Get the type of ctlVal.
            /// </summary>
            /// <returns>MmsType required for the ctlVal value.</returns>
            public MmsType GetCtlValType()
            {
                MmsType ctlValType = (MmsType)ControlObjectClient_getCtlValType(self);

                return(ctlValType);
            }
Esempio n. 6
0
 public Item61850(string pathStr, FunctionalConstraint typeFc, MmsType typeMms)
 {
     path    = pathStr;
     typeFC  = typeFc;
     typeMMS = typeMms;
 }