/*
* 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_setReportBufferSizeForURCBs(IntPtr self, int reportBufferSize);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern int IedServerConfig_getReportBufferSizeForURCBs(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_enableFileService(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool enable);
[return: MarshalAs(UnmanagedType.I1)]
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern bool IedServerConfig_isFileServiceEnabled(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);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_enableLogService(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool enable);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
static extern bool IedServerConfig_isLogServiceEnabled(IntPtr self);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_enableResvTmsForBRCB(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool enable);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
static extern bool IedServerConfig_isResvTmsForBRCBEnabled(IntPtr self);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_enableOwnerForRCB(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool enable);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
static extern bool IedServerConfig_isOwnerForRCBEnabled(IntPtr self);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_useIntegratedGoosePublisher(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool enable);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I1)]
static extern bool IedServerConfig_getSyncIntegrityReportTimes(IntPtr self);
[DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)]
static extern void IedServerConfig_setSyncIntegrityReportTimes(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool enable);
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 size of the report buffer for unbuffered report control blocks
///
/// The size of the report buffer.
public int ReportBufferSizeForURCBs
{
get
{
return IedServerConfig_getReportBufferSizeForURCBs(self);
}
set
{
IedServerConfig_setReportBufferSizeForURCBs(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);
}
}
///
/// Enable/Disable file service for MMS
///
/// true if file service is enabled; otherwise, false.
public bool FileServiceEnabled
{
get
{
return IedServerConfig_isFileServiceEnabled(self);
}
set
{
IedServerConfig_enableFileService(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);
}
}
///
/// Enable/Disable log service for MMS
///
/// true if log service is enabled; otherwise, false.
public bool LogServiceEnabled
{
get
{
return IedServerConfig_isLogServiceEnabled(self);
}
set
{
IedServerConfig_enableLogService(self, value);
}
}
///
/// Enable/Disable the presence of ResvTms attribute in BRCBs (buffered report control blocks)
///
/// true if BRCB has ResvTms; otherwise, false. Defaults to true
public bool BRCBHasResvTms
{
get
{
return IedServerConfig_isResvTmsForBRCBEnabled(self);
}
set
{
IedServerConfig_enableResvTmsForBRCB(self, value);
}
}
///
/// Enable/Disable the presence of Owner attribute in RCBs (report control blocks)
///
/// true if RCB has Owner; otherwise, false. Defaults to false
public bool RCBHasOwner
{
get
{
return IedServerConfig_isOwnerForRCBEnabled(self);
}
set
{
IedServerConfig_enableOwnerForRCB(self, value);
}
}
///
/// Enable/disable using the integrated GOOSE publisher for configured GoCBs
///
/// true when integrated GOOSE publisher is used; otherwise, false. Defaults to true
public bool UseIntegratedGoosePublisher
{
set
{
IedServerConfig_useIntegratedGoosePublisher(self, value);
}
}
///
/// Enable/Disable synchoronized integrity report times (disabled by default)
///
///
/// When this flag is enabled the integrity report generation times are
/// aligned with the UTC epoch. Then the unix time stamps are straight multiples of the
/// integrity interval.
///
/// true if sync integrity report times; otherwise, false.
public bool SyncIntegrityReportTimes
{
get
{
return IedServerConfig_getSyncIntegrityReportTimes(self);
}
set
{
IedServerConfig_setSyncIntegrityReportTimes(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();
}
}
}