fix division by 0 error
This commit is contained in:
parent
41e2c5b009
commit
52c275adaf
@ -42,7 +42,7 @@ public class Endpoint : EndpointWithoutRequest<object>
|
|||||||
BatteryVoltage = Random.Shared.Next(24),
|
BatteryVoltage = Random.Shared.Next(24),
|
||||||
BatteryChargeCurrent = Random.Shared.Next(20),
|
BatteryChargeCurrent = Random.Shared.Next(20),
|
||||||
BatteryDischargeCurrent = Random.Shared.Next(300),
|
BatteryDischargeCurrent = Random.Shared.Next(300),
|
||||||
PVInputVoltage = Random.Shared.Next(300),
|
PVInputVoltage = 0, //Random.Shared.Next(300),
|
||||||
PVInputWatt = Random.Shared.Next(1000),
|
PVInputWatt = Random.Shared.Next(1000),
|
||||||
PV_MaxCapacity = 1000,
|
PV_MaxCapacity = 1000,
|
||||||
BatteryCapacity = 100
|
BatteryCapacity = 100
|
||||||
|
|||||||
@ -25,7 +25,7 @@ public class InverterStatus
|
|||||||
public int BatteryDischargeCurrent { get; set; }
|
public int BatteryDischargeCurrent { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("g")]
|
[JsonPropertyName("g")]
|
||||||
public int BatteryDischargePotential => BatteryDischargeCurrent > 0 ? Convert.ToInt32(Convert.ToDouble(BatteryDischargeCurrent) / BatteryCapacity * 100) : 0;
|
public int BatteryDischargePotential => BatteryDischargeCurrent == 0 ? 00 : Convert.ToInt32(Convert.ToDouble(BatteryDischargeCurrent) / BatteryCapacity * 100);
|
||||||
|
|
||||||
[JsonPropertyName("h")]
|
[JsonPropertyName("h")]
|
||||||
public int BatteryDischargeWatts { get; set; }
|
public int BatteryDischargeWatts { get; set; }
|
||||||
@ -55,7 +55,7 @@ public class InverterStatus
|
|||||||
public double OutputVoltage { get; set; }
|
public double OutputVoltage { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("q")]
|
[JsonPropertyName("q")]
|
||||||
public double PVInputCurrent => PVInputWatt == 0 ? 0 : Math.Round(PVInputWatt / PVInputVoltage, 1);
|
public double PVInputCurrent => PVInputWatt == 0 || PVInputVoltage == 0 ? 0 : Math.Round(PVInputWatt / PVInputVoltage, 1);
|
||||||
|
|
||||||
[JsonPropertyName("r")]
|
[JsonPropertyName("r")]
|
||||||
public double PVInputVoltage { get; set; }
|
public double PVInputVoltage { get; set; }
|
||||||
@ -83,7 +83,7 @@ public class InverterStatus
|
|||||||
public int PV_MaxCapacity { get; set; }
|
public int PV_MaxCapacity { get; set; }
|
||||||
|
|
||||||
[JsonPropertyName("u")]
|
[JsonPropertyName("u")]
|
||||||
public int PVPotential => PVInputWatt > 0 ? Convert.ToInt32(Convert.ToDouble(PVInputWatt) / PV_MaxCapacity * 100) : 0;
|
public int PVPotential => PVInputWatt == 0 ? 0 : Convert.ToInt32(Convert.ToDouble(PVInputWatt) / PV_MaxCapacity * 100);
|
||||||
|
|
||||||
[JsonPropertyName("v")]
|
[JsonPropertyName("v")]
|
||||||
public ChargeMode ChargeMode { get; set; }
|
public ChargeMode ChargeMode { get; set; }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user