From 2ec5b34971683073ac6ffd9974d043ddeb68e9a1 Mon Sep 17 00:00:00 2001 From: ig Date: Thu, 4 May 2023 09:37:22 +0200 Subject: [PATCH] statusApi V2 --- csharp/Lib/StatusApi/BatteryStatus.cs | 15 --------------- csharp/Lib/StatusApi/CombinedStatus.cs | 16 ++++++++++++---- csharp/Lib/StatusApi/DeviceTypes/IAc1Meter.cs | 7 +++++++ csharp/Lib/StatusApi/DeviceTypes/IAc3Meter.cs | 7 +++++++ csharp/Lib/StatusApi/DeviceTypes/IAcDc1.cs | 8 ++++++++ csharp/Lib/StatusApi/DeviceTypes/IAcDc3.cs | 9 +++++++++ csharp/Lib/StatusApi/DeviceTypes/IBattery.cs | 9 +++++++++ .../IDcDc.cs} | 4 ++-- csharp/Lib/StatusApi/DeviceTypes/IMppt.cs | 10 ++++++++++ csharp/Lib/StatusApi/DeviceTypes/IPvAc1.cs | 7 +++++++ csharp/Lib/StatusApi/DeviceTypes/IPvAc3.cs | 8 ++++++++ csharp/Lib/StatusApi/MpptStatus.cs | 14 -------------- csharp/Lib/StatusApi/PowerMeterStatus.cs | 11 ----------- .../Lib/StatusApi/SinglePhaseInverterStatus.cs | 13 ------------- .../Lib/StatusApi/SinglePhasePvInverterStatus.cs | 12 ------------ csharp/Lib/StatusApi/ThreePhaseInverterStatus.cs | 13 ------------- .../Lib/StatusApi/ThreePhasePvInverterStatus.cs | 12 ------------ 17 files changed, 79 insertions(+), 96 deletions(-) delete mode 100644 csharp/Lib/StatusApi/BatteryStatus.cs create mode 100644 csharp/Lib/StatusApi/DeviceTypes/IAc1Meter.cs create mode 100644 csharp/Lib/StatusApi/DeviceTypes/IAc3Meter.cs create mode 100644 csharp/Lib/StatusApi/DeviceTypes/IAcDc1.cs create mode 100644 csharp/Lib/StatusApi/DeviceTypes/IAcDc3.cs create mode 100644 csharp/Lib/StatusApi/DeviceTypes/IBattery.cs rename csharp/Lib/StatusApi/{DcDcConverterStatus.cs => DeviceTypes/IDcDc.cs} (67%) create mode 100644 csharp/Lib/StatusApi/DeviceTypes/IMppt.cs create mode 100644 csharp/Lib/StatusApi/DeviceTypes/IPvAc1.cs create mode 100644 csharp/Lib/StatusApi/DeviceTypes/IPvAc3.cs delete mode 100644 csharp/Lib/StatusApi/MpptStatus.cs delete mode 100644 csharp/Lib/StatusApi/PowerMeterStatus.cs delete mode 100644 csharp/Lib/StatusApi/SinglePhaseInverterStatus.cs delete mode 100644 csharp/Lib/StatusApi/SinglePhasePvInverterStatus.cs delete mode 100644 csharp/Lib/StatusApi/ThreePhaseInverterStatus.cs delete mode 100644 csharp/Lib/StatusApi/ThreePhasePvInverterStatus.cs diff --git a/csharp/Lib/StatusApi/BatteryStatus.cs b/csharp/Lib/StatusApi/BatteryStatus.cs deleted file mode 100644 index be2c8f0d5..000000000 --- a/csharp/Lib/StatusApi/BatteryStatus.cs +++ /dev/null @@ -1,15 +0,0 @@ -using InnovEnergy.Lib.StatusApi.Connections; -using InnovEnergy.Lib.Units; -using InnovEnergy.Lib.Units.Composite; - -namespace InnovEnergy.Lib.StatusApi; - - -#pragma warning disable CS8618 - -public record BatteryStatus : IDcConnection -{ - public DcBus Dc { get; init; } - public Percent Soc { get; init; } - public Temperature Temperature { get; init; } -} \ No newline at end of file diff --git a/csharp/Lib/StatusApi/CombinedStatus.cs b/csharp/Lib/StatusApi/CombinedStatus.cs index 132f0c573..a27683c40 100644 --- a/csharp/Lib/StatusApi/CombinedStatus.cs +++ b/csharp/Lib/StatusApi/CombinedStatus.cs @@ -1,12 +1,20 @@ +using System.Collections; + namespace InnovEnergy.Lib.StatusApi; #pragma warning disable CS8618 -public record CombinedStatus +public class CombinedStatus : IReadOnlyList { - public T Combined { get; init; } - public IReadOnlyList Children { get; init; } + public T? Combined { get; init; } + public IReadOnlyList Stati { get; init; } - public Boolean Available => Children.Any(); + public Boolean Available => Stati.Count > 0; + + public IEnumerator GetEnumerator() => Stati.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); + public Int32 Count => Stati.Count; + + public T this[Int32 index] => Stati[index]; } \ No newline at end of file diff --git a/csharp/Lib/StatusApi/DeviceTypes/IAc1Meter.cs b/csharp/Lib/StatusApi/DeviceTypes/IAc1Meter.cs new file mode 100644 index 000000000..43ad11465 --- /dev/null +++ b/csharp/Lib/StatusApi/DeviceTypes/IAc1Meter.cs @@ -0,0 +1,7 @@ +using InnovEnergy.Lib.StatusApi.Connections; + +namespace InnovEnergy.Lib.StatusApi.DeviceTypes; + +public interface IAc1Meter : IAc1Connection +{ +} \ No newline at end of file diff --git a/csharp/Lib/StatusApi/DeviceTypes/IAc3Meter.cs b/csharp/Lib/StatusApi/DeviceTypes/IAc3Meter.cs new file mode 100644 index 000000000..f3a81e452 --- /dev/null +++ b/csharp/Lib/StatusApi/DeviceTypes/IAc3Meter.cs @@ -0,0 +1,7 @@ +using InnovEnergy.Lib.StatusApi.Connections; + +namespace InnovEnergy.Lib.StatusApi.DeviceTypes; + +public interface IAc3Meter : IAc3Connection +{ +} \ No newline at end of file diff --git a/csharp/Lib/StatusApi/DeviceTypes/IAcDc1.cs b/csharp/Lib/StatusApi/DeviceTypes/IAcDc1.cs new file mode 100644 index 000000000..baeca37d5 --- /dev/null +++ b/csharp/Lib/StatusApi/DeviceTypes/IAcDc1.cs @@ -0,0 +1,8 @@ +using InnovEnergy.Lib.StatusApi.Connections; + +namespace InnovEnergy.Lib.StatusApi.DeviceTypes; + + +public interface IAcDc1 : IAc1Connection, IDcConnection +{ +} diff --git a/csharp/Lib/StatusApi/DeviceTypes/IAcDc3.cs b/csharp/Lib/StatusApi/DeviceTypes/IAcDc3.cs new file mode 100644 index 000000000..8f913d776 --- /dev/null +++ b/csharp/Lib/StatusApi/DeviceTypes/IAcDc3.cs @@ -0,0 +1,9 @@ +using InnovEnergy.Lib.StatusApi.Connections; + +namespace InnovEnergy.Lib.StatusApi.DeviceTypes; + + +public interface IAcDc3 : IAc3Connection, IDcConnection +{ +} + \ No newline at end of file diff --git a/csharp/Lib/StatusApi/DeviceTypes/IBattery.cs b/csharp/Lib/StatusApi/DeviceTypes/IBattery.cs new file mode 100644 index 000000000..094127cf9 --- /dev/null +++ b/csharp/Lib/StatusApi/DeviceTypes/IBattery.cs @@ -0,0 +1,9 @@ +using InnovEnergy.Lib.StatusApi.Connections; +using InnovEnergy.Lib.Units; + +namespace InnovEnergy.Lib.StatusApi.DeviceTypes; + +public interface IBattery : IDcConnection +{ + public Percent Soc { get;} +} \ No newline at end of file diff --git a/csharp/Lib/StatusApi/DcDcConverterStatus.cs b/csharp/Lib/StatusApi/DeviceTypes/IDcDc.cs similarity index 67% rename from csharp/Lib/StatusApi/DcDcConverterStatus.cs rename to csharp/Lib/StatusApi/DeviceTypes/IDcDc.cs index 9a7e1c2d1..faf4aa4de 100644 --- a/csharp/Lib/StatusApi/DcDcConverterStatus.cs +++ b/csharp/Lib/StatusApi/DeviceTypes/IDcDc.cs @@ -1,10 +1,10 @@ using InnovEnergy.Lib.Units.Composite; -namespace InnovEnergy.Lib.StatusApi; +namespace InnovEnergy.Lib.StatusApi.DeviceTypes; #pragma warning disable CS8618 -public record DcDcConverterStatus +public interface IDcDc { public DcBus Left { get; init; } public DcBus Right { get; init; } diff --git a/csharp/Lib/StatusApi/DeviceTypes/IMppt.cs b/csharp/Lib/StatusApi/DeviceTypes/IMppt.cs new file mode 100644 index 000000000..9d94b24a9 --- /dev/null +++ b/csharp/Lib/StatusApi/DeviceTypes/IMppt.cs @@ -0,0 +1,10 @@ +using InnovEnergy.Lib.StatusApi.Connections; + +namespace InnovEnergy.Lib.StatusApi.DeviceTypes; + + +public interface IMppt : IDcConnection, IPvConnection +{ +} + + \ No newline at end of file diff --git a/csharp/Lib/StatusApi/DeviceTypes/IPvAc1.cs b/csharp/Lib/StatusApi/DeviceTypes/IPvAc1.cs new file mode 100644 index 000000000..8663d1a16 --- /dev/null +++ b/csharp/Lib/StatusApi/DeviceTypes/IPvAc1.cs @@ -0,0 +1,7 @@ +using InnovEnergy.Lib.StatusApi.Connections; + +namespace InnovEnergy.Lib.StatusApi.DeviceTypes; + +public interface IPvAc1 : IAc1Connection, IPvConnection +{ +} diff --git a/csharp/Lib/StatusApi/DeviceTypes/IPvAc3.cs b/csharp/Lib/StatusApi/DeviceTypes/IPvAc3.cs new file mode 100644 index 000000000..8f493228c --- /dev/null +++ b/csharp/Lib/StatusApi/DeviceTypes/IPvAc3.cs @@ -0,0 +1,8 @@ +using InnovEnergy.Lib.StatusApi.Connections; + +namespace InnovEnergy.Lib.StatusApi.DeviceTypes; + + +public interface IPvAc3 : IAc3Connection, IPvConnection +{ +} diff --git a/csharp/Lib/StatusApi/MpptStatus.cs b/csharp/Lib/StatusApi/MpptStatus.cs deleted file mode 100644 index c8b52cb98..000000000 --- a/csharp/Lib/StatusApi/MpptStatus.cs +++ /dev/null @@ -1,14 +0,0 @@ -using InnovEnergy.Lib.StatusApi.Connections; -using InnovEnergy.Lib.Units.Composite; - -namespace InnovEnergy.Lib.StatusApi; - -#pragma warning disable CS8618 - -public record MpptStatus : IDcConnection, IPvConnection -{ - public DcBus Dc { get; init; } - public IReadOnlyList Strings { get; init; } -} - - \ No newline at end of file diff --git a/csharp/Lib/StatusApi/PowerMeterStatus.cs b/csharp/Lib/StatusApi/PowerMeterStatus.cs deleted file mode 100644 index 5c10f1ded..000000000 --- a/csharp/Lib/StatusApi/PowerMeterStatus.cs +++ /dev/null @@ -1,11 +0,0 @@ -using InnovEnergy.Lib.StatusApi.Connections; -using InnovEnergy.Lib.Units.Composite; - -namespace InnovEnergy.Lib.StatusApi; - -#pragma warning disable CS8618 - -public record PowerMeterStatus : IAc3Connection -{ - public Ac3Bus Ac { get; init; } -} \ No newline at end of file diff --git a/csharp/Lib/StatusApi/SinglePhaseInverterStatus.cs b/csharp/Lib/StatusApi/SinglePhaseInverterStatus.cs deleted file mode 100644 index 247831ffc..000000000 --- a/csharp/Lib/StatusApi/SinglePhaseInverterStatus.cs +++ /dev/null @@ -1,13 +0,0 @@ -using InnovEnergy.Lib.StatusApi.Connections; -using InnovEnergy.Lib.Units.Composite; - -namespace InnovEnergy.Lib.StatusApi; - - -#pragma warning disable CS8618 - -public record SinglePhaseInverterStatus : IAc1Connection, IDcConnection -{ - public Ac1Bus Ac { get; init; } - public DcBus Dc { get; init; } -} diff --git a/csharp/Lib/StatusApi/SinglePhasePvInverterStatus.cs b/csharp/Lib/StatusApi/SinglePhasePvInverterStatus.cs deleted file mode 100644 index 6a47bb521..000000000 --- a/csharp/Lib/StatusApi/SinglePhasePvInverterStatus.cs +++ /dev/null @@ -1,12 +0,0 @@ -using InnovEnergy.Lib.StatusApi.Connections; -using InnovEnergy.Lib.Units.Composite; - -namespace InnovEnergy.Lib.StatusApi; - -#pragma warning disable CS8618 - -public record SinglePhasePvInverterStatus : IAc1Connection, IPvConnection -{ - public Ac1Bus Ac { get; init; } - public IReadOnlyList Strings { get; init; } -} diff --git a/csharp/Lib/StatusApi/ThreePhaseInverterStatus.cs b/csharp/Lib/StatusApi/ThreePhaseInverterStatus.cs deleted file mode 100644 index b33618c97..000000000 --- a/csharp/Lib/StatusApi/ThreePhaseInverterStatus.cs +++ /dev/null @@ -1,13 +0,0 @@ -using InnovEnergy.Lib.StatusApi.Connections; -using InnovEnergy.Lib.Units.Composite; - -namespace InnovEnergy.Lib.StatusApi; - -#pragma warning disable CS8618 - -public record ThreePhaseInverterStatus : IAc3Connection, IDcConnection -{ - public Ac3Bus Ac { get; init; } - public DcBus Dc { get; init; } -} - \ No newline at end of file diff --git a/csharp/Lib/StatusApi/ThreePhasePvInverterStatus.cs b/csharp/Lib/StatusApi/ThreePhasePvInverterStatus.cs deleted file mode 100644 index 94c31980d..000000000 --- a/csharp/Lib/StatusApi/ThreePhasePvInverterStatus.cs +++ /dev/null @@ -1,12 +0,0 @@ -using InnovEnergy.Lib.StatusApi.Connections; -using InnovEnergy.Lib.Units.Composite; - -namespace InnovEnergy.Lib.StatusApi; - -#pragma warning disable CS8618 - -public record ThreePhasePvInverterStatus : IAc3Connection, IPvConnection -{ - public Ac3Bus Ac { get; init; } - public IReadOnlyList Strings { get; init; } -}