public static void Main(string[] args)
        {
            // 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());

            // By default an OPC UA server uses the ACL for anonymous authentication. To
            // support user name and password based authentication the UserName ACL needs
            // to be enabled.
            server.Security.UserNameAcl.IsEnabled = true;

            // To register a specific user name and password pair add that entry to the
            // UserName ACL of the OPC UA server.
            var entry = server.Security.UserNameAcl.AddEntry("username", "password");

            // Additionally it is possible to allow and deny specific operations on the entry.
            // By default all operations are enabled on the entry.
            entry.Deny(OpcRequestType.Write);

            server.Start();
            Console.ReadKey(true);
            server.Stop();
        }
        public static void Main(string[] args)
        {
            var nodeManager = new SampleNodeManager();

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

            server.Start();
            //// NOTE: All AE specific code will be found in the SampleNodeManager.cs.

            using (var semaphore = new SemaphoreSlim(0)) {
                var thread = new Thread(() => nodeManager.Simulate(semaphore));
                thread.Start();

                Console.WriteLine("OPC UA Server is running...");
                Console.ReadKey(true);

                semaphore.Release();
                thread.Join();

                server.Stop();
            }
        }
Beispiel #3
0
        public static void Main(string[] args)
        {
            // If the server domain name does not match localhost just replace it
            // e.g. with the IP address or name of the server machine.
            OpcServer server = new OpcServer(
                "opc.tcp://localhost:4840/SampleServer",
                new SampleNodeManager());

            //// NOTE: All HDA specific code will be found in the SampleNodeManager.cs.

            server.Start();
            Console.ReadKey(true);
            server.Stop();
        }
Beispiel #4
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();
        }
        public static void Main(string[] args)
        {
            var manager = new SampleNodeManager();

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

            //// NOTE: All HDA specific code will be found in the SampleNodeManager.cs.

            server.Start();
            CreateHistoryEntries(manager);

            Console.Write("Server started - press any key to exit.");
            Console.ReadKey(true);

            server.Stop();
        }
Beispiel #6
0
 public void Dispose()
 {
     _server?.Stop();
     _server?.Dispose();
     _server = null;
 }
        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();
        }