/// <summary>
 /// Initializes object with default values.
 /// </summary>
 public TsCAeSubscription(TsCAeServer server, ITsCAeSubscription subscription, TsCAeSubscriptionState state)
 {
     server_       = server ?? throw new ArgumentNullException(nameof(server));
     subscription_ = subscription ?? throw new ArgumentNullException(nameof(subscription));
     state_        = (TsCAeSubscriptionState)state.Clone();
     name_         = state.Name;
 }
        /// <summary>
        /// Constructs a server by de-serializing its OpcUrl from the stream.
        /// </summary>
        protected TsCAeSubscription(SerializationInfo info, StreamingContext context)
        {
            state_ = (TsCAeSubscriptionState)info.GetValue(Names.State, typeof(TsCAeSubscriptionState));
            subscriptionFilters_ = (TsCAeSubscriptionFilters)info.GetValue(Names.Filters, typeof(TsCAeSubscriptionFilters));
            attributes_          = (AttributeDictionary)info.GetValue(Names.Attributes, typeof(AttributeDictionary));

            name_ = state_.Name;

            categories_ = new CategoryCollection(subscriptionFilters_.Categories.ToArray());
            areas_      = new StringCollection(subscriptionFilters_.Areas.ToArray());
            sources_    = new StringCollection(subscriptionFilters_.Sources.ToArray());
        }
Пример #3
0
        /// <summary>
        /// Returns the current state of the subscription.
        /// </summary>
        /// <returns>The current state of the subscription.</returns>
        public TsCAeSubscriptionState GetState()
        {
            if (_subscription == null)
            {
                throw new NotConnectedException();
            }

            _state      = _subscription.GetState();
            _state.Name = _name;

            return((TsCAeSubscriptionState)_state.Clone());
        }
Пример #4
0
        ///////////////////////////////////////////////////////////////////////
        #region ISerializable Members

        /// <summary>
        /// Contructs a server by de-serializing its OpcUrl from the stream.
        /// </summary>
        protected TsCAeSubscription(SerializationInfo info, StreamingContext context)
        {
            _state      = (Ae.TsCAeSubscriptionState)info.GetValue(Names.STATE, typeof(Ae.TsCAeSubscriptionState));
            _filters    = (Ae.TsCAeSubscriptionFilters)info.GetValue(Names.FILTERS, typeof(Ae.TsCAeSubscriptionFilters));
            _attributes = (AttributeDictionary)info.GetValue(Names.ATTRIBUTES, typeof(AttributeDictionary));

            _name = _state.Name;

            _categories = new CategoryCollection(_filters.Categories.ToArray());
            _areas      = new StringCollection(_filters.Areas.ToArray());
            _sources    = new StringCollection(_filters.Sources.ToArray());
        }
Пример #5
0
        ///////////////////////////////////////////////////////////////////////
        #region Constructors, Destructor, Initialization

        /// <summary>
        /// Initializes object with default values.
        /// </summary>
        public TsCAeSubscription(TsCAeServer server, ITsCAeSubscription subscription, TsCAeSubscriptionState state)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            if (subscription == null)
            {
                throw new ArgumentNullException("subscription");
            }

            _server       = server;
            _subscription = subscription;
            _state        = (Ae.TsCAeSubscriptionState)state.Clone();
            _name         = state.Name;
        }
Пример #6
0
        /// <summary>
        /// Changes the state of a subscription.
        /// </summary>
        /// <param name="masks">A bit mask that indicates which elements of the subscription state are changing.</param>
        /// <param name="state">The new subscription state.</param>
        /// <returns>The actual subscription state after applying the changes.</returns>
        public Ae.TsCAeSubscriptionState ModifyState(int masks, Ae.TsCAeSubscriptionState state)
        {
            if (_subscription == null)
            {
                throw new NotConnectedException();
            }

            _state = _subscription.ModifyState(masks, state);

            if ((masks & (int)TsCAeStateMask.Name) != 0)
            {
                _state.Name = _name = state.Name;
            }
            else
            {
                _state.Name = _name;
            }

            return((Ae.TsCAeSubscriptionState)_state.Clone());
        }
        /// <summary>
        /// Creates a new event subscription.
        /// </summary>
        /// <param name="state">The initial state for the subscription.</param>
        /// <returns>The new subscription object.</returns>
        public ITsCAeSubscription CreateSubscription(TsCAeSubscriptionState state)
        {
            LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions);
            if (Server == null)
            {
                throw new NotConnectedException();
            }

            // create remote object.
            ITsCAeSubscription subscription = ((ITsCAeServer)Server).CreateSubscription(state);

            if (subscription != null)
            {
                // create wrapper.
                var wrapper = new TsCAeSubscription(this, subscription, state);
                subscriptions_.Add(wrapper);
                return(wrapper);
            }

            // should never happen.
            return(null);
        }