From cec22d07d8266b53677ad427eb1884a9a24c5a4c Mon Sep 17 00:00:00 2001 From: ig Date: Thu, 23 Feb 2023 15:32:29 +0100 Subject: [PATCH] remove GuiFeeder --- csharp/app/GuiFeeder/GuiFeeder.csproj | 23 ------- csharp/app/GuiFeeder/Program.cs | 98 --------------------------- csharp/app/GuiFeeder/Utils.cs | 20 ------ 3 files changed, 141 deletions(-) delete mode 100644 csharp/app/GuiFeeder/GuiFeeder.csproj delete mode 100644 csharp/app/GuiFeeder/Program.cs delete mode 100644 csharp/app/GuiFeeder/Utils.cs diff --git a/csharp/app/GuiFeeder/GuiFeeder.csproj b/csharp/app/GuiFeeder/GuiFeeder.csproj deleted file mode 100644 index f7467fa81..000000000 --- a/csharp/app/GuiFeeder/GuiFeeder.csproj +++ /dev/null @@ -1,23 +0,0 @@ - - - - - enable - InnovEnergy.GuiFeeder - true - - - - - - - - - - - - ..\..\..\..\..\..\.nuget\packages\newtonsoft.json\13.0.1\lib\netstandard2.0\Newtonsoft.Json.dll - - - - diff --git a/csharp/app/GuiFeeder/Program.cs b/csharp/app/GuiFeeder/Program.cs deleted file mode 100644 index 71c38cbcc..000000000 --- a/csharp/app/GuiFeeder/Program.cs +++ /dev/null @@ -1,98 +0,0 @@ -using System.Reactive.Linq; -using InnovEnergy.Lib.Victron.VeDBus; -// TODO THIS FILE IS LEGACY NOW? - -namespace InnovEnergy.GuiFeeder; - -using Services = IReadOnlyList; - -public static class Program{ - public static async Task Main() - { - //Set Values to be written into the file and the filepath of the gui data.json file - const String filepath = @"/data/gui/data"; - - - //legacy - // var trackedKeys = new String[] - // { - // "Dc/Battery/Soc", //State of charge - // "Dc/Battery/Power", //Power of Battery - // "Dc/Vebus/Power", //Power on DC Bus - // "Ac/ConsumptionOnOutput/L1/Power", //Consumption on Output aka CRITICAL CONSUMPTION - // "Ac/ConsumptionOnOutput/L2/Power", - // "Ac/ConsumptionOnOutput/L3/Power", - // "Ac/ConsumptionOnInput/L1/Power", //Consumption on Input aka non-critical - // "Ac/ConsumptionOnInput/L2/Power", - // "Ac/ConsumptionOnInput/L3/Power", - // "Ac/Grid/L1/Power", //Power on Grid - // "Ac/Grid/L2/Power", - // "Ac/Grid/L3/Power", - // "Ac/PvOnOutput/L1/Power", //Power on PV at Ac out bus - // "Ac/PvOnOutput/L2/Power", - // "Ac/PvOnOutput/L3/Power", - // "Ac/PvOnGrid/L1/Power", //Power on PV at Ac in bus - // "Ac/PvOnGrid/L2/Power", - // "Ac/PvOnGrid/L3/Power", - // }; - - var trackedKeys = new String[] - { - "Voltage", - "Current", - "Soc", - "Temperature" - }; - - //How often should we sample - const Int32 samplePeriodSecs = 1; - var interval = TimeSpan.FromSeconds(samplePeriodSecs); - - //legacy - // //Setup dbus connection and read the data.json file - // var dbus = new DBusConnection(Bus.System); - - //legacy - //Services to track - // var names = new[] - // { "com.victronenergy.system" }; - - Console.WriteLine("start sampling"); - // Observable - // .Interval(interval) - // .Subscribe(async (b) => await UpdateDataFile(names, dbus, trackedKeys, filepath)); - - while (true) - { - await UpdateDataFile(trackedKeys, filepath); - Thread.Sleep(interval); - } - } - - private static async Task UpdateDataFile(String[] trackedKeys, String filepath) - { - //We use time as timestamp and as a tracker of how many entries we allow - var time = DateTimeOffset.Now.ToUnixTimeSeconds(); - var timemod = (time % 180).ToString(); - var dict = new Dictionary(); - - foreach (var name in names) - { - var values = await dbus.GetAllValues(name); - //Write the tracked Values into JSON - foreach (var key in values.Keys) - { - // Console.WriteLine(!trackedKeys.Contains(key)); - //we only take values we want to display - if (!trackedKeys.Contains(key)) continue; - dict.Add(key, values[key]); - } - //TODO Implement Time dependence (here and in py) - } - - //Write File after each change in Values - var jsonObject = JsonConvert.SerializeObject(dict); - File.WriteAllText(filepath + timemod + ".json", jsonObject); - Console.WriteLine("Updated " + filepath + timemod + ".json"); - } -} \ No newline at end of file diff --git a/csharp/app/GuiFeeder/Utils.cs b/csharp/app/GuiFeeder/Utils.cs deleted file mode 100644 index a86f6bca7..000000000 --- a/csharp/app/GuiFeeder/Utils.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Reactive.Linq; -using InnovEnergy.Lib.Protocols.DBus; -using InnovEnergy.Lib.Victron.VeDBus; - -namespace InnovEnergy.GuiFeeder; - -public static class Utils -{ - - public static IObservable> ObserveVeService(this DBusConnection dbus, - Func selector) - { - return dbus - .ObservePropertiesOfServices(selector) - .StartWith(Array.Empty()); - } - - -} -