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

26 lines
703 B
C#

using InnovEnergy.Lib.Utils;
using InnovEnergy.Lib.Victron.VeDBus;
using InnovEnergy.WireFormat.VictronV1;
namespace InnovEnergy.VenusLogger.Parsers;
public static class Generator
{
public static Maybe<Device> GetGenerator(this IEnumerable<ServiceProperties> services)
{
return services
.Where(VeService.IsGeneratorService)
.Select(GetGeneratorDevice)
.SingleOrDefault()
.Maybe();
}
private static Device GetGeneratorDevice(ServiceProperties serviceProps)
{
return new Device
{
Type = DeviceType.Generator,
Phases = { serviceProps.Properties.GetAcPhases() }
};
}
}