From 83cd63d3909ec7a87f93a2aeb720eede330e7c9f Mon Sep 17 00:00:00 2001 From: ig Date: Mon, 3 Jul 2023 15:57:49 +0200 Subject: [PATCH] Better Error Messages for failing devices --- csharp/Lib/Devices/Battery48TL/Battery48TlDevices.cs | 6 ++++-- csharp/Lib/Devices/EmuMeter/EmuMeterDevice.cs | 6 +++--- .../Devices/Trumpf/TruConvertDc/TruConvertDcDcDevices.cs | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/csharp/Lib/Devices/Battery48TL/Battery48TlDevices.cs b/csharp/Lib/Devices/Battery48TL/Battery48TlDevices.cs index 44108e6fa..19b636678 100644 --- a/csharp/Lib/Devices/Battery48TL/Battery48TlDevices.cs +++ b/csharp/Lib/Devices/Battery48TL/Battery48TlDevices.cs @@ -18,11 +18,13 @@ public class Battery48TlDevices return new Battery48TlRecords(records); } - catch (Exception e) + catch { - Console.WriteLine(e); + //Console.WriteLine(e); // TODO: log + "Failed to read Battery data".WriteLine(); + return Battery48TlRecords.Null; } diff --git a/csharp/Lib/Devices/EmuMeter/EmuMeterDevice.cs b/csharp/Lib/Devices/EmuMeter/EmuMeterDevice.cs index 9bf0ec45b..80c460a8d 100644 --- a/csharp/Lib/Devices/EmuMeter/EmuMeterDevice.cs +++ b/csharp/Lib/Devices/EmuMeter/EmuMeterDevice.cs @@ -1,6 +1,7 @@ using InnovEnergy.Lib.Protocols.Modbus.Channels; using InnovEnergy.Lib.Protocols.Modbus.Clients; using InnovEnergy.Lib.Protocols.Modbus.Slaves; +using InnovEnergy.Lib.Utils; namespace InnovEnergy.Lib.Devices.EmuMeter; @@ -25,10 +26,9 @@ public class EmuMeterDevice: ModbusDevice { return base.Read(); } - catch (Exception e) + catch { - // TODO: Log - Console.WriteLine(e); + "Failed to read data from Inverters".WriteLine(); return null; } } diff --git a/csharp/Lib/Devices/Trumpf/TruConvertDc/TruConvertDcDcDevices.cs b/csharp/Lib/Devices/Trumpf/TruConvertDc/TruConvertDcDcDevices.cs index 54c374dce..edd7a8bdf 100644 --- a/csharp/Lib/Devices/Trumpf/TruConvertDc/TruConvertDcDcDevices.cs +++ b/csharp/Lib/Devices/Trumpf/TruConvertDc/TruConvertDcDcDevices.cs @@ -58,9 +58,9 @@ public class TruConvertDcDcDevices return new DcDcDevicesRecord(scStatus, dcDcRecords); } - catch (Exception e) + catch { - Console.WriteLine(e); + "Failed to read DCDC data".WriteLine(); return new DcDcDevicesRecord(scStatus, Array.Empty()); } }