diff --git a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs index e820d2db..905e600c 100644 --- a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs +++ b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs @@ -878,6 +878,8 @@ namespace IEC61850 [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern void DataAttribute_setValue(IntPtr self, IntPtr mmsValue); + private DataAttributeType daType; + internal DataAttribute(IntPtr self, ModelNode parent) : base(self) { this.parent = parent; @@ -887,10 +889,22 @@ namespace IEC61850 int arrayElements, UInt32 sAddr) { this.parent = parent; + this.daType = type; self = DataAttribute_create (name, parent.self, (int)type, (int)fc, (byte)trgOps, arrayElements, sAddr); } + /// + /// Get IEC 61850 data attribute type of the data attribute + /// + public DataAttributeType Type + { + get + { + return daType; + } + } + /// /// Set the value of the data attribute (can be used to set default values before server is created) /// diff --git a/dotnet/IEC61850forCSharp/MmsValue.cs b/dotnet/IEC61850forCSharp/MmsValue.cs index 5d6a90c7..3b5e06ee 100644 --- a/dotnet/IEC61850forCSharp/MmsValue.cs +++ b/dotnet/IEC61850forCSharp/MmsValue.cs @@ -147,6 +147,12 @@ namespace IEC61850 [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr MmsValue_newVisibleString(string value); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr MmsValue_newVisibleStringWithSize(int size); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void MmsValue_setVisibleString(IntPtr self, string value); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr MmsValue_createArray(IntPtr elementType, int size); @@ -201,7 +207,7 @@ namespace IEC61850 internal IntPtr valueReference; /* reference to native MmsValue instance */ - private bool responsableForDeletion; /* if .NET wrapper is responsable for the deletion of the native MmsValue instance */ + private bool responsableForDeletion = false; /* if .NET wrapper is responsable for the deletion of the native MmsValue instance */ internal MmsValue (IntPtr value) { @@ -415,13 +421,34 @@ namespace IEC61850 return new MmsValue (newValue, true); } - /// - /// Gets the type of the value + /// + /// Create a new MmsValue instance of type MMS_VISIBLE_STRING - empty string with given maximum size /// - /// - /// The type. - /// - public new MmsType GetType () + /// The maximum size + /// + public static MmsValue NewVisibleString(int size, bool responsibleForDeletion = false) + { + IntPtr newValue = MmsValue_newVisibleStringWithSize(size); + + return new MmsValue(newValue, responsibleForDeletion); + } + + /// + /// Set the value of an MmsValue instance of type MMS_VISIBLE_STRING + /// + /// the new string value + public void SetVisibleString(string value) + { + MmsValue_setVisibleString(valueReference, value); + } + + /// + /// Gets the type of the value + /// + /// + /// The type. + /// + public new MmsType GetType () { return (MmsType)MmsValue_getType (valueReference); }