using InnovEnergy.Lib.Utils; namespace InnovEnergy.Lib.Devices.BatteryDeligreen; public class BatteryDeligreenDevices { private readonly IReadOnlyList _devices; public BatteryDeligreenDevices(IReadOnlyList devices) => _devices = devices; public BatteryDeligreenRecords? Read() { var records = _devices .Select(TryRead) .NotNull() .ToList(); return BatteryDeligreenRecords.FromBatteries(records); } private static BatteryDeligreenRecord? TryRead(BatteryDeligreenDevice d) { try { return d.Reads().Result; } catch (Exception e) { Console.WriteLine($"Failed to read Battery node {d.SlaveId}\n{e.Message}"); // TODO: log return null; } } }