From 33fcf156d4ddb02a6c57da2c15b04b04883695e8 Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Thu, 25 Feb 2016 12:25:30 +0100 Subject: [PATCH] - client: IedConnection_setRCBValues send GI last when RptEna=true included --- CMakeLists.txt | 2 +- config/stack_config.h | 2 +- .../client_example_reporting.c | 3 +- .../inc/libiec61850_platform_includes.h | 2 +- src/iec61850/client/client_report_control.c | 30 +++++++++++++++---- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 528be7a8..b303bdd5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ project(libiec61850) set(LIB_VERSION_MAJOR "0") set(LIB_VERSION_MINOR "9") -set(LIB_VERSION_PATCH "0") +set(LIB_VERSION_PATCH "1") # feature checks include(CheckLibraryExists) diff --git a/config/stack_config.h b/config/stack_config.h index 8e0a8940..449faf3f 100644 --- a/config/stack_config.h +++ b/config/stack_config.h @@ -156,7 +156,7 @@ /* default results for MMS identify service */ #define CONFIG_DEFAULT_MMS_VENDOR_NAME "libiec61850.com" #define CONFIG_DEFAULT_MMS_MODEL_NAME "LIBIEC61850" -#define CONFIG_DEFAULT_MMS_REVISION "0.9.0" +#define CONFIG_DEFAULT_MMS_REVISION "0.9.1" /* MMS virtual file store base path - where file services are looking for files */ #define CONFIG_VIRTUAL_FILESTORE_BASEPATH "./vmd-filestore/" diff --git a/examples/iec61850_client_example_reporting/client_example_reporting.c b/examples/iec61850_client_example_reporting/client_example_reporting.c index ba119f0b..378596d9 100644 --- a/examples/iec61850_client_example_reporting/client_example_reporting.c +++ b/examples/iec61850_client_example_reporting/client_example_reporting.c @@ -116,13 +116,14 @@ int main(int argc, char** argv) { ClientReportControlBlock_setResv(rcb, true); ClientReportControlBlock_setDataSetReference(rcb, "simpleIOGenericIO/LLN0$Events"); /* NOTE the "$" instead of "." ! */ ClientReportControlBlock_setRptEna(rcb, true); + ClientReportControlBlock_setGI(rcb, true); /* Configure the report receiver */ IedConnection_installReportHandler(con, "simpleIOGenericIO/LLN0.RP.EventsRCB", ClientReportControlBlock_getRptId(rcb), reportCallbackFunction, (void*) dataSetDirectory); /* Write RCB parameters and enable report */ - IedConnection_setRCBValues(con, &error, rcb, RCB_ELEMENT_RESV | RCB_ELEMENT_DATSET | RCB_ELEMENT_RPT_ENA, true); + IedConnection_setRCBValues(con, &error, rcb, RCB_ELEMENT_RESV | RCB_ELEMENT_DATSET | RCB_ELEMENT_RPT_ENA | RCB_ELEMENT_GI, true); if (error != IED_ERROR_OK) { printf("setRCBValues service error!\n"); diff --git a/src/common/inc/libiec61850_platform_includes.h b/src/common/inc/libiec61850_platform_includes.h index f4de6b94..d2639c31 100644 --- a/src/common/inc/libiec61850_platform_includes.h +++ b/src/common/inc/libiec61850_platform_includes.h @@ -15,7 +15,7 @@ #include "platform_endian.h" -#define LIBIEC61850_VERSION "0.9.0" +#define LIBIEC61850_VERSION "0.9.1" #ifndef CONFIG_DEFAULT_MMS_VENDOR_NAME #define CONFIG_DEFAULT_MMS_VENDOR_NAME "libiec61850.com" diff --git a/src/iec61850/client/client_report_control.c b/src/iec61850/client/client_report_control.c index b0b4a187..5e543054 100644 --- a/src/iec61850/client/client_report_control.c +++ b/src/iec61850/client/client_report_control.c @@ -37,7 +37,7 @@ isBufferedRcb(const char* objectReference) const char* separator = strchr(objectReference, '.'); if (separator == NULL) - return false; //TODO report an error + return false; if (*(separator + 1) == 'B') return true; @@ -50,6 +50,8 @@ ClientReportControlBlock_create(const char* objectReference) { ClientReportControlBlock self = (ClientReportControlBlock) GLOBAL_CALLOC(1, sizeof(struct sClientReportControlBlock)); + //TODO check validity of object reference?! + self->objectReference = copyString(objectReference); self->isBuffered = isBufferedRcb(objectReference); @@ -499,6 +501,7 @@ IedConnection_setRCBValues(IedConnection self, IedClientError* error, ClientRepo MmsError mmsError = MMS_ERROR_NONE; bool isBuffered = ClientReportControlBlock_isBuffered(rcb); + bool sendGILast = false; /* GI should be sent last when RptEna=TRUE is included */ char domainId[65]; char itemId[129]; @@ -591,10 +594,18 @@ IedConnection_setRCBValues(IedConnection self, IedClientError* error, ClientRepo } if (parametersMask & RCB_ELEMENT_GI) { - strcpy(itemId + itemIdLen, "$GI"); - LinkedList_add(itemIds, copyString(itemId)); - LinkedList_add(values, rcb->gi); + if (parametersMask & RCB_ELEMENT_RPT_ENA) { + if (MmsValue_getBoolean(rcb->rptEna)) + sendGILast = true; + } + + if (sendGILast == false) { + strcpy(itemId + itemIdLen, "$GI"); + + LinkedList_add(itemIds, copyString(itemId)); + LinkedList_add(values, rcb->gi); + } } if (parametersMask & RCB_ELEMENT_PURGE_BUF) { @@ -624,6 +635,13 @@ IedConnection_setRCBValues(IedConnection self, IedClientError* error, ClientRepo LinkedList_add(values, rcb->rptEna); } + if (sendGILast) { + strcpy(itemId + itemIdLen, "$GI"); + + LinkedList_add(itemIds, copyString(itemId)); + LinkedList_add(values, rcb->gi); + } + if (singleRequest) { LinkedList accessResults = NULL; @@ -672,10 +690,10 @@ IedConnection_setRCBValues(IedConnection self, IedClientError* error, ClientRepo goto exit_function; } - error_invalid_parameter: +error_invalid_parameter: *error = IED_ERROR_USER_PROVIDED_INVALID_ARGUMENT; - exit_function: +exit_function: LinkedList_destroy(itemIds); LinkedList_destroyStatic(values); }