- .NET API: Added IedServerConfig class

pull/68/head
Michael Zillgith 7 years ago
parent cc24c86484
commit 48b14619a3

@ -7,8 +7,6 @@
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>iec61850dotnet</RootNamespace> <RootNamespace>iec61850dotnet</RootNamespace>
<AssemblyName>iec61850dotnet</AssemblyName> <AssemblyName>iec61850dotnet</AssemblyName>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
@ -52,6 +50,7 @@
<Compile Include="GooseControlBlock.cs" /> <Compile Include="GooseControlBlock.cs" />
<Compile Include="GooseSubscriber.cs" /> <Compile Include="GooseSubscriber.cs" />
<Compile Include="SampledValuesSubscriber.cs" /> <Compile Include="SampledValuesSubscriber.cs" />
<Compile Include="IedServerConfig.cs" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project> </Project>

@ -561,6 +561,9 @@ namespace IEC61850
[DllImport ("iec61850", CallingConvention=CallingConvention.Cdecl)] [DllImport ("iec61850", CallingConvention=CallingConvention.Cdecl)]
static extern IntPtr IedServer_create(IntPtr modelRef); static extern IntPtr IedServer_create(IntPtr modelRef);
[DllImport ("iec61850", CallingConvention=CallingConvention.Cdecl)]
static extern IntPtr IedServer_createWithConfig(IntPtr modelRef, IntPtr tlsConfiguration, IntPtr serverConfiguratio);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServer_setLocalIpAddress(IntPtr self, string localIpAddress); static extern void IedServer_setLocalIpAddress(IntPtr self, string localIpAddress);
@ -791,6 +794,16 @@ namespace IEC61850
self = IedServer_create(iedModel.self); self = IedServer_create(iedModel.self);
} }
public IedServer(IedModel iedModel, IedServerConfig config)
{
IntPtr nativeConfig = IntPtr.Zero;
if (config != null)
nativeConfig = config.self;
self = IedServer_createWithConfig (iedModel.self, IntPtr.Zero, nativeConfig);
}
// causes undefined behavior // causes undefined behavior
//~IedServer() //~IedServer()
//{ //{

@ -0,0 +1,111 @@
/*
* IedServerConfig.cs
*
* Copyright 2018 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 <http://www.gnu.org/licenses/>.
*
* See COPYING file for the complete license text.
*/
using System;
using System.Runtime.InteropServices;
namespace IEC61850.Server
{
/// <summary>
/// IedServer configuration object
/// </summary>
public class IedServerConfig : IDisposable
{
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr IedServerConfig_create();
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr IedServerConfig_destroy(IntPtr self);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_setReportBufferSize(IntPtr self, int reportBufferSize);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern int IedServerConfig_getReportBufferSize(IntPtr self);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_setFileServiceBasePath(IntPtr self, string basepath);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr IedServerConfig_getFileServiceBasePath(IntPtr self);
internal IntPtr self;
public IedServerConfig ()
{
self = IedServerConfig_create ();
}
/// <summary>
/// Gets or sets the size of the report buffer for buffered report control blocks
/// </summary>
/// <value>The size of the report buffer.</value>
public int ReportBufferSize
{
get {
return IedServerConfig_getReportBufferSize (self);
}
set {
IedServerConfig_setReportBufferSize (self, value);
}
}
/// <summary>
/// Gets or sets the file service base path.
/// </summary>
/// <value>The file service base path.</value>
public string FileServiceBasePath
{
get {
return Marshal.PtrToStringAnsi (IedServerConfig_getFileServiceBasePath (self));
}
set {
IedServerConfig_setFileServiceBasePath (self, value);
}
}
/// <summary>
/// Releases all resource used by the <see cref="IEC61850.Server.IedServerConfig"/> object.
/// </summary>
/// <remarks>Call <see cref="Dispose"/> when you are finished using the <see cref="IEC61850.Server.IedServerConfig"/>. The
/// <see cref="Dispose"/> method leaves the <see cref="IEC61850.Server.IedServerConfig"/> in an unusable state. After
/// calling <see cref="Dispose"/>, you must release all references to the
/// <see cref="IEC61850.Server.IedServerConfig"/> so the garbage collector can reclaim the memory that the
/// <see cref="IEC61850.Server.IedServerConfig"/> was occupying.</remarks>
public void Dispose()
{
lock (this) {
if (self != IntPtr.Zero) {
IedServerConfig_destroy (self);
self = IntPtr.Zero;
}
}
}
~IedServerConfig()
{
Dispose ();
}
}
}

@ -26,7 +26,10 @@ namespace server1
DataObject spcso1 = (DataObject)iedModel.GetModelNodeByShortObjectReference ("GenericIO/GGIO1.SPCSO1"); DataObject spcso1 = (DataObject)iedModel.GetModelNodeByShortObjectReference ("GenericIO/GGIO1.SPCSO1");
IedServer iedServer = new IedServer (iedModel); IedServerConfig config = new IedServerConfig ();
config.ReportBufferSize = 100000;
IedServer iedServer = new IedServer (iedModel, config);
iedServer.SetControlHandler (spcso1, delegate(DataObject controlObject, object parameter, MmsValue ctlVal, bool test) { iedServer.SetControlHandler (spcso1, delegate(DataObject controlObject, object parameter, MmsValue ctlVal, bool test) {
bool val = ctlVal.GetBoolean(); bool val = ctlVal.GetBoolean();

Loading…
Cancel
Save