コード例 #1
0
ファイル: Program.cs プロジェクト: KPZNet/UANodeServer
        /// [Main]

        /// <summary>
        /// Prints the available EndpointDescriptions to the command line.
        /// </summary>
        /// <param name="server"></param>
        /// [PrintEndpoints]
        static void PrintEndpoints(GettingStartedServerManager server)
        {
            // print the endpoints.
            Console.WriteLine(string.Empty);
            Console.WriteLine("Listening at the following endpoints:");

            foreach (EndpointDescription endpoint in ApplicationInstance.Default.Endpoints)
            {
                StatusCode error = server.Application.GetEndpointStatus(endpoint);
                Console.WriteLine("   {0}: Status={1}", endpoint, error.ToString(true));
            }

            Console.WriteLine(string.Empty);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: KPZNet/UANodeServer
        static void Main(string[] args)
        {
            try
            {
                // The license file must be loaded from an embedded resource.
                ApplicationLicenseManager.AddProcessLicenses(System.Reflection.Assembly.GetExecutingAssembly(), "License.lic");

                // Start the server.
                Console.WriteLine("Starting Server.");
                GettingStartedServerManager server = new GettingStartedServerManager();
                //***********************************************************************
                // The following function can be called to configure the server from code
                // This will disable the configuration settings from app.config file
                //ConfigureOpcUaApplicationFromCode();
                //***********************************************************************
                ApplicationInstance.Default.AutoCreateCertificate = true;
                ApplicationInstance.Default.Start(server, null, server);

                // Print endpoints for information.
                PrintEndpoints(server);

                // Block until the server exits.
                Console.WriteLine("Press <enter> to exit the program.");
                Console.ReadLine();

                // Stop the server.
                Console.WriteLine("Stopping Server.");
                server.Stop();
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: {0}", e.Message);
                Console.WriteLine("Press <enter> to exit the program.");
                Console.ReadLine();
            }
        }