some QOL improvements

This commit is contained in:
ig 2023-08-30 16:50:38 +02:00
parent 005a5460db
commit 64b64cc1e0
1 changed files with 29 additions and 18 deletions

View File

@ -6,8 +6,6 @@ namespace InnovEnergy.Lib.Units.Composite;
public sealed class AcPower public sealed class AcPower
{ {
private AcPower(){}
public required ApparentPower Apparent { get; init; } public required ApparentPower Apparent { get; init; }
public required ActivePower Active { get; init; } public required ActivePower Active { get; init; }
public required ReactivePower Reactive { get; init; } public required ReactivePower Reactive { get; init; }
@ -84,23 +82,36 @@ public sealed class AcPower
}; };
} }
public static AcPower Null => FromVoltageCurrentPhi(0, 0, 0); public static AcPower operator +(AcPower left, AcPower right)
{
return FromActiveReactive
(
left.Active + right.Active,
left.Reactive + right.Reactive
);
}
public static AcPower operator +(AcPower left, AcPower right) => FromActiveReactive public static AcPower operator -(AcPower left, AcPower right)
( {
left.Active + right.Active, return left + -right;
left.Reactive + right.Reactive }
);
public static AcPower operator -(AcPower left, AcPower right) => FromActiveReactive public static AcPower operator -(AcPower p)
( {
left.Active - right.Active, var activePower = -p.Active;
left.Reactive - right.Reactive var reactivePower = -p.Reactive;
);
public static AcPower operator -(AcPower p) => FromActiveReactive(-p.Active, p.Reactive); return FromActiveReactive
(
activePower,
reactivePower
);
}
public static implicit operator AcPower(Double p) => FromActiveReactive(p, 0);
public static implicit operator AcPower(Int32 p) => FromActiveReactive(p, 0);
public override String ToString() => Active.ToString(); // TODO: show all public override String ToString() => Active.ToString(); // TODO: show all
} }