From bdbb686852b2fb2f77ec415d51ecac60ec88df7f Mon Sep 17 00:00:00 2001 From: Andrew Moorcroft Date: Fri, 6 Mar 2020 15:05:31 +0000 Subject: [PATCH] Added IedServer_getNumberOfOpenConnections, ClientConnection_getLocalAddress and server identity methods for dotnet. --- dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs | 90 +++++++++++++++++++ src/mms/inc/mms_server.h | 8 +- 2 files changed, 94 insertions(+), 4 deletions(-) diff --git a/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ServerAPI.cs index 8e58b129..d7dcea55 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; + } } /// @@ -1052,6 +1065,18 @@ namespace IEC61850 [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern void IedServer_setLocalIpAddress(IntPtr self, string localIpAddress); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void MmsServer_setServerIdentity(IntPtr self, string vendorName, string modelName, string revision); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr MmsServer_getVendorName(IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr MmsServer_getModelName(IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr MmsServer_getRevision(IntPtr self); + [DllImport ("iec61850", CallingConvention=CallingConvention.Cdecl)] static extern void IedServer_start(IntPtr self, int tcpPort); @@ -1065,6 +1090,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); @@ -1322,6 +1350,59 @@ namespace IEC61850 IedServer_setLocalIpAddress (self, localIpAddress); } + /// + /// Sets the values that the server will give as response for an MMS identify request + /// + /// Vendor Name for VMD + /// Model name for VMD + /// Revision for VMD + public void SetServerIdentity(string vendorName, string modelName, string revision) + { + MmsServer_setServerIdentity(self, vendorName, modelName, revision); + } + + /// + /// Gets the Vendor Name attributed to the VMD + /// + /// Vendor Name + public string GetVendorName() + { + IntPtr vendorNamePtr = MmsServer_getVendorName(self); + + if (vendorNamePtr != IntPtr.Zero) + return Marshal.PtrToStringAnsi(vendorNamePtr); + else + return null; + } + + /// + /// Gets the Model Name attributed to the VMD + /// + /// Model Name + public string GetModelName() + { + IntPtr modelNamePtr = MmsServer_getModelName(self); + + if (modelNamePtr != IntPtr.Zero) + return Marshal.PtrToStringAnsi(modelNamePtr); + else + return null; + } + + /// + /// Gets the Revision attributed to the VMD + /// + /// Revision + public string GetRevision() + { + IntPtr revisionPtr = MmsServer_getRevision(self); + + if (revisionPtr != IntPtr.Zero) + return Marshal.PtrToStringAnsi(revisionPtr); + else + return null; + } + /// /// Start MMS server /// @@ -1377,6 +1458,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/src/mms/inc/mms_server.h b/src/mms/inc/mms_server.h index 7e6118d0..19461d2c 100644 --- a/src/mms/inc/mms_server.h +++ b/src/mms/inc/mms_server.h @@ -264,7 +264,7 @@ MmsServer_enableJournalService(MmsServer self, bool enable); * \param modelName the model name attribute of the VMD * \param revision the revision attribute of the VMD */ -LIB61850_INTERNAL void +LIB61850_API void MmsServer_setServerIdentity(MmsServer self, char* vendorName, char* modelName, char* revision); /** @@ -273,7 +273,7 @@ MmsServer_setServerIdentity(MmsServer self, char* vendorName, char* modelName, c * \param self the MmsServer instance to operate on * \return the vendor name attribute of the VMD as C string */ -LIB61850_INTERNAL char* +LIB61850_API char* MmsServer_getVendorName(MmsServer self); /** @@ -282,7 +282,7 @@ MmsServer_getVendorName(MmsServer self); * \param self the MmsServer instance to operate on * \return the model name attribute of the VMD as C string */ -LIB61850_INTERNAL char* +LIB61850_API char* MmsServer_getModelName(MmsServer self); /** @@ -291,7 +291,7 @@ MmsServer_getModelName(MmsServer self); * \param self the MmsServer instance to operate on * \return the revision attribute of the VMD as C string */ -LIB61850_INTERNAL char* +LIB61850_API char* MmsServer_getRevision(MmsServer self); /***************************************************