remove GuiFeeder
This commit is contained in:
parent
2f6d9a1799
commit
cec22d07d8
|
@ -1,23 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="../InnovEnergy.app.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>InnovEnergy.GuiFeeder</RootNamespace>
|
||||
<InvariantGlobalization>true</InvariantGlobalization>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../lib/DBus/DBus.csproj" />
|
||||
<ProjectReference Include="../../lib/Utils/Utils.csproj" />
|
||||
<ProjectReference Include="../../lib/VeDBus/VeDBus.csproj" />
|
||||
<ProjectReference Include="..\..\lib\Victron\VeDBus\VeDBus.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\..\..\..\..\..\.nuget\packages\newtonsoft.json\13.0.1\lib\netstandard2.0\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -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<ServiceProperties>;
|
||||
|
||||
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<String, Object>();
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
|
@ -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<IReadOnlyList<ServiceProperties>> ObserveVeService(this DBusConnection dbus,
|
||||
Func<String, Boolean> selector)
|
||||
{
|
||||
return dbus
|
||||
.ObservePropertiesOfServices(selector)
|
||||
.StartWith(Array.Empty<ServiceProperties>());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue