libiec61850.NET  1.5.1
IEC 61850 .NET API for libiec61850 protocol library
IEC61850.Common.MmsValue Class Reference

This class is used to hold MMS data values of different types. More...

Inheritance diagram for IEC61850.Common.MmsValue:
Collaboration diagram for IEC61850.Common.MmsValue:

Public Member Functions

 MmsValue (bool value)
 
 MmsValue (float value)
 
 MmsValue (double value)
 
 MmsValue (int value)
 
 MmsValue (UInt32 value)
 
 MmsValue (long value)
 
 MmsValue (string value)
 Create a new IEC61850.Common.MmsValue instance of type MMS_VISIBLE_STRING. More...
 
void Dispose ()
 
 MmsValue (byte[] octetString)
 
void SetBinaryTime (UInt64 timestamp)
 Sets the binary time. More...
 
ulong GetBinaryTimeAsUtcMs ()
 Gets the binary time value as UTC time in ms. More...
 
void SetVisibleString (string value)
 Set the value of an MmsValue instance of type MMS_VISIBLE_STRING More...
 
new MmsType GetType ()
 Gets the type of the value More...
 
int Size ()
 Gets the size of an array, structure, or bit string More...
 
int MaxSize ()
 Gets the maximum size of an octet string More...
 
byte [] getOctetString ()
 Gets the octet string as byte array More...
 
void setOctetString (byte[] octetString)
 Sets the value of an octet string by a byte array More...
 
byte GetOctetStringOctet (int pos)
 Gets the octet string octet. More...
 
void SetOctetStringOctet (int pos, byte value)
 Sets the octet string octet. More...
 
MmsValue GetElement (int index)
 Get an element of an array or structure More...
 
void SetElement (int index, MmsValue elementValue)
 Sets the element of an array or structure More...
 
MmsDataAccessError GetDataAccessError ()
 
UInt32 ToUnixTimestamp ()
 Gets the timestamp value as UTC time in s (UNIX time stamp). More...
 
void SetUtcTimeMs (ulong timeval)
 Sets the timestamp value as UTC time in ms. More...
 
ulong GetUtcTimeInMs ()
 Gets the timestamp value as UTC time in ms. More...
 
ulong GetUtcTimeInMsWithUs (out int usec)
 Gets the timestamp value as UTC time in ms and the additional us part. More...
 
byte GetUtcTimeQuality ()
 Gets quality flags of an UTC timestamp. More...
 
void SetUtcTimeQuality (byte timeQuality)
 Sets the quality flags of an UTC timestamp More...
 
DateTimeOffset GetUtcTimeAsDateTimeOffset ()
 Convert MMS_UTC_TIME to DateTimeOffset instance More...
 
Int32 ToInt32 ()
 Return the value as 32 bit signed integer. More...
 
void SetInt32 (int value)
 Sets the 32 bit signed integer. More...
 
Int64 ToInt64 ()
 Return the value as 64 bit signed integer. More...
 
UInt32 ToUint32 ()
 Return the value as 32 bit unsigned integer. More...
 
UInt32 BitStringToUInt32 ()
 
void BitStringFromUInt32 (UInt32 intValue)
 
UInt32 BitStringToUInt32BigEndian ()
 
void BitStringFromUInt32BigEndian (UInt32 intValue)
 
void SetBit (int bitPos, bool bitValue)
 
bool GetBit (int bitPos)
 
bool GetBoolean ()
 Gets the boolean value More...
 
void SetBoolean (bool value)
 Sets the boolean value of an MMS_BOOLEAN instance More...
 
float ToFloat ()
 Gets the float value of an MMS_FLOAT instance More...
 
void SetFloat (float value)
 Sets the float value of an MMS_FLOAT instance More...
 
double ToDouble ()
 Gets the double value of an MMS_FLOAT instance More...
 
void SetDouble (double value)
 Sets the float/double value of an MMS_FLOAT instance More...
 
MmsValue GetChildValue (string childPath, MmsVariableSpecification specification)
 Gets the child value with the given name More...
 
MmsValue Clone ()
 Get an identical copy of this instance More...
 
override bool Equals (object obj)
 
override string ToString ()
 

Static Public Member Functions

