mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-24 02:58:36 +08:00
255 lines
9.9 KiB
C#
255 lines
9.9 KiB
C#
/* ========================================================================
|
|
* Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved.
|
|
*
|
|
* OPC Foundation MIT License 1.00
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person
|
|
* obtaining a copy of this software and associated documentation
|
|
* files (the "Software"), to deal in the Software without
|
|
* restriction, including without limitation the rights to use,
|
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the
|
|
* Software is furnished to do so, subject to the following
|
|
* conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be
|
|
* included in all copies or substantial portions of the Software.
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
* The complete license agreement can be found here:
|
|
* http://opcfoundation.org/License/MIT/1.00/
|
|
* ======================================================================*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Opc.Ua.Server
|
|
{
|
|
/// <summary>
|
|
/// Provides access to the subscription manager within the server.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Sinks that receive these events must not block the thread.
|
|
/// </remarks>
|
|
public interface ISubscriptionManager : IDisposable
|
|
{
|
|
/// <summary>
|
|
/// Raised after a new subscription is created.
|
|
/// </summary>
|
|
event SubscriptionEventHandler SubscriptionCreated;
|
|
|
|
/// <summary>
|
|
/// Raised before a subscription is deleted.
|
|
/// </summary>
|
|
event SubscriptionEventHandler SubscriptionDeleted;
|
|
|
|
/// <summary>
|
|
/// Returns all of the subscriptions known to the subscription manager.
|
|
/// </summary>
|
|
/// <returns>A list of the subscriptions.</returns>
|
|
IList<ISubscription> GetSubscriptions();
|
|
|
|
/// <summary>
|
|
/// Get the subscription with the specified id
|
|
/// </summary>
|
|
/// <param name="id">The id of the subscription</param>
|
|
/// <param name="subscription">The subscription if found else null</param>
|
|
/// <returns>True if found</returns>
|
|
bool TryGetSubscription(uint id, [NotNullWhen(true)] out ISubscription? subscription);
|
|
|
|
/// <summary>
|
|
/// Set a subscription into durable mode
|
|
/// </summary>
|
|
ServiceResult SetSubscriptionDurable(
|
|
ISystemContext context,
|
|
uint subscriptionId,
|
|
uint lifetimeInHours,
|
|
out uint revisedLifetimeInHours);
|
|
|
|
/// <summary>
|
|
/// Creates a new subscription.
|
|
/// </summary>
|
|
ValueTask<CreateSubscriptionResponse> CreateSubscriptionAsync(
|
|
OperationContext context,
|
|
double requestedPublishingInterval,
|
|
uint requestedLifetimeCount,
|
|
uint requestedMaxKeepAliveCount,
|
|
uint maxNotificationsPerPublish,
|
|
bool publishingEnabled,
|
|
byte priority,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Starts up the manager makes it ready to create subscriptions.
|
|
/// </summary>
|
|
ValueTask StartupAsync(CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Closes all subscriptions and rejects any new requests.
|
|
/// </summary>
|
|
ValueTask ShutdownAsync(CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Stores durable subscriptions to be able to restore them after a restart
|
|
/// </summary>
|
|
ValueTask StoreSubscriptionsAsync(CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Restore durable subscriptions after a server restart
|
|
/// </summary>
|
|
ValueTask RestoreSubscriptionsAsync(CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Deletes group of subscriptions.
|
|
/// </summary>
|
|
ValueTask<DeleteSubscriptionsResponse> DeleteSubscriptionsAsync(
|
|
OperationContext context,
|
|
ArrayOf<uint> subscriptionIds,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Publishes a subscription.
|
|
/// </summary>
|
|
Task<PublishResponse> PublishAsync(
|
|
OperationContext context,
|
|
ArrayOf<SubscriptionAcknowledgement> subscriptionAcknowledgements,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Modifies an existing subscription.
|
|
/// </summary>
|
|
void ModifySubscription(
|
|
OperationContext context,
|
|
uint subscriptionId,
|
|
double requestedPublishingInterval,
|
|
uint requestedLifetimeCount,
|
|
uint requestedMaxKeepAliveCount,
|
|
uint maxNotificationsPerPublish,
|
|
byte priority,
|
|
out double revisedPublishingInterval,
|
|
out uint revisedLifetimeCount,
|
|
out uint revisedMaxKeepAliveCount);
|
|
|
|
/// <summary>
|
|
/// Sets the publishing mode for a set of subscriptions.
|
|
/// </summary>
|
|
void SetPublishingMode(
|
|
OperationContext context,
|
|
bool publishingEnabled,
|
|
ArrayOf<uint> subscriptionIds,
|
|
out ArrayOf<StatusCode> results,
|
|
out ArrayOf<DiagnosticInfo> diagnosticInfos);
|
|
|
|
/// <summary>
|
|
/// Attaches a groups of subscriptions to a different session.
|
|
/// </summary>
|
|
ValueTask<TransferSubscriptionsResponse> TransferSubscriptionsAsync(
|
|
OperationContext context,
|
|
ArrayOf<uint> subscriptionIds,
|
|
bool sendInitialValues,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Republishes a previously published notification message.
|
|
/// </summary>
|
|
NotificationMessage Republish(
|
|
OperationContext context,
|
|
uint subscriptionId,
|
|
uint retransmitSequenceNumber);
|
|
|
|
/// <summary>
|
|
/// Updates the triggers for the monitored item.
|
|
/// </summary>
|
|
void SetTriggering(
|
|
OperationContext context,
|
|
uint subscriptionId,
|
|
uint triggeringItemId,
|
|
ArrayOf<uint> linksToAdd,
|
|
ArrayOf<uint> linksToRemove,
|
|
out ArrayOf<StatusCode> addResults,
|
|
out ArrayOf<DiagnosticInfo> addDiagnosticInfos,
|
|
out ArrayOf<StatusCode> removeResults,
|
|
out ArrayOf<DiagnosticInfo> removeDiagnosticInfos);
|
|
|
|
/// <summary>
|
|
/// Adds monitored items to a subscription.
|
|
/// </summary>
|
|
ValueTask<CreateMonitoredItemsResponse> CreateMonitoredItemsAsync(
|
|
OperationContext context,
|
|
uint subscriptionId,
|
|
TimestampsToReturn timestampsToReturn,
|
|
ArrayOf<MonitoredItemCreateRequest> itemsToCreate,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Modifies monitored items in a subscription.
|
|
/// </summary>
|
|
ValueTask<ModifyMonitoredItemsResponse> ModifyMonitoredItemsAsync(
|
|
OperationContext context,
|
|
uint subscriptionId,
|
|
TimestampsToReturn timestampsToReturn,
|
|
ArrayOf<MonitoredItemModifyRequest> itemsToModify,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Deletes the monitored items in a subscription.
|
|
/// </summary>
|
|
ValueTask<DeleteMonitoredItemsResponse> DeleteMonitoredItemsAsync(
|
|
OperationContext context,
|
|
uint subscriptionId,
|
|
ArrayOf<uint> monitoredItemIds,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Changes the monitoring mode for a set of items.
|
|
/// </summary>
|
|
ValueTask<(ArrayOf<StatusCode> results, ArrayOf<DiagnosticInfo> diagnosticInfos)> SetMonitoringModeAsync(
|
|
OperationContext context,
|
|
uint subscriptionId,
|
|
MonitoringMode monitoringMode,
|
|
ArrayOf<uint> monitoredItemIds,
|
|
CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Signals that a session is closing.
|
|
/// </summary>
|
|
ValueTask SessionClosingAsync(
|
|
OperationContext context,
|
|
NodeId sessionId,
|
|
bool deleteSubscriptions,
|
|
CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Deletes the specified subscription.
|
|
/// </summary>
|
|
ValueTask<StatusCode> DeleteSubscriptionAsync(OperationContext context, uint subscriptionId, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// Refreshes the conditions for the specified subscription.
|
|
/// </summary>
|
|
void ConditionRefresh(OperationContext context, uint subscriptionId);
|
|
|
|
/// <summary>
|
|
/// Refreshes the conditions for the specified subscription and monitored item.
|
|
/// </summary>
|
|
void ConditionRefresh2(OperationContext context, uint subscriptionId, uint monitoredItemId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The delegate for functions used to receive subscription related events.
|
|
/// </summary>
|
|
/// <param name="subscription">The subscription that was affected.</param>
|
|
/// <param name="deleted">True if the subscription was deleted.</param>
|
|
public delegate void SubscriptionEventHandler(ISubscription subscription, bool deleted);
|
|
}
|