/// <summary>
        /// Prompts the user to select items and specify trend properties.
        /// </summary>
        public TsCHdaTrend ShowDialog(TsCHdaServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            mServer_  = server;
            mResults_ = null;

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

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

            browseCtrl_.Browse(mServer_, null);
            trendCtrl_.Initialize(trend, RequestType.None);
            itemsCtrl_.Initialize(mServer_, (OpcItem[])null);
            resultsCtrl_.Initialize(mServer_, mResults_);

            // update dialog state.
            SetState(false);

            // show dialog.
            if (ShowDialog() != DialogResult.OK)
            {
                return(null);
            }

            // create or update the trend.
            trendCtrl_.Update(trend);

            // add new items.
            if (mResults_ != null)
            {
                foreach (OpcItemResult item in mResults_)
                {
                    if (item.Result.Succeeded())
                    {
                        trend.Items.Add(new TsCHdaItem(item));
                    }
                }
            }

            // return new trend.
            return(trend);
        }
Пример #2
0
        /// <summary>
        /// Prompts the user to specify values to insert for an item.
        /// </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);
            valuesCtrl_.Initialize(mServer_, null);
            resultsCtrl_.Initialize(mServer_, mValues_, mResults_);
            asyncResultsCtrl_.Initialize(mServer_, null);

            // update dialog state.
            SetState();

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

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

            // return dialog result.
            return result;
        }
Пример #3
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>
        /// 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);
        }