Beispiel #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]);
        }
Beispiel #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]);
        }
 /// <summary>
 /// Updates the current subscription state.
 /// </summary>
 public TsCDaSubscriptionState ModifyState(int masks, TsCDaSubscriptionState state)
 {
     subscriptionState_ = Subscription.ModifyState(masks, state);
     return(subscriptionState_);
 }
 /// <summary>
 /// Returns the current subscription state.
 /// </summary>
 public TsCDaSubscriptionState GetState()
 {
     subscriptionState_ = Subscription.GetState();
     return(subscriptionState_);
 }
 /// <summary>
 /// Constructs a server by de-serializing its OpcUrl from the stream.
 /// </summary>
 protected TsCDaSubscription(SerializationInfo info, StreamingContext context)
 {
     subscriptionState_ = (TsCDaSubscriptionState)info.GetValue(Names.State, typeof(TsCDaSubscriptionState));
     filters_           = (int)info.GetValue(Names.Filters, typeof(int));
     daItems_           = (TsCDaItem[])info.GetValue(Names.Items, typeof(TsCDaItem[]));
 }
 /// <summary>
 /// Updates the current subscription state.
 /// </summary>
 public TsCDaSubscriptionState ModifyState(int masks, TsCDaSubscriptionState state)
 {
     _state = _subscription.ModifyState(masks, state);
     return(_state);
 }
 /// <summary>
 /// Returns the current subscription state.
 /// </summary>
 public TsCDaSubscriptionState GetState()
 {
     _state = _subscription.GetState();
     return(_state);
 }
 /// <summary>
 /// Contructs a server by de-serializing its OpcUrl from the stream.
 /// </summary>
 protected TsCDaSubscription(SerializationInfo info, StreamingContext context)
 {
     _state   = (TsCDaSubscriptionState)info.GetValue(Names.STATE, typeof(TsCDaSubscriptionState));
     _filters = (int)info.GetValue(Names.FILTERS, typeof(int));
     _items   = (TsCDaItem[])info.GetValue(Names.ITEMS, typeof(TsCDaItem[]));
 }