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;
|
2023-09-01 12:52:09 +00:00
|
|
|
using AlarmMessage = InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.DataTypes.AlarmMessage;
|
2023-06-13 11:01:01 +00:00
|
|
|
using WarningMessage = InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.DataTypes.WarningMessage;
|
2023-09-01 12:52:09 +00:00
|
|
|
using static System.Math;
|
2023-06-13 11:01:01 +00:00
|
|
|
|
|
|
|
namespace InnovEnergy.Lib.Devices.Trumpf.TruConvertAc.Status;
|
|
|
|
|
|
|
|
public class AcDcStatus
|
|
|
|
{
|
2023-09-01 06:54:46 +00:00
|
|
|
public Ac3Bus Ac => new Ac3Bus { L1 = L1, L2 = L2, L3 = L3, Frequency = _Self.GridFrequency };
|
2023-06-13 11:01:01 +00:00
|
|
|
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;
|
2023-09-01 06:54:46 +00:00
|
|
|
|
|
|
|
private AcPhase L1 => new()
|
|
|
|
{
|
2023-09-01 12:52:09 +00:00
|
|
|
Current = Abs(_Self.GridCurrentL1),
|
|
|
|
Voltage = Abs(_Self.GridVoltageL1),
|
2023-09-01 06:54:46 +00:00
|
|
|
Phi = Atan2(_Self.ReactivePowerL1, _Self.ActivePowerL1)
|
|
|
|
};
|
|
|
|
|
|
|
|
private AcPhase L2 => new()
|
|
|
|
{
|
2023-09-01 12:52:09 +00:00
|
|
|
Current = Abs(_Self.GridCurrentL2),
|
|
|
|
Voltage = Abs(_Self.GridVoltageL2),
|
2023-09-01 06:54:46 +00:00
|
|
|
Phi = Atan2(_Self.ReactivePowerL2, _Self.ActivePowerL2)
|
|
|
|
};
|
|
|
|
|
|
|
|
private AcPhase L3 => new()
|
|
|
|
{
|
2023-09-01 12:52:09 +00:00
|
|
|
Current = Abs(_Self.GridCurrentL3),
|
|
|
|
Voltage = Abs(_Self.GridVoltageL3),
|
2023-09-01 06:54:46 +00:00
|
|
|
Phi = Atan2(_Self.ReactivePowerL3, _Self.ActivePowerL3)
|
|
|
|
};
|
2023-06-13 11:01:01 +00:00
|
|
|
|
|
|
|
internal AcDcStatus(AcDcRecord self) => _Self = self;
|
|
|
|
private readonly AcDcRecord _Self;
|
|
|
|
}
|
|
|
|
|