static MmsValue NewBitString (int bitSize)
 Create a new MmsValue instance of type MMS_BIT_STRING. More...
 
static MmsValue NewOctetString (int maxSize, int size=0)
 Create a new MmsValue instance of type MMS_OCTET_STRING. More...
 
static MmsValue NewArray (MmsVariableSpecification elementType, int size)
 Create a new MmsValue instance of type MMS_ARRAY. Array elements have the fiven type More...
 
static MmsValue NewEmptyArray (int size)
 Create a new MmsValue instance of type MMS_ARRAY. Array elements are not initialized! More...
 
static MmsValue NewEmptyStructure (int size)
 Create a new MmsValue instance of type MMS_STRUCTURE. Structure elements are not initialized! More...
 
static MmsValue NewBinaryTime (bool largeFormat)
 Create a new MmsValue instance of type MMS_BINARY_TIME More...
 
static MmsValue NewUtcTime (UInt64 timestamp)
 Create a new MmsValue instance of type MMS_UTC_TIME More...
 
static MmsValue NewVisibleString (int size, bool responsibleForDeletion=false)
 Create a new MmsValue instance of type MMS_VISIBLE_STRING - empty string with given maximum size More...
 
static DateTimeOffset MsTimeToDateTimeOffset (UInt64 msTime)
 Convert a millisecond time (milliseconds since epoch) to DataTimeOffset More...
 

Detailed Description

This class is used to hold MMS data values of different types.

Constructor & Destructor Documentation

◆ MmsValue()

IEC61850.Common.MmsValue.MmsValue ( string  value)

Create a new IEC61850.Common.MmsValue instance of type MMS_VISIBLE_STRING.

Parameters
valueValue.

Member Function Documentation

◆ Clone()

MmsValue IEC61850.Common.MmsValue.Clone ( )

Get an identical copy of this instance

◆ GetBinaryTimeAsUtcMs()

ulong IEC61850.Common.MmsValue.GetBinaryTimeAsUtcMs ( )

Gets the binary time value as UTC time in ms.

Return the value as milliseconds since epoch (1.1.1970 UTC). The value has to be of type MMS_UTC_TIME.

Returns
The UTC time in ms.
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ GetBoolean()

bool IEC61850.Common.MmsValue.GetBoolean ( )

Gets the boolean value

Returns
The boolean value
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ GetChildValue()

MmsValue IEC61850.Common.MmsValue.GetChildValue ( string  childPath,
MmsVariableSpecification  specification 
)

Gets the child value with the given name

Returns
the child value or null if no matching child has been found.
Parameters
childPathpath specifying the child using '.' or '$' as path element separator.
specificationthe variable specification to use.

◆ GetElement()

MmsValue IEC61850.Common.MmsValue.GetElement ( int  index)

Get an element of an array or structure

Returns
the MmsValue element.
Parameters
indexindex of the element starting with 0
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.
MmsValueExceptionThis exception is thrown if the index is out of range.

◆ getOctetString()

byte [] IEC61850.Common.MmsValue.getOctetString ( )

Gets the octet string as byte array

Instance has to be of type MMS_OCTET_STRING.

Returns
Byte array containing the bytes of the octet string.
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ GetOctetStringOctet()

byte IEC61850.Common.MmsValue.GetOctetStringOctet ( int  pos)

Gets the octet string octet.

Returns
The octet string octet.
Parameters
posPosition of the octet in the octet string.

◆ GetType()

new MmsType IEC61850.Common.MmsValue.GetType ( )

Gets the type of the value

Returns
The type.

◆ GetUtcTimeAsDateTimeOffset()

DateTimeOffset IEC61850.Common.MmsValue.GetUtcTimeAsDateTimeOffset ( )

Convert MMS_UTC_TIME to DateTimeOffset instance

Return the value as DateTimeOffset instance. The value has to be of type MMS_UTC_TIME.

Returns
the value as DataTimeOffset instance
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ GetUtcTimeInMs()

ulong IEC61850.Common.MmsValue.GetUtcTimeInMs ( )

Gets the timestamp value as UTC time in ms.

Return the value as milliseconds since epoch (1.1.1970 UTC). The value has to be of type MMS_UTC_TIME.

Returns
The UTC time in ms.
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ GetUtcTimeInMsWithUs()

