mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-28 22:55:49 +08:00
[Server] Extend ISubscription Interface (#3100)
This commit is contained in:
@@ -258,7 +258,7 @@ namespace Opc.Ua.Server
|
||||
uint[] serverHandles = null;
|
||||
uint[] clientHandles = null;
|
||||
|
||||
foreach (Subscription subscription in Server.SubscriptionManager.GetSubscriptions())
|
||||
foreach (ISubscription subscription in Server.SubscriptionManager.GetSubscriptions())
|
||||
{
|
||||
if (subscription.Id == subscriptionId)
|
||||
{
|
||||
@@ -301,7 +301,7 @@ namespace Opc.Ua.Server
|
||||
return StatusCodes.BadInvalidArgument;
|
||||
}
|
||||
|
||||
foreach (Subscription subscription in Server.SubscriptionManager.GetSubscriptions())
|
||||
foreach (ISubscription subscription in Server.SubscriptionManager.GetSubscriptions())
|
||||
{
|
||||
if (subscription.Id == subscriptionId)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
/* ========================================================================
|
||||
* Copyright (c) 2005-2020 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;
|
||||
|
||||
namespace Opc.Ua.Server
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface used by the monitored items to signal the subscription.
|
||||
/// </summary>
|
||||
public interface ISubscription : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// The session that owns the monitored item.
|
||||
/// </summary>
|
||||
Session Session { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The subscriptions owner identity.
|
||||
/// </summary>
|
||||
IUserIdentity EffectiveIdentity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The identifier for the item that is unique within the server.
|
||||
/// </summary>
|
||||
uint Id { get; }
|
||||
/// <summary>
|
||||
/// The identifier for the session that owns the subscription.
|
||||
/// </summary>
|
||||
NodeId SessionId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The number of monitored items.
|
||||
/// </summary>
|
||||
int MonitoredItemCount { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The priority assigned to the subscription.
|
||||
/// </summary>
|
||||
byte Priority { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The publishing rate for the subscription.
|
||||
/// </summary>
|
||||
double PublishingInterval { get; }
|
||||
|
||||
/// <summary>
|
||||
/// True if the subscription is set to durable and supports long lifetime and queue size
|
||||
/// </summary>
|
||||
bool IsDurable { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lock that must be acquired before accessing the contents of the Diagnostics property.
|
||||
/// </summary>
|
||||
object DiagnosticsLock { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the lock that must be acquired before updating the contents of the Diagnostics property.
|
||||
/// </summary>
|
||||
object DiagnosticsWriteLock { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current diagnostics for the subscription.
|
||||
/// </summary>
|
||||
public SubscriptionDiagnosticsDataType Diagnostics { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Called when a monitored item is ready to publish.
|
||||
/// </summary>
|
||||
void ItemReadyToPublish(IMonitoredItem monitoredItem);
|
||||
|
||||
/// <summary>
|
||||
/// Called when a monitored item is ready to publish.
|
||||
/// </summary>
|
||||
void ItemNotificationsAvailable(IMonitoredItem monitoredItem);
|
||||
|
||||
/// <summary>
|
||||
/// Called when a value of monitored item is discarded in the monitoring queue.
|
||||
/// </summary>
|
||||
void QueueOverflowHandler();
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the subscription is ready to publish.
|
||||
/// </summary>
|
||||
PublishingState PublishTimerExpired();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the available sequence numbers for retransmission
|
||||
/// For example used in Transfer Subscription
|
||||
/// </summary>
|
||||
public UInt32Collection AvailableSequenceNumbersForRetransmission();
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the conditions.
|
||||
/// </summary>
|
||||
void ConditionRefresh2(uint monitoredItemId);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the conditions.
|
||||
/// </summary>
|
||||
void ConditionRefresh();
|
||||
|
||||
/// <summary>
|
||||
/// Updates the publishing parameters for the subscription.
|
||||
/// </summary>
|
||||
void Modify(
|
||||
OperationContext context,
|
||||
double publishingInterval,
|
||||
uint maxLifetimeCount,
|
||||
uint maxKeepAliveCount,
|
||||
uint maxNotificationsPerPublish,
|
||||
byte priority);
|
||||
|
||||
/// <summary>
|
||||
/// Changes the monitoring mode for a set of items.
|
||||
/// </summary>
|
||||
void SetMonitoringMode(
|
||||
OperationContext context,
|
||||
MonitoringMode monitoringMode,
|
||||
UInt32Collection monitoredItemIds,
|
||||
out StatusCodeCollection results,
|
||||
out DiagnosticInfoCollection diagnosticInfos);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Enables/disables publishing for the subscription.
|
||||
/// </summary>
|
||||
void SetPublishingMode(
|
||||
OperationContext context,
|
||||
bool publishingEnabled);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the monitored items in a subscription.
|
||||
/// </summary>
|
||||
void DeleteMonitoredItems(
|
||||
OperationContext context,
|
||||
UInt32Collection monitoredItemIds,
|
||||
out StatusCodeCollection results,
|
||||
out DiagnosticInfoCollection diagnosticInfos);
|
||||
|
||||
/// <summary>
|
||||
/// Modifies monitored items in a subscription.
|
||||
/// </summary>
|
||||
void ModifyMonitoredItems(
|
||||
OperationContext context,
|
||||
TimestampsToReturn timestampsToReturn,
|
||||
MonitoredItemModifyRequestCollection itemsToModify,
|
||||
out MonitoredItemModifyResultCollection results,
|
||||
out DiagnosticInfoCollection diagnosticInfos);
|
||||
|
||||
/// <summary>
|
||||
/// Adds monitored items to a subscription.
|
||||
/// </summary>
|
||||
void CreateMonitoredItems(
|
||||
OperationContext context,
|
||||
TimestampsToReturn timestampsToReturn,
|
||||
MonitoredItemCreateRequestCollection itemsToCreate,
|
||||
out MonitoredItemCreateResultCollection results,
|
||||
out DiagnosticInfoCollection diagnosticInfos);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the monitored items for the subscription.
|
||||
/// </summary>
|
||||
void GetMonitoredItems(out uint[] serverHandles, out uint[] clientHandles);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the subscription to durable mode.
|
||||
/// </summary>
|
||||
public ServiceResult SetSubscriptionDurable(uint maxLifetimeCount);
|
||||
|
||||
/// <summary>
|
||||
/// Initiates resending of all data monitored items in a Subscription
|
||||
/// </summary>
|
||||
void ResendData(OperationContext context);
|
||||
|
||||
/// <summary>
|
||||
/// Tells the subscription that the owning session is being closed.
|
||||
/// </summary>
|
||||
void SessionClosed();
|
||||
|
||||
/// <summary>
|
||||
/// Removes a message from the message queue.
|
||||
/// </summary>
|
||||
ServiceResult Acknowledge(OperationContext context, uint sequenceNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the subscription.
|
||||
/// </summary>
|
||||
void Delete(OperationContext context);
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that a condition refresh operation is permitted.
|
||||
/// </summary>
|
||||
void ValidateConditionRefresh(OperationContext context);
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that a condition refresh operation is permitted.
|
||||
/// </summary>
|
||||
void ValidateConditionRefresh2(OperationContext context, uint monitoredItemId);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a cached notification message.
|
||||
/// </summary>
|
||||
NotificationMessage Republish(
|
||||
OperationContext context,
|
||||
uint retransmitSequenceNumber);
|
||||
|
||||
/// <summary>
|
||||
/// Publishes a timeout status message.
|
||||
/// </summary>
|
||||
NotificationMessage PublishTimeout();
|
||||
|
||||
/// <summary>
|
||||
/// Publishes a SubscriptionTransferred status message.
|
||||
/// </summary>
|
||||
NotificationMessage SubscriptionTransferred();
|
||||
|
||||
/// <summary>
|
||||
/// Returns all available notifications.
|
||||
/// </summary>
|
||||
NotificationMessage Publish(
|
||||
OperationContext context,
|
||||
out UInt32Collection availableSequenceNumbers,
|
||||
out bool moreNotifications);
|
||||
|
||||
/// <summary>
|
||||
/// Transfers the subscription to a new session.
|
||||
/// </summary>
|
||||
/// <param name="context">The session to which the subscription is transferred.</param>
|
||||
/// <param name="sendInitialValues">Whether the first Publish response shall contain current values.</param>
|
||||
void TransferSession(OperationContext context, bool sendInitialValues);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the triggers for the monitored item.
|
||||
/// </summary>
|
||||
public void SetTriggering(
|
||||
OperationContext context,
|
||||
uint triggeringItemId,
|
||||
UInt32Collection linksToAdd,
|
||||
UInt32Collection linksToRemove,
|
||||
out StatusCodeCollection addResults,
|
||||
out DiagnosticInfoCollection addDiagnosticInfos,
|
||||
out StatusCodeCollection removeResults,
|
||||
out DiagnosticInfoCollection removeDiagnosticInfos);
|
||||
|
||||
/// <summary>
|
||||
/// Return a StorableSubscription for restore after a server restart
|
||||
/// </summary>
|
||||
public IStoredSubscription ToStorableSubscription();
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,7 @@ namespace Opc.Ua.Server
|
||||
/// Clears the queues because the session is closing.
|
||||
/// </summary>
|
||||
/// <returns>The list of subscriptions in the queue.</returns>
|
||||
public IList<Subscription> Close()
|
||||
public IList<ISubscription> Close()
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -125,7 +125,7 @@ namespace Opc.Ua.Server
|
||||
}
|
||||
|
||||
// tell the subscriptions that the session is closed.
|
||||
Subscription[] subscriptions = new Subscription[m_queuedSubscriptions.Count];
|
||||
ISubscription[] subscriptions = new ISubscription[m_queuedSubscriptions.Count];
|
||||
|
||||
for (int ii = 0; ii < m_queuedSubscriptions.Count; ii++)
|
||||
{
|
||||
@@ -143,7 +143,7 @@ namespace Opc.Ua.Server
|
||||
/// <summary>
|
||||
/// Adds a subscription from the publish queue.
|
||||
/// </summary>
|
||||
public void Add(Subscription subscription)
|
||||
public void Add(ISubscription subscription)
|
||||
{
|
||||
if (subscription == null) throw new ArgumentNullException(nameof(subscription));
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace Opc.Ua.Server
|
||||
/// <summary>
|
||||
/// Removes a subscription from the publish queue.
|
||||
/// </summary>
|
||||
public void Remove(Subscription subscription, bool removeQueuedRequests)
|
||||
public void Remove(ISubscription subscription, bool removeQueuedRequests)
|
||||
{
|
||||
if (subscription == null) throw new ArgumentNullException(nameof(subscription));
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace Opc.Ua.Server
|
||||
/// <summary>
|
||||
/// Returns a subscription that is ready to publish.
|
||||
/// </summary>
|
||||
public Subscription Publish(uint clientHandle, DateTime deadline, bool requeue, AsyncPublishOperation operation)
|
||||
public ISubscription Publish(uint clientHandle, DateTime deadline, bool requeue, AsyncPublishOperation operation)
|
||||
{
|
||||
QueuedRequest request = null;
|
||||
|
||||
@@ -521,7 +521,7 @@ namespace Opc.Ua.Server
|
||||
/// <param name="operation">The asynchronous operation.</param>
|
||||
/// <param name="calldata">The calldata.</param>
|
||||
/// <returns></returns>
|
||||
public Subscription CompletePublish(
|
||||
public ISubscription CompletePublish(
|
||||
bool requeue,
|
||||
AsyncPublishOperation operation,
|
||||
object calldata)
|
||||
@@ -573,7 +573,7 @@ namespace Opc.Ua.Server
|
||||
/// <summary>
|
||||
/// Adds a subscription back into the queue because it has more notifications to publish.
|
||||
/// </summary>
|
||||
public void PublishCompleted(Subscription subscription, bool moreNotifications)
|
||||
public void PublishCompleted(ISubscription subscription, bool moreNotifications)
|
||||
{
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -604,7 +604,7 @@ namespace Opc.Ua.Server
|
||||
/// </summary>
|
||||
public void PublishTimerExpired()
|
||||
{
|
||||
List<Subscription> subscriptionsToDelete = new List<Subscription>();
|
||||
List<ISubscription> subscriptionsToDelete = new List<ISubscription>();
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -845,7 +845,7 @@ namespace Opc.Ua.Server
|
||||
/// </summary>
|
||||
private class QueuedSubscription
|
||||
{
|
||||
public Subscription Subscription;
|
||||
public ISubscription Subscription;
|
||||
public DateTime Timestamp;
|
||||
public bool ReadyToPublish;
|
||||
public bool Publishing;
|
||||
|
||||
@@ -35,46 +35,10 @@ using System.Linq;
|
||||
|
||||
namespace Opc.Ua.Server
|
||||
{
|
||||
/// <summary>
|
||||
/// An interface used by the monitored items to signal the subscription.
|
||||
/// </summary>
|
||||
public interface ISubscription
|
||||
{
|
||||
/// <summary>
|
||||
/// The session that owns the monitored item.
|
||||
/// </summary>
|
||||
Session Session { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The subscriptions owner identity.
|
||||
/// </summary>
|
||||
IUserIdentity EffectiveIdentity { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The identifier for the item that is unique within the server.
|
||||
/// </summary>
|
||||
uint Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Called when a monitored item is ready to publish.
|
||||
/// </summary>
|
||||
void ItemReadyToPublish(IMonitoredItem monitoredItem);
|
||||
|
||||
/// <summary>
|
||||
/// Called when a monitored item is ready to publish.
|
||||
/// </summary>
|
||||
void ItemNotificationsAvailable(IMonitoredItem monitoredItem);
|
||||
|
||||
/// <summary>
|
||||
/// Called when a value of monitored item is discarded in the monitoring queue.
|
||||
/// </summary>
|
||||
void QueueOverflowHandler();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Manages a subscription created by a client.
|
||||
/// </summary>
|
||||
public class Subscription : ISubscription, IDisposable
|
||||
public class Subscription : ISubscription
|
||||
{
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Opc.Ua.Server
|
||||
|
||||
m_subscriptionStore = server.SubscriptionStore;
|
||||
|
||||
m_subscriptions = new Dictionary<uint, Subscription>();
|
||||
m_subscriptions = new Dictionary<uint, ISubscription>();
|
||||
m_publishQueues = new NodeIdDictionary<SessionPublishQueue>();
|
||||
m_statusMessages = new NodeIdDictionary<Queue<StatusMessage>>();
|
||||
m_lastSubscriptionId = BitConverter.ToInt64(Nonce.CreateRandomNonceData(sizeof(long)), 0);
|
||||
@@ -100,7 +100,7 @@ namespace Opc.Ua.Server
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
List<Subscription> subscriptions = null;
|
||||
List<ISubscription> subscriptions = null;
|
||||
List<SessionPublishQueue> publishQueues = null;
|
||||
|
||||
lock (m_lock)
|
||||
@@ -108,7 +108,7 @@ namespace Opc.Ua.Server
|
||||
publishQueues = new List<SessionPublishQueue>(m_publishQueues.Values);
|
||||
m_publishQueues.Clear();
|
||||
|
||||
subscriptions = new List<Subscription>(m_subscriptions.Values);
|
||||
subscriptions = new List<ISubscription>(m_subscriptions.Values);
|
||||
m_subscriptions.Clear();
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Opc.Ua.Server
|
||||
Utils.SilentDispose(publishQueue);
|
||||
}
|
||||
|
||||
foreach (Subscription subscription in subscriptions)
|
||||
foreach (ISubscription subscription in subscriptions)
|
||||
{
|
||||
Utils.SilentDispose(subscription);
|
||||
}
|
||||
@@ -178,9 +178,9 @@ namespace Opc.Ua.Server
|
||||
/// Returns all of the subscriptions known to the subscription manager.
|
||||
/// </summary>
|
||||
/// <returns>A list of the subscriptions.</returns>
|
||||
public IList<Subscription> GetSubscriptions()
|
||||
public IList<ISubscription> GetSubscriptions()
|
||||
{
|
||||
List<Subscription> subscriptions = new List<Subscription>();
|
||||
List<ISubscription> subscriptions = new List<ISubscription>();
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -193,7 +193,7 @@ namespace Opc.Ua.Server
|
||||
/// <summary>
|
||||
/// Raises an event related to a subscription.
|
||||
/// </summary>
|
||||
protected virtual void RaiseSubscriptionEvent(Subscription subscription, bool deleted)
|
||||
protected virtual void RaiseSubscriptionEvent(ISubscription subscription, bool deleted)
|
||||
{
|
||||
SubscriptionEventHandler handler = null;
|
||||
|
||||
@@ -271,7 +271,7 @@ namespace Opc.Ua.Server
|
||||
StoreSubscriptions();
|
||||
|
||||
// dispose of subscriptions objects.
|
||||
foreach (Subscription subscription in m_subscriptions.Values)
|
||||
foreach (ISubscription subscription in m_subscriptions.Values)
|
||||
{
|
||||
subscription.Dispose();
|
||||
}
|
||||
@@ -293,7 +293,7 @@ namespace Opc.Ua.Server
|
||||
}
|
||||
var subscriptionsToStore = new List<IStoredSubscription>();
|
||||
|
||||
foreach (Subscription subscription in m_subscriptions.Values)
|
||||
foreach (ISubscription subscription in m_subscriptions.Values)
|
||||
{
|
||||
// only store durable subscriptions
|
||||
if (!subscription.IsDurable)
|
||||
@@ -360,7 +360,7 @@ namespace Opc.Ua.Server
|
||||
|
||||
foreach (IStoredSubscription storedSubscription in restoreResult.Subscriptions)
|
||||
{
|
||||
Subscription subscription;
|
||||
ISubscription subscription;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -384,7 +384,7 @@ namespace Opc.Ua.Server
|
||||
/// <summary>
|
||||
/// Restore a subscription after a restart
|
||||
/// </summary>
|
||||
protected virtual Subscription RestoreSubscription(
|
||||
protected virtual ISubscription RestoreSubscription(
|
||||
IStoredSubscription storedSubscription)
|
||||
{
|
||||
if (m_subscriptions.Count >= m_maxSubscriptionCount)
|
||||
@@ -439,7 +439,7 @@ namespace Opc.Ua.Server
|
||||
{
|
||||
// close the publish queue for the session.
|
||||
SessionPublishQueue queue = null;
|
||||
IList<Subscription> subscriptionsToDelete = null;
|
||||
IList<ISubscription> subscriptionsToDelete = null;
|
||||
uint publishingIntervalCount = 0;
|
||||
|
||||
lock (m_lock)
|
||||
@@ -475,7 +475,7 @@ namespace Opc.Ua.Server
|
||||
{
|
||||
for (int ii = 0; ii < subscriptionsToDelete.Count; ii++)
|
||||
{
|
||||
Subscription subscription = subscriptionsToDelete[ii];
|
||||
ISubscription subscription = subscriptionsToDelete[ii];
|
||||
|
||||
// delete the subscription.
|
||||
if (deleteSubscriptions)
|
||||
@@ -504,7 +504,7 @@ namespace Opc.Ua.Server
|
||||
{
|
||||
if (m_abandonedSubscriptions == null)
|
||||
{
|
||||
m_abandonedSubscriptions = new List<Subscription>();
|
||||
m_abandonedSubscriptions = new List<ISubscription>();
|
||||
}
|
||||
|
||||
m_abandonedSubscriptions.Add(subscription);
|
||||
@@ -520,7 +520,7 @@ namespace Opc.Ua.Server
|
||||
/// </summary>
|
||||
public void ConditionRefresh(OperationContext context, uint subscriptionId)
|
||||
{
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -564,7 +564,7 @@ namespace Opc.Ua.Server
|
||||
/// </summary>
|
||||
public void ConditionRefresh2(OperationContext context, uint subscriptionId, uint monitoredItemId)
|
||||
{
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -600,7 +600,7 @@ namespace Opc.Ua.Server
|
||||
/// <summary>
|
||||
/// Completes a refresh conditions request.
|
||||
/// </summary>
|
||||
private void DoConditionRefresh(Subscription subscription)
|
||||
private void DoConditionRefresh(ISubscription subscription)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -616,7 +616,7 @@ namespace Opc.Ua.Server
|
||||
/// <summary>
|
||||
/// Completes a refresh conditions request.
|
||||
/// </summary>
|
||||
private void DoConditionRefresh2(Subscription subscription, uint monitoredItemId)
|
||||
private void DoConditionRefresh2(ISubscription subscription, uint monitoredItemId)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -637,7 +637,7 @@ namespace Opc.Ua.Server
|
||||
{
|
||||
uint publishingIntervalCount = 0;
|
||||
int monitoredItemCount = 0;
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -744,7 +744,7 @@ namespace Opc.Ua.Server
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
foreach (Subscription subscription in m_subscriptions.Values)
|
||||
foreach (ISubscription subscription in m_subscriptions.Values)
|
||||
{
|
||||
double publishingInterval = subscription.PublishingInterval;
|
||||
|
||||
@@ -792,7 +792,7 @@ namespace Opc.Ua.Server
|
||||
revisedMaxKeepAliveCount = 0;
|
||||
|
||||
uint publishingIntervalCount = 0;
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
|
||||
// get session from context.
|
||||
Session session = context.Session;
|
||||
@@ -996,7 +996,7 @@ namespace Opc.Ua.Server
|
||||
/// Called when a subscription expires.
|
||||
/// </summary>
|
||||
/// <param name="subscription">The subscription.</param>
|
||||
internal void SubscriptionExpired(Subscription subscription)
|
||||
internal void SubscriptionExpired(ISubscription subscription)
|
||||
{
|
||||
lock (m_statusMessagesLock)
|
||||
{
|
||||
@@ -1048,7 +1048,7 @@ namespace Opc.Ua.Server
|
||||
do
|
||||
{
|
||||
// wait for a subscription to publish.
|
||||
Subscription subscription = queue.CompletePublish(requeue, operation, operation.Calldata);
|
||||
ISubscription subscription = queue.CompletePublish(requeue, operation, operation.Calldata);
|
||||
|
||||
if (subscription == null)
|
||||
{
|
||||
@@ -1138,7 +1138,7 @@ namespace Opc.Ua.Server
|
||||
do
|
||||
{
|
||||
// wait for a subscription to publish.
|
||||
Subscription subscription = queue.Publish(
|
||||
ISubscription subscription = queue.Publish(
|
||||
context.ClientHandle,
|
||||
context.OperationDeadline,
|
||||
requeue,
|
||||
@@ -1224,7 +1224,7 @@ namespace Opc.Ua.Server
|
||||
uint publishingIntervalCount = 0;
|
||||
|
||||
// find subscription.
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -1281,7 +1281,7 @@ namespace Opc.Ua.Server
|
||||
out uint revisedLifetimeInHours)
|
||||
{
|
||||
revisedLifetimeInHours = 0;
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
lock (m_lock)
|
||||
{
|
||||
if (!m_subscriptions.TryGetValue(subscriptionId, out subscription))
|
||||
@@ -1335,7 +1335,7 @@ namespace Opc.Ua.Server
|
||||
try
|
||||
{
|
||||
// find subscription.
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -1398,7 +1398,7 @@ namespace Opc.Ua.Server
|
||||
try
|
||||
{
|
||||
// find subscription.
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
Session ownerSession = null;
|
||||
|
||||
lock (m_lock)
|
||||
@@ -1617,7 +1617,7 @@ namespace Opc.Ua.Server
|
||||
uint retransmitSequenceNumber)
|
||||
{
|
||||
// find subscription.
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -1646,7 +1646,7 @@ namespace Opc.Ua.Server
|
||||
out DiagnosticInfoCollection removeDiagnosticInfos)
|
||||
{
|
||||
// find subscription.
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -1682,7 +1682,7 @@ namespace Opc.Ua.Server
|
||||
int monitoredItemCountIncrement = 0;
|
||||
|
||||
// find subscription.
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -1727,7 +1727,7 @@ namespace Opc.Ua.Server
|
||||
out DiagnosticInfoCollection diagnosticInfos)
|
||||
{
|
||||
// find subscription.
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -1759,7 +1759,7 @@ namespace Opc.Ua.Server
|
||||
int monitoredItemCountIncrement = 0;
|
||||
|
||||
// find subscription.
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -1803,7 +1803,7 @@ namespace Opc.Ua.Server
|
||||
out DiagnosticInfoCollection diagnosticInfos)
|
||||
{
|
||||
// find subscription.
|
||||
Subscription subscription = null;
|
||||
ISubscription subscription = null;
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -2003,7 +2003,7 @@ namespace Opc.Ua.Server
|
||||
/// <summary>
|
||||
/// Creates a new instance of a subscription.
|
||||
/// </summary>
|
||||
protected virtual Subscription CreateSubscription(
|
||||
protected virtual ISubscription CreateSubscription(
|
||||
OperationContext context,
|
||||
uint subscriptionId,
|
||||
double publishingInterval,
|
||||
@@ -2072,7 +2072,7 @@ namespace Opc.Ua.Server
|
||||
DateTime start = DateTime.UtcNow;
|
||||
|
||||
SessionPublishQueue[] queues = null;
|
||||
Subscription[] abandonedSubscriptions = null;
|
||||
ISubscription[] abandonedSubscriptions = null;
|
||||
|
||||
lock (m_lock)
|
||||
{
|
||||
@@ -2083,7 +2083,7 @@ namespace Opc.Ua.Server
|
||||
// collect abandoned subscriptions.
|
||||
if (m_abandonedSubscriptions != null && m_abandonedSubscriptions.Count > 0)
|
||||
{
|
||||
abandonedSubscriptions = new Subscription[m_abandonedSubscriptions.Count];
|
||||
abandonedSubscriptions = new ISubscription[m_abandonedSubscriptions.Count];
|
||||
|
||||
for (int ii = 0; ii < abandonedSubscriptions.Length; ii++)
|
||||
{
|
||||
@@ -2101,11 +2101,11 @@ namespace Opc.Ua.Server
|
||||
// check the publish timer for each abandoned subscription.
|
||||
if (abandonedSubscriptions != null)
|
||||
{
|
||||
List<Subscription> subscriptionsToDelete = new List<Subscription>();
|
||||
List<ISubscription> subscriptionsToDelete = new List<ISubscription>();
|
||||
|
||||
for (int ii = 0; ii < abandonedSubscriptions.Length; ii++)
|
||||
{
|
||||
Subscription subscription = abandonedSubscriptions[ii];
|
||||
ISubscription subscription = abandonedSubscriptions[ii];
|
||||
|
||||
if (subscription.PublishTimerExpired() != PublishingState.Expired)
|
||||
{
|
||||
@@ -2114,7 +2114,7 @@ namespace Opc.Ua.Server
|
||||
|
||||
if (subscriptionsToDelete == null)
|
||||
{
|
||||
subscriptionsToDelete = new List<Subscription>();
|
||||
subscriptionsToDelete = new List<ISubscription>();
|
||||
}
|
||||
|
||||
subscriptionsToDelete.Add(subscription);
|
||||
@@ -2215,7 +2215,7 @@ namespace Opc.Ua.Server
|
||||
/// </summary>
|
||||
/// <param name="server">The server.</param>
|
||||
/// <param name="subscriptionsToDelete">The subscriptions to delete.</param>
|
||||
internal static void CleanupSubscriptions(IServerInternal server, IList<Subscription> subscriptionsToDelete)
|
||||
internal static void CleanupSubscriptions(IServerInternal server, IList<ISubscription> subscriptionsToDelete)
|
||||
{
|
||||
if (subscriptionsToDelete != null && subscriptionsToDelete.Count > 0)
|
||||
{
|
||||
@@ -2239,9 +2239,9 @@ namespace Opc.Ua.Server
|
||||
object[] args = (object[])data;
|
||||
|
||||
IServerInternal server = (IServerInternal)args[0];
|
||||
List<Subscription> subscriptions = (List<Subscription>)args[1];
|
||||
List<ISubscription> subscriptions = (List<ISubscription>)args[1];
|
||||
|
||||
foreach (Subscription subscription in subscriptions)
|
||||
foreach (ISubscription subscription in subscriptions)
|
||||
{
|
||||
server.DeleteSubscription(subscription.Id);
|
||||
}
|
||||
@@ -2266,13 +2266,13 @@ namespace Opc.Ua.Server
|
||||
#region ConditionRefreshTask Class
|
||||
private class ConditionRefreshTask
|
||||
{
|
||||
public ConditionRefreshTask(Subscription subscription, uint monitoredItemId)
|
||||
public ConditionRefreshTask(ISubscription subscription, uint monitoredItemId)
|
||||
{
|
||||
Subscription = subscription;
|
||||
MonitoredItemId = monitoredItemId;
|
||||
}
|
||||
|
||||
public Subscription Subscription { get; private set; }
|
||||
public ISubscription Subscription { get; private set; }
|
||||
public uint MonitoredItemId { get; private set; }
|
||||
|
||||
public override bool Equals(Object obj)
|
||||
@@ -2313,8 +2313,8 @@ namespace Opc.Ua.Server
|
||||
private int m_maxPublishRequestCount;
|
||||
private int m_maxSubscriptionCount;
|
||||
private bool m_durableSubscriptionsEnabled;
|
||||
private Dictionary<uint, Subscription> m_subscriptions;
|
||||
private List<Subscription> m_abandonedSubscriptions;
|
||||
private Dictionary<uint, ISubscription> m_subscriptions;
|
||||
private List<ISubscription> m_abandonedSubscriptions;
|
||||
private NodeIdDictionary<Queue<StatusMessage>> m_statusMessages;
|
||||
private NodeIdDictionary<SessionPublishQueue> m_publishQueues;
|
||||
private ManualResetEvent m_shutdownEvent;
|
||||
@@ -2352,7 +2352,7 @@ namespace Opc.Ua.Server
|
||||
/// Returns all of the subscriptions known to the subscription manager.
|
||||
/// </summary>
|
||||
/// <returns>A list of the subscriptions.</returns>
|
||||
IList<Subscription> GetSubscriptions();
|
||||
IList<ISubscription> GetSubscriptions();
|
||||
|
||||
/// <summary>
|
||||
/// Set a subscription into durable mode
|
||||
@@ -2368,5 +2368,5 @@ namespace Opc.Ua.Server
|
||||
/// </summary>
|
||||
/// <param name="subscription">The subscription that was affected.</param>
|
||||
/// <param name="deleted">True if the subscription was deleted.</param>
|
||||
public delegate void SubscriptionEventHandler(Subscription subscription, bool deleted);
|
||||
public delegate void SubscriptionEventHandler(ISubscription subscription, bool deleted);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user