diff --git a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs
index b0d2c054..97adae02 100644
--- a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs
+++ b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs
@@ -2247,6 +2247,10 @@ namespace IEC61850
static extern void IedServer_handleWriteAccessForComplexAttribute(IntPtr self, IntPtr dataAttribute,
InternalWriteAccessHandler handler, IntPtr parameter);
+ [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
+ static extern void IedServer_handleWriteAccessForDataObject(IntPtr self, IntPtr dataObject, int fc,
+ InternalWriteAccessHandler handler, IntPtr parameter);
+
public delegate void ConnectionIndicationHandler(IedServer iedServer, ClientConnection clientConnection, bool connected, object parameter);
private ConnectionIndicationHandler connectionHandler = null;
@@ -2713,12 +2717,27 @@ namespace IEC61850
}
}
+ private void AddHandlerInfoForDataObjectRecursive(DataObject dataObject, FunctionalConstraint fc, WriteAccessHandler handler, object parameter, InternalWriteAccessHandler internalHandler)
+ {
+ foreach (ModelNode child in dataObject.GetChildren())
+ {
+ if (child is DataAttribute && (child as DataAttribute).FC == fc)
+ {
+ AddHandlerInfoForDataAttributeRecursive(child as DataAttribute, handler, parameter, internalHandler);
+ }
+ else if (child is DataObject)
+ {
+ AddHandlerInfoForDataObjectRecursive(child as DataObject, fc, handler, parameter, internalHandler);
+ }
+ }
+ }
+
///
/// Install a WriteAccessHandler for a data attribute and for all sub data attributes
///
/// This instructs the server to monitor write attempts by MMS clients to specific
- /// data attributes.If a client tries to write to the monitored data attribute the
- /// handler is invoked.The handler can decide if the write access will be allowed
+ /// data attributes. If a client tries to write to the monitored data attribute the
+ /// handler is invoked. The handler can decide if the write access will be allowed
/// or denied.If a WriteAccessHandler is set for a specific data attribute - the
/// default write access policy will not be performed for that data attribute.
///
@@ -2738,6 +2757,27 @@ namespace IEC61850
IedServer_handleWriteAccessForComplexAttribute(self, dataAttr.self, internalHandler, IntPtr.Zero);
}
+ ///
+ /// Install a WriteAccessHandler for a data object and for all sub data objects and sub data attributes that have the same functional constraint
+ ///
+ /// This instructs the server to monitor write attempts by MMS clients to specific
+ /// data attributes. If a client tries to write to the monitored data attribute the
+ /// handler is invoked. The handler can decide if the write access will be allowed
+ /// or denied. If a WriteAccessHandler is set the
+ /// default write access policy will not be performed for the matching data attributes.
+ /// the data object to monitor
+ /// the functional constraint (FC) to monitor
+ /// the callback function that is invoked if a client tries to write to a monitored data attribute that is a child of the data object.
+ /// a user provided parameter that is passed to the WriteAccessHandler when called.
+ public void HandleWriteAccessForDataObject(DataObject dataObj, FunctionalConstraint fc, WriteAccessHandler handler, object parameter)
+ {
+ InternalWriteAccessHandler internalHandler = new InternalWriteAccessHandler(WriteAccessHandlerImpl);
+
+ AddHandlerInfoForDataObjectRecursive(dataObj, fc, handler, parameter, internalHandler);
+
+ IedServer_handleWriteAccessForDataObject(self, dataObj.self, (int)fc, internalHandler, IntPtr.Zero);
+ }
+
///
/// Set the defualt write access policy for a specific FC. The default policy is applied when no handler is installed for a data attribute
///