introduce AcDcDevicesRecord.Null
This commit is contained in:
parent
cc554c1964
commit
5f54dd602f
|
@ -1,15 +1,12 @@
|
||||||
using InnovEnergy.Lib.Devices.Trumpf.SystemControl;
|
using InnovEnergy.Lib.Devices.Trumpf.SystemControl;
|
||||||
using InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.DataTypes;
|
using InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.DataTypes;
|
||||||
using InnovEnergy.Lib.StatusApi.DeviceTypes;
|
|
||||||
using InnovEnergy.Lib.Units.Composite;
|
using InnovEnergy.Lib.Units.Composite;
|
||||||
|
|
||||||
namespace InnovEnergy.Lib.Devices.Trumpf.TruConvertAc;
|
namespace InnovEnergy.Lib.Devices.Trumpf.TruConvertAc;
|
||||||
|
|
||||||
public class AcDcDevicesRecord : IAcDc3
|
public class AcDcDevicesRecord
|
||||||
{
|
{
|
||||||
|
public static AcDcDevicesRecord Null { get; } = new AcDcDevicesRecord(null, Array.Empty<AcDcRecord>());
|
||||||
// private static readonly AcPhase NoAcPhase = Ac3Bus.FromPhasesAndFrequency()
|
|
||||||
// private static readonly Ac3Bus NoAcDevice = Ac3Bus.FromPhasesAndFrequency()
|
|
||||||
|
|
||||||
public AcDcDevicesRecord(SystemControlRegisters? systemControl, IReadOnlyList<AcDcRecord> devices)
|
public AcDcDevicesRecord(SystemControlRegisters? systemControl, IReadOnlyList<AcDcRecord> devices)
|
||||||
{
|
{
|
||||||
|
@ -60,11 +57,26 @@ public class AcDcDevicesRecord : IAcDc3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DcBus Dc => Devices.Count == 0
|
public DcBus Dc
|
||||||
? DcBus.Null
|
{
|
||||||
: DcBus.FromVoltageCurrent
|
get
|
||||||
|
{
|
||||||
|
if (Devices.Count == 0)
|
||||||
|
return DcBus.Null;
|
||||||
|
|
||||||
|
var u = Devices
|
||||||
|
.Select(d => d.Status.DcVoltages.Extern)
|
||||||
|
.Select(vs => vs.LowerHalf + vs.UpperHalf)
|
||||||
|
.Average();
|
||||||
|
|
||||||
|
var p = Ac.Power.Active.Value;
|
||||||
|
var i = u == 0 ? 0 : p / u;
|
||||||
|
|
||||||
|
return DcBus.FromVoltageCurrent
|
||||||
(
|
(
|
||||||
voltage: Devices.Average(d => d.Status.Dc.Voltage),
|
voltage: u,
|
||||||
current: Devices.Sum(d => d.Status.Dc.Current)
|
current: i
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue