|
|
|
@ -136,6 +136,15 @@ namespace IEC61850
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_newVisibleString(string value);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_createArray(IntPtr elementType, int size);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_createEmptyArray(int size);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_createEmptyStructure(int size);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_newOctetString(int size, int maxSize);
|
|
|
|
|
|
|
|
|
@ -164,9 +173,12 @@ namespace IEC61850
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern ulong MmsValue_getBinaryTimeAsUtcMs (IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport ("iec61850", CallingConvention=CallingConvention.Cdecl)]
|
|
|
|
|
[DllImport("iec61850", CallingConvention=CallingConvention.Cdecl)]
|
|
|
|
|
static extern int MmsValue_getDataAccessError(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void MmsValue_setElement(IntPtr complexValue, int index, IntPtr elementValue);
|
|
|
|
|
|
|
|
|
|
internal IntPtr valueReference; /* reference to native MmsValue instance */
|
|
|
|
|
|
|
|
|
|
private bool responsableForDeletion; /* if .NET wrapper is responsable for the deletion of the native MmsValue instance */
|
|
|
|
@ -214,6 +226,10 @@ namespace IEC61850
|
|
|
|
|
valueReference = MmsValue_newIntegerFromInt64 (value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a new <see cref="IEC61850.Common.MmsValue"/> instance of type MMS_VISIBLE_STRING.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value">Value.</param>
|
|
|
|
|
public MmsValue (string value)
|
|
|
|
|
{
|
|
|
|
|
valueReference = MmsValue_newVisibleString(value);
|
|
|
|
@ -270,6 +286,53 @@ namespace IEC61850
|
|
|
|
|
this.setOctetString (octetString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a new MmsValue instance of type MMS_ARRAY. Array elements have the fiven type
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>the newly created array</returns>
|
|
|
|
|
/// <param name="elementType">array element type</param>
|
|
|
|
|
/// <param name="size">number of array elements</param>
|
|
|
|
|
public static MmsValue NewArray(MmsVariableSpecification elementType, int size)
|
|
|
|
|
{
|
|
|
|
|
if (size < 1)
|
|
|
|
|
throw new MmsValueException ("array requires at least one element");
|
|
|
|
|
|
|
|
|
|
IntPtr newValue = MmsValue_createArray (elementType.self, size);
|
|
|
|
|
|
|
|
|
|
return new MmsValue (newValue, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a new MmsValue instance of type MMS_ARRAY. Array elements are not initialized!
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>the newly created array</returns>
|
|
|
|
|
/// <param name="size">number of array elements</param>
|
|
|
|
|
public static MmsValue NewEmptyArray(int size)
|
|
|
|
|
{
|
|
|
|
|
if (size < 1)
|
|
|
|
|
throw new MmsValueException ("array requires at least one element");
|
|
|
|
|
|
|
|
|
|
IntPtr newValue = MmsValue_createEmptyArray (size);
|
|
|
|
|
|
|
|
|
|
return new MmsValue (newValue, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a new MmsValue instance of type MMS_STRUCTURE. Structure elements are not initialized!
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>the newly created array</returns>
|
|
|
|
|
/// <param name="size">number of structure elements</param>
|
|
|
|
|
public static MmsValue NewEmptyStructure(int size)
|
|
|
|
|
{
|
|
|
|
|
if (size < 1)
|
|
|
|
|
throw new MmsValueException ("structure requires at least one element");
|
|
|
|
|
|
|
|
|
|
IntPtr newValue = MmsValue_createEmptyStructure (size);
|
|
|
|
|
|
|
|
|
|
return new MmsValue (newValue, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Create a new MmsValue instance of type MMS_BINARY_TIME
|
|
|
|
|
/// </summary>
|
|
|
|
@ -427,6 +490,29 @@ namespace IEC61850
|
|
|
|
|
throw new MmsValueException ("Value is of wrong type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MmsDataAccessError GetDataAccessError ()
|
|
|
|
|
{
|
|
|
|
|