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