diff --git a/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs b/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs index 6b3b0b2b..574d6c82 100644 --- a/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs +++ b/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs @@ -123,7 +123,9 @@ namespace IEC61850 /** periodic transmission of all data set values */ INTEGRITY = 8, /** general interrogation (on client request) */ - GI = 16 + GI = 16, + /** Report will be triggered only on rising edge (transient variable) */ + TRG_OPT_TRANSIENT = 128 } /// diff --git a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs index 122fedbd..e820d2db 100644 --- a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs +++ b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs @@ -871,11 +871,13 @@ namespace IEC61850 public class DataAttribute : ModelNode { - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr DataAttribute_create(string name, IntPtr parent, int type, int fc, byte triggerOptions, int arrayElements, UInt32 sAddr); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void DataAttribute_setValue(IntPtr self, IntPtr mmsValue); + internal DataAttribute(IntPtr self, ModelNode parent) : base(self) { this.parent = parent; @@ -889,6 +891,14 @@ namespace IEC61850 self = DataAttribute_create (name, parent.self, (int)type, (int)fc, (byte)trgOps, arrayElements, sAddr); } + /// + /// Set the value of the data attribute (can be used to set default values before server is created) + /// + /// New value for the data attribute + public void SetValue(MmsValue value) + { + DataAttribute_setValue(self, value.valueReference); + } } public class ModelNode diff --git a/src/iec61850/inc/iec61850_dynamic_model.h b/src/iec61850/inc/iec61850_dynamic_model.h index c7da23c0..872ee425 100644 --- a/src/iec61850/inc/iec61850_dynamic_model.h +++ b/src/iec61850/inc/iec61850_dynamic_model.h @@ -137,6 +137,15 @@ LIB61850_API DataAttribute* DataAttribute_create(const char* name, ModelNode* parent, DataAttributeType type, FunctionalConstraint fc, uint8_t triggerOptions, int arrayElements, uint32_t sAddr); +/** + * \brief Set the value of the data attribute (can be used to set default values before server is created) + * + * \param self the data attribute instance + * \param value the new default value + */ +LIB61850_API void +DataAttribute_setValue(DataAttribute* self, MmsValue* value); + /** * \brief create a new report control block (RCB) * diff --git a/src/iec61850/server/model/dynamic_model.c b/src/iec61850/server/model/dynamic_model.c index 4377de8b..ea68d36d 100644 --- a/src/iec61850/server/model/dynamic_model.c +++ b/src/iec61850/server/model/dynamic_model.c @@ -607,6 +607,17 @@ DataAttribute_create(const char* name, ModelNode* parent, DataAttributeType type return self; } +void +DataAttribute_setValue(DataAttribute* self, MmsValue* value) +{ + if (self->mmsValue) { + MmsValue_update(self->mmsValue, value); + } + else { + self->mmsValue = MmsValue_clone(value); + } +} + DataSet* DataSet_create(const char* name, LogicalNode* parent) {