Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SubscriptionProperties"/> class with the value indicated by a <see cref="ControlDaSession">Session</see> object.
        /// </summary>
        /// <param name="aSession">the current session</param>
        /// <param name="aListView">the listview in InfoCollector that needs to be modified</param>
        internal SubscriptionProperties(ControlDaSession aSession, ListView aListView)
        {
            m_session  = aSession;
            m_listView = aListView;

            InitializeComponent();

            this.activeCheckBox.Checked = true;
        }
		//-----------------------------

		/// <summary>
		/// Initializes a new instance of the <see cref="ControlDaSubscription"/> class with
		/// the value indicated by an update rate and a <see cref="ControlDaSession"/> object to whom to be added.
		/// </summary>
		/// <param name="updateRate">The cyclic rate that the  active <see cref="ControlDaItem"/> objects have to be read.</param>
		/// <param name="parentSession">The session to whom the subscription is to be added.</param>
		/// <include
		///  file='TBNC.doc.xml'
		///  path='//class[@name="ControlDaSubscription"]/constructor[@name="ControlDaSubscription"]/doc/*'
		/// />
		public ControlDaSubscription(
			uint updateRate,
			ControlDaSession parentSession)
			:
				base(
				updateRate,
				parentSession)
		{
			m_updateRate = updateRate;
		} //	end ctr
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SubscriptionProperties"/> class with the value indicated by a <see cref="ControlDaSession">Session</see> object.
        /// </summary>
        /// <param name="aSession">the current session</param>
        /// <param name="aListView">the listview in InfoCollector that needs to be modified</param>
        /// <param name="position">the position on the listview the subscription must be added or edited</param>
        /// <param name="active">shows whether the current selected subscription is active or not</param>
        internal SubscriptionProperties(ControlDaSession aSession, ListView aListView, int position, bool active)
        {
            m_session  = aSession;
            m_listView = aListView;
            m_position = position;

            InitializeComponent();

            if (active)
            {
                this.activeCheckBox.Checked = true;
            }
            else
            {
                this.activeCheckBox.Checked = false;
            }
            this.subscriptionNameTextBox.Text       = aListView.Items[position].SubItems[0].Text;
            this.subscriptionUpdateRateTextBox.Text = aListView.Items[position].SubItems[2].Text;
        }
        }         //	end Start

        /// <summary>
        /// Stops the <see cref="DataControl">DataControl.</see>
        /// </summary>
        /// <remarks>
        /// The connection with the server is closing down. No values will be read for the items
        ///	that belong to the <b>DataControl.</b>
        /// </remarks>
        /// <include
        ///  file='TBNC.doc.xml'
        ///  path='//class[@name="DataControl"]/method[@name="Stop"]/doc/*'
        /// />
        public void Stop()
        {
            try
            {
                if (m_newSession == null)
                {
                    return;
                }
                foreach (ControlDaSubscription currentSubscription in m_session.SubscriptionList)
                {
                    currentSubscription.DataChanged -= new DataChangedEventHandler(ControlSubscription_DataChange);
                }

                m_newSession.ShutdownRequest -= new ShutdownEventHandler(HandleSessionShutdownWithoutReconnection);
                m_newSession.Disconnect(new ExecutionOptions());
                m_session.Disconnect(new ExecutionOptions());

                foreach (ControlDaSubscription subscription in m_newSession.SubscriptionList)
                {
                    foreach (ControlDaItem item in subscription.ItemList)
                    {
                        subscription.RemoveDaItem(item);
                    }             //	end foreach
                    m_newSession.RemoveDaSubscription(subscription);
                }                 //	end foreach

                m_instance.RemoveDaSession(m_newSession);
                m_instance.Terminate();

                m_newSession = null;
            }
            catch (Exception exc)
            {
                m_instance.Trace(EnumTraceLevel.ERR, EnumTraceGroup.CLIENT, "DataControl.Stop", exc.ToString());
            }
        }
        //-
        #endregion

        #region Public Methods
        //----------------------

        /// <summary>
        /// Starts the <see cref="DataControl">DataControl.</see>
        /// </summary>
        /// <remarks>
        /// After starting the <B>DataControl</B> the client will be notified about the <see cref="ValueQT">value</see> changes for all the
        /// <see cref="ControlDaItem">items</see> selected in the configuration phase. If an item is bound to a
        ///	Windows Forms Control then the new values will be displayed in this one.
        /// </remarks>
        /// <include
        ///  file='TBNC.doc.xml'
        ///  path='//class[@name="DataControl"]/method[@name="Start"]/doc/*'
        /// />
        public void Start()
        {
            try
            {
                if (m_session == null)
                {
                    return;
                }
                this.Clear();

                if (this.BinaryLicenseDa != string.Empty)
                {
                    m_instance.Activate(EnumFeature.DA_CLIENT, this.BinaryLicenseDa);
                }

                if (this.BinaryLicenseXmlDa != string.Empty)
                {
                    m_instance.Activate(EnumFeature.DA_CLIENT, this.BinaryLicenseXmlDa);
                }

                m_instance.Initialize();

                m_newSession = new ControlDaSession(m_session.StoredUrl);
                m_newSession.Connect(false, true, new ExecutionOptions());

                m_newSession.ShutdownRequest += new ShutdownEventHandler(HandleSessionShutdownWithReconnection);

                if (m_session.SubscriptionList.Length == 0)
                {
                    return;
                }

                foreach (ControlDaSubscription currentSubscription in m_session.SubscriptionList)
                {
                    ControlDaSubscription controlSubscription = new ControlDaSubscription(
                        currentSubscription.StoredUpdateRate,
                        m_newSession);

                    if (controlSubscription.Valid)
                    {
                        controlSubscription.Name             = currentSubscription.StoredName;
                        controlSubscription.StoredName       = controlSubscription.Name;
                        controlSubscription.StoredUpdateRate = controlSubscription.RequestedUpdateRate;
                        controlSubscription.IsActivated      = currentSubscription.IsActivated;

                        controlSubscription.DataChanged += new DataChangedEventHandler(ControlSubscription_DataChange);
                        DaItem[] items = currentSubscription.ItemList;
                        for (int i = 0; i < items.Length; i++)
                        {
                            ControlDaItem controlItem = new ControlDaItem(
                                ((ControlDaItem)items[i]).StoredId,
                                controlSubscription);

                            this.Add(controlItem);
                        }                         //	end for

                        if (controlSubscription.IsActivated)
                        {
                            controlSubscription.Connect(true, true, new ExecutionOptions());
                        }         //	end if
                    }             //	end if
                }                 //	end foreach

                m_session.Handle = m_newSession.Handle;
            }
            catch (Exception exc)
            {
                m_instance.Trace(
                    EnumTraceLevel.ERR,
                    EnumTraceGroup.CLIENT,
                    "DataControl.Start",
                    exc.ToString());
            }
        }         //	end Start