Merge remote-tracking branch 'mz/v1.4' into v1.4

pull/183/head
Király Péter 6 years ago
commit a03f57c0a7

@ -54,8 +54,15 @@ int main(int argc, char** argv) {
MmsValue* value = IedConnection_readObject(con, &error, "simpleIOGenericIO/GGIO1.AnIn1.mag.f", IEC61850_FC_MX); MmsValue* value = IedConnection_readObject(con, &error, "simpleIOGenericIO/GGIO1.AnIn1.mag.f", IEC61850_FC_MX);
if (value != NULL) { if (value != NULL) {
if (MmsValue_getType(value) == MMS_FLOAT) {
float fval = MmsValue_toFloat(value); float fval = MmsValue_toFloat(value);
printf("read float value: %f\n", fval); printf("read float value: %f\n", fval);
}
else if (MmsValue_getType(value) == MMS_DATA_ACCESS_ERROR) {
printf("Failed to read value (error code: %i)\n", MmsValue_getDataAccessError(value));
}
MmsValue_delete(value); MmsValue_delete(value);
} }
@ -64,22 +71,23 @@ int main(int argc, char** argv) {
IedConnection_writeObject(con, &error, "simpleIOGenericIO/GGIO1.NamPlt.vendor", IEC61850_FC_DC, value); IedConnection_writeObject(con, &error, "simpleIOGenericIO/GGIO1.NamPlt.vendor", IEC61850_FC_DC, value);
if (error != IED_ERROR_OK) if (error != IED_ERROR_OK)
printf("failed to write simpleIOGenericIO/GGIO1.NamPlt.vendor!\n"); printf("failed to write simpleIOGenericIO/GGIO1.NamPlt.vendor! (error code: %i)\n", error);
MmsValue_delete(value); MmsValue_delete(value);
/* read data set */ /* read data set */
ClientDataSet clientDataSet = IedConnection_readDataSetValues(con, &error, "simpleIOGenericIO/LLN0.Events", NULL); ClientDataSet clientDataSet = IedConnection_readDataSetValues(con, &error, "simpleIOGenericIO/LLN0.Events", NULL);
if (clientDataSet == NULL) if (clientDataSet == NULL) {
printf("failed to read dataset\n"); printf("failed to read dataset\n");
goto close_connection;
}
/* Read RCB values */ /* Read RCB values */
ClientReportControlBlock rcb = ClientReportControlBlock rcb =
IedConnection_getRCBValues(con, &error, "simpleIOGenericIO/LLN0.RP.EventsRCB01", NULL); IedConnection_getRCBValues(con, &error, "simpleIOGenericIO/LLN0.RP.EventsRCB01", NULL);
if (rcb) {
bool rptEna = ClientReportControlBlock_getRptEna(rcb); bool rptEna = ClientReportControlBlock_getRptEna(rcb);
printf("RptEna = %i\n", rptEna); printf("RptEna = %i\n", rptEna);
@ -118,8 +126,9 @@ int main(int argc, char** argv) {
ClientDataSet_destroy(clientDataSet); ClientDataSet_destroy(clientDataSet);
ClientReportControlBlock_destroy(rcb); ClientReportControlBlock_destroy(rcb);
}
close_connection: close_connection:
IedConnection_close(con); IedConnection_close(con);
} }

@ -1,7 +1,7 @@
/* /*
* client_example_reporting.c * client_example_reporting.c
* *
* This example is intended to be used with server_example3 or server_example_goose. * This example is intended to be used with server_example_basic_io or server_example_goose.
*/ */
#include "iec61850_client.h" #include "iec61850_client.h"
@ -40,8 +40,7 @@ reportCallbackFunction(void* parameter, ClientReport report)
ctime_r(&unixTime, timeBuf); ctime_r(&unixTime, timeBuf);
#endif #endif
printf(" report contains timestamp (%u):", (unsigned int) unixTime); printf(" report contains timestamp (%u): %s", (unsigned int) unixTime, timeBuf);
printf("%s \n", timeBuf);
} }
int i; int i;
@ -85,9 +84,12 @@ main(int argc, char** argv)
if (error == IED_ERROR_OK) { if (error == IED_ERROR_OK) {
ClientReportControlBlock rcb = NULL;
ClientDataSet clientDataSet = NULL;
LinkedList dataSetDirectory = NULL;
/* read data set directory */ /* read data set directory */
LinkedList dataSetDirectory = dataSetDirectory = IedConnection_getDataSetDirectory(con, &error, "simpleIOGenericIO/LLN0.Events", NULL);
IedConnection_getDataSetDirectory(con, &error, "simpleIOGenericIO/LLN0.Events", NULL);
if (error != IED_ERROR_OK) { if (error != IED_ERROR_OK) {
printf("Reading data set directory failed!\n"); printf("Reading data set directory failed!\n");
@ -95,8 +97,6 @@ main(int argc, char** argv)
} }
/* read data set */ /* read data set */
ClientDataSet clientDataSet;
clientDataSet = IedConnection_readDataSetValues(con, &error, "simpleIOGenericIO/LLN0.Events", NULL); clientDataSet = IedConnection_readDataSetValues(con, &error, "simpleIOGenericIO/LLN0.Events", NULL);
if (clientDataSet == NULL) { if (clientDataSet == NULL) {
@ -105,8 +105,7 @@ main(int argc, char** argv)
} }
/* Read RCB values */ /* Read RCB values */
ClientReportControlBlock rcb = rcb = IedConnection_getRCBValues(con, &error, "simpleIOGenericIO/LLN0.RP.EventsRCB01", NULL);
IedConnection_getRCBValues(con, &error, "simpleIOGenericIO/LLN0.RP.EventsRCB01", NULL);
if (error != IED_ERROR_OK) { if (error != IED_ERROR_OK) {
printf("getRCBValues service error!\n"); printf("getRCBValues service error!\n");
@ -115,6 +114,7 @@ main(int argc, char** argv)
/* prepare the parameters of the RCP */ /* prepare the parameters of the RCP */
ClientReportControlBlock_setResv(rcb, true); ClientReportControlBlock_setResv(rcb, true);
ClientReportControlBlock_setTrgOps(rcb, TRG_OPT_DATA_CHANGED | TRG_OPT_QUALITY_CHANGED | TRG_OPT_GI);
ClientReportControlBlock_setDataSetReference(rcb, "simpleIOGenericIO/LLN0$Events"); /* NOTE the "$" instead of "." ! */ ClientReportControlBlock_setDataSetReference(rcb, "simpleIOGenericIO/LLN0$Events"); /* NOTE the "$" instead of "." ! */
ClientReportControlBlock_setRptEna(rcb, true); ClientReportControlBlock_setRptEna(rcb, true);
ClientReportControlBlock_setGI(rcb, true); ClientReportControlBlock_setGI(rcb, true);
@ -124,7 +124,7 @@ main(int argc, char** argv)
(void*) dataSetDirectory); (void*) dataSetDirectory);
/* Write RCB parameters and enable report */ /* Write RCB parameters and enable report */
IedConnection_setRCBValues(con, &error, rcb, RCB_ELEMENT_RESV | RCB_ELEMENT_DATSET | RCB_ELEMENT_RPT_ENA | RCB_ELEMENT_GI, true); IedConnection_setRCBValues(con, &error, rcb, RCB_ELEMENT_RESV | RCB_ELEMENT_DATSET | RCB_ELEMENT_TRG_OPS | RCB_ELEMENT_RPT_ENA | RCB_ELEMENT_GI, true);
if (error != IED_ERROR_OK) { if (error != IED_ERROR_OK) {
printf("setRCBValues service error!\n"); printf("setRCBValues service error!\n");
@ -156,12 +156,18 @@ main(int argc, char** argv)
ClientReportControlBlock_setRptEna(rcb, false); ClientReportControlBlock_setRptEna(rcb, false);
IedConnection_setRCBValues(con, &error, rcb, RCB_ELEMENT_RPT_ENA, true); IedConnection_setRCBValues(con, &error, rcb, RCB_ELEMENT_RPT_ENA, true);
exit_error: exit_error:
IedConnection_close(con); IedConnection_close(con);
if (clientDataSet)
ClientDataSet_destroy(clientDataSet); ClientDataSet_destroy(clientDataSet);
if (rcb)
ClientReportControlBlock_destroy(rcb); ClientReportControlBlock_destroy(rcb);
if (dataSetDirectory)
LinkedList_destroy(dataSetDirectory);
} }
else { else {
printf("Failed to connect to %s:%i\n", hostname, tcpPort); printf("Failed to connect to %s:%i\n", hostname, tcpPort);

@ -9,6 +9,11 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#ifdef _MSC_VER
#if (_MSC_VER <= 1600)
#define bool int
#endif
#endif
#include <string.h> #include <string.h>
#ifdef __GNUC__ #ifdef __GNUC__

Loading…
Cancel
Save