From d327f0715e1390046d8fc2d18148e050514e4a0f Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Mon, 23 Apr 2018 20:30:10 +0200 Subject: [PATCH] - added function SVReceiver_enableDestAddrCheck --- .../SampledValuesSubscriber.cs | 45 ++++++++++++++++++- .../client_example1.c | 2 +- src/sampled_values/sv_subscriber.c | 6 +++ src/sampled_values/sv_subscriber.h | 21 ++++++--- src/vs/libiec61850.def | 3 +- 5 files changed, 68 insertions(+), 9 deletions(-) diff --git a/dotnet/IEC61850forCSharp/SampledValuesSubscriber.cs b/dotnet/IEC61850forCSharp/SampledValuesSubscriber.cs index 66a9091c..5da087a0 100644 --- a/dotnet/IEC61850forCSharp/SampledValuesSubscriber.cs +++ b/dotnet/IEC61850forCSharp/SampledValuesSubscriber.cs @@ -32,15 +32,23 @@ namespace IEC61850 namespace Subscriber { + /// + /// SV receiver. + /// + /// A receiver is responsible for processing all SV message for a single Ethernet interface. + /// In order to process messages from multiple Ethernet interfaces you have to create multiple + /// instances. public class SVReceiver : IDisposable { [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr SVReceiver_create (); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] private static extern void SVReceiver_disableDestAddrCheck(IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + private static extern void SVReceiver_enableDestAddrCheck(IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] private static extern void SVReceiver_addSubscriber(IntPtr self, IntPtr subscriber); @@ -67,6 +75,10 @@ namespace IEC61850 private bool isDisposed = false; + /// + /// Initializes a new instance of the class. + /// + public SVReceiver() { self = SVReceiver_create (); @@ -81,22 +93,38 @@ namespace IEC61850 { SVReceiver_disableDestAddrCheck (self); } + + public void EnableDestAddrCheck() + { + SVReceiver_enableDestAddrCheck (self); + } + /// + /// Add a subscriber to handle + /// + /// Subscriber. public void AddSubscriber(SVSubscriber subscriber) { SVReceiver_addSubscriber (self, subscriber.self); } + public void RemoveSubscriber(SVSubscriber subscriber) { SVReceiver_removeSubscriber (self, subscriber.self); } + /// + /// Start handling SV messages + /// public void Start() { SVReceiver_start (self); } + /// + /// Stop handling SV messges + /// public void Stop() { SVReceiver_stop (self); @@ -107,6 +135,14 @@ namespace IEC61850 return SVReceiver_isRunning (self); } + /// + /// Releases all resource used by the object. + /// + /// Call when you are finished using the . The + /// method leaves the in an unusable state. + /// After calling , you must release all references to the + /// so the garbage collector can reclaim the memory that the + /// was occupying. public void Dispose() { if (isDisposed == false) { @@ -128,6 +164,13 @@ namespace IEC61850 /// public delegate void SVUpdateListener (SVSubscriber report, object parameter, SVSubscriberASDU asdu); + /// + /// Sampled Values (SV) Subscriber + /// + /// A subscriber is an instance associated with a single stream of measurement data. It is identified + /// by the Ethernet destination address, the appID value (both are on SV message level) and the svID value + /// that is part of each ASDU. + /// public class SVSubscriber : IDisposable { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] diff --git a/examples/iec61850_client_example1/client_example1.c b/examples/iec61850_client_example1/client_example1.c index e20a2327..f5b23575 100644 --- a/examples/iec61850_client_example1/client_example1.c +++ b/examples/iec61850_client_example1/client_example1.c @@ -1,7 +1,7 @@ /* * client_example1.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" diff --git a/src/sampled_values/sv_subscriber.c b/src/sampled_values/sv_subscriber.c index 89b62a54..807e6208 100644 --- a/src/sampled_values/sv_subscriber.c +++ b/src/sampled_values/sv_subscriber.c @@ -118,6 +118,12 @@ SVReceiver_disableDestAddrCheck(SVReceiver self) self->checkDestAddr = false; } +void +SVReceiver_enableDestAddrCheck(SVReceiver self) +{ + self->checkDestAddr = false; +} + void SVReceiver_addSubscriber(SVReceiver self, SVSubscriber subscriber) { diff --git a/src/sampled_values/sv_subscriber.h b/src/sampled_values/sv_subscriber.h index 8bfe10ed..7379ac0b 100644 --- a/src/sampled_values/sv_subscriber.h +++ b/src/sampled_values/sv_subscriber.h @@ -1,7 +1,7 @@ /* * sv_subscriber.h * - * Copyright 2015 Michael Zillgith + * Copyright 2015-2018 Michael Zillgith * * This file is part of libIEC61850. * @@ -98,7 +98,7 @@ typedef struct sSVSubscriber_ASDU* SVSubscriber_ASDU; /** * \brief opaque handle to a SV subscriber instance * - * A subscriber is an instance associated with a single stream of measurement data. It is identified + * A subscriber is an instance associated with a single stream of measurement data. It is identified * by the Ethernet destination address, the appID value (both are on SV message level) and the svID value * that is part of each ASDU (SVSubscriber_ASDU object). */ @@ -135,15 +135,24 @@ SVReceiver_create(void); /** * \brief Disable check for destination address of the received SV messages * - * Per default both the appID and the destination address are checked to identify - * relevant SV messages. Destination address check can be disabled for performance - * reason when the appIDs are unique in the local system. - * * \param self the receiver instance reference */ void SVReceiver_disableDestAddrCheck(SVReceiver self); +/** + * \brief Enable check for destination address of the received SV messages + * + * Per default only the appID is checked to identify relevant SV messages and the + * destination address is ignored for performance reasons. This only works when the + * appIDs are unique in the local system. Otherwise the destination address check + * has to be enabled. + * + * \param self the receiver instance reference + */ +void +SVReceiver_enableDestAddrCheck(SVReceiver self); + /** * \brief Set the Ethernet interface ID for the receiver instance * diff --git a/src/vs/libiec61850.def b/src/vs/libiec61850.def index b3289f79..6ba5d303 100644 --- a/src/vs/libiec61850.def +++ b/src/vs/libiec61850.def @@ -706,4 +706,5 @@ EXPORTS SVPublisher_ASDU_addQuality SVPublisher_ASDU_setQuality Timestamp_createFromByteArray - IedModel_getDeviceByIndex \ No newline at end of file + IedModel_getDeviceByIndex + SVReceiver_enableDestAddrCheck \ No newline at end of file