/*
* 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 .
*
* See COPYING file for the complete license text.
*/
using System;
using System.Runtime.InteropServices;
using IEC61850.Common;
namespace IEC61850.Server
{
///
/// IedServer configuration object
///
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);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_setEdition(IntPtr self, byte edition);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern byte IedServerConfig_getEdition(IntPtr self);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_setMaxMmsConnections(IntPtr self, int maxConnections);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern int IedServerConfig_getMaxMmsConnections(IntPtr self);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
static extern bool IedServerConfig_isDynamicDataSetServiceEnabled(IntPtr self);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_enableDynamicDataSetService(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool enable);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_setMaxAssociationSpecificDataSets(IntPtr self, int maxDataSets);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern int IedServerConfig_getMaxAssociationSpecificDataSets(IntPtr self);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_setMaxDomainSpecificDataSets(IntPtr self, int maxDataSets);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern int IedServerConfig_getMaxDomainSpecificDataSets(IntPtr self);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_setMaxDataSetEntries(IntPtr self, int maxDataSetEntries);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern int IedServerConfig_getMaxDatasSetEntries(IntPtr self);
internal IntPtr self;
public IedServerConfig ()
{
self = IedServerConfig_create ();
}
///
/// Gets or sets the size of the report buffer for buffered report control blocks
///
/// The size of the report buffer.
public int ReportBufferSize
{
get {
return IedServerConfig_getReportBufferSize (self);
}
set {
IedServerConfig_setReportBufferSize (self, value);
}
}
///
/// Gets or sets the file service base path.
///
/// The file service base path.
public string FileServiceBasePath
{
get {
return Marshal.PtrToStringAnsi (IedServerConfig_getFileServiceBasePath (self));
}
set {
IedServerConfig_setFileServiceBasePath (self, value);
}
}
///
/// Gets or sets the edition of the IEC 61850 standard to use
///
/// The IEC 61850 edition to use.
public Iec61850Edition Edition
{
get {
return (Iec61850Edition)IedServerConfig_getEdition (self);
}
set {
IedServerConfig_setEdition (self, (byte) value);
}
}
///
/// Gets or sets maximum number of MMS clients
///
/// The max number of MMS client connections.
public int MaxMmsConnections
{
get {
return IedServerConfig_getMaxMmsConnections (self);
}
set {
IedServerConfig_setMaxMmsConnections (self, value);
}
}
///
/// Enable/Disable dynamic data set service for MMS
///
/// true if dynamic data set service enabled; otherwise, false.
public bool DynamicDataSetServiceEnabled
{
get {
return IedServerConfig_isDynamicDataSetServiceEnabled (self);
}
set {
IedServerConfig_enableDynamicDataSetService (self, value);
}
}
///
/// Gets or sets the maximum number of data set entries for dynamic data sets
///
/// The max. number data set entries.
public int MaxDataSetEntries
{
get {
return IedServerConfig_getMaxDatasSetEntries (self);
}
set {
IedServerConfig_setMaxDataSetEntries (self, value);
}
}
///
/// Gets or sets the maximum number of association specific (non-permanent) data sets.
///
/// The max. number of association specific data sets.
public int MaxAssociationSpecificDataSets
{
get {
return IedServerConfig_getMaxAssociationSpecificDataSets (self);
}
set {
IedServerConfig_setMaxAssociationSpecificDataSets (self, value);
}
}
///
/// Gets or sets the maximum number of domain specific (permanent) data sets.
///
/// The max. numebr of domain specific data sets.
public int MaxDomainSpecificDataSets
{
get {
return IedServerConfig_getMaxDomainSpecificDataSets (self);
}
set {
IedServerConfig_setMaxDomainSpecificDataSets (self, value);
}
}
///
/// 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()
{
lock (this) {
if (self != IntPtr.Zero) {
IedServerConfig_destroy (self);
self = IntPtr.Zero;
}
}
}
~IedServerConfig()
{
Dispose ();
}
}
}