Пример #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);
        }
Пример #2
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);
        }
        /// <summary>
        /// Called to disconnect from a server.
        /// </summary>
        public void OnDisconnect()
        {
            // disconnect server.
            if (server_ != null)
            {
                try       { server_.Disconnect(); }
                catch {}

                server_.Dispose();
                server_ = null;
            }

            // clear cache.
            cache_ = new Hashtable();

            // initialize controls.
            statusCtrl_.Start(null);
            trendsCtrl_.Initialize(null);
            valuesCtrl_.Initialize(null, null);
            outputCtrl_.Text = "";
        }