One try catch instead of two for DcDcDeviceRecord Read()
This commit is contained in:
parent
b213d97537
commit
c51250a380
|
@ -6,15 +6,15 @@ namespace InnovEnergy.Lib.Devices.Battery48TL;
|
||||||
|
|
||||||
public class Battery48TlRecords
|
public class Battery48TlRecords
|
||||||
{
|
{
|
||||||
public required DcBus Dc { get; init; }
|
public required DcBus Dc { get; init; }
|
||||||
public required Boolean Eoc { get; init; }
|
public required Boolean Eoc { get; init; }
|
||||||
public required IReadOnlyList<String> Warnings { get; init; }
|
public required IReadOnlyList<String> Warnings { get; init; }
|
||||||
public required IReadOnlyList<String> Alarms { get; init; }
|
public required IReadOnlyList<String> Alarms { get; init; }
|
||||||
public required Percent Soc { get; init; }
|
public required Percent Soc { get; init; }
|
||||||
public required Percent CurrentMinSoc { get; init; }
|
public required Percent CurrentMinSoc { get; init; }
|
||||||
public required Temperature Temperature { get; init; }
|
public required Temperature Temperature { get; init; }
|
||||||
public required DcPower HeatingPower { get; init; }
|
public required DcPower HeatingPower { get; init; }
|
||||||
public required UInt16 TimeSinceToc { get; init; }
|
public required UInt16 TimeSinceToc { get; init; }
|
||||||
public required Boolean CalibrationChargeRequested { get; init; }
|
public required Boolean CalibrationChargeRequested { get; init; }
|
||||||
|
|
||||||
public required IReadOnlyList<Battery48TlRecord> Devices { get; init; }
|
public required IReadOnlyList<Battery48TlRecord> Devices { get; init; }
|
||||||
|
|
|
@ -35,22 +35,12 @@ public class TruConvertDcDcDevices
|
||||||
|
|
||||||
public DcDcDevicesRecord Read()
|
public DcDcDevicesRecord Read()
|
||||||
{
|
{
|
||||||
SystemControlRegisters? scStatus;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
scStatus = _SystemControl.Read();
|
var scStatus = _SystemControl.Read();
|
||||||
}
|
var n = scStatus.NumberOfConnectedSlaves;
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Console.WriteLine(e);
|
|
||||||
return DcDcDevicesRecord.Null;
|
|
||||||
}
|
|
||||||
|
|
||||||
var n = scStatus.NumberOfConnectedSlaves;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var dcDcRecords = _DcDcs
|
var dcDcRecords = _DcDcs
|
||||||
.Take(n)
|
.Take(n)
|
||||||
.Select(dcdc => dcdc.Read())
|
.Select(dcdc => dcdc.Read())
|
||||||
|
@ -61,7 +51,7 @@ public class TruConvertDcDcDevices
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
"Failed to read DCDC data".WriteLine();
|
"Failed to read DCDC data".WriteLine();
|
||||||
return new DcDcDevicesRecord(scStatus, Array.Empty<DcDcRecord>());
|
return new DcDcDevicesRecord(null, Array.Empty<DcDcRecord>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue