make BatteryStatus nullable

This commit is contained in:
ig 2023-09-01 11:12:23 +02:00
parent 851b936217
commit 7fc5f80e8c
3 changed files with 8 additions and 18 deletions

View File

@ -14,7 +14,7 @@ public record StatusRecord
{
public required AcDcDevicesRecord AcDc { get; init; }
public required DcDcDevicesRecord DcDc { get; init; }
public required Battery48TlRecords Battery { get; init; }
public required Battery48TlRecords? Battery { get; init; }
public required EmuMeterRegisters? GridMeter { get; init; }
public required EmuMeterRegisters? LoadOnAcIsland { get; init; }
public required AcPowerDevice? LoadOnAcGrid { get; init; }

View File

@ -18,11 +18,8 @@ using InnovEnergy.Lib.Devices.Trumpf.TruConvertDc.Control;
using InnovEnergy.Lib.Protocols.Modbus.Channels;
using InnovEnergy.Lib.Time.Unix;
using InnovEnergy.Lib.Units;
using InnovEnergy.Lib.Units.Power;
using InnovEnergy.Lib.Utils;
using static InnovEnergy.Lib.Devices.Trumpf.SystemControl.DataTypes.SystemConfig;
using AcPower = InnovEnergy.Lib.Units.Composite.AcPower;
using Exception = System.Exception;
#pragma warning disable IL2026
@ -75,6 +72,7 @@ internal static class Program
e.LogError();
}
}
// ReSharper disable once FunctionNeverReturns
}
private static async Task Run()
@ -115,9 +113,9 @@ internal static class Program
return new StatusRecord
{
AcDc = acDc ,
DcDc = dcDc ,
Battery = battery ,
AcDc = acDc,
DcDc = dcDc,
Battery = battery,
Relays = relays,
GridMeter = gridMeter,
@ -171,6 +169,7 @@ internal static class Program
{
Watchdog.NotifyAlive();
var t = UnixTime.Now;
var record = ReadStatus();
int i = 1;
@ -218,15 +217,6 @@ internal static class Program
// ReSharper disable once FunctionNeverReturns
}
private static async Task<T?> ResultOrNull<T>(this Task<T> task)
{
if (task.Status == TaskStatus.RanToCompletion)
return await task;
return default;
}
private static void ControlConstants(this StatusRecord r)
{

View File

@ -4,10 +4,10 @@ namespace InnovEnergy.Lib.StatusApi.Connections;
public interface IPvConnection
{
IReadOnlyList<DcBus> Strings { get; }
IReadOnlyList<DcBus> Strings { get; }
}
public interface IPvConnection<out T> where T : IReadOnlyList<DcBus>
{
T Strings { get; }
}
}