public MinimalServerMainForm()
        {
            InitializeComponent();

            _config = CreateOpcUaAppConfiguration();
            CheckApplicationInstanceCertificate(_config);

            _server = new StandardServer();
            _server.Start(_config);

            UrlCB.Items.Clear();

            foreach (EndpointDescription endpoint in _server.GetEndpoints())
            {
                if (UrlCB.FindStringExact(endpoint.EndpointUrl) == -1)
                {
                    UrlCB.Items.Add(endpoint.EndpointUrl);
                }
            }

            if (UrlCB.Items.Count > 0)
            {
                UrlCB.SelectedIndex = 0;
            }
        }
Exemple #2
0
        /// <summary>
        /// Handles the DropDown event of the UrlCB control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void UrlCB_DropDown(object sender, EventArgs e)
        {
            UrlCB.Items.Clear();

            // create a table of application descriptions that match the drop down entries.
            List <ApplicationDescription> lookupTable = new List <ApplicationDescription>();

            UrlCB.Tag = lookupTable;

            try
            {
                Cursor = Cursors.WaitCursor;

                try
                {
                    IList <string> serverUrls = FormUtils.DiscoverServers(m_configuration);

                    // populate the drop down list with the discovery URLs for the available servers.
                    for (int ii = 0; ii < serverUrls.Count; ii++)
                    {
                        // remove duplicates.
                        int index = UrlCB.FindStringExact(serverUrls[ii]);

                        if (index < 0)
                        {
                            UrlCB.Items.Add(serverUrls[ii]);
                        }
                    }
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            }
            catch (Exception)
            {
                // add the default URLs even if the LDS is not running.
                UrlCB.Items.Add("http://localhost:62540/Quickstarts/MethodsServer");
                UrlCB.Items.Add("opc.tcp://localhost:62541/Quickstarts/MethodsServer");
            }
        }
        /// <summary>
        /// Handles a drop down event for the URL control.
        /// </summary>
        private void UrlCB_DropDown(object sender, EventArgs e)
        {
            UrlCB.Items.Clear();

            // create a table of application descriptions that match the drop down entries.
            List <ApplicationDescription> lookupTable = new List <ApplicationDescription>();

            UrlCB.Tag = lookupTable;

            try
            {
                Cursor = Cursors.WaitCursor;

                try
                {
                    IList <string> serverUrls = ClientUtils.DiscoverServers(m_configuration);

                    // populate the drop down list with the discovery URLs for the available servers.
                    for (int ii = 0; ii < serverUrls.Count; ii++)
                    {
                        // remove duplicates.
                        int index = UrlCB.FindStringExact(serverUrls[ii]);

                        if (index < 0)
                        {
                            UrlCB.Items.Add(serverUrls[ii]);
                        }
                    }
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            }
            catch (Exception)
            {
                // ignore errors.
            }
        }
Exemple #4
0
        /// <summary>
        /// Creates a form which displays the status for a UA server.
        /// </summary>
        /// <param name="server">The server displayed in the form.</param>
        /// <param name="configuration">The configuration used to initialize the server.</param>
        public void Initialize(StandardServer server, ApplicationConfiguration configuration)
        {
            m_server                = server;
            m_configuration         = configuration;
            UpdateTimerCTRL.Enabled = true;

            // add the urls to the drop down.
            UrlCB.Items.Clear();

            foreach (EndpointDescription endpoint in m_server.GetEndpoints())
            {
                if (UrlCB.FindStringExact(endpoint.EndpointUrl) == -1)
                {
                    UrlCB.Items.Add(endpoint.EndpointUrl);
                }
            }

            if (UrlCB.Items.Count > 0)
            {
                UrlCB.SelectedIndex = 0;
            }
        }