예제 #1
0
        /// <summary>
        /// Prompts the use to select items for the read request.
        /// </summary>
        public TsCDaItemValueResult[] ShowDialog(TsCDaSubscription subscription, bool synchronous)
        {
            if (subscription == null)
            {
                throw new ArgumentNullException("subscription");
            }

            m_server       = subscription.Server;
            m_subscription = subscription;
            m_synchronous  = synchronous;

            BackBTN.Enabled          = false;
            NextBTN.Enabled          = true;
            CancelBTN.Visible        = true;
            DoneBTN.Visible          = false;
            OptionsBTN.Visible       = true;
            BrowseCTRL.Visible       = false;
            SubscriptionCTRL.Visible = true;
            ItemsCTRL.Visible        = true;
            ResultsCTRL.Visible      = false;

            SubscriptionCTRL.Initialize(m_subscription);
            ItemsCTRL.Initialize(m_server, null, m_subscription.Items);

            ShowDialog();

            return(m_values);
        }
예제 #2
0
        /// <summary>
        /// Called to connect to a server.
        /// </summary>
        public void OnConnect()
        {
            Cursor = Cursors.WaitCursor;

            try
            {
                OpcUserIdentity credentials = null;

                do
                {
                    try
                    {
                        m_server.ForceDa20Usage = _forceDa20Usage;
                        m_server.Connect(new OpcConnectData(credentials, m_proxy));
                        break;
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }

                    credentials = new NetworkCredentialsDlg().ShowDialog(credentials);
                }while (credentials != null);

                // select all filters by default.
                m_server.SetResultFilters((int)TsCDaResultFilter.All);

                // initialize controls.
                StatusCTRL.Start(m_server);
                UpdatesCTRL.Initialize(m_server);
                SubscriptionCTRL.Initialize(m_server);
                SelectServerCTRL.OnConnect(m_server);

                // register for shutdown events.
                m_server.ServerShutdownEvent += new OpcServerShutdownEventHandler(Server_ServerShutdown);

                // save settings.
                SaveSettings();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                TsCCpxComplexTypeCache.Server = m_server = null;
            }

            Cursor = Cursors.Default;
        }