diff --git a/src/Ve.Direct.InfluxDB.Collector/CollectorConfiguration.cs b/src/Ve.Direct.InfluxDB.Collector/CollectorConfiguration.cs index e011619..1b01755 100644 --- a/src/Ve.Direct.InfluxDB.Collector/CollectorConfiguration.cs +++ b/src/Ve.Direct.InfluxDB.Collector/CollectorConfiguration.cs @@ -29,6 +29,12 @@ public class CollectorConfiguration public bool DebugOutput => this.debugOutput.ParsedValue; + public enum OutputDefinition + { + Console, + Influx + } + public CollectorConfiguration(CommandLineApplication app) { this.outputDefinition = app.Option("-o|--output", "Console or Influx", CommandOptionType.SingleValue); @@ -41,20 +47,20 @@ public CollectorConfiguration(CommandLineApplication app) this.useChecksums = app.Option("-c", "Use checksums?", CommandOptionType.SingleOrNoValue); this.debugOutput = app.Option("--debugOutput", "Debug?", CommandOptionType.SingleOrNoValue); - this.outputDefinition.DefaultValue = OutputDefinition.Console; + this.SetDefaultValues(); + } + private void SetDefaultValues() + { + this.outputDefinition.DefaultValue = OutputDefinition.Console; this.interval.DefaultValue = 30; this.influxDbUrl.DefaultValue = "http://192.168.0.220:8086"; this.influxDbBucket.DefaultValue = "solar"; this.influxDbOrg.DefaultValue = "home"; this.influxMetricPrefix.DefaultValue = "ve_direct"; - } - - public enum OutputDefinition - { - Console, - Influx + this.useChecksums.DefaultValue = false; + this.debugOutput.DefaultValue = false; } } } diff --git a/src/Ve.Direct.InfluxDB.Collector/Program.cs b/src/Ve.Direct.InfluxDB.Collector/Program.cs index b58e24d..dcc267d 100644 --- a/src/Ve.Direct.InfluxDB.Collector/Program.cs +++ b/src/Ve.Direct.InfluxDB.Collector/Program.cs @@ -17,7 +17,7 @@ public static int Main(string[] args) app.HelpOption(); app.OnExecuteAsync(async cancellationToken => { - ConsoleLogger.Init(config.DebugOutput, "3.0.0"); + ConsoleLogger.Init(config.DebugOutput, "3.1.0"); ConsoleLogger.Debug($"Current output setting: {config.Output}"); try @@ -53,7 +53,7 @@ private static void WriteMetricsCallback(Dictionary serialData) { foreach (var kvp in serialData) { - var outputValue = kvp.Key.ToLower() == "pid" ? kvp.Value.GetVictronDeviceNameByPid() : kvp.Value; + var outputValue = kvp.Key.Equals("pid", StringComparison.CurrentCultureIgnoreCase) ? kvp.Value.GetVictronDeviceNameByPid() : kvp.Value; Console.WriteLine("KeyValue: {0} - {1}", kvp.Key, outputValue); } Console.WriteLine("---");