diff --git a/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs b/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs index b6c993ae..d23eefc8 100644 --- a/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs +++ b/dotnet/IEC61850forCSharp/IEC61850ClientAPI.cs @@ -111,7 +111,10 @@ namespace IEC61850 static extern IntPtr IedConnection_getLogicalNodeDirectory (IntPtr self, out int error, string logicalNodeReference, int acsiClass); [DllImport ("iec61850", CallingConvention=CallingConvention.Cdecl)] - static extern IntPtr IedConnection_getServerDirectory (IntPtr self, out int error, bool getFileNames); + static extern IntPtr IedConnection_getServerDirectory (IntPtr self, out int error, bool getFileNames); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void IedConnection_getDeviceModelFromServer(IntPtr self, out int error); [DllImport ("iec61850", CallingConvention=CallingConvention.Cdecl)] static extern IntPtr IedConnection_getLogicalDeviceDirectory (IntPtr self, out int error, string logicalDeviceName); @@ -253,7 +256,17 @@ namespace IEC61850 ControlObject controlObject = new ControlObject (objectReference, connection, this); return controlObject; - } + } + + public void UpdateDeviceModel() + { + int error; + + IedConnection_getDeviceModelFromServer(connection, out error); + + if (error != 0) + throw new IedConnectionException("UpdateDeviceModel failed", error); + } /// This exception is thrown if there is a connection or service error public List GetServerDirectory (bool fileDirectory = false) diff --git a/dotnet/IEC61850forCSharp/IEC61850forCSharp.csproj b/dotnet/IEC61850forCSharp/IEC61850forCSharp.csproj index be311af9..d5d09da9 100644 --- a/dotnet/IEC61850forCSharp/IEC61850forCSharp.csproj +++ b/dotnet/IEC61850forCSharp/IEC61850forCSharp.csproj @@ -30,6 +30,10 @@ + + + + diff --git a/src/hal/inc/hal_socket.h b/src/hal/inc/hal_socket.h index ce950d4a..a06893dd 100644 --- a/src/hal/inc/hal_socket.h +++ b/src/hal/inc/hal_socket.h @@ -54,15 +54,44 @@ typedef struct sSocket* Socket; /** Opaque reference for a set of server and socket handles */ typedef struct sHandleSet* HandleSet; +/** + * \brief Create a new connection handle set (HandleSet) + * + * \return new HandleSet instance + */ HandleSet Handleset_new(void); +/** + * \brief add a soecket to an existing handle set + * + * \param self the HandleSet instance + * \param sock the socket to add + */ void Handleset_addSocket(HandleSet self, const Socket sock); + +/** + * \brief wait for a socket to become ready + * + * This function is corresponding to the BSD socket select function. + * It returns the number of sockets on which data is pending or 0 if no data is pending + * on any of the monitored connections. The function will return after "timeout" ms if no + * data is pending. + * The function shall return -1 if a socket error occures. + * + * \param self the HandleSet instance + * \oaram timeout in milliseconds (ms) + */ int Handleset_waitReady(HandleSet self, unsigned int timeoutMs); +/** + * \brief destroy the HandleSet instance + * + * \param self the HandleSet instance to destroy + */ void Handleset_destroy(HandleSet self); diff --git a/src/hal/socket/linux/socket_linux.c b/src/hal/socket/linux/socket_linux.c index 87c22a5b..a206da81 100644 --- a/src/hal/socket/linux/socket_linux.c +++ b/src/hal/socket/linux/socket_linux.c @@ -89,7 +89,7 @@ Handleset_waitReady(HandleSet self, unsigned int timeoutMs) { int result; - if (self != NULL && self->maxHandle >= 0) { + if ((self != NULL) && (self->maxHandle >= 0)) { struct timeval timeout; timeout.tv_sec = timeoutMs / 1000; diff --git a/src/iec61850/client/ied_connection.c b/src/iec61850/client/ied_connection.c index 846d8071..6dbedc9a 100644 --- a/src/iec61850/client/ied_connection.c +++ b/src/iec61850/client/ied_connection.c @@ -966,9 +966,8 @@ IedConnection_getDeviceModelFromServer(IedConnection self, IedClientError* error LinkedList_destroy(logicalDeviceNames); } - else { + else *error = iedConnection_mapMmsErrorToIedError(mmsError); - } } LinkedList /**/ diff --git a/src/iec61850/inc/iec61850_client.h b/src/iec61850/inc/iec61850_client.h index 1f93a812..748da871 100644 --- a/src/iec61850/inc/iec61850_client.h +++ b/src/iec61850/inc/iec61850_client.h @@ -607,13 +607,16 @@ typedef void (*ReportCallbackFunction) (void* parameter, ClientReport report); /** * \brief Install a report handler function for the specified report control block (RCB) * - * It is important that you provide a ClientDataSet instance that is already populated with an MmsValue object - * of type MMS_STRUCTURE that contains the data set entries as structure elements. This is required because otherwise - * the report handler is not able to correctly parse the report message from the server. + * This function will replace a report handler set earlier for the specified RCB. The report handler + * will be called whenever a report for the specified RCB is received. + * Please note that this function should be called whenever the RCB data set is changed or updated. + * Otherwise the internal data structures storing the received data set values will not be updated + * correctly. * - * This function will replace a formerly set report handler function for the specified RCB. + * When replacing a report handler you only have to call this function. There is no separate call to + * IedConnection_uninstallReportHandler() required. * - * \param connection the connection object + * \param self the connection object * \param rcbReference object reference of the report control block * \param rptId a string that identifies the report. If the rptId is not available then the * rcbReference is used to identify the report. @@ -626,6 +629,9 @@ IedConnection_installReportHandler(IedConnection self, char* rcbReference, char* /** * \brief uninstall a report handler function for the specified report control block (RCB) + * + * \param self the connection object + * \param rcbReference object reference of the report control block */ void IedConnection_uninstallReportHandler(IedConnection self, char* rcbReference); diff --git a/src/iec61850/server/mms_mapping/reporting.c b/src/iec61850/server/mms_mapping/reporting.c index 3a994aab..d49a6064 100644 --- a/src/iec61850/server/mms_mapping/reporting.c +++ b/src/iec61850/server/mms_mapping/reporting.c @@ -328,7 +328,6 @@ sendReport(ReportControl* self, bool isIntegrity, bool isGI) if (self->inclusionFlags[i] != REPORT_CONTROL_NONE) addReferenceForEntry = true; - if (addReferenceForEntry) { char dataReference[130];