From ff53028ec464d7d31049a70f3bada44ea283f40f Mon Sep 17 00:00:00 2001 From: andy1547 Date: Tue, 24 Mar 2020 09:59:38 +0000 Subject: [PATCH] Added various dotnet methods required for server configuration (#216) - Added the ability to set/read URCB buffer size in dotnet. - Added IedServer_getNumberOfOpenConnections, ClientConnection_getLocalAddress and server identity methods for dotnet. Co-authored-by: Andrew Moorcroft --- dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs | 25 +++++++++++++++++++ dotnet/IEC61850forCSharp/IedServerConfig.cs | 22 ++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs index 7faf2af1..90748455 100644 --- a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs +++ b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs @@ -837,6 +837,9 @@ namespace IEC61850 [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern IntPtr ClientConnection_getPeerAddress(IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr ClientConnection_getLocalAddress(IntPtr self); + internal IntPtr self; internal ClientConnection (IntPtr self) { @@ -852,6 +855,16 @@ namespace IEC61850 else return null; } + + public string GetLocalAddress() + { + IntPtr localAddrPtr = ClientConnection_getLocalAddress(self); + + if (localAddrPtr != IntPtr.Zero) + return Marshal.PtrToStringAnsi(localAddrPtr); + else + return null; + } } /// @@ -1065,6 +1078,9 @@ namespace IEC61850 [return: MarshalAs(UnmanagedType.Bool)] static extern bool IedServer_isRunning(IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern int IedServer_getNumberOfOpenConnections(IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern void IedServer_lockDataModel(IntPtr self); @@ -1395,6 +1411,15 @@ namespace IEC61850 return IedServer_isRunning(self); } + /// + /// Get number of open MMS connections + /// + /// the number of open and accepted MMS connections + public int GetNumberOfOpenConnections() + { + return IedServer_getNumberOfOpenConnections(self); + } + private ControlHandlerInfo GetControlHandlerInfo(DataObject controlObject) { ControlHandlerInfo info; diff --git a/dotnet/IEC61850forCSharp/IedServerConfig.cs b/dotnet/IEC61850forCSharp/IedServerConfig.cs index aa8dc6c9..d2b4f71b 100644 --- a/dotnet/IEC61850forCSharp/IedServerConfig.cs +++ b/dotnet/IEC61850forCSharp/IedServerConfig.cs @@ -44,6 +44,12 @@ namespace IEC61850.Server [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern int IedServerConfig_getReportBufferSize(IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void IedServerConfig_setReportBufferSizeForURCBs(IntPtr self, int reportBufferSize); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern int IedServerConfig_getReportBufferSizeForURCBs(IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern void IedServerConfig_setFileServiceBasePath(IntPtr self, string basepath); @@ -122,6 +128,22 @@ namespace IEC61850.Server } } + /// + /// Gets or sets the size of the report buffer for unbuffered report control blocks + /// + /// The size of the report buffer. + public int ReportBufferSizeForURCBs + { + get + { + return IedServerConfig_getReportBufferSizeForURCBs(self); + } + set + { + IedServerConfig_setReportBufferSizeForURCBs(self, value); + } + } + /// /// Gets or sets the file service base path. ///