From 320f511d339eaee5124291e0b4b85ddffdbe1e8a Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Fri, 20 Sep 2019 07:40:13 +0200 Subject: [PATCH] - IEC 61850 client: Added functions IedConnection_setRequestTimeout and IedConnection_getRequestTimeout to C API and IedConnection.RequestTimeout property to .NET API --- dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs | 22 +++++++++++++++++++ src/iec61850/client/ied_connection.c | 18 +++++++++++++++ src/iec61850/inc/iec61850_client.h | 22 +++++++++++++++++++ src/mms/inc/mms_client_connection.h | 10 +++++++++ .../iso_mms/client/mms_client_connection.c | 6 +++++ 5 files changed, 78 insertions(+) diff --git a/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs index fb87d7c5..aff8fc67 100644 --- a/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs +++ b/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs @@ -425,6 +425,12 @@ namespace IEC61850 [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern void IedConnection_setConnectTimeout(IntPtr self, UInt32 timeoutInMs); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void IedConnection_setRequestTimeout(IntPtr self, UInt32 timeoutInMs); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern UInt32 IedConnection_getRequestTimeout(IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] static extern void IedConnection_connect(IntPtr self, out int error, string hostname, int tcpPort); @@ -769,6 +775,22 @@ namespace IEC61850 } } + /// + /// Gets or sets the request timeout for this connection + /// + /// The request timeout in milliseconds + public UInt32 RequestTimeout + { + get + { + return IedConnection_getRequestTimeout(connection); + } + set + { + IedConnection_setRequestTimeout(connection, value); + } + } + /// /// Gets or sets the maximum size if a PDU (has to be set before calling connect!). /// diff --git a/src/iec61850/client/ied_connection.c b/src/iec61850/client/ied_connection.c index a78e2b50..5f9d2124 100644 --- a/src/iec61850/client/ied_connection.c +++ b/src/iec61850/client/ied_connection.c @@ -638,6 +638,24 @@ IedConnection_setConnectTimeout(IedConnection self, uint32_t timeoutInMs) self->connectionTimeout = timeoutInMs; } +void +IedConnection_setRequestTimeout(IedConnection self, uint32_t timeoutInMs) +{ + if (self->connection) { + MmsConnection_setRequestTimeout(self->connection, timeoutInMs); + } +} + +uint32_t +IedConnection_getRequestTimeout(IedConnection self) +{ + if (self->connection) { + return MmsConnection_getRequestTimeout(self->connection); + } + else + return 0; +} + IedConnectionState IedConnection_getState(IedConnection self) { diff --git a/src/iec61850/inc/iec61850_client.h b/src/iec61850/inc/iec61850_client.h index 45cae7f5..1c049ff8 100644 --- a/src/iec61850/inc/iec61850_client.h +++ b/src/iec61850/inc/iec61850_client.h @@ -244,6 +244,28 @@ IedConnection_destroy(IedConnection self); LIB61850_API void IedConnection_setConnectTimeout(IedConnection self, uint32_t timeoutInMs); +/** + * \brief set the request timeout in ms + * + * Set the request timeout for this connection. You can call this function any time to adjust + * timeout behavior. + * + * \param self the connection object + * \param timoutInMs the connection timeout in ms + */ +LIB61850_API void +IedConnection_setRequestTimeout(IedConnection self, uint32_t timeoutInMs); + +/** + * \brief get the request timeout in ms for this connection + * + * \param self the connection object + * + * \return request timeout in milliseconds + */ +LIB61850_API uint32_t +IedConnection_getRequestTimeout(IedConnection self); + /** * \brief Perform MMS message handling and house-keeping tasks (for non-thread mode only) * diff --git a/src/mms/inc/mms_client_connection.h b/src/mms/inc/mms_client_connection.h index e7e57338..275ecf41 100644 --- a/src/mms/inc/mms_client_connection.h +++ b/src/mms/inc/mms_client_connection.h @@ -160,6 +160,16 @@ MmsConnection_setFilestoreBasepath(MmsConnection self, const char* basepath); LIB61850_API void MmsConnection_setRequestTimeout(MmsConnection self, uint32_t timeoutInMs); +/** + * \brief Get the request timeout in ms for this connection + * + * \param self MmsConnection instance to operate on + * + * \return request timeout in milliseconds + */ +LIB61850_API uint32_t +MmsConnection_getRequestTimeout(MmsConnection self); + /** * \brief Set the connect timeout in ms for this connection instance * diff --git a/src/mms/iso_mms/client/mms_client_connection.c b/src/mms/iso_mms/client/mms_client_connection.c index b943f026..1002c42a 100644 --- a/src/mms/iso_mms/client/mms_client_connection.c +++ b/src/mms/iso_mms/client/mms_client_connection.c @@ -1555,6 +1555,12 @@ MmsConnection_setRequestTimeout(MmsConnection self, uint32_t timeoutInMs) self->requestTimeout = timeoutInMs; } +uint32_t +MmsConnection_getRequestTimeout(MmsConnection self) +{ + return self->requestTimeout; +} + void MmsConnection_setConnectTimeout(MmsConnection self, uint32_t timeoutInMs) {