Example #1
0
        ///////////////////////////////////////////////////////////////////////
        #region Public Methods

        /// <summary>Returns an unconnected copy of the server with the same OpcUrl.</summary>
        public override object Clone()
        {
            // clone the base object.
            TsCDaServer clone = (TsCDaServer)base.Clone();

            // clone subscriptions.
            if (clone._subscriptions != null)
            {
                TsCDaSubscriptionCollection subscriptions = new TsCDaSubscriptionCollection();

                foreach (TsCDaSubscription subscription in clone._subscriptions)
                {
                    subscriptions.Add(subscription.Clone());
                }

                clone._subscriptions = subscriptions;
            }

            // return clone.
            return(clone);
        }
        /// <summary>
        /// Displays the address space for the specified server.
        /// </summary>
        public void Initialize(Technosoftware.DaAeHdaClient.Da.TsCDaServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            mServer_ = server;

            TsCDaBrowseFilters filters = new TsCDaBrowseFilters();

            filters.ReturnAllProperties  = true;
            filters.ReturnPropertyValues = true;

            browseCtrl_.ShowSingleServer(mServer_, filters);
            propertiesCtrl_.Initialize(null);

            ShowDialog();

            // ensure server connection in the browse control are closed.
            browseCtrl_.Clear();
        }
        /// <summary>
        /// Dispose(bool disposing) executes in two distinct scenarios.
        /// If disposing equals true, the method has been called directly
        /// or indirectly by a user's code. Managed and unmanaged resources
        /// can be disposed.
        /// If disposing equals false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference
        /// other objects. Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing">If true managed and unmanaged resources can be disposed. If false only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!disposed_)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    if (Subscription != null)
                    {
                        Subscription.Dispose();

                        server_      = null;
                        Subscription = null;
                        daItems_     = null;
                    }
                }
                // Release unmanaged resources. If disposing is false,
                // only the following code is executed.
            }
            disposed_ = true;
        }
        /// <summary>
        /// Dispose(bool disposing) executes in two distinct scenarios.
        /// If disposing equals true, the method has been called directly
        /// or indirectly by a user's code. Managed and unmanaged resources
        /// can be disposed.
        /// If disposing equals false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference
        /// other objects. Only unmanaged resources can be disposed.
        /// </summary>
        /// <param name="disposing"></param>
        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!_disposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    if (_subscription != null)
                    {
                        _subscription.Dispose();

                        _server       = null;
                        _subscription = null;
                        _items        = null;
                    }
                }
                // Release unmanaged resources. If disposing is false,
                // only the following code is executed.
            }
            _disposed = true;
        }
Example #5
0
        /// <summary>
        /// Creates a server object for the specified URL.
        /// </summary>
        /// <param name="url">The OpcUrl of the OPC server.</param>
        /// <returns>The OpcServer object.</returns>
        public static OpcServer GetServer(OpcUrl url)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            OpcServer server = null;

            // create an unconnected server object for COM based servers.

            // DA
            if (String.CompareOrdinal(url.Scheme, OpcUrlScheme.DA) == 0)
            {
                server = new Da.TsCDaServer(new Factory(), url);
            }

            // AE
            else if (String.CompareOrdinal(url.Scheme, OpcUrlScheme.AE) == 0)
            {
                server = new Ae.TsCAeServer(new Factory(), url);
            }

            // HDA
            else if (String.CompareOrdinal(url.Scheme, OpcUrlScheme.HDA) == 0)
            {
                server = new Hda.TsCHdaServer(new Factory(), url);
            }

            // Other specifications not supported yet.
            if (server == null)
            {
                throw new NotSupportedException(url.Scheme);
            }

            return(server);
        }
        ///////////////////////////////////////////////////////////////////////
        #region Public Methods (Returns OpcServer object for a specific URL)

        /// <summary>
        /// Creates a server object for the specified URL.
        /// </summary>
        /// <param name="url">The OpcUrl of the OPC server.</param>
        /// <returns>The OpcServer obkect.</returns>
        public static OpcServer GetServer(Technosoftware.DaAeHdaClient.OpcUrl url)
        {
            if (url == null)
            {
                throw new ArgumentNullException("url");
            }

            OpcServer server = null;

            // create an unconnected server object for COM based servers.

            // DA
            if (server == null && String.Compare(url.Scheme, OpcUrlScheme.DA, false) == 0)
            {
                server = new Da.TsCDaServer(new Technosoftware.DaAeHdaClient.Com.Factory(), url);
            }

            // AE
            else if (String.Compare(url.Scheme, OpcUrlScheme.AE, false) == 0)
            {
                server = new Ae.TsCAeServer(new Technosoftware.DaAeHdaClient.Com.Factory(), url);
            }

            // HDA
            else if (String.Compare(url.Scheme, OpcUrlScheme.HDA, false) == 0)
            {
                server = new Hda.TsCHdaServer(new Technosoftware.DaAeHdaClient.Com.Factory(), url);
            }

            // Other specifications not supported yet.
            if (server == null)
            {
                throw new NotSupportedException(url.Scheme);
            }

            return(server);
        }