285 lines
11 KiB
C#
285 lines
11 KiB
C#
|
|
using System.ComponentModel;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using InnovEnergy.Lib.Devices.WITGrowatt4_15K.DataType;
|
|
using InnovEnergy.Lib.Units;
|
|
using InnovEnergy.Lib.Units.Power;
|
|
|
|
namespace InnovEnergy.Lib.Devices.WITGrowatt4_15K;
|
|
|
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
|
[SuppressMessage("ReSharper", "ConvertToAutoProperty")]
|
|
public partial class WITGrowatRecord
|
|
{
|
|
// private List<BatteryRecord> Batteries { get; set; } = new();
|
|
//public BatteriesRecord? BatteriesRecords => BatteriesRecord.FromBatteries(Batteries);
|
|
|
|
|
|
public ActivePower ConsumptionPower => GridPower + InverterActivePower ;
|
|
public ActivePower InverterActivePower => _activePower;
|
|
public ReactivePower InverterReactivePower => _reactivePower;
|
|
public Frequency Frequency => _frequency;
|
|
|
|
public VoltageRms GridAbLineVoltage => _GridAbLineVoltage;
|
|
public VoltageRms GridBcLineVoltage => _GridBcLineVoltage;
|
|
public VoltageRms GridCaLineVoltage => _GridCaLineVoltage;
|
|
public CurrentRms PhaseACurrent => _PhaseACurrent;
|
|
public CurrentRms PhaseBCurrent => _PhaseBCurrent;
|
|
public CurrentRms PhaseCCurrent => _PhaseCCurrent;
|
|
|
|
public ActivePower GridPower => _importedPowerFromGrid - _exportedPowerToGrid;
|
|
public ActivePower ExportedPowerToGridMeter => _exportedPowerToGrid;
|
|
public ActivePower ImportedPowerFromGrid => _importedPowerFromGrid;
|
|
|
|
public Temperature InverterTemperature => _InverterTemperature;
|
|
|
|
public Energy EnergyToUser => _EnergyToUser;
|
|
public Energy TotalEnergyToUser => _TotalEnergyToUser;
|
|
public Energy EnergyToGrid => _EnergyToGrid;
|
|
public Energy TotalEnergyToGrid => _TotalEnergyToGrid;
|
|
|
|
public GrowattSystemStatus SystemOperatingMode => (GrowattSystemStatus)_systemOperatingMode;
|
|
public BatteryoperatinStatus BatteryOperatingMode => (BatteryoperatinStatus) _batteryOperatingMode;
|
|
public OperatingPriority OperatingMode => (OperatingPriority)_operatingPriority;
|
|
|
|
public GrowattErrorCode FaultMainCode => _faultMainCode; // need to pre proceesed
|
|
public UInt16 FaultSubCode => _faultSubCode; // need to pre proceesed
|
|
public GrowattWarningCode WarningMainCode => _warningMainCode; // need to pre proceesed
|
|
public UInt16 WarningSubCode => _warningSubCode; // need to pre proceesed
|
|
|
|
public Voltage Pv1Voltage => _pv1Voltage;
|
|
public Current Pv1Current => _pv1Current;
|
|
public Voltage Pv2Voltage => _pv2Voltage;
|
|
public Current Pv2Current => _pv2Current;
|
|
public Voltage Pv3Voltage => _pv3Voltage;
|
|
public Current Pv3Current => _pv3Current;
|
|
public Voltage Pv4Voltage => _pv4Voltage;
|
|
public Current Pv4Current => _pv4Current;
|
|
public Voltage Pv5Voltage => _pv5Voltage;
|
|
public Current Pv5Current => _pv5Current;
|
|
public Voltage Pv6Voltage => _pv6Voltage;
|
|
public Current Pv6Current => _pv6Current;
|
|
|
|
|
|
public DcPower Pv1InpuPower => _pv1InpuPower;
|
|
|
|
|
|
public DcPower PvPower => (Pv1Voltage * Pv1Current) + (Pv2Voltage * Pv2Current) +
|
|
(Pv3Voltage * Pv3Current) + (Pv4Voltage * Pv4Current) +
|
|
(Pv5Voltage * Pv5Current) + (Pv6Voltage * Pv6Current);
|
|
// ********************************** Holding Registers (Control) *************************************************************
|
|
|
|
|
|
// public UInt16 DeviceModel => _DeviceModel;
|
|
public UInt32 RatedPower
|
|
{
|
|
get => _ratedPower;
|
|
}
|
|
|
|
public UInt32 MaxActivePower
|
|
{
|
|
get => _MaxActivePower;
|
|
}
|
|
|
|
public UInt32 PvInputMaxPower
|
|
{
|
|
get => _PvInputMaxPower;
|
|
}
|
|
|
|
public UInt16 BatteryType
|
|
{
|
|
get => _BatteryType;
|
|
}
|
|
|
|
public UInt16 VppProtocolVerNumber
|
|
{
|
|
get => _VppProtocolVerNumber;
|
|
}
|
|
|
|
public Boolean ControlPermission
|
|
{
|
|
get => _ControlPermission;
|
|
set => _ControlPermission = value;
|
|
}
|
|
|
|
public Boolean EnableCommand
|
|
{
|
|
get => _EnableCommand;
|
|
set => _EnableCommand = value;
|
|
}
|
|
|
|
public DateTime SystemDateTime
|
|
{
|
|
get
|
|
{
|
|
var systemTime1 = _SystemTime1 + 2000; // We add 2000 years to fit a correct epoch time
|
|
return new DateTime(systemTime1, _SystemTime2, _SystemTime3, _SystemTime4, _SystemTime5,
|
|
_SystemTime6);
|
|
}
|
|
}
|
|
|
|
/* public Boolean EnableSyn
|
|
{
|
|
get => _EnableSyn ;
|
|
set => _EnableSyn = value;
|
|
}*/
|
|
|
|
public Percent ActivePowerPercentDerating
|
|
{
|
|
get => _ActivePowerPercentDerating;
|
|
set => _ActivePowerPercentDerating = (UInt16)value;
|
|
}
|
|
|
|
public Percent ActivePowerPercent
|
|
{
|
|
get => _ActivePowerPercent;
|
|
set => _ActivePowerPercent = (UInt16)value;
|
|
}
|
|
public Double PowerFactor
|
|
{
|
|
get => (_PowerFactor - 10000) * 0.0001;
|
|
//set => _PowerFactor = value;
|
|
|
|
}
|
|
|
|
public UInt16 EmsCommunicationFailureTime
|
|
{
|
|
get => _EmsCommunicationFailureTime;
|
|
set => _EmsCommunicationFailureTime = value;
|
|
}
|
|
|
|
public Boolean EnableEmsCommunicationFailureTime
|
|
{
|
|
get => _EnableEmsCommunicationFailureTime;
|
|
set => _EnableEmsCommunicationFailureTime = value;
|
|
}
|
|
|
|
public UInt16 BatteryClusterIndex
|
|
{
|
|
get => _BatteryClusterIndex;
|
|
set => _BatteryClusterIndex = value;
|
|
}
|
|
|
|
public UInt32 BatteryMaxChargePower
|
|
{
|
|
get => _BatteryMaxChargePower;
|
|
set => _BatteryMaxChargePower = value;
|
|
}
|
|
|
|
public UInt32 BatteryMaxDischargePower
|
|
{
|
|
get => _BatteryMaxDischargePower;
|
|
set => _BatteryMaxDischargePower = value;
|
|
}
|
|
|
|
public Voltage ChargeCutoffSocVoltage
|
|
{
|
|
get => _batteryChargeCutoffVoltage;
|
|
set => _batteryChargeCutoffVoltage = (UInt16)value;
|
|
}
|
|
|
|
public Voltage DischargeCutoffVoltage
|
|
{
|
|
get => _batteryDischargeCutoffVoltage;
|
|
set => _batteryDischargeCutoffVoltage = (UInt16)value;
|
|
}
|
|
|
|
public Percent LoadPriorityDischargeCutoffSoc
|
|
{
|
|
get => _LoadPriorityDischargeCutoffSoc;
|
|
set => _LoadPriorityDischargeCutoffSoc = (UInt16)value;
|
|
}
|
|
|
|
public Boolean RemotePowerControl
|
|
{
|
|
get => _RemotePowerControl;
|
|
set => _RemotePowerControl = value;
|
|
}
|
|
|
|
public UInt16 RemotePowerControlChargeDuration
|
|
{
|
|
get => _RemotePowerControlChargeDuration;
|
|
set => _RemotePowerControlChargeDuration = value;
|
|
}
|
|
|
|
public Int16 RemoteChargDischargePower
|
|
{
|
|
get => _RemoteChargDischargePower;
|
|
set => _RemoteChargDischargePower = (Int16)value;
|
|
}
|
|
|
|
public Boolean AcChargeEnable
|
|
{
|
|
get => _AcChargeEnable;
|
|
set => _AcChargeEnable = value;
|
|
}
|
|
|
|
public Percent ActualChargeDischargePowerControlValue
|
|
{
|
|
get => _ActualChargeDischargePowerControlValue;
|
|
}
|
|
|
|
public Percent OffGridDischargeCutoffSoc
|
|
{
|
|
get => _OffGridDischargeCutoffSoc;
|
|
set => _OffGridDischargeCutoffSoc = (UInt16)(value);
|
|
}
|
|
|
|
public UInt16 MaxSoc
|
|
{
|
|
get => _maxSoc;
|
|
set => _maxSoc = value;
|
|
}
|
|
|
|
public UInt16 MinSoc
|
|
{
|
|
get => _minSoc;
|
|
set => _minSoc = value;
|
|
}
|
|
|
|
public Double BatteryMaxChargingCurrent
|
|
{
|
|
get => _batteryMaxChargingCurrent;
|
|
set => _batteryMaxChargingCurrent = (UInt16)value;
|
|
}
|
|
|
|
public Double BatteryMaxDischargingCurrent
|
|
{
|
|
get => _batteryMaxDischargingCurrent;
|
|
set => _batteryMaxDischargingCurrent = (UInt16) value;
|
|
}
|
|
|
|
public Double Battery1MaxDischargingCurrent => _batteryMaxDischargingCurrent;
|
|
public Double Battery1MaxChargingCurrent => _batteryMaxChargingCurrent;
|
|
|
|
public Percent Battery1Soc => _BatterySoc1;
|
|
public Percent Battery1Soh => _BatterySoh1;
|
|
public Current Battery1Current => _BatteryCurrent1;
|
|
public Voltage Battery1Voltage => _BatteryVoltage1;
|
|
public ActivePower Battery1Power => _BatteryPower1;
|
|
public ActivePower Battery1MaxAllowableChargePower => _BatteryMaxAllowableChargePower1;
|
|
public ActivePower Battery1MaxAllowableDischargePower => _BatteryMaxAllowableDischargePower1;
|
|
public Energy Battery1DailyChargeEnergy => _DailyChargeEnergy1;
|
|
public Energy Battery1DailyDischargeEnergy => _DailyDischargeEnergy1;
|
|
public Energy Battery1AccumulatedChargeEnergy => _AccumulatedChargeEnergy1;
|
|
public Energy Battery1AccumulatedDischargeEnergy => _AccumulatedDishargeEnergy1;
|
|
public Temperature Battery1AmbientTemperature => _BatteryAmbientTemperature1;
|
|
|
|
public Percent Battery2Soc => _BatterySoc2;
|
|
public Percent Battery2Soh => _BatterySoh2;
|
|
public Current Battery2Current => _BatteryCurrent2;
|
|
public Voltage Battery2Voltage => _BatteryVoltage2;
|
|
public ActivePower Battery2Power => _batteryPower2;
|
|
public ActivePower Battery2MaxAllowableChargePower => _BatteryMaxAllowableChargePower2;
|
|
public ActivePower Battery2MaxAllowableDischargePower => _BatteryMaxAllowableDischargePower2;
|
|
public Energy Battery2DailyChargeEnergy => _DailyChargeEnergy2;
|
|
public Energy Battery2DailyDischargeEnergy => _DailyDischargeEnergy2;
|
|
public Energy Battery2AccumulatedChargeEnergy => _AccumulatedChargeEnergy2;
|
|
public Energy Battery2AccumulatedDischargeEnergy => _AccumulatedDischargeEnergy2;
|
|
public Temperature Battery2AmbientTemperature => _BatteryAmbientTemperature2;
|
|
|
|
public Energy BatteryDailyChargeEnergy => _DailyChargeEnergy1 + _DailyChargeEnergy2;
|
|
public Energy BatteryDailyDischargeEnergy => _DailyDischargeEnergy1 + _DailyDischargeEnergy2;
|
|
|
|
}
|