/// <summary> /// Usage message. /// </summary> private static void Usage(Mono.Options.OptionSet options) { // show usage Logger.Information(""); Logger.Information("Usage: {0}.exe [<options>]", Assembly.GetEntryAssembly().GetName().Name); Logger.Information(""); Logger.Information($"{ProgramName} to run test operations against OPC UA servers."); Logger.Information("To exit the application, just press CTRL-C while it is running."); Logger.Information(""); Logger.Information("There are a couple of environment variables which can be used to control the application:"); Logger.Information("_GW_LOGP: sets the filename of the log file to use"); Logger.Information("_TPC_SP: sets the path to store certificates of trusted stations"); Logger.Information(""); Logger.Information("Command line arguments overrule environment variable settings."); Logger.Information(""); // output the options Logger.Information("Options:"); StringBuilder stringBuilder = new StringBuilder(); StringWriter stringWriter = new StringWriter(stringBuilder); options.WriteOptionDescriptions(stringWriter); string[] helpLines = stringBuilder.ToString().Split("\n"); foreach (var line in helpLines) { Logger.Information(line); } }
/// <summary> /// Usage message. /// </summary> private static void Usage(Mono.Options.OptionSet options) { // show usage Logger.Information(""); Logger.Information($"{ProgramName} V{FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion}"); Logger.Information($"Informational version: V{(Attribute.GetCustomAttribute(Assembly.GetEntryAssembly(), typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute).InformationalVersion}"); Logger.Information(""); Logger.Information("Usage: {0}.exe [<options>]", Assembly.GetEntryAssembly().GetName().Name); Logger.Information(""); Logger.Information("OPC UA PLC for different data simulation scenarios"); Logger.Information("To exit the application, just press CTRL-C while it is running."); Logger.Information(""); Logger.Information("To specify a list of strings, please use the following format:"); Logger.Information("\"<string 1>,<string 2>,...,<string n>\""); Logger.Information("or if one string contains commas:"); Logger.Information("\"\"<string 1>\",\"<string 2>\",...,\"<string n>\"\""); Logger.Information(""); // output the options Logger.Information("Options:"); StringBuilder stringBuilder = new StringBuilder(); System.IO.StringWriter stringWriter = new System.IO.StringWriter(stringBuilder); options.WriteOptionDescriptions(stringWriter); string[] helpLines = stringBuilder.ToString().Split("\r\n"); foreach (var line in helpLines) { Logger.Information(line); } return; }
/// <summary> /// Process a command line of the console sample application. /// </summary> public static string ProcessCommandLine( TextWriter output, string[] args, Mono.Options.OptionSet options, ref bool showHelp, bool noExtraArgs = true) { IList <string> extraArgs = null; try { extraArgs = options.Parse(args); if (noExtraArgs) { foreach (string extraArg in extraArgs) { output.WriteLine("Error: Unknown option: {0}", extraArg); showHelp = true; } } } catch (OptionException e) { output.WriteLine(e.Message); showHelp = true; } if (showHelp) { options.WriteOptionDescriptions(output); throw new ErrorExitException("Invalid Commandline or help requested.", ExitCode.ErrorInvalidCommandLine); } return(extraArgs.FirstOrDefault()); }
/// <summary> /// Usage message. /// </summary> private static void Usage(Mono.Options.OptionSet options, string[] args) { // show usage Logger.Information(""); string commandLine = string.Empty; foreach (var arg in args) { commandLine = commandLine + " " + arg; } Logger.Information($"Command line: {commandLine}"); Logger.Information(""); Logger.Information(""); Logger.Information("Usage: {0}.exe [<options>]", Assembly.GetEntryAssembly().GetName().Name); Logger.Information(""); // output the options Logger.Information("Options:"); StringBuilder stringBuilder = new StringBuilder(); StringWriter stringWriter = new StringWriter(stringBuilder); options.WriteOptionDescriptions(stringWriter); string[] helpLines = stringBuilder.ToString().Split("\r\n"); foreach (var line in helpLines) { Logger.Information(line); } }
/// <summary> /// Usage message. /// </summary> private static void Usage(Mono.Options.OptionSet options) { // show usage WriteLine(); WriteLine("Usage: {0}.exe <applicationname> [<iothubconnectionstring>] [<options>]", Assembly.GetEntryAssembly().GetName().Name); WriteLine(); WriteLine("OPC Edge Publisher to subscribe to configured OPC UA servers and send telemetry to Azure IoTHub."); WriteLine("To exit the application, just press ENTER while it is running."); WriteLine(); WriteLine("applicationname: the OPC UA application name to use, required"); WriteLine(" The application name is also used to register the publisher under this name in the"); WriteLine(" IoTHub device registry."); WriteLine(); WriteLine("iothubconnectionstring: the IoTHub owner connectionstring, optional"); WriteLine(); WriteLine("There are a couple of environment variables which can be used to control the application:"); WriteLine("_HUB_CS: sets the IoTHub owner connectionstring"); WriteLine("_GW_LOGP: sets the filename of the log file to use"); WriteLine("_TPC_SP: sets the path to store certificates of trusted stations"); WriteLine("_GW_PNFP: sets the filename of the publishing configuration file"); WriteLine(); WriteLine("Command line arguments overrule environment variable settings."); WriteLine(); // output the options WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); }
private static void ShowHelp(Mono.Options.OptionSet p) { Console.WriteLine("Usage: UaTypeGenerator.exe [OPTIONS]+"); Console.WriteLine(); Console.WriteLine("Options:"); p.WriteOptionDescriptions(Console.Out); }
/// <summary> /// Usage message. /// </summary> private static void Usage(Mono.Options.OptionSet options, string[] args = null) { Logger.Information(""); // show the args if (args != null) { string commandLine = string.Empty; foreach (var arg in args) { commandLine = commandLine + " " + arg; } Logger.Information($"Command line: {commandLine}"); } Logger.Information(""); Logger.Information($"{ProgramName} V{FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion}"); Logger.Information($"Informational version: V{(Attribute.GetCustomAttribute(Assembly.GetEntryAssembly(), typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute).InformationalVersion}"); Logger.Information(""); Logger.Information("Usage: {0} [<options>]", Assembly.GetEntryAssembly().GetName().Name); Logger.Information(""); // output the options Logger.Information("Options:"); StringBuilder stringBuilder = new StringBuilder(); StringWriter stringWriter = new StringWriter(stringBuilder); options.WriteOptionDescriptions(stringWriter); string[] helpLines = stringBuilder.ToString().Split("\n"); foreach (var line in helpLines) { Logger.Information(line); } }
/// <summary> /// Usage message. /// </summary> private static void Usage(Mono.Options.OptionSet options, string[] args) { // show usage Logger.Information(""); string commandLine = string.Empty; foreach (var arg in args) { commandLine = commandLine + " " + arg; } Logger.Information($"Command line: {commandLine}"); Logger.Information(""); Logger.Information(""); Logger.Information("Usage: dotnet NetCoreConsoleClient.dll [OPTIONS]"); Logger.Information(""); // output the options Logger.Information("Options:"); StringBuilder stringBuilder = new StringBuilder(); StringWriter stringWriter = new StringWriter(stringBuilder); options.WriteOptionDescriptions(stringWriter); string[] helpLines = stringBuilder.ToString().Split("\r\n"); foreach (var line in helpLines) { Logger.Information(line); } }
public static int Main(string[] args) { Console.WriteLine( (Utils.IsRunningOnMono() ? "Mono" : ".Net Core") + " OPC UA Console Server sample"); // command line options bool showHelp = false; int stopTimeout = 0; bool autoAccept = false; string reverseConnectUrlString = null; Uri reverseConnectUrl = 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 }, { "t|timeout=", "the number of seconds until the server stops.", (int t) => stopTimeout = t }, { "r|reverse=", "a url for a reverse connection", (string r) => reverseConnectUrlString = r } }; try { IList <string> extraArgs = options.Parse(args); foreach (string extraArg in extraArgs) { Console.WriteLine("Error: Unknown option: {0}", extraArg); showHelp = true; } if (reverseConnectUrlString != null) { reverseConnectUrl = new Uri(reverseConnectUrlString); } } catch (OptionException e) { Console.WriteLine(e.Message); showHelp = true; } if (showHelp) { Console.WriteLine(Utils.IsRunningOnMono() ? "Usage: mono NetCoreConsoleServer.exe [OPTIONS]" : "Usage: dotnet NetCoreConsoleServer.dll [OPTIONS]"); Console.WriteLine(); Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return((int)ExitCode.ErrorInvalidCommandLine); } MySampleServer server = new MySampleServer(autoAccept, stopTimeout, reverseConnectUrl); server.Run(); return((int)MySampleServer.ExitCode); }
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); }
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); }
public static int Main(string[] args) { Console.WriteLine(Name); // command line options bool showHelp = false; var opcVaultOptions = new OpcVaultApiOptions(); var azureADOptions = new OpcVaultAzureADOptions(); Mono.Options.OptionSet options = new Mono.Options.OptionSet { { "v|vault=", "OpcVault Url", g => opcVaultOptions.BaseAddress = g }, { "r|resource=", "OpcVault Resource Id", r => opcVaultOptions.ResourceId = r }, { "c|clientid=", "AD Client Id", c => azureADOptions.ClientId = c }, { "s|secret=", "AD Client Secret", s => azureADOptions.ClientSecret = s }, { "a|authority=", "Authority", a => azureADOptions.Authority = a }, { "t|tenantid=", "Tenant Id", t => azureADOptions.TenantId = t }, { "h|help", "show this message and exit", h => showHelp = h != 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 Microsoft.Azure.IIoT.OpcUa.Modules.Vault.dll [OPTIONS]"); Console.WriteLine(); Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return((int)ExitCode.ErrorInvalidCommandLine); } var server = new VaultGlobalDiscoveryServer(); server.Run(opcVaultOptions, azureADOptions); return((int)VaultGlobalDiscoveryServer.ExitCode); }
/// <summary> /// The main entry point for the application. /// </summary> public static int Main(string[] args) { Console.WriteLine("SampleCompany {0} OPC UA Sample Server", Utils.IsRunningOnMono() ? "Mono" : ".NET Core"); // command line options var showHelp = false; var stopTimeout = 0; var autoAccept = false; var 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 }, { "t|timeout=", "the number of seconds until the server stops.", (int t) => stopTimeout = t }, }; try { IList <string> extraArgs = options.Parse(args); foreach (var 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 SampleCompany.SampleServer.exe [OPTIONS]" : "Usage: dotnet SampleCompany.SampleServer.dll [OPTIONS]"); Console.WriteLine(); Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return((int)ExitCode.ErrorInvalidCommandLine); } var server = new MySampleServer(autoAccept, stopTimeout); server.Run(); return((int)MySampleServer.ExitCode); }
public static int Main(string[] args) { Console.WriteLine("OPC UA Reference Server.Net Core"); // command line options bool showHelp = false; bool autoAccept = false; bool console = 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 }, { "c|console", "log trace to console", c => console = c != 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, console); server.Run(); return((int)MyRefServer.ExitCode); }
public static int Main(string[] args) { Console.WriteLine(".Net Core OPC UA Global Discovery Server"); // command line options bool showHelp = false; Mono.Options.OptionSet options = new Mono.Options.OptionSet { { "h|help", "show this message and exit", h => showHelp = h != 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 NetCoreGlobalDiscoveryServer.dll [OPTIONS]"); Console.WriteLine(); Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return((int)ExitCode.ErrorInvalidCommandLine); } NetCoreGlobalDiscoveryServer server = new NetCoreGlobalDiscoveryServer(); server.Run(); return((int)NetCoreGlobalDiscoveryServer.ExitCode); }
/// <summary> /// Usage message. /// </summary> private static void Usage(Mono.Options.OptionSet options) { // show usage Logger.Information(""); Logger.Information("Usage: {0}.exe [<options>]", Assembly.GetEntryAssembly().GetName().Name); Logger.Information(""); Logger.Information("OPC Publisher node configuration tool."); Logger.Information("To exit the application, just press CTRL-C while it is running."); Logger.Information(""); // output the options Logger.Information("Options:"); StringBuilder stringBuilder = new StringBuilder(); StringWriter stringWriter = new StringWriter(stringBuilder); options.WriteOptionDescriptions(stringWriter); string[] helpLines = stringBuilder.ToString().Split("\n"); foreach (var line in helpLines) { Logger.Information(line); } }
/// <summary> /// Usage message. /// </summary> private static void Usage(Mono.Options.OptionSet options) { // show usage Logger.Information(""); Logger.Information("Usage: {0}.exe [<options>]", Assembly.GetEntryAssembly().GetName().Name); Logger.Information(""); Logger.Information("OPC UA Connectedfactory station for the factory simulation"); Logger.Information("To exit the application, just press ENTER while it is running."); Logger.Information(""); // output the options Logger.Information("Options:"); StringBuilder stringBuilder = new StringBuilder(); System.IO.StringWriter stringWriter = new System.IO.StringWriter(stringBuilder); options.WriteOptionDescriptions(stringWriter); string[] helpLines = stringBuilder.ToString().Split("\r\n"); foreach (var line in helpLines) { Logger.Information(line); } return; }
public Collage(string [] args) { bool showHelp = false; var options = new Mono.Options.OptionSet() { { "cols=", (int cols) => columns = cols }, { "cellsize=", (int cell) => cellsize = cell }, { "output=", (string file) => output = file }, { "h|?|help", v => showHelp = true }, }; void Help() { Console.WriteLine("collage [options] DIRECTORY\n" + $"Default output is {output}, columns {columns}, cell size {cellsize}"); options.WriteOptionDescriptions(Console.Error); Environment.Exit(0); } if (showHelp) { Help(); } var dir = options.Parse(args).FirstOrDefault(); if (dir == null) { Help(); } if (dir != null) { directory = dir; } }
static int Main(string[] args) { LogHandler.WriteLogFile("GrainCloud OPC-UA Client started"); // command line options bool showHelp = false; int stopTimeout = Timeout.Infinite; bool autoAccept = true; 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 }, { "t|timeout=", "the number of seconds until the client stops.", (int t) => stopTimeout = t } }; IList <string> extraArgs = null; try { extraArgs = options.Parse(args); if (extraArgs.Count > 1) { foreach (string extraArg in extraArgs) { LogHandler.WriteLogFile("Error: Unknown option: " + extraArg); showHelp = true; } } } catch (OptionException e) { LogHandler.WriteLogFile(e.Message); showHelp = true; } if (showHelp) { // show some app description message LogHandler.WriteLogFile(Utils.IsRunningOnMono() ? "Usage: mono MonoConsoleClient.exe [OPTIONS] [ENDPOINTURL]" : "Usage: dotnet NetCoreConsoleClient.dll [OPTIONS] [ENDPOINTURL]"); // output the options LogHandler.WriteLogFile("Options:"); options.WriteOptionDescriptions(Console.Out); return((int)ExitCode.ErrorInvalidCommandLine); } IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true) .Build(); // Read configuration settings.OPCUAServerAddress = config["OPCUAServerAddress"]; settings.CloudLogFolder = config["CloudLogFolder"]; settings.DataBaseFileAndPath = config["DataBaseFileAndPath"]; settings.PlantRefId = config["PlantRefId"]; settings.AddIDToTagName = bool.Parse(config["AddIDToTagName"]); settings.UseRPiTime = bool.Parse(config["UseRPiTime"]); settings.IgnoreTags = config .GetSection("IgnoreTags") .GetChildren() .Select(x => x.Value) .ToArray(); //CleanDB db = new CleanDB(); //db.CleanCrap(); OpcUaClient client = new OpcUaClient(settings.OPCUAServerAddress, autoAccept, stopTimeout); client.Run(); LogHandler.WriteLogFile("Process exit" + ((int)OpcUaClient.ExitCode).ToString()); return((int)OpcUaClient.ExitCode); }
/// <summary> <!-- run {{{1 --> define the Mono.Options.OptionSet /// and parse the command line with it. /// </summary> public static bool run( String[] args, out string droot, out string ftop, out string fout ) { var ret = 0; string _ftop = "source.md", _fout = "temp.md", msg = ""; droot = "."; var suite = new Mono.Options.OptionSet() { string_version(), "usage: prepandoc.exe [options]+ [directory] [header] [output]", " directory: document search directory", " header-file: markdown file for the document header", " output-file: file name for markdown output", " [options]", /// <remarks> option `-h` or `--help` /// : - output help message /// </remarks> { "h|help", "output this help message.", v => { ret = 1; } }, /// <remarks> option `-v` or `--verbose` /// : - set the output log-level. /// - it is equivalent to change logging.__level__. /// </remarks> { "v=|verbose=", "verbose level (0-99)", (int?v) => { var l = v.HasValue ? v.Value: logging.__level__; if (l < 0 || l > 99) { ret = 1; } logging.__level__ = l; } }, /// <remarks> option `-b` or `--header` /// : - specify header markdown file before parse sources. /// </remarks> { "b=|header=", "output markdown file before parse sources.", (string v) => { _ftop = parse_string(v, "source.md"); msg += "\nspecified header file: " + _ftop; } }, /// <remarks> option `-o` or `--output` /// : - the file name of markdown output. /// </remarks> { "o=|output=", "file name of the markdown output", (string v) => { _fout = parse_string(v, "temp.md"); msg += "\nspecified output file: " + _fout; } }, /// <remarks> option `-e` or `--encoding` /// : - specify the input files encoding, /// all of source files open with this encoding. /// - this is equivalent to change `Config.encoding` /// </remarks> { "e=|encoding=", "source file encoding.", (string v) => { cfg.enc = v != null?System.Text.Encoding.GetEncoding(v) : cfg.enc; msg += "\nspecified encoding: " + cfg.enc.ToString(); } }, /// <remarks> option `-a` or `--attribute` /// : - specify the XML attribute name /// - this option use with `--article-tag` option /// </remarks> { "a=|attribute=", "attribute name to extract document.", (string v) => { cfg.attr_article = v != null ? v: cfg.attr_article; msg += "\nspecified attirbute: " + cfg.attr_article; } }, /// <remarks> option `-c` or `--css` /// : - the embedded CSS file name in markdown. /// </remarks> { "c=|css=", "CSS file name for markdown.", (string v) => { cfg.css_file_name = v != null ? v: cfg.css_file_name; msg += "\nspecified CSS: " + cfg.css_file_name; } }, /// <remarks> option `-E` or `--empty-block` /// : - enable/disable to output the empty blocks into markdown. /// </remarks> { "E=|empty-block=", "output empty block.", (string v) => { cfg.f_output_empty_block = parse_boolean(v, false); msg += "\nspecified empty block: " + cfg.f_output_empty_block.ToString(); } }, /// <remarks> option `-O` or `--output-tags` /// : - tag-name to output into markdown. /// </remarks> { "O=|output-tags=", "output tag-name.", (string v) => { cfg.tags_output = parse_tags(v, cfg.tags_output); msg += "\nspecified output tags: " + String.Join(",", cfg.tags_output); } }, /// <remarks> option `-A` or `--article-tags` /// : - tag-name to output into markdown (with attributes). /// - this tag is not output without attribute, /// attribute name can be specified with `--attribute` /// option. /// </remarks> { "A=|article-tags=", "output tag-name with attribute.", (string v) => { cfg.tags_article = parse_tags(v, cfg.tags_article); msg += "\nspecified output tags with attribute: " + String.Join(",", cfg.tags_article); } }, /// <remarks> option `--version` /// : - output the version message and then exit. /// </remarks> { "version", "output version string.", v => { ret = 2; } } }; List <string> extra = null; try { extra = suite.Parse(args); } catch (OptionException e) { Console.WriteLine(e.Message); ret = 1; } ftop = _ftop; fout = _fout; if (ret == 1) { suite.WriteOptionDescriptions(Console.Out); return(true); } else if (ret == 2) { Console.WriteLine(string_version()); return(true); } if (extra != null && extra.Count >= 1 && extra[0].Length > 0) { droot = extra[0]; msg += "\nupdate search directory: " + droot; } else { msg += "\nsearch directory: " + droot; } if (extra != null && extra.Count >= 2 && extra[1].Length > 0) { ftop = extra[1]; msg += "\nupdate header file: " + ftop; } if (extra != null && extra.Count >= 3 && extra[2].Length > 0) { fout = extra[2]; msg += "\nupdate output file: " + fout; } if (msg != "") { Console.WriteLine(msg.Substring(1)); } return(false); }
public static int Main(string[] args) { Console.WriteLine( (Utils.IsRunningOnMono() ? "Mono" : ".Net Core") + " OPC UA Console Client sample"); // command line options bool showHelp = false; int stopTimeout = Timeout.Infinite; 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 }, { "t|timeout=", "the number of seconds until the client stops.", (int t) => stopTimeout = t } }; IList <string> extraArgs = null; try { extraArgs = options.Parse(args); if (extraArgs.Count > 1) { 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) { // show some app description message Console.WriteLine(Utils.IsRunningOnMono() ? "Usage: mono MonoConsoleClient.exe [OPTIONS] [ENDPOINTURL]" : "Usage: dotnet NetCoreConsoleClient.dll [OPTIONS] [ENDPOINTURL]"); Console.WriteLine(); // output the options Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return((int)ExitCode.ErrorInvalidCommandLine); } string endpointURL; if (extraArgs.Count == 0) { // use OPC UA .Net Sample server endpointURL = "opc.tcp://localhost:51210/UA/SampleServer"; } else { endpointURL = extraArgs[0]; } MySampleClient client = new MySampleClient(endpointURL, autoAccept, stopTimeout); client.Run(); return((int)MySampleClient.ExitCode); }
public static int Main(string[] args) { Console.WriteLine(".Net Core OPC UA Complex Types Client sample"); // command line options bool showHelp = false; int stopTimeout = Timeout.Infinite; bool autoAccept = false; bool writeComplexInt = false; bool noTypes = false; bool noBrowse = false; bool verbose = false; bool json = false; bool jsonReversible = false; string username = null; string pw = null; string reverseConnectUrlString = null; Uri reverseConnectUrl = 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 }, { "t|timeout=", "the number of seconds until the client stops.", (int t) => stopTimeout = t }, { "w|writeint", "Read and increment all complex types with an Int32.", w => writeComplexInt = w != null }, { "n|notypes", "Do not load the type system dictionary from the server.", n => noTypes = n != null }, { "b|nobrowse", "Do not browse the address space of the server.", n => noBrowse = n != null }, { "u|username="******"Username to access server.", (string n) => username = n }, { "p|password="******"Password to access server.", (string n) => pw = n }, { "v|verbose", "Verbose output.", v => verbose = v != null }, { "j|json", "Print custom nodes as Json.", j => json = j != null }, { "r|jsonreversible", "Use Json reversible encoding.", r => jsonReversible = r != null }, { "rc|reverseconnect=", "Connect using the reverse connection.", (string url) => reverseConnectUrlString = url }, }; IList <string> extraArgs = null; try { extraArgs = options.Parse(args); if (extraArgs.Count > 1) { foreach (string extraArg in extraArgs) { Console.WriteLine("Error: Unknown option: {0}", extraArg); showHelp = true; } } if (reverseConnectUrlString != null) { reverseConnectUrl = new Uri(reverseConnectUrlString); } } catch (OptionException e) { Console.WriteLine(e.Message); showHelp = true; } if (showHelp) { // show some app description message Console.WriteLine("Usage: dotnet NetCoreConsoleClient.dll [OPTIONS] [ENDPOINTURL]"); Console.WriteLine(); // output the options Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return((int)ExitCode.ErrorInvalidCommandLine); } string endpointURL; if (extraArgs.Count == 0) { // use OPC UA .Net Sample server endpointURL = "opc.tcp://localhost:51210/UA/SampleServer"; } else { endpointURL = extraArgs[0]; } MySampleClient client = new MySampleClient(endpointURL, autoAccept, stopTimeout) { Verbose = verbose, LoadTypeSystem = !noTypes, BrowseAdddressSpace = !noBrowse, WriteComplexInt = writeComplexInt, PrintAsJson = json, JsonReversible = jsonReversible, Username = username, Password = pw, ReverseConnectUri = reverseConnectUrl }; return((int)client.Run()); }
public static int Main(string[] args) { Console.WriteLine(".Net Core OPC UA Complex Types Client sample"); // command line options bool showHelp = false; int stopTimeout = Timeout.Infinite; bool autoAccept = false; bool writeComplexInt = false; bool noloadTypes = false; bool verbose = false; bool json = 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 }, { "t|timeout=", "the number of seconds until the client stops.", (int t) => stopTimeout = t }, { "w|writeint", "Read and increment all complex types with an Int32.", w => writeComplexInt = w != null }, { "n|noloadtypes", "Load the type system dictionary from the server.", n => noloadTypes = n != null }, { "v|verbose", "Verbose output.", v => verbose = v != null }, { "j|json", "Print custom nodes as Json.", j => json = j != null }, }; IList <string> extraArgs = null; try { extraArgs = options.Parse(args); if (extraArgs.Count > 1) { 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) { // show some app description message Console.WriteLine("Usage: dotnet NetCoreConsoleClient.dll [OPTIONS] [ENDPOINTURL]"); Console.WriteLine(); // output the options Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return((int)ExitCode.ErrorInvalidCommandLine); } string endpointURL; if (extraArgs.Count == 0) { // use OPC UA .Net Sample server endpointURL = "opc.tcp://localhost:51210/UA/SampleServer"; } else { endpointURL = extraArgs[0]; } MySampleClient client = new MySampleClient(endpointURL, autoAccept, stopTimeout) { Verbose = verbose, LoadTypeSystem = !noloadTypes, WriteComplexInt = writeComplexInt, PrintAsJson = json }; return((int)client.Run()); }
/// <summary> /// Parse arguments and set values in the environment the way the new configuration expects it. /// </summary> /// <param name="args">The specified command line arguments.</param> public StandaloneCliOptions(string[] args) { _logger = ConsoleLogger.Create(LogEventLevel.Warning); bool showHelp = false; List <string> unsupportedOptions = new List <string>(); List <string> legacyOptions = new List <string>(); // command line options var options = new Mono.Options.OptionSet { // Publisher configuration options { $"pf|publishfile=|{StandaloneCliConfigKeys.PublishedNodesConfigurationFilename}=", "The filename to configure the nodes to publish.", s => this[StandaloneCliConfigKeys.PublishedNodesConfigurationFilename] = s }, { $"pfs|publishfileschema=|{StandaloneCliConfigKeys.PublishedNodesConfigurationSchemaFilename}=", "The validation schema filename for publish file. Disabled by default.", s => this[StandaloneCliConfigKeys.PublishedNodesConfigurationSchemaFilename] = s }, { "s|site=", "The site OPC Publisher is working in.", s => this[StandaloneCliConfigKeys.PublisherSite] = s }, { $"di|diagnosticsinterval=|{StandaloneCliConfigKeys.DiagnosticsInterval}=", "Shows publisher diagnostic info at the specified interval " + "in seconds (need log level info).\n-1 disables remote diagnostic log and diagnostic output", (int i) => this[StandaloneCliConfigKeys.DiagnosticsInterval] = TimeSpan.FromSeconds(i).ToString() }, { $"lf|logfile=|{StandaloneCliConfigKeys.LogFileName}=", "The filename of the logfile to use.", s => this[StandaloneCliConfigKeys.LogFileName] = s }, { $"lt|logflushtimespan=|{StandaloneCliConfigKeys.LogFileFlushTimeSpanSec}=", "The timespan in seconds when the logfile should be flushed.", (int i) => this[StandaloneCliConfigKeys.LogFileFlushTimeSpanSec] = TimeSpan.FromSeconds(i).ToString() }, { "ll|loglevel=", "The loglevel to use (allowed: fatal, error, warn, info, debug, verbose).", (LogEventLevel l) => LogControl.Level.MinimumLevel = l }, { $"ih|iothubprotocol=|{StandaloneCliConfigKeys.HubTransport}=", "Protocol to use for communication with the hub. " + $"(allowed values: {string.Join(", ", Enum.GetNames(typeof(TransportOption)))}).", (TransportOption p) => this[StandaloneCliConfigKeys.HubTransport] = p.ToString() }, { "dc|deviceconnectionstring=", "A device or edge module connection string to use.", dc => this[StandaloneCliConfigKeys.EdgeHubConnectionString] = dc }, { $"ec|edgehubconnectionstring=|{StandaloneCliConfigKeys.EdgeHubConnectionString}=", "An edge module connection string to use", dc => this[StandaloneCliConfigKeys.EdgeHubConnectionString] = dc }, { $"{StandaloneCliConfigKeys.BypassCertVerificationKey}=", "Enables bypass of certificate verification for upstream communication to edgeHub.", (bool b) => this[StandaloneCliConfigKeys.BypassCertVerificationKey] = b.ToString() }, { $"{StandaloneCliConfigKeys.EnableMetricsKey}=", "Enables upstream metrics propagation.", (bool b) => this[StandaloneCliConfigKeys.EnableMetricsKey] = b.ToString() }, { $"hb|heartbeatinterval=|{StandaloneCliConfigKeys.HeartbeatIntervalDefault}=", "The publisher is using this as default value in seconds " + "for the heartbeat interval setting of nodes without a heartbeat interval setting.", (int i) => this[StandaloneCliConfigKeys.HeartbeatIntervalDefault] = TimeSpan.FromSeconds(i).ToString() }, // ToDo: Bring back once SkipFirst mechanism is implemented. //{ "sf|skipfirstevent=", "The publisher is using this as default value for the skip first " + // "event setting of nodes without a skip first event setting.", // (bool b) => this[StandaloneCliConfigKeys.SkipFirstDefault] = b.ToString() }, { $"fm|fullfeaturedmessage=|{StandaloneCliConfigKeys.FullFeaturedMessage}=", "The full featured mode for messages (all fields filled in)." + "Default is 'false' for legacy compatibility.", (bool b) => this[StandaloneCliConfigKeys.FullFeaturedMessage] = b.ToString() }, // Client settings { $"ot|operationtimeout=|{StandaloneCliConfigKeys.OpcOperationTimeout}=", "The operation timeout of the publisher OPC UA client in milliseconds.", (uint u) => this[StandaloneCliConfigKeys.OpcOperationTimeout] = u.ToString() }, { $"ol|opcmaxstringlen=|{StandaloneCliConfigKeys.OpcMaxStringLength}=", "The max length of a string opc can transmit/receive.", (uint u) => this[StandaloneCliConfigKeys.OpcMaxStringLength] = u.ToString() }, { $"{StandaloneCliConfigKeys.SecurityTokenLifetimeKey}=", "OPC UA Stack Transport Secure Channel - Security token lifetime in milliseconds.", (uint u) => this[StandaloneCliConfigKeys.SecurityTokenLifetimeKey] = u.ToString() }, { $"{StandaloneCliConfigKeys.ChannelLifetimeKey}=", "OPC UA Stack Transport Secure Channel - Channel lifetime in milliseconds.", (uint u) => this[StandaloneCliConfigKeys.ChannelLifetimeKey] = u.ToString() }, { $"{StandaloneCliConfigKeys.MaxBufferSizeKey}=", "OPC UA Stack Transport Secure Channel - Max buffer size.", (uint u) => this[StandaloneCliConfigKeys.MaxBufferSizeKey] = u.ToString() }, { $"{StandaloneCliConfigKeys.MaxMessageSizeKey}=", "OPC UA Stack Transport Secure Channel - Max message size.", (uint u) => this[StandaloneCliConfigKeys.MaxMessageSizeKey] = u.ToString() }, { $"{StandaloneCliConfigKeys.MaxArrayLengthKey}=", "OPC UA Stack Transport Secure Channel - Max array length.", (uint u) => this[StandaloneCliConfigKeys.MaxArrayLengthKey] = u.ToString() }, { $"{StandaloneCliConfigKeys.MaxByteStringLengthKey}=", "OPC UA Stack Transport Secure Channel - Max byte string length.", (uint u) => this[StandaloneCliConfigKeys.MaxByteStringLengthKey] = u.ToString() }, { $"oi|opcsamplinginterval=|{StandaloneCliConfigKeys.OpcSamplingInterval}=", "Default value in milliseconds to request the servers to " + "sample values.", (int i) => this[StandaloneCliConfigKeys.OpcSamplingInterval] = TimeSpan.FromMilliseconds(i).ToString() }, { $"op|opcpublishinginterval=|{StandaloneCliConfigKeys.OpcPublishingInterval}=", "Default value in milliseconds for the publishing interval " + "setting of the subscriptions against the OPC UA server.", (int i) => this[StandaloneCliConfigKeys.OpcPublishingInterval] = TimeSpan.FromMilliseconds(i).ToString() }, { $"{StandaloneCliConfigKeys.ApplicationUriKey}=", "OPC UA Client Application Config - Application URI as per OPC UA definition.", s => this[StandaloneCliConfigKeys.ApplicationUriKey] = s }, { $"{StandaloneCliConfigKeys.ProductUriKey}=", "OPC UA Client Application Config - Product URI as per OPC UA definition.", s => this[StandaloneCliConfigKeys.ProductUriKey] = s }, { $"ct|createsessiontimeout=|{StandaloneCliConfigKeys.OpcSessionCreationTimeout}=", "Maximum amount of time in seconds that a session should " + "remain open by the OPC server without any activity (session timeout) " + "- to request from the OPC server at session creation.", (uint u) => this[StandaloneCliConfigKeys.OpcSessionCreationTimeout] = u.ToString() }, { $"{StandaloneCliConfigKeys.MinSubscriptionLifetimeKey}=", "OPC UA Client Application Config - " + "Minimum subscription lifetime in seconds as per OPC UA definition.", (int i) => this[StandaloneCliConfigKeys.MinSubscriptionLifetimeKey] = i.ToString() }, { $"ki|keepaliveinterval=|{StandaloneCliConfigKeys.OpcKeepAliveIntervalInSec}=", "The interval in seconds the publisher is sending keep alive messages " + "to the OPC servers on the endpoints it is connected to.", (int i) => this[StandaloneCliConfigKeys.OpcKeepAliveIntervalInSec] = i.ToString() }, { $"kt|keepalivethreshold=|{StandaloneCliConfigKeys.OpcKeepAliveDisconnectThreshold}=", "Specify the number of keep alive packets a server can miss, before the session is disconneced.", (uint u) => this[StandaloneCliConfigKeys.OpcKeepAliveDisconnectThreshold] = u.ToString() }, { $"fd|fetchdisplayname=|{StandaloneCliConfigKeys.FetchOpcNodeDisplayName}=", "Fetches the displayname for the monitored items subscribed.", (bool b) => this[StandaloneCliConfigKeys.FetchOpcNodeDisplayName] = b.ToString() }, { $"mq|monitoreditemqueuecapacity=|{StandaloneCliConfigKeys.DefaultQueueSize}=", "Default queue size for monitored items.", (uint u) => this[StandaloneCliConfigKeys.DefaultQueueSize] = u.ToString() }, // cert store option { $"aa|autoaccept", "The publisher trusts all servers it is establishing a connection to.", b => this[StandaloneCliConfigKeys.AutoAcceptCerts] = (b != null).ToString() }, { $"{StandaloneCliConfigKeys.AutoAcceptCerts}=", "The publisher trusts all servers it is establishing a connection to.", (bool b) => this[StandaloneCliConfigKeys.AutoAcceptCerts] = b.ToString() }, { $"tm|trustmyself", "The publisher certificate is put into the trusted store automatically.", b => this[StandaloneCliConfigKeys.TrustMyself] = (b != null).ToString() }, { $"{StandaloneCliConfigKeys.TrustMyself}=", "The publisher certificate is put into the trusted store automatically.", (bool b) => this[StandaloneCliConfigKeys.TrustMyself] = b.ToString() }, { $"at|appcertstoretype=|{StandaloneCliConfigKeys.OpcOwnCertStoreType}=", "The own application cert store type (allowed: Directory, X509Store).", s => { if (s.Equals(CertificateStoreType.X509Store, StringComparison.OrdinalIgnoreCase) || s.Equals(CertificateStoreType.Directory, StringComparison.OrdinalIgnoreCase)) { this[StandaloneCliConfigKeys.OpcOwnCertStoreType] = s; return; } throw new OptionException("Bad store type", "at"); } }, { $"ap|appcertstorepath=|{StandaloneCliConfigKeys.OpcOwnCertStorePath}=", "The path where the own application cert should be stored.", s => this[StandaloneCliConfigKeys.OpcOwnCertStorePath] = s }, { $"tp|trustedcertstorepath=|{StandaloneCliConfigKeys.OpcTrustedCertStorePath}=", "The path of the trusted cert store.", s => this[StandaloneCliConfigKeys.OpcTrustedCertStorePath] = s }, { $"sn|appcertsubjectname=|{StandaloneCliConfigKeys.OpcApplicationCertificateSubjectName}=", "The subject name for the app cert.", s => this[StandaloneCliConfigKeys.OpcApplicationCertificateSubjectName] = s }, { $"an|appname=|{StandaloneCliConfigKeys.OpcApplicationName}=", "The name for the app (used during OPC UA authentication).", s => this[StandaloneCliConfigKeys.OpcApplicationName] = s }, { "tt|trustedcertstoretype=", "Legacy - do not use.", b => { legacyOptions.Add("tt|trustedcertstoretype"); } }, { $"rp|rejectedcertstorepath=|{StandaloneCliConfigKeys.OpcRejectedCertStorePath}=", "The path of the rejected cert store.", s => this[StandaloneCliConfigKeys.OpcRejectedCertStorePath] = s }, { "rt|rejectedcertstoretype=", "Legacy - do not use.", b => { legacyOptions.Add("rt|rejectedcertstoretype"); } }, { $"ip|issuercertstorepath=|{StandaloneCliConfigKeys.OpcIssuerCertStorePath}=", "The path of the trusted issuer cert store.", s => this[StandaloneCliConfigKeys.OpcIssuerCertStorePath] = s }, { $"{StandaloneCliConfigKeys.PkiRootPathKey}=", "PKI certificate store root path.", s => this[StandaloneCliConfigKeys.PkiRootPathKey] = s }, { $"{StandaloneCliConfigKeys.TrustedIssuerCertificatesTypeKey}=", "Trusted issuer certificate types.", s => this[StandaloneCliConfigKeys.TrustedIssuerCertificatesTypeKey] = s }, { $"{StandaloneCliConfigKeys.TrustedPeerCertificatesTypeKey}=", "Trusted peer certificate types.", s => this[StandaloneCliConfigKeys.TrustedPeerCertificatesTypeKey] = s }, { $"{StandaloneCliConfigKeys.RejectedCertificateStoreTypeKey}=", "Rejected certificate types.", s => this[StandaloneCliConfigKeys.RejectedCertificateStoreTypeKey] = s }, { $"{StandaloneCliConfigKeys.RejectSha1SignedCertificatesKey}=", "The publisher rejects deprecated SHA1 certificates.", (bool b) => this[StandaloneCliConfigKeys.RejectSha1SignedCertificatesKey] = b.ToString() }, { $"{StandaloneCliConfigKeys.MinimumCertificateKeySizeKey}=", "Minimum accepted certificate size.", s => this[StandaloneCliConfigKeys.MinimumCertificateKeySizeKey] = s }, { "it|issuercertstoretype=", "Legacy - do not use.", b => { legacyOptions.Add("it|issuercertstoretype"); } }, { $"bs|batchsize=|{StandaloneCliConfigKeys.BatchSize}=", "The size of message batching buffer.", (int i) => this[StandaloneCliConfigKeys.BatchSize] = i.ToString() }, { $"si|iothubsendinterval=|{StandaloneCliConfigKeys.BatchTriggerInterval}=", "The trigger batching interval in seconds.", (int k) => this[StandaloneCliConfigKeys.BatchTriggerInterval] = TimeSpan.FromSeconds(k).ToString() }, { $"ms|iothubmessagesize=|{StandaloneCliConfigKeys.IoTHubMaxMessageSize}=", "The maximum size of the (IoT D2C) message.", (int i) => this[StandaloneCliConfigKeys.IoTHubMaxMessageSize] = i.ToString() }, { $"om|maxoutgressmessages=|{StandaloneCliConfigKeys.MaxOutgressMessages}=", "The maximum size of the (IoT D2C) message outgress buffer", (int i) => this[StandaloneCliConfigKeys.MaxOutgressMessages] = i.ToString() }, { $"{StandaloneCliConfigKeys.MaxNodesPerDataSet}=", "Maximum number of nodes within a DataSet/Subscription.", (int i) => this[StandaloneCliConfigKeys.MaxNodesPerDataSet] = i.ToString() }, { $"mm|messagingmode=|{StandaloneCliConfigKeys.MessagingMode}=", "The messaging mode for messages " + $"(allowed values: {string.Join(", ", Enum.GetNames(typeof(MessagingMode)))}).", (MessagingMode m) => this[StandaloneCliConfigKeys.MessagingMode] = m.ToString() }, { $"me|messageencoding=|{StandaloneCliConfigKeys.MessageEncoding}=", "The message encoding for messages " + $"(allowed values: {string.Join(", ", Enum.GetNames(typeof(MessageEncoding)))}).", (MessageEncoding m) => this[StandaloneCliConfigKeys.MessageEncoding] = m.ToString() }, { $"lc|legacycompatibility=|{StandaloneCliConfigKeys.LegacyCompatibility}=", "Run the publisher in legacy (2.5.x) compatibility mode. " + "Default is 'false'.", (bool b) => this[StandaloneCliConfigKeys.LegacyCompatibility] = b.ToString() }, { $"rs|runtimestatereporting=|{StandaloneCliConfigKeys.RuntimeStateReporting}=", "The publisher reports its restarts. By default this is disabled.", (bool b) => this[StandaloneCliConfigKeys.RuntimeStateReporting] = b.ToString() }, { $"ri|enableroutinginfo=|{StandaloneCliConfigKeys.EnableRoutingInfo}=", "Enable adding routing info to telemetry. By default this is disabled.", (bool b) => this[StandaloneCliConfigKeys.EnableRoutingInfo] = b.ToString() }, // testing purposes { "sc|scaletestcount=", "The number of monitored item clones in scale tests.", (int i) => this[StandaloneCliConfigKeys.ScaleTestCount] = i.ToString() }, // show help { "h|help", "show this message and exit.", b => showHelp = true }, // Legacy: unsupported { "tc|telemetryconfigfile=", "Legacy - do not use.", b => { legacyOptions.Add("tc|telemetryconfigfile"); } }, { "ic|iotcentral=", "Legacy - do not use.", b => { legacyOptions.Add("ic|iotcentral"); } }, { "ns|noshutdown=", "Legacy - do not use.", b => { legacyOptions.Add("ns|noshutdown"); } }, { "rf|runforever", "Legacy - do not use.", b => { legacyOptions.Add("rf|runforever"); } }, { "pn|portnum=", "Legacy - do not use.", b => { legacyOptions.Add("pn|portnum"); } }, { "pa|path=", "Legacy - do not use.", b => { legacyOptions.Add("pa|path"); } }, { "lr|ldsreginterval=", "Legacy - do not use.", b => { legacyOptions.Add("lr|ldsreginterval"); } }, { "ss|suppressedopcstatuscodes=", "Legacy - do not use.", b => { legacyOptions.Add("ss|suppressedopcstatuscodes"); } }, { "csr", "Legacy - do not use.", b => { legacyOptions.Add("csr"); } }, { "ab|applicationcertbase64=", "Legacy - do not use.", b => { legacyOptions.Add("ab|applicationcertbase64"); } }, { "af|applicationcertfile=", "Legacy - do not use.", b => { legacyOptions.Add("af|applicationcertfile"); } }, { "pk|privatekeyfile=", "Legacy - do not use.", b => { legacyOptions.Add("pk|privatekeyfile"); } }, { "pb|privatekeybase64=", "Legacy - do not use.", b => { legacyOptions.Add("pb|privatekeybase64"); } }, { "cp|certpassword="******"Legacy - do not use.", b => { legacyOptions.Add("cp|certpassword"); } }, { "tb|addtrustedcertbase64=", "Legacy - do not use.", b => { legacyOptions.Add("tb|addtrustedcertbase64"); } }, { "tf|addtrustedcertfile=", "Legacy - do not use.", b => { legacyOptions.Add("tf|addtrustedcertfile"); } }, { "ib|addissuercertbase64=", "Legacy - do not use.", b => { legacyOptions.Add("ib|addissuercertbase64"); } }, { "if|addissuercertfile=", "Legacy - do not use.", b => { legacyOptions.Add("if|addissuercertfile"); } }, { "rb|updatecrlbase64=", "Legacy - do not use.", b => { legacyOptions.Add("rb|updatecrlbase64"); } }, { "uc|updatecrlfile=", "Legacy - do not use.", b => { legacyOptions.Add("uc|updatecrlfile"); } }, { "rc|removecert=", "Legacy - do not use.", b => { legacyOptions.Add("rc|removecert"); } }, { "dt|devicecertstoretype=", "Legacy - do not use.", b => { legacyOptions.Add("dt|devicecertstoretype"); } }, { "dp|devicecertstorepath=", "Legacy - do not use.", b => { legacyOptions.Add("dp|devicecertstorepath"); } }, { "i|install", "Legacy - do not use.", b => { legacyOptions.Add("i|install"); } }, { "st|opcstacktracemask=", "Legacy - do not use.", b => { legacyOptions.Add("st|opcstacktracemask"); } }, { "sd|shopfloordomain=", "Legacy - do not use.", b => { legacyOptions.Add("sd|shopfloordomain"); } }, { "vc|verboseconsole=", "Legacy - do not use.", b => { legacyOptions.Add("vc|verboseconsole"); } }, { "as|autotrustservercerts=", "Legacy - do not use.", b => { legacyOptions.Add("as|autotrustservercerts"); } }, }; try { unsupportedOptions = options.Parse(args); } catch (Exception e) { Warning("Parse args exception: " + e.Message); Exit(160); } if (_logger.IsEnabled(LogEventLevel.Debug)) { foreach (var key in this.Keys) { Debug("Parsed command line option: '{key}'='{value}'", key, this[key]); } } if (unsupportedOptions.Count > 0) { foreach (var option in unsupportedOptions) { Warning("Option {option} wrong or not supported, " + "please use -h option to get all the supported options.", option); } } if (legacyOptions.Count > 0) { foreach (var option in legacyOptions) { Warning("Legacy option {option} not supported, please use -h option to get all the supported options.", option); } } if (showHelp) { options.WriteOptionDescriptions(Console.Out); Exit(0); } Config = ToAgentConfigModel(); }
public static int Main(string[] args) { Console.WriteLine("Technosoftware {0} OPC UA ModelDesign Client", Utils.IsRunningOnMono() ? "Mono" : ".NET Core"); // command line options var showHelp = false; var stopTimeout = Timeout.Infinite; var autoAccept = false; var noBrowse = false; var verbose = false; string username = null; string password = null; var options = new OptionSet { { "h|help", "show this message and exit", h => showHelp = h != null }, { "a|autoaccept", "auto accept certificates (for testing only)", a => autoAccept = a != null }, { "t|timeout=", "the number of seconds until the client stops.", (int t) => stopTimeout = t }, { "b|nobrowse", "Do not browse the address space of the server.", n => noBrowse = n != null }, { "u|username="******"Username to access server.", n => username = n }, { "p|password="******"Password to access server.", n => password = n }, { "v|verbose", "Verbose output.", v => verbose = v != null }, }; IList <string> extraArgs = null; try { extraArgs = options.Parse(args); if (extraArgs.Count > 1) { foreach (var extraArg in extraArgs) { Console.WriteLine("Error: Unknown option: {0}", extraArg); showHelp = true; } } } catch (OptionException e) { Console.WriteLine(e.Message); showHelp = true; } if (showHelp) { // show some app description message Console.WriteLine("Usage: dotnet Technosoftware.ModelDesignClient.dll [OPTIONS] [ENDPOINTURL]"); Console.WriteLine(); // output the options Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return((int)ExitCode.ErrorInvalidCommandLine); } string endpointUrl; if (extraArgs == null || extraArgs.Count == 0) { // use Technosoftware OPC UA ModelDesign Server endpointUrl = "opc.tcp://localhost:55552/TechnosoftwareModelDesignServer"; } else { endpointUrl = extraArgs[0]; } var client = new MySampleClient(endpointUrl, autoAccept, stopTimeout) { Verbose = verbose, BrowseAddressSpace = !noBrowse, Username = username, Password = password, }; return((int)client.Run()); }
public static void Main(string[] args) { Console.WriteLine("OPC UA Console Reference Subscriber"); // command line options bool showHelp = false; bool useMqttJson = true; bool useMqttUadp = false; bool useUdpUadp = false; string subscriberUrl = null; Mono.Options.OptionSet options = new Mono.Options.OptionSet { { "h|help", "Show usage information", v => showHelp = v != null }, { "m|mqtt_json", "Use MQTT with Json encoding Profile. This is the default option.", v => useMqttJson = v != null }, { "p|mqtt_uadp", "Use MQTT with UADP encoding Profile.", v => useMqttUadp = v != null }, { "u|udp_uadp", "Use UDP with UADP encoding Profile", v => useUdpUadp = v != null }, { "url|subscriber_url=", "Subscriber Url Address", v => subscriberUrl = v }, }; IList <string> extraArgs = null; try { extraArgs = options.Parse(args); if (extraArgs.Count > 0) { 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 ConsoleReferenceSubscriber.dll [OPTIONS]"); Console.WriteLine(); Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return; } try { InitializeLog(); PubSubConfigurationDataType pubSubConfiguration = null; if (useUdpUadp) { // set default UDP Subscriber Url to local multicast if not sent in args. if (string.IsNullOrEmpty(subscriberUrl)) { subscriberUrl = "opc.udp://239.0.0.1:4840"; } // Create configuration using UDP protocol and UADP Encoding pubSubConfiguration = CreateSubscriberConfiguration_UdpUadp(subscriberUrl); Console.WriteLine("The Pubsub Connection was initialized using UDP & UADP Profile."); } else { // set default MQTT Broker Url to localhost if not sent in args. if (string.IsNullOrEmpty(subscriberUrl)) { subscriberUrl = "mqtt://localhost:1883"; } if (useMqttUadp) { // Create configuration using MQTT protocol and UADP Encoding pubSubConfiguration = CreateSubscriberConfiguration_MqttUadp(subscriberUrl); Console.WriteLine("The PubSub Connection was initialized using MQTT & UADP Profile."); } else { // Create configuration using MQTT protocol and JSON Encoding pubSubConfiguration = CreateSubscriberConfiguration_MqttJson(subscriberUrl); Console.WriteLine("The PubSub Connection was initialized using MQTT & JSON Profile."); } } // Create the UA Publisher application using (UaPubSubApplication uaPubSubApplication = UaPubSubApplication.Create(pubSubConfiguration)) { // Subscribte to RawDataReceived event uaPubSubApplication.RawDataReceived += UaPubSubApplication_RawDataReceived; // Subscribte to DataReceived event uaPubSubApplication.DataReceived += UaPubSubApplication_DataReceived; // Subscribte to MetaDataReceived event uaPubSubApplication.MetaDataReceived += UaPubSubApplication_MetaDataDataReceived; uaPubSubApplication.ConfigurationUpdating += UaPubSubApplication_ConfigurationUpdating; // Start the publisher uaPubSubApplication.Start(); Console.WriteLine("Subscriber Started. Press Ctrl-C to exit..."); ManualResetEvent quitEvent = new ManualResetEvent(false); try { Console.CancelKeyPress += (sender, eArgs) => { quitEvent.Set(); eArgs.Cancel = true; }; } catch { } // wait for timeout or Ctrl-C quitEvent.WaitOne(); } Console.WriteLine("Program ended."); Console.WriteLine("Press any key to finish..."); Console.ReadKey(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }