308 lines
11 KiB
C#
308 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 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 Int32 MeterPower => _MeterPower;
|
|
public ActivePower GridMeterPower => _GridPower;
|
|
|
|
public Int32 BatteryPower1
|
|
{
|
|
get => _BatteryPower1;
|
|
set => _BatteryPower1 = value;
|
|
}
|
|
|
|
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 OperatingPriority => (OperatingPriority)_OperatingPriority;
|
|
|
|
public UInt16 FaultMainCode => _FaultMainCode; // need to pre proceesed
|
|
public UInt16 FaultSubCode => _FaultSubCode; // need to pre proceesed
|
|
public UInt16 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 DcPower Pv1InpuPower => _Pv1InpuPower;
|
|
|
|
// ********************************** 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 ControlPermession
|
|
{
|
|
get => _ControlPermession;
|
|
set => _ControlPermession = 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 UInt16 PowerFactor
|
|
{
|
|
get => _PowerFactor;
|
|
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 Percent ChargeCutoffSoc
|
|
{
|
|
get => _ChargeCutoffSoc;
|
|
set => _ChargeCutoffSoc = (UInt16)value;
|
|
}
|
|
|
|
public Percent DischargeCutoffSoc
|
|
{
|
|
get => _DischargeCutoffSoc;
|
|
set => _DischargeCutoffSoc = (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 BatteryChargeCutoffVoltage
|
|
{
|
|
get => _BatteryChargeCutoffVoltage;
|
|
set => _BatteryChargeCutoffVoltage = value;
|
|
}
|
|
|
|
public UInt16 BatteryDischargeCutoffVoltage
|
|
{
|
|
get => _BatteryDischargeCutoffVoltage;
|
|
set => _BatteryDischargeCutoffVoltage = value;
|
|
}
|
|
|
|
public Double BatteryMaxChargeCurrent
|
|
{
|
|
get => _BatteryMaxChargeCurrent;
|
|
set => _BatteryMaxChargeCurrent = (UInt16)value;
|
|
}
|
|
|
|
public Double BatteryMaxdischargeCurrent
|
|
{
|
|
get => _BatteryMaxdischargeCurrent;
|
|
set => _BatteryMaxdischargeCurrent = (UInt16) value;
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
public IReadOnlyList<BatteryRecord> Batteries => new List<BatteryRecord>
|
|
{
|
|
new BatteryRecord
|
|
{
|
|
Soc = _BatterySoc1,
|
|
Soh = _BatterySoh1,
|
|
//ClusterTotalNumber = _ClusterTotalNumber1,
|
|
Current = _BatteryCurrent1,
|
|
Voltage = _BatteryVoltage1,
|
|
Power = _BatteryPower1,
|
|
MaxAllowableChargePower = _BatteryMaxAllowableChargePower1,
|
|
MaxAllowableDischargePower = _BatteryMaxAllowableDischargePower1,
|
|
DailyChargeEnergy = _DailyChargeEnergy1,
|
|
DailyDischargeEnergy = _DailyDischargeEnergy1,
|
|
AccumulatedChargeEnergy = _AccumulatedChargeEnergy1,
|
|
AccumulatedDischargeEnergy = _AccumulatedDishargeEnergy1,
|
|
BatteryAmbientTemperature = _BatteryAmbientTemperature1
|
|
|
|
},
|
|
/*
|
|
new BatteryRecord
|
|
{
|
|
Soc = _BatterySoc2,
|
|
Soh = _BatterySoh2,
|
|
// ClusterTotalNumber = _ClusterTotalNumber2,
|
|
Current = _BatteryCurrent2,
|
|
Voltage = _BatteryVoltage2,
|
|
Power = _BatteryPower2,
|
|
MaxAllowableChargePower = _BatteryMaxAllowableChargePower2,
|
|
MaxAllowableDischargePower = _BatteryMaxAllowableDischargePower2,
|
|
DailyChargeEnergy = _DailyChargeEnergy2,
|
|
DailyDischargeEnergy = _DailyDischargeEnergy2,
|
|
AccumulatedChargeEnergy = _AccumulatedChargeEnergy2,
|
|
AccumulatedDischargeEnergy = _AccumulatedDischargeEnergy2,
|
|
BatteryAmbientTemperature = _BatteryAmbientTemperature2
|
|
|
|
},*/
|
|
/*
|
|
new BatteryRecord
|
|
{
|
|
Soc = _BatterySoc3,
|
|
Soh = _BatterySoh3,
|
|
ClusterTotalNumber = _ClusterTotalNumber3,
|
|
Current = _BatteryCurrent3,
|
|
Voltage = _BatteryVoltage3,
|
|
Power = _BatteryPower3,
|
|
MaxAllowableChargePower = _BatteryMaxAllowableChargePower3,
|
|
MaxAllowableDischargePower = _BatteryMaxAllowableDischargePower3,
|
|
DailyChargeEnergy = _DailyChargeEnergy3,
|
|
DailyDischargeEnergy = _DailyDischargeEnergy3
|
|
},
|
|
|
|
new BatteryRecord
|
|
{
|
|
Soc = _BatterySoc4,
|
|
Soh = _BatterySoh4,
|
|
ClusterTotalNumber = _ClusterTotalNumber4,
|
|
Current = _BatteryCurrent4,
|
|
Voltage = _BatteryVoltage4,
|
|
Power = _BatteryPower4,
|
|
MaxAllowableChargePower = _BatteryMaxAllowableChargePower4,
|
|
MaxAllowableDischargePower = _BatteryMaxAllowableDischargePower4,
|
|
DailyChargeEnergy = _DailyChargeEnergy4,
|
|
DailyDischargeEnergy = _DailyDischargeEnergy4
|
|
}*/
|
|
};
|
|
public BatteriesRecord? BatteriesRecords => BatteriesRecord.FromBatteries(Batteries);
|
|
}
|