Beispiel #1
0
        public static void Main(string[] args)
        {
            //// To simple use the configuration stored within the XML configuration file
            //// beside the server application you just need to load the configuration file as the
            //// following code does demonstrate.
            //// By default it is not necessary to explicitly configure an OPC UA server. But in case
            //// of advanced and productive scenarios you will have to.

            // There are different ways to load the server configuration.
            OpcApplicationConfiguration configuration = null;

            // 1st Way: Load server config using a file path.
            configuration = OpcApplicationConfiguration.LoadServerConfigFile(
                Path.Combine(Environment.CurrentDirectory, "ServerConfig.xml"));

            // 2nd Way: Load server config specified in a specific section of your App.config.
            configuration = OpcApplicationConfiguration.LoadServerConfig("Opc.UaFx.Server");

            // If the server domain name does not match localhost just replace it
            // e.g. with the IP address or name of the server machine.
            var server = new OpcServer(
                "opc.tcp://localhost:4840/SampleServer",
                new SampleNodeManager());

            // To take use of the loaded server configuration, just set it on the server instance.
            server.Configuration = configuration;

            server.Start();
            server.Stop();

            // In case you are using the OPC UA server (Service) Application class, you can explicitly
            // trigger loading a configuration file using the App.config as the following code does
            // demonstrate.
            var app = new OpcServerApplication(
                "opc.tcp://localhost:4840/SampleServer",
                new SampleNodeManager());

            app.LoadConfiguration();

            // Alternatively you can assign the manually loaded server configuration on the server
            // instance used by the application instance, as the following code does demonstrate.
            app.Server.Configuration = configuration;

            app.Run();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            string endpoint = DefaultEndpoint;

            if (args != null & args.Length > 0)
            {
                if (args[0].Contains("opc.tcp://"))
                {
                    Console.WriteLine("application started with arguments.");
                    endpoint = args[0];
                }
            }


            var app = new OpcServerApplication(endpoint, NodeManager = new ZementTechNodeManager());

            app.Started += Server_Started;
            LicenseInfo license = Opc.UaFx.Server.Licenser.LicenseInfo;

            Console.WriteLine("License expiration date: " + license.ExpiryDate);

            app.Run();
        }
        public static void Main(string[] args)
        {
            //// To simple use the in code configuration you just need to configure your server
            //// instance using the Configuration property of it.
            //// By default it is not necessary to explicitly configure an OPC UA server. But in case
            //// of advanced and productive scenarios you will have to.

            // If the server domain name does not match localhost just replace it
            // e.g. with the IP address or name of the server machine.
            var server = new OpcServer(
                "opc.tcp://*****:*****@"%LocalApplicationData%\My Application\App Certificates";
            securityConfiguration.RejectedCertificateStore.StorePath
                = @"%LocalApplicationData%\My Application\Rejected Certificates";
            securityConfiguration.TrustedIssuerCertificates.StorePath
                = @"%LocalApplicationData%\My Application\Trusted Issuer Certificates";
            securityConfiguration.TrustedPeerCertificates.StorePath
                = @"%LocalApplicationData%\My Application\Trusted Peer Certificates";

            //// It is not necessary that all certificate stores have to point to the same root
            //// directory as above. Each store can also point to a totally different directory.

            server.Configuration = configuration;

            // 3rd Way: Directly change the default configuration of the server instance using the
            //         Configuration property.
            server.Configuration.ServerConfiguration.MaxSessionCount = 10;

            server.Start();
            server.Stop();

            // In case you are using the OPC UA server (Service) Application class, you can directly
            // configure your server/application using the Configuration property of the
            // application instance as the following code does demonstrate.
            var app = new OpcServerApplication(
                "opc.tcp://localhost:4840/SampleServer",
                new SampleNodeManager());

            app.Configuration.ServerConfiguration.MaxSessionCount = 10;
            app.Run();
        }