From 5cabd4370228dd28490a9f90070616a50099aedb Mon Sep 17 00:00:00 2001 From: Michael Zillgith Date: Thu, 28 Dec 2017 20:23:08 +0100 Subject: [PATCH] - added missing file --- dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs | 25 ++- .../SampledValuesControlBlock.cs | 195 ++++++++++++++++++ 2 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 dotnet/IEC61850forCSharp/SampledValuesControlBlock.cs diff --git a/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs b/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs index d5f5bfc7..1e1d8617 100644 --- a/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs +++ b/dotnet/IEC61850forCSharp/IEC61850CommonAPI.cs @@ -1,4 +1,27 @@ -using System; +/* + * IEC61850CommonAPI.cs + * + * Copyright 2014-2017 Michael Zillgith + * + * This file is part of libIEC61850. + * + * libIEC61850 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * libIEC61850 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with libIEC61850. If not, see . + * + * See COPYING file for the complete license text. + */ + +using System; using System.Runtime.InteropServices; namespace IEC61850 diff --git a/dotnet/IEC61850forCSharp/SampledValuesControlBlock.cs b/dotnet/IEC61850forCSharp/SampledValuesControlBlock.cs new file mode 100644 index 00000000..bf4cd213 --- /dev/null +++ b/dotnet/IEC61850forCSharp/SampledValuesControlBlock.cs @@ -0,0 +1,195 @@ +/* + * SampledValuesControlBlock.cs + * + * Copyright 2017 Michael Zillgith + * + * This file is part of libIEC61850. + * + * libIEC61850 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * libIEC61850 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with libIEC61850. If not, see . + * + * See COPYING file for the complete license text. + */ +using System; +using System.Runtime.InteropServices; +using System.Diagnostics; + +using IEC61850.Common; + +namespace IEC61850 +{ + namespace Client + { + /// + /// Sampled values control bloc (SvCB) representation. + /// + /// + /// This class is used as a client side representation (copy) of a sampled values control block (SvCB). + /// + public class SampledValuesControlBlock : IDisposable + { + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr ClientSVControlBlock_create (IntPtr iedConnection, string reference); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientSVControlBlock_destroy(IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern int ClientSVControlBlock_getLastComError (IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + static extern bool ClientSVControlBlock_isMulticast (IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + static extern bool ClientSVControlBlock_setSvEna (IntPtr self, bool value); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + static extern bool ClientSVControlBlock_setResv (IntPtr self, bool value); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + static extern bool ClientSVControlBlock_getSvEna (IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + static extern bool ClientSVControlBlock_getResv (IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr ClientSVControlBlock_getMsvID (IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr ClientSVControlBlock_getDatSet (IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern UInt32 ClientSVControlBlock_getConfRev (IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern UInt16 ClientSVControlBlock_getSmpRate (IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern int ClientSVControlBlock_getOptFlds (IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern byte ClientSVControlBlock_getSmpMod(IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern int ClientSVControlBlock_getNoASDU (IntPtr self); + + private IntPtr self; + private string objectReference; + + private bool isDisposed = false; + + + internal SampledValuesControlBlock(IntPtr iedConnection, string objectReference) + { + self = ClientSVControlBlock_create (iedConnection, objectReference); + this.objectReference = objectReference; + } + + public string GetObjectReference () + { + return this.objectReference; + } + + public IedClientError GetLastComError() + { + return (IedClientError)ClientSVControlBlock_getLastComError (self); + } + + public bool IsMulticast() + { + return ClientSVControlBlock_isMulticast (self); + } + + public bool GetResv() + { + return ClientSVControlBlock_getResv (self); + } + + public bool SetResv(bool value) + { + return ClientSVControlBlock_setResv (self, value); + } + + public bool GetSvEna() + { + return ClientSVControlBlock_getSvEna (self); + } + + public bool SetSvEna(bool value) + { + return ClientSVControlBlock_setSvEna (self, value); + } + + public string GetMsvID () + { + IntPtr msvIdPtr = ClientSVControlBlock_getMsvID (self); + + return Marshal.PtrToStringAnsi (msvIdPtr); + } + + public string GetDatSet () + { + IntPtr datSetPtr = ClientSVControlBlock_getDatSet (self); + + return Marshal.PtrToStringAnsi (datSetPtr); + } + + public UInt32 GetConfRev () + { + return ClientSVControlBlock_getConfRev (self); + } + + public UInt16 GetSmpRate () + { + return ClientSVControlBlock_getSmpRate (self); + } + + public SVOptions GetOptFlds () + { + return (SVOptions)ClientSVControlBlock_getOptFlds (self); + } + + public SmpMod GetSmpMod () + { + return (SmpMod)ClientSVControlBlock_getSmpMod (self); + } + + public int GetNoASDU () + { + return ClientSVControlBlock_getNoASDU (self); + } + + public void Dispose() + { + if (isDisposed == false) { + isDisposed = true; + ClientSVControlBlock_destroy (self); + self = IntPtr.Zero; + } + } + + ~SampledValuesControlBlock() + { + Dispose (); + } + + } + + + } +}