Exemplo n.º 1
0
        /// <summary>
        /// Creates a server handle for the selected item and reads the data.
        /// </summary>
        private void DoItemRead()
        {
            // create item (if necessary).
            TsCHdaItem item = m_trend.Items[m_item];

            if (item == null)
            {
                item = m_trend.AddItem(m_item);
            }

            // get request parameters from controls.
            TrendCTRL.Update(m_trend);

            if (m_synchronous)
            {
                // read data.
                TsCHdaAnnotationValueCollection[] results = m_trend.ReadAnnotations(new TsCHdaItem[] { item });

                if (results == null || results.Length != 1)
                {
                    ////throw new InvalidResponseException();
                }

                // display results.
                ItemsCTRL.Initialize(results);

                // save results.
                m_results = results;
            }
            else
            {
                // check if already waiting for results.
                if (m_asyncSent)
                {
                    return;
                }

                // begin read data.
                OpcItemResult[] results = m_trend.ReadAnnotations(
                    new TsCHdaItem[] { item },
                    null,
                    new TsCHdaReadAnnotationsCompleteEventHandler(OnReadComplete),
                    out m_request);

                if (results == null || results.Length != 1)
                {
                    ////throw new InvalidResponseException();
                }

                // display initial results.
                AsyncResultsCTRL.Initialize(m_server, results);
                m_asyncSent = true;
            }
        }
        /// <summary>
        /// Creates a server handle for the selected item and reads the data.
        /// </summary>
        private void DoItemRead()
        {
            // create item (if necessary).
            TsCHdaItem item = mTrend_.Items[mItem_];

            if (item == null)
            {
                item = mTrend_.AddItem(mItem_);
            }

            // get request parameters from controls.
            trendCtrl_.Update(mTrend_);

            if (mSynchronous_)
            {
                // read data.
                TsCHdaAnnotationValueCollection[] results = mTrend_.ReadAnnotations(new TsCHdaItem[] { item });

                if (results == null || results.Length != 1)
                {
                    ////throw new InvalidResponseException();
                }

                // display results.
                itemsCtrl_.Initialize(results);

                // save results.
                mResults_ = results;
            }
            else
            {
                // check if already waiting for results.
                if (mAsyncSent_)
                {
                    return;
                }

                // begin read data.
                OpcItemResult[] results = mTrend_.ReadAnnotations(
                    new TsCHdaItem[] { item },
                    null,
                    new TsCHdaReadAnnotationsCompleteEventHandler(OnReadComplete),
                    out mRequest_);

                if (results == null || results.Length != 1)
                {
                    ////throw new InvalidResponseException();
                }

                // display initial results.
                asyncResultsCtrl_.Initialize(mServer_, results);
                mAsyncSent_ = true;
            }
        }