- .NET API: Added properties to MmsVariableSpecification class (LIB61850-460)

pull/535/head
Michael Zillgith 11 months ago
parent 830059fca2
commit ae02944918

@ -1,7 +1,7 @@
/* /*
* MmsVariableSpecification.cs * MmsVariableSpecification.cs
* *
* Copyright 2014 Michael Zillgith * Copyright 2014-2024 Michael Zillgith
* *
* This file is part of libIEC61850. * This file is part of libIEC61850.
* *
@ -121,6 +121,14 @@ namespace IEC61850
return (MmsType)MmsVariableSpecification_getType(self); return (MmsType)MmsVariableSpecification_getType(self);
} }
/// <summary>
/// The MmsValue type of the variable
/// </summary>
public MmsType MmsType
{
get { return (MmsType)MmsVariableSpecification_getType(self); }
}
/// <summary> /// <summary>
/// Gets the type of the array elements. /// Gets the type of the array elements.
/// </summary> /// </summary>
@ -130,7 +138,8 @@ namespace IEC61850
/// <exception cref="MmsValueException">This exception is thrown if the value is not of type MMS_ARRAY</exception> /// <exception cref="MmsValueException">This exception is thrown if the value is not of type MMS_ARRAY</exception>
public MmsVariableSpecification getArrayElementType() public MmsVariableSpecification getArrayElementType()
{ {
if (GetType() == MmsType.MMS_ARRAY) { if (GetType() == MmsType.MMS_ARRAY)
{
IntPtr varSpecPtr = MmsVariableSpecification.MmsVariableSpecification_getArrayElementSpecification(self); IntPtr varSpecPtr = MmsVariableSpecification.MmsVariableSpecification_getArrayElementSpecification(self);
return new MmsVariableSpecification(varSpecPtr, this); return new MmsVariableSpecification(varSpecPtr, this);
} }
@ -138,6 +147,23 @@ namespace IEC61850
throw new MmsValueException("specification is of wrong type"); throw new MmsValueException("specification is of wrong type");
} }
/// <summary>
/// The type of array elements (when the variable is of type MMS_ARRAY)
/// </summary>
public MmsVariableSpecification ArrayElementType
{
get
{
if (GetType() == MmsType.MMS_ARRAY)
{
IntPtr varSpecPtr = MmsVariableSpecification.MmsVariableSpecification_getArrayElementSpecification(self);
return new MmsVariableSpecification(varSpecPtr, this);
}
else
return null;
}
}
/// <summary> /// <summary>
/// Gets the element specification of a structure element /// Gets the element specification of a structure element
/// </summary> /// </summary>
@ -149,9 +175,11 @@ namespace IEC61850
/// </param> /// </param>
public MmsVariableSpecification GetElement(int index) public MmsVariableSpecification GetElement(int index)
{ {
if (GetType () == MmsType.MMS_STRUCTURE) { if (GetType() == MmsType.MMS_STRUCTURE)
{
if ((index >= 0) && (index < Size ())) { if ((index >= 0) && (index < Size()))
{
IntPtr varSpecPtr = MmsVariableSpecification_getChildSpecificationByIndex(self, index); IntPtr varSpecPtr = MmsVariableSpecification_getChildSpecificationByIndex(self, index);
return new MmsVariableSpecification(varSpecPtr, this); return new MmsVariableSpecification(varSpecPtr, this);
} }
@ -163,7 +191,28 @@ namespace IEC61850
} }
/// <summary> /// <summary>
/// Gets the name of the variable /// The element types for complex variables (MMS_STRUCTURE)
/// </summary>
public MmsVariableSpecification[] Elements
{
get
{
if (GetType() != MmsType.MMS_STRUCTURE)
return null;
List<MmsVariableSpecification> elements = new List<MmsVariableSpecification>();
for (int i = 0; i < Size(); i++)
{
elements.Add(GetElement(i));
}
return elements.ToArray();
}
}
/// <summary>
/// Gets the name of the variable (relative to the parent)
/// </summary> /// </summary>
/// <returns> /// <returns>
/// The name. /// The name.
@ -175,6 +224,17 @@ namespace IEC61850
return Marshal.PtrToStringAnsi(namePtr); return Marshal.PtrToStringAnsi(namePtr);
} }
/// <summary>
/// The name of the variable (relative to the parent)
/// </summary>
public string Name
{
get
{
return GetName();
}
}
/// <summary> /// <summary>
/// Get the "size" of the variable (array size, number of structure elements ...) /// Get the "size" of the variable (array size, number of structure elements ...)
/// </summary> /// </summary>
@ -183,6 +243,17 @@ namespace IEC61850
return MmsVariableSpecification_getSize(self); return MmsVariableSpecification_getSize(self);
} }
/// <summary>
/// The "size" of the variable (array size, number of structure elements ...)
/// </summary>
public int size
{
get
{
return MmsVariableSpecification_getSize(self);
}
}
/// <summary> /// <summary>
/// Determines whether the given value object matches this type /// Determines whether the given value object matches this type
/// </summary> /// </summary>
@ -214,7 +285,8 @@ namespace IEC61850
index = -1; index = -1;
} }
public object Current { public object Current
{
get { return value.GetElement(index); } get { return value.GetElement(index); }
} }

Loading…
Cancel
Save