|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
/*
|
|
|
|
|
* MmsValue.cs
|
|
|
|
|
*
|
|
|
|
|
* Copyright 2014 Michael Zillgith
|
|
|
|
|
* Copyright 2014-2025 Michael Zillgith
|
|
|
|
|
*
|
|
|
|
|
* This file is part of libIEC61850.
|
|
|
|
|
*
|
|
|
|
@ -21,11 +21,8 @@
|
|
|
|
|
* See COPYING file for the complete license text.
|
|
|
|
|
*/
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace IEC61850
|
|
|
|
@ -38,29 +35,29 @@ namespace IEC61850
|
|
|
|
|
public class MmsValue : IEnumerable, IDisposable
|
|
|
|
|
{
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_toString (IntPtr self);
|
|
|
|
|
static extern IntPtr MmsValue_toString(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern float MmsValue_toFloat (IntPtr self);
|
|
|
|
|
static extern float MmsValue_toFloat(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void MmsValue_setFloat (IntPtr self, float value);
|
|
|
|
|
static extern void MmsValue_setFloat(IntPtr self, float value);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern double MmsValue_toDouble (IntPtr self);
|
|
|
|
|
static extern double MmsValue_toDouble(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void MmsValue_setDouble (IntPtr self, double newFloatValue);
|
|
|
|
|
static extern void MmsValue_setDouble(IntPtr self, double newFloatValue);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.I1)]
|
|
|
|
|
static extern bool MmsValue_getBoolean (IntPtr self);
|
|
|
|
|
static extern bool MmsValue_getBoolean(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void MmsValue_setBoolean(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool value);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern UInt32 MmsValue_getBitStringAsInteger (IntPtr self);
|
|
|
|
|
static extern UInt32 MmsValue_getBitStringAsInteger(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void MmsValue_setBitStringFromInteger(IntPtr self, UInt32 intValue);
|
|
|
|
@ -82,64 +79,64 @@ namespace IEC61850
|
|
|
|
|
static extern bool MmsValue_getBitStringBit(IntPtr self, int bitPos);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern Int32 MmsValue_toInt32 (IntPtr self);
|
|
|
|
|
static extern Int32 MmsValue_toInt32(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void MmsValue_setInt32(IntPtr self, int value);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern Int64 MmsValue_toInt64 (IntPtr self);
|
|
|
|
|
static extern Int64 MmsValue_toInt64(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern UInt32 MmsValue_toUint32 (IntPtr self);
|
|
|
|
|
static extern UInt32 MmsValue_toUint32(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern int MmsValue_getType (IntPtr self);
|
|
|
|
|
static extern int MmsValue_getType(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void MmsValue_delete (IntPtr self);
|
|
|
|
|
static extern void MmsValue_delete(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_getElement (IntPtr complexValue, int index);
|
|
|
|
|
static extern IntPtr MmsValue_getElement(IntPtr complexValue, int index);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern int MmsValue_getArraySize (IntPtr self);
|
|
|
|
|
static extern int MmsValue_getArraySize(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern ulong MmsValue_getUtcTimeInMs (IntPtr self);
|
|
|
|
|
static extern ulong MmsValue_getUtcTimeInMs(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void MmsValue_setUtcTimeMs (IntPtr self, ulong timeval);
|
|
|
|
|
static extern void MmsValue_setUtcTimeMs(IntPtr self, ulong timeval);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern ulong MmsValue_getUtcTimeInMsWithUs(IntPtr self, [Out] uint usec);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern byte MmsValue_getUtcTimeQuality (IntPtr self);
|
|
|
|
|
static extern byte MmsValue_getUtcTimeQuality(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void MmsValue_setUtcTimeQuality (IntPtr self, byte timeQuality);
|
|
|
|
|
static extern void MmsValue_setUtcTimeQuality(IntPtr self, byte timeQuality);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern UInt32 MmsValue_toUnixTimestamp (IntPtr self);
|
|
|
|
|
static extern UInt32 MmsValue_toUnixTimestamp(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_newBoolean ([MarshalAs(UnmanagedType.I1)] bool value);
|
|
|
|
|
static extern IntPtr MmsValue_newBoolean([MarshalAs(UnmanagedType.I1)] bool value);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_newFloat (float value);
|
|
|
|
|
static extern IntPtr MmsValue_newFloat(float value);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_newDouble (double value);
|
|
|
|
|
static extern IntPtr MmsValue_newDouble(double value);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_newIntegerFromInt32 (Int32 integer);
|
|
|
|
|
static extern IntPtr MmsValue_newIntegerFromInt32(Int32 integer);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_newUnsignedFromUint32(UInt32 integer);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_newIntegerFromInt64 (Int64 integer);
|
|
|
|
|
static extern IntPtr MmsValue_newIntegerFromInt64(Int64 integer);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_newBitString(int bitSize);
|
|
|
|
@ -188,18 +185,18 @@ namespace IEC61850
|
|
|
|
|
static extern bool MmsValue_equals(IntPtr self, IntPtr otherValue);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_newBinaryTime ([MarshalAs(UnmanagedType.I1)] bool timeOfDay);
|
|
|
|
|
static extern IntPtr MmsValue_newBinaryTime([MarshalAs(UnmanagedType.I1)] bool timeOfDay);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void MmsValue_setBinaryTime (IntPtr self, UInt64 timestamp);
|
|
|
|
|
static extern void MmsValue_setBinaryTime(IntPtr self, UInt64 timestamp);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern ulong MmsValue_getBinaryTimeAsUtcMs (IntPtr self);
|
|
|
|
|
static extern ulong MmsValue_getBinaryTimeAsUtcMs(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport ("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_newUtcTimeByMsTime (UInt64 timestamp);
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern IntPtr MmsValue_newUtcTimeByMsTime(UInt64 timestamp);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention=CallingConvention.Cdecl)]
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern int MmsValue_getDataAccessError(IntPtr self);
|
|
|
|
|
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
@ -221,82 +218,84 @@ namespace IEC61850
|
|
|
|
|
|
|
|
|
|
private bool responsableForDeletion = false; /* if .NET wrapper is responsable for the deletion of the native MmsValue instance */
|
|
|
|
|
|
|
|
|
|
internal MmsValue (IntPtr value)
|
|
|
|
|
internal MmsValue(IntPtr value)
|
|
|
|
|
{
|
|
|
|
|
valueReference = value;
|
|
|
|
|
this.responsableForDeletion = false;
|
|
|
|
|
responsableForDeletion = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int EncodeMmsData(byte[] buffer, int bufPos, bool encode)
|
|
|
|
|
{
|
|
|
|
|
return MmsValue_encodeMmsData(this.valueReference, buffer, bufPos, encode);
|
|
|
|
|
return MmsValue_encodeMmsData(valueReference, buffer, bufPos, encode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int DecodeMmsData(int bufPos, int bufferLength, IntPtr endBufPo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return MmsValue_decodeMmsData(this.valueReference, bufPos, bufferLength, endBufPo);
|
|
|
|
|
return MmsValue_decodeMmsData(valueReference, bufPos, bufferLength, endBufPo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal MmsValue (IntPtr value, bool responsableForDeletion)
|
|
|
|
|
internal MmsValue(IntPtr value, bool responsableForDeletion)
|
|
|
|
|
{
|
|
|
|
|
valueReference = value;
|
|
|
|
|
this.responsableForDeletion = responsableForDeletion;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MmsValue (bool value)
|
|
|
|
|
public MmsValue(bool value)
|
|
|
|
|
{
|
|
|
|
|
valueReference = MmsValue_newBoolean (value);
|
|
|
|
|
valueReference = MmsValue_newBoolean(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MmsValue (float value)
|
|
|
|
|
public MmsValue(float value)
|
|
|
|
|
{
|
|
|
|
|
valueReference = MmsValue_newFloat (value);
|
|
|
|
|
valueReference = MmsValue_newFloat(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MmsValue (double value)
|
|
|
|
|
public MmsValue(double value)
|
|
|
|
|
{
|
|
|
|
|
valueReference = MmsValue_newDouble (value);
|
|
|
|
|
valueReference = MmsValue_newDouble(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MmsValue (int value)
|
|
|
|
|
public MmsValue(int value)
|
|
|
|
|
{
|
|
|
|
|
valueReference = MmsValue_newIntegerFromInt32 (value);
|
|
|
|
|
valueReference = MmsValue_newIntegerFromInt32(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MmsValue (UInt32 value)
|
|
|
|
|
public MmsValue(UInt32 value)
|
|
|
|
|
{
|
|
|
|
|
valueReference = MmsValue_newUnsignedFromUint32(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public MmsValue (long value)
|
|
|
|
|
public MmsValue(long value)
|
|
|
|
|
{
|
|
|
|
|
valueReference = MmsValue_newIntegerFromInt64 (value);
|
|
|
|
|
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)
|
|
|
|
|
public MmsValue(string value)
|
|
|
|
|
{
|
|
|
|
|
valueReference = MmsValue_newVisibleString(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
lock (this) {
|
|
|
|
|
if (valueReference != IntPtr.Zero) {
|
|
|
|
|
lock (this)
|
|
|
|
|
{
|
|
|
|
|
if (valueReference != IntPtr.Zero)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (responsableForDeletion)
|
|
|
|
|
MmsValue_delete (valueReference);
|
|
|
|
|
MmsValue_delete(valueReference);
|
|
|
|
|
|
|
|
|
|
valueReference = IntPtr.Zero;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~MmsValue ()
|
|
|
|
|
~MmsValue()
|
|
|
|
|
{
|
|
|
|
|
Dispose();
|
|
|
|
|
}
|
|
|
|
@ -329,7 +328,7 @@ namespace IEC61850
|
|
|
|
|
/// <param name='size'>
|
|
|
|
|
/// the current size of the octet string in bytes (defaults to 0)
|
|
|
|
|
/// </param>
|
|
|
|
|
public static MmsValue NewOctetString (int maxSize, int size = 0)
|
|
|
|
|
public static MmsValue NewOctetString(int maxSize, int size = 0)
|
|
|
|
|
{
|
|
|
|
|
IntPtr newValue = MmsValue_newOctetString(size, maxSize);
|
|
|
|
|
|
|
|
|
@ -339,11 +338,11 @@ namespace IEC61850
|
|
|
|
|
public MmsValue(byte[] octetString)
|
|
|
|
|
{
|
|
|
|
|
if (octetString.Length > 255)
|
|
|
|
|
throw new MmsValueException ("octet string too long");
|
|
|
|
|
throw new MmsValueException("octet string too long");
|
|
|
|
|
|
|
|
|
|
valueReference = MmsValue_newOctetString(octetString.Length, octetString.Length);
|
|
|
|
|
|
|
|
|
|
this.setOctetString (octetString);
|
|
|
|
|
setOctetString(octetString);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -355,11 +354,11 @@ namespace IEC61850
|
|
|
|
|
public static MmsValue NewArray(MmsVariableSpecification elementType, int size)
|
|
|
|
|
{
|
|
|
|
|
if (size < 1)
|
|
|
|
|
throw new MmsValueException ("array requires at least one element");
|
|
|
|
|
throw new MmsValueException("array requires at least one element");
|
|
|
|
|
|
|
|
|
|
IntPtr newValue = MmsValue_createArray (elementType.self, size);
|
|
|
|
|
IntPtr newValue = MmsValue_createArray(elementType.self, size);
|
|
|
|
|
|
|
|
|
|
return new MmsValue (newValue, true);
|
|
|
|
|
return new MmsValue(newValue, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -370,11 +369,11 @@ namespace IEC61850
|
|
|
|
|
public static MmsValue NewEmptyArray(int size)
|
|
|
|
|
{
|
|
|
|
|
if (size < 1)
|
|
|
|
|
throw new MmsValueException ("array requires at least one element");
|
|
|
|
|
throw new MmsValueException("array requires at least one element");
|
|
|
|
|
|
|
|
|
|
IntPtr newValue = MmsValue_createEmptyArray (size);
|
|
|
|
|
IntPtr newValue = MmsValue_createEmptyArray(size);
|
|
|
|
|
|
|
|
|
|
return new MmsValue (newValue, true);
|
|
|
|
|
return new MmsValue(newValue, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -385,11 +384,11 @@ namespace IEC61850
|
|
|
|
|
public static MmsValue NewEmptyStructure(int size)
|
|
|
|
|
{
|
|
|
|
|
if (size < 1)
|
|
|
|
|
throw new MmsValueException ("structure requires at least one element");
|
|
|
|
|
throw new MmsValueException("structure requires at least one element");
|
|
|
|
|
|
|
|
|
|
IntPtr newValue = MmsValue_createEmptyStructure (size);
|
|
|
|
|
IntPtr newValue = MmsValue_createEmptyStructure(size);
|
|
|
|
|
|
|
|
|
|
return new MmsValue (newValue, true);
|
|
|
|
|
return new MmsValue(newValue, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -400,17 +399,18 @@ namespace IEC61850
|
|
|
|
|
/// <param name="largeFormat">If set to <c>true</c> large 6 byte format.</param>
|
|
|
|
|
public static MmsValue NewBinaryTime(bool largeFormat)
|
|
|
|
|
{
|
|
|
|
|
IntPtr newValue = MmsValue_newBinaryTime (largeFormat);
|
|
|
|
|
IntPtr newValue = MmsValue_newBinaryTime(largeFormat);
|
|
|
|
|
|
|
|
|
|
return new MmsValue (newValue, true);
|
|
|
|
|
return new MmsValue(newValue, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the binary time.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="timestamp">Timestamp.</param>
|
|
|
|
|
public void SetBinaryTime(UInt64 timestamp) {
|
|
|
|
|
MmsValue_setBinaryTime (this.valueReference, timestamp);
|
|
|
|
|
public void SetBinaryTime(UInt64 timestamp)
|
|
|
|
|
{
|
|
|
|
|
MmsValue_setBinaryTime(valueReference, timestamp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -424,12 +424,14 @@ namespace IEC61850
|
|
|
|
|
/// The UTC time in ms.
|
|
|
|
|
/// </returns>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public ulong GetBinaryTimeAsUtcMs ()
|
|
|
|
|
public ulong GetBinaryTimeAsUtcMs()
|
|
|
|
|
{
|
|
|
|
|
if (GetType() == MmsType.MMS_BINARY_TIME)
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_BINARY_TIME) {
|
|
|
|
|
return MmsValue_getBinaryTimeAsUtcMs (valueReference);
|
|
|
|
|
} else
|
|
|
|
|
throw new MmsValueException ("Value is not a time type");
|
|
|
|
|
return MmsValue_getBinaryTimeAsUtcMs(valueReference);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException("Value is not a time type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -437,11 +439,11 @@ namespace IEC61850
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>the new MmsValue instance.</returns>
|
|
|
|
|
/// <param name="timestamp">the time value as milliseconds since epoch (1.1.1970 UTC).</param>
|
|
|
|
|
public static MmsValue NewUtcTime (UInt64 timestamp)
|
|
|
|
|
public static MmsValue NewUtcTime(UInt64 timestamp)
|
|
|
|
|
{
|
|
|
|
|
IntPtr newValue = MmsValue_newUtcTimeByMsTime (timestamp);
|
|
|
|
|
IntPtr newValue = MmsValue_newUtcTimeByMsTime(timestamp);
|
|
|
|
|
|
|
|
|
|
return new MmsValue (newValue, true);
|
|
|
|
|
return new MmsValue(newValue, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -471,9 +473,9 @@ namespace IEC61850
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// The type.
|
|
|
|
|
/// </returns>
|
|
|
|
|
public new MmsType GetType ()
|
|
|
|
|
public new MmsType GetType()
|
|
|
|
|
{
|
|
|
|
|
return (MmsType)MmsValue_getType (valueReference);
|
|
|
|
|
return (MmsType)MmsValue_getType(valueReference);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -487,18 +489,22 @@ namespace IEC61850
|
|
|
|
|
/// the number of elements (array/structure elements, octets, bits depending on type)
|
|
|
|
|
/// </returns>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public int Size ()
|
|
|
|
|
public int Size()
|
|
|
|
|
{
|
|
|
|
|
if ((GetType() == MmsType.MMS_ARRAY) || (GetType() == MmsType.MMS_STRUCTURE))
|
|
|
|
|
{
|
|
|
|
|
return MmsValue_getArraySize(valueReference);
|
|
|
|
|
}
|
|
|
|
|
else if (GetType() == MmsType.MMS_BIT_STRING)
|
|
|
|
|
{
|
|
|
|
|
if ((GetType () == MmsType.MMS_ARRAY) || (GetType () == MmsType.MMS_STRUCTURE)) {
|
|
|
|
|
return MmsValue_getArraySize (valueReference);
|
|
|
|
|
} else if (GetType () == MmsType.MMS_BIT_STRING) {
|
|
|
|
|
return MmsValue_getBitStringSize(valueReference);
|
|
|
|
|
}
|
|
|
|
|
else if (GetType () == MmsType.MMS_OCTET_STRING) {
|
|
|
|
|
else if (GetType() == MmsType.MMS_OCTET_STRING)
|
|
|
|
|
{
|
|
|
|
|
return MmsValue_getOctetStringSize(valueReference);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException ("Operation not supported for this type");
|
|
|
|
|
throw new MmsValueException("Operation not supported for this type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -507,13 +513,14 @@ namespace IEC61850
|
|
|
|
|
/// <returns>
|
|
|
|
|
/// The maximum size (in bytes) of the octet string
|
|
|
|
|
/// </returns>
|
|
|
|
|
public int MaxSize ()
|
|
|
|
|
public int MaxSize()
|
|
|
|
|
{
|
|
|
|
|
if (GetType() == MmsType.MMS_OCTET_STRING)
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_OCTET_STRING) {
|
|
|
|
|
return MmsValue_getOctetStringMaxSize(valueReference);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException ("Operation not supported for this type");
|
|
|
|
|
throw new MmsValueException("Operation not supported for this type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -525,11 +532,12 @@ namespace IEC61850
|
|
|
|
|
/// Byte array containing the bytes of the octet string.
|
|
|
|
|
/// </returns>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public byte[] getOctetString ()
|
|
|
|
|
public byte[] getOctetString()
|
|
|
|
|
{
|
|
|
|
|
if (GetType() == MmsType.MMS_OCTET_STRING)
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_OCTET_STRING) {
|
|
|
|
|
IntPtr buffer = MmsValue_getOctetStringBuffer(valueReference);
|
|
|
|
|
int bufferSize = this.Size();
|
|
|
|
|
int bufferSize = Size();
|
|
|
|
|
|
|
|
|
|
byte[] octetString = new byte[bufferSize];
|
|
|
|
|
|
|
|
|
@ -538,7 +546,7 @@ namespace IEC61850
|
|
|
|
|
return octetString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException ("Operation not supported for this type");
|
|
|
|
|
throw new MmsValueException("Operation not supported for this type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -546,17 +554,18 @@ namespace IEC61850
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="octetString">Byte array containing the bytes of the octet string.</param>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type or the byte array is too large.</exception>
|
|
|
|
|
public void setOctetString (byte[] octetString)
|
|
|
|
|
public void setOctetString(byte[] octetString)
|
|
|
|
|
{
|
|
|
|
|
if (GetType() == MmsType.MMS_OCTET_STRING)
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_OCTET_STRING) {
|
|
|
|
|
|
|
|
|
|
if (this.MaxSize() < octetString.Length)
|
|
|
|
|
if (MaxSize() < octetString.Length)
|
|
|
|
|
throw new MmsValueException("octet string is to large");
|
|
|
|
|
|
|
|
|
|
MmsValue_setOctetString(valueReference, octetString, octetString.Length);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException ("Operation not supported for this type");
|
|
|
|
|
throw new MmsValueException("Operation not supported for this type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -590,22 +599,26 @@ namespace IEC61850
|
|
|
|
|
/// </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)
|
|
|
|
|
public MmsValue GetElement(int index)
|
|
|
|
|
{
|
|
|
|
|
MmsType type = GetType ();
|
|
|
|
|
MmsType type = GetType();
|
|
|
|
|
|
|
|
|
|
if ((type == MmsType.MMS_ARRAY) || (type == MmsType.MMS_STRUCTURE)) {
|
|
|
|
|
if ((index >= 0) && (index < Size ())) {
|
|
|
|
|
IntPtr value = MmsValue_getElement (valueReference, index);
|
|
|
|
|
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");
|
|
|
|
|
return new MmsValue(value);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException("Index out of bounds");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException("Value is of wrong type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -674,12 +687,12 @@ namespace IEC61850
|
|
|
|
|
/// The UTC time in seconds (UNIX time stamp).
|
|
|
|
|
/// </returns>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public UInt32 ToUnixTimestamp ()
|
|
|
|
|
public UInt32 ToUnixTimestamp()
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_UTC_TIME)
|
|
|
|
|
return MmsValue_toUnixTimestamp (valueReference);
|
|
|
|
|
if (GetType() == MmsType.MMS_UTC_TIME)
|
|
|
|
|
return MmsValue_toUnixTimestamp(valueReference);
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException ("Value is not a time type");
|
|
|
|
|
throw new MmsValueException("Value is not a time type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -692,10 +705,12 @@ namespace IEC61850
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public void SetUtcTimeMs(ulong timeval)
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_UTC_TIME) {
|
|
|
|
|
if (GetType() == MmsType.MMS_UTC_TIME)
|
|
|
|
|
{
|
|
|
|
|
MmsValue_setUtcTimeMs(valueReference, timeval);
|
|
|
|
|
} else
|
|
|
|
|
throw new MmsValueException ("Value is not a time type");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException("Value is not a time type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -709,12 +724,14 @@ namespace IEC61850
|
|
|
|
|
/// The UTC time in ms.
|
|
|
|
|
/// </returns>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public ulong GetUtcTimeInMs ()
|
|
|
|
|
public ulong GetUtcTimeInMs()
|
|
|
|
|
{
|
|
|
|
|
if (GetType() == MmsType.MMS_UTC_TIME)
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_UTC_TIME) {
|
|
|
|
|
return MmsValue_getUtcTimeInMs (valueReference);
|
|
|
|
|
} else
|
|
|
|
|
throw new MmsValueException ("Value is not a time type");
|
|
|
|
|
return MmsValue_getUtcTimeInMs(valueReference);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException("Value is not a time type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -776,8 +793,8 @@ namespace IEC61850
|
|
|
|
|
/// <param name="timeQuality">Time quality.</param>
|
|
|
|
|
public void SetUtcTimeQuality(byte timeQuality)
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_UTC_TIME)
|
|
|
|
|
MmsValue_setUtcTimeQuality (valueReference, timeQuality);
|
|
|
|
|
if (GetType() == MmsType.MMS_UTC_TIME)
|
|
|
|
|
MmsValue_setUtcTimeQuality(valueReference, timeQuality);
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException("Value is not a time type");
|
|
|
|
|
}
|
|
|
|
@ -791,11 +808,11 @@ namespace IEC61850
|
|
|
|
|
/// <param name='msTime'>
|
|
|
|
|
/// the millisecond time
|
|
|
|
|
/// </param>
|
|
|
|
|
public static DateTimeOffset MsTimeToDateTimeOffset (UInt64 msTime)
|
|
|
|
|
public static DateTimeOffset MsTimeToDateTimeOffset(UInt64 msTime)
|
|
|
|
|
{
|
|
|
|
|
DateTimeOffset retVal = new DateTimeOffset (1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
|
|
|
|
|
DateTimeOffset retVal = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero);
|
|
|
|
|
|
|
|
|
|
return retVal.AddMilliseconds ((double) msTime);
|
|
|
|
|
return retVal.AddMilliseconds(msTime);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -809,12 +826,12 @@ namespace IEC61850
|
|
|
|
|
/// the value as DataTimeOffset instance
|
|
|
|
|
/// </returns>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public DateTimeOffset GetUtcTimeAsDateTimeOffset ()
|
|
|
|
|
public DateTimeOffset GetUtcTimeAsDateTimeOffset()
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_UTC_TIME)
|
|
|
|
|
return MsTimeToDateTimeOffset (GetUtcTimeInMs ());
|
|
|
|
|
if (GetType() == MmsType.MMS_UTC_TIME)
|
|
|
|
|
return MsTimeToDateTimeOffset(GetUtcTimeInMs());
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException ("Value is not a time type");
|
|
|
|
|
throw new MmsValueException("Value is not a time type");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -829,12 +846,12 @@ namespace IEC61850
|
|
|
|
|
/// the value if the object as 32 bit signed integer
|
|
|
|
|
/// </returns>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public Int32 ToInt32 ()
|
|
|
|
|
public Int32 ToInt32()
|
|
|
|
|
{
|
|
|
|
|
if (GetType () != MmsType.MMS_INTEGER)
|
|
|
|
|
throw new MmsValueException ("Value type is not integer");
|
|
|
|
|
if (GetType() != MmsType.MMS_INTEGER)
|
|
|
|
|
throw new MmsValueException("Value type is not integer");
|
|
|
|
|
|
|
|
|
|
return MmsValue_toInt32 (valueReference);
|
|
|
|
|
return MmsValue_toInt32(valueReference);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -863,12 +880,12 @@ namespace IEC61850
|
|
|
|
|
/// the value if the object as 64 bit signed integer
|
|
|
|
|
/// </returns>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public Int64 ToInt64 ()
|
|
|
|
|
public Int64 ToInt64()
|
|
|
|
|
{
|
|
|
|
|
if (GetType () != MmsType.MMS_INTEGER)
|
|
|
|
|
throw new MmsValueException ("Value type is not integer");
|
|
|
|
|
if (GetType() != MmsType.MMS_INTEGER)
|
|
|
|
|
throw new MmsValueException("Value type is not integer");
|
|
|
|
|
|
|
|
|
|
return MmsValue_toInt64 (valueReference);
|
|
|
|
|
return MmsValue_toInt64(valueReference);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -882,25 +899,25 @@ namespace IEC61850
|
|
|
|
|
/// the value if the object as 32 bit unsigned integer
|
|
|
|
|
/// </returns>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public UInt32 ToUint32 ()
|
|
|
|
|
public UInt32 ToUint32()
|
|
|
|
|
{
|
|
|
|
|
if (GetType () != MmsType.MMS_UNSIGNED)
|
|
|
|
|
throw new MmsValueException ("Value type is not unsigned");
|
|
|
|
|
if (GetType() != MmsType.MMS_UNSIGNED)
|
|
|
|
|
throw new MmsValueException("Value type is not unsigned");
|
|
|
|
|
|
|
|
|
|
return MmsValue_toUint32 (valueReference);
|
|
|
|
|
return MmsValue_toUint32(valueReference);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public UInt32 BitStringToUInt32 ()
|
|
|
|
|
public UInt32 BitStringToUInt32()
|
|
|
|
|
{
|
|
|
|
|
if (GetType () != MmsType.MMS_BIT_STRING)
|
|
|
|
|
if (GetType() != MmsType.MMS_BIT_STRING)
|
|
|
|
|
throw new MmsValueException("Value type is not bit string");
|
|
|
|
|
|
|
|
|
|
return MmsValue_getBitStringAsInteger(valueReference);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void BitStringFromUInt32 (UInt32 intValue)
|
|
|
|
|
public void BitStringFromUInt32(UInt32 intValue)
|
|
|
|
|
{
|
|
|
|
|
if (GetType () != MmsType.MMS_BIT_STRING)
|
|
|
|
|
if (GetType() != MmsType.MMS_BIT_STRING)
|
|
|
|
|
throw new MmsValueException("Value type is not bit string");
|
|
|
|
|
|
|
|
|
|
MmsValue_setBitStringFromInteger(valueReference, intValue);
|
|
|
|
@ -922,17 +939,17 @@ namespace IEC61850
|
|
|
|
|
MmsValue_setBitStringFromIntegerBigEndian(valueReference, intValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetBit (int bitPos, bool bitValue)
|
|
|
|
|
public void SetBit(int bitPos, bool bitValue)
|
|
|
|
|
{
|
|
|
|
|
if (GetType () != MmsType.MMS_BIT_STRING)
|
|
|
|
|
if (GetType() != MmsType.MMS_BIT_STRING)
|
|
|
|
|
throw new MmsValueException("Value type is not bit string");
|
|
|
|
|
|
|
|
|
|
MmsValue_setBitStringBit(valueReference, bitPos, bitValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool GetBit (int bitPos)
|
|
|
|
|
public bool GetBit(int bitPos)
|
|
|
|
|
{
|
|
|
|
|
if (GetType () != MmsType.MMS_BIT_STRING)
|
|
|
|
|
if (GetType() != MmsType.MMS_BIT_STRING)
|
|
|
|
|
throw new MmsValueException("Value type is not bit string");
|
|
|
|
|
|
|
|
|
|
return MmsValue_getBitStringBit(valueReference, bitPos);
|
|
|
|
@ -965,12 +982,12 @@ namespace IEC61850
|
|
|
|
|
/// The boolean value
|
|
|
|
|
/// </returns>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public bool GetBoolean ()
|
|
|
|
|
public bool GetBoolean()
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_BOOLEAN)
|
|
|
|
|
return MmsValue_getBoolean (valueReference);
|
|
|
|
|
if (GetType() == MmsType.MMS_BOOLEAN)
|
|
|
|
|
return MmsValue_getBoolean(valueReference);
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException ("Value type is not boolean");
|
|
|
|
|
throw new MmsValueException("Value type is not boolean");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -995,12 +1012,12 @@ namespace IEC61850
|
|
|
|
|
/// The float value
|
|
|
|
|
/// </returns>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public float ToFloat ()
|
|
|
|
|
public float ToFloat()
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_FLOAT)
|
|
|
|
|
return MmsValue_toFloat (valueReference);
|
|
|
|
|
if (GetType() == MmsType.MMS_FLOAT)
|
|
|
|
|
return MmsValue_toFloat(valueReference);
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException ("Value type is not float");
|
|
|
|
|
throw new MmsValueException("Value type is not float");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -1010,12 +1027,12 @@ namespace IEC61850
|
|
|
|
|
/// the new value to set
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public void SetFloat (float value)
|
|
|
|
|
public void SetFloat(float value)
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_FLOAT)
|
|
|
|
|
MmsValue_setFloat (valueReference, value);
|
|
|
|
|
if (GetType() == MmsType.MMS_FLOAT)
|
|
|
|
|
MmsValue_setFloat(valueReference, value);
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException ("Value type is not float");
|
|
|
|
|
throw new MmsValueException("Value type is not float");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -1025,12 +1042,12 @@ namespace IEC61850
|
|
|
|
|
/// The float value
|
|
|
|
|
/// </returns>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public double ToDouble ()
|
|
|
|
|
public double ToDouble()
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_FLOAT)
|
|
|
|
|
return MmsValue_toDouble (valueReference);
|
|
|
|
|
if (GetType() == MmsType.MMS_FLOAT)
|
|
|
|
|
return MmsValue_toDouble(valueReference);
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException ("Value type is not float");
|
|
|
|
|
throw new MmsValueException("Value type is not float");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -1040,12 +1057,12 @@ namespace IEC61850
|
|
|
|
|
/// the new value to set
|
|
|
|
|
/// </param>
|
|
|
|
|
/// <exception cref="MmsValueException">This exception is thrown if the value has the wrong type.</exception>
|
|
|
|
|
public void SetDouble (double value)
|
|
|
|
|
public void SetDouble(double value)
|
|
|
|
|
{
|
|
|
|
|
if (GetType () == MmsType.MMS_FLOAT)
|
|
|
|
|
MmsValue_setDouble (valueReference, value);
|
|
|
|
|
if (GetType() == MmsType.MMS_FLOAT)
|
|
|
|
|
MmsValue_setDouble(valueReference, value);
|
|
|
|
|
else
|
|
|
|
|
throw new MmsValueException ("Value type is not float");
|
|
|
|
|
throw new MmsValueException("Value type is not float");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -1083,34 +1100,35 @@ namespace IEC61850
|
|
|
|
|
return new MmsValue(clonePtr, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Equals (object obj)
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
{
|
|
|
|
|
MmsValue otherValue = (MmsValue) obj;
|
|
|
|
|
MmsValue otherValue = (MmsValue)obj;
|
|
|
|
|
|
|
|
|
|
return MmsValue_equals(this.valueReference, otherValue.valueReference);
|
|
|
|
|
return MmsValue_equals(valueReference, otherValue.valueReference);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// override standard ToString() method
|
|
|
|
|
public override string ToString ()
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
switch (GetType())
|
|
|
|
|
{
|
|
|
|
|
switch (GetType ()) {
|
|
|
|
|
case MmsType.MMS_VISIBLE_STRING:
|
|
|
|
|
case MmsType.MMS_STRING:
|
|
|
|
|
return Marshal.PtrToStringAnsi (MmsValue_toString (valueReference));
|
|
|
|
|
return Marshal.PtrToStringAnsi(MmsValue_toString(valueReference));
|
|
|
|
|
case MmsType.MMS_BOOLEAN:
|
|
|
|
|
return GetBoolean ().ToString ();
|
|
|
|
|
return GetBoolean().ToString();
|
|
|
|
|
case MmsType.MMS_INTEGER:
|
|
|
|
|
return ToInt64 ().ToString ();
|
|
|
|
|
return ToInt64().ToString();
|
|
|
|
|
case MmsType.MMS_UNSIGNED:
|
|
|
|
|
return ToUint32 ().ToString ();
|
|
|
|
|
return ToUint32().ToString();
|
|
|
|
|
case MmsType.MMS_FLOAT:
|
|
|
|
|
return ToDouble ().ToString ();
|
|
|
|
|
return ToDouble().ToString();
|
|
|
|
|
case MmsType.MMS_UTC_TIME:
|
|
|
|
|
return GetUtcTimeAsDateTimeOffset ().ToString ();
|
|
|
|
|
return GetUtcTimeAsDateTimeOffset().ToString();
|
|
|
|
|
case MmsType.MMS_BINARY_TIME:
|
|
|
|
|
return (MsTimeToDateTimeOffset (GetBinaryTimeAsUtcMs ()).ToString ());
|
|
|
|
|
return (MsTimeToDateTimeOffset(GetBinaryTimeAsUtcMs()).ToString());
|
|
|
|
|
case MmsType.MMS_OCTET_STRING:
|
|
|
|
|
return BitConverter.ToString (getOctetString ());
|
|
|
|
|
return BitConverter.ToString(getOctetString());
|
|
|
|
|
case MmsType.MMS_BIT_STRING:
|
|
|
|
|
return GetBitStringAsString();
|
|
|
|
|
case MmsType.MMS_STRUCTURE:
|
|
|
|
@ -1119,13 +1137,17 @@ namespace IEC61850
|
|
|
|
|
|
|
|
|
|
bool first = true;
|
|
|
|
|
|
|
|
|
|
foreach (MmsValue element in this) {
|
|
|
|
|
if (first) {
|
|
|
|
|
retString += element.ToString ();
|
|
|
|
|
foreach (MmsValue element in this)
|
|
|
|
|
{
|
|
|
|
|
if (first)
|
|
|
|
|
{
|
|
|
|
|
retString += element.ToString();
|
|
|
|
|
|
|
|
|
|
first = false;
|
|
|
|
|
} else {
|
|
|
|
|
retString += ", " + element.ToString ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
retString += ", " + element.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1139,13 +1161,17 @@ namespace IEC61850
|
|
|
|
|
|
|
|
|
|
bool first = true;
|
|
|
|
|
|
|
|
|
|
foreach (MmsValue element in this) {
|
|
|
|
|
if (first) {
|
|
|
|
|
retString += element.ToString ();
|
|
|
|
|
foreach (MmsValue element in this)
|
|
|
|
|
{
|
|
|
|
|
if (first)
|
|
|
|
|
{
|
|
|
|
|
retString += element.ToString();
|
|
|
|
|
|
|
|
|
|
first = false;
|
|
|
|
|
} else {
|
|
|
|
|
retString += ", " + element.ToString ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
retString += ", " + element.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1161,9 +1187,9 @@ namespace IEC61850
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator ()
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator()
|
|
|
|
|
{
|
|
|
|
|
return new MmsValueEnumerator (this);
|
|
|
|
|
return new MmsValueEnumerator(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class MmsValueEnumerator : IEnumerator
|
|
|
|
@ -1171,27 +1197,28 @@ namespace IEC61850
|
|
|
|
|
private MmsValue value;
|
|
|
|
|
private int index = -1;
|
|
|
|
|
|
|
|
|
|
public MmsValueEnumerator (MmsValue value)
|
|
|
|
|
public MmsValueEnumerator(MmsValue value)
|
|
|
|
|
{
|
|
|
|
|
this.value = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region IEnumerator Members
|
|
|
|
|
public void Reset ()
|
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
index = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public object Current {
|
|
|
|
|
public object Current
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
get { return value.GetElement (index);}
|
|
|
|
|
get { return value.GetElement(index); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool MoveNext ()
|
|
|
|
|
public bool MoveNext()
|
|
|
|
|
{
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (index >= value.Size ())
|
|
|
|
|
if (index >= value.Size())
|
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
return true;
|
|
|
|
@ -1204,7 +1231,7 @@ namespace IEC61850
|
|
|
|
|
|
|
|
|
|
public class MmsValueException : Exception
|
|
|
|
|
{
|
|
|
|
|
public MmsValueException (string message)
|
|
|
|
|
public MmsValueException(string message)
|
|
|
|
|
: base(message)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|