Ejemplo n.º 1
0
        /// <summary>
        /// Prompts the user to select an item and specify trend properties.
        /// </summary>
        public TsCHdaItemValueCollection ShowDialog(TsCHdaServer server, RequestType type, bool synchronous)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            mServer_      = server;
            mType_        = type;
            mSynchronous_ = synchronous;
            mSingleItem_  = true;
            mResults_     = null;

            // create new trend.
            mTrend_ = new TsCHdaTrend(mServer_);

            // set reasonable defaults.
            mTrend_.StartTime = new TsCHdaTime("YEAR");
            mTrend_.EndTime   = new TsCHdaTime("YEAR+1H");

            browseCtrl_.Browse(mServer_, null);
            trendItemsCtrl_.Initialize(mTrend_, false, null);
            trendCtrl_.Initialize(mTrend_, type);
            itemsCtrl_.Initialize(null);
            resultsCtrl_.Initialize(mServer_, null);
            asyncResultsCtrl_.Initialize(mServer_, null);

            // update dialog state.
            SetState();

            // show dialog.
            bool result = (ShowDialog() == DialogResult.OK);

            // release item handles.
            mTrend_.ClearItems();

            // return item values.
            return((result)?mResults_[0]:null);
        }
        /// <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);
        }
        /// <summary>
        /// Prompts the user to select attributes to read for an item.
        /// </summary>
        public TsCHdaItemAttributeCollection ShowDialog(
            TsCHdaServer server,
            OpcItem item,
            TsCHdaTime startTime,
            TsCHdaTime endTime,
            bool synchronous)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            mServer_      = server;
            mItem_        = item;
            mFixedItem_   = item != null;
            mSynchronous_ = synchronous;
            mResults_     = null;

            // create new trend.
            mTrend_ = new TsCHdaTrend(mServer_);

            // set reasonable defaults.
            mTrend_.StartTime = startTime;
            mTrend_.EndTime   = endTime;

            browseCtrl_.Browse(mServer_, null);
            trendCtrl_.Initialize(mTrend_, RequestType.ReadAttributes);
            attributesCtrl_.Initialize(mServer_, null);
            resultsCtrl_.Initialize(mServer_, mResults_);
            asyncResultsCtrl_.Initialize(mServer_, null);

            // update dialog state.
            SetState();

            // show dialog.
            bool result = (ShowDialog() == DialogResult.OK);

            // release item handles.
            mTrend_.ClearItems();

            // return item values.
            return((result)?mResults_:null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Prompts the user to specified values to replace.
        /// </summary>
        public bool ShowDialog(TsCHdaServer server, OpcItem item, bool synchronous)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            mServer_      = server;
            mSynchronous_ = synchronous;
            mItem_        = item;
            mValues_      = null;
            mResults_     = null;

            // create new trend.
            mTrend_ = new TsCHdaTrend(mServer_);

            // set reasonable defaults.
            mTrend_.StartTime = new TsCHdaTime("YEAR");
            mTrend_.EndTime   = new TsCHdaTime("YEAR+1H");

            browseCtrl_.Browse(mServer_, null);
            trendCtrl_.Initialize(mTrend_, RequestType.ReadRaw);
            valuesCtrl_.Initialize(mServer_, null);
            asyncResultsCtrl_.Initialize(mServer_, null);
            resultsCtrl_.Initialize(mServer_, null);

            // update dialog state.
            SetState();

            // show dialog.
            bool result = (ShowDialog() == DialogResult.OK);

            // release item handles.
            mTrend_.ClearItems();

            // return item values.
            return(result);
        }