using PowerMonitorManager.Interface; using PowerMonitorManager.Models; namespace PowerMonitorManager; public sealed class OtherPowerCalculationService : IOtherPowerCalculationService { public PowerCalculationResult CalculateOtherPower(double? totalHomePower, IReadOnlyList monitoredSensorValues) { var total = totalHomePower ?? 0.0; var sumOfMonitored = monitoredSensorValues.Sum(v => v ?? 0.0); var otherPower = Math.Max(0.0, total - sumOfMonitored); return new PowerCalculationResult(otherPower, sumOfMonitored); } }