From 045de6ac0d417fd13ee24933cd646b04f3badbb0 Mon Sep 17 00:00:00 2001 From: ig Date: Tue, 13 Jun 2023 13:03:26 +0200 Subject: [PATCH] Status API V2 --- csharp/Lib/StatusApi/CombinedStatus.cs | 20 ------------------- .../StatusApi/Connections/IAc1Connection.cs | 3 ++- .../StatusApi/Connections/IAc3Connection.cs | 3 ++- .../StatusApi/Connections/IDcConnection.cs | 4 ++-- .../StatusApi/Connections/IPvConnection.cs | 5 +++++ csharp/Lib/StatusApi/DeviceTypes/IAc1Meter.cs | 3 ++- csharp/Lib/StatusApi/DeviceTypes/IAc3Meter.cs | 4 +++- csharp/Lib/StatusApi/DeviceTypes/IAcDc1.cs | 3 ++- csharp/Lib/StatusApi/DeviceTypes/IAcDc3.cs | 3 +-- csharp/Lib/StatusApi/DeviceTypes/IBattery.cs | 6 ++++-- csharp/Lib/StatusApi/DeviceTypes/IDcDc.cs | 10 ++++------ csharp/Lib/StatusApi/DeviceTypes/IMppt.cs | 3 +-- csharp/Lib/StatusApi/DeviceTypes/IPvAc1.cs | 1 + csharp/Lib/StatusApi/DeviceTypes/IPvAc3.cs | 3 ++- csharp/Lib/StatusApi/IDeviceRecord.cs | 7 +++++++ 15 files changed, 38 insertions(+), 40 deletions(-) delete mode 100644 csharp/Lib/StatusApi/CombinedStatus.cs create mode 100644 csharp/Lib/StatusApi/IDeviceRecord.cs diff --git a/csharp/Lib/StatusApi/CombinedStatus.cs b/csharp/Lib/StatusApi/CombinedStatus.cs deleted file mode 100644 index a27683c40..000000000 --- a/csharp/Lib/StatusApi/CombinedStatus.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System.Collections; - -namespace InnovEnergy.Lib.StatusApi; - -#pragma warning disable CS8618 - -public class CombinedStatus : IReadOnlyList -{ - public T? Combined { get; init; } - public IReadOnlyList Stati { get; init; } - - 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/Connections/IAc1Connection.cs b/csharp/Lib/StatusApi/Connections/IAc1Connection.cs index 54060cb20..8ede39061 100644 --- a/csharp/Lib/StatusApi/Connections/IAc1Connection.cs +++ b/csharp/Lib/StatusApi/Connections/IAc1Connection.cs @@ -5,4 +5,5 @@ namespace InnovEnergy.Lib.StatusApi.Connections; public interface IAc1Connection { Ac1Bus Ac { get; } -} \ No newline at end of file +} + diff --git a/csharp/Lib/StatusApi/Connections/IAc3Connection.cs b/csharp/Lib/StatusApi/Connections/IAc3Connection.cs index a1c0ca1b5..752db3c92 100644 --- a/csharp/Lib/StatusApi/Connections/IAc3Connection.cs +++ b/csharp/Lib/StatusApi/Connections/IAc3Connection.cs @@ -5,4 +5,5 @@ namespace InnovEnergy.Lib.StatusApi.Connections; public interface IAc3Connection { Ac3Bus Ac { get; } -} \ No newline at end of file +} + diff --git a/csharp/Lib/StatusApi/Connections/IDcConnection.cs b/csharp/Lib/StatusApi/Connections/IDcConnection.cs index 04d83289f..f891bbf6e 100644 --- a/csharp/Lib/StatusApi/Connections/IDcConnection.cs +++ b/csharp/Lib/StatusApi/Connections/IDcConnection.cs @@ -2,8 +2,8 @@ using InnovEnergy.Lib.Units.Composite; namespace InnovEnergy.Lib.StatusApi.Connections; - public interface IDcConnection { DcBus Dc { get; } -} \ No newline at end of file +} + diff --git a/csharp/Lib/StatusApi/Connections/IPvConnection.cs b/csharp/Lib/StatusApi/Connections/IPvConnection.cs index 6dfddccea..29a2d666e 100644 --- a/csharp/Lib/StatusApi/Connections/IPvConnection.cs +++ b/csharp/Lib/StatusApi/Connections/IPvConnection.cs @@ -5,4 +5,9 @@ namespace InnovEnergy.Lib.StatusApi.Connections; public interface IPvConnection { IReadOnlyList Strings { get; } +} + +public interface IPvConnection where T : IReadOnlyList +{ + T Strings { get; } } \ No newline at end of file diff --git a/csharp/Lib/StatusApi/DeviceTypes/IAc1Meter.cs b/csharp/Lib/StatusApi/DeviceTypes/IAc1Meter.cs index 43ad11465..76c44e55c 100644 --- a/csharp/Lib/StatusApi/DeviceTypes/IAc1Meter.cs +++ b/csharp/Lib/StatusApi/DeviceTypes/IAc1Meter.cs @@ -1,7 +1,8 @@ using InnovEnergy.Lib.StatusApi.Connections; +using InnovEnergy.Lib.Units.Composite; 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 index f3a81e452..58a1c689c 100644 --- a/csharp/Lib/StatusApi/DeviceTypes/IAc3Meter.cs +++ b/csharp/Lib/StatusApi/DeviceTypes/IAc3Meter.cs @@ -1,7 +1,9 @@ using InnovEnergy.Lib.StatusApi.Connections; +using InnovEnergy.Lib.Units.Composite; 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 index baeca37d5..9ed14c27b 100644 --- a/csharp/Lib/StatusApi/DeviceTypes/IAcDc1.cs +++ b/csharp/Lib/StatusApi/DeviceTypes/IAcDc1.cs @@ -1,8 +1,9 @@ using InnovEnergy.Lib.StatusApi.Connections; +using InnovEnergy.Lib.Units.Composite; 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 index 8f913d776..490f0b80e 100644 --- a/csharp/Lib/StatusApi/DeviceTypes/IAcDc3.cs +++ b/csharp/Lib/StatusApi/DeviceTypes/IAcDc3.cs @@ -2,8 +2,7 @@ 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 index 094127cf9..b40f1a711 100644 --- a/csharp/Lib/StatusApi/DeviceTypes/IBattery.cs +++ b/csharp/Lib/StatusApi/DeviceTypes/IBattery.cs @@ -1,9 +1,11 @@ using InnovEnergy.Lib.StatusApi.Connections; using InnovEnergy.Lib.Units; +using InnovEnergy.Lib.Units.Composite; namespace InnovEnergy.Lib.StatusApi.DeviceTypes; public interface IBattery : IDcConnection { - public Percent Soc { get;} -} \ No newline at end of file + Percent Soc { get; } +} + diff --git a/csharp/Lib/StatusApi/DeviceTypes/IDcDc.cs b/csharp/Lib/StatusApi/DeviceTypes/IDcDc.cs index faf4aa4de..9ff3ec702 100644 --- a/csharp/Lib/StatusApi/DeviceTypes/IDcDc.cs +++ b/csharp/Lib/StatusApi/DeviceTypes/IDcDc.cs @@ -4,11 +4,9 @@ namespace InnovEnergy.Lib.StatusApi.DeviceTypes; #pragma warning disable CS8618 -public interface IDcDc +public interface IDcDc { - public DcBus Left { get; init; } - public DcBus Right { get; init; } + DcBus DcLeft { get; } + DcBus DcRight { get; } } - - - \ No newline at end of file + diff --git a/csharp/Lib/StatusApi/DeviceTypes/IMppt.cs b/csharp/Lib/StatusApi/DeviceTypes/IMppt.cs index 9d94b24a9..70e208ae0 100644 --- a/csharp/Lib/StatusApi/DeviceTypes/IMppt.cs +++ b/csharp/Lib/StatusApi/DeviceTypes/IMppt.cs @@ -1,10 +1,9 @@ using InnovEnergy.Lib.StatusApi.Connections; +using InnovEnergy.Lib.Units.Composite; 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 index 8663d1a16..fc04322da 100644 --- a/csharp/Lib/StatusApi/DeviceTypes/IPvAc1.cs +++ b/csharp/Lib/StatusApi/DeviceTypes/IPvAc1.cs @@ -1,4 +1,5 @@ using InnovEnergy.Lib.StatusApi.Connections; +using InnovEnergy.Lib.Units.Composite; namespace InnovEnergy.Lib.StatusApi.DeviceTypes; diff --git a/csharp/Lib/StatusApi/DeviceTypes/IPvAc3.cs b/csharp/Lib/StatusApi/DeviceTypes/IPvAc3.cs index 8f493228c..7d45ce989 100644 --- a/csharp/Lib/StatusApi/DeviceTypes/IPvAc3.cs +++ b/csharp/Lib/StatusApi/DeviceTypes/IPvAc3.cs @@ -1,8 +1,9 @@ using InnovEnergy.Lib.StatusApi.Connections; +using InnovEnergy.Lib.Units.Composite; namespace InnovEnergy.Lib.StatusApi.DeviceTypes; - public interface IPvAc3 : IAc3Connection, IPvConnection { } + diff --git a/csharp/Lib/StatusApi/IDeviceRecord.cs b/csharp/Lib/StatusApi/IDeviceRecord.cs new file mode 100644 index 000000000..ea6a25f1b --- /dev/null +++ b/csharp/Lib/StatusApi/IDeviceRecord.cs @@ -0,0 +1,7 @@ +namespace InnovEnergy.Lib.StatusApi; + +public interface IDeviceRecord +{ + S Status { get; } + C Control { get; } +} \ No newline at end of file