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

41 lines
1000 B
C#

using System.Collections;
namespace InnovEnergy.Lib.Units.Composite;
public record Ac3Bus : IReadOnlyList<AcPhase>
{
public required AcPhase L1 { get; init; }
public required AcPhase L2 { get; init; }
public required AcPhase L3 { get; init; }
public required Frequency Frequency { get; init; }
public AcPower Power => L1.Power + L2.Power + L3.Power;
public static Ac3Bus Zero => new Ac3Bus
{
Frequency = 0,
L1 = AcPhase.Zero,
L2 = AcPhase.Zero,
L3 = AcPhase.Zero,
};
public IEnumerator<AcPhase> GetEnumerator()
{
yield return L1;
yield return L2;
yield return L3;
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public Int32 Count => 3;
public AcPhase this[Int32 index] => index switch
{
0 => L1, // it's retarded
1 => L2,
2 => L3,
_ => throw new ArgumentOutOfRangeException(nameof(index))
};
}