Innovenergy_trunk/csharp/app/VenusLogger/Parsers/PvCharger.cs

27 lines
833 B
C#
Raw Normal View History

2023-02-16 12:57:06 +00:00
using InnovEnergy.Lib.Utils;
using InnovEnergy.Lib.Victron.VeDBus;
using InnovEnergy.WireFormat.VictronV1;
namespace InnovEnergy.VenusLogger.Parsers;
public static class PvCharger
{
public static Maybe<Device> GetPvCharger(this IEnumerable<ServiceProperties> services)
{
var solarChargers = services
.Where(VeService.IsSolarChargerService)
.TrySelect(GetPvCharger)
.ToList();
if (solarChargers.Count <= 1)
return solarChargers.FirstOrDefault().Maybe();
return new Device { Type = DeviceType.Mppt, Devices = { solarChargers } };
}
private static Device GetPvCharger(ServiceProperties sp) => new Device
{
Type = DeviceType.Mppt,
Phases = { sp.Properties.GetDcPhase() }
};
}