Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
DocBrown101 committed Dec 20, 2024
1 parent f0ce8f3 commit be9d0f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
20 changes: 13 additions & 7 deletions src/Ve.Direct.InfluxDB.Collector/CollectorConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<OutputDefinition>("-o|--output", "Console or Influx", CommandOptionType.SingleValue);
Expand All @@ -41,20 +47,20 @@ public CollectorConfiguration(CommandLineApplication app)
this.useChecksums = app.Option<bool>("-c", "Use checksums?", CommandOptionType.SingleOrNoValue);
this.debugOutput = app.Option<bool>("--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;
}
}
}
4 changes: 2 additions & 2 deletions src/Ve.Direct.InfluxDB.Collector/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -53,7 +53,7 @@ private static void WriteMetricsCallback(Dictionary<string, string> 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("---");
Expand Down

0 comments on commit be9d0f6

Please sign in to comment.