/// <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;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create server handles for new items.
        /// </summary>
        private void DoRead()
        {
            // fetch the new trend parameters.
            trendCtrl_.Update(mTrend_);

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

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

            // read data.
            TsCHdaItemValueCollection[] results = mTrend_.Read(new TsCHdaItem[] { item });

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

            // save results.
            mValues_ = results;

            // display results.
            valuesCtrl_.Initialize(mServer_, mValues_[0]);
        }
        /// <summary>
        /// Runs all tests with the specified name and displays the results.
        /// </summary>
        public bool ShowDialog(TsCHdaServer server, TestData test)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            mServer_ = server;

            trendCtrl_.Initialize(test.Trend, RequestType.None);

            valuesLv_.Tag = test;

            if (test.Expected != null)
            {
                // add expected result.
                resultIdtb_.Text = test.Expected.Result.Name.Name;

                // add expected values to list view.
                UpdateValues();
            }

            if (ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            // update trend and expected values.
            trendCtrl_.Update(test.Trend);

            if (test.Expected != null)
            {
                // only update result if it does not have invalid characters.
                if (resultIdtb_.Text.IndexOfAny("() ".ToCharArray()) == -1)
                {
                    test.Expected.Result = new OpcResult(resultIdtb_.Text, "");
                }

                test.Expected.Clear();

                foreach (ListViewItem listItem in valuesLv_.Items)
                {
                    if (typeof(TsCHdaItemValue).IsInstanceOfType(listItem.Tag))
                    {
                        test.Expected.Add(listItem.Tag);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Synchronously eads the values from the server.
        /// </summary>
        private TsCHdaResultCollection[] SyncDelete(TsCHdaItem[] items)
        {
            // get request parameters from controls.
            trendCtrl_.Update(mTrend_);

            switch (mType_)
            {
            // synchronous delete raw.
            case RequestType.DeleteRaw:
            {
                OpcItemResult[] results = mTrend_.Delete(items);

                if (results != null)
                {
                    TsCHdaResultCollection[] collections = new TsCHdaResultCollection[results.Length];

                    for (int ii = 0; ii < results.Length; ii++)
                    {
                        collections[ii] = new TsCHdaResultCollection(results[ii]);
                        collections[ii].Add(new TsCHdaResult(results[ii]));
                    }

                    return(collections);
                }

                return(null);
            }

            // synchronous delete at time.
            case RequestType.DeleteAtTime:
            {
                return(mTrend_.DeleteAtTime(items));
            }
            }

            return(null);
        }
        /// <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;
            }
        }