using InnovEnergy.Lib.Utils; namespace InnovEnergy.Lib.Devices.Battery250Up; public class Battery250UpDevices { private readonly IReadOnlyList _Devices; public Battery250UpDevices(IReadOnlyList devices) => _Devices = devices; public Battery250UpRecords? Read() { var records = _Devices .Select(TryRead) .NotNull() .ToList(); return Battery250UpRecords.FromBatteries(records); } private static Battery250UpRecord? TryRead(Battery250UpDevice d) { try { return d.Read(); } catch (Exception e) { Console.WriteLine($"Failed to read Battery node {d.SlaveId}\n{e.Message}"); // TODO: log return null; } } }