Skip to content

Commit

Permalink
increase inverter communication fault tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
dj-nitehawk committed Jul 24, 2022
1 parent c1e66d4 commit 12caf3f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 27 deletions.
11 changes: 7 additions & 4 deletions src/Server/InverterService/Commands/GetChargeAmpereValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ public GetChargeAmpereValues(bool getUtilityValues)

public override void Parse(string responseFromInverter)
{
var parts = responseFromInverter[1..]
.Split(' ', StringSplitOptions.RemoveEmptyEntries)
.Select(x => x[0..3]);
if (IsCommandSuccessful(responseFromInverter))
{
var parts = responseFromInverter[1..]
.Split(' ', StringSplitOptions.RemoveEmptyEntries)
.Select(x => x[0..3]);

Result.AddRange(parts);
Result.AddRange(parts);
}
}
}
15 changes: 9 additions & 6 deletions src/Server/InverterService/Commands/GetSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ public override void Parse(string responseFromInverter)
// 24) 0 - pv ok for parallel
// 25) 1 - pv power balance

string[]? parts = responseFromInverter[1..]
.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (IsCommandSuccessful(responseFromInverter))
{
string[]? parts = responseFromInverter[1..]
.Split(' ', StringSplitOptions.RemoveEmptyEntries);

Result.MaxACChargeCurrent = parts[14 - 1];
Result.MaxCombinedChargeCurrent = parts[15 - 1];
Result.OutputPriority = $"0{parts[17 - 1]}";
Result.ChargePriority = $"0{parts[18 - 1]}";
Result.MaxACChargeCurrent = parts[14 - 1];
Result.MaxCombinedChargeCurrent = parts[15 - 1];
Result.OutputPriority = $"0{parts[17 - 1]}";
Result.ChargePriority = $"0{parts[18 - 1]}";
}
}
}
29 changes: 16 additions & 13 deletions src/Server/InverterService/Commands/GetStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ public override void Parse(string responseFromInverter)
{
//(232.0 50.1 232.0 50.1 0000 0000 000 476 27.02 000 100 0553 0000 000.0 27.00 00000 10011101 03 04 00000 101a\xc8\r

string[]? parts = responseFromInverter[1..]
.Split(' ', StringSplitOptions.RemoveEmptyEntries);
if (IsCommandSuccessful(responseFromInverter))
{
string[]? parts = responseFromInverter[1..]
.Split(' ', StringSplitOptions.RemoveEmptyEntries);

Result.GridVoltage = decimal.Parse(parts[0]);
Result.OutputVoltage = decimal.Parse(parts[2]);
Result.LoadWatts = int.Parse(parts[5]);
Result.LoadPercentage = decimal.Parse(parts[6]);
Result.BatteryVoltage = decimal.Parse(parts[8]);
Result.BatteryChargeCurrent = int.Parse(parts[9]);
Result.HeatSinkTemperature = int.Parse(parts[11]);
Result.PVInputCurrent = decimal.Parse(parts[12]);
Result.PVInputVoltage = decimal.Parse(parts[13]);
Result.BatteryDischargeCurrent = int.Parse(parts[15]);
Result.PVInputWatt = Convert.ToInt32(int.Parse(parts[19]) / 1.09);
Result.GridVoltage = decimal.Parse(parts[0]);
Result.OutputVoltage = decimal.Parse(parts[2]);
Result.LoadWatts = int.Parse(parts[5]);
Result.LoadPercentage = decimal.Parse(parts[6]);
Result.BatteryVoltage = decimal.Parse(parts[8]);
Result.BatteryChargeCurrent = int.Parse(parts[9]);
Result.HeatSinkTemperature = int.Parse(parts[11]);
Result.PVInputCurrent = decimal.Parse(parts[12]);
Result.PVInputVoltage = decimal.Parse(parts[13]);
Result.BatteryDischargeCurrent = int.Parse(parts[15]);
Result.PVInputWatt = Convert.ToInt32(int.Parse(parts[19]) / 1.09);
}
}
}
5 changes: 1 addition & 4 deletions src/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
## changelog
- optimize connection retry attempt logic
- optimize settings retrieval
- tabbed view for settings ui
- lock culture to `en-US` at startup
- increase inverter communication fault tolerance

0 comments on commit 12caf3f

Please sign in to comment.