コード例 #1
0
        /// <summary>
        /// Creates a new subscription.
        /// </summary>
        /// <returns>The new subscription object.</returns>
        /// <requirements>OPC XML-DA Server or OPC Data Access Server V2.x / V3.x</requirements>
        /// <param name="state">The initial state of the subscription.</param>
        public virtual ITsCDaSubscription CreateSubscription(TsCDaSubscriptionState state)
        {
            LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.DataAccess);
            if (state == null)
            {
                throw new ArgumentNullException(nameof(state));
            }
            if (Server == null)
            {
                throw new NotConnectedException();
            }

            // create subscription on server.
            ITsCDaSubscription subscription = ((ITsDaServer)Server).CreateSubscription(state);

            // set filters.
            subscription.SetResultFilters(filters_);

            // append new subscription to existing list.
            TsCDaSubscriptionCollection subscriptions = new TsCDaSubscriptionCollection();

            if (subscriptions_ != null)
            {
                foreach (TsCDaSubscription value in subscriptions_)
                {
                    subscriptions.Add(value);
                }
            }

            subscriptions.Add(CreateSubscription(subscription));

            // save new subscription list.
            subscriptions_ = subscriptions;

            // return new subscription.
            return(subscriptions_[subscriptions_.Count - 1]);
        }
コード例 #2
0
        /// <summary>
        /// Creates a new subscription.
        /// </summary>
        /// <returns>The new subscription object.</returns>
        /// <requirements>OPC XML-DA Server or OPC Data Access Server V2.x / V3.x</requirements>
        /// <param name="state">The initial state of the subscription.</param>
        public virtual ITsCDaSubscription CreateSubscription(TsCDaSubscriptionState state)
        {
            if (state == null)
            {
                throw new ArgumentNullException("state");
            }
            if (_server == null)
            {
                throw new NotConnectedException();
            }

            // create subscription on server.
            ITsCDaSubscription subscription = ((ITsDaServer)_server).CreateSubscription(state);

            // set filters.
            subscription.SetResultFilters(_filters);

            // append new subscription to existing list.
            TsCDaSubscriptionCollection subscriptions = new TsCDaSubscriptionCollection();

            if (_subscriptions != null)
            {
                foreach (TsCDaSubscription value in _subscriptions)
                {
                    subscriptions.Add(value);
                }
            }

            subscriptions.Add(CreateSubscription(subscription));

            // save new subscription list.
            _subscriptions = subscriptions;

            // return new subscription.
            return(_subscriptions[_subscriptions.Count - 1]);
        }
コード例 #3
0
 /// <summary>
 /// Sets default result filters for the server.
 /// </summary>
 public void SetResultFilters(int filters)
 {
     Subscription.SetResultFilters(filters);
     filters_ = filters;
 }
コード例 #4
0
 /// <summary>
 /// Sets default result filters for the server.
 /// </summary>
 public void SetResultFilters(int filters)
 {
     _subscription.SetResultFilters(filters);
     _filters = filters;
 }