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

27 lines
679 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 Grid
{
public static Maybe<Device> GetGrid(this IEnumerable<ServiceProperties> services)
{
return services
.Where(VeService.IsGridService)
.Select(GetGridDevice)
.SingleOrDefault()
.Maybe();
}
private static Device GetGridDevice(this ServiceProperties serviceProps)
{
return new Device
{
Type = DeviceType.Grid,
Phases = { serviceProps.Properties.GetAcPhases() }
};
}
}