Ejemplo n.º 1
0
        /// <summary>
        /// Removes a previously created subscription.
        /// </summary>
        private void UndoCreate()
        {
            try
            {
                m_server.CancelSubscription(m_subscription);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                if (m_subscription != null)
                {
                    m_subscription.Dispose();
                }
                m_subscription = null;
            }

            // move to edit subscription panel.
            BackBTN.Enabled          = false;
            NextBTN.Enabled          = true;
            CancelBTN.Visible        = true;
            DoneBTN.Visible          = false;
            OptionsBTN.Visible       = false;
            SubscriptionCTRL.Visible = true;
            BrowseCTRL.Visible       = false;
            ItemsCTRL.Visible        = true;
            ResultsCTRL.Visible      = false;
        }
        /// <summary>
        /// Removes a previously created subscription.
        /// </summary>
        private void UndoCreate()
        {
            try
            {
                mServer_.CancelSubscription(mSubscription_);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                if (mSubscription_ != null)
                {
                    mSubscription_.Dispose();
                }
                mSubscription_ = null;
            }

            // move to edit subscription panel.
            backBtn_.Enabled          = false;
            nextBtn_.Enabled          = true;
            cancelBtn_.Visible        = true;
            doneBtn_.Visible          = false;
            optionsBtn_.Visible       = false;
            subscriptionCtrl_.Visible = true;
            browseCtrl_.Visible       = false;
            itemsCtrl_.Visible        = true;
            resultsCtrl_.Visible      = false;
        }
        /// <summary>
        /// Deletes the specified subscription.
        /// </summary>
        private void DeleteSubscription(TreeNode node, TsCDaSubscription subscription)
        {
            if (SubscriptionModified != null)
            {
                SubscriptionModified(subscription, true);
            }

            try
            {
                TsCDaServer server = subscription.Server;
                server.CancelSubscription(subscription);
                subscription.Dispose();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            node.Remove();
        }
        /// <summary>
        /// Removes a subscription an releases all resources.
        /// </summary>
        private void RemoveSubscriptionMI_Click(object sender, System.EventArgs e)
        {
            TreeNode node = subscriptionTv_.SelectedNode;

            if (IsSubscriptionNode(node))
            {
                if (node.Parent != null)
                {
                    try
                    {
                        TsCDaServer server = (TsCDaServer)node.Parent.Tag;
                        server.CancelSubscription((TsCDaSubscription)node.Tag);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    node.Remove();
                }
            }
        }
Ejemplo n.º 5
0
        private void TestMI_Click(object sender, System.EventArgs e)
        {
            try
            {
                TsCDaServer server = (TsCDaServer)m_server;

                TsCDaItem[] items = new TsCDaItem[100];

                for (int ii = 0; ii < items.Length; ii++)
                {
                    items[ii] = new TsCDaItem();

                    items[ii].ItemName     = "Static/ArrayTypes/Object[]";
                    items[ii].ItemPath     = "DA30";
                    items[ii].ClientHandle = ii;
                }

                TsCDaSubscriptionState state = new TsCDaSubscriptionState();

                state.Active     = true;
                state.UpdateRate = 1000;

                ITsCDaSubscription subscription = server.CreateSubscription(state);
                Thread.Sleep(100);

                TsCDaItemResult[] results = subscription.AddItems(items);
                Thread.Sleep(100);

                subscription.RemoveItems(results);
                Thread.Sleep(100);

                server.CancelSubscription(subscription);
                Thread.Sleep(100);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
        /// <summary>
        /// Disconnects from the server and clears all objects.
        /// </summary>
        private void Disconnect(TreeNode node, TsCDaServer server)
        {
            // remove all subscriptions.
            foreach (TreeNode child in node.Nodes)
            {
                if (IsSubscriptionNode(child))
                {
                    if (SubscriptionModified != null)
                    {
                        SubscriptionModified((TsCDaSubscription)child.Tag, true);
                    }

                    TsCDaSubscription subscription = (TsCDaSubscription)child.Tag;
                    server.CancelSubscription(subscription);
                    subscription.Dispose();
                }
            }

            // disconnect server.
            server.Disconnect();

            // remove tree from view.
            node.Remove();
        }