diff --git a/CHANGELOG b/CHANGELOG index 13238e79..3cd3a47a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,17 @@ +Changes to version 1.3.3 +------------------------ +- IEC 61850 server: optimized report buffer handling for buffered reporting (save memory and encoding time) +- IEC 61850 client: fixed problem - IedConnection cannot be reused after IedConnection_close (github #124) +- IEC 61850 server: added support for pre configured client with ClientLN +- IEC 61850 client: added function ClientReportControlBlock_hasResvTms +- IEC 61850 server: don't clear owner when client disables BRCB (RptEna = false) +- IED Server: added ResvTms handling for BRCB +- SV publisher: fixed length calculation +- IEC 61850 server: added support for segmented reporting +- fixed bug in windows socket abstraction +- fixed client TCP keep alive problem (see github #115) +- MMS server: read service - return data access error for component access to simple variable + Changes to version 1.3.2 ------------------------ - MMS client/server: added support for component alternate access for generic variable read requests diff --git a/dotnet/IEC61850forCSharp/ReportControlBlock.cs b/dotnet/IEC61850forCSharp/ReportControlBlock.cs index 1854480f..1169a6e2 100644 --- a/dotnet/IEC61850forCSharp/ReportControlBlock.cs +++ b/dotnet/IEC61850forCSharp/ReportControlBlock.cs @@ -28,18 +28,18 @@ using IEC61850.Common; namespace IEC61850 { - namespace Client - { + namespace Client + { /// /// Report handler. /// /// represents the received report. DON'T use this object /// outside the scope of the report handler! - public delegate void ReportHandler (Report report, object parameter); + public delegate void ReportHandler(Report report, object parameter); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - internal delegate void InternalReportHandler (IntPtr parameter, IntPtr report); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + internal delegate void InternalReportHandler(IntPtr parameter, IntPtr report); /// /// Report control block (RCB) representation. @@ -50,209 +50,218 @@ namespace IEC61850 /// Values at the server are only affected when the SetRCBValues method is called. /// public class ReportControlBlock : IDisposable - { - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern IntPtr ClientReportControlBlock_create (string dataAttributeReference); + { + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr ClientReportControlBlock_create(string dataAttributeReference); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern void ClientReportControlBlock_destroy (IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientReportControlBlock_destroy(IntPtr self); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] - static extern bool ClientReportControlBlock_isBuffered (IntPtr self); + static extern bool ClientReportControlBlock_isBuffered(IntPtr self); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern IntPtr ClientReportControlBlock_getRptId (IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr ClientReportControlBlock_getRptId(IntPtr self); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern void ClientReportControlBlock_setRptId (IntPtr self, string rptId); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientReportControlBlock_setRptId(IntPtr self, string rptId); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] - static extern bool ClientReportControlBlock_getRptEna (IntPtr self); + static extern bool ClientReportControlBlock_getRptEna(IntPtr self); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern void ClientReportControlBlock_setRptEna(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool rptEna); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientReportControlBlock_setRptEna(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool rptEna); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] - static extern bool ClientReportControlBlock_getResv (IntPtr self); + static extern bool ClientReportControlBlock_getResv(IntPtr self); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern void ClientReportControlBlock_setResv (IntPtr self, [MarshalAs(UnmanagedType.I1)] bool resv); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientReportControlBlock_setResv(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool resv); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern IntPtr ClientReportControlBlock_getDataSetReference (IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr ClientReportControlBlock_getDataSetReference(IntPtr self); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern void ClientReportControlBlock_setDataSetReference (IntPtr self, string dataSetReference); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientReportControlBlock_setDataSetReference(IntPtr self, string dataSetReference); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern UInt32 ClientReportControlBlock_getConfRev (IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern UInt32 ClientReportControlBlock_getConfRev(IntPtr self); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern int ClientReportControlBlock_getOptFlds (IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern int ClientReportControlBlock_getOptFlds(IntPtr self); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern void ClientReportControlBlock_setOptFlds (IntPtr self, int optFlds); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientReportControlBlock_setOptFlds(IntPtr self, int optFlds); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern UInt32 ClientReportControlBlock_getBufTm (IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern UInt32 ClientReportControlBlock_getBufTm(IntPtr self); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern void ClientReportControlBlock_setBufTm (IntPtr self, UInt32 bufTm); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientReportControlBlock_setBufTm(IntPtr self, UInt32 bufTm); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern UInt16 ClientReportControlBlock_getSqNum (IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern UInt16 ClientReportControlBlock_getSqNum(IntPtr self); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern int ClientReportControlBlock_getTrgOps (IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern int ClientReportControlBlock_getTrgOps(IntPtr self); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern void ClientReportControlBlock_setTrgOps (IntPtr self, int trgOps); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientReportControlBlock_setTrgOps(IntPtr self, int trgOps); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern UInt32 ClientReportControlBlock_getIntgPd (IntPtr self); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern UInt32 ClientReportControlBlock_getIntgPd(IntPtr self); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern void ClientReportControlBlock_setIntgPd (IntPtr self, UInt32 intgPd); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientReportControlBlock_setIntgPd(IntPtr self, UInt32 intgPd); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] - static extern bool ClientReportControlBlock_getGI (IntPtr self); + static extern bool ClientReportControlBlock_getGI(IntPtr self); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern void ClientReportControlBlock_setGI (IntPtr self, [MarshalAs(UnmanagedType.I1)] bool gi); + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientReportControlBlock_setGI(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool gi); - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] [return: MarshalAs(UnmanagedType.I1)] - static extern bool ClientReportControlBlock_getPurgeBuf (IntPtr self); - - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern void ClientReportControlBlock_setPurgeBuf (IntPtr self, [MarshalAs(UnmanagedType.I1)] bool purgeBuf); - - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern Int16 ClientReportControlBlock_getResvTms (IntPtr self); - - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern void ClientReportControlBlock_setResvTms (IntPtr self, Int16 resvTms); - - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern IntPtr ClientReportControlBlock_getEntryId (IntPtr self); - - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern void ClientReportControlBlock_setEntryId (IntPtr self, IntPtr entryId); - - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern UInt64 ClientReportControlBlock_getEntryTime (IntPtr self); - - [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] - static extern IntPtr ClientReportControlBlock_getOwner (IntPtr self); - - private IntPtr self; - private IedConnection iedConnection = null; - private string objectReference; - private bool flagRptId = false; - private bool flagRptEna = false; - private bool flagResv = false; - private bool flagDataSetReference = false; - private bool flagConfRev = false; - private bool flagOptFlds = false; - private bool flagBufTm = false; - private bool flagSqNum = false; - private bool flagTrgOps = false; - private bool flagIntgPd = false; - private bool flagGI = false; - private bool flagPurgeBuf = false; - private bool flagResvTms = false; - private bool flagEntryId = false; - - private event ReportHandler reportHandler = null; - private object reportHandlerParameter; - private bool reportHandlerInstalled = false; + static extern bool ClientReportControlBlock_getPurgeBuf(IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientReportControlBlock_setPurgeBuf(IntPtr self, [MarshalAs(UnmanagedType.I1)] bool purgeBuf); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + [return: MarshalAs(UnmanagedType.I1)] + static extern bool ClientReportControlBlock_hasResvTms(IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern Int16 ClientReportControlBlock_getResvTms(IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientReportControlBlock_setResvTms(IntPtr self, Int16 resvTms); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr ClientReportControlBlock_getEntryId(IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern void ClientReportControlBlock_setEntryId(IntPtr self, IntPtr entryId); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern UInt64 ClientReportControlBlock_getEntryTime(IntPtr self); + + [DllImport("iec61850", CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr ClientReportControlBlock_getOwner(IntPtr self); + + private IntPtr self; + private IedConnection iedConnection = null; + private string objectReference; + private bool flagRptId = false; + private bool flagRptEna = false; + private bool flagResv = false; + private bool flagDataSetReference = false; + private bool flagConfRev = false; + private bool flagOptFlds = false; + private bool flagBufTm = false; + private bool flagSqNum = false; + private bool flagTrgOps = false; + private bool flagIntgPd = false; + private bool flagGI = false; + private bool flagPurgeBuf = false; + private bool flagResvTms = false; + private bool flagEntryId = false; + + private event ReportHandler reportHandler = null; + private object reportHandlerParameter; + private bool reportHandlerInstalled = false; private event InternalReportHandler internalHandler = null; - private void resetSendFlags () - { - flagRptId = false; - flagRptEna = false; - flagResv = false; - flagDataSetReference = false; - flagConfRev = false; - flagOptFlds = false; - flagBufTm = false; - flagSqNum = false; - flagTrgOps = false; - flagIntgPd = false; - flagGI = false; - flagPurgeBuf = false; - flagResvTms = false; - flagEntryId = false; - } - - private Report report = null; - - private void internalReportHandler (IntPtr parameter, IntPtr report) - { - try { - - if (this.report == null) - this.report = new Report (report); - - if (reportHandler != null) - reportHandler(this.report, reportHandlerParameter); - - } catch (Exception e) - { - // older versions of mono 2.10 (for linux?) cause this exception - Console.WriteLine(e.Message); - } - } - - internal ReportControlBlock (string objectReference, IedConnection iedConnection, IntPtr connection) - { - self = ClientReportControlBlock_create (objectReference); - - if (self != IntPtr.Zero) { - this.iedConnection = iedConnection; - this.objectReference = objectReference; - } - } - - /// - /// 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) { - - iedConnection.UninstallReportHandler (objectReference); - - iedConnection.RemoveRCB (this); - - ClientReportControlBlock_destroy (self); - - self = IntPtr.Zero; - } - } - } - - ~ReportControlBlock() - { - Dispose (); - } - - public string GetObjectReference () - { - return this.objectReference; - } - + private void resetSendFlags() + { + flagRptId = false; + flagRptEna = false; + flagResv = false; + flagDataSetReference = false; + flagConfRev = false; + flagOptFlds = false; + flagBufTm = false; + flagSqNum = false; + flagTrgOps = false; + flagIntgPd = false; + flagGI = false; + flagPurgeBuf = false; + flagResvTms = false; + flagEntryId = false; + } + + private Report report = null; + + private void internalReportHandler(IntPtr parameter, IntPtr report) + { + try + { + + if (this.report == null) + this.report = new Report(report); + + if (reportHandler != null) + reportHandler(this.report, reportHandlerParameter); + + } + catch (Exception e) + { + // older versions of mono 2.10 (for linux?) cause this exception + Console.WriteLine(e.Message); + } + } + + internal ReportControlBlock(string objectReference, IedConnection iedConnection, IntPtr connection) + { + self = ClientReportControlBlock_create(objectReference); + + if (self != IntPtr.Zero) + { + this.iedConnection = iedConnection; + this.objectReference = objectReference; + } + } + + /// + /// 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) + { + + iedConnection.UninstallReportHandler(objectReference); + + iedConnection.RemoveRCB(this); + + ClientReportControlBlock_destroy(self); + + self = IntPtr.Zero; + } + } + } + + ~ReportControlBlock() + { + Dispose(); + } + + public string GetObjectReference() + { + return this.objectReference; + } + /// /// Installs the report handler. /// @@ -267,40 +276,41 @@ namespace IEC61850 /// /// parameter is passed to the handler when the handler is invoked. /// - public void InstallReportHandler (ReportHandler reportHandler, object parameter) - { - this.reportHandler = new ReportHandler(reportHandler); + public void InstallReportHandler(ReportHandler reportHandler, object parameter) + { + this.reportHandler = new ReportHandler(reportHandler); - this.reportHandlerParameter = parameter; + this.reportHandlerParameter = parameter; - if (reportHandlerInstalled == false) { + if (reportHandlerInstalled == false) + { - string reportId = this.GetRptId (); + string reportId = this.GetRptId(); if (internalHandler == null) { - internalHandler = new InternalReportHandler(internalReportHandler); + internalHandler = new InternalReportHandler(internalReportHandler); } - - iedConnection.InstallReportHandler (objectReference, reportId, internalHandler); - reportHandlerInstalled = true; - } - } + iedConnection.InstallReportHandler(objectReference, reportId, internalHandler); + + reportHandlerInstalled = true; + } + } /// /// Read all RCB values from the server /// /// This exception is thrown if there is a connection or service error - public void GetRCBValues () - { - int error; + public void GetRCBValues() + { + int error; - iedConnection.GetRCBValues (out error, objectReference, self); + iedConnection.GetRCBValues(out error, objectReference, self); - if (error != 0) - throw new IedConnectionException ("getRCBValues service failed", error); - } + if (error != 0) + throw new IedConnectionException("getRCBValues service failed", error); + } /// /// Write changed RCB values to the server. @@ -310,10 +320,10 @@ namespace IEC61850 /// The RCB values are sent by a single MMS write request. /// /// This exception is thrown if there is a connection or service error - public void SetRCBValues () - { - SetRCBValues (true); - } + public void SetRCBValues() + { + SetRCBValues(true); + } /// /// Write changed RCB values to the server. @@ -325,7 +335,7 @@ namespace IEC61850 /// /// If true the values are sent by single MMS write request. Otherwise the values are all sent by their own MMS write requests. /// - public void SetRCBValues (bool singleRequest) + public void SetRCBValues(bool singleRequest) { UInt32 parametersMask = 0; @@ -373,21 +383,23 @@ namespace IEC61850 int error; - iedConnection.SetRCBValues (out error, self, parametersMask, singleRequest); + iedConnection.SetRCBValues(out error, self, parametersMask, singleRequest); - resetSendFlags(); + resetSendFlags(); if (error != 0) - throw new IedConnectionException ("setRCBValues service failed", error); + throw new IedConnectionException("setRCBValues service failed", error); - if (flagRptId) { + if (flagRptId) + { - if (reportHandlerInstalled) { + if (reportHandlerInstalled) + { reportHandlerInstalled = false; InstallReportHandler(this.reportHandler, this.reportHandlerParameter); } } - } + } /// /// Determines whether this instance is a buffered or unbuffered RCB. @@ -395,10 +407,10 @@ namespace IEC61850 /// /// true if this instance is a buffered RCB; otherwise, false. /// - public bool IsBuffered () - { - return ClientReportControlBlock_isBuffered (self); - } + public bool IsBuffered() + { + return ClientReportControlBlock_isBuffered(self); + } /// /// Gets the entry time of the RCB as ms time @@ -409,10 +421,10 @@ namespace IEC61850 /// /// The entry time as ms timestamp /// - public UInt64 GetEntryTime () - { - return ClientReportControlBlock_getEntryTime (self); - } + public UInt64 GetEntryTime() + { + return ClientReportControlBlock_getEntryTime(self); + } /// /// Gets the entry time of the RCB as DateTimeOffset @@ -423,49 +435,50 @@ namespace IEC61850 /// /// The entry time as DataTimeOffset /// - public DateTimeOffset GetEntryTimeAsDateTimeOffset () - { - UInt64 entryTime = GetEntryTime (); + public DateTimeOffset GetEntryTimeAsDateTimeOffset() + { + UInt64 entryTime = GetEntryTime(); - DateTimeOffset retVal = new DateTimeOffset (1970, 1, 1, 0, 0, 0, TimeSpan.Zero); + DateTimeOffset retVal = new DateTimeOffset(1970, 1, 1, 0, 0, 0, TimeSpan.Zero); - return retVal.AddMilliseconds (entryTime); - } + return retVal.AddMilliseconds(entryTime); + } - /// - /// Gets the entryID of RCB - /// - /// Returns the EntryID of the last received GetRCBValues service response. - /// The EntryID is only present in buffered RCBs (BRCBs). - /// - /// The entry ID - public byte[] GetEntryID() - { - IntPtr entryIdRef = ClientReportControlBlock_getEntryId (self); + /// + /// Gets the entryID of RCB + /// + /// Returns the EntryID of the last received GetRCBValues service response. + /// The EntryID is only present in buffered RCBs (BRCBs). + /// + /// The entry ID + public byte[] GetEntryID() + { + IntPtr entryIdRef = ClientReportControlBlock_getEntryId(self); - if (entryIdRef == IntPtr.Zero) - return null; - else { - MmsValue entryId = new MmsValue (entryIdRef); + if (entryIdRef == IntPtr.Zero) + return null; + else + { + MmsValue entryId = new MmsValue(entryIdRef); - return entryId.getOctetString (); - } - } + return entryId.getOctetString(); + } + } - public void SetEntryID(byte[] entryId) - { - flagEntryId = true; + public void SetEntryID(byte[] entryId) + { + flagEntryId = true; - MmsValue entryID = MmsValue.NewOctetString (entryId.Length); + MmsValue entryID = MmsValue.NewOctetString(entryId.Length); - entryID.setOctetString (entryId); + entryID.setOctetString(entryId); - ClientReportControlBlock_setEntryId (self, entryID.valueReference); + ClientReportControlBlock_setEntryId(self, entryID.valueReference); - } + } /// @@ -474,12 +487,12 @@ namespace IEC61850 /// /// The data set reference. /// - public string GetDataSetReference () - { - IntPtr dataSetRefPtr = ClientReportControlBlock_getDataSetReference (self); + public string GetDataSetReference() + { + IntPtr dataSetRefPtr = ClientReportControlBlock_getDataSetReference(self); - return Marshal.PtrToStringAnsi (dataSetRefPtr); - } + return Marshal.PtrToStringAnsi(dataSetRefPtr); + } /// /// Sets the data set reference. Use this method to select the associated data set for the RCB @@ -487,12 +500,12 @@ namespace IEC61850 /// /// The data set reference. /// - public void SetDataSetReference (string dataSetReference) - { - ClientReportControlBlock_setDataSetReference (self, dataSetReference); + public void SetDataSetReference(string dataSetReference) + { + ClientReportControlBlock_setDataSetReference(self, dataSetReference); - flagDataSetReference = true; - } + flagDataSetReference = true; + } /// /// Gets the report identifier. @@ -500,12 +513,12 @@ namespace IEC61850 /// /// The report identifier. /// - public string GetRptId () - { - IntPtr rptIdPtr = ClientReportControlBlock_getRptId (self); + public string GetRptId() + { + IntPtr rptIdPtr = ClientReportControlBlock_getRptId(self); - return Marshal.PtrToStringAnsi (rptIdPtr); - } + return Marshal.PtrToStringAnsi(rptIdPtr); + } /// /// Sets the RptId (report ID) of the RCB @@ -513,7 +526,7 @@ namespace IEC61850 /// /// The new RptId /// - public void SetRptId (string rptId) + public void SetRptId(string rptId) { ClientReportControlBlock_setRptId(self, rptId); flagRptId = true; @@ -525,10 +538,10 @@ namespace IEC61850 /// /// true, if reporting is enabled, false otherwise /// - public bool GetRptEna () - { - return ClientReportControlBlock_getRptEna (self); - } + public bool GetRptEna() + { + return ClientReportControlBlock_getRptEna(self); + } /// /// Sets report enable flag. Use this to enable reporting @@ -536,17 +549,17 @@ namespace IEC61850 /// /// true to enable reporting, false to disable /// - public void SetRptEna (bool rptEna) - { - ClientReportControlBlock_setRptEna (self, rptEna); - flagRptEna = true; - } + public void SetRptEna(bool rptEna) + { + ClientReportControlBlock_setRptEna(self, rptEna); + flagRptEna = true; + } /// /// Get the purgeBuf flag of the report control block /// /// the prugeBuf value - public bool GetPurgeBuf () + public bool GetPurgeBuf() { return ClientReportControlBlock_getPurgeBuf(self); } @@ -556,7 +569,7 @@ namespace IEC61850 /// /// This is only for buffered RCBs. If set to true the report buffer of a buffered RCB will be cleaned. /// set to true to flush report buffer - public void SetPurgeBuf (bool purgeBuf) + public void SetPurgeBuf(bool purgeBuf) { ClientReportControlBlock_setPurgeBuf(self, purgeBuf); flagPurgeBuf = true; @@ -568,10 +581,10 @@ namespace IEC61850 /// /// The buffer time in ms. /// - public UInt32 GetBufTm() - { - return ClientReportControlBlock_getBufTm (self); - } + public UInt32 GetBufTm() + { + return ClientReportControlBlock_getBufTm(self); + } /// /// Sets the buffer time. @@ -579,12 +592,12 @@ namespace IEC61850 /// /// Buffer time is ms. /// - public void SetBufTm (UInt32 bufTm) - { - ClientReportControlBlock_setBufTm (self, bufTm); + public void SetBufTm(UInt32 bufTm) + { + ClientReportControlBlock_setBufTm(self, bufTm); - flagBufTm = true; - } + flagBufTm = true; + } /// /// Gets the GI flag @@ -592,10 +605,10 @@ namespace IEC61850 /// /// true, if GI flag is set /// - public bool GetGI () - { - return ClientReportControlBlock_getGI (self); - } + public bool GetGI() + { + return ClientReportControlBlock_getGI(self); + } /// /// Sets the GI flag. Use this to trigger a GI (general interrogation) command. @@ -603,11 +616,11 @@ namespace IEC61850 /// /// request general interrogation of true /// - public void SetGI (bool GI) - { - ClientReportControlBlock_setGI (self, GI); - flagGI = true; - } + public void SetGI(bool GI) + { + ClientReportControlBlock_setGI(self, GI); + flagGI = true; + } /// /// Check if RCB is reserved by a client @@ -615,10 +628,10 @@ namespace IEC61850 /// /// true, the RCB is reserver by a client /// - public bool GetResv () - { - return ClientReportControlBlock_getResv (self); - } + public bool GetResv() + { + return ClientReportControlBlock_getResv(self); + } /// /// Gets the configuration revision of the RCB @@ -626,9 +639,9 @@ namespace IEC61850 /// /// The conf rev. /// - public UInt32 GetConfRev () + public UInt32 GetConfRev() { - return ClientReportControlBlock_getConfRev (self); + return ClientReportControlBlock_getConfRev(self); } /// @@ -637,11 +650,11 @@ namespace IEC61850 /// /// true: reserver this RCB for exclusive use /// - public void SetResv (bool resv) - { - ClientReportControlBlock_setResv (self, resv); - flagResv = true; - } + public void SetResv(bool resv) + { + ClientReportControlBlock_setResv(self, resv); + flagResv = true; + } /// /// Gets the trigger options of the RCB @@ -650,9 +663,9 @@ namespace IEC61850 /// trigger options /// public TriggerOptions GetTrgOps() - { - return (TriggerOptions) ClientReportControlBlock_getTrgOps (self); - } + { + return (TriggerOptions)ClientReportControlBlock_getTrgOps(self); + } /// /// Sets the trigger options of the RCB. @@ -661,11 +674,11 @@ namespace IEC61850 /// trigger options /// public void SetTrgOps(TriggerOptions trgOps) - { - ClientReportControlBlock_setTrgOps (self, (int) trgOps); + { + ClientReportControlBlock_setTrgOps(self, (int)trgOps); - flagTrgOps = true; - } + flagTrgOps = true; + } /// /// Gets the integrity period @@ -673,10 +686,10 @@ namespace IEC61850 /// /// integrity period in ms /// - public UInt32 GetIntgPd () - { - return ClientReportControlBlock_getIntgPd (self); - } + public UInt32 GetIntgPd() + { + return ClientReportControlBlock_getIntgPd(self); + } /// /// Sets the integrity period @@ -684,11 +697,11 @@ namespace IEC61850 /// /// integrity period in ms /// - public void SetIntgPd (UInt32 intgPd) - { - ClientReportControlBlock_setIntgPd (self, intgPd); - flagIntgPd = true; - } + public void SetIntgPd(UInt32 intgPd) + { + ClientReportControlBlock_setIntgPd(self, intgPd); + flagIntgPd = true; + } /// /// Gets the option fields. @@ -697,9 +710,9 @@ namespace IEC61850 /// The option fields /// public ReportOptions GetOptFlds() - { - return (ReportOptions) ClientReportControlBlock_getOptFlds (self); - } + { + return (ReportOptions)ClientReportControlBlock_getOptFlds(self); + } /// /// Sets the option field. Used to enable or disable optional report elements @@ -708,38 +721,47 @@ namespace IEC61850 /// Option field. /// public void SetOptFlds(ReportOptions optFlds) - { - ClientReportControlBlock_setOptFlds (self, (int)optFlds); - - flagOptFlds = true; - } - - /// - /// Gets the ResvTms (reservation time) value - /// - /// - /// Only for BRCB. - /// Value of -1 indicate the BRCB is exclusively reserved for a set of client based upon configuration. - /// Value of 0 means that the BRCB is not reserved. - /// Positive value indicates that the BRCB is reserved dynamically and the value is the number of - /// seconds for reservation after association loss. - /// - /// The reservation time - public Int16 GetResvTms() - { - return ClientReportControlBlock_getResvTms (self); - } - - /// - /// Sets the ResvTms (reservation time) value - /// - /// the reservation time value - public void SetResvTms(Int16 resvTms) - { - ClientReportControlBlock_setResvTms (self, resvTms); - - flagResvTms = true; - } + { + ClientReportControlBlock_setOptFlds(self, (int)optFlds); + + flagOptFlds = true; + } + + /// + /// Check if the report control block has the "ResvTms" attribute. + /// + /// true, if ResvTms is available, false otherwise. + public bool HasResvTms() + { + return ClientReportControlBlock_hasResvTms(self); + } + + /// + /// Gets the ResvTms (reservation time) value + /// + /// + /// Only for BRCB. + /// Value of -1 indicate the BRCB is exclusively reserved for a set of client based upon configuration. + /// Value of 0 means that the BRCB is not reserved. + /// Positive value indicates that the BRCB is reserved dynamically and the value is the number of + /// seconds for reservation after association loss. + /// + /// The reservation time + public Int16 GetResvTms() + { + return ClientReportControlBlock_getResvTms(self); + } + + /// + /// Sets the ResvTms (reservation time) value + /// + /// the reservation time value + public void SetResvTms(Int16 resvTms) + { + ClientReportControlBlock_setResvTms(self, resvTms); + + flagResvTms = true; + } /// /// Gets the current owner of the RCB @@ -758,7 +780,6 @@ namespace IEC61850 else return null; } - } - - } + } + } }