From 476a0a0fe2e8633e98943026369a75ecd08909a6 Mon Sep 17 00:00:00 2001 From: ig Date: Sun, 26 Feb 2023 19:20:43 +0100 Subject: [PATCH] rename Ac1 in IAc1Connection to plain Ac --- .../StatusApi/Connections/IAc1Connection.cs | 2 +- csharp/Lib/StatusApi/DeviceStatus.cs | 19 +++++++------------ .../StatusApi/SinglePhaseInverterStatus.cs | 2 +- .../StatusApi/SinglePhasePvInverterStatus.cs | 2 +- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/csharp/Lib/StatusApi/Connections/IAc1Connection.cs b/csharp/Lib/StatusApi/Connections/IAc1Connection.cs index df3a472a1..d90b57938 100644 --- a/csharp/Lib/StatusApi/Connections/IAc1Connection.cs +++ b/csharp/Lib/StatusApi/Connections/IAc1Connection.cs @@ -4,5 +4,5 @@ namespace InnovEnergy.Lib.StatusApi.Connections; public interface IAc1Connection { - Ac1Phase Ac1 { get; } + Ac1Phase Ac { get; } } \ No newline at end of file diff --git a/csharp/Lib/StatusApi/DeviceStatus.cs b/csharp/Lib/StatusApi/DeviceStatus.cs index f34a37d23..6cdc1ef3f 100644 --- a/csharp/Lib/StatusApi/DeviceStatus.cs +++ b/csharp/Lib/StatusApi/DeviceStatus.cs @@ -1,17 +1,12 @@ +using InnovEnergy.Lib.Utils; + namespace InnovEnergy.Lib.StatusApi; public abstract record DeviceStatus { - public String DeviceType - { - get - { - var t = GetType(); - - while (!t!.IsAbstract) - t = t.BaseType; - - return t.Name.Replace("Status", ""); - } - } + public String DeviceType => GetType() + .Generate(t => t.BaseType!) + .First(t => t.IsAbstract) + .Name + .Replace("Status", ""); } \ No newline at end of file diff --git a/csharp/Lib/StatusApi/SinglePhaseInverterStatus.cs b/csharp/Lib/StatusApi/SinglePhaseInverterStatus.cs index a1b404bd6..9e1e2c8ba 100644 --- a/csharp/Lib/StatusApi/SinglePhaseInverterStatus.cs +++ b/csharp/Lib/StatusApi/SinglePhaseInverterStatus.cs @@ -3,7 +3,7 @@ using InnovEnergy.Lib.Units.Composite; namespace InnovEnergy.Lib.StatusApi; -public abstract record SinglePhaseInverterStatus(Ac1Phase Ac1, DcPhase Dc) : +public abstract record SinglePhaseInverterStatus(Ac1Phase Ac, DcPhase Dc) : DeviceStatus, IAc1Connection, IDcConnection; diff --git a/csharp/Lib/StatusApi/SinglePhasePvInverterStatus.cs b/csharp/Lib/StatusApi/SinglePhasePvInverterStatus.cs index 377f9f6f3..51c113fce 100644 --- a/csharp/Lib/StatusApi/SinglePhasePvInverterStatus.cs +++ b/csharp/Lib/StatusApi/SinglePhasePvInverterStatus.cs @@ -3,7 +3,7 @@ using InnovEnergy.Lib.Units.Composite; namespace InnovEnergy.Lib.StatusApi; -public abstract record SinglePhasePvInverterStatus(Ac1Phase Ac1, IReadOnlyList Strings) : +public abstract record SinglePhasePvInverterStatus(Ac1Phase Ac, IReadOnlyList Strings) : DeviceStatus, IAc1Connection, IPvConnection;