|
|
|
@ -20,21 +20,12 @@
|
|
|
|
|
*
|
|
|
|
|
* See COPYING file for the complete license text.
|
|
|
|
|
*/
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Data.Common;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
using IEC61850.Client;
|
|
|
|
|
using IEC61850.Common;
|
|
|
|
|
using IEC61850.Model;
|
|
|
|
|
using IEC61850.TLS;
|
|
|
|
|
using static System.Collections.Specialized.BitVector32;
|
|
|
|
|
using static System.Net.Mime.MediaTypeNames;
|
|
|
|
|
using static IEC61850.Client.IedConnection;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
// IEC 61850 API for the libiec61850 .NET wrapper library
|
|
|
|
|
namespace IEC61850
|
|
|
|
@ -2489,7 +2480,7 @@ namespace IEC61850
|
|
|
|
|
/// <param name="handler">the callback function that is invoked if a client tries to read a data object</param>
|
|
|
|
|
/// <param name="parameter">a user provided parameter that is passed to the callback function</param>
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void IedServer_setReadAccessHandler(IntPtr self, ReadAccessHandler handler, IntPtr parameter);
|
|
|
|
|
static extern void IedServer_setReadAccessHandler(IntPtr self, IedServer_ReadAccessHandler handler, IntPtr parameter);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Set a handler to control access to a dataset (create, delete, read, write, list directory)
|
|
|
|
@ -2511,7 +2502,7 @@ namespace IEC61850
|
|
|
|
|
/// <param name="handler">the user provided callback handler</param>
|
|
|
|
|
/// <param name="parameter">a user provided parameter that is passed to the control handler</param>
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void IedServer_setActiveSettingGroupChangedHandler(IntPtr self, IntPtr sgcb, ActiveSettingGroupChangedHandler handler, IntPtr parameter);
|
|
|
|
|
static extern void IedServer_setActiveSettingGroupChangedHandler(IntPtr self, IntPtr sgcb, IedServer_ActiveSettingGroupChangedHandler handler, IntPtr parameter);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get the active setting group number
|
|
|
|
@ -2530,7 +2521,7 @@ namespace IEC61850
|
|
|
|
|
/// <param name="handler">the user provided callback handler</param>
|
|
|
|
|
/// <param name="parameter">a user provided parameter that is passed to the control handler</param>
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void IedServer_setEditSettingGroupChangedHandler(IntPtr self, IntPtr sgcb, EditSettingGroupChangedHandler handler, IntPtr parameter);
|
|
|
|
|
static extern void IedServer_setEditSettingGroupChangedHandler(IntPtr self, IntPtr sgcb, IedServer_EditSettingGroupChangedHandler handler, IntPtr parameter);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Set the callback handler for the COnfEditSG event
|
|
|
|
@ -2540,7 +2531,7 @@ namespace IEC61850
|
|
|
|
|
/// <param name="handler">the user provided callback handler</param>
|
|
|
|
|
/// <param name="parameter">a user provided parameter that is passed to the control handler</param>
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void IedServer_setEditSettingGroupConfirmationHandler(IntPtr self, IntPtr sgcb, EditSettingGroupConfirmationHandler handler, IntPtr parameter);
|
|
|
|
|
static extern void IedServer_setEditSettingGroupConfirmationHandler(IntPtr self, IntPtr sgcb, IedServer_EditSettingGroupConfirmationHandler handler, IntPtr parameter);
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// Set a handler for SVCB control block events (enable/disable)
|
|
|
|
@ -2550,7 +2541,7 @@ namespace IEC61850
|
|
|
|
|
///// <param name="handler">the event handler to be used</param>
|
|
|
|
|
///// <param name="parameter">user provided parameter that is passed to the handler</param>
|
|
|
|
|
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
|
|
|
|
|
static extern void IedServer_setSVCBHandler(IntPtr self, IntPtr svcb, SVCBEventHandler handler, IntPtr parameter);
|
|
|
|
|
static extern void IedServer_setSVCBHandler(IntPtr self, IntPtr svcb, IedServer_SVCBEventHandler handler, IntPtr parameter);
|
|
|
|
|
|
|
|
|
|
///// <summary>
|
|
|
|
|
///// callback handler for SVCB events
|
|
|
|
@ -2559,7 +2550,7 @@ namespace IEC61850
|
|
|
|
|
///// <param name="eventType">event type</param>
|
|
|
|
|
///// <param name="parameter">user defined parameter</param>
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
|
|
|
private delegate void SVCBEventHandler(IntPtr svcb, int eventType, IntPtr parameter);
|
|
|
|
|
private delegate void IedServer_SVCBEventHandler(IntPtr svcb, int eventType, IntPtr parameter);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// callback handler to control client read access to data attributes
|
|
|
|
@ -2575,7 +2566,7 @@ namespace IEC61850
|
|
|
|
|
/// <param name="parameter">the user provided parameter</param>
|
|
|
|
|
/// <returns>DATA_ACCESS_ERROR_SUCCESS if access is accepted, DATA_ACCESS_ERROR_OBJECT_ACCESS_DENIED if access is denied</returns>
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
|
|
|
private delegate MmsDataAccessError ReadAccessHandler(IntPtr ld, IntPtr ln, IntPtr dataObject, int fc, IntPtr connection, IntPtr parameter);
|
|
|
|
|
private delegate MmsDataAccessError IedServer_ReadAccessHandler(IntPtr ld, IntPtr ln, IntPtr dataObject, int fc, IntPtr connection, IntPtr parameter);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Callback handler that is invoked when the active setting group is about to be changed by an external client.
|
|
|
|
@ -2587,7 +2578,7 @@ namespace IEC61850
|
|
|
|
|
/// <param name="connection">connection the client connection that requests the change</param>
|
|
|
|
|
/// <returns>true if the change is accepted, false otherwise</returns>
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
|
|
|
private delegate bool ActiveSettingGroupChangedHandler(IntPtr parameter, IntPtr sgcb, uint newActSg, IntPtr connection);
|
|
|
|
|
private delegate bool IedServer_ActiveSettingGroupChangedHandler(IntPtr parameter, IntPtr sgcb, uint newActSg, IntPtr connection);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Callback handler that is invoked when the edit setting group is about to be changed by an external client.
|
|
|
|
@ -2601,7 +2592,7 @@ namespace IEC61850
|
|
|
|
|
/// <param name="connection">the client connection that requests the change</param>
|
|
|
|
|
/// <returns>true if the change is accepted, false otherwise</returns>
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
|
|
|
private delegate bool EditSettingGroupChangedHandler(IntPtr parameter, IntPtr sgcb, uint newEditSg, IntPtr connection);
|
|
|
|
|
private delegate bool IedServer_EditSettingGroupChangedHandler(IntPtr parameter, IntPtr sgcb, uint newEditSg, IntPtr connection);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Callback handler that is invoked when the edit setting group has been confirmed by an external client.
|
|
|
|
@ -2610,7 +2601,7 @@ namespace IEC61850
|
|
|
|
|
/// <param name="sgcb">the setting group control block of the setting group that is about to be changed</param>
|
|
|
|
|
/// <param name="editSg">the edit setting group that has been confirmed</param>
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
|
|
|
private delegate void EditSettingGroupConfirmationHandler(IntPtr parameter, IntPtr sgcb, uint editSg);
|
|
|
|
|
private delegate void IedServer_EditSettingGroupConfirmationHandler(IntPtr parameter, IntPtr sgcb, uint editSg);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Callback that is called when the client is calling a dataset operation (create, delete, read, write, list directory)
|
|
|
|
@ -2958,26 +2949,24 @@ namespace IEC61850
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//------------- Setting group
|
|
|
|
|
|
|
|
|
|
public delegate bool InternalActiveSettingGroupChangedHandler(object parameter, SettingGroupControlBlock sgcb, uint newActSg, ClientConnection connection);
|
|
|
|
|
public delegate bool ActiveSettingGroupChangedHandler(object parameter, SettingGroupControlBlock sgcb, uint newActSg, ClientConnection connection);
|
|
|
|
|
|
|
|
|
|
private InternalActiveSettingGroupChangedHandler internalActiveSettingGroupChangedHandler = null;
|
|
|
|
|
private ActiveSettingGroupChangedHandler activeSettingGroupChangedHandler = null;
|
|
|
|
|
|
|
|
|
|
private object activeSettingGroupChangedHandlerParameter = null;
|
|
|
|
|
|
|
|
|
|
private ActiveSettingGroupChangedHandler activeSettingGroupChangedHandler = null;
|
|
|
|
|
private IedServer_ActiveSettingGroupChangedHandler internalActiveSettingGroupChangedHandler = null;
|
|
|
|
|
|
|
|
|
|
public void SetActiveSettingGroupChangedHandler(InternalActiveSettingGroupChangedHandler handler,SettingGroupControlBlock settingGroupControlBlock, object parameter)
|
|
|
|
|
public void SetActiveSettingGroupChangedHandler(ActiveSettingGroupChangedHandler handler,SettingGroupControlBlock settingGroupControlBlock, object parameter)
|
|
|
|
|
{
|
|
|
|
|
internalActiveSettingGroupChangedHandler = handler;
|
|
|
|
|
activeSettingGroupChangedHandler = handler;
|
|
|
|
|
activeSettingGroupChangedHandlerParameter = parameter;
|
|
|
|
|
|
|
|
|
|
if (activeSettingGroupChangedHandler == null)
|
|
|
|
|
if (internalActiveSettingGroupChangedHandler == null)
|
|
|
|
|
{
|
|
|
|
|
activeSettingGroupChangedHandler = new ActiveSettingGroupChangedHandler(InternalActiveSettingGroupChangedImplementation);
|
|
|
|
|
internalActiveSettingGroupChangedHandler = new IedServer_ActiveSettingGroupChangedHandler(InternalActiveSettingGroupChangedImplementation);
|
|
|
|
|
|
|
|
|
|
IedServer_setActiveSettingGroupChangedHandler(self, settingGroupControlBlock.self, activeSettingGroupChangedHandler, IntPtr.Zero);
|
|
|
|
|
IedServer_setActiveSettingGroupChangedHandler(self, settingGroupControlBlock.self, internalActiveSettingGroupChangedHandler, IntPtr.Zero);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -2994,30 +2983,30 @@ namespace IEC61850
|
|
|
|
|
|
|
|
|
|
this.clientConnections.TryGetValue(connection, out con);
|
|
|
|
|
|
|
|
|
|
return internalActiveSettingGroupChangedHandler(activeSettingGroupChangedHandlerParameter, new SettingGroupControlBlock(sgcb), newActSg, con);
|
|
|
|
|
return activeSettingGroupChangedHandler(activeSettingGroupChangedHandlerParameter, new SettingGroupControlBlock(sgcb), newActSg, con);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public delegate bool InternalEditSettingGroupChangedHandler(object parameter, SettingGroupControlBlock sgcb, uint newEditSg, ClientConnection connection);
|
|
|
|
|
public delegate bool EditSettingGroupChangedHandler(object parameter, SettingGroupControlBlock sgcb, uint newEditSg, ClientConnection connection);
|
|
|
|
|
|
|
|
|
|
private InternalEditSettingGroupChangedHandler internalEditSettingGroupChangedHandler = null;
|
|
|
|
|
private EditSettingGroupChangedHandler editSettingGroupChangedHandler = null;
|
|
|
|
|
|
|
|
|
|
private object editSettingGroupChangedHandlerParameter = null;
|
|
|
|
|
|
|
|
|
|
private EditSettingGroupChangedHandler editSettingGroupChangedHandler = null;
|
|
|
|
|
private IedServer_EditSettingGroupChangedHandler internalEditSettingGroupChangedHandler = null;
|
|
|
|
|
|
|
|
|
|
public void SetEditSettingGroupChangedHandler(InternalEditSettingGroupChangedHandler handler, SettingGroupControlBlock settingGroupControlBlock, object parameter)
|
|
|
|
|
public void SetEditSettingGroupChangedHandler(EditSettingGroupChangedHandler handler, SettingGroupControlBlock settingGroupControlBlock, object parameter)
|
|
|
|
|
{
|
|
|
|
|
internalEditSettingGroupChangedHandler = handler;
|
|
|
|
|
editSettingGroupChangedHandler = handler;
|
|
|
|
|
editSettingGroupChangedHandlerParameter = parameter;
|
|
|
|
|
|
|
|
|
|
if (editSettingGroupChangedHandler == null)
|
|
|
|
|
if (internalEditSettingGroupChangedHandler == null)
|
|
|
|
|
{
|
|
|
|
|
editSettingGroupChangedHandler = new EditSettingGroupChangedHandler(InternalEditSettingGroupChangedImplementation);
|
|
|
|
|
internalEditSettingGroupChangedHandler = new IedServer_EditSettingGroupChangedHandler(InternalEditSettingGroupChangedImplementation);
|
|
|
|
|
|
|
|
|
|
IedServer_setEditSettingGroupChangedHandler(self, settingGroupControlBlock.self, editSettingGroupChangedHandler, IntPtr.Zero);
|
|
|
|
|
IedServer_setEditSettingGroupChangedHandler(self, settingGroupControlBlock.self, internalEditSettingGroupChangedHandler, IntPtr.Zero);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3029,30 +3018,30 @@ namespace IEC61850
|
|
|
|
|
|
|
|
|
|
this.clientConnections.TryGetValue(connection, out con);
|
|
|
|
|
|
|
|
|
|
return internalEditSettingGroupChangedHandler(editSettingGroupChangedHandlerParameter, new SettingGroupControlBlock(sgcb), newEditSg, con);
|
|
|
|
|
return editSettingGroupChangedHandler(editSettingGroupChangedHandlerParameter, new SettingGroupControlBlock(sgcb), newEditSg, con);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public delegate void InternalEditSettingGroupConfirmationHandler(object parameter, SettingGroupControlBlock sgcb, uint editSg);
|
|
|
|
|
public delegate void EditSettingGroupConfirmationHandler(object parameter, SettingGroupControlBlock sgcb, uint editSg);
|
|
|
|
|
|
|
|
|
|
private InternalEditSettingGroupConfirmationHandler internalEditSettingGroupConfirmationHandler = null;
|
|
|
|
|
private EditSettingGroupConfirmationHandler editSettingGroupConfirmationHandler = null;
|
|
|
|
|
|
|
|
|
|
private object editSettingGroupConfirmationHandlerParameter = null;
|
|
|
|
|
|
|
|
|
|
private EditSettingGroupConfirmationHandler editSettingGroupConfirmationHandler = null;
|
|
|
|
|
private IedServer_EditSettingGroupConfirmationHandler internalEditSettingGroupConfirmationHandler = null;
|
|
|
|
|
|
|
|
|
|
public void SetEditSettingGroupConfirmationHandler(InternalEditSettingGroupConfirmationHandler handler, SettingGroupControlBlock settingGroupControlBlock, object parameter)
|
|
|
|
|
public void SetEditSettingGroupConfirmationHandler(EditSettingGroupConfirmationHandler handler, SettingGroupControlBlock settingGroupControlBlock, object parameter)
|
|
|
|
|
{
|
|
|
|
|
internalEditSettingGroupConfirmationHandler = handler;
|
|
|
|
|
editSettingGroupConfirmationHandler = handler;
|
|
|
|
|
editSettingGroupConfirmationHandlerParameter = parameter;
|
|
|
|
|
|
|
|
|
|
if (editSettingGroupConfirmationHandler == null)
|
|
|
|
|
if (internalEditSettingGroupConfirmationHandler == null)
|
|
|
|
|
{
|
|
|
|
|
editSettingGroupConfirmationHandler = new EditSettingGroupConfirmationHandler(InternalEditSettingGroupConfirmationImplementation);
|
|
|
|
|
internalEditSettingGroupConfirmationHandler = new IedServer_EditSettingGroupConfirmationHandler(InternalEditSettingGroupConfirmationImplementation);
|
|
|
|
|
|
|
|
|
|
IedServer_setEditSettingGroupConfirmationHandler(self, settingGroupControlBlock.self, editSettingGroupConfirmationHandler, IntPtr.Zero);
|
|
|
|
|
IedServer_setEditSettingGroupConfirmationHandler(self, settingGroupControlBlock.self, internalEditSettingGroupConfirmationHandler, IntPtr.Zero);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -3060,27 +3049,20 @@ namespace IEC61850
|
|
|
|
|
{
|
|
|
|
|
if (sgcb != IntPtr.Zero)
|
|
|
|
|
{
|
|
|
|
|
internalEditSettingGroupConfirmationHandler(editSettingGroupChangedHandlerParameter, new SettingGroupControlBlock(sgcb), editSg);
|
|
|
|
|
editSettingGroupConfirmationHandler(editSettingGroupChangedHandlerParameter, new SettingGroupControlBlock(sgcb), editSg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public delegate void SVCBEventHandler(SVControlBlock sampledValuesControlBlock, SMVEvent sMVEvent, object parameter);
|
|
|
|
|
|
|
|
|
|
//------------
|
|
|
|
|
|
|
|
|
|
public delegate void InternalSVCBEventHandler(SVControlBlock sampledValuesControlBlock, SMVEvent sMVEvent, object parameter);
|
|
|
|
|
|
|
|
|
|
private InternalSVCBEventHandler internalSVCBEventHandler = null;
|
|
|
|
|
|
|
|
|
|
private object sVCBEventHandlerParameter = null;
|
|
|
|
|
|
|
|
|
|
private SVCBEventHandler sVCBEventHandler = null;
|
|
|
|
|
private IedServer_SVCBEventHandler internalSVCBEventHandler = null;
|
|
|
|
|
|
|
|
|
|
internal class SVCHandlerInfo
|
|
|
|
|
{
|
|
|
|
|
public SVControlBlock sampledValuesControlBlock = null;
|
|
|
|
|
public GCHandle handle;
|
|
|
|
|
|
|
|
|
|
public InternalSVCBEventHandler internalSVCBEventHandler = null;
|
|
|
|
|
public SVCBEventHandler sVCBEventHandler = null;
|
|
|
|
|
public object svcHandlerParameter = null;
|
|
|
|
|
|
|
|
|
|
public SVCHandlerInfo(SVControlBlock sampledValuesControlBlock)
|
|
|
|
@ -3112,17 +3094,17 @@ namespace IEC61850
|
|
|
|
|
return info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetSVCBHandler(InternalSVCBEventHandler handler, SVControlBlock sampledValuesControlBlock, object parameter)
|
|
|
|
|
public void SetSVCBHandler(SVCBEventHandler handler, SVControlBlock sampledValuesControlBlock, object parameter)
|
|
|
|
|
{
|
|
|
|
|
SVCHandlerInfo info = GetSVCHandlerInfo(sampledValuesControlBlock);
|
|
|
|
|
|
|
|
|
|
info.internalSVCBEventHandler = handler;
|
|
|
|
|
info.sVCBEventHandler = handler;
|
|
|
|
|
info.svcHandlerParameter = parameter;
|
|
|
|
|
|
|
|
|
|
if (sVCBEventHandler == null)
|
|
|
|
|
sVCBEventHandler = new SVCBEventHandler(InternalSVCBEventHandlerImplementation);
|
|
|
|
|
if (internalSVCBEventHandler == null)
|
|
|
|
|
internalSVCBEventHandler = new IedServer_SVCBEventHandler(InternalSVCBEventHandlerImplementation);
|
|
|
|
|
|
|
|
|
|
IedServer_setSVCBHandler(self, sampledValuesControlBlock.Self, sVCBEventHandler, GCHandle.ToIntPtr(info.handle));
|
|
|
|
|
IedServer_setSVCBHandler(self, sampledValuesControlBlock.Self, internalSVCBEventHandler, GCHandle.ToIntPtr(info.handle));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -3132,34 +3114,34 @@ namespace IEC61850
|
|
|
|
|
|
|
|
|
|
SVCHandlerInfo info = (SVCHandlerInfo)handle.Target;
|
|
|
|
|
|
|
|
|
|
if (info != null && info.internalSVCBEventHandler != null)
|
|
|
|
|
info.internalSVCBEventHandler(info.sampledValuesControlBlock, (SMVEvent)eventType, info.svcHandlerParameter);
|
|
|
|
|
if (info != null && info.sVCBEventHandler != null)
|
|
|
|
|
info.sVCBEventHandler(info.sampledValuesControlBlock, (SMVEvent)eventType, info.svcHandlerParameter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public delegate MmsDataAccessError InternalReadAccessHandler(LogicalDevice ld, LogicalNode ln, DataObject dataObject, FunctionalConstraint fc, ClientConnection connection, object parameter);
|
|
|
|
|
public delegate MmsDataAccessError ReadAccessHandler(LogicalDevice ld, LogicalNode ln, DataObject dataObject, FunctionalConstraint fc, ClientConnection connection, object parameter);
|
|
|
|
|
|
|
|
|
|
private InternalReadAccessHandler internalReadAccessHandler = null;
|
|
|
|
|
private ReadAccessHandler readAccessHandler = null;
|
|
|
|
|
|
|
|
|
|
private object internalReadAccessHandlerParameter = null;
|
|
|
|
|
private object readAccessHandlerParameter = null;
|
|
|
|
|
|
|
|
|
|
private ReadAccessHandler readAccessHandler = null;
|
|
|
|
|
private IedServer_ReadAccessHandler internalReadAccessHandler = null;
|
|
|
|
|
|
|
|
|
|
public void SetReadAccessHandler(InternalReadAccessHandler handler, object parameter)
|
|
|
|
|
public void SetReadAccessHandler(ReadAccessHandler handler, object parameter)
|
|
|
|
|
{
|
|
|
|
|
internalReadAccessHandler = handler;
|
|
|
|
|
internalReadAccessHandlerParameter = parameter;
|
|
|
|
|
readAccessHandler = handler;
|
|
|
|
|
readAccessHandlerParameter = parameter;
|
|
|
|
|
|
|
|
|
|
if (readAccessHandler == null)
|
|
|
|
|
if (internalReadAccessHandler == null)
|
|
|
|
|
{
|
|
|
|
|
readAccessHandler = new ReadAccessHandler (InternalReadHandlerImplementation);
|
|
|
|
|
internalReadAccessHandler = new IedServer_ReadAccessHandler (InternalReadHandlerImplementation);
|
|
|
|
|
|
|
|
|
|
IedServer_setReadAccessHandler(self, readAccessHandler, IntPtr.Zero);
|
|
|
|
|
IedServer_setReadAccessHandler(self, internalReadAccessHandler, IntPtr.Zero);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MmsDataAccessError InternalReadHandlerImplementation(IntPtr ld, IntPtr ln, IntPtr dataObject, int fc, IntPtr connection, IntPtr parameter)
|
|
|
|
|
{
|
|
|
|
|
if (internalReadAccessHandler != null && ld != IntPtr.Zero && ln != IntPtr.Zero && connection != IntPtr.Zero)
|
|
|
|
|
if (readAccessHandler != null && ld != IntPtr.Zero && ln != IntPtr.Zero && connection != IntPtr.Zero)
|
|
|
|
|
{
|
|
|
|
|
ClientConnection con = null;
|
|
|
|
|
|
|
|
|
@ -3172,7 +3154,7 @@ namespace IEC61850
|
|
|
|
|
if(dataObject != IntPtr.Zero)
|
|
|
|
|
doModelNode = iedModel.GetModelNodeFromNodeRef(dataObject);
|
|
|
|
|
|
|
|
|
|
return internalReadAccessHandler(ldModelNode as LogicalDevice, lnModelNode as LogicalNode, doModelNode as DataObject, (FunctionalConstraint)fc, con, internalReadAccessHandlerParameter);
|
|
|
|
|
return readAccessHandler(ldModelNode as LogicalDevice, lnModelNode as LogicalNode, doModelNode as DataObject, (FunctionalConstraint)fc, con, readAccessHandlerParameter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return MmsDataAccessError.UNKNOWN;
|
|
|
|
@ -3186,30 +3168,30 @@ namespace IEC61850
|
|
|
|
|
DIRECTORY_CAT_LOG_LIST
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public delegate bool InternalDirectoryAccessHandler(object parameter, ClientConnection connection, IedServer_DirectoryCategory category,LogicalDevice ld);
|
|
|
|
|
public delegate bool DirectoryAccessHandler(object parameter, ClientConnection connection, IedServer_DirectoryCategory category,LogicalDevice ld);
|
|
|
|
|
|
|
|
|
|
private InternalDirectoryAccessHandler internalDirectoryAccessHandler = null;
|
|
|
|
|
private DirectoryAccessHandler directoryAccessHandler = null;
|
|
|
|
|
|
|
|
|
|
private object internalDirectoryAccessHandlerParameter = null;
|
|
|
|
|
private object directoryAccessHandlerParameter = null;
|
|
|
|
|
|
|
|
|
|
private IedServer_DirectoryAccessHandler directoryAccessHandler = null;
|
|
|
|
|
private IedServer_DirectoryAccessHandler internalDirectoryAccessHandler = null;
|
|
|
|
|
|
|
|
|
|
public void SetDirectoryAccessHandler(InternalDirectoryAccessHandler handler, object parameter)
|
|
|
|
|
public void SetDirectoryAccessHandler(DirectoryAccessHandler handler, object parameter)
|
|
|
|
|
{
|
|
|
|
|
internalDirectoryAccessHandler = handler;
|
|
|
|
|
internalDirectoryAccessHandlerParameter = parameter;
|
|
|
|
|
directoryAccessHandler = handler;
|
|
|
|
|
directoryAccessHandlerParameter = parameter;
|
|
|
|
|
|
|
|
|
|
if (directoryAccessHandler == null)
|
|
|
|
|
if (internalDirectoryAccessHandler == null)
|
|
|
|
|
{
|
|
|
|
|
directoryAccessHandler = new IedServer_DirectoryAccessHandler(DirectoryAccessHandler);
|
|
|
|
|
internalDirectoryAccessHandler = new IedServer_DirectoryAccessHandler(InternalDirectoryAccessHandler);
|
|
|
|
|
|
|
|
|
|
IedServer_setDirectoryAccessHandler(self, directoryAccessHandler, IntPtr.Zero);
|
|
|
|
|
IedServer_setDirectoryAccessHandler(self, internalDirectoryAccessHandler, IntPtr.Zero);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool DirectoryAccessHandler(IntPtr parameter, IntPtr connection, int category, IntPtr logicalDevice)
|
|
|
|
|
private bool InternalDirectoryAccessHandler(IntPtr parameter, IntPtr connection, int category, IntPtr logicalDevice)
|
|
|
|
|
{
|
|
|
|
|
if (internalDirectoryAccessHandler != null && connection != IntPtr.Zero)
|
|
|
|
|
if (directoryAccessHandler != null && connection != IntPtr.Zero)
|
|
|
|
|
{
|
|
|
|
|
ClientConnection con = null;
|
|
|
|
|
|
|
|
|
@ -3220,7 +3202,7 @@ namespace IEC61850
|
|
|
|
|
if(logicalDevice != IntPtr.Zero)
|
|
|
|
|
ldModelNode = iedModel.GetModelNodeFromNodeRef(logicalDevice);
|
|
|
|
|
|
|
|
|
|
return internalDirectoryAccessHandler(internalDirectoryAccessHandlerParameter, con, (IedServer_DirectoryCategory)category, ldModelNode as LogicalDevice);
|
|
|
|
|
return directoryAccessHandler(directoryAccessHandlerParameter, con, (IedServer_DirectoryCategory)category, ldModelNode as LogicalDevice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|