2023-06-13 11:01:01 +00:00
|
|
|
|
|
|
|
using InnovEnergy.Lib.Devices.Trumpf.SystemControl.DataTypes;
|
|
|
|
using InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.DataTypes;
|
|
|
|
using InnovEnergy.Lib.Units.Composite;
|
|
|
|
using AlarmMessage = InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.DataTypes.AlarmMessage;
|
|
|
|
using WarningMessage = InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.DataTypes.WarningMessage;
|
|
|
|
|
|
|
|
namespace InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.Status;
|
|
|
|
|
|
|
|
public class AcDcStatus
|
|
|
|
{
|
|
|
|
public Ac3Bus Ac => Ac3Bus.FromPhasesAndFrequency(L1, L2, L3, _Self.GridFrequency);
|
|
|
|
public PowerLimit PowerLimitedBy => _Self.PowerLimitedBy;
|
|
|
|
public InverterStates InverterState => new(_Self);
|
|
|
|
public GridType ActiveGridType => _Self.ActiveGridType;
|
2023-06-20 07:50:28 +00:00
|
|
|
public Voltages DcVoltages => new(_Self);
|
2023-06-13 11:01:01 +00:00
|
|
|
public Temperatures Temperature => new(_Self);
|
|
|
|
public OverloadCapacity OverloadCapacity => new(_Self);
|
|
|
|
public Nominals Nominal => new(_Self);
|
|
|
|
|
|
|
|
public IReadOnlyList<AlarmMessage> Alarms => GetAlarms ().Take(_Self.NumberOfAlarms ).Where(IsAcDcAlarm ).ToList();
|
|
|
|
public IReadOnlyList<WarningMessage> Warnings => GetWarnings().Take(_Self.NumberOfWarnings).Where(IsAcDcWarning).ToList();
|
|
|
|
|
|
|
|
private IEnumerable<AlarmMessage> GetAlarms()
|
|
|
|
{
|
|
|
|
yield return _Self.Alarm1;
|
|
|
|
yield return _Self.Alarm2;
|
|
|
|
yield return _Self.Alarm3;
|
|
|
|
yield return _Self.Alarm4;
|
|
|
|
yield return _Self.Alarm5;
|
|
|
|
yield return _Self.Alarm6;
|
|
|
|
yield return _Self.Alarm7;
|
|
|
|
yield return _Self.Alarm8;
|
|
|
|
yield return _Self.Alarm9;
|
|
|
|
yield return _Self.Alarm10;
|
|
|
|
yield return _Self.Alarm11;
|
|
|
|
yield return _Self.Alarm12;
|
|
|
|
yield return _Self.Alarm13;
|
|
|
|
yield return _Self.Alarm14;
|
|
|
|
yield return _Self.Alarm15;
|
|
|
|
yield return _Self.Alarm16;
|
|
|
|
yield return _Self.Alarm17;
|
|
|
|
yield return _Self.Alarm18;
|
|
|
|
yield return _Self.Alarm19;
|
|
|
|
yield return _Self.Alarm20;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static Boolean IsAcDcAlarm(AlarmMessage alarm) => (UInt16)alarm is >= 50000 and < 60000;
|
|
|
|
|
|
|
|
private IEnumerable<WarningMessage> GetWarnings()
|
|
|
|
{
|
|
|
|
yield return _Self.Warning1;
|
|
|
|
yield return _Self.Warning2;
|
|
|
|
yield return _Self.Warning3;
|
|
|
|
yield return _Self.Warning4;
|
|
|
|
yield return _Self.Warning5;
|
|
|
|
yield return _Self.Warning6;
|
|
|
|
yield return _Self.Warning7;
|
|
|
|
yield return _Self.Warning8;
|
|
|
|
yield return _Self.Warning9;
|
|
|
|
yield return _Self.Warning10;
|
|
|
|
yield return _Self.Warning11;
|
|
|
|
yield return _Self.Warning12;
|
|
|
|
yield return _Self.Warning13;
|
|
|
|
yield return _Self.Warning14;
|
|
|
|
yield return _Self.Warning15;
|
|
|
|
yield return _Self.Warning16;
|
|
|
|
yield return _Self.Warning17;
|
|
|
|
yield return _Self.Warning18;
|
|
|
|
yield return _Self.Warning19;
|
|
|
|
yield return _Self.Warning20;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: there are no AcDc Warnings defined in doc
|
|
|
|
private static Boolean IsAcDcWarning(WarningMessage warning) => warning != WarningMessage.NoWarning;
|
|
|
|
|
|
|
|
private AcPhase L1 => AcPhase.FromVoltageCurrentActiveReactiveApparent
|
|
|
|
(
|
|
|
|
voltageRms : _Self.GridVoltageL1,
|
|
|
|
currentRms : _Self.GridCurrentL1,
|
|
|
|
activePower : _Self.ActivePowerL1,
|
|
|
|
reactivePower: _Self.ReactivePowerL1,
|
|
|
|
apparentPower: _Self.ApparentPowerL1
|
|
|
|
);
|
|
|
|
|
|
|
|
private AcPhase L2 => AcPhase.FromVoltageCurrentActiveReactiveApparent
|
|
|
|
(
|
|
|
|
voltageRms : _Self.GridVoltageL2,
|
|
|
|
currentRms : _Self.GridCurrentL2,
|
|
|
|
activePower : _Self.ActivePowerL2,
|
|
|
|
reactivePower: _Self.ReactivePowerL2,
|
|
|
|
apparentPower: _Self.ApparentPowerL2
|
|
|
|
);
|
|
|
|
|
|
|
|
private AcPhase L3 => AcPhase.FromVoltageCurrentActiveReactiveApparent
|
|
|
|
(
|
|
|
|
voltageRms : _Self.GridVoltageL3,
|
|
|
|
currentRms : _Self.GridCurrentL3,
|
|
|
|
activePower : _Self.ActivePowerL3,
|
|
|
|
reactivePower: _Self.ReactivePowerL3,
|
|
|
|
apparentPower: _Self.ApparentPowerL3
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
internal AcDcStatus(AcDcRecord self) => _Self = self;
|
|
|
|
private readonly AcDcRecord _Self;
|
|
|
|
|
|
|
|
}
|
|
|
|
|