예제 #1
0
        /// <summary>
        /// Creates a server handle for the selected item and reads the data.
        /// </summary>
        private void DoItemRead()
        {
            // get the attribute ids.
            if (m_attributeIDs == null)
            {
                m_attributeIDs = AttributesCTRL.GetAttributeIDs(true);
                return;
            }

            // create item (if necessary).
            TsCHdaItem item = m_trend.Items[m_item];

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

            // get the paramaters.
            TrendCTRL.Update(m_trend);

            // get the attributes.
            m_attributeIDs = AttributesCTRL.GetAttributeIDs(true);

            if (m_synchronous)
            {
                // read data.
                TsCHdaItemAttributeCollection results = m_trend.ReadAttributes(item, m_attributeIDs);

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

                // display results.
                ResultsCTRL.Initialize(m_server, results);

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

                // begin read data.
                TsCHdaResultCollection results = m_trend.ReadAttributes(
                    item,
                    m_attributeIDs,
                    null,
                    new TsCHdaReadAttributesCompleteEventHandler(OnReadComplete),
                    out m_request);

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

                // display initial results.
                AsyncResultsCTRL.Initialize(m_server, m_attributeIDs, results);
                m_asyncSent = true;
            }
        }
        /// <summary>
        /// Creates a server handle for the selected item and reads the data.
        /// </summary>
        private void DoItemRead()
        {
            // get the attribute ids.
            if (mAttributeIDs_ == null)
            {
                mAttributeIDs_ = attributesCtrl_.GetAttributeIDs(true);
                return;
            }

            // create item (if necessary).
            TsCHdaItem item = mTrend_.Items[mItem_];

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

            // get the paramaters.
            trendCtrl_.Update(mTrend_);

            // get the attributes.
            mAttributeIDs_ = attributesCtrl_.GetAttributeIDs(true);

            if (mSynchronous_)
            {
                // read data.
                TsCHdaItemAttributeCollection results = mTrend_.ReadAttributes(item, mAttributeIDs_);

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

                // display results.
                resultsCtrl_.Initialize(mServer_, results);

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

                // begin read data.
                TsCHdaResultCollection results = mTrend_.ReadAttributes(
                    item,
                    mAttributeIDs_,
                    null,
                    new TsCHdaReadAttributesCompleteEventHandler(OnReadComplete),
                    out mRequest_);

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

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