Add +- operators to AcPower

This commit is contained in:
ig 2023-06-20 10:13:28 +02:00
parent 9b997b353f
commit 4cdfb37e96
3 changed files with 16 additions and 0 deletions

View File

@ -42,4 +42,7 @@ public sealed class AcPhase
};
public static AcPhase Null { get; } = FromVoltageCurrentPhi(0, 0, 0);
}

View File

@ -86,5 +86,15 @@ public sealed class AcPower
public static AcPower Null { get; } = FromVoltageCurrentPhi(0, 0, 0);
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
}

View File

@ -11,5 +11,8 @@ public sealed class ActivePower : AcPower
public static implicit operator ActivePower(Double d) => new ActivePower(d);
public static implicit operator Double(ActivePower d) => d.Value;
public static ActivePower operator -(ActivePower d) => -d.Value;
}