ulong IEC61850.Common.MmsValue.GetUtcTimeInMsWithUs ( out int  usec)

Gets the timestamp value as UTC time in ms and the additional us part.

Return the value as milliseconds since epoch (1.1.1970 UTC) and the additional us part. The value has to be of type MMS_UTC_TIME.

Parameters
usecreturns the usec part of the time value
Returns
The UTC time in ms.
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ GetUtcTimeQuality()

byte IEC61850.Common.MmsValue.GetUtcTimeQuality ( )

Gets quality flags of an UTC timestamp.

Meaning of the bits in the timeQuality byte: bit 7 = leapSecondsKnown bit 6 = clockFailure bit 5 = clockNotSynchronized bit 0-4 = subsecond time accuracy (number of significant bits of subsecond time)

Returns
The UTC time quality.

◆ MaxSize()

int IEC61850.Common.MmsValue.MaxSize ( )

Gets the maximum size of an octet string

Returns
The maximum size (in bytes) of the octet string

◆ MsTimeToDateTimeOffset()

static DateTimeOffset IEC61850.Common.MmsValue.MsTimeToDateTimeOffset ( UInt64  msTime)
static

Convert a millisecond time (milliseconds since epoch) to DataTimeOffset

Returns
The time as DataTimeOffset
Parameters
msTimethe millisecond time

◆ NewArray()

static MmsValue IEC61850.Common.MmsValue.NewArray ( MmsVariableSpecification  elementType,
int  size 
)
static

Create a new MmsValue instance of type MMS_ARRAY. Array elements have the fiven type

Returns
the newly created array
Parameters
elementTypearray element type
sizenumber of array elements

◆ NewBinaryTime()

static MmsValue IEC61850.Common.MmsValue.NewBinaryTime ( bool  largeFormat)
static

Create a new MmsValue instance of type MMS_BINARY_TIME

Returns
the new MmsValue instance.
Parameters
largeFormatIf set to true large 6 byte format.

◆ NewBitString()

static MmsValue IEC61850.Common.MmsValue.NewBitString ( int  bitSize)
static

Create a new MmsValue instance of type MMS_BIT_STRING.

Returns
the new MmsValue instance
Parameters
bitSizethe size of the bit string in bits.

◆ NewEmptyArray()

static MmsValue IEC61850.Common.MmsValue.NewEmptyArray ( int  size)
static

Create a new MmsValue instance of type MMS_ARRAY. Array elements are not initialized!

Returns
the newly created array
Parameters
sizenumber of array elements

◆ NewEmptyStructure()

static MmsValue IEC61850.Common.MmsValue.NewEmptyStructure ( int  size)
static

Create a new MmsValue instance of type MMS_STRUCTURE. Structure elements are not initialized!

Returns
the newly created array
Parameters
sizenumber of structure elements

◆ NewOctetString()

static MmsValue IEC61850.Common.MmsValue.NewOctetString ( int  maxSize,
int  size = 0 
)
static

Create a new MmsValue instance of type MMS_OCTET_STRING.

Returns
the new MmsValue instance
Parameters
maxSizethe maximum size of the octet string in bytes
sizethe current size of the octet string in bytes (defaults to 0)

◆ NewUtcTime()

static MmsValue IEC61850.Common.MmsValue.NewUtcTime ( UInt64  timestamp)
static

Create a new MmsValue instance of type MMS_UTC_TIME

Returns
the new MmsValue instance.
Parameters
timestampthe time value as milliseconds since epoch (1.1.1970 UTC).

◆ NewVisibleString()

static MmsValue IEC61850.Common.MmsValue.NewVisibleString ( int  size,
bool  responsibleForDeletion = false 
)
static

Create a new MmsValue instance of type MMS_VISIBLE_STRING - empty string with given maximum size

Parameters
sizeThe maximum size
Returns

◆ SetBinaryTime()

void IEC61850.Common.MmsValue.SetBinaryTime ( UInt64  timestamp)

Sets the binary time.

Parameters
timestampTimestamp.

◆ SetBoolean()

void IEC61850.Common.MmsValue.SetBoolean ( bool  value)

Sets the boolean value of an MMS_BOOLEAN instance

Parameters
valuethe new value to set
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ SetDouble()

void IEC61850.Common.MmsValue.SetDouble ( double  value)

