17 lines
575 B
C#
17 lines
575 B
C#
using PowerMonitorManager.Interface;
|
|
using PowerMonitorManager.Models;
|
|
|
|
namespace PowerMonitorManager;
|
|
|
|
public sealed class OtherPowerCalculationService : IOtherPowerCalculationService
|
|
{
|
|
public PowerCalculationResult CalculateOtherPower(double? totalHomePower, IReadOnlyList<double?> 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);
|
|
}
|
|
}
|