From 245a21b1296d19732c8fd50004689196b6a0d93c Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Wed, 14 Dec 2016 17:38:33 +0100 Subject: [PATCH] - client: added function IedConnection_readInt64Value --- src/iec61850/client/ied_connection.c | 25 ++++++++++++++++++++++++- src/iec61850/inc/iec61850_client.h | 13 +++++++++++++ src/vs/libiec61850-wo-goose.def | 1 + src/vs/libiec61850.def | 1 + 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/iec61850/client/ied_connection.c b/src/iec61850/client/ied_connection.c index fd7f79cd..cab52dc6 100644 --- a/src/iec61850/client/ied_connection.c +++ b/src/iec61850/client/ied_connection.c @@ -762,7 +762,7 @@ IedConnection_readInt32Value(IedConnection self, IedClientError* error, const ch { MmsValue* value = IedConnection_readObject(self, error, objectReference, fc); - int32_t retVal = 0.f; + int32_t retVal = 0; if (value != NULL) { if ((MmsValue_getType(value) == MMS_INTEGER) || (MmsValue_getType(value) == MMS_UNSIGNED)) @@ -803,6 +803,29 @@ IedConnection_readUnsigned32Value(IedConnection self, IedClientError* error, con return retVal; } +int64_t +IedConnection_readInt64Value(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc) +{ + MmsValue* value = IedConnection_readObject(self, error, objectReference, fc); + + int64_t retVal = 0; + + if (value != NULL) { + if ((MmsValue_getType(value) == MMS_INTEGER) || (MmsValue_getType(value) == MMS_UNSIGNED)) + retVal = MmsValue_toInt64(value); + else { + if (MmsValue_getType(value) == MMS_DATA_ACCESS_ERROR) + *error = iedConnection_mapDataAccessErrorToIedError(MmsValue_getDataAccessError(value)); + else + *error = IED_ERROR_UNEXPECTED_VALUE_RECEIVED; + } + + MmsValue_delete(value); + } + + return retVal; +} + Timestamp* IedConnection_readTimestampValue(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc, Timestamp* timeStamp) diff --git a/src/iec61850/inc/iec61850_client.h b/src/iec61850/inc/iec61850_client.h index 879ae565..8d2b46b7 100644 --- a/src/iec61850/inc/iec61850_client.h +++ b/src/iec61850/inc/iec61850_client.h @@ -1186,6 +1186,19 @@ IedConnection_readStringValue(IedConnection self, IedClientError* error, const c int32_t IedConnection_readInt32Value(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc); +/** + * \brief read a functional constrained data attribute (FCDA) of type Integer or Unsigned and return the result as int64_t + * + * \param self the connection object to operate on + * \param error the error code if an error occurs + * \param object reference of the data attribute to read + * \param fc the functional constraint of the data attribute to read + * + * \return an int64_t value of the read data attributes + */ +int64_t +IedConnection_readInt64Value(IedConnection self, IedClientError* error, const char* objectReference, FunctionalConstraint fc); + /** * \brief read a functional constrained data attribute (FCDA) of type Integer or Unsigned and return the result as uint32_t * diff --git a/src/vs/libiec61850-wo-goose.def b/src/vs/libiec61850-wo-goose.def index 039b7e6b..2fee1d49 100644 --- a/src/vs/libiec61850-wo-goose.def +++ b/src/vs/libiec61850-wo-goose.def @@ -557,3 +557,4 @@ EXPORTS FileSystem_writeFile MmsConnection_obtainFile IedConnection_setFile + IedConnection_readInt64Value diff --git a/src/vs/libiec61850.def b/src/vs/libiec61850.def index b0a1025b..2b4d1a66 100644 --- a/src/vs/libiec61850.def +++ b/src/vs/libiec61850.def @@ -635,3 +635,4 @@ EXPORTS FileSystem_writeFile MmsConnection_obtainFile IedConnection_setFile + IedConnection_readInt64Value