Sets the float/double value of an MMS_FLOAT instance

Parameters
valuethe new value to set
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ SetElement()

void IEC61850.Common.MmsValue.SetElement ( int  index,
MmsValue  elementValue 
)

Sets the element of an array or structure

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.

Parameters
indexindex of the element starting with 0
elementValueMmsValue instance that will be used as element value
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.
MmsValueExceptionThis exception is thrown if the index is out of range.

◆ SetFloat()

void IEC61850.Common.MmsValue.SetFloat ( float  value)

Sets the float value of an MMS_FLOAT instance

Parameters
valuethe new value to set
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ SetInt32()

void IEC61850.Common.MmsValue.SetInt32 ( int  value)

Sets the 32 bit signed integer.

Parameters
valuethe new value to set
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ setOctetString()

void IEC61850.Common.MmsValue.setOctetString ( byte []  octetString)

Sets the value of an octet string by a byte array

Parameters
octetStringByte array containing the bytes of the octet string.
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type or the byte array is too large.

◆ SetOctetStringOctet()

void IEC61850.Common.MmsValue.SetOctetStringOctet ( int  pos,
byte  value 
)

Sets the octet string octet.

Parameters
posPosition of the octet in the octet string.
valueThe octet string octet.

◆ SetUtcTimeMs()

void IEC61850.Common.MmsValue.SetUtcTimeMs ( ulong  timeval)

Sets the timestamp value as UTC time in ms.

Sets the value as milliseconds since epoch (1.1.1970 UTC). The value has to be of type MMS_UTC_TIME.

Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ SetUtcTimeQuality()

void IEC61850.Common.MmsValue.SetUtcTimeQuality ( byte  timeQuality)

Sets the quality flags of an UTC timestamp

Meaning of the bits in the timeQuality byte: bit 7 = leapSecondsKnown bit 6 = clockFailure bit 5 = clockNotSynchronized bit 0-4 = subsecond time accuracy (number of significant bits of subsecond time)

Parameters
timeQualityTime quality.

◆ SetVisibleString()

void IEC61850.Common.MmsValue.SetVisibleString ( string  value)

Set the value of an MmsValue instance of type MMS_VISIBLE_STRING

Parameters
valuethe new string value

◆ Size()

int IEC61850.Common.MmsValue.Size ( )

Gets the size of an array, structure, or bit string

Returns
Return the size of an array of structure (number of elements) The value has to be of type MMS_ARRAY, MMS_STRUCTURE, MMS_BIT_STRING ... the number of elements (array/structure elements, octets, bits depending on type)
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ ToDouble()

double IEC61850.Common.MmsValue.ToDouble ( )

Gets the double value of an MMS_FLOAT instance

Returns
The float value
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ ToFloat()

float IEC61850.Common.MmsValue.ToFloat ( )

Gets the float value of an MMS_FLOAT instance

Returns
The float value
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ ToInt32()

Int32 IEC61850.Common.MmsValue.ToInt32 ( )

Return the value as 32 bit signed integer.

Return the value as 32 bit signed integer (Int32). The value has to be of type MMS_INTEGER.

Returns
the value if the object as 32 bit signed integer
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ ToInt64()

Int64 IEC61850.Common.MmsValue.ToInt64 ( )

Return the value as 64 bit signed integer.

Return the value as 64 bit signed integer (Int64). The value has to be of type MMS_INTEGER.

Returns
the value if the object as 64 bit signed integer
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ ToUint32()

UInt32 IEC61850.Common.MmsValue.ToUint32 ( )

Return the value as 32 bit unsigned integer.

Return the value as 32 bit unsigned integer (Int32). The value has to be of type MMS_INTEGER.

Returns
the value if the object as 32 bit unsigned integer
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

◆ ToUnixTimestamp()

UInt32 IEC61850.Common.MmsValue.ToUnixTimestamp ( )

Gets the timestamp value as UTC time in s (UNIX time stamp).

Return the value as seconds since epoch (1.1.1970 UTC). The value has to be of type MMS_UTC_TIME.

Returns
The UTC time in seconds (UNIX time stamp).
Exceptions
MmsValueExceptionThis exception is thrown if the value has the wrong type.

The documentation for this class was generated from the following file: