示例#1
0
 /// <summary>
 /// Removes a subscription to the list of active subscriptions.
 /// </summary>
 public void DeactivateSubscription(Subscription subscription)
 {
     lock (this)
     {
         for (int ii = 0; ii < m_subscriptions.Count; ii++)
         {
             if (subscription == m_subscriptions[ii])
             {
                 m_subscriptions.RemoveAt(ii);
                 return;
             }
         }
     }
 }
示例#2
0
        //======================================================================
        // CreateSubscription
        /// <summary>
        /// Creates a new subscription.
        /// </summary>
        /// <param name="state">The initial state of the subscription.</param>
        /// <returns>The new subscription object.</returns>
        public ISubscription CreateSubscription(Opc.Da.SubscriptionState state)
        {
            if (state == null)   throw new ArgumentNullException("state");

            lock (this)
            {
                Opc.Da.SubscriptionState copy = (Opc.Da.SubscriptionState)state.Clone();

                // assign unique handle.
                copy.ServerHandle = m_nextHandle++;

                // assign name.
                if (copy.Name == null || copy.Name.Length == 0)
                {
                    copy.Name = String.Format("Subscription{0,2:00}", copy.ServerHandle);
                }

                // create subscription.
                Subscription subscription = new Subscription(m_cache, this, copy);

                // save reference.
                m_subscriptions[copy.ServerHandle] = subscription;

                // return new subscription.
                return subscription;
            }
        }
示例#3
0
        /// <summary>
        /// Adds a subscription to the list of active subscriptions.
        /// </summary>
        public void ActivateSubscription(Subscription subscription)
        {
            lock (this)
            {
                // ensure duplicates are not added.
                for (int ii = 0; ii < m_subscriptions.Count; ii++)
                {
                    if (subscription == m_subscriptions[ii])
                    {
                        return;
                    }
                }

                m_subscriptions.Add(subscription);
            }
        }