コード例 #1
0
ファイル: Program.cs プロジェクト: Hpshboss/OpcuaCncControl
        public static int Main(string[] args)
        {
            #region Open a thread for pipeServer
            int      i;
            Thread[] servers = new Thread[Globals.numberThreads];

            Console.WriteLine("Waiting for client connect...\n");
            for (i = 0; i < Globals.numberThreads; i++)
            {
                servers[i] = new Thread(PipeServerThread);
                servers[i].Start();
            }
            #endregion
            Console.WriteLine("{0} OPC UA Reference Server", Utils.IsRunningOnMono() ? "Mono" : ".Net Core");

            // command line options
            bool showHelp   = false;
            bool autoAccept = false;

            Mono.Options.OptionSet options = new Mono.Options.OptionSet {
                { "h|help", "show this message and exit", h => showHelp = h != null },
                { "a|autoaccept", "auto accept certificates (for testing only)", a => autoAccept = a != null }
            };

            try
            {
                IList <string> extraArgs = options.Parse(args);
                foreach (string extraArg in extraArgs)
                {
                    Console.WriteLine("Error: Unknown option: {0}", extraArg);
                    showHelp = true;
                }
            }
            catch (OptionException e)
            {
                Console.WriteLine(e.Message);
                showHelp = true;
            }

            if (showHelp)
            {
                Console.WriteLine(Utils.IsRunningOnMono() ? "Usage: mono MonoReferenceServer.exe [OPTIONS]" : "Usage: dotnet ConsoleReferenceServer.dll [OPTIONS]");
                Console.WriteLine();

                Console.WriteLine("Options:");
                options.WriteOptionDescriptions(Console.Out);
                return((int)ExitCode.ErrorInvalidCommandLine);
            }

            MyRefServer server = new MyRefServer(autoAccept);
            server.Run();

            return((int)MyRefServer.ExitCode);
        }
コード例 #2
0
        public static async Task <int> Main(string[] args)
        {
            Console.WriteLine("{0} OPC UA Reference Server", Utils.IsRunningOnMono() ? "Mono" : ".Net Core");

            // command line options
            bool   showHelp   = false;
            bool   autoAccept = false;
            bool   console    = false;
            string password   = null;

            Mono.Options.OptionSet options = new Mono.Options.OptionSet {
                { "h|help", "show this message and exit", h => showHelp = h != null },
                { "a|autoaccept", "auto accept certificates (for testing only)", a => autoAccept = a != null },
                { "c|console", "log trace to console", c => console = c != null },
                { "p|password="******"optional password for private key", (string p) => password = p }
            };

            try
            {
                IList <string> extraArgs = options.Parse(args);
                foreach (string extraArg in extraArgs)
                {
                    Console.WriteLine("Error: Unknown option: {0}", extraArg);
                    showHelp = true;
                }
            }
            catch (OptionException e)
            {
                Console.WriteLine(e.Message);
                showHelp = true;
            }

            if (showHelp)
            {
                Console.WriteLine(Utils.IsRunningOnMono() ? "Usage: mono MonoReferenceServer.exe [OPTIONS]" : "Usage: dotnet ConsoleReferenceServer.dll [OPTIONS]");
                Console.WriteLine();

                Console.WriteLine("Options:");
                options.WriteOptionDescriptions(Console.Out);
                return((int)ExitCode.ErrorInvalidCommandLine);
            }

            var server = new MyRefServer()
            {
                AutoAccept = autoAccept,
                LogConsole = console,
                Password   = password
            };
            await server.Run().ConfigureAwait(false);

            return((int)server.ExitCode);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: zanettea/UA-.NETStandard
        public static int Main(string[] args)
        {
            Console.WriteLine(".Net Core OPC UA Reference Server");

            // command line options
            bool showHelp   = false;
            bool autoAccept = false;

            Mono.Options.OptionSet options = new Mono.Options.OptionSet {
                { "h|help", "show this message and exit", h => showHelp = h != null },
                { "a|autoaccept", "auto accept certificates (for testing only)", a => autoAccept = a != null }
            };

            try
            {
                IList <string> extraArgs = options.Parse(args);
                foreach (string extraArg in extraArgs)
                {
                    Console.WriteLine("Error: Unknown option: {0}", extraArg);
                    showHelp = true;
                }
            }
            catch (OptionException e)
            {
                Console.WriteLine(e.Message);
                showHelp = true;
            }

            if (showHelp)
            {
                Console.WriteLine("Usage: dotnet ConsoleReferenceServer.dll [OPTIONS]");
                Console.WriteLine();

                Console.WriteLine("Options:");
                options.WriteOptionDescriptions(Console.Out);
                return((int)ExitCode.ErrorInvalidCommandLine);
            }

            MyRefServer server = new MyRefServer(autoAccept);

            server.Run();

            return((int)MyRefServer.ExitCode);
        }
コード例 #4
0
        public static void Main(string[] args)
        {
            MyRefServer server = new MyRefServer();

            server.Start();
        }
コード例 #5
0
 public static void Main(string[] args)
 {
     MyRefServer server = new MyRefServer();
     server.Start();
 }