72 lines
2.3 KiB
C#
72 lines
2.3 KiB
C#
|
using System.Collections.Immutable;
|
||
|
using System.Reactive.Linq;
|
||
|
using InnovEnergy.Lib.Protocols.DBus;
|
||
|
using InnovEnergy.Lib.Victron.VeDBus;
|
||
|
|
||
|
|
||
|
namespace InnovEnergy.VenusLogger;
|
||
|
|
||
|
using Props = ImmutableDictionary<String, VeProperty>;
|
||
|
|
||
|
public static class DBusObserver
|
||
|
{
|
||
|
|
||
|
// public static IObservable<Grid> ObserveGrid(this DBusConnection dbus)
|
||
|
// {
|
||
|
// return dbus
|
||
|
// .ObserveService(VeService.Grid)
|
||
|
// .TrySelect(Parsers.Grid.Parse)
|
||
|
// .StartWith(new Grid());
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// public static IObservable<ILookup<AcBusType, AcSource>> ObservePvInverters(this DBusConnection dbus)
|
||
|
// {
|
||
|
// return dbus
|
||
|
// .ObserveServices(VeService.PvInverter)
|
||
|
// .Select(Parsers.PvInverter.Parse);
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// public static IObservable<Inverter> ObserveInverter(this DBusConnection dbus)
|
||
|
// {
|
||
|
// return dbus
|
||
|
// .ObserveService(VeService.Inverter)
|
||
|
// .TrySelect(Parsers.Inverter.Parse)
|
||
|
// .StartWith(new Inverter());
|
||
|
// }
|
||
|
//
|
||
|
//
|
||
|
// public static IObservable<IEnumerable<DcSource>> ObservePvChargers(this DBusConnection dbus)
|
||
|
// {
|
||
|
// return dbus
|
||
|
// .ObserveServices(VeService.SolarCharger)
|
||
|
// .Select(Parsers.PvCharger.Parse)
|
||
|
// .StartWith(Empty<DcSource>());
|
||
|
// }
|
||
|
//
|
||
|
// public static IObservable<Boolean> ObserveDcSystem(this DBusConnection dbus)
|
||
|
// {
|
||
|
// return dbus
|
||
|
// .ObserveService(VeService.Settings)
|
||
|
// .TrySelect(p => p["/Settings/SystemSetup/HasDcSystem"].Value.Apply(Convert.ToBoolean))
|
||
|
// .StartWith(false)
|
||
|
// .DistinctUntilChanged();
|
||
|
// }
|
||
|
//
|
||
|
// public static IObservable<IEnumerable<Battery>> Observe48TlBatteries(this DBusConnection dbus)
|
||
|
// {
|
||
|
// return dbus
|
||
|
// .ObserveService(VeService.Battery)
|
||
|
// .TrySelect(Parsers.Battery48Tl.Parse)
|
||
|
// .StartWith(Empty<Battery>());
|
||
|
// }
|
||
|
|
||
|
public static IObservable<IReadOnlyList<ServiceProperties>> ObserveServices(this DBusConnection dbus, String service)
|
||
|
{
|
||
|
return dbus
|
||
|
.ObservePropertiesOfServices(s => s.StartsWith(service))
|
||
|
.StartWith(Array.Empty<ServiceProperties>());
|
||
|
}
|
||
|
|
||
|
}
|