From b9ba81f8a001ce692ed36aef3b72c5ab1fdda6fd Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Wed, 17 May 2017 10:33:08 +0200 Subject: [PATCH] - added Timestamp_toMmsValue function --- examples/sv_publisher/sv_publisher_example.c | 2 +- src/iec61850/common/iec61850_common.c | 14 ++++++++++++++ src/iec61850/inc/iec61850_common.h | 9 +++++++++ src/vs/libiec61850-wo-goose.def | 3 ++- src/vs/libiec61850.def | 3 ++- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/examples/sv_publisher/sv_publisher_example.c b/examples/sv_publisher/sv_publisher_example.c index b048bef..6c4cf68 100644 --- a/examples/sv_publisher/sv_publisher_example.c +++ b/examples/sv_publisher/sv_publisher_example.c @@ -20,7 +20,7 @@ void sigint_handler(int signalId) int main(int argc, char** argv) { - SampledValuesPublisher svPublisher = SampledValuesPublisher_create("vboxnet0"); + SampledValuesPublisher svPublisher = SampledValuesPublisher_create("eth0"); SV_ASDU asdu1 = SampledValuesPublisher_addASDU(svPublisher, "svpub1", NULL, 1); diff --git a/src/iec61850/common/iec61850_common.c b/src/iec61850/common/iec61850_common.c index 3189203..d2a6898 100644 --- a/src/iec61850/common/iec61850_common.c +++ b/src/iec61850/common/iec61850_common.c @@ -405,6 +405,20 @@ Timestamp_setByMmsUtcTime(Timestamp* self, MmsValue* mmsValue) memcpy(self->val, mmsValue->value.utcTime, 8); } +MmsValue* +Timestamp_toMmsValue(Timestamp* self, MmsValue* mmsValue) +{ + MmsValue* convertedValue = mmsValue; + + if (convertedValue == NULL) + convertedValue = MmsValue_newUtcTime(0); + + if (convertedValue != NULL) + memcpy(convertedValue->value.utcTime, self->val, 8); + + return convertedValue; +} + char* LibIEC61850_getVersionString() { diff --git a/src/iec61850/inc/iec61850_common.h b/src/iec61850/inc/iec61850_common.h index 47131c4..a48e8ed 100644 --- a/src/iec61850/inc/iec61850_common.h +++ b/src/iec61850/inc/iec61850_common.h @@ -406,6 +406,15 @@ Timestamp_setTimeInMilliseconds(Timestamp* self, uint64_t millisSinceEpoch); void Timestamp_setByMmsUtcTime(Timestamp* self, MmsValue* mmsValue); +/** + * \brief Set an MmsValue instance of type UTCTime to the timestamp value + * + * \param self the Timestamp instance + * \param mmsValue the mmsValue instance, if NULL a new instance will be created + */ +MmsValue* +Timestamp_toMmsValue(Timestamp* self, MmsValue* mmsValue); + /** * \brief Get the version of the library as string * diff --git a/src/vs/libiec61850-wo-goose.def b/src/vs/libiec61850-wo-goose.def index 9711a2c..4a8cfc1 100644 --- a/src/vs/libiec61850-wo-goose.def +++ b/src/vs/libiec61850-wo-goose.def @@ -561,4 +561,5 @@ EXPORTS Timestamp_create Timestamp_destroy Timestamp_setByMmsUtcTime - IedServer_setLocalIpAddress \ No newline at end of file + IedServer_setLocalIpAddress + Timestamp_toMmsValue diff --git a/src/vs/libiec61850.def b/src/vs/libiec61850.def index 45dc4d2..1769ee9 100644 --- a/src/vs/libiec61850.def +++ b/src/vs/libiec61850.def @@ -639,4 +639,5 @@ EXPORTS Timestamp_create Timestamp_destroy Timestamp_setByMmsUtcTime - IedServer_setLocalIpAddress \ No newline at end of file + IedServer_setLocalIpAddress + Timestamp_toMmsValue