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

41 lines
1000 B
C#
Raw Normal View History

2023-02-26 14:39:55 +00:00
2023-09-01 08:03:29 +00:00
using System.Collections;
namespace InnovEnergy.Lib.Units.Composite;
2023-09-01 08:03:29 +00:00
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; }
2023-05-04 07:36:30 +00:00
2023-09-01 06:54:46 +00:00
public AcPower Power => L1.Power + L2.Power + L3.Power;
public static Ac3Bus Zero => new Ac3Bus
2023-05-04 07:36:30 +00:00
{
2023-09-01 06:54:46 +00:00
Frequency = 0,
L1 = AcPhase.Zero,
L2 = AcPhase.Zero,
L3 = AcPhase.Zero,
2023-05-04 07:36:30 +00:00
};
2023-09-01 08:03:29 +00:00
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))
};
2023-05-24 10:04:01 +00:00
}