Exemple #1
0
        /// <summary>
        /// Called to connect to a server.
        /// </summary>
        public void OnConnect()
        {
            if (server_ == null)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;

            try
            {
                OpcUserIdentity credentials = null;

                do
                {
                    try
                    {
                        server_.ForceDa20Usage = forceDa20Usage_;
                        server_.Connect(new OpcConnectData(credentials, mProxy_));
                        break;
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }

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

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

                // initialize controls.
                statusCtrl_.Start(server_);
                updatesCtrl_.Initialize(server_);
                subscriptionCtrl_.Initialize(server_);
                selectServerCtrl_.OnConnect(server_);

                // register for shutdown events.
                server_.ServerShutdownEvent += Server_ServerShutdown;

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

            Cursor = Cursors.Default;
        }
Exemple #2
0
        /// <summary>
        /// Called to connect to a target.
        /// </summary>
        public void OnConnectTarget(OpcServer server)
        {
            if (m_target != null)
            {
                m_target.Disconnect();
                m_target.Dispose();
                m_target = null;
            }

            // use the specified server object directly.
            m_target = (TsCDaServer)server;

            Cursor = Cursors.WaitCursor;

            try
            {
                OpcUserIdentity credentials = null;

                do
                {
                    try
                    {
                        m_target.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_target.SetResultFilters((int)TsCDaResultFilter.All);

                // initialize controls.
                SelectTargetCTRL.OnConnect(m_target);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
                m_target = null;
            }

            Cursor = Cursors.Default;
        }
Exemple #3
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;
        }
Exemple #4
0
        /// <summary>
        /// Prompts user to edit request option parameters in a modal dialog.
        /// </summary>
        private void ShowDialog(TsCDaServer server, TsCDaSubscription subscription)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            // get supported locales.
            localeCtrl_.SetSupportedLocales(server.SupportedLocales);

            // set locale.
            string locale = (subscription == null)?server.Locale:subscription.Locale;

            localeCtrl_.Locale         = locale;
            localeSpecifiedCb_.Checked = locale != null;

            // get filters.
            int filters = (subscription == null)?server.Filters:subscription.Filters;

            itemNameCb_.Checked       = ((filters & (int)TsCDaResultFilter.ItemName) != 0);
            itemPathCb_.Checked       = ((filters & (int)TsCDaResultFilter.ItemPath) != 0);
            clientHandleCb_.Checked   = ((filters & (int)TsCDaResultFilter.ClientHandle) != 0);
            itemTimeCb_.Checked       = ((filters & (int)TsCDaResultFilter.ItemTime) != 0);
            errorTextCb_.Checked      = ((filters & (int)TsCDaResultFilter.ErrorText) != 0);
            diagnosticInfoCb_.Checked = ((filters & (int)TsCDaResultFilter.DiagnosticInfo) != 0);

            // show dialog.
            while (ShowDialog() == DialogResult.OK)
            {
                // update locale.
                try
                {
                    locale = null;

                    if (localeSpecifiedCb_.Checked)
                    {
                        locale = localeCtrl_.Locale;
                    }

                    if (subscription == null)
                    {
                        server.SetLocale(locale);
                    }
                    else
                    {
                        TsCDaSubscriptionState state = new TsCDaSubscriptionState();
                        state.Locale = locale;
                        subscription.ModifyState((int)TsCDaStateMask.Locale, state);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    continue;
                }

                // update filters.
                filters = 0;

                filters |= (itemNameCb_.Checked)?(int)TsCDaResultFilter.ItemName:0;
                filters |= (itemPathCb_.Checked)?(int)TsCDaResultFilter.ItemPath:0;
                filters |= (clientHandleCb_.Checked)?(int)TsCDaResultFilter.ClientHandle:0;
                filters |= (itemTimeCb_.Checked)?(int)TsCDaResultFilter.ItemTime:0;
                filters |= (errorTextCb_.Checked)?(int)TsCDaResultFilter.ErrorText:0;
                filters |= (diagnosticInfoCb_.Checked)?(int)TsCDaResultFilter.DiagnosticInfo:0;

                try
                {
                    if (subscription == null)
                    {
                        server.SetResultFilters(filters);
                    }
                    else
                    {
                        subscription.SetResultFilters(filters);
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                    continue;
                }

                // break out of loop if no error.
                break;
            }
        }