#region Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved //----------------------------------------------------------------------------- // Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved // Web: https://www.technosoftware.com // // The source code in this file is covered under a dual-license scenario: // - Owner of a purchased license: SCLA 1.0 // - GPL V3: everybody else // // SCLA license terms accompanied with this source code. // See SCLA 1.0: https://technosoftware.com/license/Source_Code_License_Agreement.pdf // // GNU General Public License as published by the Free Software Foundation; // version 3 of the License are accompanied with this source code. // See https://technosoftware.com/license/GPLv3License.txt // // This source code 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. //----------------------------------------------------------------------------- #endregion Copyright (c) 2011-2023 Technosoftware GmbH. All rights reserved #region Using Directives using System; #endregion namespace Technosoftware.DaAeHdaClient.Da { /// /// A subscription for a set of items on a single OPC server. /// public interface ITsCDaSubscription : IDisposable { #region Events /// /// An event to receive data change updates. /// event TsCDaDataChangedEventHandler DataChangedEvent; #endregion #region Result Filters /// /// Returns the filters applied by the server to any item results returned to the client. /// /// A bit mask indicating which fields should be returned in any item results. int GetResultFilters(); /// /// Sets the filters applied by the server to any item results returned to the client. /// /// A bit mask indicating which fields should be returned in any item results. void SetResultFilters(int filters); #endregion #region State Management /// /// Returns the current state of the subscription. /// /// The current state of the subscription. TsCDaSubscriptionState GetState(); /// /// Changes the state of a subscription. /// /// A bit mask that indicates which elements of the subscription state are changing. /// The new subscription state. /// The actual subscription state after applying the changes. TsCDaSubscriptionState ModifyState(int masks, TsCDaSubscriptionState state); #endregion #region Item Management /// /// Adds items to the subscription. /// /// The set of items to add to the subscription. /// The results of the add item operation for each item. TsCDaItemResult[] AddItems(TsCDaItem[] items); /// /// Modifies the state of items in the subscription /// /// Specifies which item state parameters are being modified. /// The new state for each item. /// The results of the modify item operation for each item. TsCDaItemResult[] ModifyItems(int masks, TsCDaItem[] items); /// /// Removes items from the subscription. /// /// The identifiers (i.e. server handles) for the items being removed. /// The results of the remove item operation for each item. OpcItemResult[] RemoveItems(OpcItem[] items); #endregion #region Synchronous I/O /// /// Reads the values for a set of items in the subscription. /// /// The identifiers (i.e. server handles) for the items being read. /// The value for each of items. TsCDaItemValueResult[] Read(TsCDaItem[] items); /// /// Writes the value, quality and timestamp for a set of items in the subscription. /// /// The item values to write. /// The results of the write operation for each item. OpcItemResult[] Write(TsCDaItemValue[] items); #endregion #region Asynchronous I/O /// /// Begins an asynchronous read operation for a set of items. /// /// The set of items to read (must include the item name). /// An identifier for the request assigned by the caller. /// A delegate used to receive notifications when the request completes. /// An object that contains the state of the request (used to cancel the request). /// A set of results containing any errors encountered when the server validated the items. OpcItemResult[] Read( TsCDaItem[] items, object requestHandle, TsCDaReadCompleteEventHandler callback, out IOpcRequest request); /// /// Begins an asynchronous write operation for a set of items. /// /// The set of item values to write (must include the item name). /// An identifier for the request assigned by the caller. /// A delegate used to receive notifications when the request completes. /// An object that contains the state of the request (used to cancel the request). /// A set of results containing any errors encountered when the server validated the items. OpcItemResult[] Write( TsCDaItemValue[] items, object requestHandle, TsCDaWriteCompleteEventHandler callback, out IOpcRequest request); /// /// Cancels an asynchronous read or write operation. /// /// The object returned from the BeginRead or BeginWrite request. /// The function to invoke when the cancel completes. void Cancel(IOpcRequest request, TsCDaCancelCompleteEventHandler callback); /// /// Causes the server to send a data changed notification for all active items. /// void Refresh(); /// /// Causes the server to send a data changed notification for all active items. /// /// An identifier for the request assigned by the caller. /// An object that contains the state of the request (used to cancel the request). /// A set of results containing any errors encountered when the server validated the items. void Refresh( object requestHandle, out IOpcRequest request); /// /// Enables or disables data change notifications from the server. /// /// Whether data change notifications are enabled. void SetEnabled(bool enabled); /// /// Checks whether data change notifications from the server are enabled. /// /// Whether data change notifications are enabled. bool GetEnabled(); #endregion } #region Delegate Declarations /// /// A delegate to receive data change updates from the server. /// /// /// A unique identifier for the subscription assigned by the client. If the parameter /// ClientHandle is not defined this /// parameter is empty. /// /// /// An identifier for the request assigned by the caller. This parameter is empty if /// the corresponding parameter in the calls Read(), Write() or Refresh() is not defined. /// Can be used to Cancel an outstanding operation. /// /// /// The set of changed values. /// Each value will always have /// item’s ClientHandle field specified. /// public delegate void TsCDaDataChangedEventHandler(object subscriptionHandle, object requestHandle, TsCDaItemValueResult[] values); /// /// A delegate to receive asynchronous read completed notifications. /// /// /// An identifier for the request assigned by the caller. This parameter is empty if /// the corresponding parameter in the calls Read(), Write() or Refresh() is not defined. /// Can be used to Cancel an outstanding operation. /// /// The results of the last asynchronous read operation. public delegate void TsCDaReadCompleteEventHandler(object requestHandle, TsCDaItemValueResult[] results); /// /// A delegate to receive asynchronous write completed notifications. /// /// /// An identifier for the request assigned by the caller. This parameter is empty if /// the corresponding parameter in the calls Read(), Write() or Refresh() is not defined. /// Can be used to Cancel an outstanding operation. /// /// The results of the last asynchronous write operation. public delegate void TsCDaWriteCompleteEventHandler(object requestHandle, OpcItemResult[] results); /// /// A delegate to receive asynchronous cancel completed notifications. /// /// An identifier for the request assigned by the caller. public delegate void TsCDaCancelCompleteEventHandler(object requestHandle); #endregion }