Innovenergy_trunk/csharp/Lib/Units/Composite/AcPower.cs

34 lines
1.0 KiB
C#

using InnovEnergy.Lib.Units.Power;
using static System.Math;
namespace InnovEnergy.Lib.Units.Composite;
public record AcPower
{
public required ActivePower Active { get; init; }
public required ReactivePower Reactive { get; init; }
public ApparentPower Apparent => Sqrt(Active * Active + Reactive * Reactive);
public static AcPower operator +(AcPower left, AcPower right) => new AcPower
{
Active = left.Active + right.Active,
Reactive = left.Reactive + right.Reactive
};
public static AcPower operator -(AcPower left, AcPower right) => new AcPower
{
Active = left.Active - right.Active,
Reactive = left.Reactive - right.Reactive
};
public static AcPower operator -(AcPower p) => new AcPower
{
Active = -p.Active,
Reactive = -p.Reactive
};
public static implicit operator AcPower(Double p) => new AcPower { Active = p, Reactive = 0 };
public static implicit operator AcPower(Int32 p) => new AcPower { Active = p, Reactive = 0 };
}