some QOL improvements
This commit is contained in:
parent
005a5460db
commit
64b64cc1e0
|
@ -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)
|
||||||
|
{
|
||||||
|
return left + -right;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AcPower operator -(AcPower p)
|
||||||
|
{
|
||||||
|
var activePower = -p.Active;
|
||||||
|
var reactivePower = -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 static AcPower operator +(AcPower left, AcPower right) => FromActiveReactive
|
|
||||||
(
|
|
||||||
left.Active + right.Active,
|
|
||||||
left.Reactive + right.Reactive
|
|
||||||
);
|
|
||||||
|
|
||||||
public static AcPower operator -(AcPower left, AcPower right) => FromActiveReactive
|
|
||||||
(
|
|
||||||
left.Active - right.Active,
|
|
||||||
left.Reactive - right.Reactive
|
|
||||||
);
|
|
||||||
|
|
||||||
public static AcPower operator -(AcPower p) => FromActiveReactive(-p.Active, p.Reactive);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public override String ToString() => Active.ToString(); // TODO: show all
|
public override String ToString() => Active.ToString(); // TODO: show all
|
||||||
}
|
}
|
Loading…
Reference in New Issue